@procedures/gh 0.0.0-stage → 0.3.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.
Files changed (100) hide show
  1. package/CHANGELOG.md +43 -0
  2. package/LICENSE +21 -0
  3. package/README.md +51 -2
  4. package/dist/.tsbuildinfo +1 -0
  5. package/dist/index.d.ts +3 -0
  6. package/dist/index.d.ts.map +1 -0
  7. package/dist/index.js +4 -0
  8. package/dist/index.js.map +1 -0
  9. package/dist/module.d.ts +18 -0
  10. package/dist/module.d.ts.map +1 -0
  11. package/dist/module.js +101 -0
  12. package/dist/module.js.map +1 -0
  13. package/dist/procedures/gh/index.d.ts +14 -0
  14. package/dist/procedures/gh/index.d.ts.map +1 -0
  15. package/dist/procedures/gh/index.js +14 -0
  16. package/dist/procedures/gh/index.js.map +1 -0
  17. package/dist/procedures/gh/issue/comment.d.ts +12 -0
  18. package/dist/procedures/gh/issue/comment.d.ts.map +1 -0
  19. package/dist/procedures/gh/issue/comment.js +14 -0
  20. package/dist/procedures/gh/issue/comment.js.map +1 -0
  21. package/dist/procedures/gh/issue/create.d.ts +12 -0
  22. package/dist/procedures/gh/issue/create.d.ts.map +1 -0
  23. package/dist/procedures/gh/issue/create.js +17 -0
  24. package/dist/procedures/gh/issue/create.js.map +1 -0
  25. package/dist/procedures/gh/issue/list.d.ts +12 -0
  26. package/dist/procedures/gh/issue/list.d.ts.map +1 -0
  27. package/dist/procedures/gh/issue/list.js +19 -0
  28. package/dist/procedures/gh/issue/list.js.map +1 -0
  29. package/dist/procedures/gh/issue/view.d.ts +12 -0
  30. package/dist/procedures/gh/issue/view.d.ts.map +1 -0
  31. package/dist/procedures/gh/issue/view.js +15 -0
  32. package/dist/procedures/gh/issue/view.js.map +1 -0
  33. package/dist/procedures/gh/pr/checks.d.ts +12 -0
  34. package/dist/procedures/gh/pr/checks.d.ts.map +1 -0
  35. package/dist/procedures/gh/pr/checks.js +23 -0
  36. package/dist/procedures/gh/pr/checks.js.map +1 -0
  37. package/dist/procedures/gh/pr/create.d.ts +12 -0
  38. package/dist/procedures/gh/pr/create.d.ts.map +1 -0
  39. package/dist/procedures/gh/pr/create.js +21 -0
  40. package/dist/procedures/gh/pr/create.js.map +1 -0
  41. package/dist/procedures/gh/pr/list.d.ts +13 -0
  42. package/dist/procedures/gh/pr/list.d.ts.map +1 -0
  43. package/dist/procedures/gh/pr/list.js +21 -0
  44. package/dist/procedures/gh/pr/list.js.map +1 -0
  45. package/dist/procedures/gh/pr/view.d.ts +12 -0
  46. package/dist/procedures/gh/pr/view.d.ts.map +1 -0
  47. package/dist/procedures/gh/pr/view.js +15 -0
  48. package/dist/procedures/gh/pr/view.js.map +1 -0
  49. package/dist/procedures/gh/release/list.d.ts +12 -0
  50. package/dist/procedures/gh/release/list.d.ts.map +1 -0
  51. package/dist/procedures/gh/release/list.js +14 -0
  52. package/dist/procedures/gh/release/list.js.map +1 -0
  53. package/dist/procedures/gh/release/view.d.ts +12 -0
  54. package/dist/procedures/gh/release/view.d.ts.map +1 -0
  55. package/dist/procedures/gh/release/view.js +16 -0
  56. package/dist/procedures/gh/release/view.js.map +1 -0
  57. package/dist/procedures/gh/run/list.d.ts +12 -0
  58. package/dist/procedures/gh/run/list.d.ts.map +1 -0
  59. package/dist/procedures/gh/run/list.js +21 -0
  60. package/dist/procedures/gh/run/list.js.map +1 -0
  61. package/dist/procedures/gh/run/rerun.d.ts +12 -0
  62. package/dist/procedures/gh/run/rerun.d.ts.map +1 -0
  63. package/dist/procedures/gh/run/rerun.js +17 -0
  64. package/dist/procedures/gh/run/rerun.js.map +1 -0
  65. package/dist/procedures/gh/run/view.d.ts +12 -0
  66. package/dist/procedures/gh/run/view.d.ts.map +1 -0
  67. package/dist/procedures/gh/run/view.js +15 -0
  68. package/dist/procedures/gh/run/view.js.map +1 -0
  69. package/dist/procedures/gh/shared.d.ts +30 -0
  70. package/dist/procedures/gh/shared.d.ts.map +1 -0
  71. package/dist/procedures/gh/shared.js +63 -0
  72. package/dist/procedures/gh/shared.js.map +1 -0
  73. package/dist/register.d.ts +6 -0
  74. package/dist/register.d.ts.map +1 -0
  75. package/dist/register.js +8 -0
  76. package/dist/register.js.map +1 -0
  77. package/dist/types.d.ts +108 -0
  78. package/dist/types.d.ts.map +1 -0
  79. package/dist/types.js +8 -0
  80. package/dist/types.js.map +1 -0
  81. package/package.json +78 -3
  82. package/src/index.ts +3 -0
  83. package/src/module.ts +167 -0
  84. package/src/procedures/gh/index.ts +13 -0
  85. package/src/procedures/gh/issue/comment.ts +17 -0
  86. package/src/procedures/gh/issue/create.ts +19 -0
  87. package/src/procedures/gh/issue/list.ts +21 -0
  88. package/src/procedures/gh/issue/view.ts +19 -0
  89. package/src/procedures/gh/pr/checks.ts +25 -0
  90. package/src/procedures/gh/pr/create.ts +21 -0
  91. package/src/procedures/gh/pr/list.ts +22 -0
  92. package/src/procedures/gh/pr/view.ts +19 -0
  93. package/src/procedures/gh/release/list.ts +17 -0
  94. package/src/procedures/gh/release/view.ts +20 -0
  95. package/src/procedures/gh/run/list.ts +22 -0
  96. package/src/procedures/gh/run/rerun.ts +19 -0
  97. package/src/procedures/gh/run/view.ts +19 -0
  98. package/src/procedures/gh/shared.ts +75 -0
  99. package/src/register.ts +10 -0
  100. package/src/types.ts +124 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list.js","sourceRoot":"","sources":["../../../../src/procedures/gh/run/list.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAEjE,MAAM,MAAM,GAAG,yGAAyG,CAAC;AAEzH;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,KAAqB,EAAE,GAAqB;IAC1E,MAAM,IAAI,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,QAAQ,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,IAAI,EAAE,EAAE,CAAC,EAAE,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;IAC9G,IAAI,KAAK,CAAC,QAAQ,KAAK,SAAS;QAAE,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC;IAC7F,IAAI,KAAK,CAAC,MAAM,KAAK,SAAS;QAAE,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,KAAK,CAAC,QAAQ,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;IACrF,IAAI,KAAK,CAAC,MAAM,KAAK,SAAS;QAAE,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,KAAK,CAAC,QAAQ,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;IACrF,OAAO,EAAE,KAAK,EAAE,MAAM,MAAM,CAAiC,IAAI,EAAE,KAAK,EAAE,GAAG,CAAC,EAAE,CAAC;AACnF,CAAC"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * gh.run.rerun procedure
