gagen 0.2.18 → 0.3.1
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 +87 -9
- 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 +143 -0
- package/esm/workflow.d.ts +7 -1
- package/esm/workflow.d.ts.map +1 -1
- package/esm/workflow.js +45 -6
- 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,143 @@
|
|
|
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)
|
|
55
|
+
return `${prefix}${usesValue}`;
|
|
56
|
+
if (isCommitHash(parsed.ref)) {
|
|
57
|
+
// already pinned — preserve the existing pin entry from cache
|
|
58
|
+
if (cache) {
|
|
59
|
+
for (const entry of cache) {
|
|
60
|
+
const ep = parseActionUses(entry.original);
|
|
61
|
+
if (ep &&
|
|
62
|
+
`${ep.owner}/${ep.repo}` === `${parsed.owner}/${parsed.repo}` &&
|
|
63
|
+
entry.hash === parsed.ref) {
|
|
64
|
+
if (!pins.some((p) => p.original === entry.original)) {
|
|
65
|
+
pins.push(entry);
|
|
66
|
+
}
|
|
67
|
+
break;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return `${prefix}${usesValue}`;
|
|
72
|
+
}
|
|
73
|
+
let hash = seen.get(trimmed);
|
|
74
|
+
if (!hash) {
|
|
75
|
+
hash = resolve(parsed.owner, parsed.repo, parsed.ref);
|
|
76
|
+
seen.set(trimmed, hash);
|
|
77
|
+
}
|
|
78
|
+
if (!pins.some((p) => p.original === trimmed)) {
|
|
79
|
+
pins.push({ original: trimmed, hash });
|
|
80
|
+
}
|
|
81
|
+
const pinned = trimmed.replace(`@${parsed.ref}`, `@${hash}`);
|
|
82
|
+
return `${prefix}${pinned}`;
|
|
83
|
+
});
|
|
84
|
+
return { content, pins };
|
|
85
|
+
}
|
|
86
|
+
/** Formats pin entries as comments to append to the file. */
|
|
87
|
+
export function formatPinComments(pins) {
|
|
88
|
+
if (pins.length === 0)
|
|
89
|
+
return "";
|
|
90
|
+
const sorted = [...pins].sort((a, b) => a.original < b.original ? -1 : a.original > b.original ? 1 : 0);
|
|
91
|
+
const lines = sorted.map((p) => `# gagen:pin ${p.original} = ${p.hash}`);
|
|
92
|
+
return "\n" + lines.join("\n") + "\n";
|
|
93
|
+
}
|
|
94
|
+
/** Extracts pin entries from file content. */
|
|
95
|
+
export function parsePinComments(content) {
|
|
96
|
+
const pins = [];
|
|
97
|
+
const re = /^# gagen:pin (.+) = ([0-9a-f]{40})$/gm;
|
|
98
|
+
let match;
|
|
99
|
+
while ((match = re.exec(content)) !== null) {
|
|
100
|
+
pins.push({ original: match[1], hash: match[2] });
|
|
101
|
+
}
|
|
102
|
+
return pins;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Replaces pinned hashes in a parsed YAML object with their original
|
|
106
|
+
* tag/branch refs using the provided pin mapping.
|
|
107
|
+
*/
|
|
108
|
+
export function unpinParsedYaml(obj, pins) {
|
|
109
|
+
if (pins.length === 0 || typeof obj !== "object" || obj === null)
|
|
110
|
+
return obj;
|
|
111
|
+
const hashToOriginal = new Map();
|
|
112
|
+
for (const pin of pins) {
|
|
113
|
+
const atIndex = pin.original.lastIndexOf("@");
|
|
114
|
+
const actionPath = pin.original.substring(0, atIndex);
|
|
115
|
+
hashToOriginal.set(`${actionPath}@${pin.hash}`, pin.original);
|
|
116
|
+
}
|
|
117
|
+
const record = obj;
|
|
118
|
+
if (record.jobs && typeof record.jobs === "object") {
|
|
119
|
+
for (const jobValue of Object.values(record.jobs)) {
|
|
120
|
+
if (typeof jobValue !== "object" || jobValue === null)
|
|
121
|
+
continue;
|
|
122
|
+
const jobObj = jobValue;
|
|
123
|
+
// reusable workflow uses
|
|
124
|
+
if (typeof jobObj.uses === "string" &&
|
|
125
|
+
hashToOriginal.has(jobObj.uses)) {
|
|
126
|
+
jobObj.uses = hashToOriginal.get(jobObj.uses);
|
|
127
|
+
}
|
|
128
|
+
// steps
|
|
129
|
+
if (Array.isArray(jobObj.steps)) {
|
|
130
|
+
for (const s of jobObj.steps) {
|
|
131
|
+
if (typeof s === "object" && s !== null) {
|
|
132
|
+
const stepObj = s;
|
|
133
|
+
if (typeof stepObj.uses === "string" &&
|
|
134
|
+
hashToOriginal.has(stepObj.uses)) {
|
|
135
|
+
stepObj.uses = hashToOriginal.get(stepObj.uses);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
return obj;
|
|
143
|
+
}
|
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;
|
|
@@ -43,7 +44,7 @@ export interface WorkflowTriggers {
|
|
|
43
44
|
export interface WorkflowConfig {
|
|
44
45
|
name: string;
|
|
45
46
|
runName?: string;
|
|
46
|
-
on: WorkflowTriggers;
|
|
47
|
+
on: WorkflowTriggers | string[];
|
|
47
48
|
permissions?: Permissions;
|
|
48
49
|
concurrency?: {
|
|
49
50
|
group: 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":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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) {
|
|
@@ -46,7 +47,9 @@ export class Workflow {
|
|
|
46
47
|
if (__classPrivateFieldGet(this, _Workflow_config, "f").runName != null) {
|
|
47
48
|
obj["run-name"] = __classPrivateFieldGet(this, _Workflow_config, "f").runName;
|
|
48
49
|
}
|
|
49
|
-
obj.on =
|
|
50
|
+
obj.on = Array.isArray(__classPrivateFieldGet(this, _Workflow_config, "f").on)
|
|
51
|
+
? __classPrivateFieldGet(this, _Workflow_config, "f").on
|
|
52
|
+
: serializeTriggers(__classPrivateFieldGet(this, _Workflow_config, "f").on);
|
|
50
53
|
if (__classPrivateFieldGet(this, _Workflow_config, "f").permissions != null) {
|
|
51
54
|
obj.permissions = __classPrivateFieldGet(this, _Workflow_config, "f").permissions;
|
|
52
55
|
}
|
|
@@ -110,24 +113,60 @@ export class Workflow {
|
|
|
110
113
|
fs.writeFileSync(path, this.toYamlString(options));
|
|
111
114
|
}
|
|
112
115
|
writeOrLint(options) {
|
|
116
|
+
const pinDeps = options.pinDeps ?? true;
|
|
113
117
|
const expected = this.toYamlString(options);
|
|
114
118
|
if (isLinting) {
|
|
115
119
|
const existing = fs.readFileSync(options.filePath, { encoding: "utf8" });
|
|
116
|
-
|
|
117
|
-
|
|
120
|
+
let parsedExisting;
|
|
121
|
+
let parsedExpected;
|
|
122
|
+
if (pinDeps) {
|
|
123
|
+
const pins = parsePinComments(existing);
|
|
124
|
+
parsedExisting = unpinParsedYaml(parse(existing), pins);
|
|
125
|
+
parsedExpected = parse(expected);
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
parsedExisting = parse(existing);
|
|
129
|
+
parsedExpected = parse(expected);
|
|
130
|
+
}
|
|
118
131
|
if (JSON.stringify(parsedExisting) !== JSON.stringify(parsedExpected)) {
|
|
119
132
|
console.error(`Error: ${options.filePath} is out of date. Run without --lint to update.`);
|
|
120
133
|
process.exit(1);
|
|
121
134
|
}
|
|
122
135
|
}
|
|
123
136
|
else {
|
|
124
|
-
|
|
137
|
+
let output = expected;
|
|
138
|
+
if (pinDeps) {
|
|
139
|
+
const resolve = typeof pinDeps === "object"
|
|
140
|
+
? pinDeps.resolve
|
|
141
|
+
: undefined;
|
|
142
|
+
// reuse previously resolved hashes from existing file to avoid
|
|
143
|
+
// redundant git ls-remote calls on subsequent runs
|
|
144
|
+
let cache;
|
|
145
|
+
if (!isUpdatingPins()) {
|
|
146
|
+
try {
|
|
147
|
+
const existing = fs.readFileSync(options.filePath, {
|
|
148
|
+
encoding: "utf8",
|
|
149
|
+
});
|
|
150
|
+
cache = parsePinComments(existing);
|
|
151
|
+
}
|
|
152
|
+
catch {
|
|
153
|
+
// file doesn't exist yet
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
const result = pinYamlContent(expected, resolve, cache);
|
|
157
|
+
output = result.content + formatPinComments(result.pins);
|
|
158
|
+
}
|
|
159
|
+
fs.writeFileSync(options.filePath, output);
|
|
125
160
|
}
|
|
126
161
|
}
|
|
127
162
|
}
|
|
128
163
|
_Workflow_config = new WeakMap(), _Workflow_jobs = new WeakMap();
|
|
129
164
|
/** Gets if linting would occur when using `writeOrLint` on a workflow. */
|
|
130
165
|
export const isLinting = process.argv.includes("--lint");
|
|
166
|
+
/** Gets if pins should be re-resolved when using `writeOrLint` on a workflow. */
|
|
167
|
+
export function isUpdatingPins() {
|
|
168
|
+
return process.argv.includes("--update-pins");
|
|
169
|
+
}
|
|
131
170
|
export function createWorkflow(config) {
|
|
132
171
|
return new Workflow(config);
|
|
133
172
|
}
|
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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AsDvB,WAAW,CAAC,EAAE,YAAY,EAAE,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
|