@factorialco/gat 0.0.3 → 0.0.6

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/job.d.ts CHANGED
@@ -5,9 +5,9 @@ export interface ConcurrencyGroup {
5
5
  export interface Matrix {
6
6
  elements: Array<{
7
7
  id: string;
8
- options: any[];
8
+ options: Array<string | number | boolean>;
9
9
  }>;
10
- extra?: Array<Record<string, any>>;
10
+ extra?: Array<Record<string, string | number | boolean>>;
11
11
  }
12
12
  export interface Service {
13
13
  image: string;
package/dist/step.d.ts CHANGED
@@ -11,5 +11,5 @@ export interface RunStep extends BaseStep {
11
11
  }
12
12
  export interface UseStep extends BaseStep {
13
13
  uses: string;
14
- with?: any;
14
+ with?: Record<string, string | number | boolean>;
15
15
  }
@@ -1,6 +1,7 @@
1
1
  import { Job, JobOptions } from "./job";
2
2
  import type { Event, EventName, EventOptions } from "./event";
3
3
  import { BaseStep, Step } from "./step";
4
+ declare const DEFAULT_RUNNERS: string[];
4
5
  interface DefaultOptions {
5
6
  workingDirectory: string;
6
7
  }
@@ -8,7 +9,7 @@ interface EnvVar {
8
9
  name: string;
9
10
  value: string;
10
11
  }
11
- export declare class Workflow<JobStep extends BaseStep = Step, Runner = "ubuntu-22.04", JobName = never> {
12
+ export declare class Workflow<JobStep extends BaseStep = Step, Runner = typeof DEFAULT_RUNNERS, JobName = never> {
12
13
  name: string;
13
14
  events: Event[];
14
15
  jobs: Array<Job<JobStep, Runner, JobName>>;
@@ -18,8 +19,9 @@ export declare class Workflow<JobStep extends BaseStep = Step, Runner = "ubuntu-
18
19
  on<T extends EventName>(name: T, options?: EventOptions<T>): this;
19
20
  addDefaults(options: DefaultOptions): this;
20
21
  addJob<T extends string>(name: T, options: JobOptions<JobStep, Runner, JobName>): Workflow<JobStep, Runner, JobName | T>;
21
- setEnv(name: string, value: any): this;
22
+ setEnv(name: string, value: string): this;
22
23
  defaultRunner(): string;
24
+ private assignRunner;
23
25
  compile(): string;
24
26
  }
25
27
  export {};
package/dist/workflow.js CHANGED
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.Workflow = void 0;
7
7
  const yaml_1 = require("yaml");
8
8
  const kebabCase_1 = __importDefault(require("lodash/kebabCase"));
9
+ const DEFAULT_RUNNERS = ["ubuntu-22.04"];
9
10
  class Workflow {
10
11
  constructor(name) {
11
12
  this.name = name;
@@ -33,6 +34,11 @@ class Workflow {
33
34
  defaultRunner() {
34
35
  return "ubuntu-22.04";
35
36
  }
37
+ assignRunner(runsOn) {
38
+ const runnerName = runsOn ?? this.defaultRunner();
39
+ const isSelfHosted = !DEFAULT_RUNNERS.includes(runnerName);
40
+ return isSelfHosted ? ["self-hosted", runnerName] : runnerName;
41
+ }
36
42
  compile() {
37
43
  const result = {
38
44
  name: this.name,
@@ -47,11 +53,11 @@ class Workflow {
47
53
  env: this.env.length > 0
48
54
  ? Object.fromEntries(this.env.map(({ name, value }) => [name, value]))
49
55
  : undefined,
50
- jobs: Object.fromEntries(this.jobs.map(({ name, options: { ifExpression, runsOn, matrix, steps, dependsOn, services, timeout, concurrency, outputs, }, }) => [
56
+ jobs: Object.fromEntries(this.jobs.map(({ name, options: { ifExpression, runsOn, matrix, env, steps, dependsOn, services, timeout, concurrency, outputs, }, }) => [
51
57
  name,
52
58
  {
53
59
  if: ifExpression,
54
- "runs-on": runsOn ?? this.defaultRunner(),
60
+ "runs-on": this.assignRunner(runsOn),
55
61
  "timeout-minutes": timeout ?? 15,
56
62
  needs: dependsOn,
57
63
  services,
@@ -70,6 +76,7 @@ class Workflow {
70
76
  },
71
77
  }
72
78
  : undefined,
79
+ env,
73
80
  steps: steps.map(({ id, name, ifExpression, workingDirectory, ...options }) => ({
74
81
  id,
75
82
  name,
@@ -43,7 +43,7 @@ const workflow_1 = require("./workflow");
43
43
  workflow
44
44
  .on("push")
45
45
  .setEnv("NODE_VERSION", "16")
46
- .setEnv("ENABLED", true)
46
+ .setEnv("ENABLED", "true")
47
47
  .addJob("job1", {
48
48
  steps: [
49
49
  {
@@ -131,7 +131,7 @@ const workflow_1 = require("./workflow");
131
131
  workflow
132
132
  .on("push")
133
133
  .setEnv("NODE_VERSION", "16")
134
- .setEnv("ENABLED", true)
134
+ .setEnv("ENABLED", "true")
135
135
  .addJob("job1", {
136
136
  steps: [
137
137
  {
@@ -147,7 +147,7 @@ const workflow_1 = require("./workflow");
147
147
  (0, vitest_1.it)("allows custom types in a workflow", () => {
148
148
  const workflow = new workflow_1.Workflow("With custom types");
149
149
  workflow.on("push").addJob("job1", {
150
- runsOn: ["self-hosted", "standard-runner"],
150
+ runsOn: "standard-runner",
151
151
  steps: [
152
152
  {
153
153
  run: "echo 'Do something'",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@factorialco/gat",
3
- "version": "0.0.3",
3
+ "version": "0.0.6",
4
4
  "description": "TODO",
5
5
  "bin": {
6
6
  "gat": "dist/cli.js"
@@ -15,13 +15,21 @@
15
15
  "prepare": "npm run build",
16
16
  "prepublishOnly": "vitest run",
17
17
  "test": "vitest",
18
- "coverage": "vitest run --coverage"
18
+ "coverage": "vitest run --coverage",
19
+ "lint": "eslint src/**/*.ts",
20
+ "format": "prettier --write .",
21
+ "format:check": "prettier --check ."
19
22
  },
20
23
  "author": "David Morcillo <david.morcillo@factorial.co>",
21
24
  "license": "ISC",
22
25
  "devDependencies": {
23
26
  "@types/lodash": "^4.14.184",
27
+ "@typescript-eslint/eslint-plugin": "^5.35.1",
28
+ "@typescript-eslint/parser": "^5.35.1",
24
29
  "commander": "^9.4.0",
30
+ "eslint": "^8.23.0",
31
+ "eslint-config-prettier": "^8.5.0",
32
+ "prettier": "2.7.1",
25
33
  "typescript": "^4.7.4",
26
34
  "vitest": "^0.18.1"
27
35
  },