@blocklet/cli 1.8.61 → 1.8.63-beta-c51e554d
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/bin/blocklet.js +1 -7
- package/lib/constant.js +5 -0
- package/lib/run.d.ts +2 -0
- package/lib/run.js +72 -0
- package/package.json +21 -5
package/bin/blocklet.js
CHANGED
|
@@ -1,9 +1,3 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
process.env.ABT_NODE_MAX_CLUSTER_SIZE = Math.min(Math.max(Number(process.env.ABT_NODE_MAX_CLUSTER_SIZE) || 32, 1), 32);
|
|
6
|
-
|
|
7
|
-
process.env.ABT_NODE_PACKAGE_NAME = name;
|
|
8
|
-
|
|
9
|
-
require('@abtnode/cli/bin/blocklet');
|
|
3
|
+
require('../lib/run')();
|
package/lib/constant.js
ADDED
package/lib/run.d.ts
ADDED
package/lib/run.js
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* eslint-disable global-require */
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
+
}) : function(o, v) {
|
|
17
|
+
o["default"] = v;
|
|
18
|
+
});
|
|
19
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
20
|
+
if (mod && mod.__esModule) return mod;
|
|
21
|
+
var result = {};
|
|
22
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
23
|
+
__setModuleDefault(result, mod);
|
|
24
|
+
return result;
|
|
25
|
+
};
|
|
26
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
27
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
28
|
+
};
|
|
29
|
+
const constant_1 = require("@abtnode/cli/lib/constant");
|
|
30
|
+
// !!! PM_HOME must be set before everything
|
|
31
|
+
process.env.PM2_HOME = constant_1.PM2_HOME;
|
|
32
|
+
process.env.ABT_NODE_HOME = constant_1.ABT_NODE_HOME;
|
|
33
|
+
process.env.ABT_NODE_MAX_CLUSTER_SIZE = constant_1.ABT_NODE_MAX_CLUSTER_SIZE;
|
|
34
|
+
const cross_spawn_1 = __importDefault(require("cross-spawn"));
|
|
35
|
+
const get_cli_binary_name_1 = __importDefault(require("@abtnode/cli/lib/util/get-cli-binary-name"));
|
|
36
|
+
const exit_when_server_stopped_1 = __importDefault(require("@abtnode/cli/lib/util/exit-when-server-stopped"));
|
|
37
|
+
const print_error_1 = __importDefault(require("@abtnode/cli/lib/util/print-error"));
|
|
38
|
+
const constant_2 = require("./constant");
|
|
39
|
+
const keepAliveParams = ['--keep-alive', '-k'];
|
|
40
|
+
const parseArgv = () => {
|
|
41
|
+
const binaryName = (0, get_cli_binary_name_1.default)();
|
|
42
|
+
const isServer = process.argv[2] === 'server';
|
|
43
|
+
const isStart = process.argv[3] === 'start';
|
|
44
|
+
const keepAlive = keepAliveParams.some((x) => process.argv.includes(x));
|
|
45
|
+
return { binaryName, isServer, isStart, keepAlive };
|
|
46
|
+
};
|
|
47
|
+
module.exports = () => {
|
|
48
|
+
process.env.ABT_NODE_PACKAGE_NAME = constant_2.name;
|
|
49
|
+
const { binaryName, isServer, isStart, keepAlive } = parseArgv();
|
|
50
|
+
if (isServer && isStart && keepAlive) {
|
|
51
|
+
const argv = process.argv.slice(4).filter((x) => !keepAliveParams.includes(x));
|
|
52
|
+
const { error, status } = cross_spawn_1.default.sync(binaryName, ['server', 'start', ...argv], {
|
|
53
|
+
timeout: 3 * 60 * 1000,
|
|
54
|
+
detached: false,
|
|
55
|
+
shell: false,
|
|
56
|
+
stdio: 'inherit',
|
|
57
|
+
});
|
|
58
|
+
if (error) {
|
|
59
|
+
(0, print_error_1.default)(error.message);
|
|
60
|
+
process.exit(error.errno || -1);
|
|
61
|
+
return; // just for test
|
|
62
|
+
}
|
|
63
|
+
if (status !== 0) {
|
|
64
|
+
process.exit(status);
|
|
65
|
+
return; // just for test
|
|
66
|
+
}
|
|
67
|
+
(0, exit_when_server_stopped_1.default)();
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
Promise.resolve().then(() => __importStar(require('@abtnode/cli/bin/blocklet')));
|
|
71
|
+
}
|
|
72
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blocklet/cli",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.63-beta-c51e554d",
|
|
4
4
|
"description": "Command line tools to manage Blocklet and Blocklet Server",
|
|
5
5
|
"homepage": "https://github.com/ArcBlock/blocklet-server#readme",
|
|
6
6
|
"main": "bin/blocklet.js",
|
|
@@ -12,10 +12,15 @@
|
|
|
12
12
|
},
|
|
13
13
|
"scripts": {
|
|
14
14
|
"lint": "eslint bin",
|
|
15
|
-
"lint:fix": "eslint bin --fix"
|
|
15
|
+
"lint:fix": "eslint bin --fix",
|
|
16
|
+
"test": "node tools/jest.js",
|
|
17
|
+
"coverage": "npm run test -- --coverage",
|
|
18
|
+
"clean": "rm -fr lib",
|
|
19
|
+
"build": "npm run clean && tsc && cp src/constant.js lib"
|
|
16
20
|
},
|
|
17
21
|
"files": [
|
|
18
|
-
"bin"
|
|
22
|
+
"bin",
|
|
23
|
+
"lib"
|
|
19
24
|
],
|
|
20
25
|
"author": {
|
|
21
26
|
"name": "wangshijun",
|
|
@@ -31,15 +36,26 @@
|
|
|
31
36
|
"url": "https://github.com/ArcBlock/blocklet-server/issues"
|
|
32
37
|
},
|
|
33
38
|
"dependencies": {
|
|
34
|
-
"@abtnode/cli": "1.8.
|
|
39
|
+
"@abtnode/cli": "1.8.63-beta-c51e554d",
|
|
35
40
|
"colors": "1.4.0",
|
|
41
|
+
"cross-spawn": "^7.0.3",
|
|
36
42
|
"shelljs": "^0.8.5"
|
|
37
43
|
},
|
|
44
|
+
"devDependencies": {
|
|
45
|
+
"@types/jest": "^29.2.2",
|
|
46
|
+
"@types/joi": "^17.2.3",
|
|
47
|
+
"@typescript-eslint/eslint-plugin": "^5.42.0",
|
|
48
|
+
"@typescript-eslint/parser": "^5.42.0",
|
|
49
|
+
"jest": "^29.3.0",
|
|
50
|
+
"ts-jest": "^29.0.3",
|
|
51
|
+
"ts-node": "^10.9.1",
|
|
52
|
+
"typescript": "^4.8.4"
|
|
53
|
+
},
|
|
38
54
|
"resolutions": {
|
|
39
55
|
"colors": "1.4.0"
|
|
40
56
|
},
|
|
41
57
|
"engines": {
|
|
42
58
|
"node": ">=12"
|
|
43
59
|
},
|
|
44
|
-
"gitHead": "
|
|
60
|
+
"gitHead": "9913ed7968dfab63d6549201a5a98f9819fcfac6"
|
|
45
61
|
}
|