@factorialco/gat 3.4.1 → 3.4.3

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.
@@ -1,8 +1,8 @@
1
1
  import { Workflow } from "./workflow";
2
- interface CompileOptions {
3
- templates: Record<string, Workflow>;
2
+ interface CompileOptions<T extends Workflow> {
3
+ templates: Record<string, T>;
4
4
  lockFilePath: string;
5
5
  writeLockFile: boolean;
6
6
  }
7
- export declare const compileTemplates: (options: CompileOptions) => Promise<(string | void)[]>;
7
+ export declare const compileTemplates: <T extends Workflow>(options: CompileOptions<T>) => Promise<(string | void)[]>;
8
8
  export {};
package/dist/template.js CHANGED
@@ -32,15 +32,32 @@ const createLockFile = async (templates, lockFilePath) => {
32
32
  return;
33
33
  const { repository, version } = match.groups;
34
34
  const [owner, repo] = repository.split("/");
35
- const response = await octokit.rest.repos.listTags({
36
- owner,
37
- repo,
38
- });
39
- const tag = response.data.find((tag) => tag.name === version);
40
- if (!tag) {
41
- throw new Error(`Unable to retrieve ${action} from Github tags`);
35
+ if (/^[a-f0-9]{40}$/.test(version)) {
36
+ // Assume version is a SHA
37
+ resolvedActions[action] = `${repository}@${version}`;
38
+ }
39
+ else {
40
+ let tag = null;
41
+ let page = 1;
42
+ const perPage = 100;
43
+ while (!tag) {
44
+ const response = await octokit.rest.repos.listTags({
45
+ owner,
46
+ repo,
47
+ per_page: perPage,
48
+ page,
49
+ });
50
+ tag = response.data.find((tag) => tag.name === version);
51
+ if (response.data.length < perPage) {
52
+ break; // No more pages to check
53
+ }
54
+ page++;
55
+ }
56
+ if (!tag) {
57
+ throw new Error(`Unable to retrieve ${action} from Github tags`);
58
+ }
59
+ resolvedActions[action] = `${repository}@${tag.commit.sha}`;
42
60
  }
43
- resolvedActions[action] = `${repository}@${tag.commit.sha}`;
44
61
  }));
45
62
  fs_1.default.writeFileSync(lockFilePath, JSON.stringify(resolvedActions, null, 2));
46
63
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@factorialco/gat",
3
- "version": "3.4.1",
3
+ "version": "3.4.3",
4
4
  "description": "Write your GitHub Actions workflows using TypeScript",
5
5
  "bin": {
6
6
  "gat": "dist/cli.js"