@cloud411716/fancy-webnovel 0.1.91 → 0.1.93

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloud411716/fancy-webnovel",
3
- "version": "0.1.91",
3
+ "version": "0.1.93",
4
4
  "type": "module",
5
5
  "main": "index.js",
6
6
  "exports": {
@@ -154,7 +154,7 @@ async function runScanWithChromiumFix(ctx, session, invocation, { platform, leng
154
154
  });
155
155
  const answer = choice.answers[0]?.selected?.[0] ?? choice.answers[0]?.custom;
156
156
  if (!answer || answer === '我自己安装') {
157
- notify(session, '⚠️ 已取消。请手动安装 Chromium 后再次运行 /fancy-scan。\n安装命令:npm install -g @playwright/cli@1.40.0 --registry=https://registry.npmmirror.com && PLAYWRIGHT_DOWNLOAD_HOST=https://npmmirror.com/mirrors/playwright/ playwright-cli@1.40.0 install-browser --with-deps');
157
+ notify(session, '⚠️ 已取消。请手动安装 Chromium 后再次运行 /fancy-scan。\n安装命令:npm install -g playwright@1.40.0 --registry=https://registry.npmmirror.com && PLAYWRIGHT_DOWNLOAD_HOST=https://npmmirror.com/mirrors/playwright/ playwright install chromium --with-deps');
158
158
  return undefined;
159
159
  }
160
160
 
@@ -163,13 +163,12 @@ async function runScanWithChromiumFix(ctx, session, invocation, { platform, leng
163
163
  const installStop = startActivity(session);
164
164
 
165
165
  const installProc = spawn('sh', ['-c',
166
- 'npm install -g @playwright/cli@1.40.0 --registry=https://registry.npmmirror.com && PLAYWRIGHT_DOWNLOAD_HOST=https://npmmirror.com/mirrors/playwright/ playwright-cli@1.40.0 install-browser --with-deps'
166
+ 'npm install -g playwright@1.40.0 --registry=https://registry.npmmirror.com && PLAYWRIGHT_DOWNLOAD_HOST=https://npmmirror.com/mirrors/playwright/ playwright install chromium --with-deps'
167
167
  ], {
168
168
  stdio: ['pipe', 'pipe', 'pipe'],
169
169
  cwd: process.cwd(),
170
170
  });
171
171
  const installOut = [];
172
- let sudoPrompted = false;
173
172
 
174
173
  installProc.stdout.on('data', d => { installOut.push(d.toString()); });
175
174
  installProc.stderr.on('data', d => { installOut.push(d.toString()); });
@@ -180,27 +179,30 @@ async function runScanWithChromiumFix(ctx, session, invocation, { platform, leng
180
179
  installStop();
181
180
  });
182
181
 
182
+ let sudoDialogPromise = null;
183
183
  // 检测 sudo 密码提示
184
184
  installProc.stderr.on('data', async (d) => {
185
- if (sudoPrompted) return;
185
+ if (sudoDialogPromise) return;
186
186
  const text = d.toString();
187
187
  if (/password|密码|sudo/i.test(text)) {
188
- sudoPrompted = true;
189
- installProc.pause?.(); // 暂停输出,防止刷屏
190
- const pwdResult = await ctx.userQuestions.ask({
188
+ sudoDialogPromise = ctx.userQuestions.ask({
191
189
  questions: [{
192
190
  question: '🔐 安装过程需要 sudo 权限,请输入密码:',
193
191
  hideCustomInput: false,
194
192
  }],
195
- });
196
- const pwd = pwdResult.answers[0]?.custom ?? '';
197
- installProc.stdin?.write(pwd + '\n');
198
- installProc.resume?.(); // 恢复输出
193
+ }).then(async (pwdResult) => {
194
+ const pwd = pwdResult.answers[0]?.custom ?? '';
195
+ installProc.stdin?.write(pwd + '\n');
196
+ }).catch(() => {});
199
197
  }
200
198
  });
201
199
 
202
200
  return new Promise((resolve) => {
203
201
  installProc.on('close', async (code) => {
202
+ // 如果弹过 sudo 框,等弹框完成后再处理结果
203
+ if (sudoDialogPromise) {
204
+ await sudoDialogPromise.catch(() => {});
205
+ }
204
206
  stopCancel(); // 移除取消监听
205
207
  installStop();
206
208
  if (code === 0) {
@@ -216,7 +218,7 @@ async function runScanWithChromiumFix(ctx, session, invocation, { platform, leng
216
218
  resolve('retry');
217
219
  } else {
218
220
  const out = installOut.join('').slice(-300);
219
- notify(session, `❌ Chromium 安装失败(exit ${code})。\n请手动运行以下命令后重试:\n npm install -g @playwright/cli@1.40.0 --registry=https://registry.npmmirror.com && PLAYWRIGHT_DOWNLOAD_HOST=https://npmmirror.com/mirrors/playwright/ playwright-cli@1.40.0 install-browser --with-deps\n\n安装日志末尾:\n${out}`);
221
+ notify(session, `❌ Chromium 安装失败(exit ${code})。\n请手动运行以下命令后重试:\n npm install -g playwright@1.40.0 --registry=https://registry.npmmirror.com && PLAYWRIGHT_DOWNLOAD_HOST=https://npmmirror.com/mirrors/playwright/ playwright install chromium --with-deps\n\n安装日志末尾:\n${out}`);
220
222
  resolve(undefined);
221
223
  }
222
224
  });