Skip to content

Commit 9f77c86

Browse files
Broccoclydin
authored andcommitted
feat(@angular/cli): Update command runner.
This change removes the dependency of the ember-cli command structure.
1 parent 9c4f9e9 commit 9f77c86

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+1184
-3051
lines changed

docs/documentation/generate.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
<details>
3131
<summary>lint-fix</summary>
3232
<p>
33-
<code>--lint-fix</code> (aliases: <code>-lf</code>)
33+
<code>--lint-fix</code> (aliases: <code>-l</code>)
3434
</p>
3535
<p>
3636
Use lint to fix files after generation.

docs/documentation/generate/component.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<details>
2020
<summary>change-detection</summary>
2121
<p>
22-
<code>--change-detection</code> (aliases: <code>-cd</code>)
22+
<code>--change-detection</code> (aliases: <code>-c</code>)
2323
</p>
2424
<p>
2525
Specifies the change detection strategy.
@@ -49,7 +49,7 @@
4949
<details>
5050
<summary>inline-style</summary>
5151
<p>
52-
<code>--inline-style</code> (aliases: <code>-is</code>) <em>default value: false</em>
52+
<code>--inline-style</code> (aliases: <code>-s</code>) <em>default value: false</em>
5353
</p>
5454
<p>
5555
Specifies if the style will be in the ts file.
@@ -59,7 +59,7 @@
5959
<details>
6060
<summary>inline-template</summary>
6161
<p>
62-
<code>--inline-template</code> (aliases: <code>-it</code>) <em>default value: false</em>
62+
<code>--inline-template</code> (aliases: <code>-t</code>) <em>default value: false</em>
6363
</p>
6464
<p>
6565
Specifies if the template will be in the ts file.
@@ -109,7 +109,7 @@
109109
<details>
110110
<summary>view-encapsulation</summary>
111111
<p>
112-
<code>--view-encapsulation</code> (aliases: <code>-ve</code>)
112+
<code>--view-encapsulation</code> (aliases: <code>-v</code>)
113113
</p>
114114
<p>
115115
Specifies the view encapsulation strategy.

docs/documentation/new.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Default applications are created in a directory of the same name, with an initia
1111
<details>
1212
<summary>directory</summary>
1313
<p>
14-
<code>--directory</code> (alias: <code>-dir</code>) <em>default value: dir</em>
14+
<code>--directory</code> (alias: <code>-d</code>) <em>default value: dir</em>
1515
</p>
1616
<p>
1717
The directory name to create the app in.
@@ -31,7 +31,7 @@ Default applications are created in a directory of the same name, with an initia
3131
<details>
3232
<summary>inline-style</summary>
3333
<p>
34-
<code>--inline-style</code> (alias: <code>-is</code>) <em>default value: false</em>
34+
<code>--inline-style</code> (alias: <code>-s</code>) <em>default value: false</em>
3535
</p>
3636
<p>
3737
Should have an inline style.
@@ -41,7 +41,7 @@ Default applications are created in a directory of the same name, with an initia
4141
<details>
4242
<summary>inline-template</summary>
4343
<p>
44-
<code>--inline-template</code> (alias: <code>-it</code>) <em>default value: false</em>
44+
<code>--inline-template</code> (alias: <code>-t</code>) <em>default value: false</em>
4545
</p>
4646
<p>
4747
Should have an inline template.
@@ -94,7 +94,7 @@ Default applications are created in a directory of the same name, with an initia
9494
<details>
9595
<summary>skip-git</summary>
9696
<p>
97-
<code>--skip-git</code> (alias: <code>-sg</code>) <em>default value: false</em>
97+
<code>--skip-git</code> (alias: <code>-g</code>) <em>default value: false</em>
9898
</p>
9999
<p>
100100
Skip initializing a git repository.
@@ -114,7 +114,7 @@ Default applications are created in a directory of the same name, with an initia
114114
<details>
115115
<summary>skip-tests</summary>
116116
<p>
117-
<code>--skip-tests (aliases: </code>-st) <em>default value: false</em>
117+
<code>--skip-tests (aliases: </code>-S) <em>default value: false</em>
118118
</p>
119119
<p>
120120
Skip creating spec files.
@@ -127,7 +127,7 @@ Default applications are created in a directory of the same name, with an initia
127127
<details>
128128
<summary>source-dir</summary>
129129
<p>
130-
<code>--source-dir</code> (alias: <code>-sd</code>) <em>default value: src</em>
130+
<code>--source-dir</code> (alias: <code>-D</code>) <em>default value: src</em>
131131
</p>
132132
<p>
133133
The name of the source directory.

