@dosu/cli 0.24.0 → 0.25.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/bin/dosu.js +72 -11
- package/package.json +1 -1
package/bin/dosu.js
CHANGED
|
@@ -4577,7 +4577,7 @@ var init_dist4 = __esm(() => {
|
|
|
4577
4577
|
function getVersionString() {
|
|
4578
4578
|
return `v${VERSION}`;
|
|
4579
4579
|
}
|
|
4580
|
-
var VERSION = "0.
|
|
4580
|
+
var VERSION = "0.25.0", INSTALL_CHANNEL = "npm";
|
|
4581
4581
|
|
|
4582
4582
|
// src/debug/logger.ts
|
|
4583
4583
|
import {
|
|
@@ -15253,6 +15253,7 @@ ${import_picocolors17.default.dim(`Current: ${cfg.org_id}`)}`);
|
|
|
15253
15253
|
}
|
|
15254
15254
|
|
|
15255
15255
|
// src/commands/review.ts
|
|
15256
|
+
init_dist8();
|
|
15256
15257
|
init_dist();
|
|
15257
15258
|
init_commander();
|
|
15258
15259
|
init_trpc();
|
|
@@ -15274,6 +15275,35 @@ function humanizeSource(origin, version) {
|
|
|
15274
15275
|
return origin;
|
|
15275
15276
|
}
|
|
15276
15277
|
}
|
|
15278
|
+
function colorizeDiff(diff) {
|
|
15279
|
+
return diff.split(`
|
|
15280
|
+
`).map((line) => {
|
|
15281
|
+
if (line.startsWith("+"))
|
|
15282
|
+
return import_picocolors18.default.green(line);
|
|
15283
|
+
if (line.startsWith("-"))
|
|
15284
|
+
return import_picocolors18.default.red(line);
|
|
15285
|
+
if (line.startsWith("@@"))
|
|
15286
|
+
return import_picocolors18.default.cyan(line);
|
|
15287
|
+
return import_picocolors18.default.dim(line);
|
|
15288
|
+
}).join(`
|
|
15289
|
+
`);
|
|
15290
|
+
}
|
|
15291
|
+
function printChangePreview(change) {
|
|
15292
|
+
printInfo([
|
|
15293
|
+
["Title", change.title],
|
|
15294
|
+
["Source", change.source],
|
|
15295
|
+
[
|
|
15296
|
+
"Version",
|
|
15297
|
+
change.isNewDoc ? `${change.version} (new)` : `${change.publishedVersion ?? "?"} → ${change.version}`
|
|
15298
|
+
]
|
|
15299
|
+
]);
|
|
15300
|
+
if (!change.hasChanges) {
|
|
15301
|
+
console.log(import_picocolors18.default.dim("No content changes."));
|
|
15302
|
+
return;
|
|
15303
|
+
}
|
|
15304
|
+
console.log();
|
|
15305
|
+
console.log(colorizeDiff(change.diff));
|
|
15306
|
+
}
|
|
15277
15307
|
async function getKnowledgeStoreId2(client, spaceId) {
|
|
15278
15308
|
const store = await client.knowledgeStore.getBySpaceId.query({ space_id: spaceId });
|
|
15279
15309
|
if (!store) {
|
|
@@ -15354,19 +15384,37 @@ function reviewCommand() {
|
|
|
15354
15384
|
["Sync PR", ctx.syncPrUrl ?? undefined]
|
|
15355
15385
|
]);
|
|
15356
15386
|
});
|
|
15357
|
-
const
|
|
15358
|
-
{ name: "approve", action: "accept",
|
|
15359
|
-
{ name: "reject", action: "decline",
|
|
15360
|
-
{
|
|
15361
|
-
name: "revert",
|
|
15362
|
-
action: "revert_to_pending",
|
|
15363
|
-
description: "Revert to pending review"
|
|
15364
|
-
}
|
|
15387
|
+
const gated = [
|
|
15388
|
+
{ name: "approve", action: "accept", verb: "Approve" },
|
|
15389
|
+
{ name: "reject", action: "decline", verb: "Reject" }
|
|
15365
15390
|
];
|
|
15366
|
-
for (const { name, action,
|
|
15367
|
-
cmd.command(name).description(
|
|
15391
|
+
for (const { name, action, verb } of gated) {
|
|
15392
|
+
cmd.command(name).description(`${verb} a document version (shows the diff, requires --confirm)`).argument("<id>", "Review item ID (from `dosu review list`)").option("--confirm", "Apply without the interactive prompt").option("--json", "Output as JSON").action(async (id, opts) => {
|
|
15368
15393
|
const cfg = requireConfig9();
|
|
15369
15394
|
const client = createTypedClient(cfg);
|
|
15395
|
+
const change = await client.review.getChange.query({ id });
|
|
15396
|
+
if (!opts.json)
|
|
15397
|
+
printChangePreview(change);
|
|
15398
|
+
let proceed = opts.confirm === true;
|
|
15399
|
+
if (!proceed && !opts.json && process.stdin?.isTTY) {
|
|
15400
|
+
const answer = await confirm({
|
|
15401
|
+
message: `${verb} this change?`,
|
|
15402
|
+
initialValue: false
|
|
15403
|
+
});
|
|
15404
|
+
if (isCancel(answer)) {
|
|
15405
|
+
console.log(import_picocolors18.default.dim("Cancelled."));
|
|
15406
|
+
return;
|
|
15407
|
+
}
|
|
15408
|
+
proceed = answer === true;
|
|
15409
|
+
}
|
|
15410
|
+
if (!proceed) {
|
|
15411
|
+
if (opts.json) {
|
|
15412
|
+
printResult({ ...change, applied: false, confirmRequired: true }, opts);
|
|
15413
|
+
} else {
|
|
15414
|
+
console.log(import_picocolors18.default.dim("Aborted. Re-run with --confirm to apply."));
|
|
15415
|
+
}
|
|
15416
|
+
return;
|
|
15417
|
+
}
|
|
15370
15418
|
await client.page.updatePublicationStatus.mutate({
|
|
15371
15419
|
page_version_id: id,
|
|
15372
15420
|
action
|
|
@@ -15378,6 +15426,19 @@ function reviewCommand() {
|
|
|
15378
15426
|
console.log(import_picocolors18.default.green(`Review ${name}: ${id.slice(0, 8)}`));
|
|
15379
15427
|
});
|
|
15380
15428
|
}
|
|
15429
|
+
cmd.command("revert").description("Revert to pending review").argument("<id>", "Review item ID (from `dosu review list`)").option("--json", "Output as JSON").action(async (id, opts) => {
|
|
15430
|
+
const cfg = requireConfig9();
|
|
15431
|
+
const client = createTypedClient(cfg);
|
|
15432
|
+
await client.page.updatePublicationStatus.mutate({
|
|
15433
|
+
page_version_id: id,
|
|
15434
|
+
action: "revert_to_pending"
|
|
15435
|
+
});
|
|
15436
|
+
if (opts.json) {
|
|
15437
|
+
printResult({ success: true, id, action: "revert_to_pending" }, opts);
|
|
15438
|
+
return;
|
|
15439
|
+
}
|
|
15440
|
+
console.log(import_picocolors18.default.green(`Review revert: ${id.slice(0, 8)}`));
|
|
15441
|
+
});
|
|
15381
15442
|
return cmd;
|
|
15382
15443
|
}
|
|
15383
15444
|
|