From e1ebf415da301c985c477714581ec07b4c5959f8 Mon Sep 17 00:00:00 2001 From: qun Date: Thu, 11 Jul 2024 06:35:06 +0000 Subject: [PATCH 1/3] give a warning without interrupting the installation process --- .../rush/chore-inject-deps_2024-07-11-06-27.json | 10 ++++++++++ .../logic/installManager/WorkspaceInstallManager.ts | 6 ++++-- 2 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 common/changes/@microsoft/rush/chore-inject-deps_2024-07-11-06-27.json diff --git a/common/changes/@microsoft/rush/chore-inject-deps_2024-07-11-06-27.json b/common/changes/@microsoft/rush/chore-inject-deps_2024-07-11-06-27.json new file mode 100644 index 00000000000..48f48622e0b --- /dev/null +++ b/common/changes/@microsoft/rush/chore-inject-deps_2024-07-11-06-27.json @@ -0,0 +1,10 @@ +{ + "changes": [ + { + "packageName": "@microsoft/rush", + "comment": "Don't interrupt the installation process if the user hasn't enabled the inject dependencies feature.", + "type": "none" + } + ], + "packageName": "@microsoft/rush" +} \ No newline at end of file diff --git a/libraries/rush-lib/src/logic/installManager/WorkspaceInstallManager.ts b/libraries/rush-lib/src/logic/installManager/WorkspaceInstallManager.ts index 34f46f6f126..5e3b9e79b79 100644 --- a/libraries/rush-lib/src/logic/installManager/WorkspaceInstallManager.ts +++ b/libraries/rush-lib/src/logic/installManager/WorkspaceInstallManager.ts @@ -170,8 +170,10 @@ export class WorkspaceInstallManager extends BaseInstallManager { // there is a situation that the subspace previously has injected dependencies but removed // so we can check if the repoState up to date if (repoState.packageJsonInjectedDependenciesHash !== undefined) { - shrinkwrapWarnings.push(`Some injected dependencies' package.json might have been modified.`); - shrinkwrapIsUpToDate = false; + shrinkwrapWarnings.push( + 'It was detected that the repo-state.json contains packageJsonInjectedDependenciesHash, ' + + 'but the inject dependencies feature is not enabled.' + ); } } } From 9bed420951429c12f8b1e0e7a80ae76db420a80f Mon Sep 17 00:00:00 2001 From: qun Date: Thu, 11 Jul 2024 14:35:30 +0000 Subject: [PATCH 2/3] chore: display more accurate prompt information --- .../src/logic/installManager/WorkspaceInstallManager.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libraries/rush-lib/src/logic/installManager/WorkspaceInstallManager.ts b/libraries/rush-lib/src/logic/installManager/WorkspaceInstallManager.ts index 5e3b9e79b79..ec8cd6af0b7 100644 --- a/libraries/rush-lib/src/logic/installManager/WorkspaceInstallManager.ts +++ b/libraries/rush-lib/src/logic/installManager/WorkspaceInstallManager.ts @@ -171,8 +171,9 @@ export class WorkspaceInstallManager extends BaseInstallManager { // so we can check if the repoState up to date if (repoState.packageJsonInjectedDependenciesHash !== undefined) { shrinkwrapWarnings.push( - 'It was detected that the repo-state.json contains packageJsonInjectedDependenciesHash, ' + - 'but the inject dependencies feature is not enabled.' + `It was detected that ${repoState.filePath} contains packageJsonInjectedDependenciesHash` + + ' but the injected dependencies feature is not enabled. You can delete this file' + + ' and rerun the rush update command to generate the correct repo-state.json file.' ); } } From d028c051e1212c19c9e8e1b539e214a0c0a54477 Mon Sep 17 00:00:00 2001 From: "chao.guo" <10736839+g-chao@users.noreply.github.com> Date: Thu, 11 Jul 2024 19:18:39 -0700 Subject: [PATCH 3/3] feat: remove packageJsonInjectedDependenciesHash in repo-state.json if it is not used when run update --- libraries/rush-lib/src/logic/RepoStateFile.ts | 6 ++++++ .../src/logic/installManager/WorkspaceInstallManager.ts | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/libraries/rush-lib/src/logic/RepoStateFile.ts b/libraries/rush-lib/src/logic/RepoStateFile.ts index 6e694dbdc83..41c68e02af0 100644 --- a/libraries/rush-lib/src/logic/RepoStateFile.ts +++ b/libraries/rush-lib/src/logic/RepoStateFile.ts @@ -208,6 +208,12 @@ export class RepoStateFile { ) { this._packageJsonInjectedDependenciesHash = packageJsonInjectedDependenciesHash; this._modified = true; + } else if (!packageJsonInjectedDependenciesHash && this._packageJsonInjectedDependenciesHash) { + // if packageJsonInjectedDependenciesHash is undefined, but this._packageJsonInjectedDependenciesHash is not + // means users may turn off the injected installation + // so we will need to remove unused fields in repo-state.json as well + this._packageJsonInjectedDependenciesHash = undefined; + this._modified = true } } diff --git a/libraries/rush-lib/src/logic/installManager/WorkspaceInstallManager.ts b/libraries/rush-lib/src/logic/installManager/WorkspaceInstallManager.ts index ec8cd6af0b7..2c94c5d8b4d 100644 --- a/libraries/rush-lib/src/logic/installManager/WorkspaceInstallManager.ts +++ b/libraries/rush-lib/src/logic/installManager/WorkspaceInstallManager.ts @@ -172,8 +172,8 @@ export class WorkspaceInstallManager extends BaseInstallManager { if (repoState.packageJsonInjectedDependenciesHash !== undefined) { shrinkwrapWarnings.push( `It was detected that ${repoState.filePath} contains packageJsonInjectedDependenciesHash` + - ' but the injected dependencies feature is not enabled. You can delete this file' + - ' and rerun the rush update command to generate the correct repo-state.json file.' + ' but the injected dependencies feature is not enabled. You can manually remove this field in repo-state.json.' + + ' Or run rush update command to update the repo-state.json file.' ); } }