@angular-devkit/architect 0.800.0-rc.1 → 0.800.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* Use of this source code is governed by an MIT-style license that can be
|
|
6
6
|
* found in the LICENSE file at https://angular.io/license
|
|
7
7
|
*/
|
|
8
|
-
import { experimental, json } from '@angular-devkit/core';
|
|
8
|
+
import { experimental, json, workspaces } from '@angular-devkit/core';
|
|
9
9
|
import { BuilderInfo } from '../src';
|
|
10
10
|
import { Target } from '../src/input-schema';
|
|
11
11
|
import { ArchitectHost, Builder } from '../src/internal';
|
|
@@ -13,9 +13,13 @@ export declare type NodeModulesBuilderInfo = BuilderInfo & {
|
|
|
13
13
|
import: string;
|
|
14
14
|
};
|
|
15
15
|
export declare class WorkspaceNodeModulesArchitectHost implements ArchitectHost<NodeModulesBuilderInfo> {
|
|
16
|
-
protected _workspace: experimental.workspace.Workspace;
|
|
16
|
+
protected _workspace: experimental.workspace.Workspace | workspaces.WorkspaceDefinition;
|
|
17
17
|
protected _root: string;
|
|
18
|
+
/**
|
|
19
|
+
* @deprecated
|
|
20
|
+
*/
|
|
18
21
|
constructor(_workspace: experimental.workspace.Workspace, _root: string);
|
|
22
|
+
constructor(_workspace: workspaces.WorkspaceDefinition, _root: string);
|
|
19
23
|
getBuilderNameForTarget(target: Target): Promise<any>;
|
|
20
24
|
/**
|
|
21
25
|
* Resolve a builder. This needs to be a string which will be used in a dynamic `import()`
|
|
@@ -29,4 +33,5 @@ export declare class WorkspaceNodeModulesArchitectHost implements ArchitectHost<
|
|
|
29
33
|
getWorkspaceRoot(): Promise<string>;
|
|
30
34
|
getOptionsForTarget(target: Target): Promise<json.JsonObject | null>;
|
|
31
35
|
loadBuilder(info: NodeModulesBuilderInfo): Promise<Builder>;
|
|
36
|
+
private findProjectTarget;
|
|
32
37
|
}
|
|
@@ -10,7 +10,11 @@ class WorkspaceNodeModulesArchitectHost {
|
|
|
10
10
|
this._root = _root;
|
|
11
11
|
}
|
|
12
12
|
async getBuilderNameForTarget(target) {
|
|
13
|
-
|
|
13
|
+
const targetDefinition = this.findProjectTarget(target);
|
|
14
|
+
if (!targetDefinition) {
|
|
15
|
+
throw new Error('Project target does not exist.');
|
|
16
|
+
}
|
|
17
|
+
return targetDefinition.builder;
|
|
14
18
|
}
|
|
15
19
|
/**
|
|
16
20
|
* Resolve a builder. This needs to be a string which will be used in a dynamic `import()`
|
|
@@ -59,7 +63,7 @@ class WorkspaceNodeModulesArchitectHost {
|
|
|
59
63
|
return this._root;
|
|
60
64
|
}
|
|
61
65
|
async getOptionsForTarget(target) {
|
|
62
|
-
const targetSpec = this.
|
|
66
|
+
const targetSpec = this.findProjectTarget(target);
|
|
63
67
|
if (targetSpec === undefined) {
|
|
64
68
|
return null;
|
|
65
69
|
}
|
|
@@ -78,5 +82,18 @@ class WorkspaceNodeModulesArchitectHost {
|
|
|
78
82
|
}
|
|
79
83
|
throw new Error('Builder is not a builder');
|
|
80
84
|
}
|
|
85
|
+
findProjectTarget(target) {
|
|
86
|
+
// NOTE: Remove conditional when deprecated support for experimental workspace API is removed.
|
|
87
|
+
if ('getProjectTargets' in this._workspace) {
|
|
88
|
+
return this._workspace.getProjectTargets(target.project)[target.target];
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
const projectDefinition = this._workspace.projects.get(target.project);
|
|
92
|
+
if (!projectDefinition) {
|
|
93
|
+
throw new Error('Project does not exist.');
|
|
94
|
+
}
|
|
95
|
+
return projectDefinition.targets.get(target.target);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
81
98
|
}
|
|
82
99
|
exports.WorkspaceNodeModulesArchitectHost = WorkspaceNodeModulesArchitectHost;
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@angular-devkit/architect",
|
|
3
|
-
"version": "0.800.0
|
|
3
|
+
"version": "0.800.0",
|
|
4
4
|
"description": "Angular Build Facade",
|
|
5
5
|
"experimental": true,
|
|
6
6
|
"main": "src/index.js",
|
|
7
7
|
"typings": "src/index.d.ts",
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@angular-devkit/core": "8.0.0
|
|
9
|
+
"@angular-devkit/core": "8.0.0",
|
|
10
10
|
"rxjs": "6.4.0"
|
|
11
11
|
},
|
|
12
12
|
"builders": "./builders/builders.json",
|
package/src/architect.d.ts
CHANGED
|
@@ -15,11 +15,10 @@ export interface ScheduleOptions {
|
|
|
15
15
|
}
|
|
16
16
|
export declare class Architect {
|
|
17
17
|
private _host;
|
|
18
|
-
private _registry;
|
|
19
18
|
private readonly _scheduler;
|
|
20
19
|
private readonly _jobCache;
|
|
21
20
|
private readonly _infoCache;
|
|
22
|
-
constructor(_host: ArchitectHost,
|
|
21
|
+
constructor(_host: ArchitectHost, registry?: json.schema.SchemaRegistry, additionalJobRegistry?: experimental.jobs.Registry);
|
|
23
22
|
has(name: experimental.jobs.JobName): Observable<boolean>;
|
|
24
23
|
scheduleBuilder(name: string, options: json.JsonObject, scheduleOptions?: ScheduleOptions): Promise<BuilderRun>;
|
|
25
24
|
scheduleTarget(target: Target, overrides?: json.JsonObject, scheduleOptions?: ScheduleOptions): Promise<BuilderRun>;
|
package/src/architect.js
CHANGED
|
@@ -23,7 +23,8 @@ function _createJobHandlerFromBuilderInfo(info, target, host, registry, baseOpti
|
|
|
23
23
|
info,
|
|
24
24
|
};
|
|
25
25
|
function handler(argument, context) {
|
|
26
|
-
|
|
26
|
+
// Add input validation to the inbound bus.
|
|
27
|
+
const inboundBusWithInputValidation = context.inboundBus.pipe(operators_1.concatMap(message => {
|
|
27
28
|
if (message.kind === core_1.experimental.jobs.JobInboundMessageKind.Input) {
|
|
28
29
|
const v = message.value;
|
|
29
30
|
const options = {
|
|
@@ -31,16 +32,11 @@ function _createJobHandlerFromBuilderInfo(info, target, host, registry, baseOpti
|
|
|
31
32
|
...v.options,
|
|
32
33
|
};
|
|
33
34
|
// Validate v against the options schema.
|
|
34
|
-
return registry.compile(info.optionSchema).pipe(operators_1.concatMap(validation => validation(options)), operators_1.map(
|
|
35
|
-
if (
|
|
36
|
-
return { ...v, options:
|
|
37
|
-
}
|
|
38
|
-
else if (result.errors) {
|
|
39
|
-
throw new core_1.json.schema.SchemaValidationException(result.errors);
|
|
40
|
-
}
|
|
41
|
-
else {
|
|
42
|
-
return v;
|
|
35
|
+
return registry.compile(info.optionSchema).pipe(operators_1.concatMap(validation => validation(options)), operators_1.map(({ data, success, errors }) => {
|
|
36
|
+
if (success) {
|
|
37
|
+
return { ...v, options: data };
|
|
43
38
|
}
|
|
39
|
+
throw new core_1.json.schema.SchemaValidationException(errors);
|
|
44
40
|
}), operators_1.map(value => ({ ...message, value })));
|
|
45
41
|
}
|
|
46
42
|
else {
|
|
@@ -50,7 +46,10 @@ function _createJobHandlerFromBuilderInfo(info, target, host, registry, baseOpti
|
|
|
50
46
|
// Using a share replay because the job might be synchronously sending input, but
|
|
51
47
|
// asynchronously listening to it.
|
|
52
48
|
operators_1.shareReplay(1));
|
|
53
|
-
|
|
49
|
+
// Make an inboundBus that completes instead of erroring out.
|
|
50
|
+
// We'll merge the errors into the output instead.
|
|
51
|
+
const inboundBus = rxjs_1.onErrorResumeNext(inboundBusWithInputValidation);
|
|
52
|
+
const output = rxjs_1.from(host.loadBuilder(info)).pipe(operators_1.concatMap(builder => {
|
|
54
53
|
if (builder === null) {
|
|
55
54
|
throw new Error(`Cannot load builder for builderInfo ${JSON.stringify(info, null, 2)}`);
|
|
56
55
|
}
|
|
@@ -69,7 +68,14 @@ function _createJobHandlerFromBuilderInfo(info, target, host, registry, baseOpti
|
|
|
69
68
|
return output;
|
|
70
69
|
}
|
|
71
70
|
}));
|
|
72
|
-
})
|
|
71
|
+
}),
|
|
72
|
+
// Share subscriptions to the output, otherwise the the handler will be re-run.
|
|
73
|
+
operators_1.shareReplay());
|
|
74
|
+
// Separate the errors from the inbound bus into their own observable that completes when the
|
|
75
|
+
// builder output does.
|
|
76
|
+
const inboundBusErrors = inboundBusWithInputValidation.pipe(operators_1.ignoreElements(), operators_1.takeUntil(rxjs_1.onErrorResumeNext(output.pipe(operators_1.last()))));
|
|
77
|
+
// Return the builder output plus any input errors.
|
|
78
|
+
return rxjs_1.merge(inboundBusErrors, output);
|
|
73
79
|
}
|
|
74
80
|
return rxjs_1.of(Object.assign(handler, { jobDescription }));
|
|
75
81
|
}
|
|
@@ -197,9 +203,7 @@ function _validateOptionsFactory(host, registry) {
|
|
|
197
203
|
if (success) {
|
|
198
204
|
return rxjs_1.of(data);
|
|
199
205
|
}
|
|
200
|
-
|
|
201
|
-
throw new core_1.json.schema.SchemaValidationException(errors);
|
|
202
|
-
}
|
|
206
|
+
throw new core_1.json.schema.SchemaValidationException(errors);
|
|
203
207
|
})).toPromise();
|
|
204
208
|
}, {
|
|
205
209
|
name: '..validateOptions',
|
|
@@ -214,23 +218,22 @@ function _validateOptionsFactory(host, registry) {
|
|
|
214
218
|
});
|
|
215
219
|
}
|
|
216
220
|
class Architect {
|
|
217
|
-
constructor(_host,
|
|
221
|
+
constructor(_host, registry = new core_1.json.schema.CoreSchemaRegistry(), additionalJobRegistry) {
|
|
218
222
|
this._host = _host;
|
|
219
|
-
this._registry = _registry;
|
|
220
223
|
this._jobCache = new Map();
|
|
221
224
|
this._infoCache = new Map();
|
|
222
225
|
const privateArchitectJobRegistry = new core_1.experimental.jobs.SimpleJobRegistry();
|
|
223
226
|
// Create private jobs.
|
|
224
227
|
privateArchitectJobRegistry.register(_getTargetOptionsFactory(_host));
|
|
225
228
|
privateArchitectJobRegistry.register(_getBuilderNameForTargetFactory(_host));
|
|
226
|
-
privateArchitectJobRegistry.register(_validateOptionsFactory(_host,
|
|
229
|
+
privateArchitectJobRegistry.register(_validateOptionsFactory(_host, registry));
|
|
227
230
|
const jobRegistry = new core_1.experimental.jobs.FallbackRegistry([
|
|
228
|
-
new ArchitectTargetJobRegistry(_host,
|
|
229
|
-
new ArchitectBuilderJobRegistry(_host,
|
|
231
|
+
new ArchitectTargetJobRegistry(_host, registry, this._jobCache, this._infoCache),
|
|
232
|
+
new ArchitectBuilderJobRegistry(_host, registry, this._jobCache, this._infoCache),
|
|
230
233
|
privateArchitectJobRegistry,
|
|
231
234
|
...(additionalJobRegistry ? [additionalJobRegistry] : []),
|
|
232
235
|
]);
|
|
233
|
-
this._scheduler = new core_1.experimental.jobs.SimpleScheduler(jobRegistry,
|
|
236
|
+
this._scheduler = new core_1.experimental.jobs.SimpleScheduler(jobRegistry, registry);
|
|
234
237
|
}
|
|
235
238
|
has(name) {
|
|
236
239
|
return this._scheduler.has(name);
|
package/testing/index2.d.ts
DELETED
package/testing/index2.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* @license
|
|
4
|
-
* Copyright Google Inc. All Rights Reserved.
|
|
5
|
-
*
|
|
6
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
7
|
-
* found in the LICENSE file at https://angular.io/license
|
|
8
|
-
*/
|
|
9
|
-
function __export(m) {
|
|
10
|
-
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
|
|
11
|
-
}
|
|
12
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
__export(require("./testing-architect-host"));
|