@factorialco/gat 2.4.0 → 2.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -11,7 +11,7 @@ _Why `gat`?_ The name is an acronym of "GitHub Actions Template Generator" witho
11
11
  Install the main package and its dependencies using the following command:
12
12
 
13
13
  ```bash
14
- npm i -D @factorialco/gat typescript ts-node commander @swc/core
14
+ npm i -D @factorialco/gat typescript tsx commander @swc/core
15
15
  ```
16
16
 
17
17
  ## Usage
package/dist/cli.js CHANGED
@@ -1,33 +1,28 @@
1
1
  #!/usr/bin/env node
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
- });
2
+ "use strict";
3
+ var __importDefault = (this && this.__importDefault) || function (mod) {
4
+ return (mod && mod.__esModule) ? mod : { "default": mod };
10
5
  };
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();
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();
19
15
  cli
20
16
  .version("2.0.0")
21
17
  .description("Write your GitHub Actions workflows using TypeScript");
22
18
  cli
23
19
  .command("build")
24
20
  .description("Transpile all Gat templates into GitHub Actions 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"));
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"));
29
24
  }
30
- yield execPromise(`npx ts-node ${(_a = process.env["GAT_BUILD_FLAGS"]) !== null && _a !== void 0 ? _a : "--swc -T"} ${path.join(folder, "index.ts")}`);
25
+ await execPromise(`npx tsx ${path_1.default.join(folder, "index.ts")}`);
31
26
  process.exit(0);
32
- }));
27
+ });
33
28
  cli.parse(process.argv);
package/dist/event.js CHANGED
@@ -1 +1,2 @@
1
- export {};
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  import { Workflow } from "./workflow";
2
- import { ConcurrencyGroup, JobOptions, Matrix, Service } from "./job";
3
- import { RunStep, UseStep, BaseStep } from "./step";
2
+ import { type ConcurrencyGroup, type JobOptions, type Matrix, type Service } from "./job";
3
+ import { type RunStep, type UseStep, type BaseStep } from "./step";
4
4
  export { Workflow, RunStep, UseStep, BaseStep, ConcurrencyGroup, JobOptions, Matrix, Service, };
package/dist/index.js CHANGED
@@ -1,2 +1,5 @@
1
- import { Workflow } from "./workflow";
2
- export { Workflow, };
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; } });
package/dist/job.js CHANGED
@@ -1 +1,2 @@
1
- export {};
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/dist/step.js CHANGED
@@ -1,3 +1,7 @@
1
- export const isUseStep = (step) => {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isUseStep = void 0;
4
+ const isUseStep = (step) => {
2
5
  return step.uses !== undefined;
3
6
  };
7
+ exports.isUseStep = isUseStep;
@@ -1,6 +1,6 @@
1
1
  import { ConcurrencyGroup, Job, JobOptions, StringWithNoSpaces } from "./job";
2
2
  import type { Event, EventName, EventOptions } from "./event";
3
- import { Step } from "./step";
3
+ import { type Step } from "./step";
4
4
  declare const DEFAULT_RUNNERS: string[];
5
5
  interface DefaultOptions {
6
6
  workingDirectory: string;
package/dist/workflow.js CHANGED
@@ -1,36 +1,24 @@
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
- });
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
9
4
  };
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 axios from 'axios';
27
- import { isUseStep } from "./step";
28
- const writeFilePromise = promisify(fs.writeFile);
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 axios_1 = __importDefault(require("axios"));
13
+ const step_1 = require("./step");
14
+ const writeFilePromise = (0, util_1.promisify)(fs_1.default.writeFile);
29
15
  const DEFAULT_RUNNERS = ["ubuntu-22.04"];
30
16
  const chainAttackCache = {};
