@deveco-test/deveco-cli-openharmony-arm64 1.3.6-Test.1 → 1.3.11-Test.1

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.
Files changed (42) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +844 -837
  3. package/SKILL.md +190 -187
  4. package/THIRD-PARTY-LICENSES +342 -233
  5. package/dist/cli.js +135 -137
  6. package/dist/internal/doc-init-background.js +9 -9
  7. package/dist/internal/telemetry-upload-background.js +1 -1
  8. package/index.zip +0 -0
  9. package/package.json +110 -108
  10. package/scripts/install-better-sqlite3.mjs +51 -51
  11. package/scripts/install-jieba-wasm.mjs +47 -47
  12. package/scripts/lib/better-sqlite3-vendor.mjs +128 -128
  13. package/scripts/lib/cli-data-dir.mjs +44 -44
  14. package/scripts/lib/doc-init-log-path.mjs +15 -15
  15. package/scripts/lib/jieba-wasm-vendor.mjs +102 -102
  16. package/scripts/postinstall.mjs +64 -64
  17. package/src/resources/aclPermission/aclPermissionsInfo.json +310 -310
  18. package/templates/application/AppScope/app.json5 +10 -10
  19. package/templates/application/AppScope/resources/base/element/string.json +8 -8
  20. package/templates/application/AppScope/resources/base/media/layered_image.json +6 -6
  21. package/templates/application/build-profile.json5 +41 -41
  22. package/templates/application/code-linter.json5 +31 -31
  23. package/templates/application/entry/build-profile.json5 +32 -32
  24. package/templates/application/entry/gitignore.txt +5 -5
  25. package/templates/application/entry/hvigorfile.ts +7 -7
  26. package/templates/application/entry/obfuscation-rules.txt +19 -19
  27. package/templates/application/entry/oh-package.json5 +10 -10
  28. package/templates/application/entry/src/main/ets/entryability/EntryAbility.ets +62 -62
  29. package/templates/application/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +30 -30
  30. package/templates/application/entry/src/main/ets/pages/Index.ets +37 -37
  31. package/templates/application/entry/src/main/module.json5 +49 -49
  32. package/templates/application/entry/src/main/resources/base/element/color.json +7 -7
  33. package/templates/application/entry/src/main/resources/base/element/float.json +8 -8
  34. package/templates/application/entry/src/main/resources/base/element/string.json +15 -15
  35. package/templates/application/entry/src/main/resources/base/media/layered_image.json +6 -6
  36. package/templates/application/entry/src/main/resources/base/profile/backup_config.json +2 -2
  37. package/templates/application/entry/src/main/resources/base/profile/main_pages.json +5 -5
  38. package/templates/application/entry/src/main/resources/dark/element/color.json +7 -7
  39. package/templates/application/gitignore.txt +11 -11
  40. package/templates/application/hvigor/hvigor-config.json5 +23 -23
  41. package/templates/application/hvigorfile.ts +7 -7
  42. package/templates/application/oh-package.json5 +10 -10
