From 82196b3089afce10001c06ccd28b62c67064661f Mon Sep 17 00:00:00 2001 From: Will Huang Date: Tue, 19 Dec 2023 14:03:27 -0500 Subject: [PATCH] Bug fixes and update CommandLineHelp snapshot --- common/reviews/api/rush-lib.api.md | 6 +-- libraries/rush-lib/src/api/LastInstallFlag.ts | 2 +- libraries/rush-lib/src/api/base/BaseFlag.ts | 1 - .../rush-lib/src/cli/actions/InstallAction.ts | 12 ----- .../CommandLineHelp.test.ts.snap | 50 +++++++++---------- .../rush-lib/src/utilities/objectUtilities.ts | 10 ++-- 6 files changed, 32 insertions(+), 49 deletions(-) diff --git a/common/reviews/api/rush-lib.api.md b/common/reviews/api/rush-lib.api.md index 37d9e03c0fa..e34fd5f23ea 100644 --- a/common/reviews/api/rush-lib.api.md +++ b/common/reviews/api/rush-lib.api.md @@ -509,14 +509,14 @@ export interface _ILastInstallFlagJson { // (undocumented) [key: string]: unknown; ignoreScripts?: true; - node: string; + nodeVersion: string; packageJson?: IPackageJson; packageManager: PackageManagerName; packageManagerVersion: string; rushJsonFolder: string; selectedProjectNames?: string[]; storePath?: string; - workspaces?: true; + useWorkspaces?: true; } // @public @@ -1104,7 +1104,7 @@ export class RushConfiguration { getRepoState(variant?: string | undefined): RepoStateFile; getRepoStateFilePath(variant?: string | undefined): string; // @beta - getSubspaceTempFolder(subspaceName: string): string; + getSubspaceTempFolderPath(subspaceName: string): string; // @beta getTempSubspaceShrinkwrapFileName(subspaceName: string): string; readonly gitAllowedEmailRegExps: string[]; diff --git a/libraries/rush-lib/src/api/LastInstallFlag.ts b/libraries/rush-lib/src/api/LastInstallFlag.ts index d469fd5a392..7d0f8b7a8fd 100644 --- a/libraries/rush-lib/src/api/LastInstallFlag.ts +++ b/libraries/rush-lib/src/api/LastInstallFlag.ts @@ -248,6 +248,6 @@ export class LastInstallFlagFactory { } } - return new LastInstallFlag(rushConfiguration.getSubspaceTempFolder(subspace), currentState); + return new LastInstallFlag(rushConfiguration.getSubspaceTempFolderPath(subspace), currentState); } } diff --git a/libraries/rush-lib/src/api/base/BaseFlag.ts b/libraries/rush-lib/src/api/base/BaseFlag.ts index 4429ad8ae09..04e9761e99e 100644 --- a/libraries/rush-lib/src/api/base/BaseFlag.ts +++ b/libraries/rush-lib/src/api/base/BaseFlag.ts @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. // See LICENSE in the project root for license information. -import * as path from 'path'; import { FileSystem, JsonFile, type JsonObject } from '@rushstack/node-core-library'; import { isMatch, merge } from '../../utilities/objectUtilities'; diff --git a/libraries/rush-lib/src/cli/actions/InstallAction.ts b/libraries/rush-lib/src/cli/actions/InstallAction.ts index 751dcbd43cb..7a6929b58ef 100644 --- a/libraries/rush-lib/src/cli/actions/InstallAction.ts +++ b/libraries/rush-lib/src/cli/actions/InstallAction.ts @@ -11,7 +11,6 @@ import { SelectionParameterSet } from '../parsing/SelectionParameterSet'; export class InstallAction extends BaseInstallAction { private readonly _checkOnlyParameter!: CommandLineFlagParameter; - private _ignoreScriptsParameter!: CommandLineFlagParameter; public constructor(parser: RushCommandLineParser) { super({ @@ -43,17 +42,6 @@ export class InstallAction extends BaseInstallAction { parameterLongName: '--check-only', description: `Only check the validity of the shrinkwrap file without performing an install.` }); - - this._ignoreScriptsParameter = this.defineFlagParameter({ - parameterLongName: '--ignore-scripts', - description: - 'Do not execute any install lifecycle scripts specified in package.json files and its' + - ' dependencies when "rush install". Running with this flag may leave your installation in an incomplete' + - ' state, you need to run without this flag again to complete a full installation. Meanwhile, it makes' + - ' your installing faster. Later, you can run "rush install" to run all ignored scripts. Moreover, you' + - ' can partial install such as "rush install --to " to run ignored scripts of the dependencies' + - ' of the selected projects.' - }); } protected async buildInstallOptionsAsync(): Promise { diff --git a/libraries/rush-lib/src/cli/test/__snapshots__/CommandLineHelp.test.ts.snap b/libraries/rush-lib/src/cli/test/__snapshots__/CommandLineHelp.test.ts.snap index 49f5c5fea26..5822b2c718a 100644 --- a/libraries/rush-lib/src/cli/test/__snapshots__/CommandLineHelp.test.ts.snap +++ b/libraries/rush-lib/src/cli/test/__snapshots__/CommandLineHelp.test.ts.snap @@ -576,11 +576,11 @@ exports[`CommandLineHelp prints the help for each action: install 1`] = ` "usage: rush install [-h] [-p] [--bypass-policy] [--no-link] [--network-concurrency COUNT] [--debug-package-manager] [--max-install-attempts NUMBER] [--ignore-hooks] - [--offline] [--variant VARIANT] [-t PROJECT] [-T PROJECT] - [-f PROJECT] [-o PROJECT] [-i PROJECT] [-I PROJECT] + [--offline] [--ignore-scripts] [--variant VARIANT] + [-t PROJECT] [-T PROJECT] [-f PROJECT] [-o PROJECT] + [-i PROJECT] [-I PROJECT] [--to-version-policy VERSION_POLICY_NAME] [--from-version-policy VERSION_POLICY_NAME] [--check-only] - [--ignore-scripts] The \\"rush install\\" command installs package dependencies for all your @@ -626,6 +626,16 @@ Optional arguments: necessary NPM packages cannot be obtained from the local cache. For details, see the documentation for PNPM's \\"--offline\\" parameter. + --ignore-scripts Do not execute any install lifecycle scripts + specified in package.json files and its dependencies + when \\"rush update\\". Running with this flag leaves + your installation in a uncompleted state, you need to + run this command without this flag again or run \\"rush + install\\" to complete a full installation. Meanwhile, + it makes faster retries on running install lifecycle + scripts. You can partial install such as \\"rush + install --to \\" to run the ignored scripts of + the dependencies of the selected projects. --variant VARIANT Run command using a variant installation configuration. This parameter may alternatively be specified via the RUSH_VARIANT environment variable. @@ -708,16 +718,6 @@ Optional arguments: subsets of projects\\". --check-only Only check the validity of the shrinkwrap file without performing an install. - --ignore-scripts Do not execute any install lifecycle scripts - specified in package.json files and its dependencies - when \\"rush install\\". Running with this flag leaves - your installation in a uncompleted state, you need to - run without this flag again to complete a full - installation. Meanwhile, it makes your installing - faster. Later, you can run \\"rush install\\" to run all - ignored scripts. Moreover, you can partial install - such as \\"rush install --to \\" to run ignored - scripts of the dependencies of the selected projects. " `; @@ -1161,8 +1161,8 @@ exports[`CommandLineHelp prints the help for each action: update 1`] = ` "usage: rush update [-h] [-p] [--bypass-policy] [--no-link] [--network-concurrency COUNT] [--debug-package-manager] [--max-install-attempts NUMBER] [--ignore-hooks] - [--offline] [--variant VARIANT] [--full] [--recheck] - [--ignore-scripts] + [--offline] [--ignore-scripts] [--variant VARIANT] [--full] + [--recheck] The \\"rush update\\" command installs the dependencies described in your package. @@ -1207,6 +1207,16 @@ Optional arguments: necessary NPM packages cannot be obtained from the local cache. For details, see the documentation for PNPM's \\"--offline\\" parameter. + --ignore-scripts Do not execute any install lifecycle scripts + specified in package.json files and its dependencies + when \\"rush update\\". Running with this flag leaves + your installation in a uncompleted state, you need to + run this command without this flag again or run \\"rush + install\\" to complete a full installation. Meanwhile, + it makes faster retries on running install lifecycle + scripts. You can partial install such as \\"rush + install --to \\" to run the ignored scripts of + the dependencies of the selected projects. --variant VARIANT Run command using a variant installation configuration. This parameter may alternatively be specified via the RUSH_VARIANT environment variable. @@ -1229,16 +1239,6 @@ Optional arguments: your shrinkwrap file with Rush's fixups. (To minimize shrinkwrap churn, these fixups are normally performed only in the temporary folder.) - --ignore-scripts Do not execute any install lifecycle scripts - specified in package.json files and its dependencies - when \\"rush update\\". Running with this flag leaves - your installation in a uncompleted state, you need to - run this command without this flag again or run \\"rush - install\\" to complete a full installation. Meanwhile, - it makes faster retries on running install lifecycle - scripts. You can partial install such as \\"rush - install --to \\" to run the ignored scripts of - the dependencies of the selected projects. " `; diff --git a/libraries/rush-lib/src/utilities/objectUtilities.ts b/libraries/rush-lib/src/utilities/objectUtilities.ts index b469b6da23a..4b46f8ad904 100644 --- a/libraries/rush-lib/src/utilities/objectUtilities.ts +++ b/libraries/rush-lib/src/utilities/objectUtilities.ts @@ -120,14 +120,10 @@ function cloneDeepInner(obj: TObject, seenObjects: Set): TObje * determine if `obj` contains equivalent property values. */ export function isMatch(obj: TObject, source: TObject): boolean { - if (obj === source) { - return true; - } - - if (typeof obj !== typeof source) { - return false; - } + return obj === source || (typeof obj === typeof source && isMatchInner(obj, source)); +} +function isMatchInner(obj: TObject, source: TObject): boolean { let sourceKeys: (string | number)[] | undefined; if (typeof source === 'object' && source !== null && !Array.isArray(source)) { sourceKeys = Object.keys(source);