@cloud411716/fancy-webnovel 1.0.41 → 1.0.43
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/commands/bootstrap/index.js +35 -16
- package/commands/scan/index.js +35 -14
- package/package.json +1 -1
|
@@ -12,6 +12,9 @@ import { initProject } from './init-project.js';
|
|
|
12
12
|
|
|
13
13
|
// inject is declared in the root index.js; only apply() is imported by index.js
|
|
14
14
|
|
|
15
|
+
/** UserQuestionError codes that indicate user cancellation */
|
|
16
|
+
const USER_CANCEL_CODES = new Set(['ASK_CANCELLED', 'ASK_ABORTED']);
|
|
17
|
+
|
|
15
18
|
function isValidPath(p) {
|
|
16
19
|
return (
|
|
17
20
|
!p.includes('..') &&
|
|
@@ -77,11 +80,19 @@ export function apply(ctx) {
|
|
|
77
80
|
let projectRoot = rawInput;
|
|
78
81
|
|
|
79
82
|
if (!projectRoot) {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
83
|
+
let result;
|
|
84
|
+
try {
|
|
85
|
+
result = await ctx.userQuestions.ask({
|
|
86
|
+
questions: [bootstrap.askPath()],
|
|
87
|
+
agent: invocation.agent,
|
|
88
|
+
signal,
|
|
89
|
+
});
|
|
90
|
+
} catch (err) {
|
|
91
|
+
if (err?.code && USER_CANCEL_CODES.has(err.code)) {
|
|
92
|
+
return notify(session, 'error', bootstrap.notify({ type: 'cancelled' }));
|
|
93
|
+
}
|
|
94
|
+
throw err;
|
|
95
|
+
}
|
|
85
96
|
projectRoot = result.answers[0]?.custom?.trim() ?? '';
|
|
86
97
|
}
|
|
87
98
|
|
|
@@ -103,17 +114,25 @@ export function apply(ctx) {
|
|
|
103
114
|
}
|
|
104
115
|
|
|
105
116
|
// ---------- confirm ----------
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
+
let confirm;
|
|
118
|
+
try {
|
|
119
|
+
confirm = await ctx.userQuestions.ask({
|
|
120
|
+
questions: [{
|
|
121
|
+
id: 'confirm',
|
|
122
|
+
question: bootstrap.notify({ type: 'confirm', projectRoot }),
|
|
123
|
+
detail: projectRoot,
|
|
124
|
+
hideCustomInput: true,
|
|
125
|
+
options: bootstrap.confirmOptions(),
|
|
126
|
+
}],
|
|
127
|
+
agent: invocation.agent,
|
|
128
|
+
signal,
|
|
129
|
+
});
|
|
130
|
+
} catch (err) {
|
|
131
|
+
if (err?.code && USER_CANCEL_CODES.has(err.code)) {
|
|
132
|
+
return notify(session, 'error', bootstrap.notify({ type: 'cancelled' }));
|
|
133
|
+
}
|
|
134
|
+
throw err;
|
|
135
|
+
}
|
|
117
136
|
const ans = confirm.answers[0];
|
|
118
137
|
const chosen = ans?.selected?.[0] ?? ans?.custom;
|
|
119
138
|
if (chosen !== '确认创建') {
|
package/commands/scan/index.js
CHANGED
|
@@ -14,6 +14,9 @@ import * as fanqie from './platforms/fanqie.js';
|
|
|
14
14
|
import * as jinjiang from './platforms/jinjiang.js';
|
|
15
15
|
import * as qimao from './platforms/qimao.js';
|
|
16
16
|
|
|
17
|
+
/** UserQuestionError codes that indicate user cancellation */
|
|
18
|
+
const USER_CANCEL_CODES = new Set(['ASK_CANCELLED', 'ASK_ABORTED']);
|
|
19
|
+
|
|
17
20
|
// inject is declared in the root index.js; only apply() is imported by index.js
|
|
18
21
|
|
|
19
22
|
const PLATFORM_TABLE = [
|
|
@@ -133,15 +136,25 @@ export function apply(ctx) {
|
|
|
133
136
|
}
|
|
134
137
|
|
|
135
138
|
// ---------- platform selection ----------
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
139
|
+
let platformResult;
|
|
140
|
+
try {
|
|
141
|
+
platformResult = await ctx.userQuestions.ask({
|
|
142
|
+
questions: [{
|
|
143
|
+
id: 'platform',
|
|
144
|
+
...scan.askPlatform(),
|
|
145
|
+
question: `${scan.platformList()}\n\n请选择要扫的平台(输入编号 1-4):`,
|
|
146
|
+
}],
|
|
147
|
+
agent: invocation.agent,
|
|
148
|
+
signal,
|
|
149
|
+
});
|
|
150
|
+
} catch (err) {
|
|
151
|
+
// Handle user cancellation (ASK_CANCELLED, ASK_ABORTED, or any cancellation)
|
|
152
|
+
if (err?.code && USER_CANCEL_CODES.has(err.code)) {
|
|
153
|
+
return notify(session, 'error', scan.notify({ type: 'cancelled' }));
|
|
154
|
+
}
|
|
155
|
+
// Re-throw unexpected errors
|
|
156
|
+
throw err;
|
|
157
|
+
}
|
|
145
158
|
const answer = platformResult.answers[0]?.custom?.trim();
|
|
146
159
|
if (!answer) {
|
|
147
160
|
return notify(session, 'error', scan.notify({ type: 'cancelled' }));
|
|
@@ -154,11 +167,19 @@ export function apply(ctx) {
|
|
|
154
167
|
const platform = row[1];
|
|
155
168
|
|
|
156
169
|
// ---------- rank selection (multi-select) ----------
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
170
|
+
let rankResult;
|
|
171
|
+
try {
|
|
172
|
+
rankResult = await ctx.userQuestions.ask({
|
|
173
|
+
questions: [scan.askRankList(platform)],
|
|
174
|
+
agent: invocation.agent,
|
|
175
|
+
signal,
|
|
176
|
+
});
|
|
177
|
+
} catch (err) {
|
|
178
|
+
if (err?.code && USER_CANCEL_CODES.has(err.code)) {
|
|
179
|
+
return notify(session, 'error', scan.notify({ type: 'cancelled' }));
|
|
180
|
+
}
|
|
181
|
+
throw err;
|
|
182
|
+
}
|
|
162
183
|
const selected = rankResult.answers[0]?.selected ?? [];
|
|
163
184
|
const custom = rankResult.answers[0]?.custom?.trim();
|
|
164
185
|
|