@lazycatcloud/lzc-cli 1.3.12 → 1.3.14
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/changelog.md +21 -0
- package/lib/app/apkshell.js +37 -40
- package/lib/app/index.js +187 -186
- package/lib/app/lpk_build.js +345 -358
- package/lib/app/lpk_create.js +136 -155
- package/lib/app/lpk_create_generator.js +77 -66
- package/lib/app/lpk_devshell.js +444 -533
- package/lib/app/lpk_devshell_docker.js +48 -47
- package/lib/app/lpk_installer.js +120 -123
- package/lib/appstore/index.js +245 -214
- package/lib/appstore/login.js +146 -143
- package/lib/appstore/prePublish.js +101 -100
- package/lib/appstore/publish.js +256 -256
- package/lib/box/index.js +82 -77
- package/lib/config/index.js +59 -54
- package/lib/debug_bridge.js +282 -330
- package/lib/docker/index.js +84 -86
- package/lib/i18n/README.md +25 -0
- package/lib/i18n/index.js +37 -0
- package/lib/i18n/locales/en/translation.json +252 -0
- package/lib/i18n/locales/zh/translation.json +252 -0
- package/lib/shellapi.js +122 -146
- package/lib/utils.js +539 -552
- package/package.json +6 -8
- package/scripts/cli.js +81 -77
- package/scripts/lzc-docker-compose.js +34 -33
- package/scripts/lzc-docker.js +34 -33
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lazycatcloud/lzc-cli",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.14",
|
|
4
4
|
"description": "lazycat cloud developer kit",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"release": "release-it patch",
|
|
7
|
-
"prepublishOnly": "node check-changelog.js"
|
|
7
|
+
"prepublishOnly": "node check-changelog.js",
|
|
8
|
+
"i18n:parser": "i18next-cli extract -c i18next.config.js --sync-all && prettier -w ./lib/i18n/locales"
|
|
8
9
|
},
|
|
9
10
|
"files": [
|
|
10
11
|
"template",
|
|
@@ -42,6 +43,8 @@
|
|
|
42
43
|
"envsub": "^4.1.0",
|
|
43
44
|
"fast-glob": "^3.3.2",
|
|
44
45
|
"form-data": "^4.0.0",
|
|
46
|
+
"i18next": "^25.7.1",
|
|
47
|
+
"i18next-fs-backend": "^2.6.1",
|
|
45
48
|
"ignore": "^5.3.2",
|
|
46
49
|
"inquirer": "^10.1.8",
|
|
47
50
|
"isbinaryfile": "^5.0.2",
|
|
@@ -58,15 +61,10 @@
|
|
|
58
61
|
"devDependencies": {
|
|
59
62
|
"@release-it/conventional-changelog": "^10.0.1",
|
|
60
63
|
"@types/command-exists": "^1.2.3",
|
|
64
|
+
"i18next-cli": "^1.32.0",
|
|
61
65
|
"prettier": "^3.3.3",
|
|
62
66
|
"release-it": "^19.0.4"
|
|
63
67
|
},
|
|
64
|
-
"prettier": {
|
|
65
|
-
"bracketSameLine": true,
|
|
66
|
-
"htmlWhitespaceSensitivity": "ignore",
|
|
67
|
-
"semi": false,
|
|
68
|
-
"trailingComma": "none"
|
|
69
|
-
},
|
|
70
68
|
"release-it": {
|
|
71
69
|
"git": {
|
|
72
70
|
"requireCleanWorkingDir": false,
|
package/scripts/cli.js
CHANGED
|
@@ -1,92 +1,96 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import process from
|
|
3
|
-
import path from
|
|
4
|
-
import fs from
|
|
5
|
-
import logger from
|
|
6
|
-
import yargs from
|
|
7
|
-
import { hideBin } from
|
|
8
|
-
import
|
|
2
|
+
import process from 'process';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
import fs from 'fs';
|
|
5
|
+
import logger from 'loglevel';
|
|
6
|
+
import yargs from 'yargs';
|
|
7
|
+
import { hideBin } from 'yargs/helpers';
|
|
8
|
+
import '../lib/log.js'; // init logger
|
|
9
|
+
import i18n, { t } from '../lib/i18n/index.js'; // init i18n
|
|
9
10
|
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
} from
|
|
16
|
-
import { boxCommand } from "../lib/box/index.js"
|
|
17
|
-
import { appstoreCommand } from "../lib/appstore/index.js"
|
|
18
|
-
import { lpkAppCommand, lpkProjectCommand } from "../lib/app/index.js"
|
|
19
|
-
import { configCommand } from "../lib/config/index.js"
|
|
20
|
-
import { lzcDockerCommand } from "../lib/docker/index.js"
|
|
11
|
+
import { contextDirname, pkgInfo, getLatestVersion, checkNodejsVersion } from '../lib/utils.js';
|
|
12
|
+
import { boxCommand } from '../lib/box/index.js';
|
|
13
|
+
import { appstoreCommand } from '../lib/appstore/index.js';
|
|
14
|
+
import { lpkAppCommand, lpkProjectCommand } from '../lib/app/index.js';
|
|
15
|
+
import { configCommand } from '../lib/config/index.js';
|
|
16
|
+
import { lzcDockerCommand } from '../lib/docker/index.js';
|
|
21
17
|
|
|
22
18
|
function setLoggerLevel({ log }) {
|
|
23
|
-
|
|
19
|
+
logger.setLevel(log, false);
|
|
24
20
|
}
|
|
25
21
|
|
|
26
22
|
function checkLatestVersion(controller) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
23
|
+
return ({ _: args }) => {
|
|
24
|
+
if (args.length > 0) {
|
|
25
|
+
switch (args[0]) {
|
|
26
|
+
case 'project':
|
|
27
|
+
case 'app':
|
|
28
|
+
case 'appstore':
|
|
29
|
+
getLatestVersion(controller);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
};
|
|
37
33
|
}
|
|
38
34
|
|
|
39
35
|
const program = yargs(hideBin(process.argv))
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
36
|
+
.scriptName('lzc-cli')
|
|
37
|
+
.usage('<command> [options]')
|
|
38
|
+
.version(`lzc-cli ${pkgInfo.version}`)
|
|
39
|
+
.option('log', {
|
|
40
|
+
type: 'string',
|
|
41
|
+
default: 'info',
|
|
42
|
+
describe: "log level 'trace', 'debug', 'info', 'warn', 'error'",
|
|
43
|
+
})
|
|
44
|
+
.option('help', {
|
|
45
|
+
alias: 'h',
|
|
46
|
+
type: 'boolean',
|
|
47
|
+
default: false,
|
|
48
|
+
})
|
|
49
|
+
.completion('completion', false)
|
|
50
|
+
.detectLocale(true)
|
|
51
|
+
.wrap(null); // https://yargs.js.org/docs/#api-reference-wrapcolumns
|
|
55
52
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
53
|
+
// 读取终端本地化语言配置
|
|
54
|
+
// https://yargs.js.org/docs/#api-reference-locale
|
|
55
|
+
const locale = program.locale();
|
|
56
|
+
if (locale) {
|
|
57
|
+
i18n.changeLanguage(locale);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
configCommand(program);
|
|
61
|
+
boxCommand(program);
|
|
62
|
+
lpkAppCommand(program);
|
|
63
|
+
lpkProjectCommand(program);
|
|
64
|
+
appstoreCommand(program);
|
|
65
|
+
lzcDockerCommand(program);
|
|
62
66
|
|
|
63
67
|
// 当没有参数的时候,默认显示帮助。
|
|
64
|
-
|
|
65
|
-
|
|
68
|
+
(async () => {
|
|
69
|
+
checkNodejsVersion();
|
|
66
70
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
71
|
+
const controller = new AbortController();
|
|
72
|
+
const parser = program
|
|
73
|
+
.strict()
|
|
74
|
+
.showHelpOnFail(false, t('lzc_cli.script.cli.help_msg_content', '使用 lzc-cli help 查看更多帮助'))
|
|
75
|
+
.middleware([setLoggerLevel, checkLatestVersion(controller)])
|
|
76
|
+
.parse();
|
|
73
77
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
})()
|
|
78
|
+
try {
|
|
79
|
+
const argv = await parser;
|
|
80
|
+
if (argv._.length == 1) {
|
|
81
|
+
switch (argv._[0]) {
|
|
82
|
+
case 'box':
|
|
83
|
+
case 'app':
|
|
84
|
+
case 'project':
|
|
85
|
+
case 'appstore':
|
|
86
|
+
case 'config':
|
|
87
|
+
program.showHelp();
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
} else if (argv._.length == 0) {
|
|
91
|
+
program.showHelp();
|
|
92
|
+
}
|
|
93
|
+
} finally {
|
|
94
|
+
controller.abort();
|
|
95
|
+
}
|
|
96
|
+
})();
|
|
@@ -1,43 +1,44 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import process from
|
|
3
|
-
import logger from
|
|
4
|
-
import yargs from
|
|
5
|
-
import { hideBin } from
|
|
2
|
+
import process from 'process';
|
|
3
|
+
import logger from 'loglevel';
|
|
4
|
+
import yargs from 'yargs';
|
|
5
|
+
import { hideBin } from 'yargs/helpers';
|
|
6
6
|
|
|
7
|
-
import
|
|
8
|
-
import { pkgInfo } from
|
|
9
|
-
import { singleLzcDockerComposeCommand } from
|
|
7
|
+
import '../lib/log.js';
|
|
8
|
+
import { pkgInfo } from '../lib/utils.js';
|
|
9
|
+
import { singleLzcDockerComposeCommand } from '../lib/docker/index.js';
|
|
10
|
+
import { t } from '../lib/i18n/index.js'; // init i18n
|
|
10
11
|
|
|
11
12
|
function setLoggerLevel({ log }) {
|
|
12
|
-
|
|
13
|
+
logger.setLevel(log, false);
|
|
13
14
|
}
|
|
14
15
|
|
|
15
16
|
const program = yargs(hideBin(process.argv))
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
17
|
+
.scriptName('lzc-docker-compose')
|
|
18
|
+
.usage('<command> [options]')
|
|
19
|
+
.version(`lzc-docker-compose ${pkgInfo.version}`)
|
|
20
|
+
.option('log', {
|
|
21
|
+
type: 'string',
|
|
22
|
+
default: 'info',
|
|
23
|
+
describe: "log level 'trace', 'debug', 'info', 'warn', 'error'",
|
|
24
|
+
})
|
|
25
|
+
.option('help', {
|
|
26
|
+
alias: 'h',
|
|
27
|
+
type: 'boolean',
|
|
28
|
+
default: false,
|
|
29
|
+
})
|
|
30
|
+
.command(singleLzcDockerComposeCommand('$0'));
|
|
30
31
|
|
|
31
32
|
// 当没有参数的时候,默认显示帮助。
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
33
|
+
(async () => {
|
|
34
|
+
const parser = program
|
|
35
|
+
.strict(false)
|
|
36
|
+
.showHelpOnFail(false, t('lzc_cli.script.lzc_docker_compose.help_msg_content', '使用 lzc-cli help 查看更多帮助'))
|
|
37
|
+
.middleware([setLoggerLevel])
|
|
38
|
+
.parse();
|
|
38
39
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
})()
|
|
40
|
+
const argv = await parser;
|
|
41
|
+
if (argv._.length == 0) {
|
|
42
|
+
program.showHelp();
|
|
43
|
+
}
|
|
44
|
+
})();
|
package/scripts/lzc-docker.js
CHANGED
|
@@ -1,43 +1,44 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import process from
|
|
3
|
-
import logger from
|
|
4
|
-
import yargs from
|
|
5
|
-
import { hideBin } from
|
|
2
|
+
import process from 'process';
|
|
3
|
+
import logger from 'loglevel';
|
|
4
|
+
import yargs from 'yargs';
|
|
5
|
+
import { hideBin } from 'yargs/helpers';
|
|
6
6
|
|
|
7
|
-
import
|
|
8
|
-
import { pkgInfo } from
|
|
9
|
-
import { singleLzcDockerCommand } from
|
|
7
|
+
import '../lib/log.js';
|
|
8
|
+
import { pkgInfo } from '../lib/utils.js';
|
|
9
|
+
import { singleLzcDockerCommand } from '../lib/docker/index.js';
|
|
10
|
+
import { t } from '../lib/i18n/index.js';
|
|
10
11
|
|
|
11
12
|
function setLoggerLevel({ log }) {
|
|
12
|
-
|
|
13
|
+
logger.setLevel(log, false);
|
|
13
14
|
}
|
|
14
15
|
|
|
15
16
|
const program = yargs(hideBin(process.argv))
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
17
|
+
.scriptName('lzc-docker')
|
|
18
|
+
.usage('<command> [options]')
|
|
19
|
+
.version(`lzc-docker ${pkgInfo.version}`)
|
|
20
|
+
.option('log', {
|
|
21
|
+
type: 'string',
|
|
22
|
+
default: 'info',
|
|
23
|
+
describe: "log level 'trace', 'debug', 'info', 'warn', 'error'",
|
|
24
|
+
})
|
|
25
|
+
.option('help', {
|
|
26
|
+
alias: 'h',
|
|
27
|
+
type: 'boolean',
|
|
28
|
+
default: false,
|
|
29
|
+
})
|
|
30
|
+
.command(singleLzcDockerCommand('$0'));
|
|
30
31
|
|
|
31
32
|
// 当没有参数的时候,默认显示帮助。
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
33
|
+
(async () => {
|
|
34
|
+
const parser = program
|
|
35
|
+
.strict(false)
|
|
36
|
+
.showHelpOnFail(false, t('lzc_cli.script.lzc_docker.help_msg_content', '使用 lzc-cli help 查看更多帮助'))
|
|
37
|
+
.middleware([setLoggerLevel])
|
|
38
|
+
.parse();
|
|
38
39
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
})()
|
|
40
|
+
const argv = await parser;
|
|
41
|
+
if (argv._.length == 0) {
|
|
42
|
+
program.showHelp();
|
|
43
|
+
}
|
|
44
|
+
})();
|