@tramvai/cli 2.148.0 → 2.148.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.
- package/README.md +3 -3
- package/lib/api/build/providers/shared.js +4 -3
- package/lib/api/build/providers/shared.js.map +1 -1
- package/lib/api/start/application.js.map +1 -1
- package/lib/api/start/index.js +5 -2
- package/lib/api/start/index.js.map +1 -1
- package/lib/api/start/providers/application/shared.js +2 -5
- package/lib/api/start/providers/application/shared.js.map +1 -1
- package/lib/api/start/providers/child-app/shared.js +2 -2
- package/lib/api/start/providers/child-app/shared.js.map +1 -1
- package/lib/api/start/providers/module/shared.js +2 -2
- package/lib/api/start/providers/module/shared.js.map +1 -1
- package/lib/api/start/utils/createServer.d.ts +1 -1
- package/lib/api/start-prod/application.js +2 -0
- package/lib/api/start-prod/application.js.map +1 -1
- package/lib/api/start-prod/index.js +5 -2
- package/lib/api/start-prod/index.js.map +1 -1
- package/lib/api/start-prod/providers/application.js +2 -5
- package/lib/api/start-prod/providers/application.js.map +1 -1
- package/lib/api/start-prod/providers/child-app.js +2 -5
- package/lib/api/start-prod/providers/child-app.js.map +1 -1
- package/lib/commands/createApp.js +1 -0
- package/lib/commands/createApp.js.map +1 -1
- package/lib/commands/static/application.js +4 -1
- package/lib/commands/static/application.js.map +1 -1
- package/lib/config/configManager.d.ts +0 -3
- package/lib/config/configManager.js +5 -5
- package/lib/config/configManager.js.map +1 -1
- package/lib/di/providers/config.js +1 -1
- package/lib/di/providers/config.js.map +1 -1
- package/lib/di/providers/index.d.ts +1 -0
- package/lib/di/providers/index.js +1 -0
- package/lib/di/providers/index.js.map +1 -1
- package/lib/di/providers/network.d.ts +2 -0
- package/lib/di/providers/network.js +17 -0
- package/lib/di/providers/network.js.map +1 -0
- package/lib/di/tokens/index.d.ts +1 -0
- package/lib/di/tokens/index.js +1 -0
- package/lib/di/tokens/index.js.map +1 -1
- package/lib/di/tokens/network.d.ts +4 -0
- package/lib/di/tokens/network.js +6 -0
- package/lib/di/tokens/network.js.map +1 -0
- package/lib/di/tokens/server.d.ts +2 -2
- package/lib/library/webpack/constants/stats.d.ts +1 -1
- package/lib/library/webpack/utils/threadLoader.js +1 -1
- package/lib/library/webpack/utils/threadLoader.js.map +1 -1
- package/lib/models/port-manager.d.ts +30 -0
- package/lib/models/port-manager.js +72 -0
- package/lib/models/port-manager.js.map +1 -0
- package/lib/schema/autogeneratedSchema.json +15 -15
- package/lib/utils/detectPortSync.d.ts +0 -13
- package/lib/utils/detectPortSync.js +0 -21
- package/lib/utils/detectPortSync.js.map +1 -1
- package/package.json +2 -3
- package/schema.json +15 -15
- package/src/api/build/providers/shared.ts +5 -11
- package/src/api/start/__integration__/start.test.ts +3 -3
- package/src/api/start/application.ts +1 -0
- package/src/api/start/index.ts +5 -2
- package/src/api/start/providers/application/shared.ts +6 -12
- package/src/api/start/providers/child-app/shared.ts +5 -4
- package/src/api/start/providers/module/shared.ts +5 -4
- package/src/api/start-prod/application.ts +5 -1
- package/src/api/start-prod/index.ts +5 -2
- package/src/api/start-prod/providers/application.ts +8 -16
- package/src/api/start-prod/providers/child-app.ts +6 -7
- package/src/commands/createApp.ts +2 -0
- package/src/commands/static/application.ts +7 -0
- package/src/config/configManager.ts +6 -5
- package/src/di/providers/config.ts +1 -1
- package/src/di/providers/index.ts +1 -0
- package/src/di/providers/network.ts +16 -0
- package/src/di/tokens/index.ts +1 -0
- package/src/di/tokens/network.ts +5 -0
- package/src/library/webpack/utils/threadLoader.ts +1 -1
- package/src/models/port-manager.ts +79 -0
- package/src/schema/autogeneratedSchema.json +15 -15
- package/src/utils/detectPortSync.ts +0 -24
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"threadLoader.js","sourceRoot":"","sources":["../../../../src/library/webpack/utils/threadLoader.ts"],"names":[],"mappings":";;;;AAAA,oEAA8C;AAC9C,gEAAyD;AAKzD,MAAM,eAAe,GAAG,CAAC,aAA4C,EAAO,EAAE;IAC5E,MAAM,EAA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K1B"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { ConfigEntry } from '../typings/configEntry/common';
|
|
2
|
+
import type { Params as StartParams } from '../api/start';
|
|
3
|
+
import type { Params as StartProdParams } from '../api/start-prod';
|
|
4
|
+
interface NetworkConstructorPayload {
|
|
5
|
+
configEntry: ConfigEntry;
|
|
6
|
+
commandParams: StartParams | StartProdParams;
|
|
7
|
+
}
|
|
8
|
+
export declare class PortManager {
|
|
9
|
+
static DEFAULT_PORT: number;
|
|
10
|
+
static DEFAULT_MODULE_PORT: number;
|
|
11
|
+
static DEFAULT_STATIC_PORT: number;
|
|
12
|
+
static DEFAULT_MODULE_STATIC_PORT: number;
|
|
13
|
+
private configEntry;
|
|
14
|
+
private commandParams;
|
|
15
|
+
port: number | null;
|
|
16
|
+
staticPort: number | null;
|
|
17
|
+
constructor({ configEntry, commandParams }: NetworkConstructorPayload);
|
|
18
|
+
/**
|
|
19
|
+
* Try to detect port considering the fact, that if user requests
|
|
20
|
+
* a port explicitly, we should not try to detect a free one.
|
|
21
|
+
*
|
|
22
|
+
* Also, handle zero port (it means any random port) as the edge case,
|
|
23
|
+
* because we must pass a final number to the config manager.
|
|
24
|
+
*/
|
|
25
|
+
computeAvailablePorts(): Promise<void>;
|
|
26
|
+
private forApplication;
|
|
27
|
+
private forModule;
|
|
28
|
+
private forChildApp;
|
|
29
|
+
}
|
|
30
|
+
export {};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PortManager = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const detect_port_1 = tslib_1.__importDefault(require("detect-port"));
|
|
6
|
+
class PortManager {
|
|
7
|
+
constructor({ configEntry, commandParams }) {
|
|
8
|
+
this.port = null;
|
|
9
|
+
this.staticPort = null;
|
|
10
|
+
this.configEntry = configEntry;
|
|
11
|
+
this.commandParams = commandParams;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Try to detect port considering the fact, that if user requests
|
|
15
|
+
* a port explicitly, we should not try to detect a free one.
|
|
16
|
+
*
|
|
17
|
+
* Also, handle zero port (it means any random port) as the edge case,
|
|
18
|
+
* because we must pass a final number to the config manager.
|
|
19
|
+
*/
|
|
20
|
+
computeAvailablePorts() {
|
|
21
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
22
|
+
if (this.commandParams.port !== undefined && this.commandParams.port !== 0) {
|
|
23
|
+
// @ts-expect-error There is a string actually
|
|
24
|
+
this.port = parseInt(this.commandParams.port, 10);
|
|
25
|
+
}
|
|
26
|
+
if (this.commandParams.staticPort !== undefined && this.commandParams.staticPort !== 0) {
|
|
27
|
+
// @ts-expect-error There is a string actually
|
|
28
|
+
this.staticPort = parseInt(this.commandParams.staticPort, 10);
|
|
29
|
+
}
|
|
30
|
+
switch (this.configEntry.type) {
|
|
31
|
+
case 'child-app':
|
|
32
|
+
yield this.forChildApp();
|
|
33
|
+
break;
|
|
34
|
+
case 'module':
|
|
35
|
+
yield this.forModule();
|
|
36
|
+
break;
|
|
37
|
+
case 'application':
|
|
38
|
+
yield this.forApplication();
|
|
39
|
+
break;
|
|
40
|
+
default:
|
|
41
|
+
break;
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
forApplication() {
|
|
46
|
+
var _a, _b;
|
|
47
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
48
|
+
this.port = (_a = this.port) !== null && _a !== void 0 ? _a : (yield (0, detect_port_1.default)(PortManager.DEFAULT_PORT));
|
|
49
|
+
this.staticPort = (_b = this.staticPort) !== null && _b !== void 0 ? _b : (yield (0, detect_port_1.default)(PortManager.DEFAULT_STATIC_PORT));
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
forModule() {
|
|
53
|
+
var _a, _b;
|
|
54
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
55
|
+
this.port = (_a = this.port) !== null && _a !== void 0 ? _a : (yield (0, detect_port_1.default)(PortManager.DEFAULT_MODULE_PORT));
|
|
56
|
+
this.staticPort = (_b = this.staticPort) !== null && _b !== void 0 ? _b : (yield (0, detect_port_1.default)(PortManager.DEFAULT_MODULE_STATIC_PORT));
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
forChildApp() {
|
|
60
|
+
var _a, _b;
|
|
61
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
62
|
+
this.port = (_a = this.port) !== null && _a !== void 0 ? _a : (yield (0, detect_port_1.default)(PortManager.DEFAULT_MODULE_PORT));
|
|
63
|
+
this.staticPort = (_b = this.staticPort) !== null && _b !== void 0 ? _b : (yield (0, detect_port_1.default)(PortManager.DEFAULT_MODULE_STATIC_PORT));
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
exports.PortManager = PortManager;
|
|
68
|
+
PortManager.DEFAULT_PORT = 3000;
|
|
69
|
+
PortManager.DEFAULT_MODULE_PORT = 4040;
|
|
70
|
+
PortManager.DEFAULT_STATIC_PORT = 4000;
|
|
71
|
+
PortManager.DEFAULT_MODULE_STATIC_PORT = 4040;
|
|
72
|
+
//# sourceMappingURL=port-manager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"port-manager.js","sourceRoot":"","sources":["../../src/models/port-manager.ts"],"names":[],"mappings":";;;;AAAA,sEAAqC;AAWrC,MAAa,WAAW;IAYtB,YAAY,EAAE,WAAW,EAAE,aAAa,EAA6B;QAH9D,SAAI,GAAkB,IAAI,CAAC;QAC3B,eAAU,GAAkB,IAAI,CAAC;QAGtC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;IACrC,CAAC;IAED;;;;;;OAMG;IACU,qBAAqB;;YAChC,IAAI,IAAI,CAAC,aAAa,CAAC,IAAI,KAAK,SAAS,IAAI,IAAI,CAA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W,CAAC,0BAA0B,CAAC,CAAC,CAAC;;KACjG;IAEa,WAAW;;;YACvB,IAAI,CAAC,IAAI,GAAG,MAAA,IAAI,CAAC,IAAI,mCAAI,CAAC,MAAM,IAAA,qBAAU,EAAC,WAAW,CAAC,mBAAmB,CAAC,CAAC,CAAC;YAC7E,IAAI,CAAC,UAAU,GAAG,MAAA,IAAI,CAAC,UAAU,mCAAI,CAAC,MAAM,IAAA,qBAAU,EAAC,WAAW,CAAC,0BAA0B,CAAC,CAAC,CAAC;;KACjG;;AAlEH,kCAmEC;AAlEQ,wBAAY,GAAG,IAAI,CAAC;AACpB,+BAAmB,GAAG,IAAI,CAAC;AAC3B,+BAAmB,GAAG,IAAI,CAAC;AAC3B,sCAA0B,GAAG,IAAI,CAAC"}
|
|
@@ -1141,23 +1141,23 @@
|
|
|
1141
1141
|
"dotAll": {
|
|
1142
1142
|
"type": "boolean"
|
|
1143
1143
|
},
|
|
1144
|
-
"__@match@
|
|
1144
|
+
"__@match@8264": {
|
|
1145
1145
|
"type": "object",
|
|
1146
1146
|
"additionalProperties": false
|
|
1147
1147
|
},
|
|
1148
|
-
"__@replace@
|
|
1148
|
+
"__@replace@8266": {
|
|
1149
1149
|
"type": "object",
|
|
1150
1150
|
"additionalProperties": false
|
|
1151
1151
|
},
|
|
1152
|
-
"__@search@
|
|
1152
|
+
"__@search@8269": {
|
|
1153
1153
|
"type": "object",
|
|
1154
1154
|
"additionalProperties": false
|
|
1155
1155
|
},
|
|
1156
|
-
"__@split@
|
|
1156
|
+
"__@split@8271": {
|
|
1157
1157
|
"type": "object",
|
|
1158
1158
|
"additionalProperties": false
|
|
1159
1159
|
},
|
|
1160
|
-
"__@matchAll@
|
|
1160
|
+
"__@matchAll@8273": {
|
|
1161
1161
|
"type": "object",
|
|
1162
1162
|
"additionalProperties": false
|
|
1163
1163
|
}
|
|
@@ -1802,23 +1802,23 @@
|
|
|
1802
1802
|
"dotAll": {
|
|
1803
1803
|
"type": "boolean"
|
|
1804
1804
|
},
|
|
1805
|
-
"__@match@
|
|
1805
|
+
"__@match@8264": {
|
|
1806
1806
|
"type": "object",
|
|
1807
1807
|
"additionalProperties": false
|
|
1808
1808
|
},
|
|
1809
|
-
"__@replace@
|
|
1809
|
+
"__@replace@8266": {
|
|
1810
1810
|
"type": "object",
|
|
1811
1811
|
"additionalProperties": false
|
|
1812
1812
|
},
|
|
1813
|
-
"__@search@
|
|
1813
|
+
"__@search@8269": {
|
|
1814
1814
|
"type": "object",
|
|
1815
1815
|
"additionalProperties": false
|
|
1816
1816
|
},
|
|
1817
|
-
"__@split@
|
|
1817
|
+
"__@split@8271": {
|
|
1818
1818
|
"type": "object",
|
|
1819
1819
|
"additionalProperties": false
|
|
1820
1820
|
},
|
|
1821
|
-
"__@matchAll@
|
|
1821
|
+
"__@matchAll@8273": {
|
|
1822
1822
|
"type": "object",
|
|
1823
1823
|
"additionalProperties": false
|
|
1824
1824
|
}
|
|
@@ -2463,23 +2463,23 @@
|
|
|
2463
2463
|
"dotAll": {
|
|
2464
2464
|
"type": "boolean"
|
|
2465
2465
|
},
|
|
2466
|
-
"__@match@
|
|
2466
|
+
"__@match@8264": {
|
|
2467
2467
|
"type": "object",
|
|
2468
2468
|
"additionalProperties": false
|
|
2469
2469
|
},
|
|
2470
|
-
"__@replace@
|
|
2470
|
+
"__@replace@8266": {
|
|
2471
2471
|
"type": "object",
|
|
2472
2472
|
"additionalProperties": false
|
|
2473
2473
|
},
|
|
2474
|
-
"__@search@
|
|
2474
|
+
"__@search@8269": {
|
|
2475
2475
|
"type": "object",
|
|
2476
2476
|
"additionalProperties": false
|
|
2477
2477
|
},
|
|
2478
|
-
"__@split@
|
|
2478
|
+
"__@split@8271": {
|
|
2479
2479
|
"type": "object",
|
|
2480
2480
|
"additionalProperties": false
|
|
2481
2481
|
},
|
|
2482
|
-
"__@matchAll@
|
|
2482
|
+
"__@matchAll@8273": {
|
|
2483
2483
|
"type": "object",
|
|
2484
2484
|
"additionalProperties": false
|
|
2485
2485
|
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
interface Payload {
|
|
2
|
-
request?: number;
|
|
3
|
-
fallback: number;
|
|
4
|
-
}
|
|
5
|
-
/**
|
|
6
|
-
* Try to detect port synchronously considering the fact, that if user requests
|
|
7
|
-
* a port explicitly, we should not try to detect a free one.
|
|
8
|
-
*
|
|
9
|
-
* Also, handle zero port (it means any random port) as the edge case,
|
|
10
|
-
* because we must pass a final number to the config manager.
|
|
11
|
-
*/
|
|
12
|
-
export declare const detectPortSync: ({ request, fallback }: Payload) => number;
|
|
13
|
-
export {};
|
|
@@ -1,22 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.detectPortSync = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const child_process_1 = require("child_process");
|
|
6
|
-
const strip_ansi_1 = tslib_1.__importDefault(require("strip-ansi"));
|
|
7
|
-
/**
|
|
8
|
-
* Try to detect port synchronously considering the fact, that if user requests
|
|
9
|
-
* a port explicitly, we should not try to detect a free one.
|
|
10
|
-
*
|
|
11
|
-
* Also, handle zero port (it means any random port) as the edge case,
|
|
12
|
-
* because we must pass a final number to the config manager.
|
|
13
|
-
*/
|
|
14
|
-
const detectPortSync = ({ request, fallback }) => {
|
|
15
|
-
if (request !== undefined && request !== 0) {
|
|
16
|
-
return request;
|
|
17
|
-
}
|
|
18
|
-
const commandResult = (0, child_process_1.execSync)(`npx detect-port ${request !== null && request !== void 0 ? request : fallback}`, { encoding: 'utf-8' });
|
|
19
|
-
return parseInt((0, strip_ansi_1.default)(commandResult.toString()), 10);
|
|
20
|
-
};
|
|
21
|
-
exports.detectPortSync = detectPortSync;
|
|
22
1
|
//# sourceMappingURL=detectPortSync.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"detectPortSync.js","sourceRoot":"","sources":["../../src/utils/detectPortSync.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"detectPortSync.js","sourceRoot":"","sources":["../../src/utils/detectPortSync.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tramvai/cli",
|
|
3
|
-
"version": "2.148.
|
|
3
|
+
"version": "2.148.1",
|
|
4
4
|
"description": "Cli инструмент для сборки и запуска приложений",
|
|
5
5
|
"files": [
|
|
6
6
|
"src",
|
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
"@tinkoff/utils": "^2.1.3",
|
|
72
72
|
"@tinkoff/webpack-dedupe-plugin": "1.0.5",
|
|
73
73
|
"@tramvai/build": "3.1.4",
|
|
74
|
-
"@tramvai/react": "2.148.
|
|
74
|
+
"@tramvai/react": "2.148.1",
|
|
75
75
|
"@tramvai/tools-check-versions": "0.4.18",
|
|
76
76
|
"@tramvai/tools-migrate": "0.6.22",
|
|
77
77
|
"ajv": "^8.12.0",
|
|
@@ -146,7 +146,6 @@
|
|
|
146
146
|
"source-map": "^0.7.4",
|
|
147
147
|
"source-map-loader": "^4.0.0",
|
|
148
148
|
"spark-md5": "^3.0.2",
|
|
149
|
-
"strip-ansi": "^6.0.0",
|
|
150
149
|
"stoppable": "^1.1.0",
|
|
151
150
|
"svgo": "^3.0.2",
|
|
152
151
|
"svgo-loader": "^4.0.0",
|
package/schema.json
CHANGED
|
@@ -1163,23 +1163,23 @@
|
|
|
1163
1163
|
"dotAll": {
|
|
1164
1164
|
"type": "boolean"
|
|
1165
1165
|
},
|
|
1166
|
-
"__@match@
|
|
1166
|
+
"__@match@8264": {
|
|
1167
1167
|
"type": "object",
|
|
1168
1168
|
"additionalProperties": false
|
|
1169
1169
|
},
|
|
1170
|
-
"__@replace@
|
|
1170
|
+
"__@replace@8266": {
|
|
1171
1171
|
"type": "object",
|
|
1172
1172
|
"additionalProperties": false
|
|
1173
1173
|
},
|
|
1174
|
-
"__@search@
|
|
1174
|
+
"__@search@8269": {
|
|
1175
1175
|
"type": "object",
|
|
1176
1176
|
"additionalProperties": false
|
|
1177
1177
|
},
|
|
1178
|
-
"__@split@
|
|
1178
|
+
"__@split@8271": {
|
|
1179
1179
|
"type": "object",
|
|
1180
1180
|
"additionalProperties": false
|
|
1181
1181
|
},
|
|
1182
|
-
"__@matchAll@
|
|
1182
|
+
"__@matchAll@8273": {
|
|
1183
1183
|
"type": "object",
|
|
1184
1184
|
"additionalProperties": false
|
|
1185
1185
|
}
|
|
@@ -1833,23 +1833,23 @@
|
|
|
1833
1833
|
"dotAll": {
|
|
1834
1834
|
"type": "boolean"
|
|
1835
1835
|
},
|
|
1836
|
-
"__@match@
|
|
1836
|
+
"__@match@8264": {
|
|
1837
1837
|
"type": "object",
|
|
1838
1838
|
"additionalProperties": false
|
|
1839
1839
|
},
|
|
1840
|
-
"__@replace@
|
|
1840
|
+
"__@replace@8266": {
|
|
1841
1841
|
"type": "object",
|
|
1842
1842
|
"additionalProperties": false
|
|
1843
1843
|
},
|
|
1844
|
-
"__@search@
|
|
1844
|
+
"__@search@8269": {
|
|
1845
1845
|
"type": "object",
|
|
1846
1846
|
"additionalProperties": false
|
|
1847
1847
|
},
|
|
1848
|
-
"__@split@
|
|
1848
|
+
"__@split@8271": {
|
|
1849
1849
|
"type": "object",
|
|
1850
1850
|
"additionalProperties": false
|
|
1851
1851
|
},
|
|
1852
|
-
"__@matchAll@
|
|
1852
|
+
"__@matchAll@8273": {
|
|
1853
1853
|
"type": "object",
|
|
1854
1854
|
"additionalProperties": false
|
|
1855
1855
|
}
|
|
@@ -2503,23 +2503,23 @@
|
|
|
2503
2503
|
"dotAll": {
|
|
2504
2504
|
"type": "boolean"
|
|
2505
2505
|
},
|
|
2506
|
-
"__@match@
|
|
2506
|
+
"__@match@8264": {
|
|
2507
2507
|
"type": "object",
|
|
2508
2508
|
"additionalProperties": false
|
|
2509
2509
|
},
|
|
2510
|
-
"__@replace@
|
|
2510
|
+
"__@replace@8266": {
|
|
2511
2511
|
"type": "object",
|
|
2512
2512
|
"additionalProperties": false
|
|
2513
2513
|
},
|
|
2514
|
-
"__@search@
|
|
2514
|
+
"__@search@8269": {
|
|
2515
2515
|
"type": "object",
|
|
2516
2516
|
"additionalProperties": false
|
|
2517
2517
|
},
|
|
2518
|
-
"__@split@
|
|
2518
|
+
"__@split@8271": {
|
|
2519
2519
|
"type": "object",
|
|
2520
2520
|
"additionalProperties": false
|
|
2521
2521
|
},
|
|
2522
|
-
"__@matchAll@
|
|
2522
|
+
"__@matchAll@8273": {
|
|
2523
2523
|
"type": "object",
|
|
2524
2524
|
"additionalProperties": false
|
|
2525
2525
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { provide } from '@tinkoff/dippy';
|
|
1
2
|
import type { Provider } from '@tinkoff/dippy';
|
|
2
3
|
import {
|
|
3
4
|
CONFIG_MANAGER_TOKEN,
|
|
@@ -6,19 +7,12 @@ import {
|
|
|
6
7
|
} from '../../../di/tokens';
|
|
7
8
|
import { createConfigManager } from '../../../config/configManager';
|
|
8
9
|
import type { ApplicationConfigEntry } from '../../../typings/configEntry/application';
|
|
9
|
-
import type { Params } from '../index';
|
|
10
10
|
|
|
11
11
|
export const sharedProviders: readonly Provider[] = [
|
|
12
|
-
{
|
|
12
|
+
provide({
|
|
13
13
|
provide: CONFIG_MANAGER_TOKEN,
|
|
14
|
-
useFactory: ({
|
|
15
|
-
configEntry,
|
|
16
|
-
parameters,
|
|
17
|
-
}: {
|
|
18
|
-
configEntry: ApplicationConfigEntry;
|
|
19
|
-
parameters: Params;
|
|
20
|
-
}) => {
|
|
21
|
-
return createConfigManager(configEntry, {
|
|
14
|
+
useFactory: ({ configEntry, parameters }) => {
|
|
15
|
+
return createConfigManager(configEntry as ApplicationConfigEntry, {
|
|
22
16
|
...parameters,
|
|
23
17
|
appEnv: parameters.env,
|
|
24
18
|
env: 'production',
|
|
@@ -29,5 +23,5 @@ export const sharedProviders: readonly Provider[] = [
|
|
|
29
23
|
configEntry: CONFIG_ENTRY_TOKEN,
|
|
30
24
|
parameters: COMMAND_PARAMETERS_TOKEN,
|
|
31
25
|
},
|
|
32
|
-
},
|
|
26
|
+
}),
|
|
33
27
|
];
|
|
@@ -10,7 +10,7 @@ import { createServer } from '../utils/createServer';
|
|
|
10
10
|
import { listenServer } from '../utils/listenServer';
|
|
11
11
|
import { getListeningPort } from '../utils/getListeningPort';
|
|
12
12
|
import { stopServer } from '../utils/stopServer';
|
|
13
|
-
import {
|
|
13
|
+
import { PortManager } from '../../../models/port-manager';
|
|
14
14
|
|
|
15
15
|
const FIXTURES_DIR = resolve(__dirname, '__fixtures__');
|
|
16
16
|
|
|
@@ -290,8 +290,8 @@ describe('@tramvai/cli start command', () => {
|
|
|
290
290
|
const testServerStub = createServer();
|
|
291
291
|
const testStaticServerStub = createServer();
|
|
292
292
|
|
|
293
|
-
await listenServer(testServerStub, '0.0.0.0', DEFAULT_PORT);
|
|
294
|
-
await listenServer(testStaticServerStub, '0.0.0.0', DEFAULT_STATIC_PORT);
|
|
293
|
+
await listenServer(testServerStub, '0.0.0.0', PortManager.DEFAULT_PORT);
|
|
294
|
+
await listenServer(testStaticServerStub, '0.0.0.0', PortManager.DEFAULT_STATIC_PORT);
|
|
295
295
|
|
|
296
296
|
const { server, staticServer, close } = await start({
|
|
297
297
|
rootDir: FIXTURES_DIR,
|
|
@@ -21,6 +21,7 @@ import { registerProviders } from '../../utils/di';
|
|
|
21
21
|
|
|
22
22
|
export const startApplication = async (di: Container): Result => {
|
|
23
23
|
const options = di.get(COMMAND_PARAMETERS_TOKEN as Params);
|
|
24
|
+
|
|
24
25
|
const { buildType } = options;
|
|
25
26
|
|
|
26
27
|
const shouldBuildClient = buildType !== 'server';
|
package/src/api/start/index.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { createCommand } from '../../commands/createCommand';
|
|
|
5
5
|
import type { WithConfig } from '../shared/types/withConfig';
|
|
6
6
|
import { startApplication } from './application';
|
|
7
7
|
import { startModule } from './module';
|
|
8
|
-
import { CONFIG_ENTRY_TOKEN } from '../../di/tokens';
|
|
8
|
+
import { CONFIG_ENTRY_TOKEN, PORT_MANAGER_TOKEN } from '../../di/tokens';
|
|
9
9
|
import { startChildApp } from './child-app';
|
|
10
10
|
import type { Builder } from '../../typings/build/Builder';
|
|
11
11
|
|
|
@@ -45,8 +45,11 @@ export type StartCommand = (params: Params, providers?: Provider[]) => Result;
|
|
|
45
45
|
|
|
46
46
|
export default createCommand({
|
|
47
47
|
name: 'start',
|
|
48
|
-
command: (di): Result => {
|
|
48
|
+
command: async (di): Result => {
|
|
49
49
|
const configEntry = di.get(CONFIG_ENTRY_TOKEN);
|
|
50
|
+
const portManager = di.get(PORT_MANAGER_TOKEN);
|
|
51
|
+
|
|
52
|
+
await portManager.computeAvailablePorts();
|
|
50
53
|
|
|
51
54
|
switch (configEntry.type) {
|
|
52
55
|
case 'application':
|
|
@@ -7,35 +7,29 @@ import {
|
|
|
7
7
|
CONFIG_ENTRY_TOKEN,
|
|
8
8
|
COMMAND_PARAMETERS_TOKEN,
|
|
9
9
|
STATIC_SERVER_TOKEN,
|
|
10
|
+
PORT_MANAGER_TOKEN,
|
|
10
11
|
} from '../../../../di/tokens';
|
|
11
12
|
import { stopServer } from '../../utils/stopServer';
|
|
12
13
|
import type { ApplicationConfigEntry } from '../../../../typings/configEntry/application';
|
|
13
|
-
import {
|
|
14
|
-
createConfigManager,
|
|
15
|
-
DEFAULT_PORT,
|
|
16
|
-
DEFAULT_STATIC_PORT,
|
|
17
|
-
} from '../../../../config/configManager';
|
|
14
|
+
import { createConfigManager } from '../../../../config/configManager';
|
|
18
15
|
import { createServer } from '../../utils/createServer';
|
|
19
16
|
import { listenServer } from '../../utils/listenServer';
|
|
20
|
-
import { detectPortSync } from '../../../../utils/detectPortSync';
|
|
21
17
|
|
|
22
18
|
export const sharedProviders: readonly Provider[] = [
|
|
23
19
|
provide({
|
|
24
20
|
provide: CONFIG_MANAGER_TOKEN,
|
|
25
|
-
useFactory: ({ configEntry, parameters }) =>
|
|
21
|
+
useFactory: ({ configEntry, parameters, portManager }) =>
|
|
26
22
|
createConfigManager(configEntry as ApplicationConfigEntry, {
|
|
27
23
|
...parameters,
|
|
28
24
|
appEnv: parameters.env,
|
|
29
25
|
env: 'development',
|
|
30
|
-
port:
|
|
31
|
-
staticPort:
|
|
32
|
-
request: parameters.staticPort,
|
|
33
|
-
fallback: DEFAULT_STATIC_PORT,
|
|
34
|
-
}),
|
|
26
|
+
port: portManager.port,
|
|
27
|
+
staticPort: portManager.staticPort,
|
|
35
28
|
}),
|
|
36
29
|
deps: {
|
|
37
30
|
configEntry: CONFIG_ENTRY_TOKEN,
|
|
38
31
|
parameters: COMMAND_PARAMETERS_TOKEN,
|
|
32
|
+
portManager: PORT_MANAGER_TOKEN,
|
|
39
33
|
},
|
|
40
34
|
}),
|
|
41
35
|
provide({
|
|
@@ -6,27 +6,28 @@ import {
|
|
|
6
6
|
CONFIG_ENTRY_TOKEN,
|
|
7
7
|
COMMAND_PARAMETERS_TOKEN,
|
|
8
8
|
STATIC_SERVER_TOKEN,
|
|
9
|
+
PORT_MANAGER_TOKEN,
|
|
9
10
|
} from '../../../../di/tokens';
|
|
10
11
|
import type { ChildAppConfigEntry } from '../../../../typings/configEntry/child-app';
|
|
11
12
|
import { stopServer } from '../../utils/stopServer';
|
|
12
13
|
import { createServer } from '../../utils/createServer';
|
|
13
14
|
import { listenServer } from '../../utils/listenServer';
|
|
14
|
-
import { createConfigManager
|
|
15
|
-
import { detectPortSync } from '../../../../utils/detectPortSync';
|
|
15
|
+
import { createConfigManager } from '../../../../config/configManager';
|
|
16
16
|
|
|
17
17
|
export const sharedProviders: readonly Provider[] = [
|
|
18
18
|
provide({
|
|
19
19
|
provide: CONFIG_MANAGER_TOKEN,
|
|
20
|
-
useFactory: ({ configEntry, parameters }) =>
|
|
20
|
+
useFactory: ({ configEntry, parameters, portManager }) =>
|
|
21
21
|
createConfigManager(configEntry as ChildAppConfigEntry, {
|
|
22
22
|
...parameters,
|
|
23
23
|
appEnv: parameters.env,
|
|
24
24
|
env: 'development',
|
|
25
|
-
port:
|
|
25
|
+
port: portManager.port,
|
|
26
26
|
}),
|
|
27
27
|
deps: {
|
|
28
28
|
configEntry: CONFIG_ENTRY_TOKEN,
|
|
29
29
|
parameters: COMMAND_PARAMETERS_TOKEN,
|
|
30
|
+
portManager: PORT_MANAGER_TOKEN,
|
|
30
31
|
},
|
|
31
32
|
}),
|
|
32
33
|
provide({
|
|
@@ -6,27 +6,28 @@ import {
|
|
|
6
6
|
CONFIG_ENTRY_TOKEN,
|
|
7
7
|
COMMAND_PARAMETERS_TOKEN,
|
|
8
8
|
STATIC_SERVER_TOKEN,
|
|
9
|
+
PORT_MANAGER_TOKEN,
|
|
9
10
|
} from '../../../../di/tokens';
|
|
10
|
-
import { createConfigManager
|
|
11
|
+
import { createConfigManager } from '../../../../config/configManager';
|
|
11
12
|
import { stopServer } from '../../utils/stopServer';
|
|
12
13
|
import { createServer } from '../../utils/createServer';
|
|
13
14
|
import { listenServer } from '../../utils/listenServer';
|
|
14
|
-
import { detectPortSync } from '../../../../utils/detectPortSync';
|
|
15
15
|
import type { ModuleConfigEntry } from '../../../../typings/configEntry/module';
|
|
16
16
|
|
|
17
17
|
export const sharedProviders: readonly Provider[] = [
|
|
18
18
|
provide({
|
|
19
19
|
provide: CONFIG_MANAGER_TOKEN,
|
|
20
|
-
useFactory: ({ configEntry, parameters }) =>
|
|
20
|
+
useFactory: ({ configEntry, parameters, portManager }) =>
|
|
21
21
|
createConfigManager(configEntry as ModuleConfigEntry, {
|
|
22
22
|
...parameters,
|
|
23
23
|
appEnv: parameters.env,
|
|
24
24
|
env: 'development',
|
|
25
|
-
port:
|
|
25
|
+
port: portManager.port,
|
|
26
26
|
}),
|
|
27
27
|
deps: {
|
|
28
28
|
configEntry: CONFIG_ENTRY_TOKEN,
|
|
29
29
|
parameters: COMMAND_PARAMETERS_TOKEN,
|
|
30
|
+
portManager: PORT_MANAGER_TOKEN,
|
|
30
31
|
},
|
|
31
32
|
}),
|
|
32
33
|
provide({
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Container } from '@tinkoff/dippy';
|
|
2
2
|
import type { Params, Result } from './index';
|
|
3
|
-
import { COMMAND_PARAMETERS_TOKEN, STATIC_SERVER_TOKEN } from '../../di/tokens';
|
|
3
|
+
import { COMMAND_PARAMETERS_TOKEN, PORT_MANAGER_TOKEN, STATIC_SERVER_TOKEN } from '../../di/tokens';
|
|
4
4
|
import {
|
|
5
5
|
INIT_HANDLER_TOKEN,
|
|
6
6
|
CLOSE_HANDLER_TOKEN,
|
|
@@ -15,8 +15,12 @@ import { build } from '..';
|
|
|
15
15
|
|
|
16
16
|
export const startProdApplication = async (di: Container): Result => {
|
|
17
17
|
const parameters = di.get(COMMAND_PARAMETERS_TOKEN) as Params;
|
|
18
|
+
const portManager = di.get(PORT_MANAGER_TOKEN);
|
|
19
|
+
|
|
20
|
+
await portManager.computeAvailablePorts();
|
|
18
21
|
|
|
19
22
|
registerProviders(di, [...sharedProviders, ...applicationsProviders]);
|
|
23
|
+
|
|
20
24
|
await runHandlers(di.get({ token: INIT_HANDLER_TOKEN, optional: true }));
|
|
21
25
|
|
|
22
26
|
const { builder, ...buildResult } = await build(parameters);
|
|
@@ -4,7 +4,7 @@ import type { ChildProcess } from 'child_process';
|
|
|
4
4
|
import type { Provider } from '@tinkoff/dippy';
|
|
5
5
|
import { createCommand } from '../../commands/createCommand';
|
|
6
6
|
import type { WithConfig } from '../shared/types/withConfig';
|
|
7
|
-
import { CONFIG_ENTRY_TOKEN } from '../../di/tokens';
|
|
7
|
+
import { CONFIG_ENTRY_TOKEN, PORT_MANAGER_TOKEN } from '../../di/tokens';
|
|
8
8
|
import type { Builder } from '../../typings/build/Builder';
|
|
9
9
|
import { startProdApplication } from './application';
|
|
10
10
|
import { startProdChildApp } from './child-app';
|
|
@@ -36,8 +36,11 @@ export type StartProdCommand = (params: Params, providers?: Provider[]) => Resul
|
|
|
36
36
|
|
|
37
37
|
export default createCommand({
|
|
38
38
|
name: 'start-prod',
|
|
39
|
-
command: (di): Result => {
|
|
39
|
+
command: async (di): Result => {
|
|
40
40
|
const configEntry = di.get(CONFIG_ENTRY_TOKEN);
|
|
41
|
+
const portManager = di.get(PORT_MANAGER_TOKEN);
|
|
42
|
+
|
|
43
|
+
await portManager.computeAvailablePorts();
|
|
41
44
|
|
|
42
45
|
switch (configEntry.type) {
|
|
43
46
|
case 'application':
|