3
+ *
4
+ * Run a workflow run again
5
+ */
6
+ import type { ProcedureContext } from "@procedures/client";
7
+ import type { GhRunRerunInput, GhRunRerunOutput } from "../../../types.js";
8
+ /**
9
+ * Run a workflow run again
10
+ */
11
+ export declare function ghRunRerun(input: GhRunRerunInput, ctx: ProcedureContext): Promise<GhRunRerunOutput>;
12
+ //# sourceMappingURL=rerun.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rerun.d.ts","sourceRoot":"","sources":["../../../../src/procedures/gh/run/rerun.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAG3E;;GAEG;AACH,wBAAsB,UAAU,CAAC,KAAK,EAAE,eAAe,EAAE,GAAG,EAAE,gBAAgB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAKzG"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * gh.run.rerun procedure
3
+ *
4
+ * Run a workflow run again
5
+ */
6
+ import { repoArgs, runGh } from "../shared.js";
7
+ /**
8
+ * Run a workflow run again
9
+ */
10
+ export async function ghRunRerun(input, ctx) {
11
+ const args = ["run", "rerun", String(input.run), ...repoArgs(input)];
12
+ if (input.failedOnly)
13
+ args.push("--failed");
14
+ await runGh(args, input, ctx);
15
+ return { run: input.run };
16
+ }
17
+ //# sourceMappingURL=rerun.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rerun.js","sourceRoot":"","sources":["../../../../src/procedures/gh/run/rerun.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAE/C;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,KAAsB,EAAE,GAAqB;IAC5E,MAAM,IAAI,GAAG,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;IACrE,IAAI,KAAK,CAAC,UAAU;QAAE,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IAC5C,MAAM,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC;IAC9B,OAAO,EAAE,GAAG,EAAE,KAAK,CAAC,GAAG,EAAE,CAAC;AAC5B,CAAC"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * gh.run.view procedure
3
+ *
4
+ * One workflow run with its jobs
5
+ */
6
+ import type { ProcedureContext } from "@procedures/client";
7
+ import type { GhRunViewInput, GhRunViewOutput } from "../../../types.js";
8
+ /**
9
+ * One workflow run with its jobs
10
+ */
11
+ export declare function ghRunView(input: GhRunViewInput, ctx: ProcedureContext): Promise<GhRunViewOutput>;
12
+ //# sourceMappingURL=view.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"view.d.ts","sourceRoot":"","sources":["../../../../src/procedures/gh/run/view.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAKzE;;GAEG;AACH,wBAAsB,SAAS,CAAC,KAAK,EAAE,cAAc,EAAE,GAAG,EAAE,gBAAgB,GAAG,OAAO,CAAC,eAAe,CAAC,CAGtG"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * gh.run.view procedure
3
+ *
4
+ * One workflow run with its jobs
5
+ */
6
+ import { ghJson, repoArgs } from "../shared.js";
7
+ const FIELDS = "databaseId,workflowName,displayTitle,headBranch,headSha,event,status,conclusion,url,createdAt,updatedAt,jobs";
8
+ /**
9
+ * One workflow run with its jobs
10
+ */
11
+ export async function ghRunView(input, ctx) {
12
+ const args = ["run", "view", String(input.run), "--json", FIELDS, ...repoArgs(input)];
13
+ return { item: await ghJson(args, input, ctx) };
14
+ }
15
+ //# sourceMappingURL=view.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"view.js","sourceRoot":"","sources":["../../../../src/procedures/gh/run/view.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAEhD,MAAM,MAAM,GAAG,8GAA8G,CAAC;AAE9H;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,KAAqB,EAAE,GAAqB;IAC1E,MAAM,IAAI,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;IACtF,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAA0B,IAAI,EAAE,KAAK,EAAE,GAAG,CAAC,EAAE,CAAC;AAC3E,CAAC"}
@@ -0,0 +1,30 @@
1
+ /**
2
+ * The way every gh procedure runs the GitHub CLI: an argument list through `shell.run`, no
3
+ * shell. A value that gh reads as an argument must not start with "-", so it cannot become an
4
+ * option. The output is the JSON of `--json` where gh has it.
5
+ */
6
+ import type { ProcedureContext } from "@procedures/client";
7
+ import type { GhCommonInput } from "../../types.js";
8
+ /** A failed gh command: its exit code and its error text. */
9
+ export declare class GhError extends Error {
10
+ readonly exitCode: number;
11
+ readonly stderr: string;
12
+ readonly name = "GhError";
13
+ constructor(message: string, exitCode: number, stderr: string);
14
+ }
15
+ /** A value that gh reads as an argument (a branch, a tag, a title): it must not start with "-". */
16
+ export declare function ghArg(name: string, value: string): string;
17
+ /** The option `--repo owner/name`, when the input gives a repository. */
18
+ export declare function repoArgs(input: GhCommonInput): string[];
19
+ /** This function runs `gh <args>` and gives its output. It throws a GhError for a failed command. */
20
+ export declare function runGh(args: string[], input: GhCommonInput, ctx: ProcedureContext): Promise<string>;
21
+ /** This function runs gh with `--json` and gives the parsed value. */
22
+ export declare function ghJson<T>(args: string[], input: GhCommonInput, ctx: ProcedureContext): Promise<T>;
23
+ /** The options of a list: its limit and a search. */
24
+ export declare function listArgs(input: {
25
+ limit?: number | undefined;
26
+ search?: string | undefined;
27
+ }): string[];
28
+ /** The last line of an output that is a URL: gh prints the URL of what it made. */
29
+ export declare function urlOf(output: string): string;
30
+ //# sourceMappingURL=shared.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../../src/procedures/gh/shared.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAUpD,6DAA6D;AAC7D,qBAAa,OAAQ,SAAQ,KAAK;IAI9B,QAAQ,CAAC,QAAQ,EAAE,MAAM;IACzB,QAAQ,CAAC,MAAM,EAAE,MAAM;IAJzB,SAAkB,IAAI,aAAa;IACnC,YACE,OAAO,EAAE,MAAM,EACN,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EAGxB;CACF;AAED,mGAAmG;AACnG,wBAAgB,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAGzD;AAED,yEAAyE;AACzE,wBAAgB,QAAQ,CAAC,KAAK,EAAE,aAAa,GAAG,MAAM,EAAE,CAEvD;AAED,qGAAqG;AACrG,wBAAsB,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,aAAa,EAAE,GAAG,EAAE,gBAAgB,GAAG,OAAO,CAAC,MAAM,CAAC,CAUxG;AAED,sEAAsE;AACtE,wBAAsB,MAAM,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,aAAa,EAAE,GAAG,EAAE,gBAAgB,GAAG,OAAO,CAAC,CAAC,CAAC,CAOvG;AAED,qDAAqD;AACrD,wBAAgB,QAAQ,CAAC,KAAK,EAAE;IAAE,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,GAAG,MAAM,EAAE,CAIrG;AAED,mFAAmF;AACnF,wBAAgB,KAAK,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAG5C"}
@@ -0,0 +1,63 @@
1
+ /**
2
+ * The way every gh procedure runs the GitHub CLI: an argument list through `shell.run`, no
3
+ * shell. A value that gh reads as an argument must not start with "-", so it cannot become an
4
+ * option. The output is the JSON of `--json` where gh has it.
5
+ */
6
+ /** A failed gh command: its exit code and its error text. */
7
+ export class GhError extends Error {
8
+ exitCode;
9
+ stderr;
10
+ name = "GhError";
11
+ constructor(message, exitCode, stderr) {
12
+ super(message);
13
+ this.exitCode = exitCode;
14
+ this.stderr = stderr;
15
+ }
16
+ }
17
+ /** A value that gh reads as an argument (a branch, a tag, a title): it must not start with "-". */
18
+ export function ghArg(name, value) {
19
+ if (value.startsWith("-"))
20
+ throw new Error(`Invalid ${name} (starts with "-"): ${value}`);
21
+ return value;
22
+ }
23
+ /** The option `--repo owner/name`, when the input gives a repository. */
24
+ export function repoArgs(input) {
25
+ return input.repo === undefined ? [] : ["--repo", ghArg("repo", input.repo)];
26
+ }
27
+ /** This function runs `gh <args>` and gives its output. It throws a GhError for a failed command. */
28
+ export async function runGh(args, input, ctx) {
29
+ const shellInput = { command: "gh", args };
30
+ if (input.cwd !== undefined)
31
+ shellInput.cwd = input.cwd;
32
+ if (input.timeoutMs !== undefined)
33
+ shellInput.timeout = input.timeoutMs;
34
+ const result = await ctx.client.call(["shell", "run"], shellInput);
35
+ if (result.exitCode !== 0) {
36
+ const text = result.stderr.trim() || result.stdout.trim();
37
+ throw new GhError(`gh ${args[0] ?? ""} ${args[1] ?? ""} failed (exit ${result.exitCode}): ${text}`.trim(), result.exitCode, result.stderr);
38
+ }
39
+ return result.stdout;
40
+ }
41
+ /** This function runs gh with `--json` and gives the parsed value. */
42
+ export async function ghJson(args, input, ctx) {
43
+ const output = await runGh(args, input, ctx);
44
+ try {
45
+ return JSON.parse(output);
46
+ }
47
+ catch {
48
+ throw new GhError(`gh ${args[0] ?? ""} ${args[1] ?? ""} gave no JSON: ${output.slice(0, 200)}`, 0, "");
49
+ }
50
+ }
51
+ /** The options of a list: its limit and a search. */
52
+ export function listArgs(input) {
53
+ const args = ["--limit", String(input.limit ?? 30)];
54
+ if (input.search !== undefined)
55
+ args.push("--search", input.search);
56
+ return args;
57
+ }
58
+ /** The last line of an output that is a URL: gh prints the URL of what it made. */
59
+ export function urlOf(output) {
60
+ const lines = output.trim().split(/\r?\n/);
61
+ return lines.reverse().find((line) => line.startsWith("https://")) ?? lines[0] ?? "";
62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SAAS;QAAE,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACpE,OAAO,IAAI,CAAC;AACd,CAAC;AAED,mFAAmF;AACnF,MAAM,UAAU,KAAK,CAAC,MAAc;IAClC,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAC3C,OAAO,KAAK,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;AACvF,CAAC"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Importing this file registers the procedures of @procedures/gh in the global registry:
3
+ * `import "@procedures/gh/register"`. The package root registers nothing.
4
+ */
5
+ export * from "./module.js";
6
+ //# sourceMappingURL=register.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"register.d.ts","sourceRoot":"","sources":["../src/register.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,cAAc,aAAa,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Importing this file registers the procedures of @procedures/gh in the global registry:
3
+ * `import "@procedures/gh/register"`. The package root registers nothing.
4
+ */
5
+ import { registerGhProcedures } from "./module.js";
6
+ export * from "./module.js";
7
+ registerGhProcedures();
8
+ //# sourceMappingURL=register.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"register.js","sourceRoot":"","sources":["../src/register.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAEnD,cAAc,aAAa,CAAC;AAE5B,oBAAoB,EAAE,CAAC"}
@@ -0,0 +1,108 @@
1
+ /**
2
+ * Type definitions of the procedures of this package
3
+ *
4
+ * mark procedure new adds the types of each new procedure here. The zod schemas are in
5
+ * `module.ts`: an exported schema needs a written type (isolatedDeclarations).
6
+ */
7
+ /** The fields of each gh procedure. */
8
+ export interface GhCommonInput {
9
+ /** The repository as owner/name (default: the repository of the folder) */
10
+ repo?: string | undefined;
11
+ /** The folder where gh runs */
12
+ cwd?: string | undefined;
13
+ /** The time limit of the command, in milliseconds */
14
+ timeoutMs?: number | undefined;
15
+ }
16
+ /** A list of the JSON objects that gh gives. */
17
+ export interface GhListOutput {
18
+ items: Array<Record<string, unknown>>;
19
+ }
20
+ /** One JSON object that gh gives. */
21
+ export interface GhItemOutput {
22
+ item: Record<string, unknown>;
23
+ }
24
+ /** What gh made: its URL. */
25
+ export interface GhCreatedOutput {
26
+ url: string;
27
+ }
28
+ export interface GhPrListInput extends GhCommonInput {
29
+ state?: "open" | "closed" | "merged" | "all" | undefined;
30
+ author?: string | undefined;
31
+ base?: string | undefined;
32
+ head?: string | undefined;
33
+ search?: string | undefined;
34
+ limit?: number | undefined;
35
+ }
36
+ export type GhPrListOutput = GhListOutput;
37
+ export interface GhPrViewInput extends GhCommonInput {
38
+ /** The number, the branch or the URL of the pull request */
39
+ pr: string;
40
+ }
41
+ export type GhPrViewOutput = GhItemOutput;
42
+ export interface GhPrChecksInput extends GhCommonInput {
43
+ pr: string;
44
+ }
45
+ export type GhPrChecksOutput = GhListOutput;
46
+ export interface GhPrCreateInput extends GhCommonInput {
47
+ title: string;
48
+ body: string;
49
+ base?: string | undefined;
50
+ head?: string | undefined;
51
+ draft?: boolean | undefined;
52
+ }
53
+ export type GhPrCreateOutput = GhCreatedOutput;
54
+ export interface GhRunListInput extends GhCommonInput {
55
+ workflow?: string | undefined;
56
+ branch?: string | undefined;
57
+ status?: string | undefined;
58
+ limit?: number | undefined;
59
+ }
60
+ export type GhRunListOutput = GhListOutput;
61
+ export interface GhRunViewInput extends GhCommonInput {
62
+ /** The id of the run */
63
+ run: number;
64
+ }
65
+ export type GhRunViewOutput = GhItemOutput;
66
+ export interface GhRunRerunInput extends GhCommonInput {
67
+ run: number;
68
+ /** Only the jobs that failed */
69
+ failedOnly?: boolean | undefined;
70
+ }
71
+ export interface GhRunRerunOutput {
72
+ run: number;
73
+ }
74
+ export interface GhReleaseListInput extends GhCommonInput {
75
+ limit?: number | undefined;
76
+ }
77
+ export type GhReleaseListOutput = GhListOutput;
78
+ export interface GhReleaseViewInput extends GhCommonInput {
79
+ /** The tag of the release (default: the latest release) */
80
+ tag?: string | undefined;
81
+ }
82
+ export type GhReleaseViewOutput = GhItemOutput;
83
+ export interface GhIssueListInput extends GhCommonInput {
84
+ state?: "open" | "closed" | "all" | undefined;
85
+ label?: string | undefined;
86
+ author?: string | undefined;
87
+ search?: string | undefined;
88
+ limit?: number | undefined;
89
+ }
90
+ export type GhIssueListOutput = GhListOutput;
91
+ export interface GhIssueViewInput extends GhCommonInput {
92
+ /** The number or the URL of the issue */
93
+ issue: string;
94
+ }
95
+ export type GhIssueViewOutput = GhItemOutput;
96
+ export interface GhIssueCreateInput extends GhCommonInput {
97
+ title: string;
98
+ body: string;
99
+ labels?: string[] | undefined;
100
+ }
101
+ export type GhIssueCreateOutput = GhCreatedOutput;
102
+ export interface GhIssueCommentInput extends GhCommonInput {
103
+ /** The number or the URL of the issue or the pull request */
104
+ issue: string;
105
+ body: string;
106
+ }
107
+ export type GhIssueCommentOutput = GhCreatedOutput;
108
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,uCAAuC;AACvC,MAAM,WAAW,aAAa;IAC5B,2EAA2E;IAC3E,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,+BAA+B;IAC/B,GAAG,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB,qDAAqD;IACrD,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAChC;AAED,gDAAgD;AAChD,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,KAAK,CAAC,M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E7C,MAAM,WAAW,gBAAiB,SAAQ,aAAa;IACrD,yCAAyC;IACzC,KAAK,EAAE,MAAM,CAAC;CACf;AACD,MAAM,MAAM,iBAAiB,GAAG,YAAY,CAAC;AAE7C,MAAM,WAAW,kBAAmB,SAAQ,aAAa;IACvD,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;CAC/B;AACD,MAAM,MAAM,mBAAmB,GAAG,eAAe,CAAC;AAElD,MAAM,WAAW,mBAAoB,SAAQ,aAAa;IACxD,6DAA6D;IAC7D,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;CACd;AACD,MAAM,MAAM,oBAAoB,GAAG,eAAe,CAAC"}
package/dist/types.js ADDED
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Type definitions of the procedures of this package
3
+ *
4
+ * mark procedure new adds the types of each new procedure here. The zod schemas are in
5
+ * `module.ts`: an exported schema needs a written type (isolatedDeclarations).
6
+ */
7
+ export {};
8
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
package/package.json CHANGED
@@ -1,6 +1,81 @@
1
1
  {
2
+ "$schema": "https://json.schemastore.org/package",
2
3
  "name": "@procedures/gh",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
4
+ "version": "0.3.0",
5
+ "description": "The GitHub CLI as procedures: pull requests, workflow runs, releases and issues, with an argument list and no shell.",
6
+ "keywords": [
7
+ "procedures",
8
+ "github",
9
+ "gh",
10
+ "pull-requests",
11
+ "workflows",
12
+ "releases",
13
+ "issues"
14
+ ],
15
+ "homepage": "https://mark1russell7.github.io/client/",
16
+ "bugs": {
17
+ "url": "https://github.com/mark1russell7/client/issues"
18
+ },
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "git+https://github.com/mark1russell7/client.git",
22
+ "directory": "packages/gh"
23
+ },
24
+ "license": "MIT",
25
+ "author": "Mark Russell (https://github.com/mark1russell7)",
26
+ "type": "module",
27
+ "main": "./dist/index.js",
28
+ "types": "./dist/index.d.ts",
29
+ "exports": {
30
+ ".": {
31
+ "types": "./dist/index.d.ts",
32
+ "import": "./dist/index.js"
33
+ },
34
+ "./module": {
35
+ "types": "./dist/module.d.ts",
36
+ "import": "./dist/module.js"
37
+ },
38
+ "./register": {
39
+ "types": "./dist/register.d.ts",
40
+ "import": "./dist/register.js"
41
+ }
42
+ },
43
+ "files": [
44
+ "dist",
45
+ "src",
46
+ "!src/**/*.test.ts",
47
+ "!src/**/*.test.tsx",
48
+ "!src/**/__tests__",
49
+ "CHANGELOG.md"
50
+ ],
51
+ "sideEffects": [
52
+ "./dist/register.js"
53
+ ],
54
+ "devDependencies": {
55
+ "@mark1russell7/cue": "^1.0.0",
56
+ "typescript": "^7.0.2",
57
+ "vitest": "^5.0.3"
58
+ },
59
+ "engines": {
60
+ "node": ">=22"
61
+ },
62
+ "client": {
63
+ "procedures": "./dist/register.js"
64
+ },
65
+ "dependencies": {
66
+ "@procedures/client": "0.3.0",
67
+ "@procedures/shell": "0.3.0",
68
+ "zod": "^4.6.5"
69
+ },
70
+ "publishConfig": {
71
+ "access": "public",
72
+ "provenance": true
73
+ },
74
+ "scripts": {
75
+ "build": "tsc -b",
76
+ "typecheck": "tsc --noEmit",
77
+ "clean": "rm -rf dist .tsbuildinfo",
78
+ "test": "vitest run",
79
+ "test:watch": "vitest"
80
+ }
6
81
  }
