@depup/angular-devkit__architect 0.2102.2-depup.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/LICENSE +21 -0
- package/README.md +25 -0
- package/bin/architect.d.ts +9 -0
- package/bin/architect.js +252 -0
- package/bin/architect.js.map +1 -0
- package/bin/cli.js +10 -0
- package/builders/all-of.d.ts +11 -0
- package/builders/all-of.js +49 -0
- package/builders/all-of.js.map +1 -0
- package/builders/builders.json +25 -0
- package/builders/concat.d.ts +11 -0
- package/builders/concat.js +46 -0
- package/builders/concat.js.map +1 -0
- package/builders/false.d.ts +10 -0
- package/builders/false.js +16 -0
- package/builders/false.js.map +1 -0
- package/builders/noop-schema.json +4 -0
- package/builders/operator-schema.d.ts +22 -0
- package/builders/operator-schema.js +5 -0
- package/builders/operator-schema.js.map +1 -0
- package/builders/operator-schema.json +41 -0
- package/builders/true.d.ts +10 -0
- package/builders/true.js +13 -0
- package/builders/true.js.map +1 -0
- package/changes.json +5 -0
- package/index.d.ts +8 -0
- package/index.js +25 -0
- package/index.js.map +1 -0
- package/node/index.d.ts +10 -0
- package/node/index.js +50 -0
- package/node/index.js.map +1 -0
- package/node/jobs/job-registry.d.ts +20 -0
- package/node/jobs/job-registry.js +60 -0
- package/node/jobs/job-registry.js.map +1 -0
- package/node/node-modules-architect-host.d.ts +41 -0
- package/node/node-modules-architect-host.js +242 -0
- package/node/node-modules-architect-host.js.map +1 -0
- package/package.json +51 -0
- package/src/api.d.ts +269 -0
- package/src/api.js +98 -0
- package/src/api.js.map +1 -0
- package/src/architect.d.ts +25 -0
- package/src/architect.js +268 -0
- package/src/architect.js.map +1 -0
- package/src/builders-schema.d.ts +33 -0
- package/src/builders-schema.js +5 -0
- package/src/builders-schema.js.map +1 -0
- package/src/builders-schema.json +70 -0
- package/src/create-builder.d.ts +12 -0
- package/src/create-builder.js +184 -0
- package/src/create-builder.js.map +1 -0
- package/src/index.d.ts +12 -0
- package/src/index.js +54 -0
- package/src/index.js.map +1 -0
- package/src/input-schema.d.ts +19 -0
- package/src/input-schema.js +5 -0
- package/src/input-schema.js.map +1 -0
- package/src/input-schema.json +39 -0
- package/src/internal.d.ts +68 -0
- package/src/internal.js +27 -0
- package/src/internal.js.map +1 -0
- package/src/jobs/api.d.ts +332 -0
- package/src/jobs/api.js +74 -0
- package/src/jobs/api.js.map +1 -0
- package/src/jobs/create-job-handler.d.ts +47 -0
- package/src/jobs/create-job-handler.js +146 -0
- package/src/jobs/create-job-handler.js.map +1 -0
- package/src/jobs/dispatcher.d.ts +31 -0
- package/src/jobs/dispatcher.js +50 -0
- package/src/jobs/dispatcher.js.map +1 -0
- package/src/jobs/exception.d.ts +15 -0
- package/src/jobs/exception.js +24 -0
- package/src/jobs/exception.js.map +1 -0
- package/src/jobs/fallback-registry.d.ts +19 -0
- package/src/jobs/fallback-registry.js +28 -0
- package/src/jobs/fallback-registry.js.map +1 -0
- package/src/jobs/index.d.ts +16 -0
- package/src/jobs/index.js +56 -0
- package/src/jobs/index.js.map +1 -0
- package/src/jobs/simple-registry.d.ts +44 -0
- package/src/jobs/simple-registry.js +76 -0
- package/src/jobs/simple-registry.js.map +1 -0
- package/src/jobs/simple-scheduler.d.ts +77 -0
- package/src/jobs/simple-scheduler.js +395 -0
- package/src/jobs/simple-scheduler.js.map +1 -0
- package/src/jobs/strategy.d.ts +26 -0
- package/src/jobs/strategy.js +94 -0
- package/src/jobs/strategy.js.map +1 -0
- package/src/jobs/types.d.ts +15 -0
- package/src/jobs/types.js +10 -0
- package/src/jobs/types.js.map +1 -0
- package/src/options.d.ts +12 -0
- package/src/options.js +30 -0
- package/src/options.js.map +1 -0
- package/src/output-schema.d.ts +15 -0
- package/src/output-schema.js +5 -0
- package/src/output-schema.js.map +1 -0
- package/src/output-schema.json +33 -0
- package/src/progress-schema.d.ts +21 -0
- package/src/progress-schema.js +13 -0
- package/src/progress-schema.js.map +1 -0
- package/src/progress-schema.json +83 -0
- package/src/schedule-by-name.d.ts +23 -0
- package/src/schedule-by-name.js +101 -0
- package/src/schedule-by-name.js.map +1 -0
- package/src/targets-schema.json +39 -0
- package/testing/index.d.ts +9 -0
- package/testing/index.js +26 -0
- package/testing/index.js.map +1 -0
- package/testing/test-project-host.d.ts +32 -0
- package/testing/test-project-host.js +110 -0
- package/testing/test-project-host.js.map +1 -0
- package/testing/testing-architect-host.d.ts +42 -0
- package/testing/testing-architect-host.js +135 -0
- package/testing/testing-architect-host.js.map +1 -0
package/src/api.d.ts
ADDED
|
@@ -0,0 +1,269 @@
|
|
|
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.dev/license
|
|
7
|
+
*/
|
|
8
|
+
import { json, logging } from '@angular-devkit/core';
|
|
9
|
+
import { Observable, ObservableInput } from 'rxjs';
|
|
10
|
+
import { Schema as RealBuilderInput, Target as RealTarget } from './input-schema';
|
|
11
|
+
import { Registry } from './jobs';
|
|
12
|
+
import { Schema as RealBuilderOutput } from './output-schema';
|
|
13
|
+
import { State as BuilderProgressState, Schema as RealBuilderProgress } from './progress-schema';
|
|
14
|
+
export type Target = json.JsonObject & RealTarget;
|
|
15
|
+
export { BuilderProgressState };
|
|
16
|
+
export type BuilderRegistry = Registry<json.JsonObject, BuilderInput, BuilderOutput>;
|
|
17
|
+
/**
|
|
18
|
+
* An API typed BuilderProgress. The interface generated from the schema is too permissive,
|
|
19
|
+
* so this API is the one we show in our API. Please note that not all fields are in there; this
|
|
20
|
+
* is in addition to fields in the schema.
|
|
21
|
+
*/
|
|
22
|
+
export type TypedBuilderProgress = {
|
|
23
|
+
state: BuilderProgressState.Stopped;
|
|
24
|
+
} | {
|
|
25
|
+
state: BuilderProgressState.Error;
|
|
26
|
+
error: json.JsonValue;
|
|
27
|
+
} | {
|
|
28
|
+
state: BuilderProgressState.Waiting;
|
|
29
|
+
status?: string;
|
|
30
|
+
} | {
|
|
31
|
+
state: BuilderProgressState.Running;
|
|
32
|
+
status?: string;
|
|
33
|
+
current: number;
|
|
34
|
+
total?: number;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Declaration of those types as JsonObject compatible. JsonObject is not compatible with
|
|
38
|
+
* optional members, so those wouldn't be directly assignable to our internal Json typings.
|
|
39
|
+
* Forcing the type to be both a JsonObject and the type from the Schema tells Typescript they
|
|
40
|
+
* are compatible (which they are).
|
|
41
|
+
* These types should be used everywhere.
|
|
42
|
+
*/
|
|
43
|
+
export type BuilderInput = json.JsonObject & RealBuilderInput;
|
|
44
|
+
export type BuilderOutput = json.JsonObject & RealBuilderOutput;
|
|
45
|
+
export type BuilderProgress = json.JsonObject & RealBuilderProgress & TypedBuilderProgress;
|
|
46
|
+
/**
|
|
47
|
+
* A progress report is what the tooling will receive. It contains the builder info and the target.
|
|
48
|
+
* Although these are serializable, they are only exposed through the tooling interface, not the
|
|
49
|
+
* builder interface. The watch dog sends BuilderProgress and the Builder has a set of functions
|
|
50
|
+
* to manage the state.
|
|
51
|
+
*/
|
|
52
|
+
export type BuilderProgressReport = BuilderProgress & {
|
|
53
|
+
target?: Target;
|
|
54
|
+
builder: BuilderInfo;
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* A Run, which is what is returned by scheduleBuilder or scheduleTarget functions. This should
|
|
58
|
+
* be reconstructed across memory boundaries (it's not serializable but all internal information
|
|
59
|
+
* are).
|
|
60
|
+
*/
|
|
61
|
+
export interface BuilderRun {
|
|
62
|
+
/**
|
|
63
|
+
* Unique amongst runs. This is the same ID as the context generated for the run. It can be
|
|
64
|
+
* used to identify multiple unique runs. There is no guarantee that a run is a single output;
|
|
65
|
+
* a builder can rebuild on its own and will generate multiple outputs.
|
|
66
|
+
*/
|
|
67
|
+
id: number;
|
|
68
|
+
/**
|
|
69
|
+
* The builder information.
|
|
70
|
+
*/
|
|
71
|
+
info: BuilderInfo;
|
|
72
|
+
/**
|
|
73
|
+
* The next output from a builder. This is recommended when scheduling a builder and only being
|
|
74
|
+
* interested in the result of that single run, not of a watch-mode builder.
|
|
75
|
+
*/
|
|
76
|
+
result: Promise<BuilderOutput>;
|
|
77
|
+
/**
|
|
78
|
+
* The last output from a builder. This is recommended when scheduling a builder and only being
|
|
79
|
+
* interested in the result of that last run.
|
|
80
|
+
*/
|
|
81
|
+
lastOutput: Promise<BuilderOutput>;
|
|
82
|
+
/**
|
|
83
|
+
* The output(s) from the builder. A builder can have multiple outputs.
|
|
84
|
+
* This always replay the last output when subscribed.
|
|
85
|
+
*/
|
|
86
|
+
output: Observable<BuilderOutput>;
|
|
87
|
+
/**
|
|
88
|
+
* The progress report. A progress also contains an ID, which can be different than this run's
|
|
89
|
+
* ID (if the builder calls scheduleBuilder or scheduleTarget).
|
|
90
|
+
* This will always replay the last progress on new subscriptions.
|
|
91
|
+
*/
|
|
92
|
+
progress: Observable<BuilderProgressReport>;
|
|
93
|
+
/**
|
|
94
|
+
* Stop the builder from running. Returns a promise that resolves when the builder is stopped.
|
|
95
|
+
* Some builders might not handle stopping properly and should have a timeout here.
|
|
96
|
+
*/
|
|
97
|
+
stop(): Promise<void>;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Additional optional scheduling options.
|
|
101
|
+
*/
|
|
102
|
+
export interface ScheduleOptions {
|
|
103
|
+
/**
|
|
104
|
+
* Logger to pass to the builder. Note that messages will stop being forwarded, and if you want
|
|
105
|
+
* to log a builder scheduled from your builder you should forward log events yourself.
|
|
106
|
+
*/
|
|
107
|
+
logger?: logging.Logger;
|
|
108
|
+
/**
|
|
109
|
+
* Target to pass to the builder.
|
|
110
|
+
*/
|
|
111
|
+
target?: Target;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* The context received as a second argument in your builder.
|
|
115
|
+
*/
|
|
116
|
+
export interface BuilderContext {
|
|
117
|
+
/**
|
|
118
|
+
* Unique amongst contexts. Contexts instances are not guaranteed to be the same (but it could
|
|
119
|
+
* be the same context), and all the fields in a context could be the same, yet the builder's
|
|
120
|
+
* context could be different. This is the same ID as the corresponding run.
|
|
121
|
+
*/
|
|
122
|
+
id: number;
|
|
123
|
+
/**
|
|
124
|
+
* The builder info that called your function. Since the builder info is from the builder.json
|
|
125
|
+
* (or the host), it could contain information that is different than expected.
|
|
126
|
+
*/
|
|
127
|
+
builder: BuilderInfo;
|
|
128
|
+
/**
|
|
129
|
+
* A logger that appends messages to a log. This could be a separate interface or completely
|
|
130
|
+
* ignored. `console.log` could also be completely ignored.
|
|
131
|
+
*/
|
|
132
|
+
logger: logging.LoggerApi;
|
|
133
|
+
/**
|
|
134
|
+
* The absolute workspace root of this run. This is a system path and will not be normalized;
|
|
135
|
+
* ie. on Windows it will starts with `C:\\` (or whatever drive).
|
|
136
|
+
*/
|
|
137
|
+
workspaceRoot: string;
|
|
138
|
+
/**
|
|
139
|
+
* The current directory the user is in. This could be outside the workspace root. This is a
|
|
140
|
+
* system path and will not be normalized; ie. on Windows it will starts with `C:\\` (or
|
|
141
|
+
* whatever drive).
|
|
142
|
+
*/
|
|
143
|
+
currentDirectory: string;
|
|
144
|
+
/**
|
|
145
|
+
* The target that was used to run this builder.
|
|
146
|
+
* Target is optional if a builder was ran using `scheduleBuilder()`.
|
|
147
|
+
*/
|
|
148
|
+
target?: Target;
|
|
149
|
+
/**
|
|
150
|
+
* Schedule a target in the same workspace. This can be the same target that is being executed
|
|
151
|
+
* right now, but targets of the same name are serialized.
|
|
152
|
+
* Running the same target and waiting for it to end will result in a deadlocking scenario.
|
|
153
|
+
* Targets are considered the same if the project, the target AND the configuration are the same.
|
|
154
|
+
* @param target The target to schedule.
|
|
155
|
+
* @param overrides A set of options to override the workspace set of options.
|
|
156
|
+
* @param scheduleOptions Additional optional scheduling options.
|
|
157
|
+
* @return A promise of a run. It will resolve when all the members of the run are available.
|
|
158
|
+
*/
|
|
159
|
+
scheduleTarget(target: Target, overrides?: json.JsonObject, scheduleOptions?: ScheduleOptions): Promise<BuilderRun>;
|
|
160
|
+
/**
|
|
161
|
+
* Schedule a builder by its name. This can be the same builder that is being executed.
|
|
162
|
+
* @param builderName The name of the builder, ie. its `packageName:builderName` tuple.
|
|
163
|
+
* @param options All options to use for the builder (by default empty object). There is no
|
|
164
|
+
* additional options added, e.g. from the workspace.
|
|
165
|
+
* @param scheduleOptions Additional optional scheduling options.
|
|
166
|
+
* @return A promise of a run. It will resolve when all the members of the run are available.
|
|
167
|
+
*/
|
|
168
|
+
scheduleBuilder(builderName: string, options?: json.JsonObject, scheduleOptions?: ScheduleOptions): Promise<BuilderRun>;
|
|
169
|
+
/**
|
|
170
|
+
* Resolve and return options for a specified target. If the target isn't defined in the
|
|
171
|
+
* workspace this will reject the promise. This object will be read directly from the workspace
|
|
172
|
+
* but not validated against the builder of the target.
|
|
173
|
+
* @param target The target to resolve the options of.
|
|
174
|
+
* @return A non-validated object resolved from the workspace.
|
|
175
|
+
*/
|
|
176
|
+
getTargetOptions(target: Target): Promise<json.JsonObject>;
|
|
177
|
+
getProjectMetadata(projectName: string): Promise<json.JsonObject>;
|
|
178
|
+
getProjectMetadata(target: Target): Promise<json.JsonObject>;
|
|
179
|
+
/**
|
|
180
|
+
* Resolves and return a builder name. The exact format of the name is up to the host,
|
|
181
|
+
* so it should not be parsed to gather information (it's free form). This string can be
|
|
182
|
+
* used to validate options or schedule a builder directly.
|
|
183
|
+
* @param target The target to resolve the builder name.
|
|
184
|
+
*/
|
|
185
|
+
getBuilderNameForTarget(target: Target): Promise<string>;
|
|
186
|
+
/**
|
|
187
|
+
* Validates the options against a builder schema. This uses the same methods as the
|
|
188
|
+
* scheduleTarget and scheduleBrowser methods to validate and apply defaults to the options.
|
|
189
|
+
* It can be generically typed, if you know which interface it is supposed to validate against.
|
|
190
|
+
* @param options A generic option object to validate.
|
|
191
|
+
* @param builderName The name of a builder to use. This can be gotten for a target by using the
|
|
192
|
+
* getBuilderForTarget() method on the context.
|
|
193
|
+
*/
|
|
194
|
+
validateOptions<T extends json.JsonObject = json.JsonObject>(options: json.JsonObject, builderName: string): Promise<T>;
|
|
195
|
+
/**
|
|
196
|
+
* Set the builder to running. This should be used if an external event triggered a re-run,
|
|
197
|
+
* e.g. a file watched was changed.
|
|
198
|
+
*/
|
|
199
|
+
reportRunning(): void;
|
|
200
|
+
/**
|
|
201
|
+
* Update the status string shown on the interface.
|
|
202
|
+
* @param status The status to set it to. An empty string can be used to remove the status.
|
|
203
|
+
*/
|
|
204
|
+
reportStatus(status: string): void;
|
|
205
|
+
/**
|
|
206
|
+
* Update the progress for this builder run.
|
|
207
|
+
* @param current The current progress. This will be between 0 and total.
|
|
208
|
+
* @param total A new total to set. By default at the start of a run this is 1. If omitted it
|
|
209
|
+
* will use the same value as the last total.
|
|
210
|
+
* @param status Update the status string. If omitted the status string is not modified.
|
|
211
|
+
*/
|
|
212
|
+
reportProgress(current: number, total?: number, status?: string): void;
|
|
213
|
+
/**
|
|
214
|
+
* Add teardown logic to this Context, so that when it's being stopped it will execute teardown.
|
|
215
|
+
*/
|
|
216
|
+
addTeardown(teardown: () => Promise<void> | void): void;
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* An accepted return value from a builder. Can be either an Observable, a Promise or a vector.
|
|
220
|
+
*/
|
|
221
|
+
export type BuilderOutputLike = ObservableInput<BuilderOutput> | BuilderOutput;
|
|
222
|
+
export declare function isBuilderOutput(obj: any): obj is BuilderOutput;
|
|
223
|
+
export declare function fromAsyncIterable<T>(iterable: AsyncIterable<T>): Observable<T>;
|
|
224
|
+
/**
|
|
225
|
+
* A builder handler function. The function signature passed to `createBuilder()`.
|
|
226
|
+
*/
|
|
227
|
+
export interface BuilderHandlerFn<A> {
|
|
228
|
+
/**
|
|
229
|
+
* Builders are defined by users to perform any kind of task, like building, testing or linting,
|
|
230
|
+
* and should use this interface.
|
|
231
|
+
* @param input The options (a JsonObject), validated by the schema and received by the
|
|
232
|
+
* builder. This can include resolved options from the CLI or the workspace.
|
|
233
|
+
* @param context A context that can be used to interact with the Architect framework.
|
|
234
|
+
* @return One or many builder output.
|
|
235
|
+
*/
|
|
236
|
+
(input: A, context: BuilderContext): BuilderOutputLike;
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* A Builder general information. This is generated by the host and is expanded by the host, but
|
|
240
|
+
* the public API contains those fields.
|
|
241
|
+
*/
|
|
242
|
+
export type BuilderInfo = json.JsonObject & {
|
|
243
|
+
builderName: string;
|
|
244
|
+
description: string;
|
|
245
|
+
optionSchema: json.schema.JsonSchema;
|
|
246
|
+
};
|
|
247
|
+
/**
|
|
248
|
+
* Returns a string of "project:target[:configuration]" for the target object.
|
|
249
|
+
*/
|
|
250
|
+
export declare function targetStringFromTarget({ project, target, configuration }: Target): string;
|
|
251
|
+
/**
|
|
252
|
+
* Return a Target tuple from a specifier string.
|
|
253
|
+
* Supports abbreviated target specifiers (examples: `::`, `::development`, or `:build:production`).
|
|
254
|
+
*/
|
|
255
|
+
export declare function targetFromTargetString(specifier: string, abbreviatedProjectName?: string, abbreviatedTargetName?: string): Target;
|
|
256
|
+
/**
|
|
257
|
+
* Schedule a target, and forget about its run. This will return an observable of outputs, that
|
|
258
|
+
* as a teardown will stop the target from running. This means that the Run object this returns
|
|
259
|
+
* should not be shared.
|
|
260
|
+
*
|
|
261
|
+
* The reason this is not part of the Context interface is to keep the Context as normal form as
|
|
262
|
+
* possible. This is really an utility that people would implement in their project.
|
|
263
|
+
*
|
|
264
|
+
* @param context The context of your current execution.
|
|
265
|
+
* @param target The target to schedule.
|
|
266
|
+
* @param overrides Overrides that are used in the target.
|
|
267
|
+
* @param scheduleOptions Additional scheduling options.
|
|
268
|
+
*/
|
|
269
|
+
export declare function scheduleTargetAndForget(context: BuilderContext, target: Target, overrides?: json.JsonObject, scheduleOptions?: ScheduleOptions): Observable<BuilderOutput>;
|
package/src/api.js
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
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.dev/license
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.BuilderProgressState = void 0;
|
|
11
|
+
exports.isBuilderOutput = isBuilderOutput;
|
|
12
|
+
exports.fromAsyncIterable = fromAsyncIterable;
|
|
13
|
+
exports.targetStringFromTarget = targetStringFromTarget;
|
|
14
|
+
exports.targetFromTargetString = targetFromTargetString;
|
|
15
|
+
exports.scheduleTargetAndForget = scheduleTargetAndForget;
|
|
16
|
+
const rxjs_1 = require("rxjs");
|
|
17
|
+
const progress_schema_1 = require("./progress-schema");
|
|
18
|
+
Object.defineProperty(exports, "BuilderProgressState", { enumerable: true, get: function () { return progress_schema_1.State; } });
|
|
19
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
20
|
+
function isBuilderOutput(obj) {
|
|
21
|
+
if (!obj || typeof obj.then === 'function' || typeof obj.subscribe === 'function') {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
if (typeof obj[Symbol.asyncIterator] === 'function') {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
return typeof obj.success === 'boolean';
|
|
28
|
+
}
|
|
29
|
+
function fromAsyncIterable(iterable) {
|
|
30
|
+
return new rxjs_1.Observable((subscriber) => {
|
|
31
|
+
handleAsyncIterator(subscriber, iterable[Symbol.asyncIterator]()).then(() => subscriber.complete(), (error) => subscriber.error(error));
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
async function handleAsyncIterator(subscriber, iterator) {
|
|
35
|
+
const teardown = new Promise((resolve) => subscriber.add(() => resolve()));
|
|
36
|
+
try {
|
|
37
|
+
while (!subscriber.closed) {
|
|
38
|
+
const result = await Promise.race([teardown, iterator.next()]);
|
|
39
|
+
if (!result || result.done) {
|
|
40
|
+
break;
|
|
41
|
+
}
|
|
42
|
+
subscriber.next(result.value);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
finally {
|
|
46
|
+
await iterator.return?.();
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Returns a string of "project:target[:configuration]" for the target object.
|
|
51
|
+
*/
|
|
52
|
+
function targetStringFromTarget({ project, target, configuration }) {
|
|
53
|
+
return `${project}:${target}${configuration !== undefined ? ':' + configuration : ''}`;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Return a Target tuple from a specifier string.
|
|
57
|
+
* Supports abbreviated target specifiers (examples: `::`, `::development`, or `:build:production`).
|
|
58
|
+
*/
|
|
59
|
+
function targetFromTargetString(specifier, abbreviatedProjectName, abbreviatedTargetName) {
|
|
60
|
+
const tuple = specifier.split(':', 3);
|
|
61
|
+
if (tuple.length < 2) {
|
|
62
|
+
throw new Error('Invalid target string: ' + JSON.stringify(specifier));
|
|
63
|
+
}
|
|
64
|
+
return {
|
|
65
|
+
project: tuple[0] || abbreviatedProjectName || '',
|
|
66
|
+
target: tuple[1] || abbreviatedTargetName || '',
|
|
67
|
+
...(tuple[2] !== undefined && { configuration: tuple[2] }),
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Schedule a target, and forget about its run. This will return an observable of outputs, that
|
|
72
|
+
* as a teardown will stop the target from running. This means that the Run object this returns
|
|
73
|
+
* should not be shared.
|
|
74
|
+
*
|
|
75
|
+
* The reason this is not part of the Context interface is to keep the Context as normal form as
|
|
76
|
+
* possible. This is really an utility that people would implement in their project.
|
|
77
|
+
*
|
|
78
|
+
* @param context The context of your current execution.
|
|
79
|
+
* @param target The target to schedule.
|
|
80
|
+
* @param overrides Overrides that are used in the target.
|
|
81
|
+
* @param scheduleOptions Additional scheduling options.
|
|
82
|
+
*/
|
|
83
|
+
function scheduleTargetAndForget(context, target, overrides, scheduleOptions) {
|
|
84
|
+
let resolve = null;
|
|
85
|
+
const promise = new Promise((r) => (resolve = r));
|
|
86
|
+
context.addTeardown(() => promise);
|
|
87
|
+
return (0, rxjs_1.from)(context.scheduleTarget(target, overrides, scheduleOptions)).pipe((0, rxjs_1.switchMap)((run) => new rxjs_1.Observable((observer) => {
|
|
88
|
+
const subscription = run.output.subscribe(observer);
|
|
89
|
+
return () => {
|
|
90
|
+
subscription.unsubscribe();
|
|
91
|
+
// We can properly ignore the floating promise as it's a "reverse" promise; the teardown
|
|
92
|
+
// is waiting for the resolve.
|
|
93
|
+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
94
|
+
run.stop().then(resolve);
|
|
95
|
+
};
|
|
96
|
+
})));
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=api.js.map
|
package/src/api.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.js","sourceRoot":"","sources":["api.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,25 @@
|
|
|
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.dev/license
|
|
7
|
+
*/
|
|
8
|
+
import { json, logging } from '@angular-devkit/core';
|
|
9
|
+
import { Observable } from 'rxjs';
|
|
10
|
+
import { BuilderRun, Target } from './api';
|
|
11
|
+
import { ArchitectHost } from './internal';
|
|
12
|
+
import { JobName, Registry } from './jobs';
|
|
13
|
+
export interface ScheduleOptions {
|
|
14
|
+
logger?: logging.Logger;
|
|
15
|
+
}
|
|
16
|
+
export declare class Architect {
|
|
17
|
+
private _host;
|
|
18
|
+
private readonly _scheduler;
|
|
19
|
+
private readonly _jobCache;
|
|
20
|
+
private readonly _infoCache;
|
|
21
|
+
constructor(_host: ArchitectHost, registry?: json.schema.SchemaRegistry, additionalJobRegistry?: Registry);
|
|
22
|
+
has(name: JobName): Observable<boolean>;
|
|
23
|
+
scheduleBuilder(name: string, options: json.JsonObject, scheduleOptions?: ScheduleOptions): Promise<BuilderRun>;
|
|
24
|
+
scheduleTarget(target: Target, overrides?: json.JsonObject, scheduleOptions?: ScheduleOptions): Promise<BuilderRun>;
|
|
25
|
+
}
|
package/src/architect.js
ADDED
|
@@ -0,0 +1,268 @@
|
|
|
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.dev/license
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.Architect = void 0;
|
|
11
|
+
const core_1 = require("@angular-devkit/core");
|
|
12
|
+
const rxjs_1 = require("rxjs");
|
|
13
|
+
const api_1 = require("./api");
|
|
14
|
+
const jobs_1 = require("./jobs");
|
|
15
|
+
const options_1 = require("./options");
|
|
16
|
+
const schedule_by_name_1 = require("./schedule-by-name");
|
|
17
|
+
function _createJobHandlerFromBuilderInfo(info, target, host, registry, baseOptions) {
|
|
18
|
+
const jobDescription = {
|
|
19
|
+
name: target ? `{${(0, api_1.targetStringFromTarget)(target)}}` : info.builderName,
|
|
20
|
+
argument: true,
|
|
21
|
+
input: true,
|
|
22
|
+
output: true,
|
|
23
|
+
info,
|
|
24
|
+
};
|
|
25
|
+
function handler(argument, context) {
|
|
26
|
+
// Add input validation to the inbound bus.
|
|
27
|
+
const inboundBusWithInputValidation = context.inboundBus.pipe((0, rxjs_1.concatMap)(async (message) => {
|
|
28
|
+
if (message.kind === jobs_1.JobInboundMessageKind.Input) {
|
|
29
|
+
const v = message.value;
|
|
30
|
+
const options = (0, options_1.mergeOptions)(baseOptions, v.options);
|
|
31
|
+
// Validate v against the options schema.
|
|
32
|
+
const validation = await registry.compile(info.optionSchema);
|
|
33
|
+
const validationResult = await validation(options);
|
|
34
|
+
const { data, success, errors } = validationResult;
|
|
35
|
+
if (!success) {
|
|
36
|
+
throw new core_1.json.schema.SchemaValidationException(errors);
|
|
37
|
+
}
|
|
38
|
+
return { ...message, value: { ...v, options: data } };
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
return message;
|
|
42
|
+
}
|
|
43
|
+
}),
|
|
44
|
+
// Using a share replay because the job might be synchronously sending input, but
|
|
45
|
+
// asynchronously listening to it.
|
|
46
|
+
(0, rxjs_1.shareReplay)(1));
|
|
47
|
+
// Make an inboundBus that completes instead of erroring out.
|
|
48
|
+
// We'll merge the errors into the output instead.
|
|
49
|
+
const inboundBus = (0, rxjs_1.onErrorResumeNext)(inboundBusWithInputValidation);
|
|
50
|
+
const output = (0, rxjs_1.from)(host.loadBuilder(info)).pipe((0, rxjs_1.concatMap)((builder) => {
|
|
51
|
+
if (builder === null) {
|
|
52
|
+
throw new Error(`Cannot load builder for builderInfo ${JSON.stringify(info, null, 2)}`);
|
|
53
|
+
}
|
|
54
|
+
return builder.handler(argument, { ...context, inboundBus }).pipe((0, rxjs_1.map)((output) => {
|
|
55
|
+
if (output.kind === jobs_1.JobOutboundMessageKind.Output) {
|
|
56
|
+
// Add target to it.
|
|
57
|
+
return {
|
|
58
|
+
...output,
|
|
59
|
+
value: {
|
|
60
|
+
...output.value,
|
|
61
|
+
...(target ? { target } : 0),
|
|
62
|
+
},
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
return output;
|
|
67
|
+
}
|
|
68
|
+
}));
|
|
69
|
+
}),
|
|
70
|
+
// Share subscriptions to the output, otherwise the handler will be re-run.
|
|
71
|
+
(0, rxjs_1.shareReplay)());
|
|
72
|
+
// Separate the errors from the inbound bus into their own observable that completes when the
|
|
73
|
+
// builder output does.
|
|
74
|
+
const inboundBusErrors = inboundBusWithInputValidation.pipe((0, rxjs_1.ignoreElements)(), (0, rxjs_1.takeUntil)((0, rxjs_1.onErrorResumeNext)(output.pipe((0, rxjs_1.last)()))));
|
|
75
|
+
// Return the builder output plus any input errors.
|
|
76
|
+
return (0, rxjs_1.merge)(inboundBusErrors, output);
|
|
77
|
+
}
|
|
78
|
+
return (0, rxjs_1.of)(Object.assign(handler, { jobDescription }));
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* A JobRegistry that resolves builder targets from the host.
|
|
82
|
+
*/
|
|
83
|
+
class ArchitectBuilderJobRegistry {
|
|
84
|
+
_host;
|
|
85
|
+
_registry;
|
|
86
|
+
_jobCache;
|
|
87
|
+
_infoCache;
|
|
88
|
+
constructor(_host, _registry, _jobCache, _infoCache) {
|
|
89
|
+
this._host = _host;
|
|
90
|
+
this._registry = _registry;
|
|
91
|
+
this._jobCache = _jobCache;
|
|
92
|
+
this._infoCache = _infoCache;
|
|
93
|
+
}
|
|
94
|
+
_resolveBuilder(name) {
|
|
95
|
+
const cache = this._infoCache;
|
|
96
|
+
if (cache) {
|
|
97
|
+
const maybeCache = cache.get(name);
|
|
98
|
+
if (maybeCache !== undefined) {
|
|
99
|
+
return maybeCache;
|
|
100
|
+
}
|
|
101
|
+
const info = (0, rxjs_1.from)(this._host.resolveBuilder(name)).pipe((0, rxjs_1.shareReplay)(1));
|
|
102
|
+
cache.set(name, info);
|
|
103
|
+
return info;
|
|
104
|
+
}
|
|
105
|
+
return (0, rxjs_1.from)(this._host.resolveBuilder(name));
|
|
106
|
+
}
|
|
107
|
+
_createBuilder(info, target, options) {
|
|
108
|
+
const cache = this._jobCache;
|
|
109
|
+
if (target) {
|
|
110
|
+
const maybeHit = cache && cache.get((0, api_1.targetStringFromTarget)(target));
|
|
111
|
+
if (maybeHit) {
|
|
112
|
+
return maybeHit;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
const maybeHit = cache && cache.get(info.builderName);
|
|
117
|
+
if (maybeHit) {
|
|
118
|
+
return maybeHit;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
const result = _createJobHandlerFromBuilderInfo(info, target, this._host, this._registry, options || {});
|
|
122
|
+
if (cache) {
|
|
123
|
+
if (target) {
|
|
124
|
+
cache.set((0, api_1.targetStringFromTarget)(target), result.pipe((0, rxjs_1.shareReplay)(1)));
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
cache.set(info.builderName, result.pipe((0, rxjs_1.shareReplay)(1)));
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
return result;
|
|
131
|
+
}
|
|
132
|
+
get(name) {
|
|
133
|
+
const m = name.match(/^([^:]+):([^:]+)$/i);
|
|
134
|
+
if (!m) {
|
|
135
|
+
return (0, rxjs_1.of)(null);
|
|
136
|
+
}
|
|
137
|
+
return (0, rxjs_1.from)(this._resolveBuilder(name)).pipe((0, rxjs_1.concatMap)((builderInfo) => (builderInfo ? this._createBuilder(builderInfo) : (0, rxjs_1.of)(null))), (0, rxjs_1.first)(null, null));
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* A JobRegistry that resolves targets from the host.
|
|
142
|
+
*/
|
|
143
|
+
class ArchitectTargetJobRegistry extends ArchitectBuilderJobRegistry {
|
|
144
|
+
get(name) {
|
|
145
|
+
const m = name.match(/^{([^:]+):([^:]+)(?::([^:]*))?}$/i);
|
|
146
|
+
if (!m) {
|
|
147
|
+
return (0, rxjs_1.of)(null);
|
|
148
|
+
}
|
|
149
|
+
const target = {
|
|
150
|
+
project: m[1],
|
|
151
|
+
target: m[2],
|
|
152
|
+
configuration: m[3],
|
|
153
|
+
};
|
|
154
|
+
return (0, rxjs_1.from)(Promise.all([
|
|
155
|
+
this._host.getBuilderNameForTarget(target),
|
|
156
|
+
this._host.getOptionsForTarget(target),
|
|
157
|
+
])).pipe((0, rxjs_1.concatMap)(([builderStr, options]) => {
|
|
158
|
+
if (builderStr === null || options === null) {
|
|
159
|
+
return (0, rxjs_1.of)(null);
|
|
160
|
+
}
|
|
161
|
+
return this._resolveBuilder(builderStr).pipe((0, rxjs_1.concatMap)((builderInfo) => {
|
|
162
|
+
if (builderInfo === null) {
|
|
163
|
+
return (0, rxjs_1.of)(null);
|
|
164
|
+
}
|
|
165
|
+
return this._createBuilder(builderInfo, target, options);
|
|
166
|
+
}));
|
|
167
|
+
}), (0, rxjs_1.first)(null, null));
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
function _getTargetOptionsFactory(host) {
|
|
171
|
+
return (0, jobs_1.createJobHandler)((target) => {
|
|
172
|
+
return host.getOptionsForTarget(target).then((options) => {
|
|
173
|
+
if (options === null) {
|
|
174
|
+
throw new Error(`Invalid target: ${JSON.stringify(target)}.`);
|
|
175
|
+
}
|
|
176
|
+
return options;
|
|
177
|
+
});
|
|
178
|
+
}, {
|
|
179
|
+
name: '..getTargetOptions',
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
function _getProjectMetadataFactory(host) {
|
|
183
|
+
return (0, jobs_1.createJobHandler)((target) => {
|
|
184
|
+
return host.getProjectMetadata(target).then((options) => {
|
|
185
|
+
if (options === null) {
|
|
186
|
+
throw new Error(`Invalid target: ${JSON.stringify(target)}.`);
|
|
187
|
+
}
|
|
188
|
+
return options;
|
|
189
|
+
});
|
|
190
|
+
}, {
|
|
191
|
+
name: '..getProjectMetadata',
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
function _getBuilderNameForTargetFactory(host) {
|
|
195
|
+
return (0, jobs_1.createJobHandler)(async (target) => {
|
|
196
|
+
const builderName = await host.getBuilderNameForTarget(target);
|
|
197
|
+
if (!builderName) {
|
|
198
|
+
throw new Error(`No builder were found for target ${(0, api_1.targetStringFromTarget)(target)}.`);
|
|
199
|
+
}
|
|
200
|
+
return builderName;
|
|
201
|
+
}, {
|
|
202
|
+
name: '..getBuilderNameForTarget',
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
function _validateOptionsFactory(host, registry) {
|
|
206
|
+
return (0, jobs_1.createJobHandler)(async ([builderName, options]) => {
|
|
207
|
+
// Get option schema from the host.
|
|
208
|
+
const builderInfo = await host.resolveBuilder(builderName);
|
|
209
|
+
if (!builderInfo) {
|
|
210
|
+
throw new Error(`No builder info were found for builder ${JSON.stringify(builderName)}.`);
|
|
211
|
+
}
|
|
212
|
+
const validation = await registry.compile(builderInfo.optionSchema);
|
|
213
|
+
const { data, success, errors } = await validation(options);
|
|
214
|
+
if (!success) {
|
|
215
|
+
throw new core_1.json.schema.SchemaValidationException(errors);
|
|
216
|
+
}
|
|
217
|
+
return data;
|
|
218
|
+
}, {
|
|
219
|
+
name: '..validateOptions',
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
class Architect {
|
|
223
|
+
_host;
|
|
224
|
+
_scheduler;
|
|
225
|
+
_jobCache = new Map();
|
|
226
|
+
_infoCache = new Map();
|
|
227
|
+
constructor(_host, registry = new core_1.json.schema.CoreSchemaRegistry(), additionalJobRegistry) {
|
|
228
|
+
this._host = _host;
|
|
229
|
+
const privateArchitectJobRegistry = new jobs_1.SimpleJobRegistry();
|
|
230
|
+
// Create private jobs.
|
|
231
|
+
privateArchitectJobRegistry.register(_getTargetOptionsFactory(_host));
|
|
232
|
+
privateArchitectJobRegistry.register(_getBuilderNameForTargetFactory(_host));
|
|
233
|
+
privateArchitectJobRegistry.register(_validateOptionsFactory(_host, registry));
|
|
234
|
+
privateArchitectJobRegistry.register(_getProjectMetadataFactory(_host));
|
|
235
|
+
const jobRegistry = new jobs_1.FallbackRegistry([
|
|
236
|
+
new ArchitectTargetJobRegistry(_host, registry, this._jobCache, this._infoCache),
|
|
237
|
+
new ArchitectBuilderJobRegistry(_host, registry, this._jobCache, this._infoCache),
|
|
238
|
+
privateArchitectJobRegistry,
|
|
239
|
+
...(additionalJobRegistry ? [additionalJobRegistry] : []),
|
|
240
|
+
]);
|
|
241
|
+
this._scheduler = new jobs_1.SimpleScheduler(jobRegistry, registry);
|
|
242
|
+
}
|
|
243
|
+
has(name) {
|
|
244
|
+
return this._scheduler.has(name);
|
|
245
|
+
}
|
|
246
|
+
scheduleBuilder(name, options, scheduleOptions = {}) {
|
|
247
|
+
// The below will match 'project:target:configuration'
|
|
248
|
+
if (!/^[^:]+:[^:]+(:[^:]+)?$/.test(name)) {
|
|
249
|
+
throw new Error('Invalid builder name: ' + JSON.stringify(name));
|
|
250
|
+
}
|
|
251
|
+
return (0, schedule_by_name_1.scheduleByName)(name, options, {
|
|
252
|
+
scheduler: this._scheduler,
|
|
253
|
+
logger: scheduleOptions.logger || new core_1.logging.NullLogger(),
|
|
254
|
+
currentDirectory: this._host.getCurrentDirectory(),
|
|
255
|
+
workspaceRoot: this._host.getWorkspaceRoot(),
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
scheduleTarget(target, overrides = {}, scheduleOptions = {}) {
|
|
259
|
+
return (0, schedule_by_name_1.scheduleByTarget)(target, overrides, {
|
|
260
|
+
scheduler: this._scheduler,
|
|
261
|
+
logger: scheduleOptions.logger || new core_1.logging.NullLogger(),
|
|
262
|
+
currentDirectory: this._host.getCurrentDirectory(),
|
|
263
|
+
workspaceRoot: this._host.getWorkspaceRoot(),
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
exports.Architect = Architect;
|
|
268
|
+
//# sourceMappingURL=architect.js.map
|