@@ -1,102 +1,102 @@
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
- }
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
+ }
@@ -1,64 +1,64 @@
1
- /*
2
- * Copyright (c) 2026 Huawei Device Co., Ltd.
3
- * SPDX-License-Identifier: MIT
4
- */
5
-
6
- import { spawn } from 'child_process';
7
- import { chmodSync, existsSync, mkdirSync } from 'fs';
8
- import { platform } from 'os';
9
- import { dirname, join } from 'path';
10
- import { fileURLToPath } from 'url';
11
- import { ensureBetterSqlite3ForDocs } from './install-better-sqlite3.mjs';
12
- import { ensureJiebaWasmForDocs } from './install-jieba-wasm.mjs';
13
- import { getDocInitLogPath } from './lib/doc-init-log-path.mjs';
14
-
15
- const root = join(dirname(fileURLToPath(import.meta.url)), '..');
16
- const logPath = getDocInitLogPath();
17
- mkdirSync(dirname(logPath), { recursive: true });
18
-
19
- // On OpenHarmony's /storage/ overlayfs, npm's bin-link chmod may not persist,
20
- // causing "zsh: permission denied" when running `devecocli`.
21
- if (platform().toLowerCase().includes('openharmony')) {
22
- const cliEntry = join(root, 'dist', 'cli.js');
23
- if (existsSync(cliEntry)) {
24
- try {
25
- chmodSync(cliEntry, 0o755);
26
- } catch {
27
- /* filesystem does not support chmod */
28
- }
29
- }
30
- }
31
-
32
- const nativeResult = await ensureBetterSqlite3ForDocs();
33
- if (!nativeResult.ok && !nativeResult.skipped) {
34
- console.warn(
35
- `[deveco-cli] better-sqlite3 install via npm failed; docs search will use sqlite-wasm fallback.\n` +
36
- `${nativeResult.error ?? ''}\n`
37
- );
38
- }
39
-
40
- const jiebaResult = await ensureJiebaWasmForDocs();
41
- if (!jiebaResult.ok && !jiebaResult.skipped) {
42
- console.warn(
43
- `[deveco-cli] jieba wasm install via npm failed; docs search may fail on this machine.\n` +
44
- `${jiebaResult.error ?? ''}\n`
45
- );
46
- }
47
- const initScript = join(root, 'dist', 'internal', 'doc-init-background.js');
48
-
49
- if (!existsSync(initScript)) {
50
- process.exit(0);
51
- }
52
-
53
- const child = spawn(process.execPath, [initScript], {
54
- detached: true,
55
- stdio: ['ignore', 'ignore', 'ignore'],
56
- env: {
57
- ...process.env,
58
- DEVECO_CLI_SKIP_VERSION_CHECK: '1',
59
- DEVECO_CLI_POSTINSTALL: '1',
60
- },
61
- });
62
-
63
- child.unref();
64
- process.exit(0);
1
+ /*
2
+ * Copyright (c) 2026 Huawei Device Co., Ltd.
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ import { spawn } from 'child_process';
7
+ import { chmodSync, existsSync, mkdirSync } from 'fs';
8
+ import { platform } from 'os';
9
+ import { dirname, join } from 'path';
10
+ import { fileURLToPath } from 'url';
11
+ import { ensureBetterSqlite3ForDocs } from './install-better-sqlite3.mjs';
12
+ import { ensureJiebaWasmForDocs } from './install-jieba-wasm.mjs';
13
+ import { getDocInitLogPath } from './lib/doc-init-log-path.mjs';
14
+
15
+ const root = join(dirname(fileURLToPath(import.meta.url)), '..');
16
+ const logPath = getDocInitLogPath();
17
+ mkdirSync(dirname(logPath), { recursive: true });
18
+
19
+ // On OpenHarmony's /storage/ overlayfs, npm's bin-link chmod may not persist,
20
+ // causing "zsh: permission denied" when running `devecocli`.
21
+ if (platform().toLowerCase().includes('openharmony')) {
22
+ const cliEntry = join(root, 'dist', 'cli.js');
23
+ if (existsSync(cliEntry)) {
24
+ try {
25
+ chmodSync(cliEntry, 0o755);
26
+ } catch {
27
+ /* filesystem does not support chmod */
28
+ }
29
+ }
30
+ }
31
+
32
+ const nativeResult = await ensureBetterSqlite3ForDocs();
33
+ if (!nativeResult.ok && !nativeResult.skipped) {
34
+ console.warn(
35
+ `[deveco-cli] better-sqlite3 install via npm failed; docs search will use sqlite-wasm fallback.\n` +
36
+ `${nativeResult.error ?? ''}\n`
37
+ );
38
+ }
39
+
40
+ const jiebaResult = await ensureJiebaWasmForDocs();
41
+ if (!jiebaResult.ok && !jiebaResult.skipped) {
42
+ console.warn(
43
+ `[deveco-cli] jieba wasm install via npm failed; docs search may fail on this machine.\n` +
44
+ `${jiebaResult.error ?? ''}\n`
45
+ );
46
+ }
47
+ const initScript = join(root, 'dist', 'internal', 'doc-init-background.js');
48
+
49
+ if (!existsSync(initScript)) {
50
+ process.exit(0);
51
+ }
52
+
53
+ const child = spawn(process.execPath, [initScript], {
54
+ detached: true,
55
+ stdio: ['ignore', 'ignore', 'ignore'],
56
+ env: {
57
+ ...process.env,
58
+ DEVECO_CLI_SKIP_VERSION_CHECK: '1',
59
+ DEVECO_CLI_POSTINSTALL: '1',
60
+ },
61
+ });
62
+
63
+ child.unref();
64
+ process.exit(0);