@cloud411716/fancy-webnovel 0.1.37 → 0.1.39
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/index.js
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
import { apply as applyBootstrap } from './plugins/fancy-bootstrap/index.js';
|
|
3
3
|
import { apply as applyScan } from './plugins/fancy-scan/index.js';
|
|
4
4
|
|
|
5
|
+
export const inject = ['commands', 'userQuestions'];
|
|
6
|
+
|
|
5
7
|
export async function apply(ctx) {
|
|
6
8
|
await applyBootstrap(ctx);
|
|
7
9
|
await applyScan(ctx);
|
package/package.json
CHANGED
|
@@ -7,6 +7,8 @@ import { existsSync } from 'fs';
|
|
|
7
7
|
import { notify, spawnScript } from '../../infra.js';
|
|
8
8
|
import { bootstrap } from './templates.js';
|
|
9
9
|
|
|
10
|
+
export const inject = ['commands', 'userQuestions'];
|
|
11
|
+
|
|
10
12
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
11
13
|
const SCRIPTS_DIR = join(__dirname, 'scripts');
|
|
12
14
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* fancy-bootstrap init — 项目初始化
|
|
3
3
|
*/
|
|
4
|
-
import { writeFileSync, mkdirSync, existsSync } from 'fs';
|
|
4
|
+
import { writeFileSync, mkdirSync, existsSync, appendFileSync } from 'fs';
|
|
5
5
|
import { expandHome, resolvePath, joinPath } from './path-utils.js';
|
|
6
6
|
|
|
7
7
|
const DIRS = [
|
|
@@ -28,10 +28,7 @@ function main() {
|
|
|
28
28
|
const projectRootRaw = process.argv[2] ?? '';
|
|
29
29
|
|
|
30
30
|
// 调试:打印接收到的参数
|
|
31
|
-
|
|
32
|
-
try {
|
|
33
|
-
require('fs').appendFileSync('/tmp/fancy-init-debug.txt', `argv=${JSON.stringify(process.argv)}\nraw=${projectRootRaw}\n`);
|
|
34
|
-
} catch(e) {}
|
|
31
|
+
try { appendFileSync('/tmp/fancy-init-debug.txt', `argv=${JSON.stringify(process.argv)}\nraw=${projectRootRaw}\n`); } catch(e) {}
|
|
35
32
|
|
|
36
33
|
if (projectRootRaw.includes('..') || /[<>:"'|?*]/.test(projectRootRaw) || /[\x00-\x1f]/.test(projectRootRaw)) {
|
|
37
34
|
console.log(JSON.stringify({ ok: false, error: { code: 1, code_name: 'EC001', message: '路径不合法' } }));
|
|
@@ -102,7 +99,7 @@ function main() {
|
|
|
102
99
|
|
|
103
100
|
} catch (e) {
|
|
104
101
|
const errMsg = e instanceof Error ? e.message : String(e);
|
|
105
|
-
try {
|
|
102
|
+
try { appendFileSync('/tmp/fancy-init-debug.txt', `catch: ${errMsg}\n`); } catch(_) {}
|
|
106
103
|
console.log(JSON.stringify({ ok: false, error: { code: 17, code_name: 'EC017', message: `初始化失败: ${errMsg}` } }));
|
|
107
104
|
process.exit(17);
|
|
108
105
|
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* path-utils.js — init.js 专用路径工具
|
|
3
|
+
* restore from git
|
|
4
|
+
*/
|
|
5
|
+
import { existsSync } from 'fs';
|
|
6
|
+
import { homedir } from 'os';
|
|
7
|
+
import { resolve, join } from 'path';
|
|
8
|
+
|
|
9
|
+
export function expandHome(p) {
|
|
10
|
+
if (p === '~' || p.startsWith('~/')) {
|
|
11
|
+
return join(homedir(), p.slice(1));
|
|
12
|
+
}
|
|
13
|
+
return p;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function resolvePath(p) {
|
|
17
|
+
return resolve(p);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function joinPath(base, ...parts) {
|
|
21
|
+
return join(base, ...parts);
|
|
22
|
+
}
|
|
@@ -7,6 +7,8 @@ import { existsSync } from 'fs';
|
|
|
7
7
|
import { notify, llmFollowup, spawnScript } from '../../infra.js';
|
|
8
8
|
import { scan, PLATFORM_TABLE, platformLabel } from './templates.js';
|
|
9
9
|
|
|
10
|
+
export const inject = ['commands', 'userQuestions'];
|
|
11
|
+
|
|
10
12
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
11
13
|
const SCAN_SCRIPTS_DIR = join(__dirname, 'scripts');
|
|
12
14
|
|