gh-inari 0.1.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/LICENSE +21 -0
- package/README.md +112 -0
- package/dist/artifact.d.ts +82 -0
- package/dist/artifact.js +472 -0
- package/dist/artifact.js.map +1 -0
- package/dist/cli.d.ts +14 -0
- package/dist/cli.js +395 -0
- package/dist/cli.js.map +1 -0
- package/dist/contract/index.d.ts +4 -0
- package/dist/contract/index.js +5 -0
- package/dist/contract/index.js.map +1 -0
- package/dist/contract/ir.d.ts +178 -0
- package/dist/contract/ir.js +1071 -0
- package/dist/contract/ir.js.map +1 -0
- package/dist/contract/issue-form.d.ts +38 -0
- package/dist/contract/issue-form.js +662 -0
- package/dist/contract/issue-form.js.map +1 -0
- package/dist/contract/schema.d.ts +48 -0
- package/dist/contract/schema.js +162 -0
- package/dist/contract/schema.js.map +1 -0
- package/dist/contract/validation.d.ts +24 -0
- package/dist/contract/validation.js +212 -0
- package/dist/contract/validation.js.map +1 -0
- package/dist/github/adapter.d.ts +48 -0
- package/dist/github/adapter.js +463 -0
- package/dist/github/adapter.js.map +1 -0
- package/dist/github/errors.d.ts +43 -0
- package/dist/github/errors.js +65 -0
- package/dist/github/errors.js.map +1 -0
- package/dist/github/index.d.ts +4 -0
- package/dist/github/index.js +5 -0
- package/dist/github/index.js.map +1 -0
- package/dist/github/transport.d.ts +19 -0
- package/dist/github/transport.js +54 -0
- package/dist/github/transport.js.map +1 -0
- package/dist/github/types.d.ts +62 -0
- package/dist/github/types.js +16 -0
- package/dist/github/types.js.map +1 -0
- package/dist/github.d.ts +1 -0
- package/dist/github.js +2 -0
- package/dist/github.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +32 -0
- package/dist/index.js.map +1 -0
- package/dist/pr-policy.d.ts +39 -0
- package/dist/pr-policy.js +313 -0
- package/dist/pr-policy.js.map +1 -0
- package/dist/pull-request-template.d.ts +42 -0
- package/dist/pull-request-template.js +481 -0
- package/dist/pull-request-template.js.map +1 -0
- package/dist/template-discovery.d.ts +68 -0
- package/dist/template-discovery.js +431 -0
- package/dist/template-discovery.js.map +1 -0
- package/gh-inari +18 -0
- package/package.json +92 -0
package/dist/cli.js
ADDED
|
@@ -0,0 +1,395 @@
|
|
|
1
|
+
import { access, readFile } from "node:fs/promises";
|
|
2
|
+
import { readFileSync } from "node:fs";
|
|
3
|
+
import { createInterface } from "node:readline";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import { fileURLToPath } from "node:url";
|
|
6
|
+
import { ArtifactInputError, parseArtifactInputDocument, prepareIssueArtifact, preparePullRequestArtifact, renderIssueArtifact, renderPullRequestArtifact, validateExistingIssueArtifact, validateExistingPullRequestArtifact, } from "./artifact.js";
|
|
7
|
+
import { compileIssueFormTemplate, projectContract, SemanticValidationError, validateSemanticInput, } from "./contract/index.js";
|
|
8
|
+
import { GitHubAdapter, isGitHubAdapterError } from "./github/index.js";
|
|
9
|
+
import { compilePullRequestPolicyFile } from "./pr-policy.js";
|
|
10
|
+
import { compilePullRequestTemplate } from "./pull-request-template.js";
|
|
11
|
+
import { discoverTemplates } from "./template-discovery.js";
|
|
12
|
+
const EXIT_USAGE = 1;
|
|
13
|
+
const EXIT_VALIDATION = 2;
|
|
14
|
+
const EXIT_REMOTE = 3;
|
|
15
|
+
const EXIT_INTERNAL = 4;
|
|
16
|
+
const BOOLEAN_OPTIONS = new Set(["help", "json", "version", "draft", "maintainerCanModify"]);
|
|
17
|
+
const VALUE_OPTIONS = new Set(["from", "template", "policy", "repository", "title", "head", "base"]);
|
|
18
|
+
/** The installed gh-inari executable entrypoint. */
|
|
19
|
+
export async function runCli(argv, dependencies = {}) {
|
|
20
|
+
const metadata = dependencies.packageMetadata ?? readPackageMetadata();
|
|
21
|
+
let parsed;
|
|
22
|
+
try {
|
|
23
|
+
parsed = parseArguments(argv);
|
|
24
|
+
}
|
|
25
|
+
catch (error) {
|
|
26
|
+
const shape = toErrorShape(error);
|
|
27
|
+
const json = argv.some((token) => token === "--json" || token === "--json=true");
|
|
28
|
+
if (json || isMachineCommandTokens(argv))
|
|
29
|
+
console.log(JSON.stringify({ ok: false, error: shape }));
|
|
30
|
+
else
|
|
31
|
+
console.error(`${shape.code}: ${shape.message}`);
|
|
32
|
+
return classifyExitCode(error);
|
|
33
|
+
}
|
|
34
|
+
if (parsed.options.help === true || (parsed.positionals.length === 0 && parsed.options.version !== true)) {
|
|
35
|
+
printHelp();
|
|
36
|
+
return parsed.positionals.length === 0 && parsed.options.help !== true ? EXIT_USAGE : 0;
|
|
37
|
+
}
|
|
38
|
+
if (parsed.options.version === true) {
|
|
39
|
+
console.log(`${metadata.name} ${metadata.version}`);
|
|
40
|
+
return 0;
|
|
41
|
+
}
|
|
42
|
+
const root = path.resolve(dependencies.repositoryRoot ?? process.cwd());
|
|
43
|
+
const json = parsed.options.json === true;
|
|
44
|
+
try {
|
|
45
|
+
const [domain, command, ...rest] = parsed.positionals;
|
|
46
|
+
if (domain === "template" && command === "list") {
|
|
47
|
+
return await runTemplateList(root);
|
|
48
|
+
}
|
|
49
|
+
if (domain === "issue" || domain === "pr") {
|
|
50
|
+
return await runArtifactCommand(domain, command, rest, parsed, root, dependencies, json);
|
|
51
|
+
}
|
|
52
|
+
throw new CliError("UNKNOWN_COMMAND", `Unknown command "${parsed.positionals.join(" ")}".`);
|
|
53
|
+
}
|
|
54
|
+
catch (error) {
|
|
55
|
+
const shape = toErrorShape(error);
|
|
56
|
+
if (json || isMachineCommand(parsed.positionals))
|
|
57
|
+
console.log(JSON.stringify({ ok: false, error: shape }));
|
|
58
|
+
else
|
|
59
|
+
console.error(`${shape.code}: ${shape.message}`);
|
|
60
|
+
return classifyExitCode(error);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
class CliError extends Error {
|
|
64
|
+
code;
|
|
65
|
+
path;
|
|
66
|
+
details;
|
|
67
|
+
constructor(code, message, path, details) {
|
|
68
|
+
super(message);
|
|
69
|
+
this.name = "CliError";
|
|
70
|
+
this.code = code;
|
|
71
|
+
this.path = path;
|
|
72
|
+
this.details = details;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
async function runTemplateList(root) {
|
|
76
|
+
const discovery = await discoverTemplates(root);
|
|
77
|
+
console.log(JSON.stringify({ templates: discovery.templates }));
|
|
78
|
+
return 0;
|
|
79
|
+
}
|
|
80
|
+
async function runArtifactCommand(domain, command, rest, parsed, root, dependencies, json) {
|
|
81
|
+
if (command === "schema") {
|
|
82
|
+
const contract = await loadContract(domain, root, templateSelector(parsed, rest[0]), parsed.options.policy);
|
|
83
|
+
const projection = projectContract(contract);
|
|
84
|
+
console.log(JSON.stringify({ contract, template: contract.templateIdentity, ...projection }));
|
|
85
|
+
return 0;
|
|
86
|
+
}
|
|
87
|
+
if (command === "validate" || command === "render" || command === "create") {
|
|
88
|
+
if (command === "validate" &&
|
|
89
|
+
rest[0] !== undefined &&
|
|
90
|
+
isPositiveInteger(rest[0]) &&
|
|
91
|
+
parsed.options.from === undefined) {
|
|
92
|
+
return runExistingValidation(domain, Number(rest[0]), parsed, root, dependencies, json);
|
|
93
|
+
}
|
|
94
|
+
const contract = await loadContract(domain, root, templateSelector(parsed, rest[0]), parsed.options.policy);
|
|
95
|
+
const document = await readInputDocument(parsed.options.from);
|
|
96
|
+
const preparedDocument = mergeOptionMetadata(document, parsed.options);
|
|
97
|
+
if (command === "validate") {
|
|
98
|
+
const validation = validateSemanticInput(contract, preparedDocument.fields);
|
|
99
|
+
console.log(JSON.stringify({ valid: validation.valid, violations: validation.violations, values: validation.values }));
|
|
100
|
+
return validation.valid ? 0 : EXIT_VALIDATION;
|
|
101
|
+
}
|
|
102
|
+
if (command === "render") {
|
|
103
|
+
const body = domain === "issue"
|
|
104
|
+
? renderIssueArtifact(contract, preparedDocument.fields)
|
|
105
|
+
: renderPullRequestArtifact(contract, preparedDocument.fields);
|
|
106
|
+
if (json)
|
|
107
|
+
console.log(JSON.stringify({ valid: true, body }));
|
|
108
|
+
else
|
|
109
|
+
process.stdout.write(body);
|
|
110
|
+
return 0;
|
|
111
|
+
}
|
|
112
|
+
if (domain === "issue") {
|
|
113
|
+
const prepared = prepareIssueArtifact(contract, preparedDocument);
|
|
114
|
+
const adapter = createAdapter(dependencies, root, parsed.options.repository);
|
|
115
|
+
const created = await adapter.createIssue(prepared.artifact);
|
|
116
|
+
console.log(JSON.stringify({ ok: true, artifact: created }));
|
|
117
|
+
return 0;
|
|
118
|
+
}
|
|
119
|
+
const prepared = preparePullRequestArtifact(contract, preparedDocument);
|
|
120
|
+
const adapter = createAdapter(dependencies, root, parsed.options.repository);
|
|
121
|
+
const created = await adapter.createPullRequest(prepared.artifact);
|
|
122
|
+
console.log(JSON.stringify({ ok: true, artifact: created }));
|
|
123
|
+
return 0;
|
|
124
|
+
}
|
|
125
|
+
if (command === "explain" && rest[0] !== undefined && isPositiveInteger(rest[0])) {
|
|
126
|
+
return runExistingValidation(domain, Number(rest[0]), parsed, root, dependencies, true);
|
|
127
|
+
}
|
|
128
|
+
throw new CliError("UNKNOWN_COMMAND", `Unknown ${domain} command "${command ?? ""}".`);
|
|
129
|
+
}
|
|
130
|
+
async function runExistingValidation(domain, number, parsed, root, dependencies, json) {
|
|
131
|
+
const contract = await loadContract(domain, root, templateSelector(parsed, undefined), parsed.options.policy);
|
|
132
|
+
const adapter = createAdapter(dependencies, root, parsed.options.repository);
|
|
133
|
+
const remote = domain === "issue" ? await adapter.getIssue(number) : await adapter.getPullRequest(number);
|
|
134
|
+
const result = domain === "issue"
|
|
135
|
+
? validateExistingIssueArtifact(contract, remote.body)
|
|
136
|
+
: validateExistingPullRequestArtifact(contract, remote.body);
|
|
137
|
+
const output = {
|
|
138
|
+
valid: result.valid,
|
|
139
|
+
classification: result.classification,
|
|
140
|
+
number,
|
|
141
|
+
url: remote.url,
|
|
142
|
+
diagnostics: result.parse.diagnostics,
|
|
143
|
+
violations: result.violations,
|
|
144
|
+
};
|
|
145
|
+
console.log(JSON.stringify(output));
|
|
146
|
+
return result.valid ? 0 : EXIT_VALIDATION;
|
|
147
|
+
}
|
|
148
|
+
async function loadContract(domain, root, selector, policyPath) {
|
|
149
|
+
const discovery = await discoverTemplates(root);
|
|
150
|
+
let contract;
|
|
151
|
+
if (domain === "issue") {
|
|
152
|
+
contract = await compileIssueFormTemplate(discovery, selector);
|
|
153
|
+
}
|
|
154
|
+
else {
|
|
155
|
+
contract = await compilePullRequestTemplate(root, selector);
|
|
156
|
+
}
|
|
157
|
+
if (domain === "pr") {
|
|
158
|
+
let selectedPolicy;
|
|
159
|
+
if (typeof policyPath === "string") {
|
|
160
|
+
selectedPolicy = path.resolve(root, policyPath);
|
|
161
|
+
}
|
|
162
|
+
else {
|
|
163
|
+
const candidates = [
|
|
164
|
+
path.join(root, ".github", "inari", "pr-policy.yml"),
|
|
165
|
+
path.join(root, ".inari", "pr-policy.yml"),
|
|
166
|
+
];
|
|
167
|
+
for (const candidate of candidates) {
|
|
168
|
+
try {
|
|
169
|
+
await access(candidate);
|
|
170
|
+
selectedPolicy = candidate;
|
|
171
|
+
break;
|
|
172
|
+
}
|
|
173
|
+
catch {
|
|
174
|
+
// Continue to next candidate
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
if (selectedPolicy !== undefined)
|
|
179
|
+
contract = await compilePullRequestPolicyFile(contract, selectedPolicy);
|
|
180
|
+
}
|
|
181
|
+
return contract;
|
|
182
|
+
}
|
|
183
|
+
function createAdapter(dependencies, root, repository) {
|
|
184
|
+
const factory = dependencies.createAdapter ?? ((options) => new GitHubAdapter(options));
|
|
185
|
+
return factory({ cwd: root, ...(typeof repository === "string" ? { repository } : {}) });
|
|
186
|
+
}
|
|
187
|
+
async function readInputDocument(value) {
|
|
188
|
+
if (typeof value !== "string" || value.length === 0)
|
|
189
|
+
throw new CliError("INPUT_REQUIRED", "Use --from <file.json>.", "--from");
|
|
190
|
+
let source;
|
|
191
|
+
if (value === "-")
|
|
192
|
+
source = await readStdin();
|
|
193
|
+
else {
|
|
194
|
+
try {
|
|
195
|
+
source = await readFile(value, "utf8");
|
|
196
|
+
}
|
|
197
|
+
catch (cause) {
|
|
198
|
+
const error = new CliError("INPUT_READ_FAILED", `Cannot read input file "${value}".`, "--from");
|
|
199
|
+
if (cause instanceof Error)
|
|
200
|
+
error.cause = cause;
|
|
201
|
+
throw error;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
let parsed;
|
|
205
|
+
try {
|
|
206
|
+
parsed = JSON.parse(source);
|
|
207
|
+
}
|
|
208
|
+
catch (cause) {
|
|
209
|
+
const error = new CliError("INPUT_INVALID_JSON", "Input file must contain valid JSON.", "--from");
|
|
210
|
+
if (cause instanceof Error)
|
|
211
|
+
error.cause = cause;
|
|
212
|
+
throw error;
|
|
213
|
+
}
|
|
214
|
+
return parseArtifactInputDocument(parsed);
|
|
215
|
+
}
|
|
216
|
+
function mergeOptionMetadata(document, options) {
|
|
217
|
+
const metadata = {
|
|
218
|
+
...document.metadata,
|
|
219
|
+
...(typeof options.title === "string" ? { title: options.title } : {}),
|
|
220
|
+
...(typeof options.head === "string" ? { head: options.head } : {}),
|
|
221
|
+
...(typeof options.base === "string" ? { base: options.base } : {}),
|
|
222
|
+
...(typeof options.draft === "boolean" ? { draft: options.draft } : {}),
|
|
223
|
+
...(typeof options.maintainerCanModify === "boolean" ? { maintainerCanModify: options.maintainerCanModify } : {}),
|
|
224
|
+
};
|
|
225
|
+
return { fields: document.fields, metadata };
|
|
226
|
+
}
|
|
227
|
+
function templateSelector(parsed, positional) {
|
|
228
|
+
return typeof parsed.options.template === "string" ? parsed.options.template : positional;
|
|
229
|
+
}
|
|
230
|
+
function parseArguments(argv) {
|
|
231
|
+
const positionals = [];
|
|
232
|
+
const options = {};
|
|
233
|
+
for (let index = 0; index < argv.length; index += 1) {
|
|
234
|
+
const token = argv[index];
|
|
235
|
+
if (token === undefined)
|
|
236
|
+
continue;
|
|
237
|
+
if (token === "--") {
|
|
238
|
+
positionals.push(...argv.slice(index + 1));
|
|
239
|
+
break;
|
|
240
|
+
}
|
|
241
|
+
if (!token.startsWith("--")) {
|
|
242
|
+
positionals.push(token);
|
|
243
|
+
continue;
|
|
244
|
+
}
|
|
245
|
+
const equalIndex = token.indexOf("=");
|
|
246
|
+
const rawKey = equalIndex >= 0 ? token.slice(2, equalIndex) : token.slice(2);
|
|
247
|
+
const key = rawKey.replace(/-([a-z])/gu, (_match, letter) => letter.toUpperCase());
|
|
248
|
+
if (BOOLEAN_OPTIONS.has(key)) {
|
|
249
|
+
if (equalIndex < 0) {
|
|
250
|
+
options[key] = true;
|
|
251
|
+
continue;
|
|
252
|
+
}
|
|
253
|
+
const booleanValue = token.slice(equalIndex + 1);
|
|
254
|
+
if (booleanValue !== "true" && booleanValue !== "false")
|
|
255
|
+
throw new CliError("INVALID_OPTION", `Option --${rawKey} must be true or false.`);
|
|
256
|
+
options[key] = booleanValue === "true";
|
|
257
|
+
continue;
|
|
258
|
+
}
|
|
259
|
+
if (!VALUE_OPTIONS.has(key))
|
|
260
|
+
throw new CliError("INVALID_OPTION", `Unknown option --${rawKey}.`);
|
|
261
|
+
const value = equalIndex >= 0 ? token.slice(equalIndex + 1) : argv[++index];
|
|
262
|
+
if (value === undefined || (equalIndex < 0 && value.startsWith("--")))
|
|
263
|
+
throw new CliError("INVALID_OPTION", `Option --${rawKey} requires a value.`);
|
|
264
|
+
options[key] = value;
|
|
265
|
+
}
|
|
266
|
+
return { positionals, options };
|
|
267
|
+
}
|
|
268
|
+
function toErrorShape(error) {
|
|
269
|
+
if (error instanceof CliError)
|
|
270
|
+
return {
|
|
271
|
+
code: error.code,
|
|
272
|
+
message: error.message,
|
|
273
|
+
...(error.path === undefined ? {} : { path: error.path }),
|
|
274
|
+
...(error.details === undefined ? {} : { details: error.details }),
|
|
275
|
+
};
|
|
276
|
+
if (error instanceof SemanticValidationError)
|
|
277
|
+
return { code: "SEMANTIC_VALIDATION_FAILED", message: error.message, violations: error.violations };
|
|
278
|
+
if (error instanceof ArtifactInputError)
|
|
279
|
+
return { code: error.code, message: error.message, path: error.path };
|
|
280
|
+
if (isGitHubAdapterError(error))
|
|
281
|
+
return { code: error.code, message: error.message, details: error.details };
|
|
282
|
+
if (isObjectWithCode(error))
|
|
283
|
+
return {
|
|
284
|
+
code: error.code,
|
|
285
|
+
message: typeof error.message === "string" ? error.message : "Operation failed.",
|
|
286
|
+
...(typeof error.path === "string" ? { path: error.path } : {}),
|
|
287
|
+
...(typeof error.details === "object" ? { details: error.details } : {}),
|
|
288
|
+
...(Array.isArray(error.violations) ? { violations: error.violations } : {}),
|
|
289
|
+
};
|
|
290
|
+
return { code: "INTERNAL_ERROR", message: error instanceof Error ? error.message : "Operation failed." };
|
|
291
|
+
}
|
|
292
|
+
function classifyExitCode(error) {
|
|
293
|
+
if (error instanceof SemanticValidationError || error instanceof ArtifactInputError)
|
|
294
|
+
return EXIT_VALIDATION;
|
|
295
|
+
if (isGitHubAdapterError(error))
|
|
296
|
+
return EXIT_REMOTE;
|
|
297
|
+
if (isObjectWithCode(error) &&
|
|
298
|
+
typeof error.code === "string" &&
|
|
299
|
+
(error.code.includes("TEMPLATE") || error.code.includes("POLICY")))
|
|
300
|
+
return EXIT_VALIDATION;
|
|
301
|
+
if (error instanceof CliError &&
|
|
302
|
+
(error.code === "UNKNOWN_COMMAND" ||
|
|
303
|
+
error.code === "INVALID_OPTION" ||
|
|
304
|
+
error.code === "INPUT_REQUIRED" ||
|
|
305
|
+
error.code === "INPUT_READ_FAILED"))
|
|
306
|
+
return EXIT_USAGE;
|
|
307
|
+
if (error instanceof CliError && error.code === "INPUT_INVALID_JSON")
|
|
308
|
+
return EXIT_VALIDATION;
|
|
309
|
+
if (isObjectWithCode(error) && /^(?:ISSUE_FORM|PR_TEMPLATE|IR_|CONTRACT_)/u.test(error.code))
|
|
310
|
+
return EXIT_VALIDATION;
|
|
311
|
+
return EXIT_INTERNAL;
|
|
312
|
+
}
|
|
313
|
+
function isMachineCommand(positionals) {
|
|
314
|
+
return (positionals.length >= 2 &&
|
|
315
|
+
(positionals[1] === "schema" ||
|
|
316
|
+
positionals[1] === "validate" ||
|
|
317
|
+
positionals[1] === "render" ||
|
|
318
|
+
positionals[1] === "create" ||
|
|
319
|
+
positionals[1] === "explain"));
|
|
320
|
+
}
|
|
321
|
+
function isMachineCommandTokens(argv) {
|
|
322
|
+
const domainIndex = argv.findIndex((token) => token === "issue" || token === "pr");
|
|
323
|
+
if (domainIndex < 0)
|
|
324
|
+
return false;
|
|
325
|
+
const command = argv[domainIndex + 1];
|
|
326
|
+
return (command === "schema" ||
|
|
327
|
+
command === "validate" ||
|
|
328
|
+
command === "render" ||
|
|
329
|
+
command === "create" ||
|
|
330
|
+
command === "explain");
|
|
331
|
+
}
|
|
332
|
+
function isPositiveInteger(value) {
|
|
333
|
+
return /^[1-9]\d*$/u.test(value);
|
|
334
|
+
}
|
|
335
|
+
function isObjectWithCode(value) {
|
|
336
|
+
return typeof value === "object" && value !== null && "code" in value && typeof value.code === "string";
|
|
337
|
+
}
|
|
338
|
+
function readPackageMetadata() {
|
|
339
|
+
const packagePath = path.join(path.dirname(fileURLToPath(import.meta.url)), "..", "package.json");
|
|
340
|
+
const value = JSON.parse(requireFile(packagePath));
|
|
341
|
+
if (typeof value.name !== "string" || typeof value.version !== "string") {
|
|
342
|
+
throw new Error("package.json must define the package name and version.");
|
|
343
|
+
}
|
|
344
|
+
return {
|
|
345
|
+
name: value.name,
|
|
346
|
+
version: value.version,
|
|
347
|
+
description: typeof value.description === "string" ? value.description : "",
|
|
348
|
+
};
|
|
349
|
+
}
|
|
350
|
+
function requireFile(filePath) {
|
|
351
|
+
return readFileSync(filePath, "utf8");
|
|
352
|
+
}
|
|
353
|
+
async function readStdin() {
|
|
354
|
+
const chunks = [];
|
|
355
|
+
const reader = createInterface({ input: process.stdin });
|
|
356
|
+
for await (const line of reader)
|
|
357
|
+
chunks.push(line);
|
|
358
|
+
return chunks.join("\n");
|
|
359
|
+
}
|
|
360
|
+
function printHelp() {
|
|
361
|
+
console.log(`Usage: gh-inari <command> [options]
|
|
362
|
+
|
|
363
|
+
Commands:
|
|
364
|
+
template list
|
|
365
|
+
issue schema [template]
|
|
366
|
+
issue validate --template <template> --from <file.json>
|
|
367
|
+
issue render --template <template> --from <file.json>
|
|
368
|
+
issue create --template <template> --from <file.json>
|
|
369
|
+
issue validate <number> [--template <template>]
|
|
370
|
+
issue explain <number> [--template <template>]
|
|
371
|
+
pr schema [template]
|
|
372
|
+
pr validate --template <template> --from <file.json>
|
|
373
|
+
pr render --template <template> --from <file.json>
|
|
374
|
+
pr create --template <template> --from <file.json>
|
|
375
|
+
pr validate <number> [--template <template>]
|
|
376
|
+
pr explain <number> [--template <template>]
|
|
377
|
+
|
|
378
|
+
Options:
|
|
379
|
+
--from <path> JSON input file, or - for stdin
|
|
380
|
+
--template <id> Repository-native template id, path, or unique name
|
|
381
|
+
--policy <path> Versioned PR policy overlay
|
|
382
|
+
--repository <r> GitHub repository override for gh
|
|
383
|
+
--title <title> Issue/PR title for create
|
|
384
|
+
--head <branch> PR head branch for create
|
|
385
|
+
--base <branch> PR base branch for create
|
|
386
|
+
--draft Create the PR as a draft
|
|
387
|
+
--maintainer-can-modify
|
|
388
|
+
Allow maintainer edits on the PR
|
|
389
|
+
--json Emit structured JSON output
|
|
390
|
+
--version Print package version
|
|
391
|
+
--help Print this help
|
|
392
|
+
|
|
393
|
+
Create always validates and renders before invoking gh. Schema, validate, and render never mutate GitHub.`);
|
|
394
|
+
}
|
|
395
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,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|
2
|
+
* Versioned, compiler-generated contract representation.
|
|
3
|
+
*
|
|
4
|
+
* This module deliberately describes the result of compiling a repository's
|
|
5
|
+
* native template. It is not a second template language for repository
|
|
6
|
+
* authors to maintain.
|
|
7
|
+
*/
|
|
8
|
+
export declare const CANONICAL_IR_VERSION: "1.0.0";
|
|
9
|
+
export declare const CONTRACT_SCHEMA_VERSION: "1.0.0";
|
|
10
|
+
export declare const JSON_SCHEMA_DIALECT: "https://json-schema.org/draft/2020-12/schema";
|
|
11
|
+
/** The only built-in linked-Issue rule accepted by the v1 PR overlay. */
|
|
12
|
+
export declare const LINKED_ISSUE_PATTERN: "(?:Closes|Fixes|Resolves)\\s+#\\d+";
|
|
13
|
+
export type CanonicalIrVersion = typeof CANONICAL_IR_VERSION;
|
|
14
|
+
export type ContractSchemaVersion = typeof CONTRACT_SCHEMA_VERSION;
|
|
15
|
+
export type ArtifactKind = "issue" | "pull_request";
|
|
16
|
+
export type TemplateSource = "issue_form" | "pull_request_template";
|
|
17
|
+
export type RequiredState = "required" | "optional" | "unknown";
|
|
18
|
+
export type SectionKind = "input" | "documentation";
|
|
19
|
+
export type FieldType = "string" | "enum" | "array" | "checklist";
|
|
20
|
+
export type ArraySelection = "list" | "multi_select";
|
|
21
|
+
export interface TemplateIdentity {
|
|
22
|
+
readonly id: string;
|
|
23
|
+
readonly name: string;
|
|
24
|
+
readonly path: string;
|
|
25
|
+
readonly source: TemplateSource;
|
|
26
|
+
}
|
|
27
|
+
export interface NativeContractMetadata {
|
|
28
|
+
readonly source: TemplateSource;
|
|
29
|
+
readonly path: string;
|
|
30
|
+
readonly title?: string;
|
|
31
|
+
readonly description?: string;
|
|
32
|
+
readonly labels?: readonly string[];
|
|
33
|
+
}
|
|
34
|
+
export interface SectionRenderMetadata {
|
|
35
|
+
/** Zero-based position in the source template. */
|
|
36
|
+
readonly order: number;
|
|
37
|
+
readonly headingLevel?: number;
|
|
38
|
+
}
|
|
39
|
+
export interface FieldRenderMetadata {
|
|
40
|
+
/** Zero-based position within its section. */
|
|
41
|
+
readonly order: number;
|
|
42
|
+
}
|
|
43
|
+
export interface NativeOptionMetadata {
|
|
44
|
+
readonly value: string;
|
|
45
|
+
readonly label?: string;
|
|
46
|
+
readonly description?: string;
|
|
47
|
+
readonly required?: boolean;
|
|
48
|
+
}
|
|
49
|
+
export type NativeSectionElement = "input" | "textarea" | "dropdown" | "checkboxes" | "markdown" | "heading";
|
|
50
|
+
export interface NativeSectionMetadata {
|
|
51
|
+
readonly elementType: NativeSectionElement;
|
|
52
|
+
readonly sourceId?: string;
|
|
53
|
+
readonly headingLevel?: number;
|
|
54
|
+
readonly markdown?: string;
|
|
55
|
+
}
|
|
56
|
+
export type NativeFieldElement = "input" | "textarea" | "dropdown" | "checkboxes" | "pr_section";
|
|
57
|
+
export interface NativeFieldMetadata {
|
|
58
|
+
readonly elementType: NativeFieldElement;
|
|
59
|
+
readonly sourceId?: string;
|
|
60
|
+
readonly placeholder?: string;
|
|
61
|
+
readonly defaultValue?: string | readonly string[];
|
|
62
|
+
readonly multiple?: boolean;
|
|
63
|
+
readonly options?: readonly NativeOptionMetadata[];
|
|
64
|
+
}
|
|
65
|
+
export interface FieldConstraints {
|
|
66
|
+
readonly minLength?: number;
|
|
67
|
+
readonly maxLength?: number;
|
|
68
|
+
readonly pattern?: string;
|
|
69
|
+
readonly minItems?: number;
|
|
70
|
+
readonly maxItems?: number;
|
|
71
|
+
readonly uniqueItems?: boolean;
|
|
72
|
+
}
|
|
73
|
+
export interface SupplementalFieldConstraint {
|
|
74
|
+
readonly fieldId: string;
|
|
75
|
+
readonly required?: boolean;
|
|
76
|
+
readonly minLength?: number;
|
|
77
|
+
readonly maxLength?: number;
|
|
78
|
+
readonly pattern?: string;
|
|
79
|
+
readonly minItems?: number;
|
|
80
|
+
readonly maxItems?: number;
|
|
81
|
+
/** Require a string-like PR section to contain a conventional linked Issue. */
|
|
82
|
+
readonly linkedIssue?: boolean;
|
|
83
|
+
/** Minimum number of checked items for a PR checklist. */
|
|
84
|
+
readonly checklistMinCompleted?: number;
|
|
85
|
+
/** Require every item in a PR checklist to be checked. */
|
|
86
|
+
readonly checklistRequireComplete?: boolean;
|
|
87
|
+
}
|
|
88
|
+
export interface SupplementalConstraints {
|
|
89
|
+
/**
|
|
90
|
+
* A deliberately small overlay for constraints absent from native
|
|
91
|
+
* templates, primarily PR section policy. It is not a policy language.
|
|
92
|
+
*/
|
|
93
|
+
readonly fields: readonly SupplementalFieldConstraint[];
|
|
94
|
+
}
|
|
95
|
+
export interface EnumOption {
|
|
96
|
+
readonly value: string;
|
|
97
|
+
readonly label: string;
|
|
98
|
+
readonly description?: string;
|
|
99
|
+
}
|
|
100
|
+
export interface ChecklistItem {
|
|
101
|
+
readonly id: string;
|
|
102
|
+
readonly label: string;
|
|
103
|
+
readonly required: boolean;
|
|
104
|
+
readonly description?: string;
|
|
105
|
+
}
|
|
106
|
+
interface CanonicalFieldBase {
|
|
107
|
+
readonly id: string;
|
|
108
|
+
readonly label: string;
|
|
109
|
+
readonly description?: string;
|
|
110
|
+
readonly required: RequiredState;
|
|
111
|
+
readonly render: FieldRenderMetadata;
|
|
112
|
+
readonly nativeMetadata: NativeFieldMetadata;
|
|
113
|
+
readonly constraints?: FieldConstraints;
|
|
114
|
+
}
|
|
115
|
+
export interface StringField extends CanonicalFieldBase {
|
|
116
|
+
readonly type: "string";
|
|
117
|
+
readonly defaultValue?: string;
|
|
118
|
+
}
|
|
119
|
+
export interface EnumField extends CanonicalFieldBase {
|
|
120
|
+
readonly type: "enum";
|
|
121
|
+
readonly options: readonly EnumOption[];
|
|
122
|
+
readonly defaultValue?: string;
|
|
123
|
+
}
|
|
124
|
+
export interface ArrayField extends CanonicalFieldBase {
|
|
125
|
+
readonly type: "array";
|
|
126
|
+
readonly selection: ArraySelection;
|
|
127
|
+
readonly items: {
|
|
128
|
+
readonly type: "string";
|
|
129
|
+
readonly options?: readonly EnumOption[];
|
|
130
|
+
};
|
|
131
|
+
readonly defaultValue?: readonly string[];
|
|
132
|
+
}
|
|
133
|
+
export interface ChecklistField extends CanonicalFieldBase {
|
|
134
|
+
readonly type: "checklist";
|
|
135
|
+
readonly items: readonly ChecklistItem[];
|
|
136
|
+
readonly defaultValue?: readonly string[];
|
|
137
|
+
}
|
|
138
|
+
export type CanonicalField = StringField | EnumField | ArrayField | ChecklistField;
|
|
139
|
+
export interface CanonicalSection {
|
|
140
|
+
readonly id: string;
|
|
141
|
+
readonly title?: string;
|
|
142
|
+
readonly description?: string;
|
|
143
|
+
readonly kind: SectionKind;
|
|
144
|
+
readonly content?: string;
|
|
145
|
+
readonly render: SectionRenderMetadata;
|
|
146
|
+
readonly nativeMetadata: NativeSectionMetadata;
|
|
147
|
+
readonly fields: readonly CanonicalField[];
|
|
148
|
+
}
|
|
149
|
+
export interface CanonicalContract {
|
|
150
|
+
readonly irVersion: CanonicalIrVersion;
|
|
151
|
+
readonly schemaVersion: ContractSchemaVersion;
|
|
152
|
+
readonly artifactKind: ArtifactKind;
|
|
153
|
+
readonly templateIdentity: TemplateIdentity;
|
|
154
|
+
readonly nativeMetadata: NativeContractMetadata;
|
|
155
|
+
/** Sections and fields retain source order; their render.order values are checked against those arrays. */
|
|
156
|
+
readonly sections: readonly CanonicalSection[];
|
|
157
|
+
readonly supplementalConstraints: SupplementalConstraints;
|
|
158
|
+
}
|
|
159
|
+
export type CanonicalIrViolationCode = "IR_INVALID_JSON" | "IR_NOT_OBJECT" | "IR_MISSING_PROPERTY" | "IR_UNKNOWN_PROPERTY" | "IR_INVALID_VALUE" | "IR_UNSUPPORTED_VERSION" | "IR_UNSUPPORTED_ARTIFACT_KIND" | "IR_UNSUPPORTED_SOURCE_FORMAT" | "IR_UNSUPPORTED_FIELD_TYPE" | "IR_INVALID_IDENTIFIER" | "IR_DUPLICATE_ID" | "IR_INVALID_ORDER" | "IR_INVALID_SECTION" | "IR_INVALID_FIELD" | "IR_INVALID_NATIVE_METADATA" | "IR_INCONSISTENT_SOURCE" | "IR_INCONSISTENT_FIELD" | "IR_INVALID_OPTIONS" | "IR_INVALID_DEFAULT" | "IR_INVALID_CONSTRAINT" | "IR_INCONSISTENT_CONSTRAINT" | "IR_UNKNOWN_FIELD_REFERENCE" | "IR_CHECKLIST_REQUIRED_MISMATCH";
|
|
160
|
+
export interface CanonicalIrViolation {
|
|
161
|
+
readonly code: CanonicalIrViolationCode;
|
|
162
|
+
readonly path: string;
|
|
163
|
+
readonly message: string;
|
|
164
|
+
}
|
|
165
|
+
export interface CanonicalIrValidationResult {
|
|
166
|
+
readonly valid: boolean;
|
|
167
|
+
readonly violations: readonly CanonicalIrViolation[];
|
|
168
|
+
}
|
|
169
|
+
export declare class CanonicalIrValidationError extends Error {
|
|
170
|
+
readonly violations: readonly CanonicalIrViolation[];
|
|
171
|
+
constructor(violations: readonly CanonicalIrViolation[]);
|
|
172
|
+
}
|
|
173
|
+
export declare function validateCanonicalContract(input: unknown): CanonicalIrValidationResult;
|
|
174
|
+
export declare function isCanonicalContract(input: unknown): input is CanonicalContract;
|
|
175
|
+
export declare function assertCanonicalContract(input: unknown): asserts input is CanonicalContract;
|
|
176
|
+
export declare function serializeCanonicalContract(input: unknown): string;
|
|
177
|
+
export declare function deserializeCanonicalContract(serialized: string): CanonicalContract;
|
|
178
|
+
export {};
|