@factorialco/gat 2.2.0 → 2.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/dist/cli.js CHANGED
@@ -1,28 +1,33 @@
1
1
  #!/usr/bin/env node
2
- "use strict";
3
- var __importDefault = (this && this.__importDefault) || function (mod) {
4
- return (mod && mod.__esModule) ? mod : { "default": mod };
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
5
10
  };
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- const fs_1 = __importDefault(require("fs"));
8
- const path_1 = __importDefault(require("path"));
9
- const child_process_1 = require("child_process");
10
- const commander_1 = require("commander");
11
- const util_1 = require("util");
12
- const execPromise = (0, util_1.promisify)(child_process_1.exec);
13
- const folder = path_1.default.join(process.cwd(), ".github", "templates");
14
- const cli = new commander_1.Command();
11
+ import fs from "fs";
12
+ import path from "path";
13
+ import { exec } from "child_process";
14
+ import { Command } from "commander";
15
+ import { promisify } from "util";
16
+ const execPromise = promisify(exec);
17
+ const folder = path.join(process.cwd(), ".github", "templates");
18
+ const cli = new Command();
15
19
  cli
16
20
  .version("2.0.0")
17
21
  .description("Write your GitHub Actions workflows using TypeScript");
18
22
  cli
19
23
  .command("build")
20
24
  .description("Transpile all Gat templates into GitHub Actions workflows.")
21
- .action(async () => {
22
- if (!fs_1.default.existsSync(path_1.default.join(folder, "..", "workflows"))) {
23
- fs_1.default.mkdirSync(path_1.default.join(folder, "..", "workflows"));
25
+ .action(() => __awaiter(void 0, void 0, void 0, function* () {
26
+ var _a;
27
+ if (!fs.existsSync(path.join(folder, "..", "workflows"))) {
28
+ fs.mkdirSync(path.join(folder, "..", "workflows"));
24
29
  }
25
- await execPromise(`npx ts-node ${process.env["GAT_BUILD_FLAGS"] ?? "--swc -T"} ${path_1.default.join(folder, "index.ts")}`);
30
+ yield execPromise(`npx ts-node ${(_a = process.env["GAT_BUILD_FLAGS"]) !== null && _a !== void 0 ? _a : "--swc -T"} ${path.join(folder, "index.ts")}`);
26
31
  process.exit(0);
27
- });
32
+ }));
28
33
  cli.parse(process.argv);
package/dist/event.js CHANGED
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
package/dist/index.js CHANGED
@@ -1,5 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Workflow = void 0;
4
- const workflow_1 = require("./workflow");
5
- Object.defineProperty(exports, "Workflow", { enumerable: true, get: function () { return workflow_1.Workflow; } });
1
+ import { Workflow } from "./workflow";
2
+ export { Workflow, };
package/dist/job.js CHANGED
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
package/dist/step.js CHANGED
@@ -1,7 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isUseStep = void 0;
4
- const isUseStep = (step) => {
1
+ export const isUseStep = (step) => {
5
2
  return step.uses !== undefined;
6
3
  };
7
- exports.isUseStep = isUseStep;
package/dist/workflow.js CHANGED
@@ -1,21 +1,35 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
4
9
  };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.Workflow = void 0;
7
- const js_yaml_1 = require("js-yaml");
8
- const kebabCase_1 = __importDefault(require("lodash/kebabCase"));
9
- const fs_1 = __importDefault(require("fs"));
10
- const path_1 = __importDefault(require("path"));
11
- const util_1 = require("util");
12
- const node_fetch_1 = __importDefault(require("node-fetch"));
13
- const step_1 = require("./step");
14
- const writeFilePromise = (0, util_1.promisify)(fs_1.default.writeFile);
10
+ var __rest = (this && this.__rest) || function (s, e) {
11
+ var t = {};
12
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
13
+ t[p] = s[p];
14
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
15
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
16
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
17
+ t[p[i]] = s[p[i]];
18
+ }
19
+ return t;
20
+ };
21
+ import { dump } from "js-yaml";
22
+ import kebabCase from "lodash/kebabCase";
23
+ import fs from "fs";
24
+ import path from "path";
25
+ import { promisify } from "util";
26
+ import fetch from 'node-fetch';
27
+ import { isUseStep } from "./step";
28
+ const writeFilePromise = promisify(fs.writeFile);
15
29
  const DEFAULT_RUNNERS = ["ubuntu-22.04"];