31
- const supplyChainAttack = (step) => __awaiter(void 0, void 0, void 0, function* () {
32
- if (!isUseStep(step))
17
+ const supplyChainAttack = async (step, enabled = false) => {
18
+ if (!(0, step_1.isUseStep)(step))
33
19
  return;
20
+ if (!enabled)
21
+ return step.uses;
34
22
  const uses = step.uses;
35
23
  if (!uses)
36
24
  return uses;
@@ -40,7 +28,7 @@ const supplyChainAttack = (step) => __awaiter(void 0, void 0, void 0, function*
40
28
  if (!match)
41
29
  return uses;
42
30
  const { repository, version } = match.groups;
43
- const response = yield axios.get(`https://api.github.com/repos/${repository}/tags`);
31
+ const response = await axios_1.default.get(`https://api.github.com/repos/${repository}/tags`);
44
32
  const tags = response.data;
45
33
  const tag = tags.find((tag) => tag.name === version);
46
34
  if (!tag)
@@ -48,8 +36,8 @@ const supplyChainAttack = (step) => __awaiter(void 0, void 0, void 0, function*
48
36
  const result = `${repository}@${tag.commit.sha}`;
49
37
  chainAttackCache[uses] = result;
50
38
  return result;
51
- });
52
- export class Workflow {
39
+ };
40
+ class Workflow {
53
41
  constructor(name) {
54
42
  this.name = name;
55
43
  this.events = [];
@@ -81,88 +69,96 @@ export class Workflow {
81
69
  return "ubuntu-22.04";
82
70
  }
83
71
  assignRunner(runsOn) {
84
- const runnerName = runsOn !== null && runsOn !== void 0 ? runsOn : this.defaultRunner();
72
+ const runnerName = runsOn ?? this.defaultRunner();
85
73
  const isSelfHosted = !DEFAULT_RUNNERS.includes(runnerName);
86
74
  return isSelfHosted ? ["self-hosted", runnerName] : runnerName;
87
75
  }
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,
76
+ async compile(filepath) {
77
+ const result = {
78
+ name: this.name,
79
+ on: Object.fromEntries(this.events.map(({ name, options }) => [
80
+ name,
81
+ options ? options : null,
82
+ ])),
83
+ concurrency: this.concurrencyGroup
84
+ ? {
85
+ group: this.concurrencyGroup.groupSuffix,
86
+ "cancel-in-progress": this.concurrencyGroup.cancelPrevious,
87
+ }
88
+ : undefined,
89
+ defaults: this.defaultOptions
90
+ ? {
91
+ run: {
92
+ "working-directory": this.defaultOptions.workingDirectory,
93
+ },
94
+ }
95
+ : undefined,
96
+ env: this.env.length > 0
97
+ ? Object.fromEntries(this.env.map(({ name, value }) => [name, value]))
98
+ : undefined,
99
+ 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, }, }) => [
100
+ name,
101
+ {
102
+ name: prettyName,
103
+ permissions,
104
+ if: ifExpression,
105
+ "runs-on": this.assignRunner(runsOn),
106
+ "timeout-minutes": timeout ?? 15,
107
+ needs: dependsOn,
108
+ services,
109
+ concurrency: concurrency
110
+ ? {
111
+ group: `${(0, kebabCase_1.default)(this.name)}-${name}-${concurrency.groupSuffix}`,
112
+ "cancel-in-progress": concurrency.cancelPrevious,
113
+ }
114
+ : undefined,
115
+ strategy: matrix
116
+ ? {
117
+ "fail-fast": false,
118
+ matrix: typeof matrix === "string"
119
+ ? matrix
120
+ : {
121
+ ...Object.fromEntries(matrix.elements.map(({ id, options }) => [
122
+ id,
123
+ options,
124
+ ])),
125
+ include: matrix.extra,
126
+ },
127
+ }
128
+ : undefined,
129
+ env,
130
+ defaults: workingDirectory
131
+ ? {
132
+ run: {
133
+ "working-directory": workingDirectory,
134
+ },
135
+ }
136
+ : undefined,
137
+ steps: await Promise.all(steps.map(async (step) => {
138
+ const { id, name, ifExpression, workingDirectory, continueOnError, timeout, ...options } = step;
139
+ return {
140
+ id,
141
+ name,
118
142
  if: ifExpression,
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
- });
143
+ "continue-on-error": continueOnError,
144
+ "working-directory": workingDirectory,
145
+ "timeout-minutes": timeout,
146
+ ...options,
147
+ uses: await supplyChainAttack(step),
148
+ };
149
+ })),
150
+ outputs,
151
+ },
152
+ ]))),
153
+ };
154
+ const compiled = `# Workflow automatically generated by gat\n# DO NOT CHANGE THIS FILE MANUALLY\n\n${(0, js_yaml_1.dump)(result, {
155
+ noRefs: true,
156
+ lineWidth: 200,
157
+ noCompatMode: true,
158
+ })}`;
159
+ if (!filepath)
160
+ return compiled;
161
+ return writeFilePromise(path_1.default.join(process.cwd(), ".github", "workflows", filepath), compiled);
167
162
  }
168
163
  }
164
+ exports.Workflow = Workflow;
@@ -1,17 +1,10 @@
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");
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");
15
8
  workflow
16
9
  .on("pull_request", { types: ["opened"] })
