forked from microsoft/rushstack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCommandLineMigrationAdvisor.ts
More file actions
63 lines (53 loc) · 2.23 KB
/
CommandLineMigrationAdvisor.ts
File metadata and controls
63 lines (53 loc) · 2.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
import * as colors from 'colors';
import { RushConstants } from '../logic/RushConstants';
import { Utilities } from '../utilities/Utilities';
export class CommandLineMigrationAdvisor {
// NOTE: THIS RUNS BEFORE THE REAL COMMAND-LINE PARSING.
// TAKE EXTREME CARE THAT THE HEURISTICS CANNOT FALSELY MATCH A VALID COMMAND LINE.
public static checkArgv(argv: string[]): boolean {
// 0=node.exe, 1=script name
const args: string[] = process.argv.slice(2);
if (args.length > 0) {
if (args[0] === 'generate') {
CommandLineMigrationAdvisor._reportDeprecated(
'Instead of "rush generate", use "rush update" or "rush update --full".');
return false;
}
if (args[0] === 'install') {
if (args.indexOf('--full-clean') >= 0) {
CommandLineMigrationAdvisor._reportDeprecated(
'Instead of "rush install --full-clean", use "rush purge --unsafe".');
return false;
}
if (args.indexOf('-C') >= 0) {
CommandLineMigrationAdvisor._reportDeprecated(
'Instead of "rush install -C", use "rush purge --unsafe".');
return false;
}
if (args.indexOf('--clean') >= 0) {
CommandLineMigrationAdvisor._reportDeprecated(
'Instead of "rush install --clean", use "rush install --purge".');
return false;
}
if (args.indexOf('-c') >= 0) {
CommandLineMigrationAdvisor._reportDeprecated(
'Instead of "rush install -c", use "rush install --purge".');
return false;
}
}
}
// Everything is okay
return true;
}
private static _reportDeprecated(message: string): void {
console.error(colors.red(Utilities.wrapWords(
'ERROR: You specified an outdated command-line that is no longer supported by this version of Rush:'
)));
console.error(colors.yellow(Utilities.wrapWords(message)));
console.error();
console.error(Utilities.wrapWords(`For command-line help, type "rush -h". For migration instructions,`
+ ` please visit ${RushConstants.rushWebSiteUrl}`));
}
}