Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion packages/angular/cli/src/commands/add/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ export default class AddCommadModule
async run(options: Options<AddCommandArgs> & OtherOptions): Promise<number | void> {
const { logger, packageManager } = this.context;
const { verbose, registry, collection, skipConfirmation } = options;
packageManager.ensureCompatibility();

let packageIdentifier;
try {
Expand Down
9 changes: 0 additions & 9 deletions packages/angular/cli/src/commands/new/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,6 @@ export default class NewCommandModule
});
workflow.registry.addSmartDefaultProvider('ng-cli-version', () => VERSION.full);

// Compatibility check for NPM 7
if (
collectionName === '@schematics/angular' &&
!schematicOptions.skipInstall &&
(schematicOptions.packageManager === undefined || schematicOptions.packageManager === 'npm')
) {
this.context.packageManager.ensureCompatibility();
}

return this.runSchematic({
collectionName,
schematicName: this.schematicName,
Expand Down
2 changes: 0 additions & 2 deletions packages/angular/cli/src/commands/update/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,6 @@ export default class UpdateCommandModule extends CommandModule<UpdateCommandArgs
async run(options: Options<UpdateCommandArgs>): Promise<number | void> {
const { logger, packageManager } = this.context;

packageManager.ensureCompatibility();

// Check if the current installed CLI version is older than the latest compatible version.
// Skip when running `ng update` without a package name as this will not trigger an actual update.
if (!disableVersionCheck && options.packages?.length) {
Expand Down
27 changes: 0 additions & 27 deletions packages/angular/cli/src/utilities/package-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import { execSync, spawn } from 'child_process';
import { existsSync, promises as fs, realpathSync, rmSync } from 'fs';
import { tmpdir } from 'os';
import { join } from 'path';
import { satisfies, valid } from 'semver';
import { PackageManager } from '../../lib/config/workspace-schema';
import { AngularWorkspace, getProjectByCwd } from './config';
import { memoize } from './memoize';
Expand Down Expand Up @@ -44,32 +43,6 @@ export class PackageManagerUtils {
return this.getVersion(this.name);
}

/**
* Checks if the package manager is supported. If not, display a warning.
*/
ensureCompatibility(): void {
if (this.name !== PackageManager.Npm) {
return;
}

try {
const version = valid(this.version);
if (!version) {
return;
}

if (satisfies(version, '>=7 <7.5.6')) {
// eslint-disable-next-line no-console
console.warn(
`npm version ${version} detected.` +
' When using npm 7 with the Angular CLI, npm version 7.5.6 or higher is recommended.',
);
}
} catch {
// npm is not installed.
}
}

/** Install a single package. */
async install(
packageName: string,
Expand Down
79 changes: 43 additions & 36 deletions tests/legacy-cli/e2e/tests/misc/dedupe-duplicate-modules.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,27 @@
import { expectFileToMatch, writeFile } from '../../utils/fs';
import { expectFileToMatch, rimraf, writeFile } from '../../utils/fs';
import { gitClean } from '../../utils/git';
import { installWorkspacePackages } from '../../utils/packages';
import { ng } from '../../utils/process';
import { updateJsonFile } from '../../utils/project';
import { expectToFail } from '../../utils/utils';

export default async function () {
// Force duplicate modules
await updateJsonFile('package.json', (json) => {
json.dependencies = {
...json.dependencies,
'tslib': '2.0.0',
'tslib-1': 'npm:tslib@1.13.0',
'tslib-1-copy': 'npm:tslib@1.13.0',
};
});
try {
// Force duplicate modules
await updateJsonFile('package.json', (json) => {
json.dependencies = {
...json.dependencies,
'tslib': '2.0.0',
'tslib-1': 'npm:tslib@1.13.0',
'tslib-1-copy': 'npm:tslib@1.13.0',
};
});

await installWorkspacePackages();
await installWorkspacePackages();

await writeFile(
'./src/main.ts',
`
await writeFile(
'./src/main.ts',
`
import { __assign as __assign_0 } from 'tslib';
import { __assign as __assign_1 } from 'tslib-1';
import { __assign as __assign_2 } from 'tslib-1-copy';
Expand All @@ -30,29 +32,34 @@ export default async function () {
__assign_2,
})
`,
);

const { stderr } = await ng(
'build',
'--verbose',
'--no-vendor-chunk',
'--no-progress',
'--configuration=development',
);
const outFile = 'dist/test-project/main.js';
);

if (/\[DedupeModuleResolvePlugin\]:.+tslib-1-copy.+ -> .+tslib-1.+/.test(stderr)) {
await expectFileToMatch(outFile, './node_modules/tslib-1/tslib.es6.js');
await expectToFail(() =>
expectFileToMatch(outFile, './node_modules/tslib-1-copy/tslib.es6.js'),
const { stderr } = await ng(
'build',
'--verbose',
'--no-vendor-chunk',
'--no-progress',
'--configuration=development',
);
} else if (/\[DedupeModuleResolvePlugin\]:.+tslib-1.+ -> .+tslib-1-copy.+/.test(stderr)) {
await expectFileToMatch(outFile, './node_modules/tslib-1-copy/tslib.es6.js');
await expectToFail(() => expectFileToMatch(outFile, './node_modules/tslib-1/tslib.es6.js'));
} else {
console.error(`\n\n\n${stderr}\n\n\n`);
throw new Error('Expected stderr to contain [DedupeModuleResolvePlugin] log for tslib.');
}
const outFile = 'dist/test-project/main.js';

await expectFileToMatch(outFile, './node_modules/tslib/tslib.es6.js');
if (/\[DedupeModuleResolvePlugin\]:.+tslib-1-copy.+ -> .+tslib-1.+/.test(stderr)) {
await expectFileToMatch(outFile, './node_modules/tslib-1/tslib.es6.js');
await expectToFail(() =>
expectFileToMatch(outFile, './node_modules/tslib-1-copy/tslib.es6.js'),
);
} else if (/\[DedupeModuleResolvePlugin\]:.+tslib-1.+ -> .+tslib-1-copy.+/.test(stderr)) {
await expectFileToMatch(outFile, './node_modules/tslib-1-copy/tslib.es6.js');
await expectToFail(() => expectFileToMatch(outFile, './node_modules/tslib-1/tslib.es6.js'));
} else {
console.error(`\n\n\n${stderr}\n\n\n`);
throw new Error('Expected stderr to contain [DedupeModuleResolvePlugin] log for tslib.');
}

await expectFileToMatch(outFile, './node_modules/tslib/tslib.es6.js');
} finally {
await rimraf('node_modules/tslib');
await gitClean();
await installWorkspacePackages();
}
}
110 changes: 0 additions & 110 deletions tests/legacy-cli/e2e/tests/misc/npm-7.ts

This file was deleted.