@cloud411716/fancy-webnovel 1.0.23 → 1.0.24

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.
@@ -86,20 +86,20 @@ export function apply(ctx) {
86
86
  }
87
87
 
88
88
  if (!projectRoot) {
89
- return notify(session, bootstrap.notify({ type: 'no_path' }));
89
+ return notify(session, 'error', bootstrap.notify({ type: 'no_path' }));
90
90
  }
91
91
 
92
92
  if (projectRoot === '.') {
93
93
  projectRoot = session.header?.cwd ?? process.cwd();
94
- return notify(session, bootstrap.notify({ type: 'using_cwd', projectRoot }));
94
+ return notify(session, 'success', bootstrap.notify({ type: 'using_cwd', projectRoot }));
95
95
  }
96
96
 
97
97
  if (!isValidPath(projectRoot)) {
98
- return notify(session, bootstrap.notify({ type: 'invalid_path' }));
98
+ return notify(session, 'error', bootstrap.notify({ type: 'invalid_path' }));
99
99
  }
100
100
 
101
101
  if (existsSync(join(projectRoot, '.fancy-deployed'))) {
102
- return notify(session, bootstrap.notify({ type: 'already_initialized' }));
102
+ return notify(session, 'error', bootstrap.notify({ type: 'already_initialized' }));
103
103
  }
104
104
 
105
105
  // ---------- confirm ----------
@@ -117,16 +117,16 @@ export function apply(ctx) {
117
117
  const ans = confirm.answers[0];
118
118
  const chosen = ans?.selected?.[0] ?? ans?.custom;
119
119
  if (chosen !== '确认创建') {
120
- return notify(session, bootstrap.notify({ type: 'cancelled' }));
120
+ return notify(session, 'error', bootstrap.notify({ type: 'cancelled' }));
121
121
  }
122
122
 
123
123
  // ---------- init (in-process, no subprocess) ----------
124
124
  const result = await initProject(projectRoot);
125
125
 
126
126
  if (result.ok) {
127
- return notify(session, bootstrap.notify({ type: 'success' }));
127
+ return notify(session, 'success', bootstrap.notify({ type: 'success' }));
128
128
  } else {
129
- return notify(session, bootstrap.notify({ type: 'error', err: result.error }));
129
+ return notify(session, 'error', bootstrap.notify({ type: 'error', err: result.error }));
130
130
  }
131
131
  },
132
132
  });
@@ -128,11 +128,11 @@ export function apply(ctx) {
128
128
  // ---------- check project root ----------
129
129
  const projectRoot = session.header?.cwd ?? process.cwd();
130
130
  if (!existsSync(join(projectRoot, '.fancy-deployed'))) {
131
- return notify(session, scan.notify({ type: 'not_initialized' }));
131
+ return notify(session, 'error', scan.notify({ type: 'not_initialized' }));
132
132
  }
133
133
 
134
134
  // ---------- platform selection ----------
135
- notify(session, scan.platformList());
135
+ notify(session, 'success', scan.platformList());
136
136
 
137
137
  const platformResult = await ctx.userQuestions.ask({
138
138
  questions: [scan.askPlatform()],
@@ -141,12 +141,12 @@ export function apply(ctx) {
141
141
  });
142
142
  const answer = platformResult.answers[0]?.custom?.trim();
143
143
  if (!answer) {
144
- return notify(session, scan.notify({ type: 'cancelled' }));
144
+ return notify(session, 'error', scan.notify({ type: 'cancelled' }));
145
145
  }
146
146
  const numMatch = answer.match(/^(\d+)$/);
147
147
  const row = numMatch ? PLATFORM_TABLE.find(r => r[0] === numMatch[1]) : null;
148
148
  if (!row) {
149
- return notify(session, scan.notify({ type: 'invalid_choice' }));
149
+ return notify(session, 'error', scan.notify({ type: 'invalid_choice' }));
150
150
  }
151
151
  const platform = row[1];
152
152
 
@@ -161,7 +161,7 @@ export function apply(ctx) {
161
161
 
162
162
  const rawChoices = selected.length > 0 ? selected : (custom ? [custom] : []);
163
163
  if (rawChoices.length === 0) {
164
- return notify(session, scan.notify({ type: 'cancelled' }));
164
+ return notify(session, 'error', scan.notify({ type: 'cancelled' }));
165
165
  }
166
166
 
167
167
  const scraper = SCRAPERS[platform];
@@ -187,7 +187,7 @@ export function apply(ctx) {
187
187
  }
188
188
 
189
189
  if (rankEntries.length === 0) {
190
- return notify(session, scan.notify({ type: 'invalid_choice' }));
190
+ return notify(session, 'error', scan.notify({ type: 'invalid_choice' }));
191
191
  }
192
192
 
193
193
  // ---------- in-process scraping (no subprocess) ----------
@@ -221,7 +221,7 @@ export function apply(ctx) {
221
221
 
222
222
  // ---------- output results ----------
223
223
  if (lastReceipt && totalFiles > 0) {
224
- notify(session, scan.notify({
224
+ notify(session, 'success', scan.notify({
225
225
  type: 'handover',
226
226
  platform,
227
227
  files: lastReceipt.scan_files,
@@ -242,7 +242,7 @@ export function apply(ctx) {
242
242
  const lines = failedRanks.map(({ rank, err }) => {
243
243
  return `• ${rank.label}:${err}`;
244
244
  });
245
- return notify(session, `⚠️ 以下榜单采集失败(共 ${failedRanks.length} 项):\n${lines.join('\n')}`);
245
+ return notify(session, 'error', `⚠️ 以下榜单采集失败(共 ${failedRanks.length} 项):\n${lines.join('\n')}`);
246
246
  }
247
247
 
248
248
  return { kind: 'success', text: '' };
package/infra.js CHANGED
@@ -23,13 +23,14 @@ function stripAnsi(str) {
23
23
 
24
24
  /**
25
25
  * @param {object} session - DSH Session object (unused, kept for API compatibility)
26
+ * @param {'error'|'success'} kind
26
27
  * @param {string} text
27
- * @returns {{ kind: 'error', text: string }} Error result propagated through
28
+ * @returns {{ kind: 'error'|'success', text: string }} Result propagated through
28
29
  * dsh-commands settleThrown() → command/done → channel.notify() (TUI toast)
29
30
  * and command/done (Web left-panel with real commandId prefix)
30
31
  */
31
- export function notify(session, text) {
32
- return { kind: 'error', text: stripAnsi(text) };
32
+ export function notify(session, kind, text) {
33
+ return { kind, text: stripAnsi(text) };
33
34
  }
34
35
 
35
36
  // --------------------------------------------------------------------------
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloud411716/fancy-webnovel",
3
- "version": "1.0.23",
3
+ "version": "1.0.24",
4
4
  "type": "module",
5
5
  "main": "index.js",
6
6
  "exports": {