htmlship 0.1.4 → 0.1.5
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/dist/cli.js +32 -19
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -56,7 +56,7 @@ var VERSION;
|
|
|
56
56
|
var init_version = __esm({
|
|
57
57
|
"src/version.ts"() {
|
|
58
58
|
"use strict";
|
|
59
|
-
VERSION = "0.1.
|
|
59
|
+
VERSION = "0.1.5";
|
|
60
60
|
}
|
|
61
61
|
});
|
|
62
62
|
|
|
@@ -388,23 +388,29 @@ function createKeyStore(overrideDir) {
|
|
|
388
388
|
|
|
389
389
|
// src/commands/delete.ts
|
|
390
390
|
function registerDelete(program) {
|
|
391
|
-
program.command("delete").description("Soft-delete a page.").argument("<slug>", "Page slug").option("--owner-key <key>", "Owner key (defaults to local store)").option("-y, --yes", "Skip confirmation").action(async function(slug, opts) {
|
|
391
|
+
program.command("delete").description("Soft-delete a page.").argument("<slug>", "Page slug").option("--owner-key <key>", "Owner key (defaults to local store, else prompted)").option("-y, --yes", "Skip confirmation").action(async function(slug, opts) {
|
|
392
392
|
const keys = createKeyStore();
|
|
393
|
-
|
|
394
|
-
if (!ownerKey) {
|
|
395
|
-
throw new HTMLShipError(
|
|
396
|
-
`no owner key for '${slug}' in ${keys.file}; pass --owner-key explicitly`
|
|
397
|
-
);
|
|
398
|
-
}
|
|
399
|
-
if (!opts.yes) {
|
|
393
|
+
let ownerKey = opts.ownerKey ?? keys.lookupOwnerKey(slug);
|
|
394
|
+
if (!opts.yes || !ownerKey) {
|
|
400
395
|
const rl = createInterface({ input: process.stdin, output: process.stderr });
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
396
|
+
try {
|
|
397
|
+
if (!opts.yes) {
|
|
398
|
+
const answer = await rl.question(`Delete page '${slug}'? [y/N] `);
|
|
399
|
+
if (!/^y(es)?$/i.test(answer.trim())) {
|
|
400
|
+
process.stderr.write("Aborted.\n");
|
|
401
|
+
return;
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
if (!ownerKey) {
|
|
405
|
+
ownerKey = (await rl.question(`owner_key for '${slug}': `)).trim();
|
|
406
|
+
}
|
|
407
|
+
} finally {
|
|
408
|
+
rl.close();
|
|
406
409
|
}
|
|
407
410
|
}
|
|
411
|
+
if (!ownerKey) {
|
|
412
|
+
throw new HTMLShipError("owner_key is required");
|
|
413
|
+
}
|
|
408
414
|
const apiUrl = this.parent?.opts()?.apiUrl;
|
|
409
415
|
const client = new HTMLShipClient({ baseUrl: apiUrl });
|
|
410
416
|
await client.delete(slug, ownerKey);
|
|
@@ -577,15 +583,22 @@ function registerPublish(program) {
|
|
|
577
583
|
// src/commands/update.ts
|
|
578
584
|
init_client();
|
|
579
585
|
init_errors();
|
|
586
|
+
import { createInterface as createInterface2 } from "readline/promises";
|
|
580
587
|
function registerUpdate(program) {
|
|
581
|
-
program.command("update").description("Replace HTML for an existing page.").argument("<slug>", "Page slug").argument("[source]", "file path, '-' for stdin").option("-f, --file <path>", "HTML file path").option("--title <title>", "Optional new title").option("--owner-key <key>", "Owner key (defaults to local store)").action(async function(slug, source, opts) {
|
|
588
|
+
program.command("update").description("Replace HTML for an existing page.").argument("<slug>", "Page slug").argument("[source]", "file path, '-' for stdin").option("-f, --file <path>", "HTML file path").option("--title <title>", "Optional new title").option("--owner-key <key>", "Owner key (defaults to local store, else prompted)").action(async function(slug, source, opts) {
|
|
582
589
|
const html = readHtmlFromSource(source, opts.file);
|
|
583
590
|
const keys = createKeyStore();
|
|
584
|
-
|
|
591
|
+
let ownerKey = opts.ownerKey ?? keys.lookupOwnerKey(slug);
|
|
585
592
|
if (!ownerKey) {
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
593
|
+
const rl = createInterface2({ input: process.stdin, output: process.stderr });
|
|
594
|
+
try {
|
|
595
|
+
ownerKey = (await rl.question(`owner_key for '${slug}': `)).trim();
|
|
596
|
+
} finally {
|
|
597
|
+
rl.close();
|
|
598
|
+
}
|
|
599
|
+
if (!ownerKey) {
|
|
600
|
+
throw new HTMLShipError("owner_key is required");
|
|
601
|
+
}
|
|
589
602
|
}
|
|
590
603
|
const apiUrl = this.parent?.opts()?.apiUrl;
|
|
591
604
|
const client = new HTMLShipClient({ baseUrl: apiUrl });
|