@mark1russell7/workflow-github 0.0.0-stage → 0.1.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/build/index.js ADDED
@@ -0,0 +1,1728 @@
1
+ import { WORKFLOW_OPS, checkWorkflow, getIn, isSecretRef, setIn, workflowMachineWith } from "@mark1russell7/workflow";
2
+ import { defineLanguage, fail, isEnvelope, isRecord } from "@mark1russell7/coeval";
3
+ import { isAlias, isScalar, isSeq, parseDocument, stringify, visit } from "yaml";
4
+ // src/inject.ts
5
+ /**
6
+ * The reads that are safe in a script: numbers, hashes, ids and names that GitHub limits to safe characters. Each other
7
+ * read is not safe. The list has full paths, because a person can write any key under `github.event.inputs`.
8
+ */
9
+ const TRUSTED_READS = /* @__PURE__ */ new Set([
10
+ "github.sha",
11
+ "github.run_id",
12
+ "github.run_number",
13
+ "github.run_attempt",
14
+ "github.repository",
15
+ "github.repository_id",
16
+ "github.repository_owner",
17
+ "github.repository_owner_id",
18
+ "github.event_name",
19
+ "github.workflow_sha",
20
+ "github.job",
21
+ "github.workspace",
22
+ "github.action_path",
23
+ "github.server_url",
24
+ "github.api_url",
25
+ "github.graphql_url",
26
+ "github.retention_days",
27
+ "github.actor",
28
+ "github.actor_id",
29
+ "github.triggering_actor",
30
+ "github.event.number",
31
+ "github.event.issue.number",
32
+ "github.event.pull_request.number",
33
+ "github.event.pull_request.head.sha",
34
+ "github.event.pull_request.base.sha",
35
+ "github.event.before",
36
+ "github.event.after",
37
+ "runner.os",
38
+ "runner.arch",
39
+ "runner.temp",
40
+ "runner.tool_cache",
41
+ "strategy.job-index",
42
+ "strategy.job-total"
43
+ ]);
44
+ /**
45
+ * This function gives the trust of a reference in a script. A read of the list `TRUSTED_READS` is safe. A read of
46
+ * `github.event` or `github.head_ref` comes from outside. Each other read is not known: an input, the output of a step,
47
+ * a value of `env` or the name of a branch.
48
+ *
49
+ * @param path - The path of the reference, for example `["names", "github", "event", "issue", "title"]`.
50
+ * @returns The trust.
51
+ */
52
+ function readTrust(path) {
53
+ if (path[0] === "names" && TRUSTED_READS.has(path.slice(1).map(String).join("."))) return "trusted";
54
+ if (path[0] === "names" && path[1] === "github" && (path[2] === "event" || path[2] === "head_ref")) return "outside";
55
+ return "unknown";
56
+ }
57
+ /** This function gives the references in a document that are not safe in a script. */
58
+ function unsafeRefs(doc, out = []) {
59
+ if (Array.isArray(doc)) for (const item of doc) unsafeRefs(item, out);
60
+ else if (isRecord(doc)) {
61
+ const record = doc;
62
+ if (record["type"] === "ref" && Array.isArray(record["value"])) {
63
+ if (readTrust(record["value"]) !== "trusted") out.push(record["value"]);
64
+ } else for (const value of Object.values(record)) unsafeRefs(value, out);
65
+ }
66
+ return out;
67
+ }
68
+ const SHELL_LANGUAGES = {
69
+ bash: "sh",
70
+ sh: "sh",
71
+ pwsh: "pwsh",
72
+ powershell: "pwsh"
73
+ };
74
+ /** The parts of each language that the quote scanner does not read. Before such a part, the move refuses. */
75
+ const UNREAD_PARTS = {
76
+ sh: /<<|\$'|`|\$\(/,
77
+ pwsh: /@'|@"|\$\(|<#/,
78
+ js: /\$\{/
79
+ };
80
+ /**
81
+ * This function gives the open quote at the end of a text, or `""` outside a quote and in a comment. A part that the
82
+ * scanner does not read gives a refusal: a heredoc, a `$'...'` text, a command in a text, or a regular expression.
83
+ */
84
+ function openQuote(language, text) {
85
+ if (UNREAD_PARTS[language].test(text)) return { why: "The script has a part before the value that the move does not read: a heredoc, a command in a text or a nested template. Move the value by hand." };
86
+ const quotes = language === "js" ? "'\"`" : "'\"";
87
+ const escape = language === "pwsh" ? "`" : "\\";
88
+ let open = "";
89
+ for (let i = 0; i < text.length; i++) {
90
+ const char = text[i];
91
+ if (open === "") {
92
+ const comment = language === "js" ? text.startsWith("//", i) ? "\n" : text.startsWith("/*", i) ? "*/" : void 0 : char === "#" && (i === 0 || /\s/.test(text[i - 1])) ? "\n" : void 0;
93
+ if (comment !== void 0) {
94
+ const end = text.indexOf(comment, i + 2);
95
+ if (end < 0) return "";
96
+ i = end + comment.length - 1;
97
+ continue;
98
+ }
99
+ if (language === "js" && char === "/") return { why: "The script has a / before the value. It can be a regular expression, which the move does not read. Move the value by hand." };
100
+ if (char === escape) i++;
101
+ else if (quotes.includes(char)) open = char;
102
+ } else if (char === escape && (open !== "'" || language === "js")) i++;
103
+ else if (char === open) open = "";
104
+ }
105
+ return open;
106
+ }
107
+ /**
108
+ * This function gives the code that reads a variable at a place in a script, by the open quote there. A shell reads
109
+ * the variable in double quotes, thus the shell does not split the value. The result `undefined` means no safe form.
110
+ */
111
+ function readAt(language, quote, name) {
112
+ if (language === "sh") return quote === "\"" ? `\${${name}}` : quote === "'" ? `'"\${${name}}"'` : `"\${${name}}"`;
113
+ if (language === "pwsh") return quote === "\"" ? `\${env:${name}}` : quote === "'" ? void 0 : `"\${env:${name}}"`;
114
+ if (quote === "`") return `\${process.env.${name}}`;
115
+ return quote === "" ? `process.env.${name}` : `${quote} + process.env.${name} + ${quote}`;
116
+ }
117
+ /** This function gives the shell of a step: its own, the default of its job or of the workflow, or the default of the runner. */
118
+ function shellOf(doc, job, step) {
119
+ const named = [
120
+ getIn(step, [
121
+ "value",
122
+ "do",
123
+ "value",
124
+ "shell"
125
+ ]),
126
+ getIn(job, [
127
+ "value",
128
+ "layers",
129
+ "github",
130
+ "keys",
131
+ "defaults",
132
+ "run",
133
+ "shell"
134
+ ]),
135
+ getIn(doc, [
136
+ "value",
137
+ "layers",
138
+ "github",
139
+ "keys",
140
+ "defaults",
141
+ "run",
142
+ "shell"
143
+ ])
144
+ ].find((shell) => shell !== void 0);
145
+ if (named !== void 0) return typeof named === "string" ? named.trim().split(/\s+/)[0] ?? "" : void 0;
146
+ const runsOn = getIn(job, [
147
+ "value",
148
+ "layers",
149
+ "github",
150
+ "keys",
151
+ "runs-on"
152
+ ]);
153
+ if (typeof runsOn !== "string" || runsOn.includes("${{")) return void 0;
154
+ return /windows/i.test(runsOn) ? "pwsh" : "bash";
155
+ }
156
+ /** This function gives each script of a workflow: the `run` of a step, and the `script` input of `actions/github-script`. */
157
+ function scriptPlaces(doc) {
158
+ const places = [];
159
+ const jobs = getIn(doc, ["value", "jobs"]);
160
+ if (!isRecord(jobs)) return places;
161
+ for (const [id, job] of Object.entries(jobs)) {
162
+ const steps = getIn(job, ["value", "steps"]);
163
+ if (!Array.isArray(steps)) continue;
164
+ steps.forEach((step, index) => {
165
+ const at = [
166
+ "value",
167
+ "jobs",
168
+ id,
169
+ "value",
170
+ "steps",
171
+ index
172
+ ];
173
+ const kind = getIn(step, [
174
+ "value",
175
+ "do",
176
+ "type"
177
+ ]);
178
+ const call = Array.isArray(kind) ? kind[1] : void 0;
179
+ if (call === "run") {
180
+ const shell = shellOf(doc, job, step);
181
+ const language = shell === void 0 ? { why: "Set the shell of the step: the runner of the job is not a fixed text." } : SHELL_LANGUAGES[shell] ?? { why: `The move knows no safe form of an environment variable in the shell ${shell}.` };
182
+ places.push({
183
+ at: [
184
+ ...at,
185
+ "value",
186
+ "do",
187
+ "value",
188
+ "script"
189
+ ],
190
+ script: getIn(step, [
191
+ "value",
192
+ "do",
193
+ "value",
194
+ "script"
195
+ ]),
196
+ language
197
+ });
198
+ } else if (call === "action") {
199
+ const uses = getIn(step, [
200
+ "value",
201
+ "do",
202
+ "value",
203
+ "uses"
204
+ ]);
205
+ if (typeof uses === "string" && uses.startsWith("actions/github-script@")) places.push({
206
+ at: [
207
+ ...at,
208
+ "value",
209
+ "do",
210
+ "value",
211
+ "with",
212
+ "script"
213
+ ],
214
+ script: getIn(step, [
215
+ "value",
216
+ "do",
217
+ "value",
218
+ "with",
219
+ "script"
220
+ ]),
221
+ language: "js"
222
+ });
223
+ }
224
+ });
225
+ }
226
+ return places;
227
+ }
228
+ const refPathText = (path) => path.slice(1).map(String).join(".");
229
+ const samePath = (a, b) => a.length === b.length && a.every((key, index) => key === b[index]);
230
+ /** This function tells if a script has a text part with `${{`: an expression that no reader read. */
231
+ function hasRawExpression(script) {
232
+ if (typeof script === "string") return script.includes("${{");
233
+ if (isRecord(script) && script["type"] === "template" && Array.isArray(script["value"])) return script["value"].some((part) => typeof part === "string" && part.includes("${{"));
234
+ return false;
235
+ }
236
+ /**
237
+ * This function finds each script that reads an unsafe value with `${{ }}`. A read from outside the repository
238
+ * (`github.event`, `github.head_ref`) is an error. A read that is not known is a warning. Each problem has the code
239
+ * `script-injection`, and `moveToEnv` corrects it.
240
+ *
241
+ * A script with a text `${{` that no reader read is also an error, with the code `raw-expression`. The export
242
+ * writes it as an expression, but the check did not see it. A typed script with an open `${{` gives this error.
243
+ *
244
+ * @param doc - The workflow document.
245
+ * @returns The problems.
246
+ */
247
+ function scriptInjections(doc) {
248
+ const places = scriptPlaces(doc);
249
+ const issues = places.flatMap((place) => {
250
+ const refs = unsafeRefs(place.script);
251
+ if (refs.length === 0) return [];
252
+ const outside = refs.some((ref) => readTrust(ref) === "outside");
253
+ const names = [...new Set(refs.map(refPathText))].join(", ");
254
+ return [{
255
+ level: outside ? "error" : "warning",
256
+ code: "script-injection",
257
+ at: place.at,
258
+ message: outside ? `The script reads ${names} with \${{ }}. A person outside the repository can write this value as a command. Move the value to env.` : `The script reads ${names} with \${{ }}. If a person outside the repository sets this value, it becomes a command. Move the value to env.`
259
+ }];
260
+ });
261
+ for (const place of places.filter((item) => hasRawExpression(item.script))) issues.push({
262
+ level: "error",
263
+ code: "raw-expression",
264
+ at: place.at,
265
+ message: "This text has ${{ that no reader read. The export writes it as an expression that the check did not see. Correct the expression."
266
+ });
267
+ return issues;
268
+ }
269
+ const RESERVED = /^(GITHUB_|RUNNER_|ACTIONS_|CI$|HOME$|PATH$|[0-9])/;
270
+ /** This function gives the name of a variable for a reference: its last two keys, in upper case, not taken and not reserved. */
271
+ function variableName(path, taken) {
272
+ let base = (path.slice(2).filter((key) => typeof key === "string" && key !== "event" && key !== "outputs").slice(-2).join("_") || "VALUE").toUpperCase().replace(/[^A-Z0-9_]/g, "_");
273
+ if (RESERVED.test(base)) base = `V_${base}`;
274
+ if (!taken.has(base)) return base;
275
+ for (let n = 2;; n++) if (!taken.has(`${base}_${String(n)}`)) return `${base}_${String(n)}`;
276
+ }
277
+ const keysAt = (doc, at) => {
278
+ const value = getIn(doc, at);
279
+ return isRecord(value) ? Object.keys(value) : [];
280
+ };
281
+ /**
282
+ * This function moves each unsafe value of a script to `env` of its step. The script then reads the variable, and
283
+ * the shell does not read the value as code. The same value gets one variable. A new name is not a name of `env` of
284
+ * the job or of the workflow, thus the move hides no value.
285
+ *
286
+ * @param doc - The workflow document.
287
+ * @param at - The JSON path of the script, as the problem of `scriptInjections` gives it.
288
+ * @returns The new document, or the reason of a refusal.
289
+ */
290
+ function moveToEnv(doc, at) {
291
+ const place = scriptPlaces(doc).find((item) => samePath(item.at, at));
292
+ if (place === void 0) return {
293
+ ok: false,
294
+ why: "This path is not a script of a step."
295
+ };
296
+ const language = place.language;
297
+ if (typeof language !== "string") return {
298
+ ok: false,
299
+ why: language.why
300
+ };
301
+ const envAt = [
302
+ ...at.slice(0, at.indexOf("steps") + 2),
303
+ "value",
304
+ "env"
305
+ ];
306
+ const env = { ...isRecord(getIn(doc, envAt)) ? getIn(doc, envAt) : {} };
307
+ const byDoc = /* @__PURE__ */ new Map();
308
+ for (const [name, value] of Object.entries(env)) byDoc.set(JSON.stringify(value), name);
309
+ const taken = /* @__PURE__ */ new Set([
310
+ ...Object.keys(env),
311
+ ...keysAt(doc, [...at.slice(0, 4), "env"]),
312
+ ...keysAt(doc, ["value", "env"])
313
+ ]);
314
+ let before = "";
315
+ let refused;
316
+ const replace = (part) => {
317
+ const refs = unsafeRefs(part);
318
+ if (refs.length === 0) {
319
+ before += "\0";
320
+ return part;
321
+ }
322
+ const quote = openQuote(language, before);
323
+ const key = JSON.stringify(part);
324
+ const name = byDoc.get(key) ?? variableName(refs[0], taken);
325
+ const code = typeof quote === "string" ? readAt(language, quote, name) : void 0;
326
+ if (code === void 0) {
327
+ refused ??= typeof quote === "string" ? "The value is in a quote that does not read variables. Close the quote around the value first." : quote.why;
328
+ return part;
329
+ }
330
+ if (!byDoc.has(key)) {
331
+ taken.add(name);
332
+ byDoc.set(key, name);
333
+ env[name] = part;
334
+ }
335
+ before += "\0";
336
+ return code;
337
+ };
338
+ const script = place.script;
339
+ let next;
340
+ if (isRecord(script) && script["type"] === "template" && Array.isArray(script["value"])) {
341
+ const parts = script["value"].map((part) => {
342
+ if (typeof part !== "string") return replace(part);
343
+ before += part;
344
+ return part;
345
+ });
346
+ next = parts.every((part) => typeof part === "string") ? parts.join("") : {
347
+ type: "template",
348
+ value: parts
349
+ };
350
+ } else next = replace(script);
351
+ if (refused !== void 0) return {
352
+ ok: false,
353
+ why: refused
354
+ };
355
+ if (next === script) return {
356
+ ok: true,
357
+ doc
358
+ };
359
+ return {
360
+ ok: true,
361
+ doc: setIn(setIn(doc, at, next), envAt, env)
362
+ };
363
+ }
364
+ // src/language.ts
365
+ /** The version of the GitHub add-on language. */
366
+ const GITHUB_VERSION = "0.1.0";
367
+ const text = { shape: "text" };
368
+ const term = {
369
+ shape: "term",
370
+ of: "lit"
371
+ };
372
+ const terms = {
373
+ shape: "map",
374
+ item: term
375
+ };
376
+ /** This function stops an operation that only a GitHub runner can evaluate. */
377
+ const hostOnly = (name) => () => {
378
+ throw new TypeError(`${name} reads the state of a GitHub run. Only GitHub evaluates it.`);
379
+ };
380
+ /**
381
+ * The operations of GitHub beside the operations of the workflow language. They are an index into a value, the filter `.*`
382
+ * and the functions that read the state of a run on GitHub.
383
+ */
384
+ const OPS = {
385
+ at: ((...args) => {
386
+ const [value, key] = args;
387
+ if (isSecretRef(value)) throw new TypeError("The operation at cannot read a secret.");
388
+ if (Array.isArray(value) && typeof key === "number") return value[key] ?? null;
389
+ if (isRecord(value) && (typeof key === "string" || typeof key === "number")) {
390
+ const name = String(key).toLowerCase();
391
+ const found = Object.keys(value).find((own) => own.toLowerCase() === name);
392
+ return found === void 0 ? null : value[found];
393
+ }
394
+ return null;
395
+ }),
396
+ pluck: ((...args) => {
397
+ const [value, ...path] = args;
398
+ return (Array.isArray(value) ? value : isRecord(value) ? Object.values(value) : []).map((item) => path.reduce((at, key) => isRecord(at) ? at[String(key)] ?? null : null, item));
399
+ }),
400
+ hashFiles: hostOnly("hashFiles"),
401
+ success: hostOnly("success"),
402
+ always: hostOnly("always"),
403
+ cancelled: hostOnly("cancelled"),
404
+ failure: hostOnly("failure")
405
+ };
406
+ const SIGS = {
407
+ at: {
408
+ params: ["unknown", "unknown"],
409
+ to: "unknown"
410
+ },
411
+ pluck: {
412
+ params: ["unknown"],
413
+ rest: "unknown",
414
+ to: "unknown"
415
+ },
416
+ hashFiles: {
417
+ params: [],
418
+ rest: "text",
419
+ to: "text"
420
+ },
421
+ success: {
422
+ params: [],
423
+ to: "bool"
424
+ },
425
+ always: {
426
+ params: [],
427
+ to: "bool"
428
+ },
429
+ cancelled: {
430
+ params: [],
431
+ to: "bool"
432
+ },
433
+ failure: {
434
+ params: [],
435
+ to: "bool"
436
+ },
437
+ format: {
438
+ params: ["text"],
439
+ rest: "unknown",
440
+ to: "text"
441
+ }
442
+ };
443
+ /** The formula profile of GitHub: the operations of the workflow language and the operations of GitHub. */
444
+ const GITHUB_OPS = {
445
+ ops: {
446
+ ...WORKFLOW_OPS.ops,
447
+ ...OPS
448
+ },
449
+ ...WORKFLOW_OPS.lazy === void 0 ? {} : { lazy: WORKFLOW_OPS.lazy },
450
+ sigs: {
451
+ ...WORKFLOW_OPS.sigs,
452
+ ...SIGS
453
+ },
454
+ pure: WORKFLOW_OPS.pure === true ? true : [
455
+ ...WORKFLOW_OPS.pure ?? [],
456
+ "at",
457
+ "pluck"
458
+ ]
459
+ };
460
+ /** The GitHub add-on language: the namespace `github`. */
461
+ const GITHUB_LANGUAGE = defineLanguage({
462
+ name: "workflow-github",
463
+ version: GITHUB_VERSION,
464
+ world: { kinds: { github: { kinds: {
465
+ action: {
466
+ verbs: { eval: "github.host" },
467
+ parts: {
468
+ shape: "record",
469
+ fields: {
470
+ uses: text,
471
+ with: terms
472
+ },
473
+ required: ["uses"],
474
+ closed: true
475
+ },
476
+ summary: "A step that runs an action of GitHub, with its inputs."
477
+ },
478
+ run: {
479
+ verbs: { eval: "github.host" },
480
+ parts: {
481
+ shape: "record",
482
+ fields: {
483
+ script: term,
484
+ shell: term,
485
+ cwd: term
486
+ },
487
+ closed: true
488
+ },
489
+ summary: "A step that runs a script in the shell of a GitHub runner."
490
+ },
491
+ workflow: {
492
+ verbs: { eval: "github.host" },
493
+ parts: {
494
+ shape: "record",
495
+ fields: {
496
+ uses: text,
497
+ with: terms,
498
+ secrets: terms,
499
+ inherit: { shape: "none" }
500
+ },
501
+ required: ["uses"],
502
+ closed: true
503
+ },
504
+ summary: "A job that calls a reusable workflow of GitHub, with its inputs and secrets."
505
+ }
506
+ } } } },
507
+ code: { evaluators: { "github.host": () => fail("#CALC!", "Only GitHub runs this step.") } }
508
+ });
509
+ /**
510
+ * This function gives the machine of a GitHub workflow: the workflow language with the GitHub profile and the
511
+ * namespace `github`.
512
+ *
513
+ * @param more - The languages of other add-ons, in order.
514
+ * @returns The machine.
515
+ */
516
+ function githubMachine(...more) {
517
+ return workflowMachineWith(GITHUB_OPS, GITHUB_LANGUAGE, ...more);
518
+ }
519
+ /** The contexts of GitHub that an expression can read, beside the names of the workflow language. */
520
+ const GITHUB_NAMES = [
521
+ "github",
522
+ "vars",
523
+ "runner",
524
+ "strategy"
525
+ ];
526
+ /** The call namespaces of GitHub: an input of such a call can hold a secret. */
527
+ const GITHUB_CALLS = ["github"];
528
+ /** The values of the GitHub contexts that a builder offers at each position, as reference documents. */
529
+ const GITHUB_CONTEXT_CHOICES = [
530
+ ["github", "event_name"],
531
+ ["github", "ref"],
532
+ ["github", "ref_name"],
533
+ ["github", "sha"],
534
+ ["github", "actor"],
535
+ ["github", "repository"],
536
+ ["github", "run_id"],
537
+ [
538
+ "github",
539
+ "event",
540
+ "pull_request",
541
+ "number"
542
+ ],
543
+ ["github", "workspace"],
544
+ ["runner", "os"],
545
+ ["runner", "temp"]
546
+ ].map((path) => ({
547
+ group: String(path[0]),
548
+ label: path.join("."),
549
+ doc: {
550
+ type: "ref",
551
+ value: ["names", ...path]
552
+ }
553
+ }));
554
+ // src/expression.ts
555
+ /** The functions of GitHub, by their names in lower case. The value is the name of the operation. */
556
+ const GITHUB_FUNCTIONS = {
557
+ contains: "contains",
558
+ startswith: "startsWith",
559
+ endswith: "endsWith",
560
+ format: "format",
561
+ join: "join",
562
+ tojson: "toJSON",
563
+ fromjson: "fromJSON",
564
+ hashfiles: "hashFiles",
565
+ success: "success",
566
+ always: "always",
567
+ cancelled: "cancelled",
568
+ failure: "failure"
569
+ };
570
+ const BINARY = {
571
+ "||": {
572
+ prec: 1,
573
+ kind: "or"
574
+ },
575
+ "&&": {
576
+ prec: 2,
577
+ kind: "and"
578
+ },
579
+ "==": {
580
+ prec: 3,
581
+ kind: "eq"
582
+ },
583
+ "!=": {
584
+ prec: 3,
585
+ kind: "ne"
586
+ },
587
+ "<": {
588
+ prec: 4,
589
+ kind: "lt"
590
+ },
591
+ "<=": {
592
+ prec: 4,
593
+ kind: "le"
594
+ },
595
+ ">": {
596
+ prec: 4,
597
+ kind: "gt"
598
+ },
599
+ ">=": {
600
+ prec: 4,
601
+ kind: "ge"
602
+ }
603
+ };
604
+ const SYMBOL_OF = Object.fromEntries(Object.entries(BINARY).map(([symbol, { kind }]) => [kind, symbol]));
605
+ const PREC_NOT = 5;
606
+ const PREC_POSTFIX = 6;
607
+ var Stop = class extends Error {
608
+ issue;
609
+ constructor(issue) {
610
+ super(issue.message);
611
+ this.issue = issue;
612
+ }
613
+ };
614
+ const NAME = /^[A-Za-z_][A-Za-z0-9_-]*$/;
615
+ function tokenize(text) {
616
+ const out = [];
617
+ let i = 0;
618
+ while (i < text.length) {
619
+ const c = text[i];
620
+ if (/\s/.test(c)) {
621
+ i++;
622
+ continue;
623
+ }
624
+ const rest = text.slice(i);
625
+ const number = /^(0x[0-9a-fA-F]+|-?(\d+\.?\d*|\.\d+)([eE][+-]?\d+)?)/.exec(rest);
626
+ if (number !== null && (c !== "-" || /^-[\d.]/.test(rest))) {
627
+ out.push({
628
+ t: "num",
629
+ v: Number(number[0]),
630
+ at: i
631
+ });
632
+ i += number[0].length;
633
+ continue;
634
+ }
635
+ if (c === "'") {
636
+ let value = "";
637
+ let j = i + 1;
638
+ for (;;) {
639
+ if (j >= text.length) throw new Stop({
640
+ offset: i,
641
+ message: "A text has no end quote."
642
+ });
643
+ if (text[j] === "'") {
644
+ if (text[j + 1] === "'") {
645
+ value += "'";
646
+ j += 2;
647
+ continue;
648
+ }
649
+ break;
650
+ }
651
+ value += text[j];
652
+ j++;
653
+ }
654
+ out.push({
655
+ t: "str",
656
+ v: value,
657
+ at: i
658
+ });
659
+ i = j + 1;
660
+ continue;
661
+ }
662
+ const name = /^[A-Za-z_][A-Za-z0-9_-]*/.exec(rest);
663
+ if (name !== null) {
664
+ out.push({
665
+ t: "id",
666
+ v: name[0],
667
+ at: i
668
+ });
669
+ i += name[0].length;
670
+ continue;
671
+ }
672
+ const op = [
673
+ "&&",
674
+ "||",
675
+ "==",
676
+ "!=",
677
+ "<=",
678
+ ">=",
679
+ "<",
680
+ ">",
681
+ "!",
682
+ "(",
683
+ ")",
684
+ "[",
685
+ "]",
686
+ ".",
687
+ ",",
688
+ "*"
689
+ ].find((symbol) => rest.startsWith(symbol));
690
+ if (op === void 0) throw new Stop({
691
+ offset: i,
692
+ message: `The character ${JSON.stringify(c)} is not part of an expression.`
693
+ });
694
+ out.push({
695
+ t: "op",
696
+ v: op,
697
+ at: i
698
+ });
699
+ i += op.length;
700
+ }
701
+ out.push({
702
+ t: "end",
703
+ at: text.length
704
+ });
705
+ return out;
706
+ }
707
+ const refDoc = (path) => ({
708
+ type: "ref",
709
+ value: ["names", ...path]
710
+ });
711
+ const op = (name, args) => ({
712
+ type: ["ops", name],
713
+ value: args
714
+ });
715
+ const isRef = (doc) => isEnvelope(doc) && doc.type === "ref" && Array.isArray(doc.value);
716
+ var Parser = class {
717
+ i = 0;
718
+ tokens;
719
+ constructor(tokens) {
720
+ this.tokens = tokens;
721
+ }
722
+ peek() {
723
+ return this.tokens[this.i];
724
+ }
725
+ next() {
726
+ return this.tokens[this.i++];
727
+ }
728
+ isOp(symbol) {
729
+ const token = this.peek();
730
+ return token.t === "op" && token.v === symbol;
731
+ }
732
+ expect(symbol) {
733
+ const token = this.next();
734
+ if (token.t !== "op" || token.v !== symbol) throw new Stop({
735
+ offset: token.at,
736
+ message: `The expression needs ${symbol} here.`
737
+ });
738
+ }
739
+ parse() {
740
+ const doc = this.binary(1);
741
+ const token = this.peek();
742
+ if (token.t !== "end") throw new Stop({
743
+ offset: token.at,
744
+ message: "The expression has more text after its end."
745
+ });
746
+ return doc;
747
+ }
748
+ binary(min) {
749
+ let left = this.unary();
750
+ for (;;) {
751
+ const token = this.peek();
752
+ const info = token.t === "op" ? BINARY[token.v] : void 0;
753
+ if (info === void 0 || info.prec < min) return left;
754
+ this.next();
755
+ const right = this.binary(info.prec + 1);
756
+ if (info.kind === "and" || info.kind === "or") {
757
+ const terms = isEnvelope(left) && left.type === info.kind && Array.isArray(left.value) && !left.group ? [...left.value, right] : [left, right];
758
+ left = {
759
+ type: info.kind,
760
+ value: terms
761
+ };
762
+ } else left = op(info.kind, [left, right]);
763
+ }
764
+ }
765
+ unary() {
766
+ if (this.isOp("!")) {
767
+ this.next();
768
+ return op("not", [this.unary()]);
769
+ }
770
+ return this.postfix(this.primary());
771
+ }
772
+ postfix(start) {
773
+ let doc = start;
774
+ let pluck;
775
+ for (;;) {
776
+ if (this.isOp(".")) {
777
+ this.next();
778
+ const token = this.next();
779
+ if (token.t === "op" && token.v === "*") {
780
+ pluck = [doc];
781
+ doc = op("pluck", pluck);
782
+ continue;
783
+ }
784
+ if (token.t !== "id") throw new Stop({
785
+ offset: token.at,
786
+ message: "A name or * comes after a dot."
787
+ });
788
+ doc = this.step(doc, token.v, pluck);
789
+ continue;
790
+ }
791
+ if (this.isOp("[")) {
792
+ this.next();
793
+ const index = this.binary(1);
794
+ this.expect("]");
795
+ pluck = void 0;
796
+ doc = typeof index === "string" || typeof index === "number" ? this.step(doc, index, void 0) : op("at", [doc, index]);
797
+ continue;
798
+ }
799
+ return doc;
800
+ }
801
+ }
802
+ step(doc, key, pluck) {
803
+ if (pluck !== void 0) {
804
+ pluck.push(key);
805
+ return doc;
806
+ }
807
+ if (isRef(doc)) return {
808
+ type: "ref",
809
+ value: [...doc.value, key]
810
+ };
811
+ return op("at", [doc, key]);
812
+ }
813
+ primary() {
814
+ const token = this.next();
815
+ switch (token.t) {
816
+ case "num":
817
+ case "str": return token.v;
818
+ case "id":
819
+ if (this.isOp("(")) {
820
+ const name = GITHUB_FUNCTIONS[token.v.toLowerCase()];
821
+ if (name === void 0) throw new Stop({
822
+ offset: token.at,
823
+ message: `GitHub has no function ${token.v}.`
824
+ });
825
+ this.next();
826
+ const args = [];
827
+ if (!this.isOp(")")) {
828
+ args.push(this.binary(1));
829
+ while (this.isOp(",")) {
830
+ this.next();
831
+ args.push(this.binary(1));
832
+ }
833
+ }
834
+ this.expect(")");
835
+ return op(name, args);
836
+ }
837
+ if (token.v === "true") return true;
838
+ if (token.v === "false") return false;
839
+ if (token.v === "null") return null;
840
+ return refDoc([token.v]);
841
+ case "op":
842
+ if (token.v === "(") {
843
+ const doc = this.binary(1);
844
+ this.expect(")");
845
+ return isEnvelope(doc) && (doc.type === "and" || doc.type === "or") ? Object.defineProperty({ ...doc }, "group", {
846
+ value: true,
847
+ enumerable: false
848
+ }) : doc;
849
+ }
850
+ throw new Stop({
851
+ offset: token.at,
852
+ message: `The expression cannot start with ${token.v} here.`
853
+ });
854
+ default: throw new Stop({
855
+ offset: token.at,
856
+ message: "The expression has no term here."
857
+ });
858
+ }
859
+ }
860
+ };
861
+ /** This function changes a reference `secrets.NAME` into a secret document, at each depth of a document. */
862
+ function secretsOf(doc) {
863
+ if (Array.isArray(doc)) return doc.map(secretsOf);
864
+ if (!isRecord(doc)) return doc;
865
+ if (isRef(doc) && doc.value.length === 3 && doc.value[1] === "secrets" && typeof doc.value[2] === "string") return {
866
+ type: "secret",
867
+ value: doc.value[2]
868
+ };
869
+ if (isEnvelope(doc)) return {
870
+ type: doc.type,
871
+ value: secretsOf(doc.value)
872
+ };
873
+ return doc;
874
+ }
875
+ /**
876
+ * This function reads a GitHub expression, the text between `${{` and `}}`, into a document of the formula kit.
877
+ *
878
+ * - A context is a reference from `names`, for example `inputs.version` gives `["names", "inputs", "version"]`.
879
+ * - `secrets.NAME` gives the secret document `{ type: "secret", value: "NAME" }`.
880
+ * - The operators give `and`, `or` and the operations `not`, `eq`, `ne`, `lt`, `le`, `gt` and `ge`.
881
+ * - An index of a value that is not a reference gives the operation `at`, and `.*` gives the operation `pluck`.
882
+ * - A literal at the top gives a `lit` document, thus a text part of a template stays different from a literal.
883
+ *
884
+ * @param text - The text of the expression.
885
+ * @returns The document, or the problem with its offset.
886
+ */
887
+ function parseExpression(text) {
888
+ try {
889
+ const doc = secretsOf(new Parser(tokenize(text)).parse());
890
+ return {
891
+ ok: true,
892
+ doc: isEnvelope(doc) ? doc : {
893
+ type: "lit",
894
+ value: doc
895
+ }
896
+ };
897
+ } catch (error) {
898
+ if (error instanceof Stop) return {
899
+ ok: false,
900
+ issue: error.issue
901
+ };
902
+ throw error;
903
+ }
904
+ }
905
+ function literal(value) {
906
+ if (typeof value === "string") return `'${value.replace(/'/g, "''")}'`;
907
+ if (typeof value === "number" || typeof value === "boolean" || value === null) return String(value);
908
+ throw new TypeError(`The value ${JSON.stringify(value)} has no text in a GitHub expression.`);
909
+ }
910
+ function pathKeyText(key) {
911
+ return typeof key === "string" && NAME.test(key) ? `.${key}` : `[${literal(key)}]`;
912
+ }
913
+ function printGitHubExpr(doc, min) {
914
+ if (!isEnvelope(doc)) return literal(doc);
915
+ const type = Array.isArray(doc.type) ? doc.type.join(".") : String(doc.type);
916
+ const args = Array.isArray(doc.value) ? doc.value : [];
917
+ const group = (prec, text) => prec < min ? `(${text})` : text;
918
+ switch (type) {
919
+ case "lit": return literal(doc.value);
920
+ case "ref": {
921
+ const [, root, ...steps] = args;
922
+ return `${String(root)}${steps.map(pathKeyText).join("")}`;
923
+ }
924
+ case "secret": return `secrets${pathKeyText(doc.value)}`;
925
+ case "and":
926
+ case "or": {
927
+ const prec = type === "and" ? 2 : 1;
928
+ return group(prec, args.map((arg) => printGitHubExpr(arg, prec + 1)).join(type === "and" ? " && " : " || "));
929
+ }
930
+ case "ops.not": return group(PREC_NOT, `!${printGitHubExpr(args[0], PREC_NOT)}`);
931
+ case "ops.at": return `${printGitHubExpr(args[0], PREC_POSTFIX)}${isEnvelope(args[1]) ? `[${printGitHubExpr(args[1], 1)}]` : pathKeyText(args[1])}`;
932
+ case "ops.pluck": return `${printGitHubExpr(args[0], PREC_POSTFIX)}.*${args.slice(1).map(pathKeyText).join("")}`;
933
+ default: {
934
+ const kind = type.startsWith("ops.") ? type.slice(4) : type;
935
+ const symbol = SYMBOL_OF[kind];
936
+ if (symbol !== void 0) {
937
+ const prec = BINARY[symbol].prec;
938
+ return group(prec, `${printGitHubExpr(args[0], prec)} ${symbol} ${printGitHubExpr(args[1], prec + 1)}`);
939
+ }
940
+ if (type.startsWith("ops.")) return `${kind}(${args.map((arg) => printGitHubExpr(arg, 1)).join(", ")})`;
941
+ throw new TypeError(`The kind ${type} has no text in a GitHub expression.`);
942
+ }
943
+ }
944
+ }
945
+ /**
946
+ * This function writes a document of the formula kit as a GitHub expression, without `${{` and `}}`. The text is
947
+ * the canonical text: one space around each operator, and the GitHub names of the functions.
948
+ *
949
+ * @param doc - The document.
950
+ * @returns The text.
951
+ */
952
+ function printExpression(doc) {
953
+ return printGitHubExpr(doc, 1);
954
+ }
955
+ /**
956
+ * This function splits a text at each `${{ ... }}`. The end of an expression is the first `}}` outside a quoted text.
957
+ *
958
+ * @param text - The text.
959
+ * @returns The parts, or `undefined` when an expression has no end.
960
+ */
961
+ function splitText(text) {
962
+ const parts = [];
963
+ let i = 0;
964
+ while (i < text.length) {
965
+ const start = text.indexOf("${{", i);
966
+ if (start < 0) {
967
+ parts.push({ text: text.slice(i) });
968
+ break;
969
+ }
970
+ if (start > i) parts.push({ text: text.slice(i, start) });
971
+ let j = start + 3;
972
+ let quoted = false;
973
+ while (j < text.length) {
974
+ if (text[j] === "'") quoted = !quoted;
975
+ else if (!quoted && text.startsWith("}}", j)) break;
976
+ j++;
977
+ }
978
+ if (j >= text.length) return void 0;
979
+ parts.push({
980
+ source: text.slice(start + 3, j),
981
+ offset: start + 3
982
+ });
983
+ i = j + 2;
984
+ }
985
+ return parts;
986
+ }
987
+ // src/yaml.ts
988
+ /** The name of the format of the layer of the add-on. */
989
+ const GITHUB_LAYER = "github/1";
990
+ /** The kernel test of a record, with a type that the import can change. */
991
+ const isPlain = (value) => isRecord(value);
992
+ const defined = (record) => Object.fromEntries(Object.entries(record).filter(([, value]) => value !== void 0));
993
+ const nonEmpty = (record) => Object.keys(record).length > 0 ? record : void 0;
994
+ /** This function tells if two JSON values are equal. The order of the keys of a record does not count. */
995
+ function sameJson(a, b) {
996
+ if (a === b) return true;
997
+ if (Array.isArray(a)) return Array.isArray(b) && a.length === b.length && a.every((item, index) => sameJson(item, b[index]));
998
+ if (isPlain(a) && isPlain(b)) {
999
+ const keys = Object.keys(a);
1000
+ return keys.length === Object.keys(b).length && keys.every((key) => Object.hasOwn(b, key) && sameJson(a[key], b[key]));
1001
+ }
1002
+ return Number.isNaN(a) && Number.isNaN(b);
1003
+ }
1004
+ /**
1005
+ * This function reads a text value of GitHub. A text without `${{` stays a text, unless it is a condition. A text that
1006
+ * is one expression gives its document. Another text with expressions gives a `template`. A text with a bad expression
1007
+ * stays a text, with a problem.
1008
+ *
1009
+ * @param text - The text.
1010
+ * @param condition - `true` for the text of `if`, which is an expression without `${{ }}`.
1011
+ * @returns The value and the problems.
1012
+ */
1013
+ function readText(text, condition = false) {
1014
+ const problems = [];
1015
+ const value = textValueOf(text, condition, problems);
1016
+ return {
1017
+ value: value === void 0 ? text : value,
1018
+ problems
1019
+ };
1020
+ }
1021
+ /** This function gives the document of a text, or `undefined` when the text stays a text. */
1022
+ function textValueOf(text, condition, problems) {
1023
+ const parts = splitText(text);
1024
+ if (parts === void 0) {
1025
+ problems.push("An expression has no end }}. The value stays a text.");
1026
+ return;
1027
+ }
1028
+ const read = (source, offset) => {
1029
+ const result = parseExpression(source);
1030
+ if (result.ok) return result.doc;
1031
+ problems.push(`At ${offset + result.issue.offset}: ${result.issue.message} The value stays a text.`);
1032
+ };
1033
+ let doc;
1034
+ const only = parts.length === 1 ? parts[0] : void 0;
1035
+ if (only !== void 0 && "source" in only) doc = read(only.source, only.offset);
1036
+ else if (parts.every((part) => "text" in part)) {
1037
+ if (!condition) return void 0;
1038
+ doc = read(text, 0);
1039
+ } else {
1040
+ const value = [];
1041
+ for (const part of parts) if ("text" in part) value.push(part.text);
1042
+ else {
1043
+ const expr = read(part.source, part.offset);
1044
+ if (expr === void 0) return void 0;
1045
+ value.push(expr);
1046
+ }
1047
+ doc = {
1048
+ type: "template",
1049
+ value
1050
+ };
1051
+ }
1052
+ return doc;
1053
+ }
1054
+ /** This function reads a YAML text value of a file, and keeps its source text for the export. */
1055
+ function textDoc(state, text, condition, at) {
1056
+ const problems = [];
1057
+ const doc = textValueOf(text, condition, problems);
1058
+ for (const message of problems) state.issues.push({
1059
+ level: "warning",
1060
+ at,
1061
+ message
1062
+ });
1063
+ if (doc === void 0) return text;
1064
+ (state.texts[JSON.stringify(doc)] ??= []).push(text);
1065
+ return doc;
1066
+ }
1067
+ const termOf = (state, value, at, condition = false) => typeof value === "string" ? textDoc(state, value, condition, at) : value;
1068
+ const termsOf = (state, record, at) => Object.fromEntries(Object.entries(record).map(([key, value]) => [key, termOf(state, value, [...at, key])]));
1069
+ /** This function writes a document as a YAML value: the source text when the document did not change, else new text. */
1070
+ function plainOf(state, value, condition = false) {
1071
+ if (!isEnvelope(value)) return value;
1072
+ const key = JSON.stringify(value);
1073
+ const texts = state.texts[key];
1074
+ if (texts !== void 0 && texts.length > 0) {
1075
+ const index = state.used[key] ?? 0;
1076
+ state.used[key] = index + 1;
1077
+ return texts[Math.min(index, texts.length - 1)];
1078
+ }
1079
+ if (value.type === "template" && Array.isArray(value.value)) return value.value.map((part) => typeof part === "string" ? part : `\${{ ${printExpression(part)} }}`).join("");
1080
+ const text = printExpression(value);
1081
+ return condition && !text.startsWith("!") ? text : `\${{ ${text} }}`;
1082
+ }
1083
+ const plainsOf = (state, record) => isPlain(record) ? Object.fromEntries(Object.entries(record).map(([key, value]) => [key, plainOf(state, value)])) : void 0;
1084
+ /** This function gives the seconds of a count of minutes when the conversion back is exact. */
1085
+ function secondsOf(minutes) {
1086
+ return typeof minutes === "number" && Number.isFinite(minutes) && minutes * 60 / 60 === minutes ? minutes * 60 : void 0;
1087
+ }
1088
+ function layerOf(record) {
1089
+ const github = nonEmpty(defined(record));
1090
+ return github === void 0 ? void 0 : { github };
1091
+ }
1092
+ function stepOf(state, step, at) {
1093
+ if (!isPlain(step)) {
1094
+ state.issues.push({
1095
+ level: "warning",
1096
+ at,
1097
+ message: "A step is not a map. The layer keeps it."
1098
+ });
1099
+ return {
1100
+ type: "step",
1101
+ value: {
1102
+ do: {
1103
+ type: ["github", "run"],
1104
+ value: {}
1105
+ },
1106
+ layers: { github: { raw: step } }
1107
+ }
1108
+ };
1109
+ }
1110
+ const { id, name, if: condition, uses, with: inputs, run, shell, "working-directory": cwd, env, "continue-on-error": goOn, "timeout-minutes": minutes, ...rest } = step;
1111
+ const gh = {};
1112
+ let call;
1113
+ if (uses !== void 0) {
1114
+ if (shell !== void 0) rest["shell"] = shell;
1115
+ if (cwd !== void 0) rest["working-directory"] = cwd;
1116
+ if (run !== void 0) rest["run"] = run;
1117
+ if (typeof uses !== "string") gh["uses"] = uses;
1118
+ if (inputs !== void 0 && !isPlain(inputs)) gh["with"] = inputs;
1119
+ call = {
1120
+ type: ["github", "action"],
1121
+ value: defined({
1122
+ uses: typeof uses === "string" ? uses : void 0,
1123
+ with: isPlain(inputs) ? termsOf(state, inputs, [...at, "with"]) : void 0
1124
+ })
1125
+ };
1126
+ } else {
1127
+ if (inputs !== void 0) rest["with"] = inputs;
1128
+ if (run === void 0) gh["noRun"] = true;
1129
+ call = {
1130
+ type: ["github", "run"],
1131
+ value: defined({
1132
+ script: run === void 0 ? void 0 : termOf(state, run, [...at, "run"]),
1133
+ shell: shell === void 0 ? void 0 : termOf(state, shell, [...at, "shell"]),
1134
+ cwd: cwd === void 0 ? void 0 : termOf(state, cwd, [...at, "working-directory"])
1135
+ })
1136
+ };
1137
+ }
1138
+ if (id !== void 0 && typeof id !== "string") gh["id"] = id;
1139
+ if (name !== void 0 && typeof name !== "string") gh["name"] = name;
1140
+ if (env !== void 0 && !isPlain(env)) gh["env"] = env;
1141
+ if (goOn !== void 0 && typeof goOn !== "boolean") gh["continue"] = goOn;
1142
+ const timeout = secondsOf(minutes);
1143
+ if (minutes !== void 0 && timeout === void 0) gh["timeout"] = minutes;
1144
+ gh["keys"] = nonEmpty(rest);
1145
+ return {
1146
+ type: "step",
1147
+ value: defined({
1148
+ id: typeof id === "string" ? id : void 0,
1149
+ name: typeof name === "string" ? name : void 0,
1150
+ if: condition === void 0 ? void 0 : termOf(state, condition, [...at, "if"], true),
1151
+ do: call,
1152
+ env: isPlain(env) ? termsOf(state, env, [...at, "env"]) : void 0,
1153
+ continue: typeof goOn === "boolean" ? goOn : void 0,
1154
+ timeout,
1155
+ layers: layerOf(gh)
1156
+ })
1157
+ };
1158
+ }
1159
+ function matrixOf(state, matrix, parallel, at) {
1160
+ if (!isPlain(matrix)) return {
1161
+ doc: termOf(state, matrix, at),
1162
+ parallelUsed: false
1163
+ };
1164
+ const { include, exclude, ...axes } = matrix;
1165
+ const whole = typeof parallel === "number" && Number.isInteger(parallel) && parallel >= 1;
1166
+ return {
1167
+ doc: {
1168
+ type: "matrix",
1169
+ value: defined({
1170
+ axes: termsOf(state, axes, at),
1171
+ include: include === void 0 ? void 0 : termOf(state, include, [...at, "include"]),
1172
+ exclude: exclude === void 0 ? void 0 : termOf(state, exclude, [...at, "exclude"]),
1173
+ parallel: whole ? parallel : void 0
1174
+ })
1175
+ },
1176
+ parallelUsed: whole
1177
+ };
1178
+ }
1179
+ function jobOf(state, job, at) {
1180
+ if (!isPlain(job)) {
1181
+ state.issues.push({
1182
+ level: "warning",
1183
+ at,
1184
+ message: "A job is not a map. The layer keeps it."
1185
+ });
1186
+ return {
1187
+ type: "job",
1188
+ value: {
1189
+ steps: [],
1190
+ layers: { github: { raw: job } }
1191
+ }
1192
+ };
1193
+ }
1194
+ const { name, needs, if: condition, env, outputs, "timeout-minutes": minutes, strategy, steps, uses, with: inputs, secrets, ...rest } = job;
1195
+ const gh = {};
1196
+ let stepDocs;
1197
+ if (Array.isArray(steps)) {
1198
+ if (uses !== void 0) rest["uses"] = uses;
1199
+ if (inputs !== void 0) rest["with"] = inputs;
1200
+ if (secrets !== void 0) rest["secrets"] = secrets;
1201
+ stepDocs = steps.map((step, index) => stepOf(state, step, [
1202
+ ...at,
1203
+ "steps",
1204
+ index
1205
+ ]));
1206
+ } else if (typeof uses === "string") {
1207
+ gh["reusable"] = true;
1208
+ if (steps !== void 0) gh["steps"] = steps;
1209
+ if (inputs !== void 0 && !isPlain(inputs)) gh["with"] = inputs;
1210
+ if (secrets !== void 0 && secrets !== "inherit" && !isPlain(secrets)) gh["secrets"] = secrets;
1211
+ stepDocs = [{
1212
+ type: "step",
1213
+ value: { do: {
1214
+ type: ["github", "workflow"],
1215
+ value: defined({
1216
+ uses,
1217
+ with: isPlain(inputs) ? termsOf(state, inputs, [...at, "with"]) : void 0,
1218
+ secrets: isPlain(secrets) ? termsOf(state, secrets, [...at, "secrets"]) : void 0,
1219
+ inherit: secrets === "inherit" ? true : void 0
1220
+ })
1221
+ } }
1222
+ }];
1223
+ } else {
1224
+ if (uses !== void 0) rest["uses"] = uses;
1225
+ if (inputs !== void 0) rest["with"] = inputs;
1226
+ if (secrets !== void 0) rest["secrets"] = secrets;
1227
+ if (steps !== void 0) gh["steps"] = steps;
1228
+ gh["noSteps"] = true;
1229
+ stepDocs = [];
1230
+ }
1231
+ let needList;
1232
+ if (typeof needs === "string") {
1233
+ needList = [needs];
1234
+ gh["needsText"] = true;
1235
+ } else if (Array.isArray(needs) && needs.every((need) => typeof need === "string")) needList = needs;
1236
+ else if (needs !== void 0) gh["needs"] = needs;
1237
+ let matrix;
1238
+ if (strategy !== void 0) {
1239
+ if (isPlain(strategy)) {
1240
+ const { matrix: m, "max-parallel": parallel, ...others } = strategy;
1241
+ const strategyRest = { ...others };
1242
+ if (m !== void 0) {
1243
+ const read = matrixOf(state, m, parallel, [
1244
+ ...at,
1245
+ "strategy",
1246
+ "matrix"
1247
+ ]);
1248
+ matrix = read.doc;
1249
+ if (!read.parallelUsed && parallel !== void 0) strategyRest["max-parallel"] = parallel;
1250
+ } else if (parallel !== void 0) strategyRest["max-parallel"] = parallel;
1251
+ gh["strategy"] = strategyRest;
1252
+ } else gh["strategyRaw"] = strategy;
1253
+ }
1254
+ if (name !== void 0 && typeof name !== "string") gh["name"] = name;
1255
+ if (env !== void 0 && !isPlain(env)) gh["env"] = env;
1256
+ if (outputs !== void 0 && !isPlain(outputs)) gh["outputs"] = outputs;
1257
+ const timeout = secondsOf(minutes);
1258
+ if (minutes !== void 0 && timeout === void 0) gh["timeout"] = minutes;
1259
+ gh["keys"] = nonEmpty(rest);
1260
+ return {
1261
+ type: "job",
1262
+ value: defined({
1263
+ name: typeof name === "string" ? name : void 0,
1264
+ needs: needList,
1265
+ if: condition === void 0 ? void 0 : termOf(state, condition, [...at, "if"], true),
1266
+ matrix,
1267
+ env: isPlain(env) ? termsOf(state, env, [...at, "env"]) : void 0,
1268
+ steps: stepDocs,
1269
+ outputs: isPlain(outputs) ? termsOf(state, outputs, [...at, "outputs"]) : void 0,
1270
+ timeout,
1271
+ layers: layerOf(gh)
1272
+ })
1273
+ };
1274
+ }
1275
+ const TRIGGER_KIND = {
1276
+ workflow_dispatch: "manual",
1277
+ workflow_call: "call",
1278
+ schedule: "schedule"
1279
+ };
1280
+ function addInputs(found, kind, inputs, layer) {
1281
+ for (const [name, def] of Object.entries(inputs)) {
1282
+ const known = found.inputs[name];
1283
+ if (known === void 0) found.inputs[name] = {
1284
+ ...isPlain(def) ? def : { value: def },
1285
+ on: [kind]
1286
+ };
1287
+ else if (isPlain(known) && isPlain(def) && sameJson({
1288
+ ...known,
1289
+ on: void 0
1290
+ }, {
1291
+ ...def,
1292
+ on: void 0
1293
+ }) && Array.isArray(known["on"])) known["on"].push(kind);
1294
+ else (layer["inputs"] ??= {})[name] = def;
1295
+ }
1296
+ }
1297
+ function triggersOf(state, on, gh) {
1298
+ const found = {
1299
+ triggers: [],
1300
+ inputs: {}
1301
+ };
1302
+ let entries;
1303
+ if (typeof on === "string") {
1304
+ gh["on"] = "text";
1305
+ entries = [[on, void 0]];
1306
+ } else if (Array.isArray(on)) {
1307
+ gh["on"] = "list";
1308
+ entries = on.map((event) => [String(event), void 0]);
1309
+ } else if (isPlain(on)) entries = Object.entries(on);
1310
+ else {
1311
+ gh["on"] = on === void 0 ? "none" : "raw";
1312
+ if (on !== void 0) gh["onRaw"] = on;
1313
+ entries = [];
1314
+ }
1315
+ for (const [event, config] of entries) {
1316
+ const at = ["on", event];
1317
+ const layer = { event };
1318
+ const kind = TRIGGER_KIND[event] ?? "event";
1319
+ if (kind === "schedule" && Array.isArray(config) && config.every((item) => isPlain(item) && typeof item["cron"] === "string")) {
1320
+ config.forEach((item, index) => {
1321
+ const { cron, ...more } = item;
1322
+ found.triggers.push({
1323
+ type: ["trigger", "schedule"],
1324
+ value: defined({
1325
+ cron,
1326
+ layers: layerOf({
1327
+ event,
1328
+ index,
1329
+ keys: nonEmpty(more)
1330
+ })
1331
+ })
1332
+ });
1333
+ });
1334
+ if (config.length === 0) found.triggers.push({
1335
+ type: ["trigger", "event"],
1336
+ value: {
1337
+ event,
1338
+ layers: { github: {
1339
+ event,
1340
+ config
1341
+ } }
1342
+ }
1343
+ });
1344
+ continue;
1345
+ }
1346
+ const value = {};
1347
+ if (config === null) layer["config"] = null;
1348
+ else if (isPlain(config)) {
1349
+ const rest = { ...config };
1350
+ if ((kind === "manual" || kind === "call") && isPlain(rest["inputs"]) && Object.keys(rest["inputs"]).length > 0) {
1351
+ addInputs(found, kind, rest["inputs"], layer);
1352
+ delete rest["inputs"];
1353
+ }
1354
+ if (kind === "call" && isPlain(rest["secrets"])) {
1355
+ found.secrets = rest["secrets"];
1356
+ delete rest["secrets"];
1357
+ }
1358
+ if (kind === "call" && isPlain(rest["outputs"]) && Object.values(rest["outputs"]).every((def) => isPlain(def) && "value" in def)) {
1359
+ const outputs = {};
1360
+ const meta = {};
1361
+ for (const [name, def] of Object.entries(rest["outputs"])) {
1362
+ const { value: expr, ...more } = def;
1363
+ outputs[name] = termOf(state, expr, [
1364
+ ...at,
1365
+ "outputs",
1366
+ name,
1367
+ "value"
1368
+ ]);
1369
+ meta[name] = more;
1370
+ }
1371
+ found.outputs = outputs;
1372
+ layer["outputs"] = meta;
1373
+ delete rest["outputs"];
1374
+ }
1375
+ if (kind === "event" && Array.isArray(rest["types"]) && rest["types"].every((type) => typeof type === "string")) {
1376
+ value["types"] = rest["types"];
1377
+ delete rest["types"];
1378
+ }
1379
+ layer["config"] = rest;
1380
+ } else if (config !== void 0) layer["raw"] = config;
1381
+ if (kind === "event") value["event"] = event;
1382
+ found.triggers.push({
1383
+ type: ["trigger", kind],
1384
+ value: {
1385
+ ...value,
1386
+ layers: { github: layer }
1387
+ }
1388
+ });
1389
+ }
1390
+ return found;
1391
+ }
1392
+ /**
1393
+ * This function reads the YAML of a GitHub workflow into a workflow document. It does not throw.
1394
+ *
1395
+ * - The parser is the `yaml` package. A text with anchors or aliases is refused.
1396
+ * - Each expression becomes a document, and the layer keeps its source text.
1397
+ * - Each key that the core does not model stays in the layer `github` of its workflow, job, step or trigger.
1398
+ * - The layer of the workflow keeps the source text, thus `toGitHub` changes only the edited values.
1399
+ *
1400
+ * @param text - The YAML text.
1401
+ * @param options - The name of the file and the workspace.
1402
+ * @returns The document and the problems.
1403
+ */
1404
+ function fromGitHub(text, options = {}) {
1405
+ const issues = [];
1406
+ const parsed = parseDocument(text, { prettyErrors: false });
1407
+ for (const error of parsed.errors) issues.push({
1408
+ level: "error",
1409
+ at: [],
1410
+ message: error.message
1411
+ });
1412
+ if (parsed.errors.length > 0) return {
1413
+ ok: false,
1414
+ issues
1415
+ };
1416
+ let shared = false;
1417
+ visit(parsed, (_key, node) => {
1418
+ if (isAlias(node) || typeof node === "object" && node !== null && "anchor" in node && typeof node.anchor === "string" && node.anchor !== "") {
1419
+ shared = true;
1420
+ return visit.BREAK;
1421
+ }
1422
+ });
1423
+ if (shared) return {
1424
+ ok: false,
1425
+ issues: [{
1426
+ level: "error",
1427
+ at: [],
1428
+ message: "The workflow has YAML anchors or aliases. Version 1 of the add-on does not read them."
1429
+ }]
1430
+ };
1431
+ const source = parsed.toJS();
1432
+ if (!isPlain(source)) return {
1433
+ ok: false,
1434
+ issues: [{
1435
+ level: "error",
1436
+ at: [],
1437
+ message: "A workflow is a map at the top."
1438
+ }]
1439
+ };
1440
+ const state = {
1441
+ issues,
1442
+ texts: {}
1443
+ };
1444
+ const { name, on, env, jobs, ...rest } = source;
1445
+ const gh = { format: GITHUB_LAYER };
1446
+ if (name === void 0) gh["unnamed"] = true;
1447
+ else if (typeof name !== "string") gh["name"] = name;
1448
+ const found = triggersOf(state, on, gh);
1449
+ const jobDocs = {};
1450
+ if (isPlain(jobs)) for (const [id, job] of Object.entries(jobs)) jobDocs[id] = jobOf(state, job, ["jobs", id]);
1451
+ else if (jobs !== void 0) gh["jobs"] = jobs;
1452
+ else gh["noJobs"] = true;
1453
+ if (env !== void 0 && !isPlain(env)) gh["env"] = env;
1454
+ gh["keys"] = nonEmpty(rest);
1455
+ gh["texts"] = state.texts;
1456
+ gh["source"] = text;
1457
+ return {
1458
+ ok: true,
1459
+ doc: {
1460
+ type: "workflow",
1461
+ value: defined({
1462
+ name: typeof name === "string" ? name : options.file ?? "workflow",
1463
+ workspace: options.workspace ?? "default",
1464
+ triggers: found.triggers,
1465
+ inputs: nonEmpty(found.inputs),
1466
+ secrets: found.secrets,
1467
+ env: isPlain(env) ? termsOf(state, env, ["env"]) : void 0,
1468
+ jobs: jobDocs,
1469
+ outputs: found.outputs,
1470
+ layers: { github: defined(gh) }
1471
+ })
1472
+ },
1473
+ issues
1474
+ };
1475
+ }
1476
+ const githubOf = (value) => {
1477
+ const layers = isPlain(value) ? value["layers"] : void 0;
1478
+ const github = isPlain(layers) ? layers["github"] : void 0;
1479
+ return isPlain(github) ? github : {};
1480
+ };
1481
+ const valueOf = (doc) => isEnvelope(doc) && isPlain(doc.value) ? doc.value : {};
1482
+ function stepOut(state, step) {
1483
+ const value = valueOf(step);
1484
+ const gh = githubOf(value);
1485
+ if ("raw" in gh) return gh["raw"];
1486
+ const call = valueOf(value["do"]);
1487
+ const kind = isEnvelope(value["do"]) && Array.isArray(value["do"].type) ? value["do"].type[1] : void 0;
1488
+ const out = {};
1489
+ if (value["id"] !== void 0 || gh["id"] !== void 0) out["id"] = value["id"] ?? gh["id"];
1490
+ if (value["name"] !== void 0 || gh["name"] !== void 0) out["name"] = value["name"] ?? gh["name"];
1491
+ if (value["if"] !== void 0) out["if"] = plainOf(state, value["if"], true);
1492
+ if (kind === "action") {
1493
+ out["uses"] = call["uses"] ?? gh["uses"];
1494
+ const inputs = plainsOf(state, call["with"]) ?? gh["with"];
1495
+ if (inputs !== void 0) out["with"] = inputs;
1496
+ } else {
1497
+ if (call["script"] !== void 0) out["run"] = plainOf(state, call["script"]);
1498
+ if (call["shell"] !== void 0) out["shell"] = plainOf(state, call["shell"]);
1499
+ if (call["cwd"] !== void 0) out["working-directory"] = plainOf(state, call["cwd"]);
1500
+ }
1501
+ const env = plainsOf(state, value["env"]) ?? gh["env"];
1502
+ if (env !== void 0) out["env"] = env;
1503
+ if (value["continue"] !== void 0 || gh["continue"] !== void 0) out["continue-on-error"] = value["continue"] ?? gh["continue"];
1504
+ if (typeof value["timeout"] === "number") out["timeout-minutes"] = value["timeout"] / 60;
1505
+ else if (gh["timeout"] !== void 0) out["timeout-minutes"] = gh["timeout"];
1506
+ return {
1507
+ ...out,
1508
+ ...isPlain(gh["keys"]) ? gh["keys"] : {}
1509
+ };
1510
+ }
1511
+ function matrixOut(state, matrix) {
1512
+ if (!isEnvelope(matrix) || matrix.type !== "matrix") return { matrix: plainOf(state, matrix) };
1513
+ const value = valueOf(matrix);
1514
+ const out = { ...plainsOf(state, value["axes"]) ?? {} };
1515
+ if (value["include"] !== void 0) out["include"] = plainOf(state, value["include"]);
1516
+ if (value["exclude"] !== void 0) out["exclude"] = plainOf(state, value["exclude"]);
1517
+ return value["parallel"] === void 0 ? { matrix: out } : {
1518
+ matrix: out,
1519
+ parallel: value["parallel"]
1520
+ };
1521
+ }
1522
+ function jobOut(state, job) {
1523
+ const value = valueOf(job);
1524
+ const gh = githubOf(value);
1525
+ if ("raw" in gh) return gh["raw"];
1526
+ const out = {};
1527
+ if (value["name"] !== void 0 || gh["name"] !== void 0) out["name"] = value["name"] ?? gh["name"];
1528
+ if (Array.isArray(value["needs"])) out["needs"] = gh["needsText"] === true && value["needs"].length === 1 ? value["needs"][0] : value["needs"];
1529
+ else if (gh["needs"] !== void 0) out["needs"] = gh["needs"];
1530
+ if (value["if"] !== void 0) out["if"] = plainOf(state, value["if"], true);
1531
+ if (value["matrix"] !== void 0 || isPlain(gh["strategy"])) {
1532
+ const strategy = { ...isPlain(gh["strategy"]) ? gh["strategy"] : {} };
1533
+ if (value["matrix"] !== void 0) {
1534
+ const read = matrixOut(state, value["matrix"]);
1535
+ strategy["matrix"] = read.matrix;
1536
+ if (read.parallel !== void 0) strategy["max-parallel"] = read.parallel;
1537
+ }
1538
+ out["strategy"] = strategy;
1539
+ } else if (gh["strategyRaw"] !== void 0) out["strategy"] = gh["strategyRaw"];
1540
+ const env = plainsOf(state, value["env"]) ?? gh["env"];
1541
+ if (env !== void 0) out["env"] = env;
1542
+ const steps = Array.isArray(value["steps"]) ? value["steps"] : [];
1543
+ if (gh["reusable"] === true && steps.length === 1) {
1544
+ const call = valueOf(valueOf(steps[0])["do"]);
1545
+ out["uses"] = call["uses"];
1546
+ const inputs = plainsOf(state, call["with"]) ?? gh["with"];
1547
+ if (inputs !== void 0) out["with"] = inputs;
1548
+ if (call["inherit"] === true) out["secrets"] = "inherit";
1549
+ else if (call["secrets"] !== void 0) out["secrets"] = plainsOf(state, call["secrets"]);
1550
+ else if (gh["secrets"] !== void 0) out["secrets"] = gh["secrets"];
1551
+ if (gh["steps"] !== void 0) out["steps"] = gh["steps"];
1552
+ } else if (gh["noSteps"] === true && steps.length === 0) {
1553
+ if (gh["steps"] !== void 0) out["steps"] = gh["steps"];
1554
+ } else out["steps"] = steps.map((step) => stepOut(state, step));
1555
+ const outputs = plainsOf(state, value["outputs"]) ?? gh["outputs"];
1556
+ if (outputs !== void 0) out["outputs"] = outputs;
1557
+ if (typeof value["timeout"] === "number") out["timeout-minutes"] = value["timeout"] / 60;
1558
+ else if (gh["timeout"] !== void 0) out["timeout-minutes"] = gh["timeout"];
1559
+ return {
1560
+ ...out,
1561
+ ...isPlain(gh["keys"]) ? gh["keys"] : {}
1562
+ };
1563
+ }
1564
+ const EVENT_OF = {
1565
+ manual: "workflow_dispatch",
1566
+ call: "workflow_call",
1567
+ schedule: "schedule"
1568
+ };
1569
+ function onOut(state, workflow, gh) {
1570
+ if (gh["on"] === "raw") return gh["onRaw"];
1571
+ const triggers = Array.isArray(workflow["triggers"]) ? workflow["triggers"] : [];
1572
+ const on = {};
1573
+ const inputs = isPlain(workflow["inputs"]) ? workflow["inputs"] : {};
1574
+ for (const trigger of triggers) {
1575
+ if (!isEnvelope(trigger) || !Array.isArray(trigger.type)) continue;
1576
+ const kind = String(trigger.type[1]);
1577
+ const value = valueOf(trigger);
1578
+ const layer = githubOf(value);
1579
+ const event = typeof layer["event"] === "string" ? layer["event"] : kind === "event" ? String(value["event"]) : EVENT_OF[kind] ?? kind;
1580
+ if (kind === "schedule") {
1581
+ const list = Array.isArray(on[event]) ? on[event] : [];
1582
+ list.push({
1583
+ cron: value["cron"],
1584
+ ...isPlain(layer["keys"]) ? layer["keys"] : {}
1585
+ });
1586
+ on[event] = list;
1587
+ continue;
1588
+ }
1589
+ if ("raw" in layer) {
1590
+ on[event] = layer["raw"];
1591
+ continue;
1592
+ }
1593
+ const config = isPlain(layer["config"]) ? { ...layer["config"] } : {};
1594
+ if (Array.isArray(value["types"])) config["types"] = value["types"];
1595
+ if (kind === "manual" || kind === "call") {
1596
+ const own = {};
1597
+ for (const [name, def] of Object.entries(inputs)) {
1598
+ if (!isPlain(def)) continue;
1599
+ const { on: takers, ...rest } = def;
1600
+ if (takers === void 0 || Array.isArray(takers) && takers.includes(kind)) own[name] = "value" in rest && Object.keys(rest).length === 1 ? rest["value"] : rest;
1601
+ }
1602
+ Object.assign(own, isPlain(layer["inputs"]) ? layer["inputs"] : {});
1603
+ if (Object.keys(own).length > 0) config["inputs"] = own;
1604
+ }
1605
+ if (kind === "call") {
1606
+ if (workflow["secrets"] !== void 0) config["secrets"] = workflow["secrets"];
1607
+ if (isPlain(workflow["outputs"])) {
1608
+ const meta = isPlain(layer["outputs"]) ? layer["outputs"] : {};
1609
+ config["outputs"] = Object.fromEntries(Object.entries(workflow["outputs"]).map(([name, expr]) => [name, {
1610
+ ...isPlain(meta[name]) ? meta[name] : {},
1611
+ value: plainOf(state, expr)
1612
+ }]));
1613
+ }
1614
+ }
1615
+ on[event] = layer["config"] === null && Object.keys(config).length === 0 ? null : layer["config"] === void 0 && Object.keys(config).length === 0 ? null : config;
1616
+ }
1617
+ if (gh["on"] === "text" || gh["on"] === "list") {
1618
+ const events = Object.keys(on);
1619
+ if (events.every((event) => on[event] === null)) return gh["on"] === "text" && events.length === 1 ? events[0] : events;
1620
+ }
1621
+ return on;
1622
+ }
1623
+ /**
1624
+ * This function writes a workflow document as the plain value of a GitHub workflow: the value that the YAML of the
1625
+ * file gives. Each expression gives its source text when its document did not change.
1626
+ *
1627
+ * @param doc - The workflow document.
1628
+ * @returns The value.
1629
+ */
1630
+ function toGitHubObject(doc) {
1631
+ const workflow = valueOf(doc);
1632
+ const gh = githubOf(workflow);
1633
+ const state = {
1634
+ texts: isPlain(gh["texts"]) ? gh["texts"] : {},
1635
+ used: {}
1636
+ };
1637
+ const out = {};
1638
+ if (gh["unnamed"] !== true) out["name"] = gh["name"] ?? workflow["name"];
1639
+ if (gh["on"] !== "none") out["on"] = onOut(state, workflow, gh);
1640
+ Object.assign(out, isPlain(gh["keys"]) ? gh["keys"] : {});
1641
+ const env = plainsOf(state, workflow["env"]) ?? gh["env"];
1642
+ if (env !== void 0) out["env"] = env;
1643
+ if (gh["noJobs"] !== true) out["jobs"] = isPlain(workflow["jobs"]) ? Object.fromEntries(Object.entries(workflow["jobs"]).map(([id, job]) => [id, jobOut(state, job)])) : gh["jobs"];
1644
+ return out;
1645
+ }
1646
+ /** This function changes the YAML tree at a path from the value `before` to the value `after`, and keeps the rest. */
1647
+ function patch(tree, path, before, after) {
1648
+ if (sameJson(before, after)) return;
1649
+ if (isPlain(before) && isPlain(after)) {
1650
+ for (const key of Object.keys(before)) if (!Object.hasOwn(after, key)) tree.deleteIn([...path, key]);
1651
+ for (const [key, value] of Object.entries(after)) if (Object.hasOwn(before, key)) patch(tree, [...path, key], before[key], value);
1652
+ else tree.setIn([...path, key], tree.createNode(value));
1653
+ return;
1654
+ }
1655
+ const node = path.length === 0 ? tree.contents : tree.getIn(path, true);
1656
+ if (Array.isArray(before) && Array.isArray(after) && isSeq(node)) {
1657
+ let head = 0;
1658
+ while (head < before.length && head < after.length && sameJson(before[head], after[head])) head++;
1659
+ let tail = 0;
1660
+ while (tail < before.length - head && tail < after.length - head && sameJson(before[before.length - 1 - tail], after[after.length - 1 - tail])) tail++;
1661
+ const removed = before.length - head - tail;
1662
+ const added = after.length - head - tail;
1663
+ if (removed === added) {
1664
+ for (let index = head; index < head + added; index++) patch(tree, [...path, index], before[index], after[index]);
1665
+ return;
1666
+ }
1667
+ node.items.splice(head, removed, ...after.slice(head, head + added).map((item) => tree.createNode(item)));
1668
+ return;
1669
+ }
1670
+ if (isScalar(node) && !isPlain(after) && !Array.isArray(after)) {
1671
+ node.value = after;
1672
+ return;
1673
+ }
1674
+ if (path.length === 0) tree.contents = tree.createNode(after);
1675
+ else tree.setIn(path, tree.createNode(after));
1676
+ }
1677
+ /**
1678
+ * This function writes a workflow document as the YAML of a GitHub workflow.
1679
+ *
1680
+ * - A document from `fromGitHub` keeps its source text in its layer. When the document did not change, the result is
1681
+ * that text, byte for byte.
1682
+ * - After an edit, the export changes only the edited values of the source tree. The comments and the forms of the
1683
+ * other values stay.
1684
+ * - A document with no source text gives new YAML.
1685
+ *
1686
+ * @param doc - The workflow document.
1687
+ * @returns The YAML text.
1688
+ */
1689
+ function toGitHub(doc) {
1690
+ const gh = githubOf(valueOf(doc));
1691
+ const after = toGitHubObject(doc);
1692
+ if (typeof gh["source"] === "string") {
1693
+ const tree = parseDocument(gh["source"]);
1694
+ const before = tree.toJS();
1695
+ if (sameJson(before, after)) return gh["source"];
1696
+ patch(tree, [], before, after);
1697
+ return tree.toString({
1698
+ lineWidth: 0,
1699
+ nullStr: ""
1700
+ });
1701
+ }
1702
+ return stringify(after, {
1703
+ lineWidth: 0,
1704
+ nullStr: ""
1705
+ });
1706
+ }
1707
+ // src/index.ts
1708
+ /**
1709
+ * This function checks a workflow from GitHub with the machine of the add-on. The contexts of GitHub are names, an
1710
+ * input of a `github` call can hold a secret, and the secrets of the repository need no declaration. A script that
1711
+ * reads an untrusted value with `${{ }}` is an error (`scriptInjections`).
1712
+ *
1713
+ * @param doc - The workflow document.
1714
+ * @param options - More options of `checkWorkflow`.
1715
+ * @returns The problems.
1716
+ */
1717
+ function checkGitHub(doc, options = {}) {
1718
+ return [...checkWorkflow(doc, {
1719
+ machine: githubMachine(),
1720
+ openSecrets: true,
1721
+ ...options,
1722
+ hostNames: [...GITHUB_NAMES, ...options.hostNames ?? []],
1723
+ callNamespaces: [...GITHUB_CALLS, ...options.callNamespaces ?? []]
1724
+ }), ...scriptInjections(doc)];
1725
+ }
1726
+ export { GITHUB_CALLS, GITHUB_CONTEXT_CHOICES, GITHUB_FUNCTIONS, GITHUB_LANGUAGE, GITHUB_LAYER, GITHUB_NAMES, GITHUB_OPS, GITHUB_VERSION, checkGitHub, fromGitHub, githubMachine, moveToEnv, parseExpression, printExpression, readText, readTrust, sameJson, scriptInjections, splitText, toGitHub, toGitHubObject };
1727
+
1728
+ //# sourceMappingURL=index.js.map