gagen 0.0.4
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 +553 -0
- package/esm/_dnt.polyfills.d.ts +12 -0
- package/esm/_dnt.polyfills.d.ts.map +1 -0
- package/esm/_dnt.polyfills.js +15 -0
- package/esm/_dnt.test_shims.d.ts.map +1 -0
- package/esm/artifact.d.ts +20 -0
- package/esm/artifact.d.ts.map +1 -0
- package/esm/artifact.js +62 -0
- package/esm/deps/jsr.io/@std/assert/1.0.18/almost_equals.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.18/array_includes.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.18/assert.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.18/assertion_error.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.18/equal.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.18/equals.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.18/exists.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.18/fail.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.18/false.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.18/greater.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.18/greater_or_equal.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.18/instance_of.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.18/is_error.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.18/less.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.18/less_or_equal.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.18/match.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.18/mod.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.18/not_equals.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.18/not_instance_of.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.18/not_match.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.18/not_strict_equals.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.18/object_match.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.18/rejects.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.18/strict_equals.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.18/string_includes.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.18/throws.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.18/unimplemented.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.18/unreachable.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/internal/1.0.12/build_message.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/internal/1.0.12/diff.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/internal/1.0.12/diff_str.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/internal/1.0.12/format.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/internal/1.0.12/styles.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/internal/1.0.12/types.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.11/_chars.d.ts +33 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.11/_chars.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.11/_chars.js +48 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.11/_dumper_state.d.ts +106 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.11/_dumper_state.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.11/_dumper_state.js +712 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.11/_loader_state.d.ts +69 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.11/_loader_state.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.11/_loader_state.js +1404 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.11/_schema.d.ts +44 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.11/_schema.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.11/_schema.js +117 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.11/_type/binary.d.ts +3 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.11/_type/binary.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.11/_type/binary.js +103 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.11/_type/bool.d.ts +3 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.11/_type/bool.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.11/_type/bool.js +32 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.11/_type/float.d.ts +3 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.11/_type/float.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.11/_type/float.js +96 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.11/_type/int.d.ts +3 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.11/_type/int.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.11/_type/int.js +159 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.11/_type/map.d.ts +3 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.11/_type/map.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.11/_type/map.js +14 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.11/_type/merge.d.ts +3 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.11/_type/merge.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.11/_type/merge.js +10 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.11/_type/nil.d.ts +3 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.11/_type/nil.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.11/_type/nil.js +22 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.11/_type/omap.d.ts +3 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.11/_type/omap.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.11/_type/omap.js +29 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.11/_type/pairs.d.ts +3 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.11/_type/pairs.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.11/_type/pairs.js +19 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.11/_type/regexp.d.ts +3 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.11/_type/regexp.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.11/_type/regexp.js +30 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.11/_type/seq.d.ts +3 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.11/_type/seq.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.11/_type/seq.js +10 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.11/_type/set.d.ts +3 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.11/_type/set.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.11/_type/set.js +14 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.11/_type/str.d.ts +3 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.11/_type/str.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.11/_type/str.js +9 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.11/_type/timestamp.d.ts +3 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.11/_type/timestamp.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.11/_type/timestamp.js +81 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.11/_type/undefined.d.ts +3 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.11/_type/undefined.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.11/_type/undefined.js +20 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.11/_type.d.ts +32 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.11/_type.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.11/_type.js +6 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.11/_utils.d.ts +4 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.11/_utils.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.11/_utils.js +13 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.11/parse.d.ts +76 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.11/parse.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.11/parse.js +93 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.11/stringify.d.ts +100 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.11/stringify.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/yaml/1.0.11/stringify.js +33 -0
- package/esm/expression.d.ts +157 -0
- package/esm/expression.d.ts.map +1 -0
- package/esm/expression.js +393 -0
- package/esm/expression_test.d.ts.map +1 -0
- package/esm/job.d.ts +77 -0
- package/esm/job.d.ts.map +1 -0
- package/esm/job.js +906 -0
- package/esm/matrix.d.ts +15 -0
- package/esm/matrix.d.ts.map +1 -0
- package/esm/matrix.js +44 -0
- package/esm/mod.d.ts +14 -0
- package/esm/mod.d.ts.map +1 -0
- package/esm/mod.js +7 -0
- package/esm/mod_test.d.ts.map +1 -0
- package/esm/package.json +3 -0
- package/esm/permissions.d.ts +4 -0
- package/esm/permissions.d.ts.map +1 -0
- package/esm/permissions.js +1 -0
- package/esm/step.d.ts +48 -0
- package/esm/step.d.ts.map +1 -0
- package/esm/step.js +226 -0
- package/esm/workflow.d.ts +71 -0
- package/esm/workflow.d.ts.map +1 -0
- package/esm/workflow.js +136 -0
- package/package.json +28 -0
package/esm/matrix.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ExpressionValue } from "./expression.js";
|
|
2
|
+
type ExtractMatrixKeys<T> = Exclude<keyof T & string, "include" | "exclude"> | (T extends {
|
|
3
|
+
include: readonly (infer I)[];
|
|
4
|
+
} ? keyof I & string : never);
|
|
5
|
+
export declare class Matrix<_K extends string> {
|
|
6
|
+
#private;
|
|
7
|
+
constructor(def: Record<string, unknown>, keys: string[]);
|
|
8
|
+
toYaml(): Record<string, unknown>;
|
|
9
|
+
}
|
|
10
|
+
type MatrixWithExprs<K extends string> = Matrix<K> & {
|
|
11
|
+
readonly [P in K]: ExpressionValue;
|
|
12
|
+
};
|
|
13
|
+
export declare function defineMatrix<const T extends Record<string, unknown>>(def: T): MatrixWithExprs<ExtractMatrixKeys<T>>;
|
|
14
|
+
export {};
|
|
15
|
+
//# sourceMappingURL=matrix.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"matrix.d.ts","sourceRoot":"","sources":["../src/matrix.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAElD,KAAK,iBAAiB,CAAC,CAAC,IACpB,OAAO,CAAC,MAAM,CAAC,GAAG,MAAM,EAAE,SAAS,GAAG,SAAS,CAAC,GAChD,CAAC,CAAC,SAAS;IAAE,OAAO,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC,EAAE,CAAA;CAAE,GAAG,MAAM,CAAC,GAAG,MAAM,GAAG,KAAK,CAAC,CAAC;AAE7E,qBAAa,MAAM,CAAC,EAAE,SAAS,MAAM;;gBAGvB,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE;IASxD,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAGlC;AAED,KAAK,eAAe,CAAC,CAAC,SAAS,MAAM,IACjC,MAAM,CAAC,CAAC,CAAC,GACT;IACA,QAAQ,EAAE,CAAC,IAAI,CAAC,GAAG,eAAe;CACnC,CAAC;AAEJ,wBAAgB,YAAY,CAAC,KAAK,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAClE,GAAG,EAAE,CAAC,GACL,eAAe,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAkBvC"}
|
package/esm/matrix.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
2
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
3
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
4
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
5
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
6
|
+
};
|
|
7
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
8
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
9
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
10
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
|
+
};
|
|
12
|
+
var _Matrix_def;
|
|
13
|
+
import { ExpressionValue } from "./expression.js";
|
|
14
|
+
export class Matrix {
|
|
15
|
+
constructor(def, keys) {
|
|
16
|
+
_Matrix_def.set(this, void 0);
|
|
17
|
+
__classPrivateFieldSet(this, _Matrix_def, def, "f");
|
|
18
|
+
for (const key of keys) {
|
|
19
|
+
this[key] = new ExpressionValue(`matrix.${key}`);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
toYaml() {
|
|
23
|
+
return __classPrivateFieldGet(this, _Matrix_def, "f");
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
_Matrix_def = new WeakMap();
|
|
27
|
+
export function defineMatrix(def) {
|
|
28
|
+
const keys = new Set();
|
|
29
|
+
for (const [key, value] of Object.entries(def)) {
|
|
30
|
+
if (key !== "include" && key !== "exclude") {
|
|
31
|
+
keys.add(key);
|
|
32
|
+
}
|
|
33
|
+
if (key === "include" && Array.isArray(value)) {
|
|
34
|
+
for (const item of value) {
|
|
35
|
+
if (typeof item === "object" && item !== null) {
|
|
36
|
+
for (const k of Object.keys(item)) {
|
|
37
|
+
keys.add(k);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return new Matrix(def, [...keys]);
|
|
44
|
+
}
|
package/esm/mod.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import "./_dnt.polyfills.js";
|
|
2
|
+
export { Step, step, StepGroup, steps } from "./step.js";
|
|
3
|
+
export type { ConditionLike, ConfigValue, StepConfig, StepLike, } from "./step.js";
|
|
4
|
+
export { Job, job } from "./job.js";
|
|
5
|
+
export type { JobConfig, JobDef, ReusableJobConfig, ReusableJobDef, ServiceContainer, StepsJobConfig, StepsJobDef, } from "./job.js";
|
|
6
|
+
export { createWorkflow, Workflow } from "./workflow.js";
|
|
7
|
+
export type { isLinting, WorkflowCallInput, WorkflowCallOutput, WorkflowCallSecret, WorkflowCallTrigger, WorkflowConfig, WorkflowTriggers, } from "./workflow.js";
|
|
8
|
+
export { Condition, conditions, ElseIfBuilder, expr, ExpressionValue, ThenBuilder, } from "./expression.js";
|
|
9
|
+
export type { ExpressionSource, TernaryValue } from "./expression.js";
|
|
10
|
+
export { defineMatrix, Matrix } from "./matrix.js";
|
|
11
|
+
export type { PermissionLevel, Permissions, PermissionScope, } from "./permissions.js";
|
|
12
|
+
export { Artifact, defineArtifact } from "./artifact.js";
|
|
13
|
+
export type { ArtifactOptions, DownloadConfig, UploadConfig, } from "./artifact.js";
|
|
14
|
+
//# sourceMappingURL=mod.d.ts.map
|
package/esm/mod.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../src/mod.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAC7B,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AACzD,YAAY,EACV,aAAa,EACb,WAAW,EACX,UAAU,EACV,QAAQ,GACT,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AACpC,YAAY,EACV,SAAS,EACT,MAAM,EACN,iBAAiB,EACjB,cAAc,EACd,gBAAgB,EAChB,cAAc,EACd,WAAW,GACZ,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzD,YAAY,EACV,SAAS,EACT,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACnB,cAAc,EACd,gBAAgB,GACjB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,SAAS,EACT,UAAU,EACV,aAAa,EACb,IAAI,EACJ,eAAe,EACf,WAAW,GACZ,MAAM,iBAAiB,CAAC;AACzB,YAAY,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACtE,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACnD,YAAY,EACV,eAAe,EACf,WAAW,EACX,eAAe,GAChB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACzD,YAAY,EACV,eAAe,EACf,cAAc,EACd,YAAY,GACb,MAAM,eAAe,CAAC"}
|
package/esm/mod.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import "./_dnt.polyfills.js";
|
|
2
|
+
export { Step, step, StepGroup, steps } from "./step.js";
|
|
3
|
+
export { Job, job } from "./job.js";
|
|
4
|
+
export { createWorkflow, Workflow } from "./workflow.js";
|
|
5
|
+
export { Condition, conditions, ElseIfBuilder, expr, ExpressionValue, ThenBuilder, } from "./expression.js";
|
|
6
|
+
export { defineMatrix, Matrix } from "./matrix.js";
|
|
7
|
+
export { Artifact, defineArtifact } from "./artifact.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mod_test.d.ts","sourceRoot":"","sources":["../src/mod_test.ts"],"names":[],"mappings":""}
|
package/esm/package.json
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export type PermissionLevel = "read" | "write" | "none";
|
|
2
|
+
export type PermissionScope = "actions" | "attestations" | "checks" | "contents" | "deployments" | "discussions" | "id-token" | "issues" | "packages" | "pages" | "pull-requests" | "repository-projects" | "security-events" | "statuses";
|
|
3
|
+
export type Permissions = Partial<Record<PermissionScope, PermissionLevel>> | "read-all" | "write-all";
|
|
4
|
+
//# sourceMappingURL=permissions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"permissions.d.ts","sourceRoot":"","sources":["../src/permissions.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,CAAC;AAExD,MAAM,MAAM,eAAe,GACvB,SAAS,GACT,cAAc,GACd,QAAQ,GACR,UAAU,GACV,aAAa,GACb,aAAa,GACb,UAAU,GACV,QAAQ,GACR,UAAU,GACV,OAAO,GACP,eAAe,GACf,qBAAqB,GACrB,iBAAiB,GACjB,UAAU,CAAC;AAEf,MAAM,MAAM,WAAW,GACnB,OAAO,CAAC,MAAM,CAAC,eAAe,EAAE,eAAe,CAAC,CAAC,GACjD,UAAU,GACV,WAAW,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/esm/step.d.ts
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { Condition, type ExpressionSource, ExpressionValue } from "./expression.js";
|
|
2
|
+
export type ConditionLike = Condition | ExpressionValue | string;
|
|
3
|
+
export type ConfigValue = string | number | boolean | ExpressionValue;
|
|
4
|
+
export interface StepConfig<O extends string = never> {
|
|
5
|
+
name?: string;
|
|
6
|
+
id?: string;
|
|
7
|
+
uses?: string;
|
|
8
|
+
run?: string | string[];
|
|
9
|
+
with?: Record<string, ConfigValue>;
|
|
10
|
+
env?: Record<string, ConfigValue>;
|
|
11
|
+
if?: ConditionLike;
|
|
12
|
+
shell?: string;
|
|
13
|
+
workingDirectory?: string;
|
|
14
|
+
continueOnError?: boolean | string;
|
|
15
|
+
timeoutMinutes?: number;
|
|
16
|
+
outputs?: readonly O[];
|
|
17
|
+
}
|
|
18
|
+
export declare function resetStepCounter(): void;
|
|
19
|
+
export type StepLike = Step<string> | StepGroup;
|
|
20
|
+
export declare class Step<O extends string = never> implements ExpressionSource {
|
|
21
|
+
#private;
|
|
22
|
+
readonly config: StepConfig<O>;
|
|
23
|
+
readonly dependencies: Step<string>[];
|
|
24
|
+
readonly comesAfterDeps: Step<string>[];
|
|
25
|
+
readonly outputs: {
|
|
26
|
+
[K in O]: ExpressionValue;
|
|
27
|
+
};
|
|
28
|
+
readonly _crossJobDeps: Step<string>[];
|
|
29
|
+
_job?: ExpressionSource;
|
|
30
|
+
constructor(config: StepConfig<O>);
|
|
31
|
+
get id(): string;
|
|
32
|
+
dependsOn(...deps: StepLike[]): this;
|
|
33
|
+
comesAfter(...deps: StepLike[]): this;
|
|
34
|
+
toYaml(effectiveIf?: Condition): Record<string, unknown>;
|
|
35
|
+
}
|
|
36
|
+
export declare function step<const O extends string = never>(config: StepConfig<O>): Step<O>;
|
|
37
|
+
export declare function serializeConditionLike(c: ConditionLike): string;
|
|
38
|
+
export declare function toCondition(c: ConditionLike): Condition;
|
|
39
|
+
export declare function serializeConfigValues(record: Record<string, ConfigValue>): Record<string, string | number | boolean>;
|
|
40
|
+
export declare class StepGroup {
|
|
41
|
+
readonly all: Step<string>[];
|
|
42
|
+
constructor(steps: Step<string>[]);
|
|
43
|
+
if(condition: ConditionLike): this;
|
|
44
|
+
dependsOn(...deps: StepLike[]): this;
|
|
45
|
+
comesAfter(...deps: StepLike[]): this;
|
|
46
|
+
}
|
|
47
|
+
export declare function steps(...items: (Step<string> | StepGroup | StepConfig)[]): StepGroup;
|
|
48
|
+
//# sourceMappingURL=step.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"step.d.ts","sourceRoot":"","sources":["../src/step.ts"],"names":[],"mappings":"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"}
|
package/esm/step.js
ADDED
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
2
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
3
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
4
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
5
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
6
|
+
};
|
|
7
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
8
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
9
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
10
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
|
+
};
|
|
12
|
+
var _Step_id;
|
|
13
|
+
import { Condition, ExpressionValue, RawCondition, sourcesFrom, } from "./expression.js";
|
|
14
|
+
let stepCounter = 0;
|
|
15
|
+
// exported for testing only
|
|
16
|
+
export function resetStepCounter() {
|
|
17
|
+
stepCounter = 0;
|
|
18
|
+
}
|
|
19
|
+
export class Step {
|
|
20
|
+
constructor(config) {
|
|
21
|
+
_Step_id.set(this, void 0);
|
|
22
|
+
Object.defineProperty(this, "config", {
|
|
23
|
+
enumerable: true,
|
|
24
|
+
configurable: true,
|
|
25
|
+
writable: true,
|
|
26
|
+
value: void 0
|
|
27
|
+
});
|
|
28
|
+
Object.defineProperty(this, "dependencies", {
|
|
29
|
+
enumerable: true,
|
|
30
|
+
configurable: true,
|
|
31
|
+
writable: true,
|
|
32
|
+
value: []
|
|
33
|
+
});
|
|
34
|
+
Object.defineProperty(this, "comesAfterDeps", {
|
|
35
|
+
enumerable: true,
|
|
36
|
+
configurable: true,
|
|
37
|
+
writable: true,
|
|
38
|
+
value: []
|
|
39
|
+
});
|
|
40
|
+
Object.defineProperty(this, "outputs", {
|
|
41
|
+
enumerable: true,
|
|
42
|
+
configurable: true,
|
|
43
|
+
writable: true,
|
|
44
|
+
value: void 0
|
|
45
|
+
});
|
|
46
|
+
// cross-job step references for needs inference (e.g., artifact download → upload)
|
|
47
|
+
Object.defineProperty(this, "_crossJobDeps", {
|
|
48
|
+
enumerable: true,
|
|
49
|
+
configurable: true,
|
|
50
|
+
writable: true,
|
|
51
|
+
value: []
|
|
52
|
+
});
|
|
53
|
+
// set by Job.resolveSteps() — the job that owns this step
|
|
54
|
+
Object.defineProperty(this, "_job", {
|
|
55
|
+
enumerable: true,
|
|
56
|
+
configurable: true,
|
|
57
|
+
writable: true,
|
|
58
|
+
value: void 0
|
|
59
|
+
});
|
|
60
|
+
if (config.outputs?.length && !config.id) {
|
|
61
|
+
throw new Error("Step with outputs must have an explicit id");
|
|
62
|
+
}
|
|
63
|
+
__classPrivateFieldSet(this, _Step_id, config.id ?? `_step_${stepCounter++}`, "f");
|
|
64
|
+
this.config = config;
|
|
65
|
+
// build typed outputs
|
|
66
|
+
const outputs = {};
|
|
67
|
+
if (config.outputs) {
|
|
68
|
+
for (const name of config.outputs) {
|
|
69
|
+
outputs[name] =
|
|
70
|
+
new ExpressionValue(`steps.${__classPrivateFieldGet(this, _Step_id, "f")}.outputs.${name}`, this);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
this.outputs = outputs;
|
|
74
|
+
}
|
|
75
|
+
get id() {
|
|
76
|
+
return __classPrivateFieldGet(this, _Step_id, "f");
|
|
77
|
+
}
|
|
78
|
+
dependsOn(...deps) {
|
|
79
|
+
for (const d of deps) {
|
|
80
|
+
if (d instanceof StepGroup) {
|
|
81
|
+
this.dependencies.push(...d.all);
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
this.dependencies.push(d);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return this;
|
|
88
|
+
}
|
|
89
|
+
comesAfter(...deps) {
|
|
90
|
+
for (const d of deps) {
|
|
91
|
+
if (d instanceof StepGroup) {
|
|
92
|
+
this.comesAfterDeps.push(...d.all);
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
this.comesAfterDeps.push(d);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return this;
|
|
99
|
+
}
|
|
100
|
+
toYaml(effectiveIf) {
|
|
101
|
+
const result = {};
|
|
102
|
+
if (this.config.name != null) {
|
|
103
|
+
result.name = this.config.name;
|
|
104
|
+
}
|
|
105
|
+
// only include user-provided id
|
|
106
|
+
if (this.config.id) {
|
|
107
|
+
result.id = this.config.id;
|
|
108
|
+
}
|
|
109
|
+
if (this.config.uses != null) {
|
|
110
|
+
result.uses = this.config.uses;
|
|
111
|
+
}
|
|
112
|
+
const ifCondition = effectiveIf ?? this.config.if;
|
|
113
|
+
if (ifCondition != null) {
|
|
114
|
+
result.if = serializeConditionLike(ifCondition);
|
|
115
|
+
}
|
|
116
|
+
if (this.config.shell != null) {
|
|
117
|
+
result.shell = this.config.shell;
|
|
118
|
+
}
|
|
119
|
+
if (this.config.workingDirectory != null) {
|
|
120
|
+
result["working-directory"] = this.config.workingDirectory;
|
|
121
|
+
}
|
|
122
|
+
if (this.config.env != null) {
|
|
123
|
+
result.env = serializeConfigValues(this.config.env);
|
|
124
|
+
}
|
|
125
|
+
if (this.config.continueOnError != null) {
|
|
126
|
+
result["continue-on-error"] = this.config.continueOnError;
|
|
127
|
+
}
|
|
128
|
+
if (this.config.timeoutMinutes != null) {
|
|
129
|
+
result["timeout-minutes"] = this.config.timeoutMinutes;
|
|
130
|
+
}
|
|
131
|
+
if (this.config.with != null) {
|
|
132
|
+
result.with = serializeConfigValues(this.config.with);
|
|
133
|
+
}
|
|
134
|
+
if (this.config.run != null) {
|
|
135
|
+
result.run = Array.isArray(this.config.run)
|
|
136
|
+
? this.config.run.join("\n")
|
|
137
|
+
: this.config.run;
|
|
138
|
+
}
|
|
139
|
+
return result;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
_Step_id = new WeakMap();
|
|
143
|
+
export function step(config) {
|
|
144
|
+
return new Step(config);
|
|
145
|
+
}
|
|
146
|
+
// --- serialization helpers ---
|
|
147
|
+
export function serializeConditionLike(c) {
|
|
148
|
+
if (c instanceof Condition) {
|
|
149
|
+
return c.toExpression();
|
|
150
|
+
}
|
|
151
|
+
else if (c instanceof ExpressionValue) {
|
|
152
|
+
return c.expression;
|
|
153
|
+
}
|
|
154
|
+
else {
|
|
155
|
+
return c;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
export function toCondition(c) {
|
|
159
|
+
if (c instanceof Condition)
|
|
160
|
+
return c;
|
|
161
|
+
if (c instanceof ExpressionValue) {
|
|
162
|
+
return new RawCondition(c.expression, sourcesFrom(c));
|
|
163
|
+
}
|
|
164
|
+
return new RawCondition(c, new Set());
|
|
165
|
+
}
|
|
166
|
+
export function serializeConfigValues(record) {
|
|
167
|
+
const result = {};
|
|
168
|
+
for (const [key, value] of Object.entries(record)) {
|
|
169
|
+
result[key] = value instanceof ExpressionValue ? value.toString() : value;
|
|
170
|
+
}
|
|
171
|
+
return result;
|
|
172
|
+
}
|
|
173
|
+
// --- step group ---
|
|
174
|
+
export class StepGroup {
|
|
175
|
+
constructor(steps) {
|
|
176
|
+
Object.defineProperty(this, "all", {
|
|
177
|
+
enumerable: true,
|
|
178
|
+
configurable: true,
|
|
179
|
+
writable: true,
|
|
180
|
+
value: void 0
|
|
181
|
+
});
|
|
182
|
+
this.all = steps;
|
|
183
|
+
}
|
|
184
|
+
if(condition) {
|
|
185
|
+
const cond = toCondition(condition);
|
|
186
|
+
for (const s of this.all) {
|
|
187
|
+
if (s.config.if != null) {
|
|
188
|
+
s.config.if = cond.and(toCondition(s.config.if));
|
|
189
|
+
}
|
|
190
|
+
else {
|
|
191
|
+
s.config.if = cond;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
return this;
|
|
195
|
+
}
|
|
196
|
+
dependsOn(...deps) {
|
|
197
|
+
for (const s of this.all) {
|
|
198
|
+
s.dependsOn(...deps);
|
|
199
|
+
}
|
|
200
|
+
return this;
|
|
201
|
+
}
|
|
202
|
+
comesAfter(...deps) {
|
|
203
|
+
for (const s of this.all) {
|
|
204
|
+
s.comesAfter(...deps);
|
|
205
|
+
}
|
|
206
|
+
return this;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
export function steps(...items) {
|
|
210
|
+
if (items.length === 0) {
|
|
211
|
+
throw new Error("steps() requires at least one step");
|
|
212
|
+
}
|
|
213
|
+
const created = [];
|
|
214
|
+
for (const item of items) {
|
|
215
|
+
if (item instanceof StepGroup) {
|
|
216
|
+
created.push(...item.all);
|
|
217
|
+
}
|
|
218
|
+
else if (item instanceof Step) {
|
|
219
|
+
created.push(item);
|
|
220
|
+
}
|
|
221
|
+
else {
|
|
222
|
+
created.push(new Step(item));
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
return new StepGroup(created);
|
|
226
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { Job, type JobDef } from "./job.js";
|
|
2
|
+
import type { Permissions } from "./permissions.js";
|
|
3
|
+
import type { ConfigValue } from "./step.js";
|
|
4
|
+
export interface WorkflowCallInput {
|
|
5
|
+
type: "string" | "boolean" | "number";
|
|
6
|
+
description?: string;
|
|
7
|
+
required?: boolean;
|
|
8
|
+
default?: string | boolean | number;
|
|
9
|
+
}
|
|
10
|
+
export interface WorkflowCallOutput {
|
|
11
|
+
description?: string;
|
|
12
|
+
value: string;
|
|
13
|
+
}
|
|
14
|
+
export interface WorkflowCallSecret {
|
|
15
|
+
description?: string;
|
|
16
|
+
required?: boolean;
|
|
17
|
+
}
|
|
18
|
+
export interface WorkflowCallTrigger {
|
|
19
|
+
inputs?: Record<string, WorkflowCallInput>;
|
|
20
|
+
outputs?: Record<string, WorkflowCallOutput>;
|
|
21
|
+
secrets?: Record<string, WorkflowCallSecret>;
|
|
22
|
+
}
|
|
23
|
+
export interface WorkflowTriggers {
|
|
24
|
+
push?: {
|
|
25
|
+
branches?: string[];
|
|
26
|
+
tags?: string[];
|
|
27
|
+
paths?: string[];
|
|
28
|
+
pathsIgnore?: string[];
|
|
29
|
+
};
|
|
30
|
+
pull_request?: {
|
|
31
|
+
branches?: string[];
|
|
32
|
+
types?: string[];
|
|
33
|
+
paths?: string[];
|
|
34
|
+
pathsIgnore?: string[];
|
|
35
|
+
};
|
|
36
|
+
workflow_dispatch?: Record<string, unknown>;
|
|
37
|
+
workflow_call?: WorkflowCallTrigger;
|
|
38
|
+
schedule?: {
|
|
39
|
+
cron: string;
|
|
40
|
+
}[];
|
|
41
|
+
[key: string]: unknown;
|
|
42
|
+
}
|
|
43
|
+
export interface WorkflowConfig {
|
|
44
|
+
name: string;
|
|
45
|
+
on: WorkflowTriggers;
|
|
46
|
+
permissions?: Permissions;
|
|
47
|
+
concurrency?: {
|
|
48
|
+
group: string;
|
|
49
|
+
cancelInProgress?: boolean | string;
|
|
50
|
+
};
|
|
51
|
+
env?: Record<string, ConfigValue>;
|
|
52
|
+
jobs?: (JobDef | Job)[];
|
|
53
|
+
}
|
|
54
|
+
export declare class Workflow {
|
|
55
|
+
#private;
|
|
56
|
+
constructor(config: WorkflowConfig);
|
|
57
|
+
toYamlString(options?: {
|
|
58
|
+
header?: string;
|
|
59
|
+
}): string;
|
|
60
|
+
writeToFile(path: string | URL, options?: {
|
|
61
|
+
header?: string;
|
|
62
|
+
}): void;
|
|
63
|
+
writeOrLint(options: {
|
|
64
|
+
filePath: URL;
|
|
65
|
+
header?: string;
|
|
66
|
+
}): void;
|
|
67
|
+
}
|
|
68
|
+
/** Gets if linting would occur when using `writeOrLint` on a workflow. */
|
|
69
|
+
export declare const isLinting: boolean;
|
|
70
|
+
export declare function createWorkflow(config: WorkflowConfig): Workflow;
|
|
71
|
+
//# sourceMappingURL=workflow.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workflow.d.ts","sourceRoot":"","sources":["../src/workflow.ts"],"names":[],"mappings":"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"}
|
package/esm/workflow.js
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
2
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
3
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
4
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
5
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
6
|
+
};
|
|
7
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
8
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
9
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
10
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
|
+
};
|
|
12
|
+
var _Workflow_config, _Workflow_jobs;
|
|
13
|
+
import process from "node:process";
|
|
14
|
+
import { parse } from "./deps/jsr.io/@std/yaml/1.0.11/parse.js";
|
|
15
|
+
import { stringify } from "./deps/jsr.io/@std/yaml/1.0.11/stringify.js";
|
|
16
|
+
import { ExpressionValue } from "./expression.js";
|
|
17
|
+
import { Job, job as jobFn, resolveJobId } from "./job.js";
|
|
18
|
+
import fs from "node:fs";
|
|
19
|
+
export class Workflow {
|
|
20
|
+
constructor(config) {
|
|
21
|
+
_Workflow_config.set(this, void 0);
|
|
22
|
+
_Workflow_jobs.set(this, new Map());
|
|
23
|
+
__classPrivateFieldSet(this, _Workflow_config, config, "f");
|
|
24
|
+
if (config.jobs != null) {
|
|
25
|
+
for (const jobOrDef of config.jobs) {
|
|
26
|
+
let id;
|
|
27
|
+
let resolved;
|
|
28
|
+
if (jobOrDef instanceof Job) {
|
|
29
|
+
id = jobOrDef.id;
|
|
30
|
+
resolved = jobOrDef;
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
id = resolveJobId(jobOrDef);
|
|
34
|
+
resolved = jobFn(id, jobOrDef);
|
|
35
|
+
}
|
|
36
|
+
if (__classPrivateFieldGet(this, _Workflow_jobs, "f").has(id)) {
|
|
37
|
+
throw new Error(`Duplicate job id: "${id}"`);
|
|
38
|
+
}
|
|
39
|
+
__classPrivateFieldGet(this, _Workflow_jobs, "f").set(id, resolved);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
toYamlString(options) {
|
|
44
|
+
const obj = {};
|
|
45
|
+
obj.name = __classPrivateFieldGet(this, _Workflow_config, "f").name;
|
|
46
|
+
obj.on = serializeTriggers(__classPrivateFieldGet(this, _Workflow_config, "f").on);
|
|
47
|
+
if (__classPrivateFieldGet(this, _Workflow_config, "f").permissions != null) {
|
|
48
|
+
obj.permissions = __classPrivateFieldGet(this, _Workflow_config, "f").permissions;
|
|
49
|
+
}
|
|
50
|
+
if (__classPrivateFieldGet(this, _Workflow_config, "f").concurrency != null) {
|
|
51
|
+
const c = {
|
|
52
|
+
group: __classPrivateFieldGet(this, _Workflow_config, "f").concurrency.group,
|
|
53
|
+
};
|
|
54
|
+
if (__classPrivateFieldGet(this, _Workflow_config, "f").concurrency.cancelInProgress != null) {
|
|
55
|
+
c["cancel-in-progress"] = __classPrivateFieldGet(this, _Workflow_config, "f").concurrency.cancelInProgress;
|
|
56
|
+
}
|
|
57
|
+
obj.concurrency = c;
|
|
58
|
+
}
|
|
59
|
+
if (__classPrivateFieldGet(this, _Workflow_config, "f").env != null) {
|
|
60
|
+
const env = {};
|
|
61
|
+
for (const [key, value] of Object.entries(__classPrivateFieldGet(this, _Workflow_config, "f").env)) {
|
|
62
|
+
env[key] = value instanceof ExpressionValue ? value.toString() : value;
|
|
63
|
+
}
|
|
64
|
+
obj.env = env;
|
|
65
|
+
}
|
|
66
|
+
// pre-resolve all jobs to establish step→job mappings for cross-job deps
|
|
67
|
+
for (const job of __classPrivateFieldGet(this, _Workflow_jobs, "f").values()) {
|
|
68
|
+
job.resolveSteps();
|
|
69
|
+
}
|
|
70
|
+
// jobs
|
|
71
|
+
const jobs = {};
|
|
72
|
+
for (const [id, job] of __classPrivateFieldGet(this, _Workflow_jobs, "f")) {
|
|
73
|
+
jobs[id] = job.toYaml();
|
|
74
|
+
}
|
|
75
|
+
obj.jobs = jobs;
|
|
76
|
+
const yaml = stringify(obj, {
|
|
77
|
+
useAnchors: false,
|
|
78
|
+
lineWidth: 10_000,
|
|
79
|
+
compatMode: false,
|
|
80
|
+
});
|
|
81
|
+
const header = options?.header;
|
|
82
|
+
return header ? `${header}\n\n${yaml}` : yaml;
|
|
83
|
+
}
|
|
84
|
+
writeToFile(path, options) {
|
|
85
|
+
fs.writeFileSync(path, this.toYamlString(options));
|
|
86
|
+
}
|
|
87
|
+
writeOrLint(options) {
|
|
88
|
+
const expected = this.toYamlString(options);
|
|
89
|
+
if (isLinting) {
|
|
90
|
+
const existing = fs.readFileSync(options.filePath, { encoding: "utf8" });
|
|
91
|
+
const parsedExisting = parse(existing);
|
|
92
|
+
const parsedExpected = parse(expected);
|
|
93
|
+
if (JSON.stringify(parsedExisting) !== JSON.stringify(parsedExpected)) {
|
|
94
|
+
console.error(`Error: ${options.filePath} is out of date. Run without --lint to update.`);
|
|
95
|
+
process.exit(1);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
fs.writeFileSync(options.filePath, expected);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
_Workflow_config = new WeakMap(), _Workflow_jobs = new WeakMap();
|
|
104
|
+
/** Gets if linting would occur when using `writeOrLint` on a workflow. */
|
|
105
|
+
export const isLinting = process.argv.includes("--lint");
|
|
106
|
+
export function createWorkflow(config) {
|
|
107
|
+
return new Workflow(config);
|
|
108
|
+
}
|
|
109
|
+
// --- trigger serialization ---
|
|
110
|
+
function serializeTriggers(triggers) {
|
|
111
|
+
const result = {};
|
|
112
|
+
for (const [key, value] of Object.entries(triggers)) {
|
|
113
|
+
if (value == null)
|
|
114
|
+
continue;
|
|
115
|
+
if (key === "pathsIgnore") {
|
|
116
|
+
result["paths-ignore"] = value;
|
|
117
|
+
}
|
|
118
|
+
else if (typeof value === "object" && !Array.isArray(value)) {
|
|
119
|
+
result[key] = serializeTriggerObject(value);
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
result[key] = value;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
return result;
|
|
126
|
+
}
|
|
127
|
+
function serializeTriggerObject(obj) {
|
|
128
|
+
const result = {};
|
|
129
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
130
|
+
if (value == null)
|
|
131
|
+
continue;
|
|
132
|
+
const yamlKey = key === "pathsIgnore" ? "paths-ignore" : key;
|
|
133
|
+
result[yamlKey] = value;
|
|
134
|
+
}
|
|
135
|
+
return result;
|
|
136
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "gagen",
|
|
3
|
+
"description": "Generate complex GitHub Actions YAML files using a declarative API.",
|
|
4
|
+
"version": "0.0.4",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/dsherret/gagen.git"
|
|
8
|
+
},
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"bugs": {
|
|
11
|
+
"url": "https://github.com/dsherret/gagen/issues"
|
|
12
|
+
},
|
|
13
|
+
"module": "./esm/mod.js",
|
|
14
|
+
"exports": {
|
|
15
|
+
".": {
|
|
16
|
+
"import": "./esm/mod.js"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"scripts": {
|
|
20
|
+
"test": "node test_runner.js"
|
|
21
|
+
},
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"@types/node": "^20.9.0",
|
|
24
|
+
"picocolors": "^1.0.0",
|
|
25
|
+
"@deno/shim-deno": "~0.18.0"
|
|
26
|
+
},
|
|
27
|
+
"_generatedBy": "dnt@dev"
|
|
28
|
+
}
|