@remogram/cli 0.1.0-beta.3 → 0.1.0-beta.4
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/index.js +90 -6
- package/package.json +7 -7
package/index.js
CHANGED
|
@@ -21,6 +21,7 @@ import {
|
|
|
21
21
|
throwIfStaleHeadByNumber,
|
|
22
22
|
FACT_INVENTORY_PACKET_TYPES,
|
|
23
23
|
forgeFactInventoryPacket,
|
|
24
|
+
assertWriteCommandConfigured,
|
|
24
25
|
} from '@remogram/core';
|
|
25
26
|
import { provider as giteaApi } from '@remogram/provider-gitea-api';
|
|
26
27
|
import { provider as githubApi } from '@remogram/provider-github-api';
|
|
@@ -36,6 +37,13 @@ const PROVIDERS = {
|
|
|
36
37
|
'github-gh': githubGh,
|
|
37
38
|
};
|
|
38
39
|
|
|
40
|
+
const REPEATABLE_FLAGS = new Set(['allowed_path']);
|
|
41
|
+
|
|
42
|
+
function parseAllowedPathFlags(flags) {
|
|
43
|
+
if (flags.allowed_path == null) return undefined;
|
|
44
|
+
return Array.isArray(flags.allowed_path) ? flags.allowed_path : [flags.allowed_path];
|
|
45
|
+
}
|
|
46
|
+
|
|
39
47
|
function parsePositiveInt(value, name) {
|
|
40
48
|
if (value == null) return undefined;
|
|
41
49
|
const n = Number(value);
|
|
@@ -212,6 +220,22 @@ async function buildDoctorPacket(cwd, providers) {
|
|
|
212
220
|
),
|
|
213
221
|
);
|
|
214
222
|
|
|
223
|
+
if (providerCapabilities.write_support) {
|
|
224
|
+
const providerWrites = (providerCapabilities.write_commands || []).filter(Boolean);
|
|
225
|
+
const configuredWrites = Array.isArray(config?.write_commands) ? config.write_commands : [];
|
|
226
|
+
const missing = providerWrites.filter((name) => !configuredWrites.includes(name));
|
|
227
|
+
checks.push(
|
|
228
|
+
doctorCheck(
|
|
229
|
+
'write_config',
|
|
230
|
+
missing.length ? 'warn' : 'pass',
|
|
231
|
+
missing.length
|
|
232
|
+
? `Provider supports write commands but .remogram.json write_commands omits: ${missing.join(', ')}`
|
|
233
|
+
: 'Consumer write_commands matches provider write surface',
|
|
234
|
+
{ provider_write_commands: providerWrites, configured_write_commands: configuredWrites },
|
|
235
|
+
),
|
|
236
|
+
);
|
|
237
|
+
}
|
|
238
|
+
|
|
215
239
|
if (!providerCapabilities.check_sources?.length) {
|
|
216
240
|
checks.push(doctorCheck('checks', 'warn', 'Provider does not report forge check sources'));
|
|
217
241
|
} else {
|
|
@@ -270,7 +294,13 @@ export async function runCli(argv, options = {}) {
|
|
|
270
294
|
else if (arg.startsWith('--')) {
|
|
271
295
|
const key = arg.slice(2).replace(/-/g, '_');
|
|
272
296
|
const next = argv[i + 1];
|
|
273
|
-
if (
|
|
297
|
+
if (REPEATABLE_FLAGS.has(key)) {
|
|
298
|
+
if (!flags[key]) flags[key] = [];
|
|
299
|
+
if (next != null && !next.startsWith('--')) {
|
|
300
|
+
flags[key].push(next);
|
|
301
|
+
i += 1;
|
|
302
|
+
}
|
|
303
|
+
} else if (next != null && !next.startsWith('--')) {
|
|
274
304
|
flags[key] = next;
|
|
275
305
|
i += 1;
|
|
276
306
|
} else {
|
|
@@ -361,12 +391,58 @@ export async function runCli(argv, options = {}) {
|
|
|
361
391
|
),
|
|
362
392
|
});
|
|
363
393
|
}
|
|
394
|
+
const inventoryBody = await provider.crInventory(ctx, {
|
|
395
|
+
slice_ref: flags.slice_ref,
|
|
396
|
+
limit: parsePositiveInt(flags.limit, '--limit'),
|
|
397
|
+
sort: flags.sort,
|
|
398
|
+
});
|
|
399
|
+
if (inventoryBody.list_truncated === true) {
|
|
400
|
+
throw Object.assign(new Error('Open CR list incomplete'), {
|
|
401
|
+
forgeError: forgeError(
|
|
402
|
+
ERROR_CODES.INVENTORY_LIST_INCOMPLETE,
|
|
403
|
+
'Open change request list could not be proved complete within pagination bounds',
|
|
404
|
+
null,
|
|
405
|
+
{
|
|
406
|
+
inventory_list: {
|
|
407
|
+
entry_count: inventoryBody.entry_count,
|
|
408
|
+
},
|
|
409
|
+
},
|
|
410
|
+
),
|
|
411
|
+
});
|
|
412
|
+
}
|
|
364
413
|
packet = forgeFactInventoryPacket(
|
|
365
414
|
FACT_INVENTORY_PACKET_TYPES.CR_INVENTORY_SLICE,
|
|
366
415
|
ctx,
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
416
|
+
inventoryBody,
|
|
417
|
+
);
|
|
418
|
+
} else if (group === 'cr' && sub === 'open') {
|
|
419
|
+
if (typeof provider.crOpen !== 'function') {
|
|
420
|
+
throw Object.assign(new Error('cr open not implemented for provider'), {
|
|
421
|
+
forgeError: forgeError(
|
|
422
|
+
ERROR_CODES.PROVIDER_UNSUPPORTED,
|
|
423
|
+
'cr open not implemented for provider',
|
|
424
|
+
),
|
|
425
|
+
});
|
|
426
|
+
}
|
|
427
|
+
if (!flags.head || !flags.base || !flags.title) {
|
|
428
|
+
throw Object.assign(new Error('--head, --base, and --title required'), {
|
|
429
|
+
forgeError: forgeError(
|
|
430
|
+
ERROR_CODES.INVALID_ARGS,
|
|
431
|
+
'--head, --base, and --title required for cr open',
|
|
432
|
+
),
|
|
433
|
+
});
|
|
434
|
+
}
|
|
435
|
+
assertGitRef(flags.head, '--head');
|
|
436
|
+
assertGitRef(flags.base, '--base');
|
|
437
|
+
assertWriteCommandConfigured(ctx.config, 'cr_open');
|
|
438
|
+
packet = forgePacket(
|
|
439
|
+
PACKET_TYPES.CHANGE_REQUEST_OPENED,
|
|
440
|
+
ctx,
|
|
441
|
+
await provider.crOpen(ctx, {
|
|
442
|
+
head: flags.head,
|
|
443
|
+
base: flags.base,
|
|
444
|
+
title: flags.title,
|
|
445
|
+
body: flags.body,
|
|
370
446
|
}),
|
|
371
447
|
);
|
|
372
448
|
} else if (group === 'pr' && sub === 'view') {
|
|
@@ -415,7 +491,15 @@ export async function runCli(argv, options = {}) {
|
|
|
415
491
|
forgeError: forgeError(ERROR_CODES.INVALID_ARGS, '--number required for merge plan'),
|
|
416
492
|
});
|
|
417
493
|
}
|
|
418
|
-
|
|
494
|
+
const allowedPaths = parseAllowedPathFlags(flags);
|
|
495
|
+
packet = forgePacket(
|
|
496
|
+
PACKET_TYPES.MERGE_PLAN,
|
|
497
|
+
ctx,
|
|
498
|
+
await provider.mergePlan(ctx, {
|
|
499
|
+
number,
|
|
500
|
+
...(allowedPaths ? { allowed_paths: allowedPaths } : {}),
|
|
501
|
+
}),
|
|
502
|
+
);
|
|
419
503
|
} else if (group === 'sync' && sub === 'plan') {
|
|
420
504
|
const remote = flags.remote || ctx.config.remote;
|
|
421
505
|
assertGitRemote(remote, '--remote');
|
|
@@ -428,7 +512,7 @@ export async function runCli(argv, options = {}) {
|
|
|
428
512
|
throw Object.assign(new Error(`Unknown command: ${positional.join(' ')}`), {
|
|
429
513
|
forgeError: forgeError(
|
|
430
514
|
ERROR_CODES.INVALID_ARGS,
|
|
431
|
-
'Unknown command. Try: provider capabilities, repo status, refs compare, refs inventory, cr inventory, pr view, pr checks, merge plan, sync plan',
|
|
515
|
+
'Unknown command. Try: provider capabilities, repo status, refs compare, refs inventory, cr inventory, cr open, pr view, pr checks, merge plan, sync plan',
|
|
432
516
|
),
|
|
433
517
|
});
|
|
434
518
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@remogram/cli",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.4",
|
|
4
4
|
"description": "Remogram forge boundary CLI",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -27,11 +27,11 @@
|
|
|
27
27
|
"node": ">=20"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@remogram/core": "0.1.0-beta.
|
|
31
|
-
"@remogram/provider-gitea-api": "0.1.0-beta.
|
|
32
|
-
"@remogram/provider-github-api": "0.1.0-beta.
|
|
33
|
-
"@remogram/provider-gitlab-api": "0.1.0-beta.
|
|
34
|
-
"@remogram/provider-gitea-tea": "0.1.0-beta.
|
|
35
|
-
"@remogram/provider-github-gh": "0.1.0-beta.
|
|
30
|
+
"@remogram/core": "0.1.0-beta.4",
|
|
31
|
+
"@remogram/provider-gitea-api": "0.1.0-beta.4",
|
|
32
|
+
"@remogram/provider-github-api": "0.1.0-beta.4",
|
|
33
|
+
"@remogram/provider-gitlab-api": "0.1.0-beta.4",
|
|
34
|
+
"@remogram/provider-gitea-tea": "0.1.0-beta.4",
|
|
35
|
+
"@remogram/provider-github-gh": "0.1.0-beta.4"
|
|
36
36
|
}
|
|
37
37
|
}
|