@wpkernel/pipeline 0.12.1-beta.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 +287 -0
- package/README.md +110 -0
- package/dist/async-utils.d.ts +51 -0
- package/dist/async-utils.d.ts.map +1 -0
- package/dist/async-utils.js +39 -0
- package/dist/createExtension.d.ts +164 -0
- package/dist/createExtension.d.ts.map +1 -0
- package/dist/createExtension.js +23 -0
- package/dist/createPipeline.d.ts +205 -0
- package/dist/createPipeline.d.ts.map +1 -0
- package/dist/createPipeline.js +447 -0
- package/dist/dependency-graph.d.ts +80 -0
- package/dist/dependency-graph.d.ts.map +1 -0
- package/dist/dependency-graph.js +105 -0
- package/dist/error-factory.d.ts +46 -0
- package/dist/error-factory.d.ts.map +1 -0
- package/dist/error-factory.js +15 -0
- package/dist/executor.d.ts +24 -0
- package/dist/executor.d.ts.map +1 -0
- package/dist/executor.js +40 -0
- package/dist/extensions.d.ts +83 -0
- package/dist/extensions.d.ts.map +1 -0
- package/dist/extensions.js +88 -0
- package/dist/helper.d.ts +134 -0
- package/dist/helper.d.ts.map +1 -0
- package/dist/helper.js +29 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +31 -0
- package/dist/registration.d.ts +44 -0
- package/dist/registration.d.ts.map +1 -0
- package/dist/registration.js +50 -0
- package/dist/types.d.ts +332 -0
- package/dist/types.d.ts.map +1 -0
- package/package.json +41 -0
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import { CreatePipelineOptions, Helper, HelperKind, Pipeline, PipelineDiagnostic, PipelineReporter, PipelineRunState } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Creates a pipeline orchestrator-the execution engine that powers WPKernel's entire code generation infrastructure.
|
|
4
|
+
*
|
|
5
|
+
* ## Why Pipelines Matter
|
|
6
|
+
*
|
|
7
|
+
* The pipeline system is the **single most critical component** of the framework:
|
|
8
|
+
*
|
|
9
|
+
* - **CLI package**: Every generator (`wpk generate resource`, `wpk generate action`, etc.) runs on pipeline
|
|
10
|
+
* - **PHP Driver**: All PHP AST transformations flow through pipeline helpers
|
|
11
|
+
* - **Core package**: Resource definitions, action middleware, and capability proxies leverage pipeline
|
|
12
|
+
* - **Future-proof**: Designed to extract into standalone `@wpkernel/pipeline` package
|
|
13
|
+
*
|
|
14
|
+
* Pipelines provide:
|
|
15
|
+
* 1. **Dependency resolution**: Topologically sorts helpers based on `dependsOn` declarations
|
|
16
|
+
* 2. **Priority ordering**: Executes helpers in deterministic order via priority values
|
|
17
|
+
* 3. **Error recovery**: Automatic rollback on failure via commit/rollback protocol
|
|
18
|
+
* 4. **Diagnostics**: Built-in error tracking with reporter integration
|
|
19
|
+
* 5. **Extensibility**: Plugin-style extensions via hooks (pre-run, post-build, etc.)
|
|
20
|
+
*
|
|
21
|
+
* ## Architecture
|
|
22
|
+
*
|
|
23
|
+
* A pipeline consists of three phases:
|
|
24
|
+
*
|
|
25
|
+
* ### 1. Registration Phase
|
|
26
|
+
* ```
|
|
27
|
+
* pipeline.registerFragment(helper1)
|
|
28
|
+
* pipeline.registerBuilder(helper2)
|
|
29
|
+
* ```
|
|
30
|
+
* Helpers are collected but not executed. Dependency graph is constructed.
|
|
31
|
+
*
|
|
32
|
+
* ### 2. Execution Phase
|
|
33
|
+
* ```
|
|
34
|
+
* const result = await pipeline.run(options)
|
|
35
|
+
* ```
|
|
36
|
+
* - Validates dependency graph (detects missing deps, cycles)
|
|
37
|
+
* - Sorts helpers topologically
|
|
38
|
+
* - Runs fragment helpers to transform AST
|
|
39
|
+
* - Runs builder helpers to produce artifacts
|
|
40
|
+
* - Commits successful results
|
|
41
|
+
*
|
|
42
|
+
* ### 3. Rollback Phase (on error)
|
|
43
|
+
* ```
|
|
44
|
+
* // Automatic on failure
|
|
45
|
+
* ```
|
|
46
|
+
* - Walks back through executed helpers in reverse order
|
|
47
|
+
* - Invokes rollback functions to undo side effects
|
|
48
|
+
* - Aggregates diagnostics for debugging
|
|
49
|
+
*
|
|
50
|
+
* ## Extension System
|
|
51
|
+
*
|
|
52
|
+
* Pipelines support hooks that intercept execution at key points:
|
|
53
|
+
*
|
|
54
|
+
* - `pre-run`: Before any helpers execute (validation, setup)
|
|
55
|
+
* - `post-fragment`: After fragment helpers complete (AST inspection)
|
|
56
|
+
* - `post-builder`: After builder helpers complete (artifact transformation)
|
|
57
|
+
* - `pre-commit`: Before committing results (final validation)
|
|
58
|
+
*
|
|
59
|
+
* Extensions enable:
|
|
60
|
+
* - Custom validation logic
|
|
61
|
+
* - Third-party integrations (ESLint, Prettier, type checkers)
|
|
62
|
+
* - Conditional execution (feature flags, environment checks)
|
|
63
|
+
* - Artifact post-processing (minification, bundling)
|
|
64
|
+
*
|
|
65
|
+
* ## Type Safety
|
|
66
|
+
*
|
|
67
|
+
* The pipeline is fully generic across 16 type parameters, enabling:
|
|
68
|
+
* - Type-safe context sharing between helpers
|
|
69
|
+
* - Strongly-typed input/output contracts
|
|
70
|
+
* - Custom reporter integration (LogLayer, console, etc.)
|
|
71
|
+
* - Flexible artifact types (strings, AST nodes, binary data)
|
|
72
|
+
*
|
|
73
|
+
* ## Performance
|
|
74
|
+
*
|
|
75
|
+
* - **Lazy execution**: Helpers only run when `pipeline.run()` is called
|
|
76
|
+
* - **Incremental registration**: Add helpers at any time before execution
|
|
77
|
+
* - **Async support**: Mix sync and async helpers seamlessly
|
|
78
|
+
* - **Memory efficiency**: Helpers are immutable descriptors (no closures)
|
|
79
|
+
*
|
|
80
|
+
* @param options
|
|
81
|
+
* @category Pipeline
|
|
82
|
+
*
|
|
83
|
+
* @example Basic pipeline setup
|
|
84
|
+
* ```typescript
|
|
85
|
+
* import { createPipeline, createHelper } from '@wpkernel/core/pipeline';
|
|
86
|
+
* import { createReporter } from '@wpkernel/core';
|
|
87
|
+
*
|
|
88
|
+
* interface MyContext {
|
|
89
|
+
* reporter: ReturnType<typeof createReporter>;
|
|
90
|
+
* namespace: string;
|
|
91
|
+
* }
|
|
92
|
+
*
|
|
93
|
+
* const pipeline = createPipeline({
|
|
94
|
+
* fragmentKind: 'fragment',
|
|
95
|
+
* builderKind: 'builder',
|
|
96
|
+
*
|
|
97
|
+
* createContext: (reporter) => ({
|
|
98
|
+
* reporter,
|
|
99
|
+
* namespace: 'MyPlugin',
|
|
100
|
+
* }),
|
|
101
|
+
*
|
|
102
|
+
* buildFragment: (ctx, opts) => {
|
|
103
|
+
* // Transform AST node
|
|
104
|
+
* const fragment = opts.input;
|
|
105
|
+
* fragment.namespace = ctx.namespace;
|
|
106
|
+
* return { fragment };
|
|
107
|
+
* },
|
|
108
|
+
*
|
|
109
|
+
* buildArtifact: (ctx, opts) => {
|
|
110
|
+
* // Generate final PHP code
|
|
111
|
+
* const code = opts.draft.toString();
|
|
112
|
+
* return { artifact: code };
|
|
113
|
+
* },
|
|
114
|
+
* });
|
|
115
|
+
*
|
|
116
|
+
* // Register helpers
|
|
117
|
+
* pipeline.registerFragment(addPHPTagHelper);
|
|
118
|
+
* pipeline.registerFragment(addNamespaceHelper);
|
|
119
|
+
* pipeline.registerBuilder(writeFileHelper);
|
|
120
|
+
*
|
|
121
|
+
* // Execute
|
|
122
|
+
* const result = await pipeline.run({ input: myAST });
|
|
123
|
+
* console.log(result.artifact); // Generated PHP code
|
|
124
|
+
* ```
|
|
125
|
+
*
|
|
126
|
+
* @example Pipeline with extensions
|
|
127
|
+
* ```typescript
|
|
128
|
+
* const pipeline = createPipeline({
|
|
129
|
+
* // ... base config ...
|
|
130
|
+
*
|
|
131
|
+
* extensions: [
|
|
132
|
+
* {
|
|
133
|
+
* key: 'eslint-validation',
|
|
134
|
+
* hooks: {
|
|
135
|
+
* 'post-builder': async ({ artifact, context }) => {
|
|
136
|
+
* const lintResult = await eslint.lintText(artifact);
|
|
137
|
+
* if (lintResult.errorCount > 0) {
|
|
138
|
+
* throw new Error('Linting failed');
|
|
139
|
+
* }
|
|
140
|
+
* return { artifact };
|
|
141
|
+
* },
|
|
142
|
+
* },
|
|
143
|
+
* },
|
|
144
|
+
* ],
|
|
145
|
+
* });
|
|
146
|
+
* ```
|
|
147
|
+
*
|
|
148
|
+
* @example Error handling with rollback
|
|
149
|
+
* ```typescript
|
|
150
|
+
* const result = await pipeline.run({ input: myAST });
|
|
151
|
+
*
|
|
152
|
+
* if (!result.success) {
|
|
153
|
+
* console.error('Pipeline failed:', result.diagnostics);
|
|
154
|
+
* // Rollback already executed automatically
|
|
155
|
+
* // Files restored, temp resources cleaned up
|
|
156
|
+
* } else {
|
|
157
|
+
* console.log('Success:', result.artifact);
|
|
158
|
+
* // All commit functions executed
|
|
159
|
+
* }
|
|
160
|
+
* ```
|
|
161
|
+
*
|
|
162
|
+
* @example Real-world CLI usage
|
|
163
|
+
* ```typescript
|
|
164
|
+
* // This is how `wpk generate resource` works internally:
|
|
165
|
+
*
|
|
166
|
+
* const resourcePipeline = createPipeline({
|
|
167
|
+
* fragmentKind: 'fragment',
|
|
168
|
+
* builderKind: 'builder',
|
|
169
|
+
* createContext: (reporter) => ({
|
|
170
|
+
* reporter,
|
|
171
|
+
* config: loadKernelConfig(),
|
|
172
|
+
* }),
|
|
173
|
+
* buildFragment: (ctx, opts) => {
|
|
174
|
+
* // Build PHP AST for resource class
|
|
175
|
+
* return buildResourceClass(opts.input, ctx.config);
|
|
176
|
+
* },
|
|
177
|
+
* buildArtifact: async (ctx, opts) => {
|
|
178
|
+
* // Convert AST to PHP code
|
|
179
|
+
* const code = await printPhpAst(opts.draft);
|
|
180
|
+
* return { artifact: code };
|
|
181
|
+
* },
|
|
182
|
+
* });
|
|
183
|
+
*
|
|
184
|
+
* // Register standard helpers
|
|
185
|
+
* resourcePipeline.registerFragment(phpOpeningTagHelper);
|
|
186
|
+
* resourcePipeline.registerFragment(namespaceHelper);
|
|
187
|
+
* resourcePipeline.registerFragment(useStatementsHelper);
|
|
188
|
+
* resourcePipeline.registerFragment(classDefinitionHelper);
|
|
189
|
+
* resourcePipeline.registerBuilder(writeFileHelper);
|
|
190
|
+
* resourcePipeline.registerBuilder(formatCodeHelper);
|
|
191
|
+
*
|
|
192
|
+
* // User can inject custom helpers via config
|
|
193
|
+
* const userHelpers = loadUserHelpers();
|
|
194
|
+
* userHelpers.forEach(h => resourcePipeline.registerFragment(h));
|
|
195
|
+
*
|
|
196
|
+
* // Execute generation
|
|
197
|
+
* const result = await resourcePipeline.run({
|
|
198
|
+
* input: { name: 'Post', endpoint: '/posts' }
|
|
199
|
+
* });
|
|
200
|
+
* ```
|
|
201
|
+
*/
|
|
202
|
+
export declare function createPipeline<TRunOptions, TBuildOptions, TContext extends {
|
|
203
|
+
reporter: TReporter;
|
|
204
|
+
}, TReporter extends PipelineReporter = PipelineReporter, TDraft = unknown, TArtifact = unknown, TDiagnostic extends PipelineDiagnostic = PipelineDiagnostic, TRunResult = PipelineRunState<TArtifact, TDiagnostic>, TFragmentInput = unknown, TFragmentOutput = unknown, TBuilderInput = unknown, TBuilderOutput = unknown, TFragmentKind extends HelperKind = 'fragment', TBuilderKind extends HelperKind = 'builder', TFragmentHelper extends Helper<TContext, TFragmentInput, TFragmentOutput, TReporter, TFragmentKind> = Helper<TContext, TFragmentInput, TFragmentOutput, TReporter, TFragmentKind>, TBuilderHelper extends Helper<TContext, TBuilderInput, TBuilderOutput, TReporter, TBuilderKind> = Helper<TContext, TBuilderInput, TBuilderOutput, TReporter, TBuilderKind>>(options: CreatePipelineOptions<TRunOptions, TBuildOptions, TContext, TReporter, TDraft, TArtifact, TDiagnostic, TRunResult, TFragmentInput, TFragmentOutput, TBuilderInput, TBuilderOutput, TFragmentKind, TBuilderKind, TFragmentHelper, TBuilderHelper>): Pipeline<TRunOptions, TRunResult, TContext, TReporter, TBuildOptions, TArtifact, TFragmentInput, TFragmentOutput, TBuilderInput, TBuilderOutput, TDiagnostic, TFragmentKind, TBuilderKind, TFragmentHelper, TBuilderHelper>;
|
|
205
|
+
//# sourceMappingURL=createPipeline.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createPipeline.d.ts","sourceRoot":"","sources":["../src/createPipeline.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EACX,qBAAqB,EACrB,MAAM,EAEN,UAAU,EAGV,QAAQ,EACR,kBAAkB,EAClB,gBAAgB,EAMhB,gBAAgB,EAEhB,MAAM,SAAS,CAAC;AAEjB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuMG;AACH,wBAAgB,cAAc,CAC7B,WAAW,EACX,aAAa,EACb,QAAQ,SAAS;IAAE,QAAQ,EAAE,SAAS,CAAA;CAAE,EACxC,SAAS,SAAS,gBAAgB,GAAG,gBAAgB,EACrD,MAAM,GAAG,OAAO,EAChB,SAAS,GAAG,OAAO,EACnB,WAAW,SAAS,kBAAkB,GAAG,kBAAkB,EAC3D,UAAU,GAAG,gBAAgB,CAAC,SAAS,EAAE,WAAW,CAAC,EACrD,cAAc,GAAG,OAAO,EACxB,eAAe,GAAG,OAAO,EACzB,aAAa,GAAG,OAAO,EACvB,cAAc,GAAG,OAAO,EACxB,aAAa,SAAS,UAAU,GAAG,UAAU,EAC7C,YAAY,SAAS,UAAU,GAAG,SAAS,EAC3C,eAAe,SAAS,MAAM,CAC7B,QAAQ,EACR,cAAc,EACd,eAAe,EACf,SAAS,EACT,aAAa,CACb,GAAG,MAAM,CACT,QAAQ,EACR,cAAc,EACd,eAAe,EACf,SAAS,EACT,aAAa,CACb,EACD,cAAc,SAAS,MAAM,CAC5B,QAAQ,EACR,aAAa,EACb,cAAc,EACd,SAAS,EACT,YAAY,CACZ,GAAG,MAAM,CACT,QAAQ,EACR,aAAa,EACb,cAAc,EACd,SAAS,EACT,YAAY,CACZ,EAED,OAAO,EAAE,qBAAqB,CAC7B,WAAW,EACX,aAAa,EACb,QAAQ,EACR,SAAS,EACT,MAAM,EACN,SAAS,EACT,WAAW,EACX,UAAU,EACV,cAAc,EACd,eAAe,EACf,aAAa,EACb,cAAc,EACd,aAAa,EACb,YAAY,EACZ,eAAe,EACf,cAAc,CACd,GACC,QAAQ,CACV,WAAW,EACX,UAAU,EACV,QAAQ,EACR,SAAS,EACT,aAAa,EACb,SAAS,EACT,cAAc,EACd,eAAe,EACf,aAAa,EACb,cAAc,EACd,WAAW,EACX,aAAa,EACb,YAAY,EACZ,eAAe,EACf,cAAc,CACd,CAywBA"}
|
|
@@ -0,0 +1,447 @@
|
|
|
1
|
+
import { maybeThen as M, maybeTry as Q } from "./async-utils.js";
|
|
2
|
+
import { createDependencyGraph as X } from "./dependency-graph.js";
|
|
3
|
+
import { runExtensionHooks as ie, rollbackExtensionResults as ce, commitExtensionResults as ae, createRollbackErrorMetadata as Y } from "./extensions.js";
|
|
4
|
+
import { executeHelpers as Z } from "./executor.js";
|
|
5
|
+
import { registerHelper as _, handleExtensionRegisterResult as ue } from "./registration.js";
|
|
6
|
+
/**
|
|
7
|
+
* @wpkernel/pipeline
|
|
8
|
+
* @license EUPL-1.2
|
|
9
|
+
*/
|
|
10
|
+
function ye(c) {
|
|
11
|
+
const b = c.fragmentKind ?? "fragment", m = c.builderKind ?? "builder", h = c.createError ?? ((e, n) => new Error(`[${e}] ${n}`)), E = [], y = [], S = [], G = /* @__PURE__ */ new WeakMap();
|
|
12
|
+
let H;
|
|
13
|
+
const v = [], l = b, p = m;
|
|
14
|
+
function C(e, n) {
|
|
15
|
+
return e === l ? `Fragment helper "${n.key}"` : e === p ? `Builder helper "${n.key}"` : `Helper "${n.key}"`;
|
|
16
|
+
}
|
|
17
|
+
function P(e, n, t, r) {
|
|
18
|
+
const a = c.createConflictDiagnostic?.({
|
|
19
|
+
helper: e,
|
|
20
|
+
existing: n,
|
|
21
|
+
message: r
|
|
22
|
+
}) ?? {
|
|
23
|
+
type: "conflict",
|
|
24
|
+
key: e.key,
|
|
25
|
+
mode: e.mode,
|
|
26
|
+
helpers: [
|
|
27
|
+
n.origin ?? n.key,
|
|
28
|
+
e.origin ?? e.key
|
|
29
|
+
],
|
|
30
|
+
message: r,
|
|
31
|
+
kind: t
|
|
32
|
+
};
|
|
33
|
+
O(a);
|
|
34
|
+
}
|
|
35
|
+
function q(e, n, t) {
|
|
36
|
+
const r = `${C(t, e)} depends on unknown helper "${n}".`, a = c.createMissingDependencyDiagnostic?.({
|
|
37
|
+
helper: e,
|
|
38
|
+
dependency: n,
|
|
39
|
+
message: r
|
|
40
|
+
}) ?? {
|
|
41
|
+
type: "missing-dependency",
|
|
42
|
+
key: e.key,
|
|
43
|
+
dependency: n,
|
|
44
|
+
message: r,
|
|
45
|
+
kind: t,
|
|
46
|
+
helper: e.origin ?? e.key
|
|
47
|
+
};
|
|
48
|
+
O(a);
|
|
49
|
+
}
|
|
50
|
+
function D(e, n, t, r) {
|
|
51
|
+
const a = `${C(n, e)} ${t}.`, u = c.createUnusedHelperDiagnostic?.({
|
|
52
|
+
helper: e,
|
|
53
|
+
message: a
|
|
54
|
+
}) ?? {
|
|
55
|
+
type: "unused-helper",
|
|
56
|
+
key: e.key,
|
|
57
|
+
message: a,
|
|
58
|
+
kind: n,
|
|
59
|
+
helper: e.origin ?? e.key,
|
|
60
|
+
dependsOn: r
|
|
61
|
+
};
|
|
62
|
+
O(u);
|
|
63
|
+
}
|
|
64
|
+
function T(e) {
|
|
65
|
+
if (!H || !c.onDiagnostic)
|
|
66
|
+
return;
|
|
67
|
+
const n = G.get(H);
|
|
68
|
+
if (n?.has(e))
|
|
69
|
+
return;
|
|
70
|
+
const t = n ?? /* @__PURE__ */ new Set();
|
|
71
|
+
c.onDiagnostic({
|
|
72
|
+
reporter: H,
|
|
73
|
+
diagnostic: e
|
|
74
|
+
}), t.add(e), n || G.set(H, t);
|
|
75
|
+
}
|
|
76
|
+
function O(e) {
|
|
77
|
+
S.push(e), T(e);
|
|
78
|
+
}
|
|
79
|
+
function W(e, n, t) {
|
|
80
|
+
for (const r of e)
|
|
81
|
+
n.has(r.id) || D(
|
|
82
|
+
r.helper,
|
|
83
|
+
t,
|
|
84
|
+
"was registered but never executed",
|
|
85
|
+
r.helper.dependsOn
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
function A(e, n, t) {
|
|
89
|
+
const r = [], a = [], u = [];
|
|
90
|
+
for (const k of e) {
|
|
91
|
+
const f = k.helper.key;
|
|
92
|
+
r.push(f), n.has(k.id) ? a.push(f) : u.push(f);
|
|
93
|
+
}
|
|
94
|
+
return {
|
|
95
|
+
kind: t,
|
|
96
|
+
registered: r,
|
|
97
|
+
executed: a,
|
|
98
|
+
missing: u
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
function j(e, n, t) {
|
|
102
|
+
if (n.missing.length === 0)
|
|
103
|
+
return;
|
|
104
|
+
const r = e.filter(
|
|
105
|
+
(u) => n.missing.includes(u.helper.key) && !u.helper.optional
|
|
106
|
+
);
|
|
107
|
+
if (r.length === 0)
|
|
108
|
+
return;
|
|
109
|
+
const a = r.map(
|
|
110
|
+
(u) => C(t, u.helper)
|
|
111
|
+
);
|
|
112
|
+
throw h(
|
|
113
|
+
"ValidationError",
|
|
114
|
+
`Pipeline finalisation aborted because ${a.join(", ")} did not execute.`
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
const N = (e) => _(
|
|
118
|
+
e,
|
|
119
|
+
b,
|
|
120
|
+
E,
|
|
121
|
+
l,
|
|
122
|
+
(n, t, r) => P(
|
|
123
|
+
n,
|
|
124
|
+
t,
|
|
125
|
+
l,
|
|
126
|
+
r
|
|
127
|
+
),
|
|
128
|
+
h
|
|
129
|
+
), I = (e) => _(
|
|
130
|
+
e,
|
|
131
|
+
m,
|
|
132
|
+
y,
|
|
133
|
+
p,
|
|
134
|
+
(n, t, r) => P(
|
|
135
|
+
n,
|
|
136
|
+
t,
|
|
137
|
+
p,
|
|
138
|
+
r
|
|
139
|
+
),
|
|
140
|
+
h
|
|
141
|
+
), J = (e, n) => ue(e, n, v);
|
|
142
|
+
function ee(e) {
|
|
143
|
+
const n = c.createBuildOptions(e), t = c.createContext(e);
|
|
144
|
+
H = t.reporter;
|
|
145
|
+
for (const o of S)
|
|
146
|
+
T(o);
|
|
147
|
+
const r = c.createFragmentState({
|
|
148
|
+
options: e,
|
|
149
|
+
context: t,
|
|
150
|
+
buildOptions: n
|
|
151
|
+
}), a = X(
|
|
152
|
+
E,
|
|
153
|
+
{
|
|
154
|
+
onMissingDependency: ({ dependant: o, dependencyKey: i }) => {
|
|
155
|
+
const s = o.helper;
|
|
156
|
+
q(
|
|
157
|
+
s,
|
|
158
|
+
i,
|
|
159
|
+
l
|
|
160
|
+
), D(
|
|
161
|
+
s,
|
|
162
|
+
l,
|
|
163
|
+
`could not execute because dependency "${i}" was not found`,
|
|
164
|
+
s.dependsOn
|
|
165
|
+
);
|
|
166
|
+
},
|
|
167
|
+
onUnresolvedHelpers: ({ unresolved: o }) => {
|
|
168
|
+
for (const i of o) {
|
|
169
|
+
const s = i.helper;
|
|
170
|
+
D(
|
|
171
|
+
s,
|
|
172
|
+
l,
|
|
173
|
+
"could not execute because its dependencies never resolved",
|
|
174
|
+
s.dependsOn
|
|
175
|
+
);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
},
|
|
179
|
+
h
|
|
180
|
+
).order, u = [], k = (o) => {
|
|
181
|
+
const i = o.helper;
|
|
182
|
+
u.push({
|
|
183
|
+
id: o.id,
|
|
184
|
+
index: u.length,
|
|
185
|
+
key: i.key,
|
|
186
|
+
kind: i.kind,
|
|
187
|
+
mode: i.mode,
|
|
188
|
+
priority: i.priority,
|
|
189
|
+
dependsOn: i.dependsOn,
|
|
190
|
+
origin: i.origin
|
|
191
|
+
});
|
|
192
|
+
}, f = {
|
|
193
|
+
onMissingDependency: ({ dependant: o, dependencyKey: i }) => {
|
|
194
|
+
const s = o.helper;
|
|
195
|
+
q(
|
|
196
|
+
s,
|
|
197
|
+
i,
|
|
198
|
+
p
|
|
199
|
+
), D(
|
|
200
|
+
s,
|
|
201
|
+
p,
|
|
202
|
+
`could not execute because dependency "${i}" was not found`,
|
|
203
|
+
s.dependsOn
|
|
204
|
+
);
|
|
205
|
+
},
|
|
206
|
+
onUnresolvedHelpers: ({ unresolved: o }) => {
|
|
207
|
+
for (const i of o) {
|
|
208
|
+
const s = i.helper;
|
|
209
|
+
D(
|
|
210
|
+
s,
|
|
211
|
+
p,
|
|
212
|
+
"could not execute because its dependencies never resolved",
|
|
213
|
+
s.dependsOn
|
|
214
|
+
);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}, K = c.createExtensionHookOptions ?? ((o) => ({
|
|
218
|
+
context: o.context,
|
|
219
|
+
options: o.options,
|
|
220
|
+
artifact: o.artifact
|
|
221
|
+
})), U = (o) => K({
|
|
222
|
+
context: t,
|
|
223
|
+
options: e,
|
|
224
|
+
buildOptions: n,
|
|
225
|
+
artifact: o
|
|
226
|
+
}), $ = c.onExtensionRollbackError ?? ((o) => {
|
|
227
|
+
const { reporter: i } = o.context, s = i.warn;
|
|
228
|
+
typeof s == "function" && s.call(i, "Pipeline extension rollback failed.", {
|
|
229
|
+
error: o.error,
|
|
230
|
+
errorName: o.errorMetadata.name,
|
|
231
|
+
errorMessage: o.errorMetadata.message,
|
|
232
|
+
errorStack: o.errorMetadata.stack,
|
|
233
|
+
errorCause: o.errorMetadata.cause,
|
|
234
|
+
extensions: o.extensionKeys,
|
|
235
|
+
hookKeys: o.hookSequence
|
|
236
|
+
});
|
|
237
|
+
});
|
|
238
|
+
return {
|
|
239
|
+
runOptions: e,
|
|
240
|
+
buildOptions: n,
|
|
241
|
+
context: t,
|
|
242
|
+
draft: r,
|
|
243
|
+
fragmentOrder: a,
|
|
244
|
+
steps: u,
|
|
245
|
+
pushStep: k,
|
|
246
|
+
builderGraphOptions: f,
|
|
247
|
+
createHookOptions: U,
|
|
248
|
+
handleRollbackError: $
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
const ne = c.createRunResult ?? ((e) => ({
|
|
252
|
+
artifact: e.artifact,
|
|
253
|
+
diagnostics: e.diagnostics,
|
|
254
|
+
steps: e.steps
|
|
255
|
+
}));
|
|
256
|
+
function te(e) {
|
|
257
|
+
const {
|
|
258
|
+
runOptions: n,
|
|
259
|
+
buildOptions: t,
|
|
260
|
+
context: r,
|
|
261
|
+
draft: a,
|
|
262
|
+
fragmentOrder: u,
|
|
263
|
+
steps: k,
|
|
264
|
+
pushStep: f,
|
|
265
|
+
builderGraphOptions: K,
|
|
266
|
+
createHookOptions: U,
|
|
267
|
+
handleRollbackError: $
|
|
268
|
+
} = e;
|
|
269
|
+
let o = A(
|
|
270
|
+
y,
|
|
271
|
+
/* @__PURE__ */ new Set(),
|
|
272
|
+
m
|
|
273
|
+
);
|
|
274
|
+
const i = Z(
|
|
275
|
+
u,
|
|
276
|
+
(s) => c.createFragmentArgs({
|
|
277
|
+
helper: s.helper,
|
|
278
|
+
options: n,
|
|
279
|
+
context: r,
|
|
280
|
+
buildOptions: t,
|
|
281
|
+
draft: a
|
|
282
|
+
}),
|
|
283
|
+
(s, F, x) => s.apply(F, x),
|
|
284
|
+
(s) => f(s)
|
|
285
|
+
);
|
|
286
|
+
return M(i, (s) => {
|
|
287
|
+
W(
|
|
288
|
+
E,
|
|
289
|
+
s,
|
|
290
|
+
l
|
|
291
|
+
);
|
|
292
|
+
const F = A(
|
|
293
|
+
E,
|
|
294
|
+
s,
|
|
295
|
+
b
|
|
296
|
+
);
|
|
297
|
+
j(
|
|
298
|
+
E,
|
|
299
|
+
F,
|
|
300
|
+
l
|
|
301
|
+
);
|
|
302
|
+
let x = c.finalizeFragmentState({
|
|
303
|
+
draft: a,
|
|
304
|
+
options: n,
|
|
305
|
+
context: r,
|
|
306
|
+
buildOptions: t,
|
|
307
|
+
helpers: { fragments: F }
|
|
308
|
+
});
|
|
309
|
+
const re = X(
|
|
310
|
+
y,
|
|
311
|
+
K,
|
|
312
|
+
h
|
|
313
|
+
).order, oe = ie(
|
|
314
|
+
v,
|
|
315
|
+
U(x),
|
|
316
|
+
({ error: R, extensionKeys: B, hookSequence: z }) => $({
|
|
317
|
+
error: R,
|
|
318
|
+
extensionKeys: B,
|
|
319
|
+
hookSequence: z,
|
|
320
|
+
errorMetadata: Y(R),
|
|
321
|
+
context: r
|
|
322
|
+
})
|
|
323
|
+
);
|
|
324
|
+
return M(oe, (R) => {
|
|
325
|
+
x = R.artifact;
|
|
326
|
+
const B = () => (d) => M(
|
|
327
|
+
ce(
|
|
328
|
+
R.results,
|
|
329
|
+
v,
|
|
330
|
+
({
|
|
331
|
+
error: g,
|
|
332
|
+
extensionKeys: w,
|
|
333
|
+
hookSequence: V
|
|
334
|
+
}) => $({
|
|
335
|
+
error: g,
|
|
336
|
+
extensionKeys: w,
|
|
337
|
+
hookSequence: V,
|
|
338
|
+
errorMetadata: Y(
|
|
339
|
+
g
|
|
340
|
+
),
|
|
341
|
+
context: r
|
|
342
|
+
})
|
|
343
|
+
),
|
|
344
|
+
() => {
|
|
345
|
+
throw d;
|
|
346
|
+
}
|
|
347
|
+
), z = B(), se = (d) => {
|
|
348
|
+
W(
|
|
349
|
+
y,
|
|
350
|
+
d,
|
|
351
|
+
p
|
|
352
|
+
);
|
|
353
|
+
const g = A(
|
|
354
|
+
y,
|
|
355
|
+
d,
|
|
356
|
+
m
|
|
357
|
+
);
|
|
358
|
+
j(
|
|
359
|
+
y,
|
|
360
|
+
g,
|
|
361
|
+
p
|
|
362
|
+
), o = g;
|
|
363
|
+
const w = () => ne({
|
|
364
|
+
artifact: x,
|
|
365
|
+
diagnostics: S.slice(),
|
|
366
|
+
steps: k,
|
|
367
|
+
context: r,
|
|
368
|
+
buildOptions: t,
|
|
369
|
+
options: n,
|
|
370
|
+
helpers: {
|
|
371
|
+
fragments: F,
|
|
372
|
+
builders: o
|
|
373
|
+
}
|
|
374
|
+
}), V = B();
|
|
375
|
+
return M(
|
|
376
|
+
Q(
|
|
377
|
+
() => ae(
|
|
378
|
+
R.results
|
|
379
|
+
),
|
|
380
|
+
V
|
|
381
|
+
),
|
|
382
|
+
w
|
|
383
|
+
);
|
|
384
|
+
};
|
|
385
|
+
return Q(() => M(
|
|
386
|
+
Z(
|
|
387
|
+
re,
|
|
388
|
+
(d) => c.createBuilderArgs({
|
|
389
|
+
helper: d.helper,
|
|
390
|
+
options: n,
|
|
391
|
+
context: r,
|
|
392
|
+
buildOptions: t,
|
|
393
|
+
artifact: x
|
|
394
|
+
}),
|
|
395
|
+
(d, g, w) => d.apply(g, w),
|
|
396
|
+
(d) => f(d)
|
|
397
|
+
),
|
|
398
|
+
se
|
|
399
|
+
), z);
|
|
400
|
+
});
|
|
401
|
+
});
|
|
402
|
+
}
|
|
403
|
+
const L = {
|
|
404
|
+
fragmentKind: b,
|
|
405
|
+
builderKind: m,
|
|
406
|
+
ir: {
|
|
407
|
+
use(e) {
|
|
408
|
+
N(e);
|
|
409
|
+
}
|
|
410
|
+
},
|
|
411
|
+
builders: {
|
|
412
|
+
use(e) {
|
|
413
|
+
I(e);
|
|
414
|
+
}
|
|
415
|
+
},
|
|
416
|
+
extensions: {
|
|
417
|
+
use(e) {
|
|
418
|
+
const n = e.register(L);
|
|
419
|
+
return n && typeof n?.then == "function" ? n.then(
|
|
420
|
+
(t) => J(e.key, t)
|
|
421
|
+
) : J(e.key, n);
|
|
422
|
+
}
|
|
423
|
+
},
|
|
424
|
+
use(e) {
|
|
425
|
+
if (e.kind === b) {
|
|
426
|
+
N(e);
|
|
427
|
+
return;
|
|
428
|
+
}
|
|
429
|
+
if (e.kind === m) {
|
|
430
|
+
I(e);
|
|
431
|
+
return;
|
|
432
|
+
}
|
|
433
|
+
throw h(
|
|
434
|
+
"ValidationError",
|
|
435
|
+
`Unsupported helper kind "${e.kind}".`
|
|
436
|
+
);
|
|
437
|
+
},
|
|
438
|
+
run(e) {
|
|
439
|
+
const n = ee(e);
|
|
440
|
+
return te(n);
|
|
441
|
+
}
|
|
442
|
+
};
|
|
443
|
+
return L;
|
|
444
|
+
}
|
|
445
|
+
export {
|
|
446
|
+
ye as createPipeline
|
|
447
|
+
};
|