1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 | import {ArgDescriptor} from 'command-line-args';
|
19 | import {Environment} from './environment/environment';
|
20 | import {buildEnvironment} from './environments/environments';
|
21 |
|
22 | export const globalArguments: ArgDescriptor[] = [
|
23 | {
|
24 | name: 'env',
|
25 | description: 'The environment to use to specialize certain commands, ' +
|
26 | 'like build',
|
27 | type: (value: string): Environment | undefined => {
|
28 | return buildEnvironment(value);
|
29 | },
|
30 | group: 'global',
|
31 | },
|
32 | {
|
33 | name: 'entrypoint',
|
34 | description: 'The main HTML file that will be requested for all routes.',
|
35 | group: 'global',
|
36 | },
|
37 | {
|
38 | name: 'shell',
|
39 | type: String,
|
40 | description: 'The app shell HTML import',
|
41 | group: 'global',
|
42 | },
|
43 | {
|
44 | name: 'fragment',
|
45 | type: String,
|
46 | multiple: true,
|
47 | description: 'HTML imports that are loaded on-demand.',
|
48 | group: 'global',
|
49 | },
|
50 | {
|
51 | name: 'root',
|
52 | type: String,
|
53 | description: 'The root directory of your project. Defaults to the current' +
|
54 | ' working directory.',
|
55 | group: 'global',
|
56 | },
|
57 | {
|
58 | name: 'sources',
|
59 | type: String,
|
60 | multiple: true,
|
61 | description: 'Glob(s) that match your project source files. ' +
|
62 | 'Defaults to `src/**/*`.',
|
63 | group: 'global',
|
64 | },
|
65 | {
|
66 | name: 'extra-dependencies',
|
67 | type: String,
|
68 | multiple: true,
|
69 | description: 'Glob(s) that match any additional dependencies not caught ' +
|
70 | 'by the analyzer to include with your build.',
|
71 | group: 'global',
|
72 | },
|
73 | {
|
74 | name: 'npm',
|
75 | type: Boolean,
|
76 | description: 'Sets npm mode: dependencies are installed from npm, ' +
|
77 | 'component directory is "node_modules" and the package name is read ' +
|
78 | 'from package.json',
|
79 | },
|
80 | {
|
81 | name: 'module-resolution',
|
82 | description: 'Algorithm to use for resolving module specifiers in import ' +
|
83 | 'and export statements when rewriting them to be web-compatible. ' +
|
84 | 'Valid values are "none" and "node". "none" disables module specifier ' +
|
85 | 'rewriting. "node" uses Node.js resolution to find modules.',
|
86 | type: String,
|
87 |
|
88 |
|
89 |
|
90 | defaultValue: undefined,
|
91 | },
|
92 | {
|
93 | name: 'component-dir',
|
94 | type: String,
|
95 | description: 'The component directory to use. Defaults to reading from ' +
|
96 | 'the Bower config (usually bower_components/).',
|
97 | },
|
98 | {
|
99 | name: 'verbose',
|
100 | description: 'turn on debugging output',
|
101 | type: Boolean,
|
102 | alias: 'v',
|
103 | group: 'global',
|
104 | },
|
105 | {
|
106 | name: 'help',
|
107 | description: 'print out helpful usage information',
|
108 | type: Boolean,
|
109 | alias: 'h',
|
110 | group: 'global',
|
111 | },
|
112 | {
|
113 | name: 'quiet',
|
114 | description: 'silence output',
|
115 | type: Boolean,
|
116 | alias: 'q',
|
117 | group: 'global',
|
118 | },
|
119 | ];
|
120 |
|
121 |
|
122 |
|
123 |
|
124 |
|
125 |
|
126 |
|
127 |
|
128 |
|
129 |
|
130 | export function mergeArguments(argumentLists: ArgDescriptor[][]):
|
131 | ArgDescriptor[] {
|
132 | const argsByName = new Map<string, ArgDescriptor>();
|
133 | for (const args of argumentLists) {
|
134 | for (const arg of args) {
|
135 | argsByName.set(
|
136 | arg.name, Object.assign({}, argsByName.get(arg.name), arg));
|
137 | }
|
138 | }
|
139 | return Array.from(argsByName.values());
|
140 | }
|