16
30
  const chainAttackCache = {};
17
- const supplyChainAttack = async (step) => {
18
- if (!(0, step_1.isUseStep)(step))
31
+ const supplyChainAttack = (step) => __awaiter(void 0, void 0, void 0, function* () {
32
+ if (!isUseStep(step))
19
33
  return;
20
34
  const uses = step.uses;
21
35
  if (!uses)
@@ -26,16 +40,16 @@ const supplyChainAttack = async (step) => {
26
40
  if (!match)
27
41
  return uses;
28
42
  const { repository, version } = match.groups;
29
- const response = await (0, node_fetch_1.default)(`https://api.github.com/repos/${repository}/tags`);
30
- const tags = (await response.json());
43
+ const response = yield fetch(`https://api.github.com/repos/${repository}/tags`);
44
+ const tags = (yield response.json());
31
45
  const tag = tags.find((tag) => tag.name === version);
32
46
  if (!tag)
33
47
  return uses;
34
48
  const result = `${repository}@${tag.commit.sha}`;
35
49
  chainAttackCache[uses] = result;
36
50
  return result;
37
- };
38
- class Workflow {
51
+ });
52
+ export class Workflow {
39
53
  constructor(name) {
40
54
  this.name = name;
41
55
  this.events = [];
@@ -67,96 +81,88 @@ class Workflow {
67
81
  return "ubuntu-22.04";
68
82
  }
69
83
  assignRunner(runsOn) {
70
- const runnerName = runsOn ?? this.defaultRunner();
84
+ const runnerName = runsOn !== null && runsOn !== void 0 ? runsOn : this.defaultRunner();
71
85
  const isSelfHosted = !DEFAULT_RUNNERS.includes(runnerName);
72
86
  return isSelfHosted ? ["self-hosted", runnerName] : runnerName;
73
87
  }
74
- async compile(filepath) {
75
- const result = {
76
- name: this.name,
77
- on: Object.fromEntries(this.events.map(({ name, options }) => [
78
- name,
79
- options ? options : null,
80
- ])),
81
- concurrency: this.concurrencyGroup
82
- ? {
83
- group: this.concurrencyGroup.groupSuffix,
84
- "cancel-in-progress": this.concurrencyGroup.cancelPrevious,
85
- }
86
- : undefined,
87
- defaults: this.defaultOptions
88
- ? {
89
- run: {
90
- "working-directory": this.defaultOptions.workingDirectory,
91
- },
92
- }
93
- : undefined,
94
- env: this.env.length > 0
95
- ? Object.fromEntries(this.env.map(({ name, value }) => [name, value]))
96
- : undefined,
97
- jobs: Object.fromEntries(await Promise.all(this.jobs.map(async ({ name, options: { prettyName, permissions, ifExpression, runsOn, matrix, env, steps, dependsOn, services, timeout, concurrency, outputs, workingDirectory, }, }) => [
98
- name,
99
- {
100
- name: prettyName,
101
- permissions,
102
- if: ifExpression,
103
- "runs-on": this.assignRunner(runsOn),
104
- "timeout-minutes": timeout ?? 15,
105
- needs: dependsOn,
106
- services,
107
- concurrency: concurrency
108
- ? {
109
- group: `${(0, kebabCase_1.default)(this.name)}-${name}-${concurrency.groupSuffix}`,
110
- "cancel-in-progress": concurrency.cancelPrevious,
111
- }
112
- : undefined,
113
- strategy: matrix
114
- ? {
115
- "fail-fast": false,
116
- matrix: typeof matrix === "string"
117
- ? matrix
118
- : {
119
- ...Object.fromEntries(matrix.elements.map(({ id, options }) => [
120
- id,
121
- options,
122
- ])),
123
- include: matrix.extra,
124
- },
125
- }
126
- : undefined,
127
- env,
128
- defaults: workingDirectory
129
- ? {
130
- run: {
131
- "working-directory": workingDirectory,
132
- },
133
- }
134
- : undefined,
135
- steps: await Promise.all(steps.map(async (step) => {
136
- const { id, name, ifExpression, workingDirectory, continueOnError, timeout, ...options } = step;
137
- return {
138
- id,
139
- name,
88
+ compile(filepath) {
89
+ return __awaiter(this, void 0, void 0, function* () {
90
+ const result = {
91
+ name: this.name,
92
+ on: Object.fromEntries(this.events.map(({ name, options }) => [
93
+ name,
94
+ options ? options : null,
95
+ ])),
96
+ concurrency: this.concurrencyGroup
97
+ ? {
98
+ group: this.concurrencyGroup.groupSuffix,
99
+ "cancel-in-progress": this.concurrencyGroup.cancelPrevious,
100
+ }
101
+ : undefined,
102
+ defaults: this.defaultOptions
103
+ ? {
104
+ run: {
105
+ "working-directory": this.defaultOptions.workingDirectory,
106
+ },
107
+ }
108
+ : undefined,
109
+ env: this.env.length > 0
110
+ ? Object.fromEntries(this.env.map(({ name, value }) => [name, value]))
111
+ : undefined,
112
+ jobs: Object.fromEntries(yield Promise.all(this.jobs.map(({ name, options: { prettyName, permissions, ifExpression, runsOn, matrix, env, steps, dependsOn, services, timeout, concurrency, outputs, workingDirectory, }, }) => __awaiter(this, void 0, void 0, function* () {
113
+ return [
114
+ name,
115
+ {
116
+ name: prettyName,
117
+ permissions,
140
118
  if: ifExpression,
141
- "continue-on-error": continueOnError,
142
- "working-directory": workingDirectory,
143
- "timeout-minutes": timeout,
144
- ...options,
145
- uses: await supplyChainAttack(step),
146
- };
147
- })),
148
- outputs,
149
- },
150
- ]))),
151
- };
152
- const compiled = `# Workflow automatically generated by gat\n# DO NOT CHANGE THIS FILE MANUALLY\n\n${(0, js_yaml_1.dump)(result, {
153
- noRefs: true,
154
- lineWidth: 200,
155
- noCompatMode: true,
156
- })}`;
157
- if (!filepath)
158
- return compiled;
159
- return writeFilePromise(path_1.default.join(process.cwd(), ".github", "workflows", filepath), compiled);
119
+ "runs-on": this.assignRunner(runsOn),
120
+ "timeout-minutes": timeout !== null && timeout !== void 0 ? timeout : 15,
121
+ needs: dependsOn,
122
+ services,
123
+ concurrency: concurrency
124
+ ? {
125
+ group: `${kebabCase(this.name)}-${name}-${concurrency.groupSuffix}`,
126
+ "cancel-in-progress": concurrency.cancelPrevious,
127
+ }
128
+ : undefined,
129
+ strategy: matrix
130
+ ? {
131
+ "fail-fast": false,
132
+ matrix: typeof matrix === "string"
133
+ ? matrix
134
+ : Object.assign(Object.assign({}, Object.fromEntries(matrix.elements.map(({ id, options }) => [
135
+ id,
136
+ options,
137
+ ]))), { include: matrix.extra }),
138
+ }
139
+ : undefined,
140
+ env,
141
+ defaults: workingDirectory
142
+ ? {
143
+ run: {
144
+ "working-directory": workingDirectory,
145
+ },
146
+ }
147
+ : undefined,
148
+ steps: yield Promise.all(steps.map((step) => __awaiter(this, void 0, void 0, function* () {
149
+ const { id, name, ifExpression, workingDirectory, continueOnError, timeout } = step, options = __rest(step, ["id", "name", "ifExpression", "workingDirectory", "continueOnError", "timeout"]);
150
+ return Object.assign(Object.assign({ id,
151
+ name, if: ifExpression, "continue-on-error": continueOnError, "working-directory": workingDirectory, "timeout-minutes": timeout }, options), { uses: yield supplyChainAttack(step) });
152
+ }))),
153
+ outputs,
154
+ },
155
+ ];
156
+ })))),
157
+ };
158
+ const compiled = `# Workflow automatically generated by gat\n# DO NOT CHANGE THIS FILE MANUALLY\n\n${dump(result, {
159
+ noRefs: true,
160
+ lineWidth: 200,
161
+ noCompatMode: true,
162
+ })}`;
163
+ if (!filepath)
164
+ return compiled;
165
+ return writeFilePromise(path.join(process.cwd(), ".github", "workflows", filepath), compiled);
166
+ });
160
167
  }
161
168
  }
162
- exports.Workflow = Workflow;
@@ -1,10 +1,17 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const vitest_1 = require("vitest");
4
- const workflow_1 = require("./workflow");
5
- (0, vitest_1.describe)("Workflow", () => {
6
- (0, vitest_1.it)("generates a simple workflow", async () => {
7
- const workflow = new workflow_1.Workflow("Simple");
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { describe, it, expect } from "vitest";
11
+ import { Workflow } from "./workflow";
12
+ describe("Workflow", () => {
13
+ it("generates a simple workflow", () => __awaiter(void 0, void 0, void 0, function* () {
14
+ const workflow = new Workflow("Simple");
8
15
  workflow
9
16
  .on("pull_request", { types: ["opened"] })
10
17
  .addJob("job1", {
@@ -14,20 +21,20 @@ const workflow_1 = require("./workflow");
14
21
  steps: [{ name: "Do something else", run: "exit 0" }],
15
22
  dependsOn: ["job1"],
16
23
  });
17
- (0, vitest_1.expect)(await workflow.compile()).toMatchSnapshot();
18
- });
19
- (0, vitest_1.it)("allows multiple events", async () => {
20
- const workflow = new workflow_1.Workflow("Multiple events");
24
+ expect(yield workflow.compile()).toMatchSnapshot();
25
+ }));
26
+ it("allows multiple events", () => __awaiter(void 0, void 0, void 0, function* () {
27
+ const workflow = new Workflow("Multiple events");
21
28
  workflow
22
29
  .on("push", { branches: ["main"] })
23
30
  .on("pull_request", { types: ["opened"] })
24
31
  .addJob("job1", {
25
32
  steps: [{ name: "Do something", run: "exit 0" }],
26
33
  });
27
- (0, vitest_1.expect)(await workflow.compile()).toMatchSnapshot();
28
- });
29
- (0, vitest_1.it)("allows declaring default options", async () => {
30
- const workflow = new workflow_1.Workflow("Default options");
34
+ expect(yield workflow.compile()).toMatchSnapshot();
35
+ }));
36
+ it("allows declaring default options", () => __awaiter(void 0, void 0, void 0, function* () {
37
+ const workflow = new Workflow("Default options");
31
38
  workflow
32
39
  .on("push", { branches: ["main"] })
33
40
  .addDefaults({
@@ -36,10 +43,10 @@ const workflow_1 = require("./workflow");
36
43
  .addJob("job1", {
37
44
  steps: [{ name: "Do something", run: "exit 0" }],
38
45
  });
39
- (0, vitest_1.expect)(await workflow.compile()).toMatchSnapshot();
40
- });
41
- (0, vitest_1.it)("allows declaring environment variables", async () => {
42
- const workflow = new workflow_1.Workflow("With Environment variables");
46
+ expect(yield workflow.compile()).toMatchSnapshot();
47
+ }));
48
+ it("allows declaring environment variables", () => __awaiter(void 0, void 0, void 0, function* () {
49
+ const workflow = new Workflow("With Environment variables");
43
50
  workflow
44
51
  .on("push")
45
52
  .setEnv("NODE_VERSION", "16")
@@ -52,10 +59,10 @@ const workflow_1 = require("./workflow");
52
59
  },
53
60
  ],
54
61
  });
55
- (0, vitest_1.expect)(await workflow.compile()).toMatchSnapshot();
56
- });
57
- (0, vitest_1.it)("allows using a concurrency group", async () => {
58
- const workflow = new workflow_1.Workflow("Concurrency group");
62
+ expect(yield workflow.compile()).toMatchSnapshot();
63
+ }));
64
+ it("allows using a concurrency group", () => __awaiter(void 0, void 0, void 0, function* () {
65
+ const workflow = new Workflow("Concurrency group");
59
66
  workflow.on("push").addJob("job1", {
60
67
  concurrency: {
61
68
  groupSuffix: "foo",
@@ -67,10 +74,10 @@ const workflow_1 = require("./workflow");
67
74
  },
68
75
  ],
69
76
  });
70
- (0, vitest_1.expect)(await workflow.compile()).toMatchSnapshot();
71
- });
72
- (0, vitest_1.it)("allows using outputs", async () => {
73
- const workflow = new workflow_1.Workflow("Using outputs");
77
+ expect(yield workflow.compile()).toMatchSnapshot();
78
+ }));
79
+ it("allows using outputs", () => __awaiter(void 0, void 0, void 0, function* () {
80
+ const workflow = new Workflow("Using outputs");
74
81
  workflow.on("push").addJob("job1", {
75
82
  steps: [
76
83
  {
@@ -82,10 +89,10 @@ const workflow_1 = require("./workflow");
82
89
  "random-number": "${{ steps.random-number.outputs.random-number }}",
83
90
  },
84
91
  });
85
- (0, vitest_1.expect)(await workflow.compile()).toMatchSnapshot();
86
- });
87
- (0, vitest_1.it)("allows conditional jobs", async () => {
88
- const workflow = new workflow_1.Workflow("Conditional job");
92
+ expect(yield workflow.compile()).toMatchSnapshot();
93
+ }));
94
+ it("allows conditional jobs", () => __awaiter(void 0, void 0, void 0, function* () {
95
+ const workflow = new Workflow("Conditional job");
89
96
  workflow.on("push").addJob("job1", {
90
97
  ifExpression: "${{ github.ref != 'refs/heads/main' }}",
91
98
  steps: [
@@ -94,10 +101,10 @@ const workflow_1 = require("./workflow");
94
101
  },
95
102
  ],
96
103
  });
97
- (0, vitest_1.expect)(await workflow.compile()).toMatchSnapshot();
98
- });
99
- (0, vitest_1.it)("allows a job matrix", async () => {
100
- const workflow = new workflow_1.Workflow("Conditional job");
104
+ expect(yield workflow.compile()).toMatchSnapshot();
105
+ }));
106
+ it("allows a job matrix", () => __awaiter(void 0, void 0, void 0, function* () {
107
+ const workflow = new Workflow("Conditional job");
101
108
  workflow.on("push").addJob("job1", {
102
109
  matrix: {
103
110
  elements: [
@@ -124,10 +131,10 @@ const workflow_1 = require("./workflow");
124
131
  },
125
132
  ],
126
133
  });
127
- (0, vitest_1.expect)(await workflow.compile()).toMatchSnapshot();
128
- });
129
- (0, vitest_1.it)("allows uses steps", async () => {
130
- const workflow = new workflow_1.Workflow("Uses steps");
134
+ expect(yield workflow.compile()).toMatchSnapshot();
135
+ }));
136
+ it("allows uses steps", () => __awaiter(void 0, void 0, void 0, function* () {
137
+ const workflow = new Workflow("Uses steps");
131
138
  workflow
132
139
  .on("push")
133
140
  .setEnv("NODE_VERSION", "16")
@@ -142,10 +149,10 @@ const workflow_1 = require("./workflow");
142
149
  },
143
150
  ],
144
151
  });
145
- (0, vitest_1.expect)(await workflow.compile()).toMatchSnapshot();
146
- });
147
- (0, vitest_1.it)("allows custom types in a workflow", async () => {
148
- const workflow = new workflow_1.Workflow("With custom types");
152
+ expect(yield workflow.compile()).toMatchSnapshot();
153
+ }));
154
+ it("allows custom types in a workflow", () => __awaiter(void 0, void 0, void 0, function* () {
155
+ const workflow = new Workflow("With custom types");
149
156
  workflow.on("push").addJob("job1", {
150
157
  runsOn: "standard-runner",
151
158
  steps: [
@@ -160,10 +167,10 @@ const workflow_1 = require("./workflow");
160
167
  },
161
168
  ],
162
169
  });
163
- (0, vitest_1.expect)(await workflow.compile()).toMatchSnapshot();
164
- });
165
- (0, vitest_1.it)("support workflow dispatch event", async () => {
166
- const workflow = new workflow_1.Workflow("Workflow dispatch");
170
+ expect(yield workflow.compile()).toMatchSnapshot();
171
+ }));
172
+ it("support workflow dispatch event", () => __awaiter(void 0, void 0, void 0, function* () {
173
+ const workflow = new Workflow("Workflow dispatch");
167
174
  workflow
168
175
  .on("workflow_dispatch", {
169
176
  inputs: {
@@ -181,27 +188,27 @@ const workflow_1 = require("./workflow");
181
188
  .addJob("job1", {
182
189
  steps: [{ name: "Do something", run: "exit 0" }],
183
190
  });
184
- (0, vitest_1.expect)(await workflow.compile()).toMatchSnapshot();
185
- });
186
- (0, vitest_1.it)("supports schedule event", async () => {
187
- const workflow = new workflow_1.Workflow("Schedule")
191
+ expect(yield workflow.compile()).toMatchSnapshot();
192
+ }));
193
+ it("supports schedule event", () => __awaiter(void 0, void 0, void 0, function* () {
194
+ const workflow = new Workflow("Schedule")
188
195
  .on("schedule", [{ cron: "0 4 * * 1-5" }])
189
196
  .addJob("job1", {
190
197
  steps: [{ name: "Do something", run: "exit 0" }],
191
198
  });
192
- (0, vitest_1.expect)(await workflow.compile()).toMatchSnapshot();
193
- });
194
- (0, vitest_1.it)("supports a pretty name for the job", async () => {
195
- const workflow = new workflow_1.Workflow("Job with pretty name")
199
+ expect(yield workflow.compile()).toMatchSnapshot();
200
+ }));
201
+ it("supports a pretty name for the job", () => __awaiter(void 0, void 0, void 0, function* () {
202
+ const workflow = new Workflow("Job with pretty name")
196
203
  .on("push")
197
204
  .addJob("job1", {
198
205
  prettyName: "My pretty name",
199
206
  steps: [{ name: "Do something", run: "exit 0" }],
200
207
  });
201
- (0, vitest_1.expect)(await workflow.compile()).toMatchSnapshot();
202
- });
203
- (0, vitest_1.it)("allows permissions into jobs", async () => {
204
- const workflow = new workflow_1.Workflow("Job with permissions")
208
+ expect(yield workflow.compile()).toMatchSnapshot();
209
+ }));
210
+ it("allows permissions into jobs", () => __awaiter(void 0, void 0, void 0, function* () {
211
+ const workflow = new Workflow("Job with permissions")
205
212
  .on("push")
206
213
  .addJob("job1", {
207
214
  permissions: {
@@ -210,10 +217,10 @@ const workflow_1 = require("./workflow");
210
217
  },
211
218
  steps: [{ name: "Do something", run: "exit 0" }],
212
219
  });
213
- (0, vitest_1.expect)(await workflow.compile()).toMatchSnapshot();
214
- });
215
- (0, vitest_1.it)("allows multiline strings", async () => {
216
- const workflow = new workflow_1.Workflow("Multiline strings")
220
+ expect(yield workflow.compile()).toMatchSnapshot();
221
+ }));
222
+ it("allows multiline strings", () => __awaiter(void 0, void 0, void 0, function* () {
223
+ const workflow = new Workflow("Multiline strings")
217
224
  .on("push")
218
225
  .addJob("job1", {
219
226
  steps: [
@@ -224,10 +231,10 @@ exit 0`,
224
231
  },
225
232
  ],
226
233
  });
227
- (0, vitest_1.expect)(await workflow.compile()).toMatchSnapshot();
228
- });
229
- (0, vitest_1.it)("allows concurrency groups at workflow level", async () => {
230
- const workflow = new workflow_1.Workflow("Concurrency at workflow level")
234
+ expect(yield workflow.compile()).toMatchSnapshot();
235
+ }));
236
+ it("allows concurrency groups at workflow level", () => __awaiter(void 0, void 0, void 0, function* () {
237
+ const workflow = new Workflow("Concurrency at workflow level")
231
238
  .on("push")
232
239
  .setConcurrencyGroup({
233
240
  groupSuffix: "${{ github.workflow }}-${{ github.ref }}",
@@ -241,6 +248,6 @@ exit 0`,
241
248
  },
242
249
  ],
243
250
  });
244
- (0, vitest_1.expect)(await workflow.compile()).toMatchSnapshot();
245
- });
251
+ expect(yield workflow.compile()).toMatchSnapshot();
252
+ }));
246
253
  });
package/package.json CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "name": "@factorialco/gat",
3
- "version": "2.2.0",
3
+ "version": "2.3.0",
4
4
  "description": "Write your GitHub Actions workflows using TypeScript",
5
5
  "bin": {
6
6
  "gat": "dist/cli.js"
7
7
  },
8
+ "type": "module",
8
9
  "main": "dist/index.js",
9
10
  "files": [
10
11
  "dist/**/*"