@factorialco/gat 2.3.0 → 2.5.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
@@ -23,11 +23,10 @@ cli
23
23
  .command("build")
24
24
  .description("Transpile all Gat templates into GitHub Actions workflows.")
25
25
  .action(() => __awaiter(void 0, void 0, void 0, function* () {
26
- var _a;
27
26
  if (!fs.existsSync(path.join(folder, "..", "workflows"))) {
28
27
  fs.mkdirSync(path.join(folder, "..", "workflows"));
29
28
  }
30
- yield execPromise(`npx ts-node ${(_a = process.env["GAT_BUILD_FLAGS"]) !== null && _a !== void 0 ? _a : "--swc -T"} ${path.join(folder, "index.ts")}`);
29
+ yield execPromise(`npx tsx ${path.join(folder, "index.ts")}`);
31
30
  process.exit(0);
32
31
  }));
33
32
  cli.parse(process.argv);
package/dist/workflow.js CHANGED
@@ -23,14 +23,16 @@ import kebabCase from "lodash/kebabCase";
23
23
  import fs from "fs";
24
24
  import path from "path";
25
25
  import { promisify } from "util";
26
- import fetch from 'node-fetch';
26
+ import axios from "axios";
27
27
  import { isUseStep } from "./step";
28
28
  const writeFilePromise = promisify(fs.writeFile);
29
29
  const DEFAULT_RUNNERS = ["ubuntu-22.04"];
30
30
  const chainAttackCache = {};
