diff --git a/tests/legacy-cli/e2e/tests/build/build-app-shell-with-schematic.ts b/tests/legacy-cli/e2e/tests/build/build-app-shell-with-schematic.ts index cdbef3d36c..4d6b61a7b6 100644 --- a/tests/legacy-cli/e2e/tests/build/build-app-shell-with-schematic.ts +++ b/tests/legacy-cli/e2e/tests/build/build-app-shell-with-schematic.ts @@ -1,6 +1,7 @@ import { getGlobalVariable } from '../../utils/env'; import { appendToFile, expectFileToMatch } from '../../utils/fs'; -import { ng, silentNpm } from '../../utils/process'; +import { installPackage } from '../../utils/packages'; +import { ng } from '../../utils/process'; import { updateJsonFile } from '../../utils/project'; const snapshots = require('../../ng-snapshot/package.json'); @@ -23,7 +24,7 @@ export default async function () { }); for (const pkg of packagesToInstall) { - await silentNpm('install', pkg); + await installPackage(pkg); } } diff --git a/tests/legacy-cli/e2e/tests/build/build-app-shell.ts b/tests/legacy-cli/e2e/tests/build/build-app-shell.ts index e74e4f1de8..60e430619c 100644 --- a/tests/legacy-cli/e2e/tests/build/build-app-shell.ts +++ b/tests/legacy-cli/e2e/tests/build/build-app-shell.ts @@ -1,7 +1,8 @@ import { stripIndent } from 'common-tags'; import { getGlobalVariable } from '../../utils/env'; import { expectFileToMatch, writeFile } from '../../utils/fs'; -import { ng, npm } from '../../utils/process'; +import { installWorkspacePackages } from '../../utils/packages'; +import { ng } from '../../utils/process'; import { updateJsonFile } from '../../utils/project'; import { readNgVersion } from '../../utils/version'; @@ -159,7 +160,7 @@ export default function() { updateJsonFile('package.json', packageJson => { const dependencies = packageJson['dependencies']; dependencies['@angular/platform-server'] = platformServerVersion; - }).then(() => npm('install')), + }).then(() => installWorkspacePackages()), ) .then(() => ng('run', 'test-project:app-shell')) .then(() => expectFileToMatch('dist/test-project/index.html', /shell Works!/)); diff --git a/tests/legacy-cli/e2e/tests/build/material.ts b/tests/legacy-cli/e2e/tests/build/material.ts index 3719bc4eab..4ee43b0f5a 100644 --- a/tests/legacy-cli/e2e/tests/build/material.ts +++ b/tests/legacy-cli/e2e/tests/build/material.ts @@ -1,6 +1,7 @@ import { getGlobalVariable } from '../../utils/env'; import { replaceInFile } from '../../utils/fs'; -import { ng, silentNpm } from '../../utils/process'; +import { installPackage, installWorkspacePackages } from '../../utils/packages'; +import { ng } from '../../utils/process'; import { isPrereleaseCli, updateJsonFile } from '../../utils/project'; const snapshots = require('../../ng-snapshot/package.json'); @@ -25,12 +26,12 @@ export default async function () { snapshots.dependencies['@angular/material-moment-adapter']; }); - await silentNpm('install'); + await installWorkspacePackages(); } else { - await silentNpm('install', '@angular/material-moment-adapter'); + await installPackage('@angular/material-moment-adapter'); } - await silentNpm('install', 'moment'); + await installPackage('moment'); await ng('build', '--prod'); diff --git a/tests/legacy-cli/e2e/tests/build/platform-server.ts b/tests/legacy-cli/e2e/tests/build/platform-server.ts index c026a15c05..1d0e992820 100644 --- a/tests/legacy-cli/e2e/tests/build/platform-server.ts +++ b/tests/legacy-cli/e2e/tests/build/platform-server.ts @@ -1,6 +1,7 @@ import { normalize } from 'path'; import { getGlobalVariable } from '../../utils/env'; import { appendToFile, expectFileToMatch, writeFile } from '../../utils/fs'; +import { installPackage } from '../../utils/packages'; import { exec, ng, silentNpm } from '../../utils/process'; import { isPrereleaseCli, updateJsonFile } from '../../utils/project'; @@ -37,7 +38,7 @@ export default async function () { }); for (const pkg of packagesToInstall) { - await silentNpm('install', pkg); + await installPackage(pkg); } } diff --git a/tests/legacy-cli/e2e/tests/build/service-worker.ts b/tests/legacy-cli/e2e/tests/build/service-worker.ts index 670f40e1e4..df7c3e358c 100644 --- a/tests/legacy-cli/e2e/tests/build/service-worker.ts +++ b/tests/legacy-cli/e2e/tests/build/service-worker.ts @@ -1,7 +1,8 @@ import {join} from 'path'; import {getGlobalVariable} from '../../utils/env'; import {expectFileNotToExist, expectFileToExist, expectFileToMatch, writeFile} from '../../utils/fs'; -import {ng, npm, silentNpm} from '../../utils/process'; +import { installPackage, uninstallPackage } from '../../utils/packages'; +import {ng} from '../../utils/process'; const MANIFEST = { index: '/index.html', @@ -25,8 +26,8 @@ const MANIFEST = { export default function() { // Can't use the `ng` helper because somewhere the environment gets // stuck to the first build done - return silentNpm('remove', '@angular/service-worker') - .then(() => silentNpm('install', '@angular/service-worker')) + return uninstallPackage('@angular/service-worker') + .then(() => installPackage('@angular/service-worker')) .then(() => ng('config', 'projects.test-project.architect.build.options.serviceWorker', 'true')) .then(() => writeFile('src/ngsw-config.json', JSON.stringify(MANIFEST, null, 2))) .then(() => ng('build', '--optimization')) diff --git a/tests/legacy-cli/e2e/tests/build/styles/material-import.ts b/tests/legacy-cli/e2e/tests/build/styles/material-import.ts index 3c2b6f6caf..bbdf53c52a 100644 --- a/tests/legacy-cli/e2e/tests/build/styles/material-import.ts +++ b/tests/legacy-cli/e2e/tests/build/styles/material-import.ts @@ -4,7 +4,8 @@ import { replaceInFile, writeMultipleFiles, } from '../../../utils/fs'; -import { ng, silentNpm } from '../../../utils/process'; +import { installWorkspacePackages } from '../../../utils/packages'; +import { ng } from '../../../utils/process'; import { updateJsonFile } from '../../../utils/project'; const snapshots = require('../../../ng-snapshot/package.json'); @@ -19,7 +20,7 @@ export default async function () { dependencies['@angular/cdk'] = isSnapshotBuild ? snapshots.dependencies['@angular/cdk'] : 'latest'; }); - await silentNpm('install'); + await installWorkspacePackages(); for (const ext of ['css', 'scss', 'less', 'styl']) { await writeMultipleFiles({ diff --git a/tests/legacy-cli/e2e/tests/build/styles/node-sass.ts b/tests/legacy-cli/e2e/tests/build/styles/node-sass.ts index 4c9d116a51..cedd837836 100644 --- a/tests/legacy-cli/e2e/tests/build/styles/node-sass.ts +++ b/tests/legacy-cli/e2e/tests/build/styles/node-sass.ts @@ -4,7 +4,8 @@ import { replaceInFile, writeMultipleFiles, } from '../../../utils/fs'; -import { ng, silentExec, silentNpm } from '../../../utils/process'; +import { installPackage } from '../../../utils/packages'; +import { ng, silentExec } from '../../../utils/process'; import { updateJsonFile } from '../../../utils/project'; import { expectToFail } from '../../../utils/utils'; @@ -32,7 +33,7 @@ export default async function () { await silentExec('rm', '-rf', 'node_modules/sass'); await expectToFail(() => ng('build', '--extract-css', '--source-map')); - await silentNpm('install', 'node-sass'); + await installPackage('node-sass'); await silentExec('rm', '-rf', 'node_modules/sass'); await ng('build', '--extract-css', '--source-map'); @@ -41,9 +42,9 @@ export default async function () { await expectToFail(() => expectFileToMatch('dist/test-project/styles.css', '"mappings":""')); await expectFileToMatch('dist/test-project/main.js', /.outer.*.inner.*background:\s*#[fF]+/); - await silentNpm('install', 'node-gyp'); - await silentNpm('install', 'fibers'); - await silentNpm('install', 'sass'); + await installPackage('node-gyp'); + await installPackage('fibers'); + await installPackage('sass'); await silentExec('rm', '-rf', 'node_modules/node-sass'); await ng('build', '--extract-css', '--source-map'); diff --git a/tests/legacy-cli/e2e/tests/commands/add/add-pwa-yarn.ts b/tests/legacy-cli/e2e/tests/commands/add/add-pwa-yarn.ts index 37f9299542..4730f1f1ef 100644 --- a/tests/legacy-cli/e2e/tests/commands/add/add-pwa-yarn.ts +++ b/tests/legacy-cli/e2e/tests/commands/add/add-pwa-yarn.ts @@ -1,8 +1,13 @@ import { join } from 'path'; +import { getGlobalVariable } from '../../../utils/env'; import { expectFileToExist, readFile, rimraf } from '../../../utils/fs'; import { ng, npm } from '../../../utils/process'; export default async function () { + if (getGlobalVariable('package-manager') === 'yarn') { + return; + } + // forcibly remove in case another test doesn't clean itself up await rimraf('node_modules/@angular/pwa'); diff --git a/tests/legacy-cli/e2e/tests/i18n/extract-ivy-libraries.ts b/tests/legacy-cli/e2e/tests/i18n/extract-ivy-libraries.ts index f61b7f7cb3..71418bfbe2 100644 --- a/tests/legacy-cli/e2e/tests/i18n/extract-ivy-libraries.ts +++ b/tests/legacy-cli/e2e/tests/i18n/extract-ivy-libraries.ts @@ -1,6 +1,7 @@ import { getGlobalVariable } from '../../utils/env'; import { expectFileToMatch, replaceInFile, writeFile } from '../../utils/fs'; -import { ng, npm } from '../../utils/process'; +import { installPackage, uninstallPackage } from '../../utils/packages'; +import { ng } from '../../utils/process'; import { readNgVersion } from '../../utils/version'; export default async function() { @@ -57,7 +58,7 @@ export default async function() { if (getGlobalVariable('argv')['ng-snapshots']) { localizeVersion = require('../../ng-snapshot/package.json').dependencies['@angular/localize']; } - await npm('install', `${localizeVersion}`); + await installPackage(localizeVersion); // Extract messages await ng('xi18n', '--ivy'); @@ -69,5 +70,5 @@ export default async function() { 'projects/i18n-lib-test/src/lib/i18n-lib-test.component.ts', ); - await npm('uninstall', '@angular/localize'); + await uninstallPackage('@angular/localize'); } diff --git a/tests/legacy-cli/e2e/tests/i18n/extract-ivy.ts b/tests/legacy-cli/e2e/tests/i18n/extract-ivy.ts index b31d61baa3..e9e61ef7db 100644 --- a/tests/legacy-cli/e2e/tests/i18n/extract-ivy.ts +++ b/tests/legacy-cli/e2e/tests/i18n/extract-ivy.ts @@ -1,7 +1,8 @@ import { join } from 'path'; import { getGlobalVariable } from '../../utils/env'; import { writeFile } from '../../utils/fs'; -import { ng, npm } from '../../utils/process'; +import { installPackage, uninstallPackage } from '../../utils/packages'; +import { ng } from '../../utils/process'; import { updateJsonFile } from '../../utils/project'; import { expectToFail } from '../../utils/utils'; import { readNgVersion } from '../../utils/version'; @@ -30,7 +31,7 @@ export default async function() { if (getGlobalVariable('argv')['ng-snapshots']) { localizeVersion = require('../../ng-snapshot/package.json').dependencies['@angular/localize']; } - await npm('install', `${localizeVersion}`); + await installPackage(localizeVersion); // Should show ivy enabled application warning without --ivy flag const { stderr: message3 } = await ng('xi18n', '--no-ivy'); @@ -57,5 +58,5 @@ export default async function() { throw new Error('Expected ivy disabled application warning'); } - await npm('uninstall', '@angular/localize'); + await uninstallPackage('@angular/localize'); } diff --git a/tests/legacy-cli/e2e/tests/i18n/ivy-localize-app-shell.ts b/tests/legacy-cli/e2e/tests/i18n/ivy-localize-app-shell.ts index f6be20dfca..ddb6fbce80 100644 --- a/tests/legacy-cli/e2e/tests/i18n/ivy-localize-app-shell.ts +++ b/tests/legacy-cli/e2e/tests/i18n/ivy-localize-app-shell.ts @@ -7,7 +7,8 @@ import { replaceInFile, writeFile, } from '../../utils/fs'; -import { ng, silentNpm } from '../../utils/process'; +import { installWorkspacePackages } from '../../utils/packages'; +import { ng } from '../../utils/process'; import { updateJsonFile } from '../../utils/project'; import { readNgVersion } from '../../utils/version'; @@ -38,7 +39,7 @@ export default async function () { }); } - await silentNpm('install'); + await installWorkspacePackages(); const browserBaseDir = 'dist/test-project/browser'; diff --git a/tests/legacy-cli/e2e/tests/i18n/ivy-localize-server.ts b/tests/legacy-cli/e2e/tests/i18n/ivy-localize-server.ts index 7350c23a96..412a6fa52b 100644 --- a/tests/legacy-cli/e2e/tests/i18n/ivy-localize-server.ts +++ b/tests/legacy-cli/e2e/tests/i18n/ivy-localize-server.ts @@ -2,7 +2,8 @@ import * as express from 'express'; import { join } from 'path'; import { getGlobalVariable } from '../../utils/env'; import { appendToFile, expectFileToMatch, writeFile } from '../../utils/fs'; -import { ng, silentNpm } from '../../utils/process'; +import { installWorkspacePackages } from '../../utils/packages'; +import { ng } from '../../utils/process'; import { updateJsonFile } from '../../utils/project'; import { expectToFail } from '../../utils/utils'; import { langTranslations, setupI18nConfig } from './legacy'; @@ -27,7 +28,7 @@ export default async function () { }); } - await silentNpm('install'); + await installWorkspacePackages(); const serverbaseDir = 'dist/test-project/server'; const serverBuildArgs = ['run', 'test-project:server']; diff --git a/tests/legacy-cli/e2e/tests/i18n/ivy-localize-serviceworker.ts b/tests/legacy-cli/e2e/tests/i18n/ivy-localize-serviceworker.ts index 242b878054..1b7b26a92f 100644 --- a/tests/legacy-cli/e2e/tests/i18n/ivy-localize-serviceworker.ts +++ b/tests/legacy-cli/e2e/tests/i18n/ivy-localize-serviceworker.ts @@ -8,7 +8,8 @@ import { replaceInFile, writeFile, } from '../../utils/fs'; -import { ng, npm } from '../../utils/process'; +import { installPackage } from '../../utils/packages'; +import { ng } from '../../utils/process'; import { updateJsonFile } from '../../utils/project'; import { expectToFail } from '../../utils/utils'; import { readNgVersion } from '../../utils/version'; @@ -22,7 +23,7 @@ export default async function() { if (getGlobalVariable('argv')['ng-snapshots']) { localizeVersion = require('../../ng-snapshot/package.json').dependencies['@angular/localize']; } - await npm('install', `${localizeVersion}`); + await installPackage(localizeVersion); let serviceWorkerVersion = '@angular/service-worker@' + readNgVersion(); if (getGlobalVariable('argv')['ng-snapshots']) { @@ -30,7 +31,7 @@ export default async function() { '@angular/service-worker' ]; } - await npm('install', `${serviceWorkerVersion}`); + await installPackage(serviceWorkerVersion); await updateJsonFile('tsconfig.json', config => { config.compilerOptions.target = 'es2015'; diff --git a/tests/legacy-cli/e2e/tests/i18n/legacy.ts b/tests/legacy-cli/e2e/tests/i18n/legacy.ts index 238945af8c..a53df4aa75 100644 --- a/tests/legacy-cli/e2e/tests/i18n/legacy.ts +++ b/tests/legacy-cli/e2e/tests/i18n/legacy.ts @@ -2,7 +2,8 @@ import * as express from 'express'; import { resolve } from 'path'; import { getGlobalVariable } from '../../utils/env'; import { appendToFile, copyFile, expectFileToExist, expectFileToMatch, replaceInFile, writeFile } from '../../utils/fs'; -import { ng, npm } from '../../utils/process'; +import { installPackage } from '../../utils/packages'; +import { ng } from '../../utils/process'; import { updateJsonFile } from '../../utils/project'; import { expectToFail } from '../../utils/utils'; import { readNgVersion } from '../../utils/version'; @@ -213,7 +214,7 @@ export async function setupI18nConfig(useLocalize = true, format: keyof typeof f if (getGlobalVariable('argv')['ng-snapshots']) { localizeVersion = require('../../ng-snapshot/package.json').dependencies['@angular/localize']; } - await npm('install', `${localizeVersion}`); + await installPackage(localizeVersion); } // Extract the translation messages. diff --git a/tests/legacy-cli/e2e/tests/i18n/ve-localize-es2015.ts b/tests/legacy-cli/e2e/tests/i18n/ve-localize-es2015.ts index 19d5a45778..0a0094db90 100644 --- a/tests/legacy-cli/e2e/tests/i18n/ve-localize-es2015.ts +++ b/tests/legacy-cli/e2e/tests/i18n/ve-localize-es2015.ts @@ -1,10 +1,11 @@ import { getGlobalVariable } from '../../utils/env'; import { expectFileToMatch, writeFile } from '../../utils/fs'; -import { execAndWaitForOutputToMatch, ng, npm } from '../../utils/process'; +import { installPackage } from '../../utils/packages'; +import { execAndWaitForOutputToMatch, ng } from '../../utils/process'; import { updateJsonFile } from '../../utils/project'; import { expectToFail } from '../../utils/utils'; import { readNgVersion } from '../../utils/version'; -import { baseDir, externalServer, langTranslations, setupI18nConfig } from './legacy'; +import { externalServer, langTranslations, setupI18nConfig } from './legacy'; export default async function() { if (!getGlobalVariable('argv')['ve']) { @@ -19,7 +20,7 @@ export default async function() { if (getGlobalVariable('argv')['ng-snapshots']) { localizeVersion = require('../../ng-snapshot/package.json').dependencies['@angular/localize']; } - await npm('install', `${localizeVersion}`); + await installPackage(localizeVersion); // Ensure a ES2015 build is used. await writeFile('.browserslistrc', 'Chrome 65'); diff --git a/tests/legacy-cli/e2e/tests/misc/common-async.ts b/tests/legacy-cli/e2e/tests/misc/common-async.ts index 9c317e7596..90cf4a0227 100644 --- a/tests/legacy-cli/e2e/tests/misc/common-async.ts +++ b/tests/legacy-cli/e2e/tests/misc/common-async.ts @@ -1,7 +1,7 @@ import {readdirSync} from 'fs'; import {oneLine} from 'common-tags'; - -import {ng, silentNpm} from '../../utils/process'; +import { installPackage } from '../../utils/packages'; +import { ng } from '../../utils/process'; import {appendToFile, expectFileToExist, prependToFile, replaceInFile} from '../../utils/fs'; import {expectToFail} from '../../utils/utils'; @@ -32,7 +32,7 @@ export default function() { } oldNumberOfFiles = currentNumberOfDistFiles; }) - .then(() => silentNpm('install', 'moment')) + .then(() => installPackage('moment')) .then(() => appendToFile('src/app/lazy-a/lazy-a.module.ts', ` import * as moment from 'moment'; console.log(moment); diff --git a/tests/legacy-cli/e2e/tests/misc/dedupe-duplicate-modules.ts b/tests/legacy-cli/e2e/tests/misc/dedupe-duplicate-modules.ts index 090a7587be..4dabe72940 100644 --- a/tests/legacy-cli/e2e/tests/misc/dedupe-duplicate-modules.ts +++ b/tests/legacy-cli/e2e/tests/misc/dedupe-duplicate-modules.ts @@ -1,5 +1,6 @@ import { expectFileToMatch, writeFile } from '../../utils/fs'; -import { ng, silentNpm } from '../../utils/process'; +import { installWorkspacePackages } from '../../utils/packages'; +import { ng } from '../../utils/process'; import { updateJsonFile } from '../../utils/project'; import { expectToFail } from '../../utils/utils'; @@ -14,7 +15,7 @@ export default async function () { }; }); - await silentNpm('install'); + await installWorkspacePackages(); await writeFile('./src/main.ts', ` diff --git a/tests/legacy-cli/e2e/tests/misc/lazy-module.ts b/tests/legacy-cli/e2e/tests/misc/lazy-module.ts index 745a76db63..299ebe5c29 100644 --- a/tests/legacy-cli/e2e/tests/misc/lazy-module.ts +++ b/tests/legacy-cli/e2e/tests/misc/lazy-module.ts @@ -1,6 +1,6 @@ import {readdirSync} from 'fs'; - -import {ng, silentNpm} from '../../utils/process'; +import { installPackage } from '../../utils/packages'; +import {ng} from '../../utils/process'; import {appendToFile, writeFile, prependToFile, replaceInFile} from '../../utils/fs'; @@ -53,7 +53,7 @@ export default function() { oldNumberOfFiles = currentNumberOfDistFiles; }) // verify 'import *' syntax doesn't break lazy modules - .then(() => silentNpm('install', 'moment')) + .then(() => installPackage('moment')) .then(() => appendToFile('src/app/app.component.ts', ` import * as moment from 'moment'; console.log(moment); diff --git a/tests/legacy-cli/e2e/tests/misc/module-resolution.ts b/tests/legacy-cli/e2e/tests/misc/module-resolution.ts index 0396650258..a4db70c883 100644 --- a/tests/legacy-cli/e2e/tests/misc/module-resolution.ts +++ b/tests/legacy-cli/e2e/tests/misc/module-resolution.ts @@ -1,5 +1,6 @@ import { appendToFile, createDir, moveFile, prependToFile } from '../../utils/fs'; -import { ng, silentNpm } from '../../utils/process'; +import { installPackage } from '../../utils/packages'; +import { ng } from '../../utils/process'; import { updateJsonFile } from '../../utils/project'; import { expectToFail } from '../../utils/utils'; @@ -50,11 +51,11 @@ export default async function () { await prependToFile('src/app/app.module.ts', 'import * as firebase from \'firebase\';'); await appendToFile('src/app/app.module.ts', 'firebase.initializeApp({});'); - await silentNpm('install', 'firebase@3.7.8'); + await installPackage('firebase@3.7.8'); await ng('build', '--aot'); await ng('test', '--watch=false'); - await silentNpm('install', 'firebase@4.9.0'); + await installPackage('firebase@4.9.0'); await ng('build', '--aot'); await ng('test', '--watch=false'); diff --git a/tests/legacy-cli/e2e/tests/misc/third-party-decorators.ts b/tests/legacy-cli/e2e/tests/misc/third-party-decorators.ts index 8f6bb0fcf1..40a2b730c1 100644 --- a/tests/legacy-cli/e2e/tests/misc/third-party-decorators.ts +++ b/tests/legacy-cli/e2e/tests/misc/third-party-decorators.ts @@ -1,5 +1,6 @@ import { writeMultipleFiles } from '../../utils/fs'; -import { ng, npm } from '../../utils/process'; +import { installWorkspacePackages } from '../../utils/packages'; +import { ng } from '../../utils/process'; import { updateJsonFile } from '../../utils/project'; export default function () { @@ -10,7 +11,7 @@ export default function () { packageJson['dependencies']['@ngrx/store'] = '^9.1.0'; packageJson['dependencies']['@ngrx/store-devtools'] = '^9.1.0'; }) - .then(() => npm('install')) + .then(() => installWorkspacePackages()) // Create an app that uses ngrx decorators and has e2e tests. .then(_ => writeMultipleFiles({ './e2e/src/app.po.ts': ` diff --git a/tests/legacy-cli/e2e/tests/third-party/bootstrap.ts b/tests/legacy-cli/e2e/tests/third-party/bootstrap.ts index 91ff0215ce..93e372109f 100644 --- a/tests/legacy-cli/e2e/tests/third-party/bootstrap.ts +++ b/tests/legacy-cli/e2e/tests/third-party/bootstrap.ts @@ -1,4 +1,5 @@ -import {silentNpm, ng} from '../../utils/process'; +import { installPackage } from '../../utils/packages'; +import {ng} from '../../utils/process'; import {updateJsonFile} from '../../utils/project'; import {expectFileToMatch} from '../../utils/fs'; import {oneLineTrim} from 'common-tags'; @@ -8,7 +9,7 @@ export default function() { // TODO(architect): Delete this test. It is now in devkit/build-angular. return Promise.resolve() - .then(() => silentNpm('install', 'bootstrap@4.0.0-beta.3')) + .then(() => installPackage('bootstrap@4.0.0-beta.3')) .then(() => updateJsonFile('angular.json', workspaceJson => { const appArchitect = workspaceJson.projects['test-project'].architect; appArchitect.build.options.styles = [ diff --git a/tests/legacy-cli/e2e/tests/third-party/material-icons.ts b/tests/legacy-cli/e2e/tests/third-party/material-icons.ts index 4ced68fbac..3b426329ef 100644 --- a/tests/legacy-cli/e2e/tests/third-party/material-icons.ts +++ b/tests/legacy-cli/e2e/tests/third-party/material-icons.ts @@ -1,10 +1,11 @@ import { expectFileToMatch } from '../../utils/fs'; -import { ng, silentNpm } from '../../utils/process'; +import { installPackage } from '../../utils/packages'; +import { ng } from '../../utils/process'; import { updateJsonFile } from '../../utils/project'; export default async function() { // Install material design icons - await silentNpm('install', 'material-design-icons@3.0.1'); + await installPackage('material-design-icons@3.0.1'); // Add icon stylesheet to application await updateJsonFile('angular.json', workspaceJson => { diff --git a/tests/legacy-cli/e2e/tests/update/update-1.0.ts b/tests/legacy-cli/e2e/tests/update/update-1.0.ts index 6d24c8ffeb..bc9cf4b51d 100644 --- a/tests/legacy-cli/e2e/tests/update/update-1.0.ts +++ b/tests/legacy-cli/e2e/tests/update/update-1.0.ts @@ -1,5 +1,6 @@ import { createProjectFromAsset } from '../../utils/assets'; -import { ng, silentNpm } from '../../utils/process'; +import { installWorkspacePackages } from '../../utils/packages'; +import { ng } from '../../utils/process'; import { isPrereleaseCli, useBuiltPackages, useCIChrome, useCIDefaults } from '../../utils/project'; import { expectToFail } from '../../utils/utils'; @@ -12,7 +13,7 @@ export default async function() { await expectToFail(() => ng('build')); await ng('update', '@angular/cli'); await useBuiltPackages(); - await silentNpm('install'); + await installWorkspacePackages(false); await ng('update', '@angular/core', ...extraUpdateArgs); await useCIDefaults('one-oh-project'); await ng('generate', 'component', 'my-comp'); diff --git a/tests/legacy-cli/e2e/tests/update/update-1.7-longhand.ts b/tests/legacy-cli/e2e/tests/update/update-1.7-longhand.ts index adec63d719..9272ceede0 100644 --- a/tests/legacy-cli/e2e/tests/update/update-1.7-longhand.ts +++ b/tests/legacy-cli/e2e/tests/update/update-1.7-longhand.ts @@ -1,5 +1,6 @@ import { createProjectFromAsset } from '../../utils/assets'; -import { ng, silentNpm } from '../../utils/process'; +import { installWorkspacePackages } from '../../utils/packages'; +import { ng } from '../../utils/process'; import { isPrereleaseCli, useBuiltPackages } from '../../utils/project'; import { expectToFail } from '../../utils/utils'; @@ -11,7 +12,7 @@ export default async function() { await expectToFail(() => ng('build')); await ng('update', '@angular/cli', '--migrate-only', '--from=1.7.1'); await useBuiltPackages(); - await silentNpm('install'); + await installWorkspacePackages(false); await ng('update', '@angular/core', ...extraUpdateArgs); await ng('build'); } diff --git a/tests/legacy-cli/e2e/tests/update/update-1.7.ts b/tests/legacy-cli/e2e/tests/update/update-1.7.ts index 3353686384..41f2c02e46 100644 --- a/tests/legacy-cli/e2e/tests/update/update-1.7.ts +++ b/tests/legacy-cli/e2e/tests/update/update-1.7.ts @@ -1,6 +1,7 @@ import * as fs from 'fs'; import { createProjectFromAsset } from '../../utils/assets'; -import { ng, silentNpm } from '../../utils/process'; +import { installWorkspacePackages } from '../../utils/packages'; +import { ng } from '../../utils/process'; import { isPrereleaseCli, useBuiltPackages, useCIChrome, useCIDefaults } from '../../utils/project'; import { expectToFail } from '../../utils/utils'; @@ -14,7 +15,7 @@ export default async function() { await expectToFail(() => ng('build')); await ng('update', '@angular/cli'); await useBuiltPackages(); - await silentNpm('install'); + await installWorkspacePackages(false); await ng('update', '@angular/core', ...extraUpdateArgs); await useCIDefaults('latest-project'); await ng('generate', 'component', 'my-comp'); diff --git a/tests/legacy-cli/e2e/tests/update/update-7.0.ts b/tests/legacy-cli/e2e/tests/update/update-7.0.ts index ca10c3739f..a00962bf71 100644 --- a/tests/legacy-cli/e2e/tests/update/update-7.0.ts +++ b/tests/legacy-cli/e2e/tests/update/update-7.0.ts @@ -1,5 +1,6 @@ import { createProjectFromAsset } from '../../utils/assets'; import { expectFileMatchToExist, expectFileToExist, expectFileToMatch } from '../../utils/fs'; +import { installWorkspacePackages } from '../../utils/packages'; import { ng, noSilentNg, silentNpm } from '../../utils/process'; import { isPrereleaseCli, useBuiltPackages, useCIChrome, useCIDefaults } from '../../utils/project'; import { expectToFail } from '../../utils/utils'; @@ -27,11 +28,12 @@ export default async function() { await useCIChrome('src/'); await useCIChrome('e2e/'); await useCIDefaults('seven-oh-project'); - await silentNpm('install'); + await installWorkspacePackages(false); // Update Angular. const extraUpdateArgs = (await isPrereleaseCli()) ? ['--next', '--force'] : []; await ng('update', '@angular/core', ...extraUpdateArgs); + await silentNpm('run', 'webdriver-update'); // Run CLI commands. await ng('generate', 'component', 'my-comp'); diff --git a/tests/legacy-cli/e2e/tests/update/update.ts b/tests/legacy-cli/e2e/tests/update/update.ts index 2ed02ee658..b06f6d84fb 100644 --- a/tests/legacy-cli/e2e/tests/update/update.ts +++ b/tests/legacy-cli/e2e/tests/update/update.ts @@ -1,4 +1,5 @@ -import { ng, silentNpm } from '../../utils/process'; +import { installWorkspacePackages } from '../../utils/packages'; +import { ng } from '../../utils/process'; import { readFile, writeFile } from '../../utils/fs'; import { updateJsonFile } from '../../utils/project'; @@ -45,5 +46,5 @@ export default function () { } }) .then(() => writeFile('package.json', origPackageJson)) - .then(() => silentNpm('install')); + .then(() => installWorkspacePackages()); } diff --git a/tests/legacy-cli/e2e/utils/assets.ts b/tests/legacy-cli/e2e/utils/assets.ts index 742af0bc16..80a7851a78 100644 --- a/tests/legacy-cli/e2e/utils/assets.ts +++ b/tests/legacy-cli/e2e/utils/assets.ts @@ -3,8 +3,8 @@ import * as glob from 'glob'; import { getGlobalVariable } from './env'; import { relative, resolve } from 'path'; import { copyFile, writeFile } from './fs'; +import { installWorkspacePackages } from './packages'; import { useBuiltPackages } from './project'; -import { silentNpm } from './process'; export function assetDir(assetName: string) { return join(__dirname, '../assets', assetName); @@ -53,7 +53,7 @@ export async function createProjectFromAsset( } if (!skipInstall) { - await silentNpm('install'); + await installWorkspacePackages(false); } return dir; diff --git a/tests/legacy-cli/e2e/utils/packages.ts b/tests/legacy-cli/e2e/utils/packages.ts new file mode 100644 index 0000000000..4107f4d5d3 --- /dev/null +++ b/tests/legacy-cli/e2e/utils/packages.ts @@ -0,0 +1,46 @@ +import { getGlobalVariable } from './env'; +import { ProcessOutput, silentNpm, silentYarn } from './process'; + +export function getActivePackageManager(): 'npm' | 'yarn' { + const value = getGlobalVariable('package-manager'); + if (value && value !== 'npm' && value !== 'yarn') { + throw new Error('Invalid package manager value: ' + value); + } + + return value || 'npm'; +} + +export async function installWorkspacePackages(updateWebdriver = true): Promise { + switch (getActivePackageManager()) { + case 'npm': + await silentNpm('install'); + if (updateWebdriver) { + await silentNpm('run', 'webdriver-update'); + } + break; + case 'yarn': + await silentYarn(); + if (updateWebdriver) { + await silentYarn('webdriver-update'); + } + break; + } +} + +export async function installPackage(specifier: string): Promise { + switch (getActivePackageManager()) { + case 'npm': + return silentNpm('install', specifier); + case 'yarn': + return silentYarn('add', specifier); + } +} + +export async function uninstallPackage(name: string): Promise { + switch (getActivePackageManager()) { + case 'npm': + return silentNpm('uninstall', name); + case 'yarn': + return silentYarn('remove', name); + } +} diff --git a/tests/legacy-cli/e2e/utils/project.ts b/tests/legacy-cli/e2e/utils/project.ts index e494e8f35c..02d10a1526 100644 --- a/tests/legacy-cli/e2e/utils/project.ts +++ b/tests/legacy-cli/e2e/utils/project.ts @@ -4,7 +4,8 @@ import { packages } from '../../../../lib/packages'; import { getGlobalVariable } from './env'; import { prependToFile, readFile, replaceInFile, writeFile } from './fs'; import { gitCommit } from './git'; -import { execAndWaitForOutputToMatch, git, ng, npm, silentNpm } from './process'; +import { installWorkspacePackages } from './packages'; +import { execAndWaitForOutputToMatch, git, ng, npm } from './process'; const tsConfigPath = 'tsconfig.json'; @@ -94,9 +95,7 @@ export async function prepareProjectForE2e(name) { console.log( `Project ${name} created... Installing npm.`, ); - await silentNpm( - 'install', - ); + await installWorkspacePackages(false); await useCIDefaults( name, ); diff --git a/tests/legacy-cli/e2e_runner.ts b/tests/legacy-cli/e2e_runner.ts index 68c945fd62..d5ff300bf0 100644 --- a/tests/legacy-cli/e2e_runner.ts +++ b/tests/legacy-cli/e2e_runner.ts @@ -143,6 +143,7 @@ if (testsToRun.length == allTests.length) { } setGlobalVariable('argv', argv); +setGlobalVariable('package-manager', argv.yarn ? 'yarn' : 'npm'); // Setup local package registry const registryPath =