Skip to content

Commit 26ff802

Browse files
committed
feat(@angular/cli): use architect
1 parent a0fc670 commit 26ff802

File tree

196 files changed

+2129
-5917
lines changed

Some content is hidden

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

196 files changed

+2129
-5917
lines changed

package-lock.json

+797-381
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+3-40
Original file line numberDiff line numberDiff line change
@@ -41,63 +41,29 @@
4141
},
4242
"homepage": "https://github.com/angular/angular-cli",
4343
"dependencies": {
44-
"@angular-devkit/build-optimizer": "0.4.5",
45-
"@angular-devkit/core": "0.4.5",
44+
"@angular-devkit/architect": "angular/angular-devkit-architect-builds#891f470",
45+
"@angular-devkit/build-webpack": "angular/angular-devkit-build-webpack-builds#891f470",
46+
"@angular-devkit/core": "angular/angular-devkit-core-builds#891f470",
4647
"@angular-devkit/schematics": "0.4.5",
4748
"@schematics/angular": "0.4.5",
4849
"@schematics/package-update": "0.4.5",
4950
"ajv": "^6.1.1",
50-
"autoprefixer": "^7.2.3",
51-
"cache-loader": "^1.2.0",
5251
"chalk": "~2.2.0",
53-
"circular-dependency-plugin": "^4.4.0",
54-
"clean-css": "^4.1.9",
5552
"common-tags": "^1.3.1",
56-
"copy-webpack-plugin": "~4.4.2",
5753
"core-object": "^3.1.0",
5854
"ember-cli-string-utils": "^1.0.0",
59-
"extract-text-webpack-plugin": "~4.0.0-beta.0",
60-
"file-loader": "^1.1.9",
6155
"fs-extra": "^4.0.0",
62-
"glob": "^7.0.3",
63-
"html-webpack-plugin": "github:webpack-contrib/html-webpack-plugin#a8a8c2b6ea496c257fd6f501db3a06a51fa03e1e",
64-
"istanbul-instrumenter-loader": "^3.0.0",
65-
"karma-source-map-support": "^1.2.0",
66-
"less": "^2.7.2",
67-
"less-loader": "^4.0.5",
68-
"license-webpack-plugin": "^1.1.2",
69-
"loader-utils": "^1.1.0",
7056
"lodash": "^4.11.1",
71-
"memory-fs": "^0.4.1",
72-
"minimatch": "^3.0.4",
7357
"node-modules-path": "^1.0.0",
7458
"opn": "~5.1.0",
75-
"parse5": "^4.0.0",
76-
"portfinder": "~1.0.12",
77-
"postcss": "^6.0.19",
78-
"postcss-import": "^11.1.0",
79-
"postcss-loader": "^2.1.1",
80-
"postcss-url": "^7.1.2",
81-
"raw-loader": "^0.5.1",
8259
"resolve": "^1.1.7",
8360
"rxjs": "^5.5.6",
84-
"sass-loader": "^6.0.6",
8561
"semver": "^5.3.0",
8662
"silent-error": "^1.0.0",
87-
"source-map-support": "^0.4.1",
88-
"style-loader": "^0.20.2",
89-
"stylus": "^0.54.5",
90-
"stylus-loader": "^3.0.2",
9163
"tree-kill": "^1.0.0",
9264
"typescript": "~2.6.2",
93-
"uglifyjs-webpack-plugin": "^1.2.2",
94-
"url-loader": "^0.6.2",
9565
"webpack": "~4.0.0",
96-
"webpack-dev-middleware": "^2.0.6",
97-
"webpack-dev-server": "^3.0.1-beta.0",
98-
"webpack-merge": "^4.1.2",
9966
"webpack-sources": "^1.1.0",
100-
"webpack-subresource-integrity": "^1.0.1",
10167
"yargs-parser": "^9.0.2"
10268
},
10369
"devDependencies": {
@@ -142,8 +108,5 @@
142108
"ts-node": "^4.1.0",
143109
"tslint": "^5.8.0",
144110
"zone.js": "^0.8.20"
145-
},
146-
"optionalDependencies": {
147-
"node-sass": "^4.7.2"
148111
}
149112
}
+25-274
Original file line numberDiff line numberDiff line change
@@ -1,293 +1,44 @@
1-
import { Command, Option, CommandScope } from '../models/command';
2-
import { CliConfig } from '../models/config';
3-
import { BuildOptions } from '../models/build-options';
1+
import { ArchitectCommand } from '../models/architect-command';
2+
import { Option, CommandScope } from '../models/command';
43
import { Version } from '../upgrade/version';
5-
import { oneLine } from 'common-tags';
6-
import { getAppFromConfig } from '../utilities/app-utils';
7-
import { join } from 'path';
8-
import { RenderUniversalTaskOptions } from '../tasks/render-universal';
94

