Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(@schematics/angular): remove DevkitBuildNgPackagr and DevkitBuildWebpack from latest-versions #20299

Merged
merged 2 commits into from Mar 17, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -23,7 +23,7 @@ export function updateDevkitBuildNgPackagr(): Rule {
{
type: existing.type,
name: '@angular-devkit/build-ng-packagr',
version: latestVersions.DevkitBuildNgPackagr,
version: '^4.2.0',
overwrite: true,
},
);
Expand Down
Expand Up @@ -47,6 +47,6 @@ describe('updateDevkitBuildNgPackagr', () => {
const content = tree2.readContent('/package.json');
const pkg = JSON.parse(content);
expect(pkg.devDependencies['@angular-devkit/build-ng-packagr'])
.toBe(latestVersions.DevkitBuildNgPackagr);
.toBe('^4.2.0');
});
});
Expand Up @@ -13,12 +13,12 @@ export function updateDependencies() {
return (host: Tree) => {
const dependenciesToUpdate: Record<string, string> = {
'@angular/pwa': '^0.803.9',
'@angular-devkit/build-angular': latestVersions.DevkitBuildAngular,
'@angular-devkit/build-ng-packagr': latestVersions.DevkitBuildNgPackagr,
'@angular-devkit/build-webpack': latestVersions.DevkitBuildWebpack,
'zone.js': latestVersions.ZoneJs,
'@angular-devkit/build-angular': '~0.803.9',
'@angular-devkit/build-ng-packagr': '~0.803.9',
'@angular-devkit/build-webpack': '~0.803.9',
'zone.js': '~0.10.0',
tsickle: '^0.37.0',
'ng-packagr': latestVersions.ngPackagr,
'ng-packagr': '^5.0.0',
'web-animations-js': '^2.3.2',
};

Expand Down
Expand Up @@ -16,11 +16,11 @@ import { latestVersions } from '../../utility/latest-versions';
export function updateDependencies(): Rule {
return (host, context) => {
const dependenciesToUpdate: Record<string, string> = {
'@angular-devkit/build-angular': latestVersions.DevkitBuildAngular,
'@angular-devkit/build-ng-packagr': latestVersions.DevkitBuildNgPackagr,
'@angular-devkit/build-webpack': latestVersions.DevkitBuildWebpack,
'zone.js': latestVersions.ZoneJs,
'ng-packagr': latestVersions.ngPackagr,
'@angular-devkit/build-angular': '~0.901.15',
'@angular-devkit/build-ng-packagr': '~0.901.15',
'@angular-devkit/build-webpack': '~0.901.15',
'zone.js': '~0.10.0',
'ng-packagr': '^9.0.0',
'web-animations-js': '^2.3.2',
'codelyzer': '^5.1.2',
'@types/node': '^12.11.1',
Expand Down
2 changes: 0 additions & 2 deletions packages/schematics/angular/utility/latest-versions.ts
Expand Up @@ -19,8 +19,6 @@ export const latestVersions = {
// During RC periods they will not match the latest RC until there's a new git tag, and
// should not be updated.
DevkitBuildAngular: '~0.1200.0-next.3',
DevkitBuildNgPackagr: '~0.1200.0-next.3',
DevkitBuildWebpack: '~0.1200.0-next.3',

ngPackagr: '^12.0.0-next.0',
};
3 changes: 1 addition & 2 deletions tests/legacy-cli/e2e/assets/8.0-project/tsconfig.spec.json
Expand Up @@ -3,8 +3,7 @@
"compilerOptions": {
"outDir": "./out-tsc/spec",
"types": [
"jasmine",
"node"
"jasmine"
]
},
"files": [
Expand Down
10 changes: 2 additions & 8 deletions tests/legacy-cli/e2e/setup/500-create-project.ts
Expand Up @@ -2,6 +2,7 @@ import { join } from 'path';
import { getGlobalVariable } from '../utils/env';
import { expectFileToExist, writeFile } from '../utils/fs';
import { gitClean } from '../utils/git';
import { setRegistry as setNPMConfigRegistry } from '../utils/packages';
import { ng, npm } from '../utils/process';
import { prepareProjectForE2e, updateJsonFile } from '../utils/project';

Expand All @@ -21,14 +22,7 @@ export default async function() {
const isCI = getGlobalVariable('ci');

// Ensure local test registry is used when outside a project
if (isCI) {
// Safe to set a user configuration on CI
await npm('config', 'set', 'registry', testRegistry);
} else {
// Yarn does not use the environment variable so an .npmrc file is also required
await writeFile('.npmrc', `registry=${testRegistry}`);
process.env['NPM_CONFIG_REGISTRY'] = testRegistry;
}
await setNPMConfigRegistry(true);

await ng('new', 'test-project', '--skip-install', ...extraArgs);
await expectFileToExist(join(process.cwd(), 'test-project'));
Expand Down
44 changes: 34 additions & 10 deletions tests/legacy-cli/e2e/tests/update/update-8.ts
@@ -1,23 +1,47 @@
import { createProjectFromAsset } from '../../utils/assets';
import { expectFileMatchToExist } from '../../utils/fs';
import { installWorkspacePackages } from '../../utils/packages';
import { ng, noSilentNg, silentNpm } from '../../utils/process';
import { getGlobalVariable } from '../../utils/env';
import { expectFileMatchToExist, rimraf, writeFile } from '../../utils/fs';
import { installWorkspacePackages, setRegistry } from '../../utils/packages';
import { ng, noSilentNg } from '../../utils/process';
import { isPrereleaseCli, useBuiltPackages, useCIChrome, useCIDefaults } from '../../utils/project';

export default async function() {
await createProjectFromAsset('8.0-project');
await ng('update', '@angular/cli', '--migrate-only', '--from=8');
export default async function () {
await createProjectFromAsset('8.0-project', true, true);

// We need to use the public registry because in the local NPM server we don't have
// older versions @angular/cli packages which would cause `npm install` during `ng update` to fail.
try {
await setRegistry(false);

await useBuiltPackages();
await installWorkspacePackages();

// Update Angular CLI.
await ng('update', '@angular/cli', '--migrate-only', '--from=8');
} finally {
await setRegistry(true);
}

if (!getGlobalVariable('ci')) {
const testRegistry = getGlobalVariable('package-registry');
await writeFile('.npmrc', `registry=${testRegistry}`);
}

// Update Angular.
const extraUpdateArgs = await isPrereleaseCli() ? ['--next', '--force'] : [];
await ng('update', '@angular/core', ...extraUpdateArgs);

// Use the packages we are building in this commit, and CI Chrome.
await useBuiltPackages();
await useCIChrome('./');
await useCIChrome('./e2e/');
await useCIDefaults('eight-project');
await installWorkspacePackages();

// Update Angular.
const extraUpdateArgs = await isPrereleaseCli() ? ['--next', '--force'] : [];
await ng('update', '@angular/core', ...extraUpdateArgs);
// This is needed as otherwise causes local modules not to override already present modules
await rimraf('node_modules/@angular-devkit');
await rimraf('node_modules/@angular/cli');

await installWorkspacePackages();

// Run CLI commands.
await ng('generate', 'component', 'my-comp');
Expand Down
21 changes: 20 additions & 1 deletion tests/legacy-cli/e2e/utils/packages.ts
@@ -1,5 +1,6 @@
import { getGlobalVariable } from './env';
import { ProcessOutput, silentNpm, silentYarn } from './process';
import { writeFile } from './fs';
import { ProcessOutput, npm, silentNpm, silentYarn } from './process';

export function getActivePackageManager(): 'npm' | 'yarn' {
const value = getGlobalVariable('package-manager');
Expand Down Expand Up @@ -39,3 +40,21 @@ export async function uninstallPackage(name: string): Promise<ProcessOutput> {
return silentYarn('remove', name);
}
}

export async function setRegistry(useTestRegistry: boolean): Promise<void> {
const url = useTestRegistry
? getGlobalVariable('package-registry')
: 'https://registry.npmjs.org';

const isCI = getGlobalVariable('ci');

// Ensure local test registry is used when outside a project
if (isCI) {
// Safe to set a user configuration on CI
await npm('config', 'set', 'registry', url);
} else {
// Yarn does not use the environment variable so an .npmrc file is also required
await writeFile('.npmrc', `registry=${url}`);
process.env['NPM_CONFIG_REGISTRY'] = url;
}
}