@blocklet/cli 1.16.54-beta-20251021-070951-25e3083c → 1.16.54-beta-20251024-030947-6f2889bf
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/lib/commands/server/command.js +11 -2
- package/lib/commands/server/info.js +28 -13
- package/lib/commands/server/init.js +6 -4
- package/lib/util/index.js +4 -2
- package/package.json +26 -25
|
@@ -34,6 +34,10 @@ module.exports = (parentCommand = '') => {
|
|
|
34
34
|
async (...args) => {
|
|
35
35
|
printVersionTip();
|
|
36
36
|
|
|
37
|
+
// @note: 这里的 yes 我始终无法通过 commander.js 获取,所以做一下特殊处理
|
|
38
|
+
const yes = process.argv.includes('--yes') || process.argv.includes('-y');
|
|
39
|
+
Object.assign(args[0], { yes });
|
|
40
|
+
|
|
37
41
|
const commonOptions = program.opts();
|
|
38
42
|
const options = last(args);
|
|
39
43
|
const allOptions = { ...commonOptions, ...options };
|
|
@@ -65,10 +69,15 @@ module.exports = (parentCommand = '') => {
|
|
|
65
69
|
|
|
66
70
|
program
|
|
67
71
|
.command('init')
|
|
68
|
-
.option(
|
|
72
|
+
.option(
|
|
73
|
+
'-y --yes',
|
|
74
|
+
'Initialize a Blocklet Server instance without having it ask any questions, same as --force',
|
|
75
|
+
false
|
|
76
|
+
)
|
|
77
|
+
.option('-f --force', 'alias of -y, --yes', false)
|
|
69
78
|
.option(
|
|
70
79
|
'-i --interactive',
|
|
71
|
-
'Should we run in interactive mode (default: false), if `--force` is enabled, the `--interactive` argument will be invalid',
|
|
80
|
+
'Should we run in interactive mode (default: false), if `--force` or `--yes` is enabled, the `--interactive` argument will be invalid',
|
|
72
81
|
false
|
|
73
82
|
)
|
|
74
83
|
.option(
|
|
@@ -5,15 +5,23 @@ const chalk = require('chalk');
|
|
|
5
5
|
const clipboardy = require('clipboardy');
|
|
6
6
|
const ip = require('@abtnode/core/lib/util/ip');
|
|
7
7
|
const info = require('@abtnode/core/lib/util/sysinfo');
|
|
8
|
+
const stripAnsi = require('strip-ansi');
|
|
8
9
|
|
|
9
10
|
const { canUseFileSystemIsolateApi } = require('@abtnode/util/lib/security');
|
|
10
|
-
const { print, printError, printInfo, getCLIBinaryName } = require('../../util');
|
|
11
|
+
const { print, printError, printInfo, getCLIBinaryName, getVersionInfo } = require('../../util');
|
|
11
12
|
const { readNodeConfigWithValidate, getNode } = require('../../node');
|
|
12
13
|
const getDockerStatusLog = require('../../util/docker-status-log');
|
|
13
14
|
|
|
14
15
|
exports.run = ({ clipboard }) => {
|
|
15
16
|
// Clipboard is not accessible when on a linux tty
|
|
16
17
|
const copyToClipboard = process.platform === 'linux' && !process.env.DISPLAY ? false : clipboard;
|
|
18
|
+
// 收集需要复制到剪贴板的 printInfo 信息
|
|
19
|
+
const toPlainText = (str) => stripAnsi(str);
|
|
20
|
+
let clipboardBuffer = `${getVersionInfo()}\n`;
|
|
21
|
+
const bufferedPrintInfo = (...args) => {
|
|
22
|
+
printInfo(...args);
|
|
23
|
+
clipboardBuffer += `${args.map(toPlainText).join(' ')}\n`;
|
|
24
|
+
};
|
|
17
25
|
|
|
18
26
|
const printEnvInfo = (err) => {
|
|
19
27
|
if (err) {
|
|
@@ -32,9 +40,11 @@ exports.run = ({ clipboard }) => {
|
|
|
32
40
|
})
|
|
33
41
|
.then((output) => {
|
|
34
42
|
print(output);
|
|
43
|
+
clipboardBuffer += `${output}`;
|
|
35
44
|
|
|
36
45
|
if (copyToClipboard) {
|
|
37
|
-
|
|
46
|
+
const combined = `${clipboardBuffer}`;
|
|
47
|
+
clipboardy.writeSync(combined);
|
|
38
48
|
}
|
|
39
49
|
|
|
40
50
|
process.exit(0);
|
|
@@ -47,15 +57,20 @@ exports.run = ({ clipboard }) => {
|
|
|
47
57
|
|
|
48
58
|
return readNodeConfigWithValidate(process.cwd())
|
|
49
59
|
.then(async ({ config, configFile }) => {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
60
|
+
bufferedPrintInfo('Server binary from:', chalk.cyan(shell.which(getCLIBinaryName())?.stdout));
|
|
61
|
+
bufferedPrintInfo('Server config from:', chalk.cyan(configFile));
|
|
62
|
+
bufferedPrintInfo('Server router provider:', chalk.cyan(config.node.routing.provider));
|
|
63
|
+
bufferedPrintInfo('Server http port:', chalk.cyan(config.node.routing.httpPort));
|
|
64
|
+
bufferedPrintInfo('Server https port:', chalk.cyan(config.node.routing.httpsPort));
|
|
55
65
|
|
|
56
66
|
let result = await info.getSysInfo();
|
|
57
|
-
|
|
58
|
-
|
|
67
|
+
bufferedPrintInfo(
|
|
68
|
+
'Server host cpu:',
|
|
69
|
+
chalk.cyan(result.cpu.physicalCores),
|
|
70
|
+
'/',
|
|
71
|
+
chalk.cyan(result.cpu.cpus.length)
|
|
72
|
+
);
|
|
73
|
+
bufferedPrintInfo(
|
|
59
74
|
'Server host memory:',
|
|
60
75
|
chalk.cyan(xbytes(result.mem.used, { iec: true })),
|
|
61
76
|
'/',
|
|
@@ -63,7 +78,7 @@ exports.run = ({ clipboard }) => {
|
|
|
63
78
|
);
|
|
64
79
|
|
|
65
80
|
result = await ip.get();
|
|
66
|
-
|
|
81
|
+
bufferedPrintInfo('Server host IP:', chalk.cyan(JSON.stringify(result)));
|
|
67
82
|
const correct = await ip.isDnsIpMappingCorrect(config.node.did);
|
|
68
83
|
|
|
69
84
|
/**
|
|
@@ -75,7 +90,7 @@ exports.run = ({ clipboard }) => {
|
|
|
75
90
|
const { enableFileSystemIsolation } = nodeInfo;
|
|
76
91
|
const canUseFileSystemIsolation = canUseFileSystemIsolateApi();
|
|
77
92
|
|
|
78
|
-
|
|
93
|
+
bufferedPrintInfo(
|
|
79
94
|
'Server file system isolation status:',
|
|
80
95
|
enableFileSystemIsolation
|
|
81
96
|
? `${canUseFileSystemIsolation ? chalk.green('on(available)') : chalk.yellow('on(unavailable, version must be >= 21.6.0)')}`
|
|
@@ -83,8 +98,8 @@ exports.run = ({ clipboard }) => {
|
|
|
83
98
|
);
|
|
84
99
|
// 判断是否是mac
|
|
85
100
|
|
|
86
|
-
getDockerStatusLog(
|
|
87
|
-
|
|
101
|
+
getDockerStatusLog(bufferedPrintInfo, nodeInfo);
|
|
102
|
+
bufferedPrintInfo('Server domain status:', correct ? chalk.green('correct') : chalk.red('mismatch'));
|
|
88
103
|
|
|
89
104
|
return printEnvInfo();
|
|
90
105
|
})
|
|
@@ -35,7 +35,6 @@ const {
|
|
|
35
35
|
readInitInfoFromEc2,
|
|
36
36
|
getDefaultName,
|
|
37
37
|
getDefaultDescription,
|
|
38
|
-
printInvalidModeInfo,
|
|
39
38
|
} = require('../../util');
|
|
40
39
|
const {
|
|
41
40
|
getBaseConfigDataDirectory,
|
|
@@ -195,7 +194,9 @@ exports.run = async ({
|
|
|
195
194
|
trustedPassportIssuer: defaultTrustedPassportIssuer,
|
|
196
195
|
webWalletUrl: defaultWebWalletUrl,
|
|
197
196
|
sk,
|
|
197
|
+
yes,
|
|
198
198
|
}) => {
|
|
199
|
+
const effectiveForce = force === true || yes === true;
|
|
199
200
|
const customSk = sk || process.env.ABT_NODE_SK;
|
|
200
201
|
const workingDir = process.cwd();
|
|
201
202
|
const baseConfigDirectory = getBaseConfigDataDirectory(workingDir);
|
|
@@ -221,7 +222,8 @@ exports.run = async ({
|
|
|
221
222
|
}
|
|
222
223
|
|
|
223
224
|
if (![NODE_MODES.PRODUCTION, NODE_MODES.DEBUG].includes(defaultMode)) {
|
|
224
|
-
|
|
225
|
+
printError('Invalid mode');
|
|
226
|
+
printInfo(`Valid mode should be "${NODE_MODES.PRODUCTION}" or "${NODE_MODES.DEBUG}"`);
|
|
225
227
|
process.exit(1);
|
|
226
228
|
}
|
|
227
229
|
|
|
@@ -237,7 +239,7 @@ exports.run = async ({
|
|
|
237
239
|
process.exit(1);
|
|
238
240
|
}
|
|
239
241
|
|
|
240
|
-
if (
|
|
242
|
+
if (effectiveForce !== true) {
|
|
241
243
|
const { confirmCreate } = await inquirer.prompt({
|
|
242
244
|
type: 'confirm',
|
|
243
245
|
name: 'confirmCreate',
|
|
@@ -268,7 +270,7 @@ exports.run = async ({
|
|
|
268
270
|
}
|
|
269
271
|
|
|
270
272
|
let interactiveCreate = interactive;
|
|
271
|
-
if (
|
|
273
|
+
if (effectiveForce === true) {
|
|
272
274
|
interactiveCreate = false;
|
|
273
275
|
}
|
|
274
276
|
|
package/lib/util/index.js
CHANGED
|
@@ -348,9 +348,10 @@ const readInitInfoFromEc2 = () => {
|
|
|
348
348
|
}
|
|
349
349
|
};
|
|
350
350
|
|
|
351
|
+
const getVersionInfo = () => `${getCLIBinaryName()} ${process.argv[2]} v${version}`;
|
|
352
|
+
|
|
351
353
|
const printVersionTip = () => {
|
|
352
|
-
|
|
353
|
-
print(chalk.bold(versionTip));
|
|
354
|
+
print(chalk.bold(getVersionInfo()));
|
|
354
355
|
debug(`Nodejs: ${process.version}`);
|
|
355
356
|
};
|
|
356
357
|
|
|
@@ -641,6 +642,7 @@ const lib = {
|
|
|
641
642
|
getDataDir,
|
|
642
643
|
getWallet: getNodeWallet,
|
|
643
644
|
readInitInfoFromEc2,
|
|
645
|
+
getVersionInfo,
|
|
644
646
|
printVersionTip,
|
|
645
647
|
printInvalidModeInfo,
|
|
646
648
|
getIpDescription,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blocklet/cli",
|
|
3
|
-
"version": "1.16.54-beta-
|
|
3
|
+
"version": "1.16.54-beta-20251024-030947-6f2889bf",
|
|
4
4
|
"description": "Command line tools to manage Blocklet Server",
|
|
5
5
|
"homepage": "https://www.arcblock.io/docs/blocklet-cli",
|
|
6
6
|
"bin": {
|
|
@@ -35,33 +35,33 @@
|
|
|
35
35
|
"url": "https://github.com/ArcBlock/blocklet-server/issues"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@abtnode/blocklet-services": "1.16.54-beta-
|
|
39
|
-
"@abtnode/constant": "1.16.54-beta-
|
|
40
|
-
"@abtnode/core": "1.16.54-beta-
|
|
41
|
-
"@abtnode/db-cache": "1.16.54-beta-
|
|
42
|
-
"@abtnode/logger": "1.16.54-beta-
|
|
43
|
-
"@abtnode/models": "1.16.54-beta-
|
|
44
|
-
"@abtnode/router-provider": "1.16.54-beta-
|
|
45
|
-
"@abtnode/util": "1.16.54-beta-
|
|
46
|
-
"@abtnode/webapp": "1.16.54-beta-
|
|
47
|
-
"@arcblock/did": "^1.26.
|
|
48
|
-
"@arcblock/event-hub": "^1.26.
|
|
38
|
+
"@abtnode/blocklet-services": "1.16.54-beta-20251024-030947-6f2889bf",
|
|
39
|
+
"@abtnode/constant": "1.16.54-beta-20251024-030947-6f2889bf",
|
|
40
|
+
"@abtnode/core": "1.16.54-beta-20251024-030947-6f2889bf",
|
|
41
|
+
"@abtnode/db-cache": "1.16.54-beta-20251024-030947-6f2889bf",
|
|
42
|
+
"@abtnode/logger": "1.16.54-beta-20251024-030947-6f2889bf",
|
|
43
|
+
"@abtnode/models": "1.16.54-beta-20251024-030947-6f2889bf",
|
|
44
|
+
"@abtnode/router-provider": "1.16.54-beta-20251024-030947-6f2889bf",
|
|
45
|
+
"@abtnode/util": "1.16.54-beta-20251024-030947-6f2889bf",
|
|
46
|
+
"@abtnode/webapp": "1.16.54-beta-20251024-030947-6f2889bf",
|
|
47
|
+
"@arcblock/did": "^1.26.3",
|
|
48
|
+
"@arcblock/event-hub": "^1.26.3",
|
|
49
49
|
"@arcblock/ipfs-only-hash": "^0.0.2",
|
|
50
|
-
"@arcblock/jwt": "^1.26.
|
|
51
|
-
"@arcblock/ws": "^1.26.
|
|
52
|
-
"@blocklet/constant": "1.16.54-beta-
|
|
50
|
+
"@arcblock/jwt": "^1.26.3",
|
|
51
|
+
"@arcblock/ws": "^1.26.3",
|
|
52
|
+
"@blocklet/constant": "1.16.54-beta-20251024-030947-6f2889bf",
|
|
53
53
|
"@blocklet/error": "^0.2.5",
|
|
54
54
|
"@blocklet/form-collector": "^0.1.8",
|
|
55
|
-
"@blocklet/images": "1.16.54-beta-
|
|
56
|
-
"@blocklet/meta": "1.16.54-beta-
|
|
57
|
-
"@blocklet/resolver": "1.16.54-beta-
|
|
58
|
-
"@blocklet/server-js": "1.16.54-beta-
|
|
59
|
-
"@blocklet/store": "1.16.54-beta-
|
|
55
|
+
"@blocklet/images": "1.16.54-beta-20251024-030947-6f2889bf",
|
|
56
|
+
"@blocklet/meta": "1.16.54-beta-20251024-030947-6f2889bf",
|
|
57
|
+
"@blocklet/resolver": "1.16.54-beta-20251024-030947-6f2889bf",
|
|
58
|
+
"@blocklet/server-js": "1.16.54-beta-20251024-030947-6f2889bf",
|
|
59
|
+
"@blocklet/store": "1.16.54-beta-20251024-030947-6f2889bf",
|
|
60
60
|
"@blocklet/theme-builder": "^0.4.7",
|
|
61
|
-
"@ocap/client": "^1.26.
|
|
62
|
-
"@ocap/mcrypto": "^1.26.
|
|
63
|
-
"@ocap/util": "^1.26.
|
|
64
|
-
"@ocap/wallet": "^1.26.
|
|
61
|
+
"@ocap/client": "^1.26.3",
|
|
62
|
+
"@ocap/mcrypto": "^1.26.3",
|
|
63
|
+
"@ocap/util": "^1.26.3",
|
|
64
|
+
"@ocap/wallet": "^1.26.3",
|
|
65
65
|
"@vercel/ncc": "^0.38.3",
|
|
66
66
|
"archiver": "^7.0.1",
|
|
67
67
|
"async": "^3.2.4",
|
|
@@ -137,6 +137,7 @@
|
|
|
137
137
|
"source-map": "^0.7.4",
|
|
138
138
|
"sqlite3": "^5.1.7",
|
|
139
139
|
"ssri": "^8.0.1",
|
|
140
|
+
"strip-ansi": "6.0.1",
|
|
140
141
|
"tar": "^6.1.11",
|
|
141
142
|
"terminal-link": "^2.1.1",
|
|
142
143
|
"tweetnacl": "^1.0.3",
|
|
@@ -154,7 +155,7 @@
|
|
|
154
155
|
"engines": {
|
|
155
156
|
"node": ">=14"
|
|
156
157
|
},
|
|
157
|
-
"gitHead": "
|
|
158
|
+
"gitHead": "73e5a3a80b82a2a7c62d42fdc08207b28e67633e",
|
|
158
159
|
"devDependencies": {
|
|
159
160
|
"@types/fs-extra": "^11.0.4",
|
|
160
161
|
"@types/jest": "^29.5.13"
|