@angular-devkit/architect 0.1200.0-rc.0 → 0.1200.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.
- package/builders/all-of.d.ts +1 -1
- package/builders/all-of.js +18 -9
- package/builders/concat.d.ts +1 -1
- package/builders/concat.js +13 -4
- package/builders/false.d.ts +7 -0
- package/builders/false.js +2 -2
- package/builders/noop-schema.json +1 -1
- package/builders/operator-schema.json +2 -6
- package/builders/true.d.ts +7 -0
- package/builders/true.js +2 -2
- package/node/index.d.ts +1 -1
- package/node/index.js +7 -7
- package/node/node-modules-architect-host.d.ts +1 -1
- package/node/node-modules-architect-host.js +10 -2
- package/package.json +3 -3
- package/src/api.d.ts +8 -8
- package/src/api.js +12 -5
- package/src/architect.d.ts +1 -1
- package/src/architect.js +22 -25
- package/src/builders-schema.json +4 -13
- package/src/create-builder.d.ts +1 -1
- package/src/create-builder.js +32 -19
- package/src/index.d.ts +1 -1
- package/src/index.js +7 -7
- package/src/input-schema.json +2 -10
- package/src/internal.d.ts +1 -1
- package/src/internal.js +7 -0
- package/src/output-schema.json +1 -3
- package/src/progress-schema.json +9 -28
- package/src/schedule-by-name.d.ts +1 -1
- package/src/schedule-by-name.js +19 -12
- package/src/targets-schema.json +2 -5
- package/testing/index.d.ts +1 -1
- package/testing/index.js +7 -7
- package/testing/test-project-host.d.ts +1 -1
- package/testing/test-project-host.js +13 -11
- package/testing/testing-architect-host.d.ts +1 -1
- package/testing/testing-architect-host.js +11 -4
package/builders/all-of.d.ts
CHANGED
package/builders/all-of.js
CHANGED
|
@@ -1,38 +1,47 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @license
|
|
4
|
+
* Copyright Google LLC 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
|
+
*/
|
|
2
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
10
|
const rxjs_1 = require("rxjs");
|
|
4
11
|
const operators_1 = require("rxjs/operators");
|
|
5
12
|
const src_1 = require("../src");
|
|
6
13
|
exports.default = src_1.createBuilder((options, context) => {
|
|
7
14
|
const allRuns = [];
|
|
8
|
-
context.reportProgress(0, (options.targets ? options.targets.length : 0)
|
|
9
|
-
|
|
15
|
+
context.reportProgress(0, (options.targets ? options.targets.length : 0) +
|
|
16
|
+
(options.builders ? options.builders.length : 0));
|
|
10
17
|
if (options.targets) {
|
|
11
18
|
allRuns.push(...options.targets.map(({ target: targetStr, overrides }, i) => {
|
|
12
19
|
const [project, target, configuration] = targetStr.split(/:/g, 3);
|
|
13
|
-
return context
|
|
14
|
-
.
|
|
20
|
+
return context
|
|
21
|
+
.scheduleTarget({ project, target, configuration }, overrides || {})
|
|
22
|
+
.then((run) => [i, run]);
|
|
15
23
|
}));
|
|
16
24
|
}
|
|
17
25
|
if (options.builders) {
|
|
18
26
|
allRuns.push(...options.builders.map(({ builder, options }, i) => {
|
|
19
|
-
return context
|
|
20
|
-
.
|
|
27
|
+
return context
|
|
28
|
+
.scheduleBuilder(builder, options || {})
|
|
29
|
+
.then((run) => [i, run]);
|
|
21
30
|
}));
|
|
22
31
|
}
|
|
23
32
|
const allResults = allRuns.map(() => null);
|
|
24
33
|
let n = 0;
|
|
25
34
|
context.reportProgress(n++, allRuns.length);
|
|
26
|
-
return rxjs_1.from(allRuns).pipe(operators_1.mergeMap(runPromise => rxjs_1.from(runPromise)), operators_1.mergeMap(([i, run]) => run.output.pipe(operators_1.map(output => [i, output]))), operators_1.mergeMap(([i, output]) => {
|
|
35
|
+
return rxjs_1.from(allRuns).pipe(operators_1.mergeMap((runPromise) => rxjs_1.from(runPromise)), operators_1.mergeMap(([i, run]) => run.output.pipe(operators_1.map((output) => [i, output]))), operators_1.mergeMap(([i, output]) => {
|
|
27
36
|
allResults[i] = output;
|
|
28
37
|
context.reportProgress(n++, allRuns.length);
|
|
29
|
-
if (allResults.some(x => x === null)) {
|
|
38
|
+
if (allResults.some((x) => x === null)) {
|
|
30
39
|
// Some builders aren't done running yet.
|
|
31
40
|
return rxjs_1.EMPTY;
|
|
32
41
|
}
|
|
33
42
|
else {
|
|
34
43
|
return rxjs_1.of({
|
|
35
|
-
success: allResults.every(x => x ? x.success : false),
|
|
44
|
+
success: allResults.every((x) => (x ? x.success : false)),
|
|
36
45
|
});
|
|
37
46
|
}
|
|
38
47
|
}));
|
package/builders/concat.d.ts
CHANGED
package/builders/concat.js
CHANGED
|
@@ -1,12 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @license
|
|
4
|
+
* Copyright Google LLC 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
|
+
*/
|
|
2
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
10
|
const rxjs_1 = require("rxjs");
|
|
4
11
|
const operators_1 = require("rxjs/operators");
|
|
5
12
|
const src_1 = require("../src");
|
|
6
13
|
exports.default = src_1.createBuilder((options, context) => {
|
|
7
14
|
const allRuns = [];
|
|
8
|
-
context.reportProgress(0, (options.targets ? options.targets.length : 0)
|
|
9
|
-
|
|
15
|
+
context.reportProgress(0, (options.targets ? options.targets.length : 0) +
|
|
16
|
+
(options.builders ? options.builders.length : 0));
|
|
10
17
|
if (options.targets) {
|
|
11
18
|
allRuns.push(...options.targets.map(({ target: targetStr, overrides }) => {
|
|
12
19
|
const [project, target, configuration] = targetStr.split(/:/g, 3);
|
|
@@ -21,13 +28,15 @@ exports.default = src_1.createBuilder((options, context) => {
|
|
|
21
28
|
let stop = null;
|
|
22
29
|
let i = 0;
|
|
23
30
|
context.reportProgress(i++, allRuns.length);
|
|
24
|
-
return rxjs_1.from(allRuns).pipe(operators_1.concatMap(
|
|
31
|
+
return rxjs_1.from(allRuns).pipe(operators_1.concatMap((fn) => stop
|
|
32
|
+
? rxjs_1.of(null)
|
|
33
|
+
: rxjs_1.from(fn()).pipe(operators_1.switchMap((run) => (run === null ? rxjs_1.of(null) : run.output.pipe(operators_1.first()))))), operators_1.map((output) => {
|
|
25
34
|
context.reportProgress(i++, allRuns.length);
|
|
26
35
|
if (output === null || stop !== null) {
|
|
27
36
|
return stop || { success: false };
|
|
28
37
|
}
|
|
29
38
|
else if (output.success === false) {
|
|
30
|
-
return stop = output;
|
|
39
|
+
return (stop = output);
|
|
31
40
|
}
|
|
32
41
|
else {
|
|
33
42
|
return output;
|
package/builders/false.d.ts
CHANGED
|
@@ -1,2 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright Google LLC All Rights Reserved.
|
|
4
|
+
*
|
|
5
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
+
* found in the LICENSE file at https://angular.io/license
|
|
7
|
+
*/
|
|
1
8
|
declare const _default: import("../src/internal").Builder<import("../../core/src").JsonObject>;
|
|
2
9
|
export default _default;
|
package/builders/false.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
2
|
/**
|
|
4
3
|
* @license
|
|
5
|
-
* Copyright Google
|
|
4
|
+
* Copyright Google LLC All Rights Reserved.
|
|
6
5
|
*
|
|
7
6
|
* Use of this source code is governed by an MIT-style license that can be
|
|
8
7
|
* found in the LICENSE file at https://angular.io/license
|
|
9
8
|
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
10
|
const src_1 = require("../src");
|
|
11
11
|
exports.default = src_1.createBuilder(() => ({
|
|
12
12
|
success: false,
|
|
@@ -16,9 +16,7 @@
|
|
|
16
16
|
"type": "object"
|
|
17
17
|
}
|
|
18
18
|
},
|
|
19
|
-
"required": [
|
|
20
|
-
"builder"
|
|
21
|
-
]
|
|
19
|
+
"required": ["builder"]
|
|
22
20
|
},
|
|
23
21
|
"minItems": 1
|
|
24
22
|
},
|
|
@@ -35,9 +33,7 @@
|
|
|
35
33
|
"type": "object"
|
|
36
34
|
}
|
|
37
35
|
},
|
|
38
|
-
"required": [
|
|
39
|
-
"target"
|
|
40
|
-
]
|
|
36
|
+
"required": ["target"]
|
|
41
37
|
},
|
|
42
38
|
"minItems": 1
|
|
43
39
|
}
|
package/builders/true.d.ts
CHANGED
|
@@ -1,2 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright Google LLC All Rights Reserved.
|
|
4
|
+
*
|
|
5
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
+
* found in the LICENSE file at https://angular.io/license
|
|
7
|
+
*/
|
|
1
8
|
declare const _default: import("../src/internal").Builder<import("../../core/src").JsonObject>;
|
|
2
9
|
export default _default;
|
package/builders/true.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
2
|
/**
|
|
4
3
|
* @license
|
|
5
|
-
* Copyright Google
|
|
4
|
+
* Copyright Google LLC All Rights Reserved.
|
|
6
5
|
*
|
|
7
6
|
* Use of this source code is governed by an MIT-style license that can be
|
|
8
7
|
* found in the LICENSE file at https://angular.io/license
|
|
9
8
|
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
10
|
const src_1 = require("../src");
|
|
11
11
|
exports.default = src_1.createBuilder(() => ({ success: true }));
|
package/node/index.d.ts
CHANGED
package/node/index.js
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @license
|
|
4
|
+
* Copyright Google LLC 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
|
+
*/
|
|
2
9
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
10
|
if (k2 === undefined) k2 = k;
|
|
4
11
|
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
@@ -10,11 +17,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
10
17
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
18
|
};
|
|
12
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
/**
|
|
14
|
-
* @license
|
|
15
|
-
* Copyright Google Inc. All Rights Reserved.
|
|
16
|
-
*
|
|
17
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
18
|
-
* found in the LICENSE file at https://angular.io/license
|
|
19
|
-
*/
|
|
20
20
|
__exportStar(require("./node-modules-architect-host"), exports);
|
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @license
|
|
4
|
+
* Copyright Google LLC 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
|
+
*/
|
|
2
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
10
|
exports.WorkspaceNodeModulesArchitectHost = void 0;
|
|
4
11
|
const path = require("path");
|
|
@@ -120,13 +127,14 @@ class WorkspaceNodeModulesArchitectHost {
|
|
|
120
127
|
return null;
|
|
121
128
|
}
|
|
122
129
|
let options = await this.workspaceHost.getOptions(target.project, target.target);
|
|
123
|
-
const targetConfiguration = target.configuration ||
|
|
130
|
+
const targetConfiguration = target.configuration ||
|
|
131
|
+
(await this.workspaceHost.getDefaultConfigurationName(target.project, target.target));
|
|
124
132
|
if (targetConfiguration) {
|
|
125
133
|
const configurations = targetConfiguration.split(',').map((c) => c.trim());
|
|
126
134
|
for (const configuration of configurations) {
|
|
127
135
|
options = {
|
|
128
136
|
...options,
|
|
129
|
-
...await this.workspaceHost.getOptions(target.project, target.target, configuration),
|
|
137
|
+
...(await this.workspaceHost.getOptions(target.project, target.target, configuration)),
|
|
130
138
|
};
|
|
131
139
|
}
|
|
132
140
|
}
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@angular-devkit/architect",
|
|
3
|
-
"version": "0.1200.0
|
|
3
|
+
"version": "0.1200.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": "12.0.0
|
|
9
|
+
"@angular-devkit/core": "12.0.0",
|
|
10
10
|
"rxjs": "6.6.7"
|
|
11
11
|
},
|
|
12
12
|
"builders": "./builders/builders.json",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"url": "https://github.com/angular/angular-cli.git"
|
|
23
23
|
},
|
|
24
24
|
"engines": {
|
|
25
|
-
"node": "
|
|
25
|
+
"node": "^12.14.1 || ^14.0.0",
|
|
26
26
|
"npm": "^6.11.0 || ^7.5.6",
|
|
27
27
|
"yarn": ">= 1.13.0"
|
|
28
28
|
},
|
package/src/api.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright Google
|
|
3
|
+
* Copyright Google LLC All Rights Reserved.
|
|
4
4
|
*
|
|
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
|
|
@@ -9,16 +9,16 @@ import { analytics, experimental, json, logging } from '@angular-devkit/core';
|
|
|
9
9
|
import { Observable, SubscribableOrPromise } from 'rxjs';
|
|
10
10
|
import { Schema as RealBuilderInput, Target as RealTarget } from './input-schema';
|
|
11
11
|
import { Schema as RealBuilderOutput } from './output-schema';
|
|
12
|
-
import {
|
|
12
|
+
import { State as BuilderProgressState, Schema as RealBuilderProgress } from './progress-schema';
|
|
13
13
|
export declare type Target = json.JsonObject & RealTarget;
|
|
14
|
-
export { BuilderProgressState
|
|
14
|
+
export { BuilderProgressState };
|
|
15
15
|
export declare type BuilderRegistry = experimental.jobs.Registry<json.JsonObject, BuilderInput, BuilderOutput>;
|
|
16
16
|
/**
|
|
17
17
|
* An API typed BuilderProgress. The interface generated from the schema is too permissive,
|
|
18
18
|
* so this API is the one we show in our API. Please note that not all fields are in there; this
|
|
19
19
|
* is in addition to fields in the schema.
|
|
20
20
|
*/
|
|
21
|
-
export declare type TypedBuilderProgress =
|
|
21
|
+
export declare type TypedBuilderProgress = {
|
|
22
22
|
state: BuilderProgressState.Stopped;
|
|
23
23
|
} | {
|
|
24
24
|
state: BuilderProgressState.Error;
|
|
@@ -31,7 +31,7 @@ export declare type TypedBuilderProgress = ({
|
|
|
31
31
|
status?: string;
|
|
32
32
|
current: number;
|
|
33
33
|
total?: number;
|
|
34
|
-
}
|
|
34
|
+
};
|
|
35
35
|
/**
|
|
36
36
|
* Declaration of those types as JsonObject compatible. JsonObject is not compatible with
|
|
37
37
|
* optional members, so those wouldn't be directly assignable to our internal Json typings.
|
|
@@ -48,10 +48,10 @@ export declare type BuilderProgress = json.JsonObject & RealBuilderProgress & Ty
|
|
|
48
48
|
* builder interface. The watch dog sends BuilderProgress and the Builder has a set of functions
|
|
49
49
|
* to manage the state.
|
|
50
50
|
*/
|
|
51
|
-
export declare type BuilderProgressReport = BuilderProgress &
|
|
51
|
+
export declare type BuilderProgressReport = BuilderProgress & {
|
|
52
52
|
target?: Target;
|
|
53
53
|
builder: BuilderInfo;
|
|
54
|
-
}
|
|
54
|
+
};
|
|
55
55
|
/**
|
|
56
56
|
* A Run, which is what is returned by scheduleBuilder or scheduleTarget functions. This should
|
|
57
57
|
* be reconstructed across memory boundaries (it's not serializable but all internal information
|
|
@@ -212,7 +212,7 @@ export interface BuilderContext {
|
|
|
212
212
|
/**
|
|
213
213
|
* Add teardown logic to this Context, so that when it's being stopped it will execute teardown.
|
|
214
214
|
*/
|
|
215
|
-
addTeardown(teardown: () =>
|
|
215
|
+
addTeardown(teardown: () => Promise<void> | void): void;
|
|
216
216
|
}
|
|
217
217
|
/**
|
|
218
218
|
* An accepted return value from a builder. Can be either an Observable, a Promise or a vector.
|
package/src/api.js
CHANGED
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @license
|
|
4
|
+
* Copyright Google LLC 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
|
+
*/
|
|
2
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
10
|
exports.scheduleTargetAndForget = exports.targetFromTargetString = exports.targetStringFromTarget = exports.fromAsyncIterable = exports.isBuilderOutput = exports.BuilderProgressState = void 0;
|
|
4
11
|
const rxjs_1 = require("rxjs");
|
|
5
12
|
const operators_1 = require("rxjs/operators");
|
|
6
13
|
const progress_schema_1 = require("./progress-schema");
|
|
7
14
|
Object.defineProperty(exports, "BuilderProgressState", { enumerable: true, get: function () { return progress_schema_1.State; } });
|
|
8
|
-
//
|
|
15
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
9
16
|
function isBuilderOutput(obj) {
|
|
10
17
|
if (!obj || typeof obj.then === 'function' || typeof obj.subscribe === 'function') {
|
|
11
18
|
return false;
|
|
@@ -56,7 +63,7 @@ function targetFromTargetString(str) {
|
|
|
56
63
|
return {
|
|
57
64
|
project: tuple[0],
|
|
58
65
|
target: tuple[1],
|
|
59
|
-
...(tuple[2] !== undefined
|
|
66
|
+
...(tuple[2] !== undefined && { configuration: tuple[2] }),
|
|
60
67
|
};
|
|
61
68
|
}
|
|
62
69
|
exports.targetFromTargetString = targetFromTargetString;
|
|
@@ -75,15 +82,15 @@ exports.targetFromTargetString = targetFromTargetString;
|
|
|
75
82
|
*/
|
|
76
83
|
function scheduleTargetAndForget(context, target, overrides, scheduleOptions) {
|
|
77
84
|
let resolve = null;
|
|
78
|
-
const promise = new Promise(r => resolve = r);
|
|
85
|
+
const promise = new Promise((r) => (resolve = r));
|
|
79
86
|
context.addTeardown(() => promise);
|
|
80
|
-
return rxjs_1.from(context.scheduleTarget(target, overrides, scheduleOptions)).pipe(operators_1.switchMap(run => new rxjs_1.Observable(observer => {
|
|
87
|
+
return rxjs_1.from(context.scheduleTarget(target, overrides, scheduleOptions)).pipe(operators_1.switchMap((run) => new rxjs_1.Observable((observer) => {
|
|
81
88
|
const subscription = run.output.subscribe(observer);
|
|
82
89
|
return () => {
|
|
83
90
|
subscription.unsubscribe();
|
|
84
91
|
// We can properly ignore the floating promise as it's a "reverse" promise; the teardown
|
|
85
92
|
// is waiting for the resolve.
|
|
86
|
-
//
|
|
93
|
+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
87
94
|
run.stop().then(resolve);
|
|
88
95
|
};
|
|
89
96
|
})));
|
package/src/architect.d.ts
CHANGED
package/src/architect.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Architect = void 0;
|
|
4
2
|
/**
|
|
5
3
|
* @license
|
|
6
|
-
* Copyright Google
|
|
4
|
+
* Copyright Google LLC All Rights Reserved.
|
|
7
5
|
*
|
|
8
6
|
* Use of this source code is governed by an MIT-style license that can be
|
|
9
7
|
* found in the LICENSE file at https://angular.io/license
|
|
10
8
|
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.Architect = void 0;
|
|
11
11
|
const core_1 = require("@angular-devkit/core");
|
|
12
12
|
const rxjs_1 = require("rxjs");
|
|
13
13
|
const operators_1 = require("rxjs/operators");
|
|
@@ -25,7 +25,7 @@ function _createJobHandlerFromBuilderInfo(info, target, host, registry, baseOpti
|
|
|
25
25
|
};
|
|
26
26
|
function handler(argument, context) {
|
|
27
27
|
// Add input validation to the inbound bus.
|
|
28
|
-
const inboundBusWithInputValidation = context.inboundBus.pipe(operators_1.concatMap(message => {
|
|
28
|
+
const inboundBusWithInputValidation = context.inboundBus.pipe(operators_1.concatMap((message) => {
|
|
29
29
|
if (message.kind === core_1.experimental.jobs.JobInboundMessageKind.Input) {
|
|
30
30
|
const v = message.value;
|
|
31
31
|
const options = {
|
|
@@ -33,13 +33,13 @@ function _createJobHandlerFromBuilderInfo(info, target, host, registry, baseOpti
|
|
|
33
33
|
...v.options,
|
|
34
34
|
};
|
|
35
35
|
// Validate v against the options schema.
|
|
36
|
-
return registry.compile(info.optionSchema).pipe(operators_1.concatMap(validation => validation(options)), operators_1.map((validationResult) => {
|
|
36
|
+
return registry.compile(info.optionSchema).pipe(operators_1.concatMap((validation) => validation(options)), operators_1.map((validationResult) => {
|
|
37
37
|
const { data, success, errors } = validationResult;
|
|
38
38
|
if (success) {
|
|
39
39
|
return { ...v, options: data };
|
|
40
40
|
}
|
|
41
41
|
throw new core_1.json.schema.SchemaValidationException(errors);
|
|
42
|
-
}), operators_1.map(value => ({ ...message, value })));
|
|
42
|
+
}), operators_1.map((value) => ({ ...message, value })));
|
|
43
43
|
}
|
|
44
44
|
else {
|
|
45
45
|
return rxjs_1.of(message);
|
|
@@ -51,18 +51,18 @@ function _createJobHandlerFromBuilderInfo(info, target, host, registry, baseOpti
|
|
|
51
51
|
// Make an inboundBus that completes instead of erroring out.
|
|
52
52
|
// We'll merge the errors into the output instead.
|
|
53
53
|
const inboundBus = rxjs_1.onErrorResumeNext(inboundBusWithInputValidation);
|
|
54
|
-
const output = rxjs_1.from(host.loadBuilder(info)).pipe(operators_1.concatMap(builder => {
|
|
54
|
+
const output = rxjs_1.from(host.loadBuilder(info)).pipe(operators_1.concatMap((builder) => {
|
|
55
55
|
if (builder === null) {
|
|
56
56
|
throw new Error(`Cannot load builder for builderInfo ${JSON.stringify(info, null, 2)}`);
|
|
57
57
|
}
|
|
58
|
-
return builder.handler(argument, { ...context, inboundBus }).pipe(operators_1.map(output => {
|
|
58
|
+
return builder.handler(argument, { ...context, inboundBus }).pipe(operators_1.map((output) => {
|
|
59
59
|
if (output.kind === core_1.experimental.jobs.JobOutboundMessageKind.Output) {
|
|
60
60
|
// Add target to it.
|
|
61
61
|
return {
|
|
62
62
|
...output,
|
|
63
63
|
value: {
|
|
64
64
|
...output.value,
|
|
65
|
-
...target ? { target } : 0,
|
|
65
|
+
...(target ? { target } : 0),
|
|
66
66
|
},
|
|
67
67
|
};
|
|
68
68
|
}
|
|
@@ -134,7 +134,7 @@ class ArchitectBuilderJobRegistry {
|
|
|
134
134
|
if (!m) {
|
|
135
135
|
return rxjs_1.of(null);
|
|
136
136
|
}
|
|
137
|
-
return rxjs_1.from(this._resolveBuilder(name)).pipe(operators_1.concatMap(builderInfo => (builderInfo ? this._createBuilder(builderInfo) : rxjs_1.of(null))), operators_1.first(null, null));
|
|
137
|
+
return rxjs_1.from(this._resolveBuilder(name)).pipe(operators_1.concatMap((builderInfo) => (builderInfo ? this._createBuilder(builderInfo) : rxjs_1.of(null))), operators_1.first(null, null));
|
|
138
138
|
}
|
|
139
139
|
}
|
|
140
140
|
/**
|
|
@@ -158,7 +158,7 @@ class ArchitectTargetJobRegistry extends ArchitectBuilderJobRegistry {
|
|
|
158
158
|
if (builderStr === null || options === null) {
|
|
159
159
|
return rxjs_1.of(null);
|
|
160
160
|
}
|
|
161
|
-
return this._resolveBuilder(builderStr).pipe(operators_1.concatMap(builderInfo => {
|
|
161
|
+
return this._resolveBuilder(builderStr).pipe(operators_1.concatMap((builderInfo) => {
|
|
162
162
|
if (builderInfo === null) {
|
|
163
163
|
return rxjs_1.of(null);
|
|
164
164
|
}
|
|
@@ -168,8 +168,8 @@ class ArchitectTargetJobRegistry extends ArchitectBuilderJobRegistry {
|
|
|
168
168
|
}
|
|
169
169
|
}
|
|
170
170
|
function _getTargetOptionsFactory(host) {
|
|
171
|
-
return core_1.experimental.jobs.createJobHandler(target => {
|
|
172
|
-
return host.getOptionsForTarget(target).then(options => {
|
|
171
|
+
return core_1.experimental.jobs.createJobHandler((target) => {
|
|
172
|
+
return host.getOptionsForTarget(target).then((options) => {
|
|
173
173
|
if (options === null) {
|
|
174
174
|
throw new Error(`Invalid target: ${JSON.stringify(target)}.`);
|
|
175
175
|
}
|
|
@@ -182,8 +182,8 @@ function _getTargetOptionsFactory(host) {
|
|
|
182
182
|
});
|
|
183
183
|
}
|
|
184
184
|
function _getProjectMetadataFactory(host) {
|
|
185
|
-
return core_1.experimental.jobs.createJobHandler(target => {
|
|
186
|
-
return host.getProjectMetadata(target).then(options => {
|
|
185
|
+
return core_1.experimental.jobs.createJobHandler((target) => {
|
|
186
|
+
return host.getProjectMetadata(target).then((options) => {
|
|
187
187
|
if (options === null) {
|
|
188
188
|
throw new Error(`Invalid target: ${JSON.stringify(target)}.`);
|
|
189
189
|
}
|
|
@@ -193,10 +193,7 @@ function _getProjectMetadataFactory(host) {
|
|
|
193
193
|
name: '..getProjectMetadata',
|
|
194
194
|
output: { type: 'object' },
|
|
195
195
|
argument: {
|
|
196
|
-
oneOf: [
|
|
197
|
-
{ type: 'string' },
|
|
198
|
-
inputSchema.properties.target,
|
|
199
|
-
],
|
|
196
|
+
oneOf: [{ type: 'string' }, inputSchema.properties.target],
|
|
200
197
|
},
|
|
201
198
|
});
|
|
202
199
|
}
|
|
@@ -220,21 +217,21 @@ function _validateOptionsFactory(host, registry) {
|
|
|
220
217
|
if (!builderInfo) {
|
|
221
218
|
throw new Error(`No builder info were found for builder ${JSON.stringify(builderName)}.`);
|
|
222
219
|
}
|
|
223
|
-
return registry
|
|
220
|
+
return registry
|
|
221
|
+
.compile(builderInfo.optionSchema)
|
|
222
|
+
.pipe(operators_1.concatMap((validation) => validation(options)), operators_1.switchMap(({ data, success, errors }) => {
|
|
224
223
|
if (success) {
|
|
225
224
|
return rxjs_1.of(data);
|
|
226
225
|
}
|
|
227
226
|
throw new core_1.json.schema.SchemaValidationException(errors);
|
|
228
|
-
}))
|
|
227
|
+
}))
|
|
228
|
+
.toPromise();
|
|
229
229
|
}, {
|
|
230
230
|
name: '..validateOptions',
|
|
231
231
|
output: { type: 'object' },
|
|
232
232
|
argument: {
|
|
233
233
|
type: 'array',
|
|
234
|
-
items: [
|
|
235
|
-
{ type: 'string' },
|
|
236
|
-
{ type: 'object' },
|
|
237
|
-
],
|
|
234
|
+
items: [{ type: 'string' }, { type: 'object' }],
|
|
238
235
|
},
|
|
239
236
|
});
|
|
240
237
|
}
|
package/src/builders-schema.json
CHANGED
|
@@ -15,9 +15,7 @@
|
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
},
|
|
18
|
-
"required": [
|
|
19
|
-
"builders"
|
|
20
|
-
],
|
|
18
|
+
"required": ["builders"],
|
|
21
19
|
"definitions": {
|
|
22
20
|
"builder": {
|
|
23
21
|
"type": "object",
|
|
@@ -34,10 +32,7 @@
|
|
|
34
32
|
"description": "Builder description."
|
|
35
33
|
}
|
|
36
34
|
},
|
|
37
|
-
"required": [
|
|
38
|
-
"schema",
|
|
39
|
-
"description"
|
|
40
|
-
]
|
|
35
|
+
"required": ["schema", "description"]
|
|
41
36
|
},
|
|
42
37
|
{
|
|
43
38
|
"anyOf": [
|
|
@@ -48,9 +43,7 @@
|
|
|
48
43
|
"description": "The next generation builder module."
|
|
49
44
|
}
|
|
50
45
|
},
|
|
51
|
-
"required": [
|
|
52
|
-
"implementation"
|
|
53
|
-
]
|
|
46
|
+
"required": ["implementation"]
|
|
54
47
|
},
|
|
55
48
|
{
|
|
56
49
|
"properties": {
|
|
@@ -59,9 +52,7 @@
|
|
|
59
52
|
"description": "The builder class module."
|
|
60
53
|
}
|
|
61
54
|
},
|
|
62
|
-
"required": [
|
|
63
|
-
"class"
|
|
64
|
-
]
|
|
55
|
+
"required": ["class"]
|
|
65
56
|
}
|
|
66
57
|
]
|
|
67
58
|
}
|
package/src/create-builder.d.ts
CHANGED
package/src/create-builder.js
CHANGED
|
@@ -1,22 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createBuilder = void 0;
|
|
4
2
|
/**
|
|
5
3
|
* @license
|
|
6
|
-
* Copyright Google
|
|
4
|
+
* Copyright Google LLC All Rights Reserved.
|
|
7
5
|
*
|
|
8
6
|
* Use of this source code is governed by an MIT-style license that can be
|
|
9
7
|
* found in the LICENSE file at https://angular.io/license
|
|
10
8
|
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.createBuilder = void 0;
|
|
11
11
|
const core_1 = require("@angular-devkit/core");
|
|
12
12
|
const rxjs_1 = require("rxjs");
|
|
13
13
|
const operators_1 = require("rxjs/operators");
|
|
14
14
|
const api_1 = require("./api");
|
|
15
15
|
const internal_1 = require("./internal");
|
|
16
16
|
const schedule_by_name_1 = require("./schedule-by-name");
|
|
17
|
-
//
|
|
17
|
+
// eslint-disable-next-line max-lines-per-function
|
|
18
18
|
function createBuilder(fn) {
|
|
19
19
|
const cjh = core_1.experimental.jobs.createJobHandler;
|
|
20
|
+
// eslint-disable-next-line max-lines-per-function
|
|
20
21
|
const handler = cjh((options, context) => {
|
|
21
22
|
const scheduler = context.scheduler;
|
|
22
23
|
const progressChannel = context.createChannel('progress');
|
|
@@ -50,15 +51,14 @@ function createBuilder(fn) {
|
|
|
50
51
|
id: context.id,
|
|
51
52
|
});
|
|
52
53
|
}
|
|
53
|
-
return new rxjs_1.Observable(observer => {
|
|
54
|
+
return new rxjs_1.Observable((observer) => {
|
|
54
55
|
const subscriptions = [];
|
|
55
|
-
const inputSubscription = context.inboundBus.subscribe(i => {
|
|
56
|
+
const inputSubscription = context.inboundBus.subscribe((i) => {
|
|
56
57
|
switch (i.kind) {
|
|
57
58
|
case core_1.experimental.jobs.JobInboundMessageKind.Stop:
|
|
58
59
|
// Run teardown logic then complete.
|
|
59
60
|
tearingDown = true;
|
|
60
|
-
Promise.all(teardownLogics.map(fn => fn() || Promise.resolve()))
|
|
61
|
-
.then(() => observer.complete(), err => observer.error(err));
|
|
61
|
+
Promise.all(teardownLogics.map((fn) => fn() || Promise.resolve())).then(() => observer.complete(), (err) => observer.error(err));
|
|
62
62
|
break;
|
|
63
63
|
case core_1.experimental.jobs.JobInboundMessageKind.Input:
|
|
64
64
|
if (!tearingDown) {
|
|
@@ -73,7 +73,7 @@ function createBuilder(fn) {
|
|
|
73
73
|
? api_1.targetStringFromTarget(i.target)
|
|
74
74
|
: builder.builderName;
|
|
75
75
|
const logger = new core_1.logging.Logger(loggerName);
|
|
76
|
-
subscriptions.push(logger.subscribe(entry => log(entry)));
|
|
76
|
+
subscriptions.push(logger.subscribe((entry) => log(entry)));
|
|
77
77
|
const context = {
|
|
78
78
|
builder,
|
|
79
79
|
workspaceRoot: i.workspaceRoot,
|
|
@@ -89,7 +89,7 @@ function createBuilder(fn) {
|
|
|
89
89
|
currentDirectory: i.currentDirectory,
|
|
90
90
|
});
|
|
91
91
|
// We don't want to subscribe errors and complete.
|
|
92
|
-
subscriptions.push(run.progress.subscribe(event => progressChannel.next(event)));
|
|
92
|
+
subscriptions.push(run.progress.subscribe((event) => progressChannel.next(event)));
|
|
93
93
|
return run;
|
|
94
94
|
},
|
|
95
95
|
async scheduleBuilder(builderName, options = {}, scheduleOptions = {}) {
|
|
@@ -101,20 +101,31 @@ function createBuilder(fn) {
|
|
|
101
101
|
currentDirectory: i.currentDirectory,
|
|
102
102
|
});
|
|
103
103
|
// We don't want to subscribe errors and complete.
|
|
104
|
-
subscriptions.push(run.progress.subscribe(event => progressChannel.next(event)));
|
|
104
|
+
subscriptions.push(run.progress.subscribe((event) => progressChannel.next(event)));
|
|
105
105
|
return run;
|
|
106
106
|
},
|
|
107
107
|
async getTargetOptions(target) {
|
|
108
|
-
return scheduler
|
|
108
|
+
return scheduler
|
|
109
|
+
.schedule('..getTargetOptions', target)
|
|
110
|
+
.output.toPromise();
|
|
109
111
|
},
|
|
110
112
|
async getProjectMetadata(target) {
|
|
111
|
-
return scheduler
|
|
113
|
+
return scheduler
|
|
114
|
+
.schedule('..getProjectMetadata', target)
|
|
115
|
+
.output.toPromise();
|
|
112
116
|
},
|
|
113
117
|
async getBuilderNameForTarget(target) {
|
|
114
|
-
return scheduler
|
|
118
|
+
return scheduler
|
|
119
|
+
.schedule('..getBuilderNameForTarget', target)
|
|
120
|
+
.output.toPromise();
|
|
115
121
|
},
|
|
116
122
|
async validateOptions(options, builderName) {
|
|
117
|
-
return scheduler
|
|
123
|
+
return scheduler
|
|
124
|
+
.schedule('..validateOptions', [
|
|
125
|
+
builderName,
|
|
126
|
+
options,
|
|
127
|
+
])
|
|
128
|
+
.output.toPromise();
|
|
118
129
|
},
|
|
119
130
|
reportRunning() {
|
|
120
131
|
switch (currentState) {
|
|
@@ -140,7 +151,7 @@ function createBuilder(fn) {
|
|
|
140
151
|
progress({ state: currentState, current, total, status }, context);
|
|
141
152
|
}
|
|
142
153
|
},
|
|
143
|
-
analytics: new core_1.analytics.ForwardingAnalytics(report => analyticsChannel.next(report)),
|
|
154
|
+
analytics: new core_1.analytics.ForwardingAnalytics((report) => analyticsChannel.next(report)),
|
|
144
155
|
addTeardown(teardown) {
|
|
145
156
|
teardownLogics.push(teardown);
|
|
146
157
|
},
|
|
@@ -164,13 +175,15 @@ function createBuilder(fn) {
|
|
|
164
175
|
}
|
|
165
176
|
// Manage some state automatically.
|
|
166
177
|
progress({ state: api_1.BuilderProgressState.Running, current: 0, total: 1 }, context);
|
|
167
|
-
subscriptions.push(result
|
|
178
|
+
subscriptions.push(result
|
|
179
|
+
.pipe(operators_1.tap(() => {
|
|
168
180
|
progress({ state: api_1.BuilderProgressState.Running, current: total }, context);
|
|
169
181
|
progress({ state: api_1.BuilderProgressState.Stopped }, context);
|
|
170
|
-
}))
|
|
182
|
+
}))
|
|
183
|
+
.subscribe((message) => observer.next(message), (error) => observer.error(error), () => observer.complete()));
|
|
171
184
|
}
|
|
172
185
|
return () => {
|
|
173
|
-
subscriptions.forEach(x => x.unsubscribe());
|
|
186
|
+
subscriptions.forEach((x) => x.unsubscribe());
|
|
174
187
|
inputSubscription.unsubscribe();
|
|
175
188
|
};
|
|
176
189
|
});
|
package/src/index.d.ts
CHANGED
package/src/index.js
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @license
|
|
4
|
+
* Copyright Google LLC 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
|
+
*/
|
|
2
9
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
10
|
if (k2 === undefined) k2 = k;
|
|
4
11
|
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
@@ -11,13 +18,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
11
18
|
};
|
|
12
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
20
|
exports.createBuilder = exports.Architect = void 0;
|
|
14
|
-
/**
|
|
15
|
-
* @license
|
|
16
|
-
* Copyright Google Inc. All Rights Reserved.
|
|
17
|
-
*
|
|
18
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
19
|
-
* found in the LICENSE file at https://angular.io/license
|
|
20
|
-
*/
|
|
21
21
|
__exportStar(require("./api"), exports);
|
|
22
22
|
var architect_1 = require("./architect");
|
|
23
23
|
Object.defineProperty(exports, "Architect", { enumerable: true, get: function () { return architect_1.Architect; } });
|
package/src/input-schema.json
CHANGED
|
@@ -26,10 +26,7 @@
|
|
|
26
26
|
"type": "string"
|
|
27
27
|
}
|
|
28
28
|
},
|
|
29
|
-
"required": [
|
|
30
|
-
"project",
|
|
31
|
-
"target"
|
|
32
|
-
]
|
|
29
|
+
"required": ["project", "target"]
|
|
33
30
|
},
|
|
34
31
|
"info": {
|
|
35
32
|
"type": "object"
|
|
@@ -38,10 +35,5 @@
|
|
|
38
35
|
"type": "object"
|
|
39
36
|
}
|
|
40
37
|
},
|
|
41
|
-
"required": [
|
|
42
|
-
"currentDirectory",
|
|
43
|
-
"id",
|
|
44
|
-
"info",
|
|
45
|
-
"workspaceRoot"
|
|
46
|
-
]
|
|
38
|
+
"required": ["currentDirectory", "id", "info", "workspaceRoot"]
|
|
47
39
|
}
|
package/src/internal.d.ts
CHANGED
package/src/internal.js
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @license
|
|
4
|
+
* Copyright Google LLC 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
|
+
*/
|
|
2
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
10
|
exports.BuilderVersionSymbol = exports.BuilderSymbol = void 0;
|
|
4
11
|
// Internal types that should not be exported directly. These are used by the host and architect
|
package/src/output-schema.json
CHANGED
package/src/progress-schema.json
CHANGED
|
@@ -12,40 +12,30 @@
|
|
|
12
12
|
"properties": {
|
|
13
13
|
"state": {
|
|
14
14
|
"type": "string",
|
|
15
|
-
"enum": [
|
|
16
|
-
"stopped"
|
|
17
|
-
]
|
|
15
|
+
"enum": ["stopped"]
|
|
18
16
|
}
|
|
19
17
|
},
|
|
20
|
-
"required": [
|
|
21
|
-
"state"
|
|
22
|
-
]
|
|
18
|
+
"required": ["state"]
|
|
23
19
|
},
|
|
24
20
|
{
|
|
25
21
|
"type": "object",
|
|
26
22
|
"properties": {
|
|
27
23
|
"state": {
|
|
28
24
|
"type": "string",
|
|
29
|
-
"enum": [
|
|
30
|
-
"waiting"
|
|
31
|
-
]
|
|
25
|
+
"enum": ["waiting"]
|
|
32
26
|
},
|
|
33
27
|
"status": {
|
|
34
28
|
"type": "string"
|
|
35
29
|
}
|
|
36
30
|
},
|
|
37
|
-
"required": [
|
|
38
|
-
"state"
|
|
39
|
-
]
|
|
31
|
+
"required": ["state"]
|
|
40
32
|
},
|
|
41
33
|
{
|
|
42
34
|
"type": "object",
|
|
43
35
|
"properties": {
|
|
44
36
|
"state": {
|
|
45
37
|
"type": "string",
|
|
46
|
-
"enum": [
|
|
47
|
-
"running"
|
|
48
|
-
]
|
|
38
|
+
"enum": ["running"]
|
|
49
39
|
},
|
|
50
40
|
"current": {
|
|
51
41
|
"type": "number",
|
|
@@ -59,24 +49,18 @@
|
|
|
59
49
|
"type": "string"
|
|
60
50
|
}
|
|
61
51
|
},
|
|
62
|
-
"required": [
|
|
63
|
-
"state"
|
|
64
|
-
]
|
|
52
|
+
"required": ["state"]
|
|
65
53
|
},
|
|
66
54
|
{
|
|
67
55
|
"type": "object",
|
|
68
56
|
"properties": {
|
|
69
57
|
"state": {
|
|
70
58
|
"type": "string",
|
|
71
|
-
"enum": [
|
|
72
|
-
"error"
|
|
73
|
-
]
|
|
59
|
+
"enum": ["error"]
|
|
74
60
|
},
|
|
75
61
|
"error": true
|
|
76
62
|
},
|
|
77
|
-
"required": [
|
|
78
|
-
"state"
|
|
79
|
-
]
|
|
63
|
+
"required": ["state"]
|
|
80
64
|
}
|
|
81
65
|
]
|
|
82
66
|
},
|
|
@@ -93,10 +77,7 @@
|
|
|
93
77
|
"type": "number"
|
|
94
78
|
}
|
|
95
79
|
},
|
|
96
|
-
"required": [
|
|
97
|
-
"builder",
|
|
98
|
-
"id"
|
|
99
|
-
]
|
|
80
|
+
"required": ["builder", "id"]
|
|
100
81
|
}
|
|
101
82
|
]
|
|
102
83
|
}
|
package/src/schedule-by-name.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.scheduleByTarget = exports.scheduleByName = void 0;
|
|
4
2
|
/**
|
|
5
3
|
* @license
|
|
6
|
-
* Copyright Google
|
|
4
|
+
* Copyright Google LLC All Rights Reserved.
|
|
7
5
|
*
|
|
8
6
|
* Use of this source code is governed by an MIT-style license that can be
|
|
9
7
|
* found in the LICENSE file at https://angular.io/license
|
|
10
8
|
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.scheduleByTarget = exports.scheduleByName = void 0;
|
|
11
11
|
const core_1 = require("@angular-devkit/core");
|
|
12
12
|
const rxjs_1 = require("rxjs");
|
|
13
13
|
const operators_1 = require("rxjs/operators");
|
|
@@ -34,7 +34,7 @@ async function scheduleByName(name, buildOptions, options) {
|
|
|
34
34
|
};
|
|
35
35
|
// Wait for the job to be ready.
|
|
36
36
|
if (job.state !== core_1.experimental.jobs.JobState.Started) {
|
|
37
|
-
stateSubscription = job.outboundBus.subscribe(event => {
|
|
37
|
+
stateSubscription = job.outboundBus.subscribe((event) => {
|
|
38
38
|
if (event.kind === core_1.experimental.jobs.JobOutboundMessageKind.Start) {
|
|
39
39
|
job.input.next(message);
|
|
40
40
|
}
|
|
@@ -43,7 +43,7 @@ async function scheduleByName(name, buildOptions, options) {
|
|
|
43
43
|
else {
|
|
44
44
|
job.input.next(message);
|
|
45
45
|
}
|
|
46
|
-
const logChannelSub = job.getChannel('log').subscribe(entry => {
|
|
46
|
+
const logChannelSub = job.getChannel('log').subscribe((entry) => {
|
|
47
47
|
logger.next(entry);
|
|
48
48
|
}, () => { });
|
|
49
49
|
const s = job.outboundBus.subscribe({
|
|
@@ -56,16 +56,17 @@ async function scheduleByName(name, buildOptions, options) {
|
|
|
56
56
|
}
|
|
57
57
|
},
|
|
58
58
|
});
|
|
59
|
-
const output = job.output.pipe(operators_1.map(output => ({
|
|
59
|
+
const output = job.output.pipe(operators_1.map((output) => ({
|
|
60
60
|
...output,
|
|
61
|
-
...options.target ? { target: options.target } : 0,
|
|
61
|
+
...(options.target ? { target: options.target } : 0),
|
|
62
62
|
info,
|
|
63
63
|
})), operators_1.shareReplay());
|
|
64
64
|
// If there's an analytics object, take the job channel and report it to the analytics.
|
|
65
65
|
if (options.analytics) {
|
|
66
66
|
const reporter = new core_1.analytics.AnalyticsReporter(options.analytics);
|
|
67
|
-
job
|
|
68
|
-
.
|
|
67
|
+
job
|
|
68
|
+
.getChannel('analytics')
|
|
69
|
+
.subscribe((report) => reporter.report(report));
|
|
69
70
|
}
|
|
70
71
|
// Start the builder.
|
|
71
72
|
output.pipe(operators_1.first()).subscribe({
|
|
@@ -75,12 +76,18 @@ async function scheduleByName(name, buildOptions, options) {
|
|
|
75
76
|
id,
|
|
76
77
|
info,
|
|
77
78
|
// This is a getter so that it always returns the next output, and not the same one.
|
|
78
|
-
get result() {
|
|
79
|
+
get result() {
|
|
80
|
+
return output.pipe(operators_1.first()).toPromise();
|
|
81
|
+
},
|
|
79
82
|
output,
|
|
80
|
-
progress: job
|
|
83
|
+
progress: job
|
|
84
|
+
.getChannel('progress', progressSchema)
|
|
85
|
+
.pipe(operators_1.shareReplay(1)),
|
|
81
86
|
stop() {
|
|
82
87
|
job.stop();
|
|
83
|
-
return job.outboundBus
|
|
88
|
+
return job.outboundBus
|
|
89
|
+
.pipe(operators_1.ignoreElements(), operators_1.catchError(() => rxjs_1.EMPTY))
|
|
90
|
+
.toPromise();
|
|
84
91
|
},
|
|
85
92
|
};
|
|
86
93
|
}
|
package/src/targets-schema.json
CHANGED
package/testing/index.d.ts
CHANGED
package/testing/index.js
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @license
|
|
4
|
+
* Copyright Google LLC 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
|
+
*/
|
|
2
9
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
10
|
if (k2 === undefined) k2 = k;
|
|
4
11
|
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
@@ -10,12 +17,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
10
17
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
18
|
};
|
|
12
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
/**
|
|
14
|
-
* @license
|
|
15
|
-
* Copyright Google Inc. All Rights Reserved.
|
|
16
|
-
*
|
|
17
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
18
|
-
* found in the LICENSE file at https://angular.io/license
|
|
19
|
-
*/
|
|
20
20
|
__exportStar(require("./testing-architect-host"), exports);
|
|
21
21
|
__exportStar(require("./test-project-host"), exports);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
3
|
* @license
|
|
4
|
-
* Copyright Google
|
|
4
|
+
* Copyright Google LLC All Rights Reserved.
|
|
5
5
|
*
|
|
6
6
|
* Use of this source code is governed by an MIT-style license that can be
|
|
7
7
|
* found in the LICENSE file at https://angular.io/license
|
|
@@ -37,24 +37,24 @@ class TestProjectHost extends node_1.NodeJsSyncHost {
|
|
|
37
37
|
initialize() {
|
|
38
38
|
const recursiveList = (path) => this.list(path).pipe(
|
|
39
39
|
// Emit each fragment individually.
|
|
40
|
-
operators_1.concatMap(fragments => rxjs_1.from(fragments)),
|
|
40
|
+
operators_1.concatMap((fragments) => rxjs_1.from(fragments)),
|
|
41
41
|
// Join the path with fragment.
|
|
42
|
-
operators_1.map(fragment => core_1.join(path, fragment)),
|
|
42
|
+
operators_1.map((fragment) => core_1.join(path, fragment)),
|
|
43
43
|
// Emit directory content paths instead of the directory path.
|
|
44
|
-
operators_1.mergeMap(path => this.isDirectory(path).pipe(operators_1.concatMap(isDir => isDir ? recursiveList(path) : rxjs_1.of(path)))));
|
|
44
|
+
operators_1.mergeMap((path) => this.isDirectory(path).pipe(operators_1.concatMap((isDir) => (isDir ? recursiveList(path) : rxjs_1.of(path))))));
|
|
45
45
|
// Find a unique folder that we can write to to use as current root.
|
|
46
46
|
return this.findUniqueFolderPath().pipe(
|
|
47
47
|
// Save the path and create a scoped host for it.
|
|
48
|
-
operators_1.tap(newFolderPath => {
|
|
48
|
+
operators_1.tap((newFolderPath) => {
|
|
49
49
|
this._currentRoot = newFolderPath;
|
|
50
50
|
this._scopedSyncHost = new core_1.virtualFs.SyncDelegateHost(new core_1.virtualFs.ScopedHost(this, this.root()));
|
|
51
51
|
}),
|
|
52
52
|
// List all files in root.
|
|
53
53
|
operators_1.concatMap(() => recursiveList(this._templateRoot)),
|
|
54
54
|
// Copy them over to the current root.
|
|
55
|
-
operators_1.concatMap(from => {
|
|
55
|
+
operators_1.concatMap((from) => {
|
|
56
56
|
const to = core_1.join(this.root(), core_1.relative(this._templateRoot, from));
|
|
57
|
-
return this.read(from).pipe(operators_1.concatMap(buffer => this.write(to, buffer)));
|
|
57
|
+
return this.read(from).pipe(operators_1.concatMap((buffer) => this.write(to, buffer)));
|
|
58
58
|
}), operators_1.map(() => { }));
|
|
59
59
|
}
|
|
60
60
|
restore() {
|
|
@@ -63,13 +63,13 @@ class TestProjectHost extends node_1.NodeJsSyncHost {
|
|
|
63
63
|
}
|
|
64
64
|
// Delete the current root and clear the variables.
|
|
65
65
|
// Wait 50ms and retry up to 10 times, to give time for file locks to clear.
|
|
66
|
-
return this.exists(this.root()).pipe(operators_1.delay(50), operators_1.concatMap(exists => exists ? this.delete(this.root()) : rxjs_1.EMPTY), operators_1.retry(10), operators_1.finalize(() => {
|
|
66
|
+
return this.exists(this.root()).pipe(operators_1.delay(50), operators_1.concatMap((exists) => (exists ? this.delete(this.root()) : rxjs_1.EMPTY)), operators_1.retry(10), operators_1.finalize(() => {
|
|
67
67
|
this._currentRoot = null;
|
|
68
68
|
this._scopedSyncHost = null;
|
|
69
69
|
}));
|
|
70
70
|
}
|
|
71
71
|
writeMultipleFiles(files) {
|
|
72
|
-
Object.keys(files).forEach(fileName => {
|
|
72
|
+
Object.keys(files).forEach((fileName) => {
|
|
73
73
|
let content = files[fileName];
|
|
74
74
|
if (typeof content == 'string') {
|
|
75
75
|
content = core_1.virtualFs.stringToFileBuffer(content);
|
|
@@ -89,7 +89,9 @@ class TestProjectHost extends node_1.NodeJsSyncHost {
|
|
|
89
89
|
this.scopedSync().write(core_1.normalize(path), core_1.virtualFs.stringToFileBuffer(content.concat(str)));
|
|
90
90
|
}
|
|
91
91
|
fileMatchExists(dir, regex) {
|
|
92
|
-
const [fileName] = this.scopedSync()
|
|
92
|
+
const [fileName] = this.scopedSync()
|
|
93
|
+
.list(core_1.normalize(dir))
|
|
94
|
+
.filter((name) => name.match(regex));
|
|
93
95
|
return fileName || undefined;
|
|
94
96
|
}
|
|
95
97
|
copyFile(from, to) {
|
|
@@ -101,7 +103,7 @@ class TestProjectHost extends node_1.NodeJsSyncHost {
|
|
|
101
103
|
const randomString = Math.random().toString(36).slice(2);
|
|
102
104
|
const newFolderName = `test-project-host-${core_1.basename(this._templateRoot)}-${randomString}`;
|
|
103
105
|
const newFolderPath = core_1.join(core_1.dirname(this._templateRoot), newFolderName);
|
|
104
|
-
return this.exists(newFolderPath).pipe(operators_1.concatMap(exists => exists ? this.findUniqueFolderPath() : rxjs_1.of(newFolderPath)));
|
|
106
|
+
return this.exists(newFolderPath).pipe(operators_1.concatMap((exists) => (exists ? this.findUniqueFolderPath() : rxjs_1.of(newFolderPath))));
|
|
105
107
|
}
|
|
106
108
|
}
|
|
107
109
|
exports.TestProjectHost = TestProjectHost;
|
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @license
|
|
4
|
+
* Copyright Google LLC 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
|
+
*/
|
|
2
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
10
|
exports.TestingArchitectHost = void 0;
|
|
4
11
|
const src_1 = require("../src");
|
|
@@ -65,8 +72,8 @@ class TestingArchitectHost {
|
|
|
65
72
|
* @returns All the info needed for the builder itself.
|
|
66
73
|
*/
|
|
67
74
|
async resolveBuilder(builderName) {
|
|
68
|
-
return this._builderMap.get(builderName)
|
|
69
|
-
|
|
75
|
+
return (this._builderMap.get(builderName) ||
|
|
76
|
+
(this._backendHost && this._backendHost.resolveBuilder(builderName)));
|
|
70
77
|
}
|
|
71
78
|
async getCurrentDirectory() {
|
|
72
79
|
return this.currentDirectory;
|
|
@@ -86,8 +93,8 @@ class TestingArchitectHost {
|
|
|
86
93
|
return this._backendHost && this._backendHost.getProjectMetadata(target);
|
|
87
94
|
}
|
|
88
95
|
async loadBuilder(info) {
|
|
89
|
-
return this._builderImportMap.get(info.builderName)
|
|
90
|
-
|
|
96
|
+
return (this._builderImportMap.get(info.builderName) ||
|
|
97
|
+
(this._backendHost && this._backendHost.loadBuilder(info)));
|
|
91
98
|
}
|
|
92
99
|
}
|
|
93
100
|
exports.TestingArchitectHost = TestingArchitectHost;
|