From d2a0f50424ebb554953c069614175df1e3a3f8da Mon Sep 17 00:00:00 2001 From: Lincoln <778157949@qq.com> Date: Wed, 15 Jan 2025 08:38:36 +0000 Subject: [PATCH 1/9] A new plugin to create a symbolic link for a package. --- .../main_2025-01-15-08-38.json | 10 ++ common/config/rush/pnpm-lock.yaml | 47 +++++++++ .../rush-link-project-plugin/.eslintrc.js | 14 +++ .../rush-link-project-plugin/.gitignore | 1 + .../rush-link-project-plugin/.npmignore | 35 +++++++ .../rush-link-project-plugin/CHANGELOG.json | 22 +++++ .../rush-link-project-plugin/CHANGELOG.md | 11 +++ rush-plugins/rush-link-project-plugin/LICENSE | 21 ++++ .../rush-link-project-plugin/README.md | 25 +++++ .../command-line.json | 22 +++++ .../rush-link-project-plugin/config/rig.json | 7 ++ .../lint-staged.config.cjs | 5 + .../rush-link-project-plugin/package.json | 42 ++++++++ .../rush-plugin-manifest.json | 10 ++ .../rush-link-project-plugin/src/constants.ts | 5 + .../rush-link-project-plugin/src/index.ts | 52 ++++++++++ .../rush-link-project-plugin/src/utils.ts | 18 ++++ .../rush-link-project-plugin/tsconfig.json | 97 +++++++++++++++++++ rush.json | 5 + 19 files changed, 449 insertions(+) create mode 100644 common/changes/rush-link-project-plugin/main_2025-01-15-08-38.json create mode 100644 rush-plugins/rush-link-project-plugin/.eslintrc.js create mode 100644 rush-plugins/rush-link-project-plugin/.gitignore create mode 100644 rush-plugins/rush-link-project-plugin/.npmignore create mode 100644 rush-plugins/rush-link-project-plugin/CHANGELOG.json create mode 100644 rush-plugins/rush-link-project-plugin/CHANGELOG.md create mode 100644 rush-plugins/rush-link-project-plugin/LICENSE create mode 100644 rush-plugins/rush-link-project-plugin/README.md create mode 100644 rush-plugins/rush-link-project-plugin/command-line.json create mode 100644 rush-plugins/rush-link-project-plugin/config/rig.json create mode 100644 rush-plugins/rush-link-project-plugin/lint-staged.config.cjs create mode 100644 rush-plugins/rush-link-project-plugin/package.json create mode 100644 rush-plugins/rush-link-project-plugin/rush-plugin-manifest.json create mode 100644 rush-plugins/rush-link-project-plugin/src/constants.ts create mode 100644 rush-plugins/rush-link-project-plugin/src/index.ts create mode 100644 rush-plugins/rush-link-project-plugin/src/utils.ts create mode 100644 rush-plugins/rush-link-project-plugin/tsconfig.json diff --git a/common/changes/rush-link-project-plugin/main_2025-01-15-08-38.json b/common/changes/rush-link-project-plugin/main_2025-01-15-08-38.json new file mode 100644 index 0000000..4469bd3 --- /dev/null +++ b/common/changes/rush-link-project-plugin/main_2025-01-15-08-38.json @@ -0,0 +1,10 @@ +{ + "changes": [ + { + "packageName": "rush-link-project-plugin", + "comment": "A new plugin to create a symbolic link for a package.", + "type": "minor" + } + ], + "packageName": "rush-link-project-plugin" +} \ No newline at end of file diff --git a/common/config/rush/pnpm-lock.yaml b/common/config/rush/pnpm-lock.yaml index bbbc1bc..a3d3489 100644 --- a/common/config/rush/pnpm-lock.yaml +++ b/common/config/rush/pnpm-lock.yaml @@ -307,6 +307,49 @@ importers: specifier: ~5.0.4 version: 5.0.4 + ../../rush-plugins/rush-link-project-plugin: + dependencies: + '@rushstack/node-core-library': + specifier: 3.62.0 + version: 3.62.0(@types/node@18.17.15) + '@rushstack/rush-sdk': + specifier: ^5.139.0 + version: 5.140.0(@types/node@18.17.15) + '@rushstack/terminal': + specifier: ~0.14.2 + version: 0.14.2(@types/node@18.17.15) + fs-extra: + specifier: ~10.1.0 + version: 10.1.0 + minimist: + specifier: ^1.2.8 + version: 1.2.8 + devDependencies: + '@rushstack/eslint-config': + specifier: 3.3.4 + version: 3.3.4(eslint@8.57.1)(typescript@5.0.4) + '@rushstack/heft': + specifier: 0.61.0 + version: 0.61.0(@types/node@18.17.15) + '@rushstack/heft-node-rig': + specifier: 2.2.25 + version: 2.2.25(@rushstack/heft@0.61.0)(@types/node@18.17.15)(ts-node@11.0.0-beta.1) + '@types/fs-extra': + specifier: ~9.0.13 + version: 9.0.13 + '@types/heft-jest': + specifier: 1.0.1 + version: 1.0.1 + '@types/minimist': + specifier: 1.2.2 + version: 1.2.2 + '@types/node': + specifier: 18.17.15 + version: 18.17.15 + typescript: + specifier: ~5.0.4 + version: 5.0.4 + ../../rush-plugins/rush-lint-staged-plugin: dependencies: '@rushstack/node-core-library': @@ -1874,6 +1917,10 @@ packages: /@types/minimatch@5.1.2: resolution: {integrity: sha512-K0VQKziLUWkVKiRVrx4a40iPaxTUefQmjtkQofBkYRcoaaL/8rhwDWww9qWbrgicNOgnpIsMxyNIUM4+n6dUIA==} + /@types/minimist@1.2.2: + resolution: {integrity: sha512-jhuKLIRrhvCPLqwPcx6INqmKeiA5EWrsCOPhrlFSrbrmU4ZMPjj5Ul/oLCMDO98XRUIwVm78xICz4EPCektzeQ==} + dev: true + /@types/node-fetch@1.6.9: resolution: {integrity: sha512-n2r6WLoY7+uuPT7pnEtKJCmPUGyJ+cbyBR8Avnu4+m1nzz7DwBVuyIvvlBzCZ/nrpC7rIgb3D6pNavL7rFEa9g==} dependencies: diff --git a/rush-plugins/rush-link-project-plugin/.eslintrc.js b/rush-plugins/rush-link-project-plugin/.eslintrc.js new file mode 100644 index 0000000..259cbb5 --- /dev/null +++ b/rush-plugins/rush-link-project-plugin/.eslintrc.js @@ -0,0 +1,14 @@ +// This is a workaround for https://github.com/eslint/eslint/issues/3458 +require('@rushstack/eslint-config/patch/modern-module-resolution'); + +module.exports = { + extends: [ + '@rushstack/eslint-config/profile/node-trusted-tool', + '@rushstack/eslint-config/mixins/friendly-locals' + ], + parserOptions: { tsconfigRootDir: __dirname }, + ignorePatterns: ['node_modules/', 'lib/', 'jest.config.js'], + rules: { + '@typescript-eslint/no-explicit-any': 'off' + } +}; diff --git a/rush-plugins/rush-link-project-plugin/.gitignore b/rush-plugins/rush-link-project-plugin/.gitignore new file mode 100644 index 0000000..f1ff06d --- /dev/null +++ b/rush-plugins/rush-link-project-plugin/.gitignore @@ -0,0 +1 @@ +lib/ \ No newline at end of file diff --git a/rush-plugins/rush-link-project-plugin/.npmignore b/rush-plugins/rush-link-project-plugin/.npmignore new file mode 100644 index 0000000..cdad8ba --- /dev/null +++ b/rush-plugins/rush-link-project-plugin/.npmignore @@ -0,0 +1,35 @@ +# THIS IS A STANDARD TEMPLATE FOR .npmignore FILES IN THIS REPO. + +# Ignore all files by default, to avoid accidentally publishing unintended files. +* + +# Use negative patterns to bring back the specific things we want to publish. +!/bin/** +!/lib/** +!/lib-*/** +!/dist/** + +!CHANGELOG.md +!CHANGELOG.json +!heft-plugin.json +!rush-plugin-manifest.json +!ThirdPartyNotice.txt + +# Ignore certain patterns that should not get published. +/dist/*.stats.* +/lib/**/test/ +/lib-*/**/test/ +*.test.js + +# NOTE: These don't need to be specified, because NPM includes them automatically. +# +# package.json +# README.md +# LICENSE + +# --------------------------------------------------------------------------- +# DO NOT MODIFY ABOVE THIS LINE! Add any project-specific overrides below. +# --------------------------------------------------------------------------- + +!/includes/** +!command-line.json diff --git a/rush-plugins/rush-link-project-plugin/CHANGELOG.json b/rush-plugins/rush-link-project-plugin/CHANGELOG.json new file mode 100644 index 0000000..251b395 --- /dev/null +++ b/rush-plugins/rush-link-project-plugin/CHANGELOG.json @@ -0,0 +1,22 @@ +{ + "name": "rush-dep-graph-plugin", + "entries": [ + { + "version": "0.1.0", + "tag": "rush-dep-graph-plugin_v0.1.0", + "date": "Tue, 17 Dec 2024 03:42:09 GMT", + "comments": { + "minor": [ + { + "comment": "Create a `rush-dep-graph-plugin` Rush plugin to display the dependency graph." + } + ], + "none": [ + { + "comment": "Try to fix the CI issue" + } + ] + } + } + ] +} diff --git a/rush-plugins/rush-link-project-plugin/CHANGELOG.md b/rush-plugins/rush-link-project-plugin/CHANGELOG.md new file mode 100644 index 0000000..5b05d41 --- /dev/null +++ b/rush-plugins/rush-link-project-plugin/CHANGELOG.md @@ -0,0 +1,11 @@ +# Change Log - rush-dep-graph-plugin + +This log was last generated on Tue, 17 Dec 2024 03:42:09 GMT and should not be manually modified. + +## 0.1.0 +Tue, 17 Dec 2024 03:42:09 GMT + +### Minor changes + +- Create a `rush-dep-graph-plugin` Rush plugin to display the dependency graph. + diff --git a/rush-plugins/rush-link-project-plugin/LICENSE b/rush-plugins/rush-link-project-plugin/LICENSE new file mode 100644 index 0000000..3bd1dad --- /dev/null +++ b/rush-plugins/rush-link-project-plugin/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) TikTok Pte. Ltd. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/rush-plugins/rush-link-project-plugin/README.md b/rush-plugins/rush-link-project-plugin/README.md new file mode 100644 index 0000000..910e11f --- /dev/null +++ b/rush-plugins/rush-link-project-plugin/README.md @@ -0,0 +1,25 @@ +# rush-dep-graph-plugin + +A Rush plugin that displays the dependency graph. + +# Prerequisite + +Rush.js >= 5.83.2 + + +# Quick Start + +1. Enabling this rush plugin + +Please follow the [official doc](https://rushjs.io/pages/maintainer/using_rush_plugins/) to enable this plugin in your repo. + +2. Running `dep-graph` command + +``` +Usage: rush dep-graph [OPTIONS] + +Options: + -t, --to Select the packages that depend on specific project. + -f, --from Select the package that is dependent on specific package. + --filter Select the packages based on a custom filter criteria, such as specific keywords in the package name. +``` diff --git a/rush-plugins/rush-link-project-plugin/command-line.json b/rush-plugins/rush-link-project-plugin/command-line.json new file mode 100644 index 0000000..e051b09 --- /dev/null +++ b/rush-plugins/rush-link-project-plugin/command-line.json @@ -0,0 +1,22 @@ +{ + "$schema": "https://developer.microsoft.com/json-schemas/rush/v5/command-line.schema.json", + "commands": [ + { + "name": "link-project", + "commandKind": "global", + "summary": "Creates a symbolic link for a package", + "description": "Creates a symbolic link for a package", + "shellCommand": "ts-node common/autoinstallers/link-package/src/index.ts", + "autoinstallerName": "link-project" + } + ], + "parameters": [ + { + "parameterKind": "string", + "argumentName": "PATH", + "description": "The path to the package you want to link. This can be an absolute or relative path. If it's a relative path, it will be resolved from the current working directory.", + "longName": "--path", + "associatedCommands": ["link-project"] + } + ] +} diff --git a/rush-plugins/rush-link-project-plugin/config/rig.json b/rush-plugins/rush-link-project-plugin/config/rig.json new file mode 100644 index 0000000..6ac88a9 --- /dev/null +++ b/rush-plugins/rush-link-project-plugin/config/rig.json @@ -0,0 +1,7 @@ +{ + // The "rig.json" file directs tools to look for their config files in an external package. + // Documentation for this system: https://www.npmjs.com/package/@rushstack/rig-package + "$schema": "https://developer.microsoft.com/json-schemas/rig-package/rig.schema.json", + + "rigPackageName": "@rushstack/heft-node-rig" +} diff --git a/rush-plugins/rush-link-project-plugin/lint-staged.config.cjs b/rush-plugins/rush-link-project-plugin/lint-staged.config.cjs new file mode 100644 index 0000000..5db81b9 --- /dev/null +++ b/rush-plugins/rush-link-project-plugin/lint-staged.config.cjs @@ -0,0 +1,5 @@ +/* eslint-env es6 */ +const config = { + '*': "echo 'good job'" +}; +module.exports = config; diff --git a/rush-plugins/rush-link-project-plugin/package.json b/rush-plugins/rush-link-project-plugin/package.json new file mode 100644 index 0000000..da8d52d --- /dev/null +++ b/rush-plugins/rush-link-project-plugin/package.json @@ -0,0 +1,42 @@ +{ + "name": "rush-link-project-plugin", + "version": "0.1.0", + "description": "Creates a symbolic link for a package", + "keywords": [ + "rush", + "plugin", + "command", + "link" + ], + "homepage": "https://github.com/tiktok/rush-plugins#readme", + "repository": { + "type": "git", + "url": "https://github.com/tiktok/rush-plugins", + "directory": "rush-plugins/rush-link-project-plugin" + }, + "license": "MIT", + "main": "lib/index.js", + "scripts": { + "build": "heft build --clean", + "build:watch": "heft build --watch", + "prepublishOnly": "npm run build", + "test": "heft test" + }, + "dependencies": { + "@rushstack/node-core-library": "3.62.0", + "@rushstack/rush-sdk": "^5.139.0", + "@rushstack/terminal": "~0.14.2", + "fs-extra": "~10.1.0", + "minimist": "^1.2.8" + }, + "devDependencies": { + "@rushstack/eslint-config": "3.3.4", + "@rushstack/heft": "0.61.0", + "@rushstack/heft-node-rig": "2.2.25", + "@types/fs-extra": "~9.0.13", + "@types/heft-jest": "1.0.1", + "@types/minimist": "1.2.2", + "@types/node": "18.17.15", + "typescript": "~5.0.4" + } +} diff --git a/rush-plugins/rush-link-project-plugin/rush-plugin-manifest.json b/rush-plugins/rush-link-project-plugin/rush-plugin-manifest.json new file mode 100644 index 0000000..fd0cb78 --- /dev/null +++ b/rush-plugins/rush-link-project-plugin/rush-plugin-manifest.json @@ -0,0 +1,10 @@ +{ + "$schema": "https://developer.microsoft.com/json-schemas/rush/v5/rush-plugin-manifest.schema.json", + "plugins": [ + { + "pluginName": "link-project", + "description": "Creates a symbolic link for a package", + "commandLineJsonFilePath": "command-line.json" + } + ] +} diff --git a/rush-plugins/rush-link-project-plugin/src/constants.ts b/rush-plugins/rush-link-project-plugin/src/constants.ts new file mode 100644 index 0000000..e412a38 --- /dev/null +++ b/rush-plugins/rush-link-project-plugin/src/constants.ts @@ -0,0 +1,5 @@ +import { EnvironmentVariableNames } from '@rushstack/rush-sdk'; + +export const RUSH_EVOKE_FOLDER: string = process.env[EnvironmentVariableNames.RUSH_INVOKED_FOLDER] as string; + +export const PACKAGE_JSON: 'package.json' = 'package.json'; diff --git a/rush-plugins/rush-link-project-plugin/src/index.ts b/rush-plugins/rush-link-project-plugin/src/index.ts new file mode 100644 index 0000000..2e4e16a --- /dev/null +++ b/rush-plugins/rush-link-project-plugin/src/index.ts @@ -0,0 +1,52 @@ +import minimist from 'minimist'; +import path from 'path'; +import fs from 'fs'; +import { JsonFile, INodePackageJson } from '@rushstack/node-core-library'; +import { Colorize } from '@rushstack/terminal'; + +import { PACKAGE_JSON, RUSH_EVOKE_FOLDER } from './constants'; +import { lookUpPackageJson, logger } from './utils'; + +(async () => { + const argv: minimist.ParsedArgs = minimist(process.argv.slice(2)); + const targetPath: string = path.resolve(RUSH_EVOKE_FOLDER, argv.path); + const targetJsonPath: string = path.resolve(targetPath, PACKAGE_JSON); + + if (!fs.existsSync(targetJsonPath)) { + throw new Error(`Can not find ${PACKAGE_JSON} in the path ${argv.path}`); + } + + const originJsonPath: string | undefined = lookUpPackageJson(RUSH_EVOKE_FOLDER); + + if (!originJsonPath) { + throw new Error(`Cannot find ${PACKAGE_JSON} in the path ${RUSH_EVOKE_FOLDER}`); + } + + const packageJson: INodePackageJson = JsonFile.load(targetJsonPath); + + let packageName: string = packageJson.name; + let nodeModulesPath: string = path.resolve(originJsonPath, 'node_modules'); + if (packageName.includes('/')) { + const [scope, packageBaseName] = packageName.split('/'); + nodeModulesPath = path.resolve(nodeModulesPath, scope); + packageName = packageBaseName; + } + + if (!fs.existsSync(nodeModulesPath)) { + logger.writeLine(`'node_modules' directory does not exist at ${nodeModulesPath}. Creating...`); + fs.mkdirSync(nodeModulesPath, { recursive: true }); + } + + const linkPath: string = path.resolve(nodeModulesPath, packageName); + + if (fs.existsSync(linkPath)) { + logger.writeLine( + Colorize.yellow(`Soft link already exists for '${packageName}' in 'node_modules'. Skipping creation.`) + ); + } else { + fs.symlinkSync(targetPath, linkPath); + logger.writeLine( + Colorize.green(`Successfully created a symbolic link for '${packageName}' in 'node_modules'.`) + ); + } +})().catch((e) => logger.writeErrorLine(e?.message ?? e)); diff --git a/rush-plugins/rush-link-project-plugin/src/utils.ts b/rush-plugins/rush-link-project-plugin/src/utils.ts new file mode 100644 index 0000000..4fb8597 --- /dev/null +++ b/rush-plugins/rush-link-project-plugin/src/utils.ts @@ -0,0 +1,18 @@ +import fs from 'fs'; +import path from 'path'; +import { Terminal, ConsoleTerminalProvider } from '@rushstack/terminal'; +import { PACKAGE_JSON } from './constants'; + +export const logProvider: ConsoleTerminalProvider = new ConsoleTerminalProvider(); +export const logger: Terminal = new Terminal(logProvider); + +export const lookUpPackageJson = (currentDir: string): string | undefined => { + while (currentDir !== '.') { + const packageJsonPath: string = path.resolve(currentDir, PACKAGE_JSON); + if (fs.existsSync(packageJsonPath)) { + return currentDir; + } + currentDir = path.resolve(currentDir, '..'); + } + return undefined; +}; diff --git a/rush-plugins/rush-link-project-plugin/tsconfig.json b/rush-plugins/rush-link-project-plugin/tsconfig.json new file mode 100644 index 0000000..82917d2 --- /dev/null +++ b/rush-plugins/rush-link-project-plugin/tsconfig.json @@ -0,0 +1,97 @@ +{ + "compilerOptions": { + /* Visit https://aka.ms/tsconfig.json to read more about this file */ + /* Projects */ + // "incremental": true, /* Enable incremental compilation */ + // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */ + // "tsBuildInfoFile": "./", /* Specify the folder for .tsbuildinfo incremental compilation files. */ + // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects */ + // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */ + // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */ + /* Language and Environment */ + "target": "es5" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */, + "lib": [ + "ES2015" + ] /* Specify a set of bundled library declaration files that describe the target runtime environment. */, + // "jsx": "preserve", /* Specify what JSX code is generated. */ + // "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */ + // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */ + // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h' */ + // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */ + // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using `jsx: react-jsx*`.` */ + // "reactNamespace": "", /* Specify the object invoked for `createElement`. This only applies when targeting `react` JSX emit. */ + // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */ + // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */ + /* Modules */ + "module": "commonjs" /* Specify what module code is generated. */, + // "rootDir": "./", /* Specify the root folder within your source files. */ + // "moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */ + // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */ + // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */ + // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */ + // "typeRoots": [], /* Specify multiple folders that act like `./node_modules/@types`. */ + "types": [ + "heft-jest", + "node" + ] /* Specify type package names to be included without being referenced in a source file. */, + // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ + // "resolveJsonModule": true, /* Enable importing .json files */ + // "noResolve": true, /* Disallow `import`s, `require`s or ``s from expanding the number of files TypeScript should add to a project. */ + /* JavaScript Support */ + // "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the `checkJS` option to get errors from these files. */ + // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */ + // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from `node_modules`. Only applicable with `allowJs`. */ + /* Emit */ + "declaration": true /* Generate .d.ts files from TypeScript and JavaScript files in your project. */, + "declarationMap": true /* Create sourcemaps for d.ts files. */, + // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */ + "sourceMap": true /* Create source map files for emitted JavaScript files. */, + // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If `declaration` is true, also designates a file that bundles all .d.ts output. */ + "outDir": "./lib" /* Specify an output folder for all emitted files. */, + // "removeComments": true, /* Disable emitting comments. */ + // "noEmit": true, /* Disable emitting files from a compilation. */ + // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */ + // "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types */ + "downlevelIteration": true /* Emit more compliant, but verbose and less performant JavaScript for iteration. */, + // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */ + // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ + // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */ + // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */ + // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */ + // "newLine": "crlf", /* Set the newline character for emitting files. */ + // "stripInternal": true, /* Disable emitting declarations that have `@internal` in their JSDoc comments. */ + // "noEmitHelpers": true, /* Disable generating custom helper functions like `__extends` in compiled output. */ + // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */ + // "preserveConstEnums": true, /* Disable erasing `const enum` declarations in generated code. */ + // "declarationDir": "./", /* Specify the output directory for generated declaration files. */ + /* Interop Constraints */ + // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */ + // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */ + "esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables `allowSyntheticDefaultImports` for type compatibility. */, + // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */ + "forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */, + /* Type Checking */ + "strict": true /* Enable all strict type-checking options. */, + // "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied `any` type.. */ + // "strictNullChecks": true, /* When type checking, take into account `null` and `undefined`. */ + // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */ + // "strictBindCallApply": true, /* Check that the arguments for `bind`, `call`, and `apply` methods match the original function. */ + // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */ + // "noImplicitThis": true, /* Enable error reporting when `this` is given the type `any`. */ + // "useUnknownInCatchVariables": true, /* Type catch clause variables as 'unknown' instead of 'any'. */ + // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */ + // "noUnusedLocals": true, /* Enable error reporting when a local variables aren't read. */ + // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read */ + // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */ + // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */ + // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */ + // "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */ + // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */ + // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type */ + // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */ + // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */ + /* Completeness */ + // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ + "skipLibCheck": true /* Skip type checking all .d.ts files. */ + } +} diff --git a/rush.json b/rush.json index 6170d96..48543c4 100644 --- a/rush.json +++ b/rush.json @@ -506,6 +506,11 @@ "packageName": "rush-dep-graph-plugin", "projectFolder": "rush-plugins/rush-dep-graph-plugin", "shouldPublish": true + }, + { + "packageName": "rush-link-project-plugin", + "projectFolder": "rush-plugins/rush-link-project-plugin", + "shouldPublish": true } ] } From 0b4dcb6a28584ae6abdba5623af0f17499f629d1 Mon Sep 17 00:00:00 2001 From: Lincoln <778157949@qq.com> Date: Wed, 15 Jan 2025 08:41:04 +0000 Subject: [PATCH 2/9] modify readme --- README.md | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index bbcff9a..7efbf55 100644 --- a/README.md +++ b/README.md @@ -90,4 +90,13 @@ The rush subspace is a new feature that intends to move common projects into 1 w Are you struggling with the complex dependencies between packages? This plugin helps you visualize the dependency relationships between packages. -[More](./rush-plugins/rush-dep-graph-plugin/README.md) \ No newline at end of file +[More](./rush-plugins/rush-dep-graph-plugin/README.md) + +# rush-dep-graph-plugin + +[![npm](https://img.shields.io/npm/dt/rush-link-project-plugin.svg?style=flat-square)](https://www.npmjs.com/package/rush-link-project-plugin) +[![npm](https://img.shields.io/npm/dw/rush-link-project-plugin.svg?style=flat-square)](https://www.npmjs.com/package/rush-link-project-plugin) + +Having trouble managing symbolic links for your packages? This plugin helps you easily create and manage symbolic links for your packages in the rush project. + +[More](./rush-plugins/rush-link-project-plugin/README.md) \ No newline at end of file From 569186db9ebca40139abdd180048bc9f12cc499c Mon Sep 17 00:00:00 2001 From: Lincoln <778157949@qq.com> Date: Wed, 15 Jan 2025 08:45:10 +0000 Subject: [PATCH 3/9] modify readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7efbf55..d77a424 100644 --- a/README.md +++ b/README.md @@ -92,7 +92,7 @@ Are you struggling with the complex dependencies between packages? This plugin h [More](./rush-plugins/rush-dep-graph-plugin/README.md) -# rush-dep-graph-plugin +# rush-link-project-plugin [![npm](https://img.shields.io/npm/dt/rush-link-project-plugin.svg?style=flat-square)](https://www.npmjs.com/package/rush-link-project-plugin) [![npm](https://img.shields.io/npm/dw/rush-link-project-plugin.svg?style=flat-square)](https://www.npmjs.com/package/rush-link-project-plugin) From 954dbbc6a3a2870050fa90402b411d14636c3130 Mon Sep 17 00:00:00 2001 From: Lincoln <778157949@qq.com> Date: Wed, 15 Jan 2025 08:57:22 +0000 Subject: [PATCH 4/9] remove changelog --- .../rush-link-project-plugin/CHANGELOG.json | 22 ------------------- .../rush-link-project-plugin/CHANGELOG.md | 11 ---------- 2 files changed, 33 deletions(-) delete mode 100644 rush-plugins/rush-link-project-plugin/CHANGELOG.json delete mode 100644 rush-plugins/rush-link-project-plugin/CHANGELOG.md diff --git a/rush-plugins/rush-link-project-plugin/CHANGELOG.json b/rush-plugins/rush-link-project-plugin/CHANGELOG.json deleted file mode 100644 index 251b395..0000000 --- a/rush-plugins/rush-link-project-plugin/CHANGELOG.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "name": "rush-dep-graph-plugin", - "entries": [ - { - "version": "0.1.0", - "tag": "rush-dep-graph-plugin_v0.1.0", - "date": "Tue, 17 Dec 2024 03:42:09 GMT", - "comments": { - "minor": [ - { - "comment": "Create a `rush-dep-graph-plugin` Rush plugin to display the dependency graph." - } - ], - "none": [ - { - "comment": "Try to fix the CI issue" - } - ] - } - } - ] -} diff --git a/rush-plugins/rush-link-project-plugin/CHANGELOG.md b/rush-plugins/rush-link-project-plugin/CHANGELOG.md deleted file mode 100644 index 5b05d41..0000000 --- a/rush-plugins/rush-link-project-plugin/CHANGELOG.md +++ /dev/null @@ -1,11 +0,0 @@ -# Change Log - rush-dep-graph-plugin - -This log was last generated on Tue, 17 Dec 2024 03:42:09 GMT and should not be manually modified. - -## 0.1.0 -Tue, 17 Dec 2024 03:42:09 GMT - -### Minor changes - -- Create a `rush-dep-graph-plugin` Rush plugin to display the dependency graph. - From fba220c534ce66ea40266265f09c1fa5762e32bf Mon Sep 17 00:00:00 2001 From: Lincoln <778157949@qq.com> Date: Wed, 15 Jan 2025 09:01:31 +0000 Subject: [PATCH 5/9] Update README --- rush-plugins/rush-link-project-plugin/README.md | 15 +++++++-------- .../rush-link-project-plugin/package.json | 2 +- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/rush-plugins/rush-link-project-plugin/README.md b/rush-plugins/rush-link-project-plugin/README.md index 910e11f..8289c51 100644 --- a/rush-plugins/rush-link-project-plugin/README.md +++ b/rush-plugins/rush-link-project-plugin/README.md @@ -1,6 +1,6 @@ -# rush-dep-graph-plugin +# rush-link-project-plugin -A Rush plugin that displays the dependency graph. +A plugin to create a symbolic link for a package. # Prerequisite @@ -13,13 +13,12 @@ Rush.js >= 5.83.2 Please follow the [official doc](https://rushjs.io/pages/maintainer/using_rush_plugins/) to enable this plugin in your repo. -2. Running `dep-graph` command +2. Running `link-project` command ``` -Usage: rush dep-graph [OPTIONS] +usage: rush link-project [-h] [--path PATH] -Options: - -t, --to Select the packages that depend on specific project. - -f, --from Select the package that is dependent on specific package. - --filter Select the packages based on a custom filter criteria, such as specific keywords in the package name. +Optional arguments: + -h, --help Show this help message and exit. + --path PATH ``` diff --git a/rush-plugins/rush-link-project-plugin/package.json b/rush-plugins/rush-link-project-plugin/package.json index da8d52d..d1e081c 100644 --- a/rush-plugins/rush-link-project-plugin/package.json +++ b/rush-plugins/rush-link-project-plugin/package.json @@ -1,7 +1,7 @@ { "name": "rush-link-project-plugin", "version": "0.1.0", - "description": "Creates a symbolic link for a package", + "description": "A plugin to create a symbolic link for a package.", "keywords": [ "rush", "plugin", From 120c1dfc147d6c424fea470977507254d7a030c8 Mon Sep 17 00:00:00 2001 From: Lincoln <778157949@qq.com> Date: Wed, 15 Jan 2025 09:09:53 +0000 Subject: [PATCH 6/9] Update README --- README.md | 2 +- rush-plugins/rush-link-project-plugin/README.md | 2 +- rush-plugins/rush-link-project-plugin/command-line.json | 4 ++-- rush-plugins/rush-link-project-plugin/package.json | 2 +- .../rush-link-project-plugin/rush-plugin-manifest.json | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index d77a424..332c940 100644 --- a/README.md +++ b/README.md @@ -97,6 +97,6 @@ Are you struggling with the complex dependencies between packages? This plugin h [![npm](https://img.shields.io/npm/dt/rush-link-project-plugin.svg?style=flat-square)](https://www.npmjs.com/package/rush-link-project-plugin) [![npm](https://img.shields.io/npm/dw/rush-link-project-plugin.svg?style=flat-square)](https://www.npmjs.com/package/rush-link-project-plugin) -Having trouble managing symbolic links for your packages? This plugin helps you easily create and manage symbolic links for your packages in the rush project. +Tired of manually managing local packages in your Rush project? This plugin links your local package to the project, making it easily accessible in other locations. [More](./rush-plugins/rush-link-project-plugin/README.md) \ No newline at end of file diff --git a/rush-plugins/rush-link-project-plugin/README.md b/rush-plugins/rush-link-project-plugin/README.md index 8289c51..6b6a9d5 100644 --- a/rush-plugins/rush-link-project-plugin/README.md +++ b/rush-plugins/rush-link-project-plugin/README.md @@ -1,6 +1,6 @@ # rush-link-project-plugin -A plugin to create a symbolic link for a package. +A plugin that makes the current local package accessible in another location. # Prerequisite diff --git a/rush-plugins/rush-link-project-plugin/command-line.json b/rush-plugins/rush-link-project-plugin/command-line.json index e051b09..a3c9356 100644 --- a/rush-plugins/rush-link-project-plugin/command-line.json +++ b/rush-plugins/rush-link-project-plugin/command-line.json @@ -4,8 +4,8 @@ { "name": "link-project", "commandKind": "global", - "summary": "Creates a symbolic link for a package", - "description": "Creates a symbolic link for a package", + "summary": "A plugin that makes the current local package accessible in another location.", + "description": "A plugin that makes the current local package accessible in another location.", "shellCommand": "ts-node common/autoinstallers/link-package/src/index.ts", "autoinstallerName": "link-project" } diff --git a/rush-plugins/rush-link-project-plugin/package.json b/rush-plugins/rush-link-project-plugin/package.json index d1e081c..778ea08 100644 --- a/rush-plugins/rush-link-project-plugin/package.json +++ b/rush-plugins/rush-link-project-plugin/package.json @@ -1,7 +1,7 @@ { "name": "rush-link-project-plugin", "version": "0.1.0", - "description": "A plugin to create a symbolic link for a package.", + "description": "A plugin that makes the current local package accessible in another location.", "keywords": [ "rush", "plugin", diff --git a/rush-plugins/rush-link-project-plugin/rush-plugin-manifest.json b/rush-plugins/rush-link-project-plugin/rush-plugin-manifest.json index fd0cb78..469bef4 100644 --- a/rush-plugins/rush-link-project-plugin/rush-plugin-manifest.json +++ b/rush-plugins/rush-link-project-plugin/rush-plugin-manifest.json @@ -3,7 +3,7 @@ "plugins": [ { "pluginName": "link-project", - "description": "Creates a symbolic link for a package", + "description": "A plugin that makes the current local package accessible in another location.", "commandLineJsonFilePath": "command-line.json" } ] From 4ef842d03a3fb9c2e462a1e780599f174b9c861d Mon Sep 17 00:00:00 2001 From: Lincoln <778157949@qq.com> Date: Wed, 15 Jan 2025 09:15:38 +0000 Subject: [PATCH 7/9] Update README --- rush-plugins/rush-link-project-plugin/command-line.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rush-plugins/rush-link-project-plugin/command-line.json b/rush-plugins/rush-link-project-plugin/command-line.json index a3c9356..68cdff4 100644 --- a/rush-plugins/rush-link-project-plugin/command-line.json +++ b/rush-plugins/rush-link-project-plugin/command-line.json @@ -14,7 +14,7 @@ { "parameterKind": "string", "argumentName": "PATH", - "description": "The path to the package you want to link. This can be an absolute or relative path. If it's a relative path, it will be resolved from the current working directory.", + "description": "The path to the package you want to link. This can be an absolute or relative path.", "longName": "--path", "associatedCommands": ["link-project"] } From aa2e41f7621d170eb23e546734fa4b0cd367f5aa Mon Sep 17 00:00:00 2001 From: Lincoln <778157949@qq.com> Date: Wed, 15 Jan 2025 09:31:19 +0000 Subject: [PATCH 8/9] Update error log --- rush-plugins/rush-link-project-plugin/src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rush-plugins/rush-link-project-plugin/src/index.ts b/rush-plugins/rush-link-project-plugin/src/index.ts index 2e4e16a..5e4a7bc 100644 --- a/rush-plugins/rush-link-project-plugin/src/index.ts +++ b/rush-plugins/rush-link-project-plugin/src/index.ts @@ -13,7 +13,7 @@ import { lookUpPackageJson, logger } from './utils'; const targetJsonPath: string = path.resolve(targetPath, PACKAGE_JSON); if (!fs.existsSync(targetJsonPath)) { - throw new Error(`Can not find ${PACKAGE_JSON} in the path ${argv.path}`); + throw new Error(`Cannot find ${PACKAGE_JSON} in the path ${argv.path}`); } const originJsonPath: string | undefined = lookUpPackageJson(RUSH_EVOKE_FOLDER); From adcf1422b6f7bf4fa46756092d0218e01e6045b1 Mon Sep 17 00:00:00 2001 From: Lincoln <778157949@qq.com> Date: Wed, 15 Jan 2025 09:38:42 +0000 Subject: [PATCH 9/9] Update error log --- rush-plugins/rush-link-project-plugin/src/index.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/rush-plugins/rush-link-project-plugin/src/index.ts b/rush-plugins/rush-link-project-plugin/src/index.ts index 5e4a7bc..7450127 100644 --- a/rush-plugins/rush-link-project-plugin/src/index.ts +++ b/rush-plugins/rush-link-project-plugin/src/index.ts @@ -33,7 +33,6 @@ import { lookUpPackageJson, logger } from './utils'; } if (!fs.existsSync(nodeModulesPath)) { - logger.writeLine(`'node_modules' directory does not exist at ${nodeModulesPath}. Creating...`); fs.mkdirSync(nodeModulesPath, { recursive: true }); }