@yolkai/nx-schematics
Version:
63 lines (59 loc) • 2.75 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const fs_1 = require("fs");
const nx_workspace_1 = require("@yolkai/nx-workspace");
const literals_1 = require("@angular-devkit/core/src/utils/literals");
const child_process_1 = require("child_process");
const path_1 = require("path");
exports.default = {
description: `Switch to Nx 6.0`,
run: () => {
if (!fs_1.existsSync('.angular-cli.json') && fs_1.existsSync('angular.json')) {
console.warn(literals_1.stripIndents `
You have already upgraded to Angular CLI 6.
We will not be able to recover information about your project's tags for you.
`);
return;
}
nx_workspace_1.updateJsonFile('package.json', json => {
json.devDependencies['@angular/cli'] = '6.1.2';
});
nx_workspace_1.updateJsonFile('package.json', json => {
delete json.scripts.postinstall;
});
try {
if (fs_1.existsSync('yarn.lock')) {
child_process_1.execSync('yarn install', { stdio: [0, 1, 2] });
}
else {
child_process_1.execSync('npm install', { stdio: [0, 1, 2] });
}
child_process_1.execSync('ng update @angular/cli --from 1.7.4 --to 6.0.1 --migrate-only', {
stdio: [0, 1, 2]
});
const currentVersion = nx_workspace_1.readJsonFile(path_1.join(__dirname, '../../package.json'))
.version;
child_process_1.execSync(`ng generate @schematics/update:migrate --package @yolkai/nx-schematics --collection @yolkai/nx-schematics/migrations/migrations.json --from 1.0.3 --to ${currentVersion}`, {
stdio: [0, 1, 2]
});
}
catch (e) {
console.warn(literals_1.stripIndents `
The automatic upgrade to Nx 6 has failed with the following error: ${e}.
You can upgrade it manually by running:
* yarn install or npm install
* ng update @angular/cli@6.0.1
* ng update @yolkai/nx-schematics@6.0.0
The upgrade process creates a test target for every library. If you have a library
that does not have specs, either set failOnEmptyTestSuite to false in karma.conf.js of the library,
or remove the test target in angular.json.
`);
throw e;
}
console.log(literals_1.stripIndents `
The upgrade process creates a test target for every library. If you have a library
that does not have specs, either set failOnEmptyTestSuite to false in karma.conf.js of the library,
or remove the test target in angular.json.
`);
}
};