gagen 0.2.18 → 0.3.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/README.md +37 -0
- package/esm/deps/jsr.io/@std/assert/{1.0.18 → 1.0.19}/almost_equals.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/assert/{1.0.18 → 1.0.19}/array_includes.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/assert/{1.0.18 → 1.0.19}/assert.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/assert/{1.0.18 → 1.0.19}/assertion_error.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/assert/1.0.19/equal.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/1.0.19/equals.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/{1.0.18 → 1.0.19}/exists.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/assert/{1.0.18 → 1.0.19}/fail.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/assert/{1.0.18 → 1.0.19}/false.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/assert/{1.0.18 → 1.0.19}/greater.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/assert/{1.0.18 → 1.0.19}/greater_or_equal.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/assert/{1.0.18 → 1.0.19}/instance_of.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/assert/{1.0.18 → 1.0.19}/is_error.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/assert/{1.0.18 → 1.0.19}/less.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/assert/{1.0.18 → 1.0.19}/less_or_equal.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/assert/{1.0.18 → 1.0.19}/match.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/assert/{1.0.18 → 1.0.19}/mod.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/assert/1.0.19/not_equals.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/assert/{1.0.18 → 1.0.19}/not_instance_of.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/assert/{1.0.18 → 1.0.19}/not_match.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/assert/{1.0.18 → 1.0.19}/not_strict_equals.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/assert/{1.0.18 → 1.0.19}/object_match.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/assert/{1.0.18 → 1.0.19}/rejects.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/assert/{1.0.18 → 1.0.19}/strict_equals.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/assert/{1.0.18 → 1.0.19}/string_includes.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/assert/{1.0.18 → 1.0.19}/throws.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/assert/{1.0.18 → 1.0.19}/unimplemented.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/assert/{1.0.18 → 1.0.19}/unreachable.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_chars.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_dumper_state.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_loader_state.d.ts +0 -5
- package/esm/deps/jsr.io/@std/yaml/1.0.12/_loader_state.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_loader_state.js +216 -175
- package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_schema.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/binary.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/bool.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/float.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/int.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/map.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/merge.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/nil.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/omap.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/pairs.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/regexp.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/seq.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/set.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/str.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/timestamp.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/undefined.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_utils.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/parse.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/parse.js +0 -2
- package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/stringify.d.ts.map +1 -1
- package/esm/expression.d.ts +0 -68
- package/esm/expression.d.ts.map +1 -1
- package/esm/expression.js +1 -261
- package/esm/mod.d.ts +4 -2
- package/esm/mod.d.ts.map +1 -1
- package/esm/mod.js +2 -1
- package/esm/pin.d.ts +30 -0
- package/esm/pin.d.ts.map +1 -0
- package/esm/pin.js +123 -0
- package/esm/workflow.d.ts +6 -0
- package/esm/workflow.d.ts.map +1 -1
- package/esm/workflow.js +42 -5
- package/package.json +1 -1
- package/esm/deps/jsr.io/@std/assert/1.0.18/equal.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.18/equals.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.18/not_equals.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/yaml/1.0.11/_loader_state.d.ts.map +0 -1
- /package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_chars.d.ts +0 -0
- /package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_chars.js +0 -0
- /package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_dumper_state.d.ts +0 -0
- /package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_dumper_state.js +0 -0
- /package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_schema.d.ts +0 -0
- /package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_schema.js +0 -0
- /package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/binary.d.ts +0 -0
- /package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/binary.js +0 -0
- /package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/bool.d.ts +0 -0
- /package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/bool.js +0 -0
- /package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/float.d.ts +0 -0
- /package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/float.js +0 -0
- /package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/int.d.ts +0 -0
- /package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/int.js +0 -0
- /package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/map.d.ts +0 -0
- /package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/map.js +0 -0
- /package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/merge.d.ts +0 -0
- /package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/merge.js +0 -0
- /package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/nil.d.ts +0 -0
- /package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/nil.js +0 -0
- /package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/omap.d.ts +0 -0
- /package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/omap.js +0 -0
- /package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/pairs.d.ts +0 -0
- /package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/pairs.js +0 -0
- /package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/regexp.d.ts +0 -0
- /package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/regexp.js +0 -0
- /package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/seq.d.ts +0 -0
- /package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/seq.js +0 -0
- /package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/set.d.ts +0 -0
- /package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/set.js +0 -0
- /package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/str.d.ts +0 -0
- /package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/str.js +0 -0
- /package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/timestamp.d.ts +0 -0
- /package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/timestamp.js +0 -0
- /package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/undefined.d.ts +0 -0
- /package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type/undefined.js +0 -0
- /package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type.d.ts +0 -0
- /package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_type.js +0 -0
- /package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_utils.d.ts +0 -0
- /package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/_utils.js +0 -0
- /package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/parse.d.ts +0 -0
- /package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/stringify.d.ts +0 -0
- /package/esm/deps/jsr.io/@std/yaml/{1.0.11 → 1.0.12}/stringify.js +0 -0
package/esm/pin.js
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { execSync } from "node:child_process";
|
|
2
|
+
const SHA_RE = /^[0-9a-f]{40}$/;
|
|
3
|
+
export function isCommitHash(ref) {
|
|
4
|
+
return SHA_RE.test(ref);
|
|
5
|
+
}
|
|
6
|
+
export function parseActionUses(uses) {
|
|
7
|
+
if (uses.startsWith("./") || uses.startsWith("docker://"))
|
|
8
|
+
return undefined;
|
|
9
|
+
const atIndex = uses.lastIndexOf("@");
|
|
10
|
+
if (atIndex === -1)
|
|
11
|
+
return undefined;
|
|
12
|
+
const beforeAt = uses.substring(0, atIndex);
|
|
13
|
+
const ref = uses.substring(atIndex + 1);
|
|
14
|
+
const parts = beforeAt.split("/");
|
|
15
|
+
if (parts.length < 2)
|
|
16
|
+
return undefined;
|
|
17
|
+
return {
|
|
18
|
+
owner: parts[0],
|
|
19
|
+
repo: parts[1],
|
|
20
|
+
path: parts.slice(2).join("/"),
|
|
21
|
+
ref,
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
export function resolveRef(owner, repo, ref) {
|
|
25
|
+
const url = `https://github.com/${owner}/${repo}`;
|
|
26
|
+
const tagOutput = execSync(`git ls-remote "${url}" "refs/tags/${ref}" "refs/tags/${ref}^{}"`, { encoding: "utf8", timeout: 30_000 }).trim();
|
|
27
|
+
if (tagOutput) {
|
|
28
|
+
const lines = tagOutput.split("\n");
|
|
29
|
+
for (const line of lines) {
|
|
30
|
+
if (line.includes("^{}")) {
|
|
31
|
+
return line.split(/\s+/)[0];
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return lines[0].split(/\s+/)[0];
|
|
35
|
+
}
|
|
36
|
+
const branchOutput = execSync(`git ls-remote "${url}" "refs/heads/${ref}"`, { encoding: "utf8", timeout: 30_000 }).trim();
|
|
37
|
+
if (branchOutput) {
|
|
38
|
+
return branchOutput.split(/\s+/)[0];
|
|
39
|
+
}
|
|
40
|
+
throw new Error(`Could not resolve ref "${ref}" for ${owner}/${repo}`);
|
|
41
|
+
}
|
|
42
|
+
/** Resolves non-SHA refs in YAML content to commit hashes. */
|
|
43
|
+
export function pinYamlContent(yamlStr, resolve = resolveRef, cache) {
|
|
44
|
+
const pins = [];
|
|
45
|
+
const seen = new Map();
|
|
46
|
+
if (cache) {
|
|
47
|
+
for (const entry of cache) {
|
|
48
|
+
seen.set(entry.original, entry.hash);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
const content = yamlStr.replace(/^(\s+(?:-\s+)?uses:\s+)(.+)$/gm, (_match, prefix, usesValue) => {
|
|
52
|
+
const trimmed = usesValue.trim();
|
|
53
|
+
const parsed = parseActionUses(trimmed);
|
|
54
|
+
if (!parsed || isCommitHash(parsed.ref))
|
|
55
|
+
return `${prefix}${usesValue}`;
|
|
56
|
+
let hash = seen.get(trimmed);
|
|
57
|
+
if (!hash) {
|
|
58
|
+
hash = resolve(parsed.owner, parsed.repo, parsed.ref);
|
|
59
|
+
seen.set(trimmed, hash);
|
|
60
|
+
pins.push({ original: trimmed, hash });
|
|
61
|
+
}
|
|
62
|
+
const pinned = trimmed.replace(`@${parsed.ref}`, `@${hash}`);
|
|
63
|
+
return `${prefix}${pinned}`;
|
|
64
|
+
});
|
|
65
|
+
return { content, pins };
|
|
66
|
+
}
|
|
67
|
+
/** Formats pin entries as comments to append to the file. */
|
|
68
|
+
export function formatPinComments(pins) {
|
|
69
|
+
if (pins.length === 0)
|
|
70
|
+
return "";
|
|
71
|
+
const lines = pins.map((p) => `# gagen:pin ${p.original} = ${p.hash}`);
|
|
72
|
+
return "\n" + lines.join("\n") + "\n";
|
|
73
|
+
}
|
|
74
|
+
/** Extracts pin entries from file content. */
|
|
75
|
+
export function parsePinComments(content) {
|
|
76
|
+
const pins = [];
|
|
77
|
+
const re = /^# gagen:pin (.+) = ([0-9a-f]{40})$/gm;
|
|
78
|
+
let match;
|
|
79
|
+
while ((match = re.exec(content)) !== null) {
|
|
80
|
+
pins.push({ original: match[1], hash: match[2] });
|
|
81
|
+
}
|
|
82
|
+
return pins;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Replaces pinned hashes in a parsed YAML object with their original
|
|
86
|
+
* tag/branch refs using the provided pin mapping.
|
|
87
|
+
*/
|
|
88
|
+
export function unpinParsedYaml(obj, pins) {
|
|
89
|
+
if (pins.length === 0 || typeof obj !== "object" || obj === null)
|
|
90
|
+
return obj;
|
|
91
|
+
const hashToOriginal = new Map();
|
|
92
|
+
for (const pin of pins) {
|
|
93
|
+
const atIndex = pin.original.lastIndexOf("@");
|
|
94
|
+
const actionPath = pin.original.substring(0, atIndex);
|
|
95
|
+
hashToOriginal.set(`${actionPath}@${pin.hash}`, pin.original);
|
|
96
|
+
}
|
|
97
|
+
const record = obj;
|
|
98
|
+
if (record.jobs && typeof record.jobs === "object") {
|
|
99
|
+
for (const jobValue of Object.values(record.jobs)) {
|
|
100
|
+
if (typeof jobValue !== "object" || jobValue === null)
|
|
101
|
+
continue;
|
|
102
|
+
const jobObj = jobValue;
|
|
103
|
+
// reusable workflow uses
|
|
104
|
+
if (typeof jobObj.uses === "string" &&
|
|
105
|
+
hashToOriginal.has(jobObj.uses)) {
|
|
106
|
+
jobObj.uses = hashToOriginal.get(jobObj.uses);
|
|
107
|
+
}
|
|
108
|
+
// steps
|
|
109
|
+
if (Array.isArray(jobObj.steps)) {
|
|
110
|
+
for (const s of jobObj.steps) {
|
|
111
|
+
if (typeof s === "object" && s !== null) {
|
|
112
|
+
const stepObj = s;
|
|
113
|
+
if (typeof stepObj.uses === "string" &&
|
|
114
|
+
hashToOriginal.has(stepObj.uses)) {
|
|
115
|
+
stepObj.uses = hashToOriginal.get(stepObj.uses);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
return obj;
|
|
123
|
+
}
|
package/esm/workflow.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Job, type JobDef } from "./job.js";
|
|
2
2
|
import type { Permissions } from "./permissions.js";
|
|
3
3
|
import type { ConfigValue } from "./step.js";
|
|
4
|
+
import type { RefResolver } from "./pin.js";
|
|
4
5
|
export interface WorkflowCallInput {
|
|
5
6
|
type: "string" | "boolean" | "number";
|
|
6
7
|
description?: string;
|
|
@@ -70,9 +71,14 @@ export declare class Workflow {
|
|
|
70
71
|
writeOrLint(options: {
|
|
71
72
|
filePath: URL;
|
|
72
73
|
header?: string;
|
|
74
|
+
pinDeps?: boolean | {
|
|
75
|
+
resolve: RefResolver;
|
|
76
|
+
};
|
|
73
77
|
}): void;
|
|
74
78
|
}
|
|
75
79
|
/** Gets if linting would occur when using `writeOrLint` on a workflow. */
|
|
76
80
|
export declare const isLinting: boolean;
|
|
81
|
+
/** Gets if pins should be re-resolved when using `writeOrLint` on a workflow. */
|
|
82
|
+
export declare function isUpdatingPins(): boolean;
|
|
77
83
|
export declare function createWorkflow(config: WorkflowConfig): Workflow;
|
|
78
84
|
//# sourceMappingURL=workflow.d.ts.map
|
package/esm/workflow.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workflow.d.ts","sourceRoot":"","sources":["../src/workflow.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,GAAG,EAAgB,KAAK,MAAM,EAAgB,MAAM,UAAU,CAAC;AACxE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,KAAK,EAAE,WAAW,EAAQ,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"workflow.d.ts","sourceRoot":"","sources":["../src/workflow.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,GAAG,EAAgB,KAAK,MAAM,EAAgB,MAAM,UAAU,CAAC;AACxE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,KAAK,EAAE,WAAW,EAAQ,MAAM,WAAW,CAAC;AAOnD,OAAO,KAAK,EAAY,WAAW,EAAE,MAAM,UAAU,CAAC;AAGtD,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,QAAQ,GAAG,SAAS,GAAG,QAAQ,CAAC;IACtC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,MAAM,CAAC;CACrC;AAED,MAAM,WAAW,kBAAkB;IACjC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,kBAAkB;IACjC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,mBAAmB;IAClC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;I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AAM,CAAC;YAAC,gBAAgB,CAAC,EAAE,MAAM,CAAA;SAAE,CAAA;KAAE,CAAC;IACnE,IAAI,CAAC,EAAE,CAAC,MAAM,GAAG,GAAG,CAAC,EAAE,CAAC;CACzB;AAED,qBAAa,QAAQ;;gBAIP,MAAM,EAAE,cAAc;IAqBlC,YAAY,CAAC,OAAO,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,MAAM;IA8EnD,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,GAAG,EAAE,OAAO,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI;IAIpE,WAAW,CACT,OAAO,EAAE;QACP,QAAQ,EAAE,GAAG,CAAC;QACd,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,OAAO,CAAC,EAAE,OAAO,GAAG;YAAE,OAAO,EAAE,WAAW,CAAA;SAAE,CAAC;KAC9C,GACA,IAAI;CAmDR;AAED,0EAA0E;AAC1E,eAAO,MAAM,SAAS,EAAE,OAAyC,CAAC;AAElE,iFAAiF;AACjF,wBAAgB,cAAc,IAAI,OAAO,CAExC;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,cAAc,GAAG,QAAQ,CAE/D"}
|
package/esm/workflow.js
CHANGED
|
@@ -11,10 +11,11 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
11
11
|
};
|
|
12
12
|
var _Workflow_config, _Workflow_jobs;
|
|
13
13
|
import process from "node:process";
|
|
14
|
-
import { parse } from "./deps/jsr.io/@std/yaml/1.0.
|
|
15
|
-
import { stringify } from "./deps/jsr.io/@std/yaml/1.0.
|
|
14
|
+
import { parse } from "./deps/jsr.io/@std/yaml/1.0.12/parse.js";
|
|
15
|
+
import { stringify } from "./deps/jsr.io/@std/yaml/1.0.12/stringify.js";
|
|
16
16
|
import { ExpressionValue } from "./expression.js";
|
|
17
17
|
import { Job, job as jobFn, resolveJobId } from "./job.js";
|
|
18
|
+
import { formatPinComments, parsePinComments, pinYamlContent, unpinParsedYaml, } from "./pin.js";
|
|
18
19
|
import fs from "node:fs";
|
|
19
20
|
export class Workflow {
|
|
20
21
|
constructor(config) {
|
|
@@ -110,24 +111,60 @@ export class Workflow {
|
|
|
110
111
|
fs.writeFileSync(path, this.toYamlString(options));
|
|
111
112
|
}
|
|
112
113
|
writeOrLint(options) {
|
|
114
|
+
const pinDeps = options.pinDeps ?? true;
|
|
113
115
|
const expected = this.toYamlString(options);
|
|
114
116
|
if (isLinting) {
|
|
115
117
|
const existing = fs.readFileSync(options.filePath, { encoding: "utf8" });
|
|
116
|
-
|
|
117
|
-
|
|
118
|
+
let parsedExisting;
|
|
119
|
+
let parsedExpected;
|
|
120
|
+
if (pinDeps) {
|
|
121
|
+
const pins = parsePinComments(existing);
|
|
122
|
+
parsedExisting = unpinParsedYaml(parse(existing), pins);
|
|
123
|
+
parsedExpected = parse(expected);
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
parsedExisting = parse(existing);
|
|
127
|
+
parsedExpected = parse(expected);
|
|
128
|
+
}
|
|
118
129
|
if (JSON.stringify(parsedExisting) !== JSON.stringify(parsedExpected)) {
|
|
119
130
|
console.error(`Error: ${options.filePath} is out of date. Run without --lint to update.`);
|
|
120
131
|
process.exit(1);
|
|
121
132
|
}
|
|
122
133
|
}
|
|
123
134
|
else {
|
|
124
|
-
|
|
135
|
+
let output = expected;
|
|
136
|
+
if (pinDeps) {
|
|
137
|
+
const resolve = typeof pinDeps === "object"
|
|
138
|
+
? pinDeps.resolve
|
|
139
|
+
: undefined;
|
|
140
|
+
// reuse previously resolved hashes from existing file to avoid
|
|
141
|
+
// redundant git ls-remote calls on subsequent runs
|
|
142
|
+
let cache;
|
|
143
|
+
if (!isUpdatingPins()) {
|
|
144
|
+
try {
|
|
145
|
+
const existing = fs.readFileSync(options.filePath, {
|
|
146
|
+
encoding: "utf8",
|
|
147
|
+
});
|
|
148
|
+
cache = parsePinComments(existing);
|
|
149
|
+
}
|
|
150
|
+
catch {
|
|
151
|
+
// file doesn't exist yet
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
const result = pinYamlContent(expected, resolve, cache);
|
|
155
|
+
output = result.content + formatPinComments(result.pins);
|
|
156
|
+
}
|
|
157
|
+
fs.writeFileSync(options.filePath, output);
|
|
125
158
|
}
|
|
126
159
|
}
|
|
127
160
|
}
|
|
128
161
|
_Workflow_config = new WeakMap(), _Workflow_jobs = new WeakMap();
|
|
129
162
|
/** Gets if linting would occur when using `writeOrLint` on a workflow. */
|
|
130
163
|
export const isLinting = process.argv.includes("--lint");
|
|
164
|
+
/** Gets if pins should be re-resolved when using `writeOrLint` on a workflow. */
|
|
165
|
+
export function isUpdatingPins() {
|
|
166
|
+
return process.argv.includes("--update-pins");
|
|
167
|
+
}
|
|
131
168
|
export function createWorkflow(config) {
|
|
132
169
|
return new Workflow(config);
|
|
133
170
|
}
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"equal.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/1.0.18/equal.ts"],"names":[],"mappings":"AA0FA;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,GAAG,OAAO,CAgHrD"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"equals.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/1.0.18/equals.ts"],"names":[],"mappings":"AAUA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAC5B,MAAM,EAAE,CAAC,EACT,QAAQ,EAAE,CAAC,EACX,GAAG,CAAC,EAAE,MAAM,QAmBb"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"not_equals.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/1.0.18/not_equals.ts"],"names":[],"mappings":"AAOA;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE,MAAM,QAUtE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"_loader_state.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/yaml/1.0.11/_loader_state.ts"],"names":[],"mappings":"AAsCA,OAAO,EAAkB,KAAK,MAAM,EAAE,KAAK,OAAO,EAAE,MAAM,cAAc,CAAC;AACzE,OAAO,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAqBjD,MAAM,WAAW,kBAAkB;IACjC,iCAAiC;IACjC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,+CAA+C;IAC/C,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,4CAA4C;IAC5C,SAAS,CAAC,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;CAChC;AAgID,UAAU,KAAK;IACb,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IACnB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,IAAI,EAAE,QAAQ,GAAG,IAAI,CAAC;IACtB,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,GAAG,IAAI,CAAC;CAC7D;AACD,qBAAa,WAAW;;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,SAAK;IACf,SAAS,SAAK;IACd,QAAQ,SAAK;IACb,IAAI,SAAK;IACT,SAAS,EAAE,CAAC,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;IAChD,kBAAkB,EAAE,OAAO,CAAC;IAC5B,aA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WAAW,EAAE,WAAW,EAAE,YAAY,EAAE,EAAE;QACpE,YAAY,EAAE,MAAM,CAAC;QACrB,WAAW,EAAE,MAAM,CAAC;QACpB,WAAW,EAAE,OAAO,CAAC;QACrB,YAAY,EAAE,OAAO,CAAC;KACvB,GAAG,KAAK,GAAG,IAAI;IAkIhB,cAAc;IAuEd,YAAY;IA2DX,aAAa;CAKf"}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|