Skip to content

Commit a0d8d66

Browse files
author
Nick Pape
committed
PR Feedback
1 parent d788f09 commit a0d8d66

3 files changed

Lines changed: 40 additions & 16 deletions

File tree

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

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
import * as colors from 'colors';
55
import * as os from 'os';
6+
import * as path from 'path';
67
import * as fsx from 'fs-extra';
78
import { CommandLineFlagParameter } from '@microsoft/ts-command-line';
89

@@ -105,19 +106,24 @@ export default class GenerateAction extends BaseRushAction {
105106
fsx.unlinkSync(tempShrinkwrapFilename);
106107
}
107108

108-
if (isLazy) {
109-
console.log(colors.green(
110-
`${os.EOL}Rush is running in "--lazy" mode. ` +
111-
`You will need to run a normal "rush generate" before committing.`));
109+
if (isLazy || this.rushConfiguration.packageManager === 'pnpm') {
110+
if (this.rushConfiguration.packageManager === 'npm') {
111+
console.log(colors.green(
112+
`${os.EOL}Rush is running in "--lazy" mode. ` +
113+
`You will need to run a normal "rush generate" before committing.`));
114+
}
112115

113116
// Do an incremental install
114117
installManager.installCommonModules(InstallType.Normal);
115118

116119
if (this.rushConfiguration.packageManager === 'npm') {
117120
console.log(os.EOL + colors.bold('(Skipping "npm shrinkwrap")') + os.EOL);
118-
} else if (this.rushConfiguration.packageManager === 'pnpm') {
119-
console.log(os.EOL + colors.bold('(Deleting "shrinkwrap.yaml")') + os.EOL);
120-
fsx.unlinkSync(tempShrinkwrapFilename);
121+
const packageLogFilePath: string = path.join(this.rushConfiguration.commonTempFolder, 'package.lock');
122+
123+
if (fsx.existsSync(packageLogFilePath)) {
124+
console.log('Removing NPM5\'s "package.lock" file');
125+
fsx.removeSync(packageLogFilePath);
126+
}
121127
}
122128
} else {
123129
// Do a clean install

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

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -485,12 +485,24 @@ export default class InstallManager {
485485
'node_modules');
486486

487487
// This marker file indicates that the last "rush install" completed successfully
488-
const markerFileExistedAtStart: boolean = fsx.existsSync(this.commonNodeModulesMarkerFilename);
488+
let markerFileExistedAndWasValidAtStart: boolean = false;
489+
490+
if (fsx.existsSync(this.commonNodeModulesMarkerFilename)) {
491+
const markerFileContents: string = fsx.readFileSync(this.commonNodeModulesMarkerFilename).toString();
492+
const expectedFileContents: string =
493+
`${this._rushConfiguration.packageManager}@${this._rushConfiguration.packageManagerToolVersion}`;
494+
if (markerFileContents === expectedFileContents) {
495+
markerFileExistedAndWasValidAtStart = true;
496+
}
497+
}
498+
499+
// @todo for PNPM, we should look at the lock file to determine if the store needs to be cleaned
500+
// ie even if the marker file does not exist, the store may be ok if there is no lock file
489501

490502
// If "--clean" or "--full-clean" was specified, or if the last install was interrupted,
491503
// then we will need to delete the node_modules folder. Otherwise, we can do an incremental
492504
// install.
493-
const deletingNodeModules: boolean = installType !== InstallType.Normal || !markerFileExistedAtStart;
505+
const deletingNodeModules: boolean = installType !== InstallType.Normal || !markerFileExistedAndWasValidAtStart;
494506

495507
// Based on timestamps, can we skip this install entirely?
496508
if (!deletingNodeModules) {
@@ -526,13 +538,13 @@ export default class InstallManager {
526538
console.log(`Deleting the "npm-tmp" folder`);
527539
this._asyncRecycler.moveFolder(this._rushConfiguration.npmTmpFolder);
528540

529-
} else if (installType === InstallType.UnsafePurge) {
541+
} else {
530542
console.log(`Deleting the "pnpm-store" folder`);
531543
this._asyncRecycler.moveFolder(this._rushConfiguration.pnpmStoreFolder);
532544
}
533545
}
534546

535-
if (markerFileExistedAtStart) {
547+
if (markerFileExistedAndWasValidAtStart) {
536548
// Delete the successful install file to indicate the install transaction has started
537549
fsx.unlinkSync(this.commonNodeModulesMarkerFilename);
538550
}
@@ -614,8 +626,14 @@ export default class InstallManager {
614626
// One possible solution would be to have the shrinkwrap include information about whether the dependency
615627
// is optional or not, but it does not appear to do so. Also, this would result in strange behavior where
616628
// people would have different node_modules based on their system.
629+
//
630+
// NOTE FOR PNPM:
631+
// PNPM does not appear to support the --no-optional flag at the moment
617632

618-
const installArgs: string[] = ['install', '--no-optional'];
633+
const installArgs: string[] = ['install'];
634+
if (this._rushConfiguration.packageManager === 'npm') {
635+
installArgs.push('--no-optional');
636+
}
619637
this.pushConfigurationArgs(installArgs);
620638

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

‎apps/rush-lib/src/cli/utilities/pnpm/PnpmLinkManager.ts‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,10 @@ export default class PnpmLinkManager extends LinkManager {
6969
project: RushConfigurationProject,
7070
rushLinkJson: IRushLinkJson): void {
7171

72-
// Naively, PNPM creates a directed acyclic graph, rather than a tree
73-
// thus if sp-http and sp-core-library both depend on GCB@1.2.3,
74-
// and GCB@1.2.3 depends on gulp-typescript, then for both cases it must
75-
// be the exact same version of gulp-typescript
72+
// PNPM creates a directed acyclic graph, rather than a tree.
73+
// Thus, imagine "sp-http" and "sp-core-library" both depend on "request"@1.2.3,
74+
// and "request"@1.2.3 depends on "http@*", then both "sp-http" and "sp-core-library"
75+
// must have the exact same version of "http"
7676
// thus, we only need to link the direct dependencies of this project to the
7777
// common folder
7878

0 commit comments

Comments
 (0)