@factorialco/gat 0.0.14 → 0.0.17

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
@@ -11,21 +11,30 @@ const commander_1 = require("commander");
11
11
  const util_1 = require("util");
12
12
  const execPromise = (0, util_1.promisify)(child_process_1.exec);
13
13
  const writeFilePromise = (0, util_1.promisify)(fs_1.default.writeFile);
14
+ const parseFile = async (templateFile) => {
15
+ const { stdout } = await execPromise(`npx ts-node ${templateFile}`);
16
+ await writeFilePromise(path_1.default.join(process.cwd(), ".github", "workflows", templateFile.split("/").at(-1).replace(".ts", ".yml")), stdout);
17
+ };
14
18
  const cli = new commander_1.Command();
15
19
  cli.version("0.0.1").description("TODO");
16
20
  cli
17
21
  .command("build")
18
22
  .description("TODO")
19
- .action(async () => {
23
+ .argument("[file]", "TODO")
24
+ .action(async (file) => {
20
25
  const folder = path_1.default.join(process.cwd(), ".github", "templates");
21
26
  if (!fs_1.default.existsSync(path_1.default.join(folder, "..", "workflows"))) {
22
27
  fs_1.default.mkdirSync(path_1.default.join(folder, "..", "workflows"));
23
28
  }
24
- for await (const templateFile of fs_1.default.readdirSync(folder)) {
25
- if (!templateFile.match(/^shared$/)) {
26
- const { stdout } = await execPromise(`npx ts-node ${path_1.default.join(folder, templateFile)}`);
27
- await writeFilePromise(path_1.default.join(folder, "..", "workflows", templateFile.replace(".ts", ".yml")), stdout);
28
- }
29
+ if (file !== undefined) {
30
+ await parseFile(file);
31
+ }
32
+ else {
33
+ await Promise.all(fs_1.default.readdirSync(folder).map(async (templateFile) => {
34
+ if (!templateFile.match(/^shared$/)) {
35
+ await parseFile(`${path_1.default.join(folder, templateFile)}`);
36
+ }
37
+ }));
29
38
  }
30
39
  process.exit(0);
31
40
  });
package/dist/event.d.ts CHANGED
@@ -21,6 +21,7 @@ interface WorkflowDispatchInput {
21
21
  required?: boolean;
22
22
  type?: "choice" | "boolean";
23
23
  options?: string[];
24
+ default?: string | boolean;
24
25
  }
25
26
  interface WorkflowDispatchEventOptions {
26
27
  inputs?: Record<string, WorkflowDispatchInput>;
package/dist/workflow.js CHANGED
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.Workflow = void 0;
7
- const yaml_1 = require("yaml");
7
+ const js_yaml_1 = require("js-yaml");
8
8
  const kebabCase_1 = __importDefault(require("lodash/kebabCase"));
9
9
  const DEFAULT_RUNNERS = ["ubuntu-22.04"];
10
10
  class Workflow {
@@ -91,10 +91,10 @@ class Workflow {
91
91
  },
92
92
  ])),
93
93
  };
94
- const compiled = `# Template automatically generated by gat\n# DO NOT CHANGE THIS FILE MANUALLY\n\n${(0, yaml_1.stringify)(result, {
95
- singleQuote: true,
96
- aliasDuplicateObjects: false,
97
- lineWidth: 150,
94
+ const compiled = `# Workflow automatically generated by gat\n# DO NOT CHANGE THIS FILE MANUALLY\n\n${(0, js_yaml_1.dump)(result, {
95
+ noRefs: true,
96
+ lineWidth: 200,
97
+ noCompatMode: true,
98
98
  })}`;
99
99
  console.log(compiled);
100
100
  return compiled;
@@ -212,4 +212,20 @@ const workflow_1 = require("./workflow");
212
212
  });
213
213
  (0, vitest_1.expect)(workflow.compile()).toMatchSnapshot();
214
214
  });
215
+ (0, vitest_1.it)("allows multiline strings", () => {
216
+ const workflow = new workflow_1.Workflow("Multiline strings")
217
+ .on("push")
218
+ .addJob("job1", {
219
+ steps: [
220
+ {
221
+ name: "Do something",
222
+ run: `
223
+ echo foo
224
+ exit 0
225
+ `,
226
+ },
227
+ ],
228
+ });
229
+ (0, vitest_1.expect)(workflow.compile()).toMatchSnapshot();
230
+ });
215
231
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@factorialco/gat",
3
- "version": "0.0.14",
3
+ "version": "0.0.17",
4
4
  "description": "TODO",
5
5
  "bin": {
6
6
  "gat": "dist/cli.js"
@@ -23,6 +23,7 @@
23
23
  "author": "David Morcillo <david.morcillo@factorial.co>",
24
24
  "license": "ISC",
25
25
  "devDependencies": {
26
+ "@types/js-yaml": "^4.0.5",
26
27
  "@types/lodash": "^4.14.184",
27
28
  "@typescript-eslint/eslint-plugin": "^5.35.1",
28
29
  "@typescript-eslint/parser": "^5.35.1",
@@ -34,8 +35,8 @@
34
35
  "vitest": "^0.18.1"
35
36
  },
36
37
  "dependencies": {
37
- "lodash": "^4.17.21",
38
- "yaml": "^2.1.1"
38
+ "js-yaml": "^4.1.0",
39
+ "lodash": "^4.17.21"
39
40
  },
40
41
  "repository": {
41
42
  "type": "git",