mirror of
https://github.com/angular/angular-cli.git
synced 2025-05-21 05:52:41 +08:00
fix(@angular/cli): on postinstall show a message if using an old version of CLI
Fix #10258
This commit is contained in:
parent
ce0de40ef6
commit
73075b7235
43
packages/@angular/cli/bin/ng-update-message.js
Executable file
43
packages/@angular/cli/bin/ng-update-message.js
Executable file
@ -0,0 +1,43 @@
|
||||
#!/usr/bin/env node
|
||||
'use strict';
|
||||
|
||||
// Check if the current directory contains '.angular-cli.json'. If it does, show a message to the user that they
|
||||
// should use the migration script.
|
||||
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
|
||||
let found = false;
|
||||
let current = path.dirname(path.dirname(__dirname));
|
||||
while (current !== path.dirname(current)) {
|
||||
if (fs.existsSync(path.join(current, 'angular-cli.json'))
|
||||
|| fs.existsSync(path.join(current, '.angular-cli.json'))) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
if (fs.existsSync(path.join(current, 'angular.json'))
|
||||
|| fs.existsSync(path.join(current, '.angular.json'))
|
||||
|| fs.existsSync(path.join(current, 'package.json'))) {
|
||||
break;
|
||||
}
|
||||
|
||||
current = path.dirname(current);
|
||||
}
|
||||
|
||||
|
||||
if (found) {
|
||||
// ------------------------------------------------------------------------------------------
|
||||
// If changing this message, please update the same message in
|
||||
// `packages/@angular/cli/models/command-runner.ts`
|
||||
|
||||
// eslint-disable-next-line no-console
|
||||
console.error(`\u001b[31m
|
||||
${'='.repeat(80)}
|
||||
An old CLI configuration has been detected, which needs to be updated to the latest version.
|
||||
|
||||
Please run the following command to update this workspace:
|
||||
ng update @angular/cli --migrate-only --from=1
|
||||
${'='.repeat(80)}
|
||||
\u001b[39m`.replace(/^ {4}/gm, ''));
|
||||
}
|
@ -298,13 +298,14 @@ function verifyWorkspace(command: Command, executionScope: CommandScope, root: s
|
||||
|
||||
// If an old configuration file is found, throw an exception.
|
||||
if (oldConfigFilePath) {
|
||||
// ------------------------------------------------------------------------------------------
|
||||
// If changing this message, please update the same message in
|
||||
// `packages/@angular/cli/bin/ng-update-message.js`
|
||||
throw new SilentError(tags.stripIndent`
|
||||
An old project has been detected, which needs to be updated to Angular CLI 6.
|
||||
An old CLI configuration has been detected, which needs to be updated to the latest version.
|
||||
|
||||
Please run the following commands to update this project.
|
||||
|
||||
ng update @angular/cli --migrate-only --from=1.7.1
|
||||
npm i
|
||||
Please run the following command to update this workspace:
|
||||
ng update @angular/cli --migrate-only --from=1
|
||||
`);
|
||||
}
|
||||
|
||||
|
@ -12,6 +12,9 @@
|
||||
"angular-cli",
|
||||
"Angular CLI"
|
||||
],
|
||||
"scripts": {
|
||||
"postinstall": "node ./bin/ng-update-message.js"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/angular/angular-cli.git"
|
||||
|
Loading…
x
Reference in New Issue
Block a user