/
command-config.ts
114 lines (108 loc) · 2.33 KB
/
command-config.ts
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
import { CommandModuleConstructor } from '../command-builder/utilities/command';
export type CommandNames =
| 'add'
| 'analytics'
| 'build'
| 'cache'
| 'completion'
| 'config'
| 'deploy'
| 'doc'
| 'e2e'
| 'extract-i18n'
| 'generate'
| 'lint'
| 'make-this-awesome'
| 'new'
| 'run'
| 'serve'
| 'test'
| 'update'
| 'version';
export interface CommandConfig {
aliases?: string[];
factory: () => Promise<{ default: CommandModuleConstructor }>;
}
export const RootCommands: Record<
/* Command */ CommandNames & string,
/* Command Config */ CommandConfig
> = {
'add': {
factory: () => import('./add/cli'),
},
'analytics': {
factory: () => import('./analytics/cli'),
},
'build': {
factory: () => import('./build/cli'),
aliases: ['b'],
},
'cache': {
factory: () => import('./cache/cli'),
},
'completion': {
factory: () => import('./completion/cli'),
},
'config': {
factory: () => import('./config/cli'),
},
'deploy': {
factory: () => import('./deploy/cli'),
},
'doc': {
factory: () => import('./doc/cli'),
aliases: ['d'],
},
'e2e': {
factory: () => import('./e2e/cli'),
aliases: ['e2e'],
},
'extract-i18n': {
factory: () => import('./extract-i18n/cli'),
},
'generate': {
factory: () => import('./generate/cli'),
aliases: ['g'],
},
'lint': {
factory: () => import('./lint/cli'),
},
'make-this-awesome': {
factory: () => import('./make-this-awesome/cli'),
},
'new': {
factory: () => import('./new/cli'),
aliases: ['n'],
},
'run': {
factory: () => import('./run/cli'),
},
'serve': {
factory: () => import('./serve/cli'),
aliases: ['s'],
},
'test': {
factory: () => import('./test/cli'),
aliases: ['t'],
},
'update': {
factory: () => import('./update/cli'),
},
'version': {
factory: () => import('./version/cli'),
aliases: ['v'],
},
};
export const RootCommandsAliases = Object.values(RootCommands).reduce((prev, current) => {
current.aliases?.forEach((alias) => {
prev[alias] = current;
});
return prev;
}, {} as Record<string, CommandConfig>);