package-lock.json

Lines changed: 30 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,8 @@
9898
"webpack-dev-server": "^3.0.1-beta.0",
9999
"webpack-merge": "^4.1.2",
100100
"webpack-sources": "^1.1.0",
101-
"webpack-subresource-integrity": "^1.0.1"
101+
"webpack-subresource-integrity": "^1.0.1",
102+
"yargs-parser": "^9.0.2"
102103
},
103104
"devDependencies": {
104105
"@angular/common": "^5.2.0",

packages/@angular/cli/bin/ng

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,10 @@ resolve('@angular/cli', { basedir: process.cwd() },
196196
cliArgs: process.argv.slice(2),
197197
inputStream: standardInput,
198198
outputStream: process.stdout
199-
}).then(function (result) {
200-
process.exit(typeof result === 'object' ? result.exitCode : result);
199+
}).then(function (exitCode) {
200+
process.exit(exitCode);
201+
}).catch(function(err) {
202+
console.log('Unknown error: ' + err.toString());
203+
process.exit(127);
201204
});
202205
});

packages/@angular/cli/commands/build.ts

Lines changed: 43 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { Command, Option, CommandScope } from '../models/command';
12
import { CliConfig } from '../models/config';
23
import { BuildOptions } from '../models/build-options';
34
import { Version } from '../upgrade/version';
@@ -6,7 +7,6 @@ import { getAppFromConfig } from '../utilities/app-utils';
67
import { join } from 'path';
78
import { RenderUniversalTaskOptions } from '../tasks/render-universal';
89

9-
const Command = require('../ember-cli/lib/models/command');
1010
const SilentError = require('silent-error');
1111

1212
const config = CliConfig.fromProject() || CliConfig.fromGlobal();
@@ -16,12 +16,13 @@ const buildConfigDefaults = config.getPaths('defaults.build', [
1616
]);
1717

