Skip to content

Commit e89bc42

Browse files
author
Nick Pape
committed
PR feedback
1 parent d7a2a38 commit e89bc42

8 files changed

Lines changed: 31 additions & 29 deletions

File tree

‎apps/rush-lib/src/cli/actions/GenerateAction.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export default class GenerateAction extends BaseRushAction {
7171

7272
try {
7373
const shrinkwrapFile: ShrinkwrapFile | undefined
74-
= ShrinkwrapFile.loadFromFile(this.rushConfiguration.packageManager, committedShrinkwrapFilename);
74+
= ShrinkwrapFile.loadFromFile(committedShrinkwrapFilename);
7575

7676
if (shrinkwrapFile
7777
&& !this._forceParameter.value

‎apps/rush-lib/src/cli/actions/InstallAction.ts‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,7 @@ export default class InstallAction extends BaseRushAction {
8282
installManager.ensureLocalPackageManager(this._cleanInstallFull.value);
8383

8484
const shrinkwrapFile: ShrinkwrapFile | undefined
85-
= ShrinkwrapFile.loadFromFile(
86-
this.rushConfiguration.packageManager,
87-
this.rushConfiguration.committedShrinkwrapFilename);
85+
= ShrinkwrapFile.loadFromFile(this.rushConfiguration.committedShrinkwrapFilename);
8886

8987
if (!shrinkwrapFile) {
9088
console.log('');

‎apps/rush-lib/src/cli/utilities/InstallManager.ts‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ export default class InstallManager {
142142
}
143143

144144
/**
145-
* If the "(p)npm-local" symlink hasn't been set up yet, this creates it, installing the
145+
* If the "npm-local" symlink hasn't been set up yet, this creates it, installing the
146146
* specified NPM version in the user's home directory if needed.
147147
*/
148148
public ensureLocalPackageManager(forceReinstall: boolean): void {
@@ -615,10 +615,7 @@ export default class InstallManager {
615615
// is optional or not, but it does not appear to do so. Also, this would result in strange behavior where
616616
// people would have different node_modules based on their system.
617617

618-
const installArgs: string[] = ['install'];
619-
if (this._rushConfiguration.packageManager === 'npm') {
620-
installArgs.push('--no-optional');
621-
}
618+
const installArgs: string[] = ['install', '--no-optional'];
622619
this.pushConfigurationArgs(installArgs);
623620

624621
console.log(os.EOL + colors.bold(`Running "${this._rushConfiguration.packageManager} install" in`

‎apps/rush-lib/src/cli/utilities/Package.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ export default class Package {
7373
*/
7474
public parent: Package | undefined;
7575

76+
/**
77+
* The raw package.json information for this Package
78+
*/
7679
public packageJson: IRushTempPackageJson | undefined;
7780

7881
/**

‎apps/rush-lib/src/cli/utilities/ShrinkwrapFile.ts‎

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,18 @@ import * as semver from 'semver';
66
import npmPackageArg = require('npm-package-arg');
77

88
import Utilities from '../../utilities/Utilities';
9-
import { PackageManager } from '../../data/RushConfiguration';
109
import { RushConstants } from '../../RushConstants';
1110

1211
/**
13-
* This class is a parser for both NPM's npm-shrinkwrap.json file formats.
12+
* This class is a parser for NPM's npm-shrinkwrap.json file format.
1413
*/
1514
export default abstract class ShrinkwrapFile {
1615
protected _alreadyWarnedSpecs: Set<string> = new Set<string>();
1716

18-
public static loadFromFile(packageManager: PackageManager, shrinkwrapFilename: string): ShrinkwrapFile | undefined {
17+
/**
18+
* Attempt to load the shrinkwrap from a filepath
19+
*/
20+
public static loadFromFile(shrinkwrapFilename: string): ShrinkwrapFile | undefined {
1921
return require('./npm/NpmShrinkwrapFile').default.loadFromFile(shrinkwrapFilename);
2022
}
2123

@@ -59,16 +61,4 @@ export default abstract class ShrinkwrapFile {
5961
public abstract getTempProjectNames(): ReadonlyArray<string>;
6062

6163
protected abstract getDependencyVersion(dependencyName: string, tempProjectName?: string): string | undefined;
62-
63-
protected _getTempProjectNames(dependencies: { [key: string]: {} } ): ReadonlyArray<string> {
64-
const result: string[] = [];
65-
for (const key of Object.keys(dependencies)) {
66-
// If it starts with @rush-temp, then include it:
67-
if (Utilities.parseScopedPackageName(key).scope === RushConstants.rushTempNpmScope) {
68-
result.push(key);
69-
}
70-
}
71-
result.sort(); // make the result deterministic
72-
return result;
73-
}
7464
}

‎apps/rush-lib/src/cli/utilities/npm/NpmShrinkwrapFile.ts‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import * as fsx from 'fs-extra';
22
import * as os from 'os';
33

4+
import Utilities from '../../../utilities/Utilities';
5+
import { RushConstants } from '../../../RushConstants';
6+
47
import ShrinkwrapFile from '../ShrinkwrapFile';
58

69
interface IShrinkwrapDependencyJson {
@@ -101,4 +104,15 @@ export default class NpmShrinkwrapFile extends ShrinkwrapFile {
101104
}
102105
}
103106

107+
protected _getTempProjectNames(dependencies: { [key: string]: {} } ): ReadonlyArray<string> {
108+
const result: string[] = [];
109+
for (const key of Object.keys(dependencies)) {
110+
// If it starts with @rush-temp, then include it:
111+
if (Utilities.parseScopedPackageName(key).scope === RushConstants.rushTempNpmScope) {
112+
result.push(key);
113+
}
114+
}
115+
result.sort(); // make the result deterministic
116+
return result;
117+
}
104118
}

‎apps/rush-lib/src/cli/utilities/test/ShrinkwrapFile.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import ShrinkwapFile from '../ShrinkwrapFile';
88

99
describe('NPM ShrinkwrapFile', () => {
1010
const filename: string = path.resolve(path.join(__dirname, './shrinkwrapFile/npm-shrinkwrap.json'));
11-
const shrinkwrapFile: ShrinkwapFile = ShrinkwapFile.loadFromFile('npm', filename)!;
11+
const shrinkwrapFile: ShrinkwapFile = ShrinkwapFile.loadFromFile(filename)!;
1212

1313
it('verifies root-level dependency', () => {
1414
shrinkwrapFile.hasCompatibleDependency('q', '~1.5.0');

‎apps/rush-lib/src/data/RushConfiguration.ts‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ export default class RushConfiguration {
274274
* _validateCommonRushConfigFolder() function makes sure that this folder only contains
275275
* recognized config files.
276276
*/
277-
private static _validateCommonRushConfigFolder(commonRushConfigFolder: string, packageManager: PackageManager): void {
277+
private static _validateCommonRushConfigFolder(commonRushConfigFolder: string): void {
278278
if (!fsx.existsSync(commonRushConfigFolder)) {
279279
console.log(`Creating folder: ${commonRushConfigFolder}`);
280280
fsx.mkdirsSync(commonRushConfigFolder);
@@ -392,7 +392,7 @@ export default class RushConfiguration {
392392
* The filename of the NPM shrinkwrap file that is tracked e.g. by Git. (The "rush install"
393393
* command uses a temporary copy, whose path is tempShrinkwrapFilename.)
394394
* This property merely reports the filename; the file itself may not actually exist.
395-
* Example: "C:\MyRepo\common\npm-shrinkwrap.json" or "C:\MyRepo\common\shrinkwrap.yaml"
395+
* Example: "C:\MyRepo\common\npm-shrinkwrap.json"
396396
*/
397397
public get committedShrinkwrapFilename(): string {
398398
return this._committedShrinkwrapFilename;
@@ -402,7 +402,7 @@ export default class RushConfiguration {
402402
* The filename of the temporary NPM shrinkwrap file that is used by "rush install".
403403
* (The master copy is tempShrinkwrapFilename.)
404404
* This property merely reports the filename; the file itself may not actually exist.
405-
* Example: "C:\MyRepo\common\temp\npm-shrinkwrap.json" or "C:\MyRepo\common\temp\shrinkwrap.yaml"
405+
* Example: "C:\MyRepo\common\temp\npm-shrinkwrap.json"
406406
*/
407407
public get tempShrinkwrapFilename(): string {
408408
return this._tempShrinkwrapFilename;
@@ -626,7 +626,7 @@ export default class RushConfiguration {
626626
this._packageManagerToolFilename = path.resolve(path.join(this._commonTempFolder,
627627
'npm-local', 'node_modules', '.bin', 'npm'));
628628

629-
RushConfiguration._validateCommonRushConfigFolder(this._commonRushConfigFolder, this.packageManager);
629+
RushConfiguration._validateCommonRushConfigFolder(this._commonRushConfigFolder);
630630

631631
this._projectFolderMinDepth = rushConfigurationJson.projectFolderMinDepth !== undefined
632632
? rushConfigurationJson.projectFolderMinDepth : 1;

0 commit comments

Comments
 (0)