@deveco-test/deveco-cli 1.3.0-Test.9 → 1.3.1-Test.2
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/README.md +321 -77
- package/SKILL.md +23 -13
- package/THIRD-PARTY-LICENSES +255 -1037
- package/dist/cli.js +134 -122
- package/dist/internal/doc-init-background.js +1 -65
- package/dist/internal/telemetry-upload-background.js +9 -0
- package/docs.zip +2 -2
- package/index.zip +0 -0
- package/package.json +12 -18
- package/scripts/postinstall.mjs +1 -22
- package/scripts/install-better-sqlite3.mjs +0 -51
- package/scripts/install-jieba-wasm.mjs +0 -47
- package/scripts/lib/better-sqlite3-vendor.mjs +0 -129
- package/scripts/lib/cli-data-dir.mjs +0 -44
- package/scripts/lib/doc-init-log-path.mjs +0 -15
- package/scripts/lib/jieba-wasm-vendor.mjs +0 -102
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2026 Huawei Device Co., Ltd.
|
|
3
|
-
* SPDX-License-Identifier: MIT
|
|
4
|
-
*
|
|
5
|
-
* Keep in sync with src/utils/cli-data-dir.ts
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import { homedir } from 'os';
|
|
9
|
-
import { join, resolve } from 'path';
|
|
10
|
-
|
|
11
|
-
const APP_NAME = 'deveco-cli';
|
|
12
|
-
|
|
13
|
-
/** Strip quotes from cmd.exe `set VAR="path"` (quotes become part of the value). */
|
|
14
|
-
function normalizeEnvDataDir(value) {
|
|
15
|
-
let normalized = value.trim();
|
|
16
|
-
if (
|
|
17
|
-
(normalized.startsWith('"') && normalized.endsWith('"')) ||
|
|
18
|
-
(normalized.startsWith("'") && normalized.endsWith("'"))
|
|
19
|
-
) {
|
|
20
|
-
normalized = normalized.slice(1, -1).trim();
|
|
21
|
-
}
|
|
22
|
-
return normalized;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export function isCliDataDirConfigured() {
|
|
26
|
-
const raw = process.env.DEVECO_CLI_DATA_DIR;
|
|
27
|
-
return raw !== undefined && normalizeEnvDataDir(raw) !== '';
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
function getDefaultCliDataDir() {
|
|
31
|
-
return join(homedir(), '.local', 'share', APP_NAME);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export function getCliDataDir() {
|
|
35
|
-
const raw = process.env.DEVECO_CLI_DATA_DIR;
|
|
36
|
-
if (raw === undefined || raw === '') {
|
|
37
|
-
return getDefaultCliDataDir();
|
|
38
|
-
}
|
|
39
|
-
const envDir = normalizeEnvDataDir(raw);
|
|
40
|
-
if (!envDir) {
|
|
41
|
-
return getDefaultCliDataDir();
|
|
42
|
-
}
|
|
43
|
-
return resolve(envDir);
|
|
44
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2026 Huawei Device Co., Ltd.
|
|
3
|
-
* SPDX-License-Identifier: MIT
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import { join } from 'path';
|
|
7
|
-
import { getCliDataDir } from './cli-data-dir.mjs';
|
|
8
|
-
|
|
9
|
-
export function getDocInitLogDir() {
|
|
10
|
-
return join(getCliDataDir(), 'logs');
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export function getDocInitLogPath() {
|
|
14
|
-
return join(getDocInitLogDir(), 'doc-init.log');
|
|
15
|
-
}
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2026 Huawei Device Co., Ltd.
|
|
3
|
-
* SPDX-License-Identifier: MIT
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import { dirname, join } from 'path';
|
|
7
|
-
import { existsSync } from 'fs';
|
|
8
|
-
import { spawnSync } from 'child_process';
|
|
9
|
-
import { fileURLToPath } from 'url';
|
|
10
|
-
import { packageRoot } from './better-sqlite3-vendor.mjs';
|
|
11
|
-
|
|
12
|
-
const JIEBA_WASM_VERSION = '2.0.1';
|
|
13
|
-
|
|
14
|
-
function resolveNpmCliPath() {
|
|
15
|
-
const nodeDir = dirname(process.execPath);
|
|
16
|
-
const candidates = [
|
|
17
|
-
join(nodeDir, 'node_modules', 'npm', 'bin', 'npm-cli.js'),
|
|
18
|
-
join(nodeDir, '..', 'lib', 'node_modules', 'npm', 'bin', 'npm-cli.js'),
|
|
19
|
-
];
|
|
20
|
-
return candidates.find((candidate) => existsSync(candidate)) ?? null;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
function quoteWindowsCmdArg(arg) {
|
|
24
|
-
return /\s/.test(arg) ? `"${arg.replace(/"/g, '\\"')}"` : arg;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
function spawnDetail(result) {
|
|
28
|
-
return [result.stderr, result.stdout, result.error?.message]
|
|
29
|
-
.filter(Boolean)
|
|
30
|
-
.join('\n')
|
|
31
|
-
.trim();
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
function runNpmInstallJiebaWasm(targetVersion) {
|
|
35
|
-
const args = [
|
|
36
|
-
'install',
|
|
37
|
-
`@node-rs/jieba-wasm32-wasi@${targetVersion}`,
|
|
38
|
-
'--no-save',
|
|
39
|
-
'--cpu=wasm32',
|
|
40
|
-
];
|
|
41
|
-
const npmCli = resolveNpmCliPath();
|
|
42
|
-
if (npmCli) {
|
|
43
|
-
return spawnSync(process.execPath, [npmCli, ...args], {
|
|
44
|
-
cwd: packageRoot,
|
|
45
|
-
stdio: 'pipe',
|
|
46
|
-
encoding: 'utf-8',
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
if (process.platform === 'win32') {
|
|
50
|
-
const command = ['npm', ...args].map(quoteWindowsCmdArg).join(' ');
|
|
51
|
-
return spawnSync(command, {
|
|
52
|
-
cwd: packageRoot,
|
|
53
|
-
stdio: 'pipe',
|
|
54
|
-
encoding: 'utf-8',
|
|
55
|
-
shell: true,
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
return spawnSync('npm', args, {
|
|
59
|
-
cwd: packageRoot,
|
|
60
|
-
stdio: 'pipe',
|
|
61
|
-
encoding: 'utf-8',
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
export async function installJiebaWasmViaNpm(targetVersion = JIEBA_WASM_VERSION) {
|
|
66
|
-
try {
|
|
67
|
-
await import('@node-rs/jieba-wasm32-wasi');
|
|
68
|
-
return { ok: true, skipped: true, reason: 'already-installed' };
|
|
69
|
-
} catch {
|
|
70
|
-
// continue — try native or install wasm
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
try {
|
|
74
|
-
await import('@node-rs/jieba');
|
|
75
|
-
return { ok: true, skipped: true, reason: 'native-available' };
|
|
76
|
-
} catch {
|
|
77
|
-
// continue — install wasm fallback
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
const result = runNpmInstallJiebaWasm(targetVersion);
|
|
81
|
-
if (result.status !== 0) {
|
|
82
|
-
return {
|
|
83
|
-
ok: false,
|
|
84
|
-
reason: 'npm-install-failed',
|
|
85
|
-
version: targetVersion,
|
|
86
|
-
error: spawnDetail(result) || `exit ${result.status ?? 'null'}`,
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
try {
|
|
91
|
-
await import('@node-rs/jieba-wasm32-wasi');
|
|
92
|
-
} catch {
|
|
93
|
-
return {
|
|
94
|
-
ok: false,
|
|
95
|
-
reason: 'load-failed',
|
|
96
|
-
version: targetVersion,
|
|
97
|
-
error:
|
|
98
|
-
'npm install finished but @node-rs/jieba-wasm32-wasi still cannot be imported',
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
return { ok: true, version: targetVersion, method: 'npm' };
|
|
102
|
-
}
|