1818
// defaults for BuildOptions
19-
export const baseBuildCommandOptions: any = [
19+
export const baseBuildCommandOptions: Option[] = [
2020
{
2121
name: 'target',
2222
type: String,
2323
default: 'development',
24-
aliases: ['t', { 'dev': 'development' }, { 'prod': 'production' }],
24+
// TODO: re-add support for `--prod`
25+
aliases: ['t'],
2526
description: 'Defines the build target.'
2627
},
2728
{
@@ -213,29 +214,33 @@ export interface BuildTaskOptions extends BuildOptions {
213214
statsJson?: boolean;
214215
}
215216

216-
const BuildCommand = Command.extend({
217-
name: 'build',
218-
description: 'Builds your app and places it into the output path (dist/ by default).',
219-
aliases: ['b'],
220-
221-
availableOptions: baseBuildCommandOptions.concat([
217+
export default class BuildCommand extends Command {
218+
public readonly name = 'build';
219+
public readonly description =
220+
'Builds your app and places it into the output path (dist/ by default).';
221+
public static aliases = ['b'];
222+
public scope = CommandScope.inProject;
223+
public arguments: string[];
224+
public options = baseBuildCommandOptions.concat([
222225
{
223226
name: 'stats-json',
224227
type: Boolean,
225228
default: false,
226229
description: oneLine`Generates a \`stats.json\` file which can be analyzed using tools
227230
such as: \`webpack-bundle-analyzer\` or https://webpack.github.io/analyse.`
228231
}
229-
]),
232+
]);
230233

231-
run: function (commandOptions: BuildTaskOptions) {
232-
// Check Angular and TypeScript versions.
234+
public validate(_options: BuildTaskOptions) {
233235
Version.assertAngularVersionIs2_3_1OrHigher(this.project.root);
234236
Version.assertTypescriptVersion(this.project.root);
237+
return true;
238+
}
235239

240+
public async run(options: BuildTaskOptions) {
236241
// Add trailing slash if missing to prevent https://github.com/angular/angular-cli/issues/7295
237-
if (commandOptions.deployUrl && commandOptions.deployUrl.substr(-1) !== '/') {
238-
commandOptions.deployUrl += '/';
242+
if (options.deployUrl && options.deployUrl.substr(-1) !== '/') {
243+
options.deployUrl += '/';
239244
}
240245

241246
const BuildTask = require('../tasks/build').default;
@@ -245,11 +250,11 @@ const BuildCommand = Command.extend({
245250
ui: this.ui,
246251
});
247252

248-
const clientApp = getAppFromConfig(commandOptions.app);
253+
const clientApp = getAppFromConfig(options.app);
249254

250-
const doAppShell = commandOptions.target === 'production' &&
251-
(commandOptions.aot === undefined || commandOptions.aot === true) &&
252-
!commandOptions.skipAppShell;
255+
const doAppShell = options.target === 'production' &&
256+
(options.aot === undefined || options.aot === true) &&
257+
!options.skipAppShell;
253258

254259
let serverApp: any = null;
255260
if (clientApp.appShell && doAppShell) {
@@ -259,40 +264,30 @@ const BuildCommand = Command.extend({
259264
}
260265
}
261266

262-
const buildPromise = buildTask.run(commandOptions);
263-
267+
const buildTaskResult = await buildTask.run(options);
264268
if (!clientApp.appShell || !doAppShell) {
265-
return buildPromise;
269+
return buildTaskResult;
266270
}
267271

268-
return buildPromise
269-
.then(() => {
272+
const serverOptions = {
273+
...options,
274+
app: clientApp.appShell.app
275+
};
276+
await buildTask.run(serverOptions);
270277

271-
const serverOptions = {
272-
...commandOptions,
273-
app: clientApp.appShell.app
274-
};
275-
return buildTask.run(serverOptions);
276-
})
277-
.then(() => {
278-
const RenderUniversalTask = require('../tasks/render-universal').default;
278+
const RenderUniversalTask = require('../tasks/render-universal').default;
279279

280-
const renderUniversalTask = new RenderUniversalTask({
281-
project: this.project,
282-
ui: this.ui,
283-
});
284-
const renderUniversalOptions: RenderUniversalTaskOptions = {
285-
inputIndexPath: join(this.project.root, clientApp.outDir, clientApp.index),
286-
route: clientApp.appShell.route,
287-
serverOutDir: join(this.project.root, serverApp.outDir),
288-
outputIndexPath: join(this.project.root, clientApp.outDir, clientApp.index)
289-
};
280+
const renderUniversalTask = new RenderUniversalTask({
281+
project: this.project,
282+
ui: this.ui,
283+
});
284+
const renderUniversalOptions: RenderUniversalTaskOptions = {
285+
inputIndexPath: join(this.project.root, clientApp.outDir, clientApp.index),
286+
route: clientApp.appShell.route,
287+
serverOutDir: join(this.project.root, serverApp.outDir),
288+
outputIndexPath: join(this.project.root, clientApp.outDir, clientApp.index)
289+
};
290290

291-
return renderUniversalTask.run(renderUniversalOptions);
292-
});
291+
return await renderUniversalTask.run(renderUniversalOptions);
293292
}
294-
});
295-
296-
297-
BuildCommand.overrideCore = true;
298-
export default BuildCommand;
293+
}

0 commit comments

Comments
 (0)