@factorialco/gat 3.2.0 → 3.2.2

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
@@ -20,7 +20,7 @@ export interface Service {
20
20
  options?: string;
21
21
  volumes?: string[];
22
22
  }
23
- export interface BaseJobOptions<RunnerDefinition, Name> {
23
+ export interface StepsJobOptions<Step, RunnerDefinition, Name> {
24
24
  prettyName?: string;
25
25
  permissions?: object;
26
26
  ifExpression?: string;
@@ -33,11 +33,12 @@ export interface BaseJobOptions<RunnerDefinition, Name> {
33
33
  matrix?: Matrix | string;
34
34
  outputs?: Record<string, string>;
35
35
  workingDirectory?: string;
36
- }
37
- export interface StepsJobOptions<Step, RunnerDefinition, Name> extends BaseJobOptions<RunnerDefinition, Name> {
38
36
  steps: Step[];
39
37
  }
40
- export interface UsesJobOptions<RunnerDefinition, Name> extends BaseJobOptions<RunnerDefinition, Name> {
38
+ export interface UsesJobOptions<Name> {
39
+ prettyName?: string;
40
+ dependsOn?: Array<Name>;
41
+ ifExpression?: string;
41
42
  uses: string;
42
43
  with?: Record<string, string | number | boolean | object>;
43
44
  secrets?: Record<string, string | number | boolean | object> | "inherit";
@@ -45,5 +46,5 @@ export interface UsesJobOptions<RunnerDefinition, Name> extends BaseJobOptions<R
45
46
  export type StringWithNoSpaces<T> = T extends `${string} ${string}` ? never : T extends ` ${string}` ? never : T extends `${string} ` ? never : T;
46
47
  export interface Job<Step, RunnerDefinition, Name> {
47
48
  name: string;
48
- options: StepsJobOptions<Step, RunnerDefinition, Name> | UsesJobOptions<RunnerDefinition, Name>;
49
+ options: StepsJobOptions<Step, RunnerDefinition, Name> | UsesJobOptions<Name>;
49
50
  }
@@ -22,7 +22,7 @@ export declare class Workflow<JobStep extends Step = Step, Runner extends Runner
22
22
  constructor(name: string);
23
23
  on<T extends EventName>(name: T, options?: EventOptions<T>): this;
24
24
  addDefaults(options: DefaultOptions): this;
25
- addJob<T extends string>(name: StringWithNoSpaces<T>, options: StepsJobOptions<JobStep, Runner, JobName> | UsesJobOptions<Runner, JobName>): Workflow<JobStep, Runner, JobName | T>;
25
+ addJob<T extends string>(name: StringWithNoSpaces<T>, options: StepsJobOptions<JobStep, Runner, JobName> | UsesJobOptions<JobName>): Workflow<JobStep, Runner, JobName | T>;
26
26
  setEnv(name: string, value: string): this;
27
27
  setConcurrencyGroup(concurrencyGroup: ConcurrencyGroup | null): this;
28
28
  defaultRunner(): string;
package/dist/workflow.js CHANGED
@@ -91,60 +91,59 @@ class Workflow {
91
91
  ? Object.fromEntries(this.env.map(({ name, value }) => [name, value]))
92
92
  : undefined,
93
93
  jobs: Object.fromEntries(await Promise.all(this.jobs.map(async ({ name, options: jobOptions }) => {
94
- const { prettyName, permissions, ifExpression, runsOn, matrix, env, dependsOn, services, timeout, concurrency, outputs, workingDirectory, } = jobOptions;
95
- const computedOptions = {
96
- name: prettyName,
97
- permissions,
98
- if: ifExpression,
99
- "runs-on": runsOn ?? this.defaultRunner(),
100
- "timeout-minutes": timeout ?? 15,
101
- needs: dependsOn,
102
- services,
103
- concurrency: concurrency
104
- ? {
105
- group: `${(0, kebabCase_1.default)(this.name)}-${name}-${concurrency.groupSuffix}`,
106
- "cancel-in-progress": concurrency.cancelPrevious,
107
- }
108
- : undefined,
109
- strategy: matrix
110
- ? {
111
- "fail-fast": false,
112
- matrix: typeof matrix === "string"
113
- ? matrix
114
- : {
115
- ...Object.fromEntries(matrix.elements.map(({ id, options }) => [
116
- id,
117
- options,
118
- ])),
119
- include: matrix.extra,
120
- },
121
- }
122
- : undefined,
123
- env,
124
- defaults: workingDirectory
125
- ? {
126
- run: {
127
- "working-directory": workingDirectory,
128
- },
129
- }
130
- : undefined,
131
- outputs,
132
- };
133
94
  if ("uses" in jobOptions) {
95
+ const { prettyName, ifExpression, dependsOn } = jobOptions;
134
96
  return [
135
97
  name,
136
98
  {
137
- ...computedOptions,
99
+ name: prettyName,
100
+ if: ifExpression,
101
+ needs: dependsOn,
138
102
  uses: jobOptions.uses,
139
103
  with: jobOptions.with,
140
104
  secrets: jobOptions.secrets,
141
105
  },
142
106
  ];
143
107
  }
108
+ const { prettyName, permissions, ifExpression, runsOn, matrix, env, dependsOn, services, timeout, concurrency, outputs, workingDirectory, } = jobOptions;
144
109
  return [
145
110
  name,
146
111
  {
147
- ...computedOptions,
112
+ name: prettyName,
113
+ permissions,
114
+ if: ifExpression,
115
+ "runs-on": runsOn ?? this.defaultRunner(),
116
+ "timeout-minutes": timeout ?? 15,
117
+ needs: dependsOn,
118
+ services,
119
+ concurrency: concurrency
120
+ ? {
121
+ group: `${(0, kebabCase_1.default)(this.name)}-${name}-${concurrency.groupSuffix}`,
122
+ "cancel-in-progress": concurrency.cancelPrevious,
123
+ }
124
+ : undefined,
125
+ strategy: matrix
126
+ ? {
127
+ "fail-fast": false,
128
+ matrix: typeof matrix === "string"
129
+ ? matrix
130
+ : {
131
+ ...Object.fromEntries(matrix.elements.map(({ id, options }) => [
132
+ id,
133
+ options,
134
+ ])),
135
+ include: matrix.extra,
136
+ },
137
+ }
138
+ : undefined,
139
+ env,
140
+ defaults: workingDirectory
141
+ ? {
142
+ run: {
143
+ "working-directory": workingDirectory,
144
+ },
145
+ }
146
+ : undefined,
148
147
  steps: await Promise.all(jobOptions.steps.map(async (step) => {
149
148
  const { id, name, ifExpression, workingDirectory, continueOnError, timeout, ...options } = step;
150
149
  return {
@@ -158,6 +157,7 @@ class Workflow {
158
157
  uses: await supplyChainAttack(step),
159
158
  };
160
159
  })),
160
+ outputs,
161
161
  },
162
162
  ];
163
163
  }))),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@factorialco/gat",
3
- "version": "3.2.0",
3
+ "version": "3.2.2",
4
4
  "description": "Write your GitHub Actions workflows using TypeScript",
5
5
  "bin": {
6
6
  "gat": "dist/cli.js"