package/src/index.ts ADDED
@@ -0,0 +1,3 @@
1
+ // The root registers nothing: import "<package>/register", or give the module to createRegistry()
2
+ export * from "./module.js";
3
+ export * from "./types.js";
package/src/module.ts ADDED
@@ -0,0 +1,167 @@
1
+ /**
2
+ * The procedures of @procedures/gh as data. Importing this file registers nothing.
3
+ *
4
+ * Each procedure runs the GitHub CLI (`gh`) through `shell.run`, with an argument list and no
5
+ * shell (roadmap R42). The reads declare `reads: ["network"]`. The procedures that make or change
6
+ * something on GitHub declare `writes: ["network"]`.
7
+ *
8
+ * Scaffold a procedure with: mark procedure new <name> --path packages/gh
9
+ */
10
+
11
+ import { z } from "zod";
12
+ import { defineModule, registerModules, PROCEDURE_REGISTRY, type AnyProcedure, type Effects, type ProcedureModule, type ProcedureRegistry, createProcedure, zodAdapter } from "@procedures/client";
13
+ import shellModule from "@procedures/shell/module";
14
+ import { ghPrList } from "./procedures/gh/pr/list.js";
15
+ import { ghPrView } from "./procedures/gh/pr/view.js";
16
+ import { ghPrChecks } from "./procedures/gh/pr/checks.js";
17
+ import { ghPrCreate } from "./procedures/gh/pr/create.js";
18
+ import { ghRunList } from "./procedures/gh/run/list.js";
19
+ import { ghRunView } from "./procedures/gh/run/view.js";
20
+ import { ghRunRerun } from "./procedures/gh/run/rerun.js";
21
+ import { ghReleaseList } from "./procedures/gh/release/list.js";
22
+ import { ghReleaseView } from "./procedures/gh/release/view.js";
23
+ import { ghIssueList } from "./procedures/gh/issue/list.js";
24
+ import { ghIssueView } from "./procedures/gh/issue/view.js";
25
+ import { ghIssueCreate } from "./procedures/gh/issue/create.js";
26
+ import { ghIssueComment } from "./procedures/gh/issue/comment.js";
27
+
28
+ /** A read of GitHub: it changes nothing. */
29
+ const READS: Effects = { reads: ["network"], writes: [] };
30
+ /** A write to GitHub that makes something new: not destructive, and a second call makes a second one. */
31
+ const MAKES: Effects = { reads: ["network"], writes: ["network"], destructive: false, idempotent: false };
32
+
33
+ const common = {
34
+ repo: z.string().regex(/^[\w.-]+\/[\w.-]+$/, "owner/name").optional().describe("The repository as owner/name (default: the repository of the folder)"),
35
+ cwd: z.string().optional().describe("The folder where gh runs"),
36
+ timeoutMs: z.number().int().min(1).optional().describe("The time limit of the command, in milliseconds"),
37
+ };
38
+ const limit = z.number().int().min(1).max(1000).optional().describe("The most items (default 30)");
39
+ const list = z.object({ items: z.array(z.record(z.string(), z.unknown())).describe("The JSON objects that gh gives") });
40
+ const item = z.object({ item: z.record(z.string(), z.unknown()).describe("The JSON object that gh gives") });
41
+ const created = z.object({ url: z.string().describe("The URL of what gh made") });
42
+
43
+ /** One procedure of this package. Each one runs gh through shell.run, and declares it. */
44
+ function gh<I, O>(
45
+ path: string[],
46
+ description: string,
47
+ input: z.ZodType<I>,
48
+ output: z.ZodType<O>,
49
+ effects: Effects,
50
+ handler: (input: I, ctx: Parameters<typeof ghPrList>[1]) => Promise<O>,
51
+ args: string[] = [],
52
+ ): AnyProcedure {
53
+ return createProcedure()
54
+ .path(path)
55
+ .input(zodAdapter<I>(input))
56
+ .output(zodAdapter<O>(output))
57
+ .meta({ description, args, shorts: {}, output: "json", effects, calls: ["shell.run"] })
58
+ .handler(handler as never)
59
+ .build() as unknown as AnyProcedure;
60
+ }
61
+
62
+ const procedures: AnyProcedure[] = [
63
+ gh(
64
+ ["gh", "pr", "list"],
65
+ "The pull requests of a repository",
66
+ z.object({
67
+ ...common,
68
+ state: z.enum(["open", "closed", "merged", "all"]).optional().describe("The state (default open)"),
69
+ author: z.string().optional().describe("Only the pull requests of this author"),
70
+ base: z.string().optional().describe("Only the pull requests into this branch"),
71
+ head: z.string().optional().describe("Only the pull requests from this branch"),
72
+ search: z.string().optional().describe("A search of GitHub"),
73
+ limit,
74
+ }),
75
+ list,
76
+ READS,
77
+ ghPrList,
78
+ ),
79
+ gh(["gh", "pr", "view"], "One pull request", z.object({ ...common, pr: z.string().min(1).describe("The number, the branch or the URL of the pull request") }), item, READS, ghPrView, ["pr"]),
80
+ gh(["gh", "pr", "checks"], "The checks of a pull request", z.object({ ...common, pr: z.string().min(1).describe("The number, the branch or the URL of the pull request") }), list, READS, ghPrChecks, ["pr"]),
81
+ gh(
82
+ ["gh", "pr", "create"],
83
+ "Open a pull request",
84
+ z.object({
85
+ ...common,
86
+ title: z.string().min(1).describe("The title"),
87
+ body: z.string().describe("The text of the pull request"),
88
+ base: z.string().optional().describe("The branch to merge into (default: the default branch)"),
89
+ head: z.string().optional().describe("The branch with the changes (default: the current branch)"),
90
+ draft: z.boolean().optional().describe("Open it as a draft"),
91
+ }),
92
+ created,
93
+ MAKES,
94
+ ghPrCreate,
95
+ ),
96
+ gh(
97
+ ["gh", "run", "list"],
98
+ "The workflow runs of a repository",
99
+ z.object({
100
+ ...common,
101
+ workflow: z.string().optional().describe("The name or the file of a workflow"),
102
+ branch: z.string().optional().describe("Only the runs of this branch"),
103
+ status: z.string().optional().describe("Only the runs with this status, for example completed or failure"),
104
+ limit: z.number().int().min(1).max(1000).optional().describe("The most runs (default 20)"),
105
+ }),
106
+ list,
107
+ READS,
108
+ ghRunList,
109
+ ),
110
+ gh(["gh", "run", "view"], "One workflow run with its jobs", z.object({ ...common, run: z.number().int().min(1).describe("The id of the run") }), item, READS, ghRunView, ["run"]),
111
+ gh(
112
+ ["gh", "run", "rerun"],
113
+ "Run a workflow run again",
114
+ z.object({ ...common, run: z.number().int().min(1).describe("The id of the run"), failedOnly: z.boolean().optional().describe("Only the jobs that failed") }),
115
+ z.object({ run: z.number().describe("The id of the run") }),
116
+ MAKES,
117
+ ghRunRerun,
118
+ ["run"],
119
+ ),
120
+ gh(["gh", "release", "list"], "The releases of a repository", z.object({ ...common, limit }), list, READS, ghReleaseList),
121
+ gh(["gh", "release", "view"], "One release: the release of a tag, or the latest release", z.object({ ...common, tag: z.string().optional().describe("The tag (default: the latest release)") }), item, READS, ghReleaseView, ["tag"]),
122
+ gh(
123
+ ["gh", "issue", "list"],
124
+ "The issues of a repository",
125
+ z.object({
126
+ ...common,
127
+ state: z.enum(["open", "closed", "all"]).optional().describe("The state (default open)"),
128
+ label: z.string().optional().describe("Only the issues with this label"),
129
+ author: z.string().optional().describe("Only the issues of this author"),
130
+ search: z.string().optional().describe("A search of GitHub"),
131
+ limit,
132
+ }),
133
+ list,
134
+ READS,
135
+ ghIssueList,
136
+ ),
137
+ gh(["gh", "issue", "view"], "One issue, with its comments", z.object({ ...common, issue: z.string().min(1).describe("The number or the URL of the issue") }), item, READS, ghIssueView, ["issue"]),
138
+ gh(
139
+ ["gh", "issue", "create"],
140
+ "Open an issue",
141
+ z.object({ ...common, title: z.string().min(1).describe("The title"), body: z.string().describe("The text of the issue"), labels: z.array(z.string()).optional().describe("The labels") }),
142
+ created,
143
+ MAKES,
144
+ ghIssueCreate,
145
+ ),
146
+ gh(
147
+ ["gh", "issue", "comment"],
148
+ "Add a comment to an issue or a pull request",
149
+ z.object({ ...common, issue: z.string().min(1).describe("The number or the URL of the issue or the pull request"), body: z.string().min(1).describe("The text of the comment") }),
150
+ created,
151
+ MAKES,
152
+ ghIssueComment,
153
+ ["issue"],
154
+ ),
155
+ ];
156
+
157
+ export const ghModule: ProcedureModule = defineModule("@procedures/gh", procedures, [shellModule]);
158
+
159
+ export default ghModule;
160
+
161
+ /**
162
+ * This function registers the procedures of @procedures/gh in a registry. The default is the
163
+ * global registry.
164
+ */
165
+ export function registerGhProcedures(registry: ProcedureRegistry = PROCEDURE_REGISTRY): void {
166
+ registerModules(registry, [ghModule]);
167
+ }
@@ -0,0 +1,13 @@
1
+ export { ghPrList } from "./pr/list.js";
2
+ export { ghPrView } from "./pr/view.js";
3
+ export { ghPrChecks } from "./pr/checks.js";
4
+ export { ghPrCreate } from "./pr/create.js";
5
+ export { ghRunList } from "./run/list.js";
6
+ export { ghRunView } from "./run/view.js";
7
+ export { ghRunRerun } from "./run/rerun.js";
8
+ export { ghReleaseList } from "./release/list.js";
9
+ export { ghReleaseView } from "./release/view.js";
10
+ export { ghIssueList } from "./issue/list.js";
11
+ export { ghIssueView } from "./issue/view.js";
12
+ export { ghIssueCreate } from "./issue/create.js";
13
+ export { ghIssueComment } from "./issue/comment.js";
@@ -0,0 +1,17 @@
1
+ /**
2
+ * gh.issue.comment procedure
3
+ *
4
+ * Add a comment to an issue or a pull request
5
+ */
6
+
7
+ import type { ProcedureContext } from "@procedures/client";
8
+ import type { GhIssueCommentInput, GhIssueCommentOutput } from "../../../types.js";
9
+ import { ghArg, repoArgs, runGh, urlOf } from "../shared.js";
10
+
11
+ /**
12
+ * Add a comment to an issue or a pull request
13
+ */
14
+ export async function ghIssueComment(input: GhIssueCommentInput, ctx: ProcedureContext): Promise<GhIssueCommentOutput> {
15
+ const args = ["issue", "comment", ghArg("issue", input.issue), "--body", input.body, ...repoArgs(input)];
16
+ return { url: urlOf(await runGh(args, input, ctx)) };
17
+ }