10-
const SilentError = require('silent-error');
11-
12-
const config = CliConfig.fromProject() || CliConfig.fromGlobal();
13-
const buildConfigDefaults = config.getPaths('defaults.build', [
14-
'sourcemaps', 'baseHref', 'progress', 'poll', 'deleteOutputPath', 'preserveSymlinks',
15-
'showCircularDependencies', 'commonChunk', 'namedChunks'
16-
]);
17-
18-
// defaults for BuildOptions
19-
export const baseBuildCommandOptions: Option[] = [
20-
{
21-
name: 'target',
22-
type: String,
23-
default: 'development',
24-
// TODO: re-add support for `--prod`
25-
aliases: ['t'],
26-
description: 'Defines the build target.'
27-
},
28-
{
29-
name: 'environment',
30-
type: String,
31-
aliases: ['e'],
32-
description: 'Defines the build environment.'
33-
},
34-
{
35-
name: 'output-path',
36-
type: 'Path',
37-
aliases: ['op'],
38-
description: 'Path where output will be placed.'
39-
},
40-
{
41-
name: 'aot',
42-
type: Boolean,
43-
description: 'Build using Ahead of Time compilation.'
44-
},
45-
{
46-
name: 'sourcemaps',
47-
type: Boolean,
48-
aliases: ['sm', 'sourcemap'],
49-
description: 'Output sourcemaps.',
50-
default: buildConfigDefaults['sourcemaps']
51-
},
52-
{
53-
name: 'vendor-chunk',
54-
type: Boolean,
55-
aliases: ['vc'],
56-
description: 'Use a separate bundle containing only vendor libraries.'
57-
},
58-
{
59-
name: 'common-chunk',
60-
type: Boolean,
61-
default: buildConfigDefaults['commonChunk'],
62-
aliases: ['cc'],
63-
description: 'Use a separate bundle containing code used across multiple bundles.'
64-
},
65-
{
66-
name: 'base-href',
67-
type: String,
68-
aliases: ['bh'],
69-
description: 'Base url for the application being built.',
70-
default: buildConfigDefaults['baseHref']
71-
},
72-
{
73-
name: 'deploy-url',
74-
type: String,
75-
aliases: ['d'],
76-
description: 'URL where files will be deployed.'
77-
},
78-
{
79-
name: 'verbose',
80-
type: Boolean,
81-
default: false,
82-
aliases: ['v'],
83-
description: 'Adds more details to output logging.'
84-
},
85-
{
86-
name: 'progress',
87-
type: Boolean,
88-
aliases: ['pr'],
89-
description: 'Log progress to the console while building.',
90-
default: typeof buildConfigDefaults['progress'] !== 'undefined'
91-
? buildConfigDefaults['progress']
92-
: process.stdout.isTTY === true
93-
},
94-
{
95-
name: 'i18n-file',
96-
type: String,
97-
description: 'Localization file to use for i18n.'
98-
},
99-
{
100-
name: 'i18n-format',
101-
type: String,
102-
description: 'Format of the localization file specified with --i18n-file.'
103-
},
104-
{
105-
name: 'locale',
106-
type: String,
107-
description: 'Locale to use for i18n.'
108-
},
109-
{
110-
name: 'missing-translation',
111-
type: String,
112-
description: 'How to handle missing translations for i18n.'
113-
},
114-
{
115-
name: 'extract-css',
116-
type: Boolean,
117-
aliases: ['ec'],
118-
description: 'Extract css from global styles onto css files instead of js ones.'
119-
},
120-
{
121-
name: 'watch',
122-
type: Boolean,
123-
default: false,
124-
aliases: ['w'],
125-
description: 'Run build when files change.'
126-
},
127-
{
128-
name: 'output-hashing',
129-
type: String,
130-
values: ['none', 'all', 'media', 'bundles'],
131-
description: 'Define the output filename cache-busting hashing mode.',
132-
aliases: ['oh']
133-
},
134-
{
135-
name: 'poll',
136-
type: Number,
137-
description: 'Enable and define the file watching poll time period (milliseconds).',
138-
default: buildConfigDefaults['poll']
139-
},
140-
{
141-
name: 'app',
142-
type: String,
143-
aliases: ['a'],
144-
description: 'Specifies app name or index to use.'
145-
},
146-
{
147-
name: 'delete-output-path',
148-
type: Boolean,
149-
aliases: ['dop'],
150-
description: 'Delete output path before build.',
151-
default: buildConfigDefaults['deleteOutputPath'],
152-
},
153-
{
154-
name: 'preserve-symlinks',
155-
type: Boolean,
156-
description: 'Do not use the real path when resolving modules.',
157-
default: buildConfigDefaults['preserveSymlinks']
158-
},
159-
{
160-
name: 'extract-licenses',
161-
type: Boolean,
162-
description: 'Extract all licenses in a separate file, in the case of production builds only.'
163-
},
164-
{
165-
name: 'show-circular-dependencies',
166-
type: Boolean,
167-
aliases: ['scd'],
168-
description: 'Show circular dependency warnings on builds.',
169-
default: buildConfigDefaults['showCircularDependencies']
170-
},
171-
{
172-
name: 'build-optimizer',
173-
type: Boolean,
174-
description: 'Enables @angular-devkit/build-optimizer optimizations when using `--aot`.'
175-
},
176-
{
177-
name: 'named-chunks',
178-
type: Boolean,
179-
aliases: ['nc'],
180-
description: 'Use file name for lazy loaded chunks.',
181-
default: buildConfigDefaults['namedChunks']
182-
},
183-
{
184-
name: 'subresource-integrity',
185-
type: Boolean,
186-
default: false,
187-
aliases: ['sri'],
188-
description: 'Enables the use of subresource integrity validation.'
189-
},
190-
{
191-
name: 'bundle-dependencies',
192-
type: ['none', 'all'],
193-
default: 'none',
194-
description: 'Available on server platform only. Which external dependencies to bundle into '
195-
+ 'the module. By default, all of node_modules will be kept as requires.'
196-
},
197-
{
198-
name: 'service-worker',
199-
type: Boolean,
200-
default: true,
201-
aliases: ['sw'],
202-
description: 'Generates a service worker config for production builds, if the app has '
203-
+ 'service worker enabled.'
204-
},
205-
{
206-
name: 'skip-app-shell',
207-
type: Boolean,
208-
description: 'Flag to prevent building an app shell',
209-
default: false
210-
}
211-
];
212-
213-
export interface BuildTaskOptions extends BuildOptions {
214-
statsJson?: boolean;
5+
export interface Options {
6+
app?: string;
7+
configuration?: string;
8+
prod: boolean;
2159
}
21610

217-
export default class BuildCommand extends Command {
11+
export default class BuildCommand extends ArchitectCommand {
21812
public readonly name = 'build';
13+
public readonly target = 'browser';
21914
public readonly description =
22015
'Builds your app and places it into the output path (dist/ by default).';
22116
public static aliases = ['b'];
22217
public scope = CommandScope.inProject;
223-
public arguments: string[];
224-
public options = baseBuildCommandOptions.concat([
225-
{
226-
name: 'stats-json',
227-
type: Boolean,
228-
default: false,
229-
description: oneLine`Generates a \`stats.json\` file which can be analyzed using tools
230-
such as: \`webpack-bundle-analyzer\` or https://webpack.github.io/analyse.`
231-
}
232-
]);
18+
public arguments: string[] = ['app'];
19+
public options: Option[] = [
20+
this.prodOption,
21+
this.configurationOption
22+
];
23323

234-
public validate(_options: BuildTaskOptions) {
24+
public validate(_options: Options) {
23525
Version.assertAngularVersionIs2_3_1OrHigher(this.project.root);
23626
Version.assertTypescriptVersion(this.project.root);
23727
return true;
23828
}
23929

240-
public async run(options: BuildTaskOptions) {
241-
// Add trailing slash if missing to prevent https://github.com/angular/angular-cli/issues/7295
242-
if (options.deployUrl && options.deployUrl.substr(-1) !== '/') {
243-
options.deployUrl += '/';
244-
}
245-
246-
const BuildTask = require('../tasks/build').default;
247-
248-
const buildTask = new BuildTask({
249-
project: this.project,
250-
ui: this.ui,
251-
});
252-
253-
const clientApp = getAppFromConfig(options.app);
254-
255-
const doAppShell = options.target === 'production' &&
256-
(options.aot === undefined || options.aot === true) &&
257-
!options.skipAppShell;
258-
259-
let serverApp: any = null;
260-
if (clientApp.appShell && doAppShell) {
261-
serverApp = getAppFromConfig(clientApp.appShell.app);
262-
if (serverApp.platform !== 'server') {
263-
throw new SilentError(`Shell app's platform is not "server"`);
264-
}
265-
}
266-
267-
const buildTaskResult = await buildTask.run(options);
268-
if (!clientApp.appShell || !doAppShell) {
269-
return buildTaskResult;
30+
public async run(options: Options) {
31+
let configuration = options.configuration;
32+
if (!configuration && options.prod) {
33+
configuration = 'production';
27034
}
271-
272-
const serverOptions = {
273-
...options,
274-
app: clientApp.appShell.app
275-
};
276-
await buildTask.run(serverOptions);
277-
278-
const RenderUniversalTask = require('../tasks/render-universal').default;
279-
280-
const renderUniversalTask = new RenderUniversalTask({
281-
project: this.project,
282-
ui: this.ui,
35+
const overrides = {...options};
36+
delete overrides.app;
37+
delete overrides.prod;
38+
return this.runArchitect({
39+
app: options.app,
40+
configuration,
41+
overrides
28342
});
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-
};
290-
291-
return await renderUniversalTask.run(renderUniversalOptions);
29243
}
29344
}

0 commit comments

Comments
 (0)