31
- const supplyChainAttack = (step) => __awaiter(void 0, void 0, void 0, function* () {
31
+ const supplyChainAttack = (step, enabled = false) => __awaiter(void 0, void 0, void 0, function* () {
32
32
  if (!isUseStep(step))
33
33
  return;
34
+ if (!enabled)
35
+ return step.uses;
34
36
  const uses = step.uses;
35
37
  if (!uses)
36
38
  return uses;
@@ -40,8 +42,8 @@ const supplyChainAttack = (step) => __awaiter(void 0, void 0, void 0, function*
40
42
  if (!match)
41
43
  return uses;
42
44
  const { repository, version } = match.groups;
43
- const response = yield fetch(`https://api.github.com/repos/${repository}/tags`);
44
- const tags = (yield response.json());
45
+ const response = yield axios.get(`https://api.github.com/repos/${repository}/tags`);
46
+ const tags = response.data;
45
47
  const tag = tags.find((tag) => tag.name === version);
46
48
  if (!tag)
47
49
  return uses;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@factorialco/gat",
3
- "version": "2.3.0",
3
+ "version": "2.5.0",
4
4
  "description": "Write your GitHub Actions workflows using TypeScript",
5
5
  "bin": {
6
6
  "gat": "dist/cli.js"
@@ -33,13 +33,14 @@
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
  },
39
40
  "dependencies": {
41
+ "axios": "^1.6.0",
40
42
  "js-yaml": "^4.1.0",
41
- "lodash": "^4.17.21",
42
- "node-fetch": "^3.3.2"
43
+ "lodash": "^4.17.21"
43
44
  },
44
45
  "repository": {
45
46
  "type": "git",
package/dist/cli.d.ts DELETED
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- export {};
package/dist/event.d.ts DELETED
@@ -1,40 +0,0 @@
1
- export type EventName = "push" | "pull_request" | "pull_request_review" | "workflow_run" | "workflow_dispatch" | "schedule" | "pull_request_target" | "repository_dispatch";
2
- export type EventOptions<T extends EventName> = T extends "push" ? PushEventOptions : T extends "pull_request" ? PullRequestEventOptions : T extends "pull_request_review" ? PullRequestReviewEventOptions : T extends "workflow_run" ? WorkflowRunEventOptions : T extends "workflow_dispatch" ? WorkflowDispatchEventOptions : T extends "schedule" ? ScheduleEventOptions : T extends "repository_dispatch" ? RepositoryDispatchEventOptions : never;
3
- interface PushEventOptions {
4
- branches?: string[];
5
- paths?: string[];
6
- }
7
- interface PullRequestEventOptions {
8
- branches?: string[];
9
- paths?: string[];
10
- types?: Array<"opened" | "closed" | "reopened" | "synchronize" | "labeled" | "unlabeled">;
11
- }
12
- interface PullRequestReviewEventOptions {
13
- types?: Array<"submitted">;
14
- }
15
- interface WorkflowRunEventOptions {
16
- workflows?: string[];
17
- types?: Array<"completed">;
18
- branches?: string[];
19
- }
20
- interface WorkflowDispatchInput {
21
- description: string;
22
- required?: boolean;
23
- type?: "choice" | "boolean" | "string";
24
- options?: string[];
25
- default?: string | boolean;
26
- }
27
- interface WorkflowDispatchEventOptions {
28
- inputs?: Record<string, WorkflowDispatchInput>;
29
- }
30
- type ScheduleEventOptions = Array<{
31
- cron: string;
32
- }>;
33
- interface RepositoryDispatchEventOptions {
34
- types: string[];
35
- }
36
- export interface Event {
37
- name: EventName;
38
- options?: EventOptions<EventName>;
39
- }
40
- export {};
package/dist/index.d.ts DELETED
@@ -1,4 +0,0 @@
1
- import { Workflow } from "./workflow";
2
- import { ConcurrencyGroup, JobOptions, Matrix, Service } from "./job";
3
- import { RunStep, UseStep, BaseStep } from "./step";
4
- export { Workflow, RunStep, UseStep, BaseStep, ConcurrencyGroup, JobOptions, Matrix, Service, };
package/dist/job.d.ts DELETED
@@ -1,42 +0,0 @@
1
- export interface ConcurrencyGroup {
2
- groupSuffix: string;
3
- cancelPrevious: boolean;
4
- }
5
- export interface Matrix {
6
- elements: Array<{
7
- id: string;
8
- options: Array<string | number | boolean>;
9
- }>;
10
- extra?: Array<Record<string, string | number | boolean>>;
11
- }
12
- export interface Service {
13
- image: string;
14
- credentials?: {
15
- username: string;
16
- password: string;
17
- };
18
- env?: Record<string, string>;
19
- ports: string[];
20
- options?: string;
21
- volumes?: string[];
22
- }
23
- export interface JobOptions<Step, Runner, Name> {
24
- prettyName?: string;
25
- permissions?: object;
26
- ifExpression?: string;
27
- runsOn?: Runner;
28
- timeout?: number;
29
- dependsOn?: Array<Name>;
30
- services?: Record<string, Service>;
31
- env?: Record<string, string>;
32
- concurrency?: ConcurrencyGroup;
33
- matrix?: Matrix | string;
34
- steps: Step[];
35
- outputs?: Record<string, string>;
36
- workingDirectory?: string;
37
- }
38
- export type StringWithNoSpaces<T> = T extends `${string} ${string}` ? never : T extends ` ${string}` ? never : T extends `${string} ` ? never : T;
39
- export interface Job<Step, Runner, Name> {
40
- name: string;
41
- options: JobOptions<Step, Runner, Name>;
42
- }
package/dist/step.d.ts DELETED
@@ -1,18 +0,0 @@
1
- export interface BaseStep {
2
- id?: string;
3
- name?: string;
4
- env?: Record<string, string>;
5
- ifExpression?: string;
6
- workingDirectory?: string;
7
- continueOnError?: boolean;
8
- timeout?: number;
9
- }
10
- export type Step = RunStep | UseStep;
11
- export interface RunStep extends BaseStep {
12
- run: string;
13
- }
14
- export interface UseStep extends BaseStep {
15
- uses: string;
16
- with?: Record<string, string | number | boolean>;
17
- }
18
- export declare const isUseStep: (step: Step) => step is UseStep;
@@ -1,29 +0,0 @@
1
- import { ConcurrencyGroup, Job, JobOptions, StringWithNoSpaces } from "./job";
2
- import type { Event, EventName, EventOptions } from "./event";
3
- import { Step } from "./step";
4
- declare const DEFAULT_RUNNERS: string[];
5
- interface DefaultOptions {
6
- workingDirectory: string;
7
- }
8
- interface EnvVar {
9
- name: string;
10
- value: string;
11
- }
12
- export declare class Workflow<JobStep extends Step = Step, Runner = typeof DEFAULT_RUNNERS, JobName = never> {
13
- name: string;
14
- events: Event[];
15
- jobs: Array<Job<JobStep, Runner, JobName>>;
16
- defaultOptions: DefaultOptions | null;
17
- env: EnvVar[];
18
- concurrencyGroup?: ConcurrencyGroup;
19
- constructor(name: string);
20
- on<T extends EventName>(name: T, options?: EventOptions<T>): this;
21
- addDefaults(options: DefaultOptions): this;
22
- addJob<T extends string>(name: StringWithNoSpaces<T>, options: JobOptions<JobStep, Runner, JobName>): Workflow<JobStep, Runner, JobName | T>;
23
- setEnv(name: string, value: string): this;
24
- setConcurrencyGroup(concurrencyGroup: ConcurrencyGroup): this;
25
- defaultRunner(): string;
26
- private assignRunner;
27
- compile(filepath?: string): Promise<string | void>;
28
- }
29
- export {};
@@ -1 +0,0 @@
1
- export {};