From cfff797f03300805e045ebbe010c61fad8ab11fc Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 3 Dec 2025 19:11:11 +0000 Subject: [PATCH 1/3] Initial plan From 9a35a69178bb3355c912d31b2d3f040c32070f21 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 3 Dec 2025 19:20:23 +0000 Subject: [PATCH 2/3] fix: Write last-install.flag after update-autoinstaller completes Co-authored-by: iclanton <5010588+iclanton@users.noreply.github.com> --- libraries/rush-lib/src/logic/Autoinstaller.ts | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/libraries/rush-lib/src/logic/Autoinstaller.ts b/libraries/rush-lib/src/logic/Autoinstaller.ts index 8c35ea07b8..84fb06f243 100644 --- a/libraries/rush-lib/src/logic/Autoinstaller.ts +++ b/libraries/rush-lib/src/logic/Autoinstaller.ts @@ -265,6 +265,44 @@ export class Autoinstaller { } else { this._logIfConsoleOutputIsNotRestricted(Colorize.green('Already up to date.')); } + + // Write the last-install.flag file so that a subsequent "rush install-autoinstaller" + // will not perform a redundant install. + await this._createFlagsAsync(); + } + + private async _createFlagsAsync(): Promise { + const autoinstallerFullPath: string = this.folderFullPath; + + // Example: .../common/autoinstallers/my-task/.rush/temp + const lastInstallFlagPath: string = path.join( + autoinstallerFullPath, + RushConstants.projectRushFolderName, + 'temp' + ); + + const packageJsonPath: string = path.join(autoinstallerFullPath, 'package.json'); + const packageJson: IPackageJson = JsonFile.load(packageJsonPath); + + const lastInstallFlag: LastInstallFlag = new LastInstallFlag(lastInstallFlagPath, { + node: process.versions.node, + packageManager: this._rushConfiguration.packageManager, + packageManagerVersion: this._rushConfiguration.packageManagerToolVersion, + packageJson: packageJson, + rushJsonFolder: this._rushConfiguration.rushJsonFolder + }); + + // Create file: ../common/autoinstallers/my-task/.rush/temp/last-install.flag + await lastInstallFlag.createAsync(); + + // Example: ../common/autoinstallers/my-task/node_modules + const nodeModulesFolder: string = `${autoinstallerFullPath}/${RushConstants.nodeModulesFolderName}`; + const flagPath: string = `${nodeModulesFolder}/rush-autoinstaller.flag`; + + FileSystem.writeFile( + flagPath, + 'If this file is deleted, Rush will assume that the node_modules folder has been cleaned and will reinstall it.' + ); } private _logIfConsoleOutputIsNotRestricted(message?: string): void { From c4863889188163a983af115b9aaf293c41b3f91c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 2 Jan 2026 23:29:53 +0000 Subject: [PATCH 3/3] fix: Use existing PackageJsonEditor instead of re-reading file Co-authored-by: dmichon-msft <26827560+dmichon-msft@users.noreply.github.com> --- libraries/rush-lib/src/logic/Autoinstaller.ts | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/libraries/rush-lib/src/logic/Autoinstaller.ts b/libraries/rush-lib/src/logic/Autoinstaller.ts index 84fb06f243..ae5d018785 100644 --- a/libraries/rush-lib/src/logic/Autoinstaller.ts +++ b/libraries/rush-lib/src/logic/Autoinstaller.ts @@ -268,10 +268,10 @@ export class Autoinstaller { // Write the last-install.flag file so that a subsequent "rush install-autoinstaller" // will not perform a redundant install. - await this._createFlagsAsync(); + await this._createFlagsAsync(packageJsonEditor.saveToObject()); } - private async _createFlagsAsync(): Promise { + private async _createFlagsAsync(packageJson: IPackageJson): Promise { const autoinstallerFullPath: string = this.folderFullPath; // Example: .../common/autoinstallers/my-task/.rush/temp @@ -281,9 +281,6 @@ export class Autoinstaller { 'temp' ); - const packageJsonPath: string = path.join(autoinstallerFullPath, 'package.json'); - const packageJson: IPackageJson = JsonFile.load(packageJsonPath); - const lastInstallFlag: LastInstallFlag = new LastInstallFlag(lastInstallFlagPath, { node: process.versions.node, packageManager: this._rushConfiguration.packageManager,