@pmate/cli 0.24.16 → 0.24.17
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/index.d.ts +7 -0
- package/dist/index.js +82 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -167,6 +167,13 @@ type QuizCommandArgs = {
|
|
|
167
167
|
stepIds: string[];
|
|
168
168
|
apiBaseUrl?: string;
|
|
169
169
|
linkBaseUrl?: string;
|
|
170
|
+
} | {
|
|
171
|
+
type: Command.Quiz;
|
|
172
|
+
action: "delete-step";
|
|
173
|
+
paperId: string;
|
|
174
|
+
stepId: string;
|
|
175
|
+
apiBaseUrl?: string;
|
|
176
|
+
linkBaseUrl?: string;
|
|
170
177
|
} | {
|
|
171
178
|
type: Command.Quiz;
|
|
172
179
|
action: "activate";
|
package/dist/index.js
CHANGED
|
@@ -15270,6 +15270,35 @@ async function updateQuizPaperStep({
|
|
|
15270
15270
|
data
|
|
15271
15271
|
};
|
|
15272
15272
|
}
|
|
15273
|
+
async function deleteQuizPaperStep({
|
|
15274
|
+
fetchImpl = fetch,
|
|
15275
|
+
apiBaseUrl,
|
|
15276
|
+
linkBaseUrl,
|
|
15277
|
+
paperId,
|
|
15278
|
+
stepId,
|
|
15279
|
+
token
|
|
15280
|
+
}) {
|
|
15281
|
+
const trimmedApiBaseUrl = apiBaseUrl.replace(/\/+$/, "");
|
|
15282
|
+
const trimmedLinkBaseUrl = linkBaseUrl.replace(/\/+$/, "");
|
|
15283
|
+
const previewLink = `${trimmedLinkBaseUrl}/?paper=${encodeURIComponent(paperId)}`;
|
|
15284
|
+
const data = await requestJson(
|
|
15285
|
+
fetchImpl,
|
|
15286
|
+
`${trimmedApiBaseUrl}/api/quiz/papers/${encodeURIComponent(paperId)}/steps/${encodeURIComponent(stepId)}`,
|
|
15287
|
+
{
|
|
15288
|
+
method: "DELETE",
|
|
15289
|
+
headers: {
|
|
15290
|
+
Authorization: `Bearer ${token}`
|
|
15291
|
+
}
|
|
15292
|
+
},
|
|
15293
|
+
`\u5220\u9664\u9898\u76EE\uFF08${stepId}\uFF09`
|
|
15294
|
+
);
|
|
15295
|
+
return {
|
|
15296
|
+
apiBaseUrl: trimmedApiBaseUrl,
|
|
15297
|
+
paperId,
|
|
15298
|
+
previewLink,
|
|
15299
|
+
data
|
|
15300
|
+
};
|
|
15301
|
+
}
|
|
15273
15302
|
async function reorderQuizPaperSteps({
|
|
15274
15303
|
fetchImpl = fetch,
|
|
15275
15304
|
apiBaseUrl,
|
|
@@ -15440,6 +15469,18 @@ var QuizCommandHandler = class {
|
|
|
15440
15469
|
ui.info("\u6570\u91CF", String(args.stepIds.length));
|
|
15441
15470
|
return;
|
|
15442
15471
|
}
|
|
15472
|
+
if (args.action === "delete-step") {
|
|
15473
|
+
const result = await deleteQuizPaperStep({
|
|
15474
|
+
apiBaseUrl,
|
|
15475
|
+
linkBaseUrl,
|
|
15476
|
+
paperId: args.paperId,
|
|
15477
|
+
stepId: args.stepId,
|
|
15478
|
+
token: session.token
|
|
15479
|
+
});
|
|
15480
|
+
ui.success("Quiz \u9898\u76EE\u5DF2\u5220\u9664", result.previewLink);
|
|
15481
|
+
ui.info("stepId", args.stepId);
|
|
15482
|
+
return;
|
|
15483
|
+
}
|
|
15443
15484
|
if (args.action === "view") {
|
|
15444
15485
|
const result = await viewQuizPaper({
|
|
15445
15486
|
apiBaseUrl,
|
|
@@ -23748,6 +23789,7 @@ var HELP_TEXT = [
|
|
|
23748
23789
|
` ${import_chalk4.default.gray(" update-meta --paper-id <id> --file <metadata.json>")}`,
|
|
23749
23790
|
` ${import_chalk4.default.gray(" append-step --paper-id <id> --file <step.json>")}`,
|
|
23750
23791
|
` ${import_chalk4.default.gray(" update-step --paper-id <id> --step-id <step-id> --file <step.json>")}`,
|
|
23792
|
+
` ${import_chalk4.default.gray(" delete-step --paper-id <id> --step-id <step-id>")}`,
|
|
23751
23793
|
` ${import_chalk4.default.gray(" reorder --paper-id <id> --step-ids <id1,id2,...>")}`,
|
|
23752
23794
|
` ${import_chalk4.default.gray(" activate --paper-id <id>")}`,
|
|
23753
23795
|
` ${import_chalk4.default.gray(" view --paper-id <id>")}`,
|
|
@@ -24408,7 +24450,7 @@ function parseQuizArgs(tokens) {
|
|
|
24408
24450
|
const rest = [...tokens];
|
|
24409
24451
|
const action = rest.shift();
|
|
24410
24452
|
if (!action) {
|
|
24411
|
-
throw new Error("Missing quiz action. Usage: quiz create-draft|update-meta|append-step|update-step|reorder|activate|view|edit-step");
|
|
24453
|
+
throw new Error("Missing quiz action. Usage: quiz create-draft|update-meta|append-step|update-step|delete-step|reorder|activate|view|edit-step");
|
|
24412
24454
|
}
|
|
24413
24455
|
if (action === "create-draft") {
|
|
24414
24456
|
let paperId;
|
|
@@ -24609,6 +24651,45 @@ function parseQuizArgs(tokens) {
|
|
|
24609
24651
|
linkBaseUrl
|
|
24610
24652
|
};
|
|
24611
24653
|
}
|
|
24654
|
+
if (action === "delete-step") {
|
|
24655
|
+
let paperId;
|
|
24656
|
+
let stepId;
|
|
24657
|
+
let apiBaseUrl;
|
|
24658
|
+
let linkBaseUrl;
|
|
24659
|
+
while (rest.length > 0) {
|
|
24660
|
+
const token = rest.shift();
|
|
24661
|
+
switch (token) {
|
|
24662
|
+
case "--paper-id":
|
|
24663
|
+
paperId = requireValue13(rest, token);
|
|
24664
|
+
break;
|
|
24665
|
+
case "--step-id":
|
|
24666
|
+
stepId = requireValue13(rest, token);
|
|
24667
|
+
break;
|
|
24668
|
+
case "--base-url":
|
|
24669
|
+
apiBaseUrl = requireValue13(rest, token);
|
|
24670
|
+
break;
|
|
24671
|
+
case "--link-base":
|
|
24672
|
+
linkBaseUrl = requireValue13(rest, token);
|
|
24673
|
+
break;
|
|
24674
|
+
default:
|
|
24675
|
+
throw new Error(`Unknown quiz delete-step option: ${token}`);
|
|
24676
|
+
}
|
|
24677
|
+
}
|
|
24678
|
+
if (!paperId) {
|
|
24679
|
+
throw new Error("Missing --paper-id. Usage: quiz delete-step --paper-id <id> --step-id <id>.");
|
|
24680
|
+
}
|
|
24681
|
+
if (!stepId) {
|
|
24682
|
+
throw new Error("Missing --step-id. Usage: quiz delete-step --paper-id <id> --step-id <id>.");
|
|
24683
|
+
}
|
|
24684
|
+
return {
|
|
24685
|
+
type: "quiz" /* Quiz */,
|
|
24686
|
+
action: "delete-step",
|
|
24687
|
+
paperId,
|
|
24688
|
+
stepId,
|
|
24689
|
+
apiBaseUrl,
|
|
24690
|
+
linkBaseUrl
|
|
24691
|
+
};
|
|
24692
|
+
}
|
|
24612
24693
|
if (action === "activate") {
|
|
24613
24694
|
let paperId;
|
|
24614
24695
|
let apiBaseUrl;
|