17
10
  .addJob("job1", {
@@ -21,20 +14,20 @@ describe("Workflow", () => {
21
14
  steps: [{ name: "Do something else", run: "exit 0" }],
22
15
  dependsOn: ["job1"],
23
16
  });
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");
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");
28
21
  workflow
29
22
  .on("push", { branches: ["main"] })
30
23
  .on("pull_request", { types: ["opened"] })
31
24
  .addJob("job1", {
32
25
  steps: [{ name: "Do something", run: "exit 0" }],
33
26
  });
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");
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");
38
31
  workflow
39
32
  .on("push", { branches: ["main"] })
40
33
  .addDefaults({
@@ -43,10 +36,10 @@ describe("Workflow", () => {
43
36
  .addJob("job1", {
44
37
  steps: [{ name: "Do something", run: "exit 0" }],
45
38
  });
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");
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");
50
43
  workflow
51
44
  .on("push")
52
45
  .setEnv("NODE_VERSION", "16")
@@ -59,10 +52,10 @@ describe("Workflow", () => {
59
52
  },
60
53
  ],
61
54
  });
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");
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");
66
59
  workflow.on("push").addJob("job1", {
67
60
  concurrency: {
68
61
  groupSuffix: "foo",
@@ -74,10 +67,10 @@ describe("Workflow", () => {
74
67
  },
75
68
  ],
76
69
  });
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");
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");
81
74
  workflow.on("push").addJob("job1", {
82
75
  steps: [
83
76
  {
@@ -89,10 +82,10 @@ describe("Workflow", () => {
89
82
  "random-number": "${{ steps.random-number.outputs.random-number }}",
90
83
  },
91
84
  });
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");
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");
96
89
  workflow.on("push").addJob("job1", {
97
90
  ifExpression: "${{ github.ref != 'refs/heads/main' }}",
98
91
  steps: [
@@ -101,10 +94,10 @@ describe("Workflow", () => {
101
94
  },
102
95
  ],
103
96
  });
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");
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");
108
101
  workflow.on("push").addJob("job1", {
109
102
  matrix: {
110
103
  elements: [
@@ -131,10 +124,10 @@ describe("Workflow", () => {
131
124
  },
132
125
  ],
133
126
  });
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");
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");
138
131
  workflow
139
132
  .on("push")
140
133
  .setEnv("NODE_VERSION", "16")
@@ -149,10 +142,10 @@ describe("Workflow", () => {
149
142
  },
150
143
  ],
151
144
  });
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");
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");
156
149
  workflow.on("push").addJob("job1", {
157
150
  runsOn: "standard-runner",
158
151
  steps: [
@@ -167,10 +160,10 @@ describe("Workflow", () => {
167
160
  },
168
161
  ],
169
162
  });
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");
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");
174
167
  workflow
175
168
  .on("workflow_dispatch", {
176
169
  inputs: {
@@ -188,27 +181,27 @@ describe("Workflow", () => {
188
181
  .addJob("job1", {
189
182
  steps: [{ name: "Do something", run: "exit 0" }],
190
183
  });
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")
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")
195
188
  .on("schedule", [{ cron: "0 4 * * 1-5" }])
196
189
  .addJob("job1", {
197
190
  steps: [{ name: "Do something", run: "exit 0" }],
198
191
  });
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")
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")
203
196
  .on("push")
204
197
  .addJob("job1", {
205
198
  prettyName: "My pretty name",
206
199
  steps: [{ name: "Do something", run: "exit 0" }],
207
200
  });
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")
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")
212
205
  .on("push")
213
206
  .addJob("job1", {
214
207
  permissions: {
@@ -217,10 +210,10 @@ describe("Workflow", () => {
217
210
  },
218
211
  steps: [{ name: "Do something", run: "exit 0" }],
219
212
  });
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")
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")
224
217
  .on("push")
225
218
  .addJob("job1", {
226
219
  steps: [
@@ -231,10 +224,10 @@ exit 0`,
231
224
  },
232
225
  ],
233
226
  });
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")
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")
238
231
  .on("push")
239
232
  .setConcurrencyGroup({
240
233
  groupSuffix: "${{ github.workflow }}-${{ github.ref }}",
@@ -248,6 +241,6 @@ exit 0`,
248
241
  },
249
242
  ],
250
243
  });
251
- expect(yield workflow.compile()).toMatchSnapshot();
252
- }));
244
+ (0, vitest_1.expect)(await workflow.compile()).toMatchSnapshot();
245
+ });
253
246
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@factorialco/gat",
3
- "version": "2.4.0",
3
+ "version": "2.6.0",
4
4
  "description": "Write your GitHub Actions workflows using TypeScript",
5
5
  "bin": {
6
6
  "gat": "dist/cli.js"
@@ -33,6 +33,7 @@
33
33
  "eslint": "^8.23.0",
34
34
  "eslint-config-prettier": "^9.0.0",
35
35
  "prettier": "^3.0.3",
36
+ "tsx": "^3.14.0",
36
37
  "typescript": "^5.2.2",
37
38
  "vitest": "^0.34.6"
38
39
  },