Skip to content

Commit

Permalink
fix(@schematics/angular): update several testing dev dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
alan-agius4 authored and clydin committed Jun 2, 2020
1 parent d44d374 commit a1378a2
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 21 deletions.
10 changes: 5 additions & 5 deletions packages/schematics/angular/migrations/migration-collection.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,6 @@
"factory": "./update-10/update-libraries-tslib",
"description": "Update library projects to use tslib version 2 as a direct dependency."
},
"update-workspace-dependencies": {
"version": "10.0.0-rc.1",
"factory": "./update-10/update-dependencies",
"description": "Workspace dependencies updates."
},
"solution-style-tsconfig": {
"version": "10.0.0-beta.7",
"factory": "./update-10/solution-style-tsconfig",
Expand All @@ -109,6 +104,11 @@
"version": "10.0.0-rc.1",
"factory": "./update-10/update-module-and-target-compiler-options",
"description": "Update 'module' and 'target' TypeScript compiler options."
},
"update-workspace-dependencies": {
"version": "10.0.0-rc.2",
"factory": "./update-10/update-dependencies",
"description": "Workspace dependencies updates."
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/
import { Rule } from '@angular-devkit/schematics';
import { NodePackageInstallTask } from '@angular-devkit/schematics/tasks';
import {
addPackageJsonDependency,
getPackageJsonDependency,
Expand All @@ -15,13 +16,19 @@ import { latestVersions } from '../../utility/latest-versions';
export default function (): Rule {
return (host, context) => {
const dependenciesToUpdate: Record<string, string> = {
'jasmine-core': '~3.5.0',
'jasmine-spec-reporter': '~5.0.0',
'karma': '~5.0.0',
'karma-chrome-launcher': '~3.1.0',
'karma-coverage-istanbul-reporter': '~3.0.2',
'karma-jasmine': '~3.3.0',
'karma-jasmine-html-reporter': '^1.5.0',
'protractor': '~7.0.0',
'ng-packagr': latestVersions.ngPackagr,
'tslib': '^2.0.0',
};

let hasChanges = false;
for (const [name, version] of Object.entries(dependenciesToUpdate)) {
const current = getPackageJsonDependency(host, name);
if (!current || current.version === version) {
Expand All @@ -34,6 +41,12 @@ export default function (): Rule {
version,
overwrite: true,
});

hasChanges = true;
}

if (hasChanges) {
context.addTask(new NodePackageInstallTask());
}

// Check for @angular-devkit/schematics and @angular-devkit/core
Expand Down
19 changes: 3 additions & 16 deletions tests/legacy-cli/e2e/tests/update/update-7.0.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,12 @@
import * as fs from 'fs';
import { createProjectFromAsset } from '../../utils/assets';
import { expectFileMatchToExist, expectFileToExist, expectFileToMatch } from '../../utils/fs';
import { ng, noSilentNg, silentNpm } from '../../utils/process';
import { isPrereleaseCli, useBuiltPackages, useCIChrome, useCIDefaults } from '../../utils/project';
import { expectToFail } from '../../utils/utils';

export default async function() {
const extraUpdateArgs = (await isPrereleaseCli()) ? ['--next', '--force'] : [];

// Create new project from previous version files.
// We must use the original NPM packages to force a real update.
await createProjectFromAsset('7.0-project', true);
// Update to version 8, to use the self update CLI feature.
await ng('update', '@angular/cli@8');

fs.writeFileSync('.npmrc', 'registry = http://localhost:4873', 'utf8');

// Update the CLI.
// Users of CLI <7.2 will see the following warnings:
// packageGroup metadata of package @angular/cli is malformed. Ignoring.
// This is expected since the format changed in 7.2.
await ng('update', '@angular/cli', ...extraUpdateArgs);
await createProjectFromAsset('7.0-project');
await ng('update', '@angular/cli', '--migrate-only', '--from=7');

// Test CLI migrations.
// Should update the lazy route syntax via update-lazy-module-paths.
Expand All @@ -44,6 +30,7 @@ export default async function() {
await silentNpm('install');

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

// Run CLI commands.
Expand Down

0 comments on commit a1378a2

Please sign in to comment.