@tramvai/cli 2.65.9 → 2.66.2
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/api/start/providers/application/server.js +11 -18
- package/lib/api/start/providers/application/server.js.map +1 -1
- package/lib/api/start/providers/application/shared.js +17 -25
- package/lib/api/start/providers/application/shared.js.map +1 -1
- package/lib/api/start/providers/child-app/shared.js +12 -19
- package/lib/api/start/providers/child-app/shared.js.map +1 -1
- package/lib/api/start/providers/module/shared.js +6 -13
- package/lib/api/start/providers/module/shared.js.map +1 -1
- package/lib/api/start/utils/listenServer.js +3 -2
- package/lib/api/start/utils/listenServer.js.map +1 -1
- package/lib/api/start-prod/providers/application.js +2 -1
- package/lib/api/start-prod/providers/application.js.map +1 -1
- package/lib/api/start-prod/providers/child-app.js +2 -1
- package/lib/api/start-prod/providers/child-app.js.map +1 -1
- package/lib/api/start-prod/providers/shared.js +2 -10
- package/lib/api/start-prod/providers/shared.js.map +1 -1
- package/lib/builder/webpack/providers/build/client.js.map +1 -1
- package/lib/config/configManager.d.ts +3 -0
- package/lib/config/configManager.js +5 -2
- package/lib/config/configManager.js.map +1 -1
- package/lib/utils/detectPortSync.d.ts +1 -0
- package/lib/utils/detectPortSync.js +10 -0
- package/lib/utils/detectPortSync.js.map +1 -0
- package/package.json +3 -2
- package/src/api/start/__integration__/start.test.ts +37 -1
- package/src/api/start/providers/application/server.ts +14 -23
- package/src/api/start/providers/application/shared.ts +26 -52
- package/src/api/start/providers/child-app/shared.ts +17 -35
- package/src/api/start/providers/module/shared.ts +10 -22
- package/src/api/start/utils/listenServer.ts +2 -1
- package/src/api/start-prod/providers/application.ts +11 -7
- package/src/api/start-prod/providers/child-app.ts +6 -6
- package/src/api/start-prod/providers/shared.ts +2 -12
- package/src/builder/webpack/providers/build/client.ts +0 -1
- package/src/config/configManager.ts +8 -2
- package/src/utils/detectPortSync.ts +7 -0
|
@@ -2,41 +2,34 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.serverProviders = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
+
const dippy_1 = require("@tinkoff/dippy");
|
|
5
6
|
const tokens_1 = require("../../tokens");
|
|
6
7
|
const tokens_2 = require("../../../../di/tokens");
|
|
7
8
|
const stopServer_1 = require("../../utils/stopServer");
|
|
8
9
|
const createServer_1 = require("../../utils/createServer");
|
|
9
10
|
const listenServer_1 = require("../../utils/listenServer");
|
|
10
11
|
exports.serverProviders = [
|
|
11
|
-
{
|
|
12
|
+
(0, dippy_1.provide)({
|
|
12
13
|
provide: tokens_2.SERVER_TOKEN,
|
|
13
14
|
useFactory: createServer_1.createServer,
|
|
14
|
-
},
|
|
15
|
-
{
|
|
15
|
+
}),
|
|
16
|
+
(0, dippy_1.provide)({
|
|
16
17
|
provide: tokens_1.INIT_HANDLER_TOKEN,
|
|
17
18
|
multi: true,
|
|
18
|
-
useFactory: ({ server,
|
|
19
|
+
useFactory: ({ server, configManager }) => {
|
|
19
20
|
return function staticServerListen() {
|
|
20
21
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
21
|
-
const { host
|
|
22
|
-
|
|
23
|
-
yield (0, listenServer_1.listenServer)(server, host, port);
|
|
24
|
-
}
|
|
25
|
-
catch (error) {
|
|
26
|
-
if (error.code === 'EADDRINUSE') {
|
|
27
|
-
throw new Error(`Address '${host}:${port}' in use, either release this port or use options --port --host`);
|
|
28
|
-
}
|
|
29
|
-
throw error;
|
|
30
|
-
}
|
|
22
|
+
const { host, port } = configManager;
|
|
23
|
+
yield (0, listenServer_1.listenServer)(server, host, port);
|
|
31
24
|
});
|
|
32
25
|
};
|
|
33
26
|
},
|
|
34
27
|
deps: {
|
|
35
28
|
server: tokens_2.SERVER_TOKEN,
|
|
36
|
-
|
|
29
|
+
configManager: tokens_2.CONFIG_MANAGER_TOKEN,
|
|
37
30
|
},
|
|
38
|
-
},
|
|
39
|
-
{
|
|
31
|
+
}),
|
|
32
|
+
(0, dippy_1.provide)({
|
|
40
33
|
provide: tokens_1.CLOSE_HANDLER_TOKEN,
|
|
41
34
|
multi: true,
|
|
42
35
|
useFactory: ({ server }) => {
|
|
@@ -47,6 +40,6 @@ exports.serverProviders = [
|
|
|
47
40
|
deps: {
|
|
48
41
|
server: tokens_2.SERVER_TOKEN,
|
|
49
42
|
},
|
|
50
|
-
},
|
|
43
|
+
}),
|
|
51
44
|
];
|
|
52
45
|
//# sourceMappingURL=server.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../../../../src/api/start/providers/application/server.ts"],"names":[],"mappings":";;;;AACA,yCAAuE;AACvE,
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../../../../src/api/start/providers/application/server.ts"],"names":[],"mappings":";;;;AACA,0CAAyC;AAEzC,yCAAuE;AACvE,kDAA2E;AAC3E,uDAAoD;AACpD,2DAAwD;AACxD,2DAAwD;AAE3C,QAAA,eAAe,GAAwB;IAClD,IAAA,eAAO,EAAC;QACN,OAAO,EAAE,qBAAY;QACrB,UAAU,EAAE,2BAAY;KACzB,CAAC;IACF,IAAA,eAAO,EAAC;QACN,OAAO,EAAE,2BAAkB;QAC3B,KAAK,EAAE,IAAI;QACX,UAAU,EAAE,CAAC,EAAE,MAAM,EAAE,aAAa,EAAE,EAAE,EAAE;YACxC,OAAO,SAAe,kBAAkB;;oBACtC,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,aAAa,CAAC;oBAErC,MAAM,IAAA,2BAAY,EAAC,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;gBACzC,CAAC;aAAA,CAAC;QACJ,CAAC;QACD,IAAI,EAAE;YACJ,MAAM,EAAE,qBAAY;YACpB,aAAa,EAAE,6BAAoB;SACpC;KACF,CAAC;IACF,IAAA,eAAO,EAAC;QACN,OAAO,EAAE,4BAAmB;QAC5B,KAAK,EAAE,IAAI;QACX,UAAU,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE;YACzB,OAAO,GAAG,EAAE;gBACV,OAAO,IAAA,uBAAU,EAAC,MAAM,CAAC,CAAC;YAC5B,CAAC,CAAC;QACJ,CAAC;QACD,IAAI,EAAE;YACJ,MAAM,EAAE,qBAAY;SACrB;KACF,CAAC;CACM,CAAC"}
|
|
@@ -2,55 +2,47 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.sharedProviders = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
+
const dippy_1 = require("@tinkoff/dippy");
|
|
5
6
|
const tokens_1 = require("../../tokens");
|
|
6
7
|
const tokens_2 = require("../../../../di/tokens");
|
|
7
8
|
const stopServer_1 = require("../../utils/stopServer");
|
|
8
9
|
const configManager_1 = require("../../../../config/configManager");
|
|
9
10
|
const createServer_1 = require("../../utils/createServer");
|
|
10
11
|
const listenServer_1 = require("../../utils/listenServer");
|
|
11
|
-
const
|
|
12
|
+
const detectPortSync_1 = require("../../../../utils/detectPortSync");
|
|
12
13
|
exports.sharedProviders = [
|
|
13
|
-
{
|
|
14
|
+
(0, dippy_1.provide)({
|
|
14
15
|
provide: tokens_2.CONFIG_MANAGER_TOKEN,
|
|
15
|
-
useFactory: ({ configEntry, parameters
|
|
16
|
-
|
|
16
|
+
useFactory: ({ configEntry, parameters }) => {
|
|
17
|
+
var _a, _b;
|
|
18
|
+
return (0, configManager_1.createConfigManager)(configEntry, Object.assign(Object.assign({}, parameters), { env: 'development', port: (0, detectPortSync_1.detectPortSync)((_a = parameters.port) !== null && _a !== void 0 ? _a : configManager_1.DEFAULT_PORT), staticPort: (0, detectPortSync_1.detectPortSync)((_b = parameters.staticPort) !== null && _b !== void 0 ? _b : configManager_1.DEFAULT_STATIC_PORT) }));
|
|
17
19
|
},
|
|
18
20
|
deps: {
|
|
19
21
|
configEntry: tokens_2.CONFIG_ENTRY_TOKEN,
|
|
20
22
|
parameters: tokens_2.COMMAND_PARAMETERS_TOKEN,
|
|
21
|
-
staticServer: tokens_2.STATIC_SERVER_TOKEN,
|
|
22
|
-
server: { token: tokens_2.SERVER_TOKEN, optional: true },
|
|
23
23
|
},
|
|
24
|
-
},
|
|
25
|
-
{
|
|
24
|
+
}),
|
|
25
|
+
(0, dippy_1.provide)({
|
|
26
26
|
provide: tokens_2.STATIC_SERVER_TOKEN,
|
|
27
27
|
useFactory: createServer_1.createServer,
|
|
28
|
-
},
|
|
29
|
-
{
|
|
28
|
+
}),
|
|
29
|
+
(0, dippy_1.provide)({
|
|
30
30
|
provide: tokens_1.INIT_HANDLER_TOKEN,
|
|
31
31
|
multi: true,
|
|
32
|
-
useFactory: ({
|
|
32
|
+
useFactory: ({ configManager, staticServer }) => {
|
|
33
33
|
return function staticServerListen() {
|
|
34
34
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
35
|
-
const { staticHost
|
|
36
|
-
|
|
37
|
-
yield (0, listenServer_1.listenServer)(staticServer, staticHost.replace('localhost', '0.0.0.0'), staticPort);
|
|
38
|
-
}
|
|
39
|
-
catch (error) {
|
|
40
|
-
if (error.code === 'EADDRINUSE') {
|
|
41
|
-
throw new Error(`Address '${staticHost}:${staticPort}' in use, either release this port or use options --staticPort --staticHost`);
|
|
42
|
-
}
|
|
43
|
-
throw error;
|
|
44
|
-
}
|
|
35
|
+
const { staticHost, staticPort } = configManager;
|
|
36
|
+
yield (0, listenServer_1.listenServer)(staticServer, staticHost.replace('localhost', '0.0.0.0'), staticPort);
|
|
45
37
|
});
|
|
46
38
|
};
|
|
47
39
|
},
|
|
48
40
|
deps: {
|
|
49
41
|
staticServer: tokens_2.STATIC_SERVER_TOKEN,
|
|
50
|
-
|
|
42
|
+
configManager: tokens_2.CONFIG_MANAGER_TOKEN,
|
|
51
43
|
},
|
|
52
|
-
},
|
|
53
|
-
{
|
|
44
|
+
}),
|
|
45
|
+
(0, dippy_1.provide)({
|
|
54
46
|
provide: tokens_1.CLOSE_HANDLER_TOKEN,
|
|
55
47
|
multi: true,
|
|
56
48
|
useFactory: ({ staticServer }) => {
|
|
@@ -61,6 +53,6 @@ exports.sharedProviders = [
|
|
|
61
53
|
deps: {
|
|
62
54
|
staticServer: tokens_2.STATIC_SERVER_TOKEN,
|
|
63
55
|
},
|
|
64
|
-
},
|
|
56
|
+
}),
|
|
65
57
|
];
|
|
66
58
|
//# sourceMappingURL=shared.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../../../../../src/api/start/providers/application/shared.ts"],"names":[],"mappings":";;;;AACA,yCAAuE;AACvE,
|
|
1
|
+
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../../../../../src/api/start/providers/application/shared.ts"],"names":[],"mappings":";;;;AACA,0CAAyC;AAEzC,yCAAuE;AACvE,kDAK+B;AAC/B,uDAAoD;AAEpD,oEAI0C;AAC1C,2DAAwD;AACxD,2DAAwD;AACxD,qEAAkE;AAErD,QAAA,eAAe,GAAwB;IAClD,IAAA,eAAO,EAAC;QACN,OAAO,EAAE,6BAAoB;QAC7B,UAAU,EAAE,CAAC,EAAE,WAAW,EAAE,UAAU,EAAE,EAAE,EAAE;;YAC1C,OAAA,IAAA,mCAAmB,EAAC,WAAqC,kCACpD,UAAU,KACb,GAAG,EAAE,aAAa,EAClB,IAAI,EAAE,IAAA,+BAAc,EAAC,MAAA,UAAU,CAAC,IAAI,mCAAI,4BAAY,CAAC,EACrD,UAAU,EAAE,IAAA,+BAAc,EAAC,MAAA,UAAU,CAAC,UAAU,mCAAI,mCAAmB,CAAC,IACxE,CAAA;SAAA;QACJ,IAAI,EAAE;YACJ,WAAW,EAAE,2BAAkB;YAC/B,UAAU,EAAE,iCAAwB;SACrC;KACF,CAAC;IACF,IAAA,eAAO,EAAC;QACN,OAAO,EAAE,4BAAmB;QAC5B,UAAU,EAAE,2BAAY;KACzB,CAAC;IACF,IAAA,eAAO,EAAC;QACN,OAAO,EAAE,2BAAkB;QAC3B,KAAK,EAAE,IAAI;QACX,UAAU,EAAE,CAAC,EAAE,aAAa,EAAE,YAAY,EAAE,EAAE,EAAE;YAC9C,OAAO,SAAe,kBAAkB;;oBACtC,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,GAAG,aAAa,CAAC;oBAEjD,MAAM,IAAA,2BAAY,EAAC,YAAY,EAAE,UAAU,CAAC,OAAO,CAAC,WAAW,EAAE,SAAS,CAAC,EAAE,UAAU,CAAC,CAAC;gBAC3F,CAAC;aAAA,CAAC;QACJ,CAAC;QACD,IAAI,EAAE;YACJ,YAAY,EAAE,4BAAmB;YACjC,aAAa,EAAE,6BAAoB;SACpC;KACF,CAAC;IACF,IAAA,eAAO,EAAC;QACN,OAAO,EAAE,4BAAmB;QAC5B,KAAK,EAAE,IAAI;QACX,UAAU,EAAE,CAAC,EAAE,YAAY,EAAE,EAAE,EAAE;YAC/B,OAAO,GAAG,EAAE;gBACV,OAAO,IAAA,uBAAU,EAAC,YAAY,CAAC,CAAC;YAClC,CAAC,CAAC;QACJ,CAAC;QACD,IAAI,EAAE;YACJ,YAAY,EAAE,4BAAmB;SAClC;KACF,CAAC;CACM,CAAC"}
|
|
@@ -10,47 +10,40 @@ const stopServer_1 = require("../../utils/stopServer");
|
|
|
10
10
|
const createServer_1 = require("../../utils/createServer");
|
|
11
11
|
const listenServer_1 = require("../../utils/listenServer");
|
|
12
12
|
const configManager_1 = require("../../../../config/configManager");
|
|
13
|
+
const detectPortSync_1 = require("../../../../utils/detectPortSync");
|
|
13
14
|
exports.sharedProviders = [
|
|
14
15
|
(0, dippy_1.provide)({
|
|
15
16
|
provide: tokens_2.CONFIG_MANAGER_TOKEN,
|
|
16
17
|
useFactory: ({ configEntry, parameters }) => {
|
|
17
18
|
var _a;
|
|
18
|
-
return (0, configManager_1.createConfigManager)(configEntry, Object.assign(Object.assign({}, parameters), { env: 'development', port: (_a = parameters.port) !== null && _a !== void 0 ? _a :
|
|
19
|
+
return (0, configManager_1.createConfigManager)(configEntry, Object.assign(Object.assign({}, parameters), { env: 'development', port: (0, detectPortSync_1.detectPortSync)((_a = parameters.port) !== null && _a !== void 0 ? _a : configManager_1.DEFAULT_STATIC_MODULE_PORT) }));
|
|
19
20
|
},
|
|
20
21
|
deps: {
|
|
21
22
|
configEntry: tokens_2.CONFIG_ENTRY_TOKEN,
|
|
22
23
|
parameters: tokens_2.COMMAND_PARAMETERS_TOKEN,
|
|
23
24
|
},
|
|
24
25
|
}),
|
|
25
|
-
{
|
|
26
|
+
(0, dippy_1.provide)({
|
|
26
27
|
provide: tokens_2.STATIC_SERVER_TOKEN,
|
|
27
28
|
useFactory: createServer_1.createServer,
|
|
28
|
-
},
|
|
29
|
-
{
|
|
29
|
+
}),
|
|
30
|
+
(0, dippy_1.provide)({
|
|
30
31
|
provide: tokens_1.INIT_HANDLER_TOKEN,
|
|
31
32
|
multi: true,
|
|
32
|
-
useFactory: ({ staticServer,
|
|
33
|
+
useFactory: ({ staticServer, configManager }) => {
|
|
33
34
|
return function staticServerListen() {
|
|
34
35
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
35
|
-
const { host
|
|
36
|
-
|
|
37
|
-
yield (0, listenServer_1.listenServer)(staticServer, host, port);
|
|
38
|
-
}
|
|
39
|
-
catch (error) {
|
|
40
|
-
if (error.code === 'EADDRINUSE') {
|
|
41
|
-
throw new Error(`Address '${host}:${port}' in use, either release this port or use options --port --host`);
|
|
42
|
-
}
|
|
43
|
-
throw error;
|
|
44
|
-
}
|
|
36
|
+
const { host, port } = configManager;
|
|
37
|
+
yield (0, listenServer_1.listenServer)(staticServer, host, port);
|
|
45
38
|
});
|
|
46
39
|
};
|
|
47
40
|
},
|
|
48
41
|
deps: {
|
|
49
42
|
staticServer: tokens_2.STATIC_SERVER_TOKEN,
|
|
50
|
-
|
|
43
|
+
configManager: tokens_2.CONFIG_MANAGER_TOKEN,
|
|
51
44
|
},
|
|
52
|
-
},
|
|
53
|
-
{
|
|
45
|
+
}),
|
|
46
|
+
(0, dippy_1.provide)({
|
|
54
47
|
provide: tokens_1.CLOSE_HANDLER_TOKEN,
|
|
55
48
|
multi: true,
|
|
56
49
|
useFactory: ({ staticServer }) => {
|
|
@@ -61,7 +54,7 @@ exports.sharedProviders = [
|
|
|
61
54
|
deps: {
|
|
62
55
|
staticServer: tokens_2.STATIC_SERVER_TOKEN,
|
|
63
56
|
},
|
|
64
|
-
},
|
|
57
|
+
}),
|
|
65
58
|
(0, dippy_1.provide)({
|
|
66
59
|
provide: tokens_1.CLOSE_HANDLER_TOKEN,
|
|
67
60
|
multi: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../../../../../src/api/start/providers/child-app/shared.ts"],"names":[],"mappings":";;;;AACA,0CAAyC;AACzC,yCAAuE;AACvE,kDAK+B;
|
|
1
|
+
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../../../../../src/api/start/providers/child-app/shared.ts"],"names":[],"mappings":";;;;AACA,0CAAyC;AACzC,yCAAuE;AACvE,kDAK+B;AAE/B,+EAA0F;AAC1F,uDAAoD;AACpD,2DAAwD;AACxD,2DAAwD;AACxD,oEAAmG;AACnG,qEAAkE;AAErD,QAAA,eAAe,GAAwB;IAClD,IAAA,eAAO,EAAC;QACN,OAAO,EAAE,6BAAoB;QAC7B,UAAU,EAAE,CAAC,EAAE,WAAW,EAAE,UAAU,EAAE,EAAE,EAAE;;YAC1C,OAAA,IAAA,mCAAmB,EAAC,WAAkC,kCACjD,UAAU,KACb,GAAG,EAAE,aAAa,EAClB,IAAI,EAAE,IAAA,+BAAc,EAAC,MAAA,UAAU,CAAC,IAAI,mCAAI,0CAA0B,CAAC,IACnE,CAAA;SAAA;QACJ,IAAI,EAAE;YACJ,WAAW,EAAE,2BAAkB;YAC/B,UAAU,EAAE,iCAAwB;SACrC;KACF,CAAC;IACF,IAAA,eAAO,EAAC;QACN,OAAO,EAAE,4BAAmB;QAC5B,UAAU,EAAE,2BAAY;KACzB,CAAC;IACF,IAAA,eAAO,EAAC;QACN,OAAO,EAAE,2BAAkB;QAC3B,KAAK,EAAE,IAAI;QACX,UAAU,EAAE,CAAC,EAAE,YAAY,EAAE,aAAa,EAAE,EAAE,EAAE;YAC9C,OAAO,SAAe,kBAAkB;;oBACtC,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,aAAa,CAAC;oBAErC,MAAM,IAAA,2BAAY,EAAC,YAAY,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;gBAC/C,CAAC;aAAA,CAAC;QACJ,CAAC;QACD,IAAI,EAAE;YACJ,YAAY,EAAE,4BAAmB;YACjC,aAAa,EAAE,6BAAoB;SACpC;KACF,CAAC;IACF,IAAA,eAAO,EAAC;QACN,OAAO,EAAE,4BAAmB;QAC5B,KAAK,EAAE,IAAI;QACX,UAAU,EAAE,CAAC,EAAE,YAAY,EAAE,EAAE,EAAE;YAC/B,OAAO,GAAG,EAAE;gBACV,OAAO,IAAA,uBAAU,EAAC,YAAY,CAAC,CAAC;YAClC,CAAC,CAAC;QACJ,CAAC;QACD,IAAI,EAAE;YACJ,YAAY,EAAE,4BAAmB;SAClC;KACF,CAAC;IACF,IAAA,eAAO,EAAC;QACN,OAAO,EAAE,4BAAmB;QAC5B,KAAK,EAAE,IAAI;QACX,UAAU,EAAE,CAAC,EAAE,aAAa,EAAE,EAAE,EAAE;YAChC,OAAO,GAAS,EAAE;gBAChB,MAAM,IAAA,uCAAyB,EAAC,aAAa,CAAC,CAAC;YACjD,CAAC,CAAA,CAAC;QACJ,CAAC;QACD,IAAI,EAAE;YACJ,aAAa,EAAE,6BAAoB;SACpC;KACF,CAAC;CACM,CAAC"}
|
|
@@ -10,12 +10,13 @@ const workersPool_1 = require("../../../../library/webpack/utils/workersPool");
|
|
|
10
10
|
const stopServer_1 = require("../../utils/stopServer");
|
|
11
11
|
const createServer_1 = require("../../utils/createServer");
|
|
12
12
|
const listenServer_1 = require("../../utils/listenServer");
|
|
13
|
+
const detectPortSync_1 = require("../../../../utils/detectPortSync");
|
|
13
14
|
exports.sharedProviders = [
|
|
14
15
|
(0, dippy_1.provide)({
|
|
15
16
|
provide: tokens_2.CONFIG_MANAGER_TOKEN,
|
|
16
17
|
useFactory: ({ configEntry, parameters }) => {
|
|
17
18
|
var _a;
|
|
18
|
-
return (0, configManager_1.createConfigManager)(configEntry, Object.assign(Object.assign({}, parameters), { env: 'development', port: (_a = parameters.port) !== null && _a !== void 0 ? _a :
|
|
19
|
+
return (0, configManager_1.createConfigManager)(configEntry, Object.assign(Object.assign({}, parameters), { env: 'development', port: (0, detectPortSync_1.detectPortSync)((_a = parameters.port) !== null && _a !== void 0 ? _a : configManager_1.DEFAULT_STATIC_MODULE_PORT) }));
|
|
19
20
|
},
|
|
20
21
|
deps: {
|
|
21
22
|
configEntry: tokens_2.CONFIG_ENTRY_TOKEN,
|
|
@@ -29,25 +30,17 @@ exports.sharedProviders = [
|
|
|
29
30
|
(0, dippy_1.provide)({
|
|
30
31
|
provide: tokens_1.INIT_HANDLER_TOKEN,
|
|
31
32
|
multi: true,
|
|
32
|
-
useFactory: ({ staticServer,
|
|
33
|
+
useFactory: ({ staticServer, configManager }) => {
|
|
33
34
|
return function staticServerListen() {
|
|
34
35
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
35
|
-
const { host
|
|
36
|
-
|
|
37
|
-
yield (0, listenServer_1.listenServer)(staticServer, host, port);
|
|
38
|
-
}
|
|
39
|
-
catch (error) {
|
|
40
|
-
if (error.code === 'EADDRINUSE') {
|
|
41
|
-
throw new Error(`Address '${host}:${port}' in use, either release this port or use options --port --host`);
|
|
42
|
-
}
|
|
43
|
-
throw error;
|
|
44
|
-
}
|
|
36
|
+
const { host, port } = configManager;
|
|
37
|
+
yield (0, listenServer_1.listenServer)(staticServer, host, port);
|
|
45
38
|
});
|
|
46
39
|
};
|
|
47
40
|
},
|
|
48
41
|
deps: {
|
|
49
42
|
staticServer: tokens_2.STATIC_SERVER_TOKEN,
|
|
50
|
-
|
|
43
|
+
configManager: tokens_2.CONFIG_MANAGER_TOKEN,
|
|
51
44
|
},
|
|
52
45
|
}),
|
|
53
46
|
(0, dippy_1.provide)({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../../../../../src/api/start/providers/module/shared.ts"],"names":[],"mappings":";;;;AACA,0CAAyC;AACzC,yCAAuE;AACvE,kDAK+B;
|
|
1
|
+
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../../../../../src/api/start/providers/module/shared.ts"],"names":[],"mappings":";;;;AACA,0CAAyC;AACzC,yCAAuE;AACvE,kDAK+B;AAC/B,oEAAmG;AACnG,+EAA0F;AAC1F,uDAAoD;AACpD,2DAAwD;AACxD,2DAAwD;AACxD,qEAAkE;AAGrD,QAAA,eAAe,GAAwB;IAClD,IAAA,eAAO,EAAC;QACN,OAAO,EAAE,6BAAoB;QAC7B,UAAU,EAAE,CAAC,EAAE,WAAW,EAAE,UAAU,EAAE,EAAE,EAAE;;YAC1C,OAAA,IAAA,mCAAmB,EAAC,WAAgC,kCAC/C,UAAU,KACb,GAAG,EAAE,aAAa,EAClB,IAAI,EAAE,IAAA,+BAAc,EAAC,MAAA,UAAU,CAAC,IAAI,mCAAI,0CAA0B,CAAC,IACnE,CAAA;SAAA;QACJ,IAAI,EAAE;YACJ,WAAW,EAAE,2BAAkB;YAC/B,UAAU,EAAE,iCAAwB;SACrC;KACF,CAAC;IACF,IAAA,eAAO,EAAC;QACN,OAAO,EAAE,4BAAmB;QAC5B,UAAU,EAAE,2BAAY;KACzB,CAAC;IACF,IAAA,eAAO,EAAC;QACN,OAAO,EAAE,2BAAkB;QAC3B,KAAK,EAAE,IAAI;QACX,UAAU,EAAE,CAAC,EAAE,YAAY,EAAE,aAAa,EAAE,EAAE,EAAE;YAC9C,OAAO,SAAe,kBAAkB;;oBACtC,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,aAAa,CAAC;oBAErC,MAAM,IAAA,2BAAY,EAAC,YAAY,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;gBAC/C,CAAC;aAAA,CAAC;QACJ,CAAC;QACD,IAAI,EAAE;YACJ,YAAY,EAAE,4BAAmB;YACjC,aAAa,EAAE,6BAAoB;SACpC;KACF,CAAC;IACF,IAAA,eAAO,EAAC;QACN,OAAO,EAAE,4BAAmB;QAC5B,KAAK,EAAE,IAAI;QACX,UAAU,EAAE,CAAC,EAAE,YAAY,EAAE,EAAE,EAAE;YAC/B,OAAO,GAAG,EAAE;gBACV,OAAO,IAAA,uBAAU,EAAC,YAAY,CAAC,CAAC;YAClC,CAAC,CAAC;QACJ,CAAC;QACD,IAAI,EAAE;YACJ,YAAY,EAAE,4BAAmB;SAClC;KACF,CAAC;IACF,IAAA,eAAO,EAAC;QACN,OAAO,EAAE,4BAAmB;QAC5B,KAAK,EAAE,IAAI;QACX,UAAU,EAAE,CAAC,EAAE,aAAa,EAAE,EAAE,EAAE;YAChC,OAAO,GAAS,EAAE;gBAChB,IAAA,uCAAyB,EAAC,aAAa,CAAC,CAAC;YAC3C,CAAC,CAAA,CAAC;QACJ,CAAC;QACD,IAAI,EAAE;YACJ,aAAa,EAAE,6BAAoB;SACpC;KACF,CAAC;CACM,CAAC"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.listenServer = void 0;
|
|
4
|
-
const
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const listenServer = (server, host, port) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
5
6
|
return new Promise((resolve, reject) => {
|
|
6
7
|
server.once('error', (error) => {
|
|
7
8
|
reject(error);
|
|
@@ -10,6 +11,6 @@ const listenServer = (server, host, port) => {
|
|
|
10
11
|
resolve();
|
|
11
12
|
});
|
|
12
13
|
});
|
|
13
|
-
};
|
|
14
|
+
});
|
|
14
15
|
exports.listenServer = listenServer;
|
|
15
16
|
//# sourceMappingURL=listenServer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"listenServer.js","sourceRoot":"","sources":["../../../../src/api/start/utils/listenServer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"listenServer.js","sourceRoot":"","sources":["../../../../src/api/start/utils/listenServer.ts"],"names":[],"mappings":";;;;AAEO,MAAM,YAAY,GAAG,CAAO,MAAc,EAAE,IAAY,EAAE,IAAY,EAAiB,EAAE;IAC9F,OAAO,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QAC3C,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE;YAC7B,MAAM,CAAC,KAAK,CAAC,CAAC;QAChB,CAAC,CAAC,CAAC;QAEH,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE;YAC7B,OAAO,EAAE,CAAC;QACZ,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAA,CAAC;AAVW,QAAA,YAAY,gBAUvB"}
|
|
@@ -8,6 +8,7 @@ const child_process_1 = require("child_process");
|
|
|
8
8
|
const tokens_1 = require("../../../di/tokens");
|
|
9
9
|
const tokens_2 = require("../tokens");
|
|
10
10
|
const constants_1 = require("../../../config/constants");
|
|
11
|
+
const detectPortSync_1 = require("../../../utils/detectPortSync");
|
|
11
12
|
const safeRequire_1 = require("../../../utils/safeRequire");
|
|
12
13
|
const configManager_1 = require("../../../config/configManager");
|
|
13
14
|
exports.applicationsProviders = [
|
|
@@ -15,7 +16,7 @@ exports.applicationsProviders = [
|
|
|
15
16
|
provide: tokens_1.CONFIG_MANAGER_TOKEN,
|
|
16
17
|
useFactory: ({ configEntry, parameters }) => {
|
|
17
18
|
var _a, _b;
|
|
18
|
-
return (0, configManager_1.createConfigManager)(configEntry, Object.assign(Object.assign({}, parameters), { env: 'production', port: (_a = parameters.port) !== null && _a !== void 0 ? _a :
|
|
19
|
+
return (0, configManager_1.createConfigManager)(configEntry, Object.assign(Object.assign({}, parameters), { env: 'production', buildType: 'client', port: (0, detectPortSync_1.detectPortSync)((_a = parameters.port) !== null && _a !== void 0 ? _a : configManager_1.DEFAULT_PORT), staticPort: (0, detectPortSync_1.detectPortSync)((_b = parameters.staticPort) !== null && _b !== void 0 ? _b : configManager_1.DEFAULT_STATIC_PORT) }));
|
|
19
20
|
},
|
|
20
21
|
deps: {
|
|
21
22
|
configEntry: tokens_1.CONFIG_ENTRY_TOKEN,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"application.js","sourceRoot":"","sources":["../../../../src/api/start-prod/providers/application.ts"],"names":[],"mappings":";;;;AAAA,wDAAwB;AAExB,0CAAyC;AACzC,iDAAqC;AACrC,+CAI4B;AAG5B,sCAAsE;AACtE,yDAAuD;AACvD,4DAAyD;AAEzD,
|
|
1
|
+
{"version":3,"file":"application.js","sourceRoot":"","sources":["../../../../src/api/start-prod/providers/application.ts"],"names":[],"mappings":";;;;AAAA,wDAAwB;AAExB,0CAAyC;AACzC,iDAAqC;AACrC,+CAI4B;AAG5B,sCAAsE;AACtE,yDAAuD;AACvD,kEAA+D;AAC/D,4DAAyD;AAEzD,iEAIuC;AAG1B,QAAA,qBAAqB,GAAwB;IACxD,IAAA,eAAO,EAAC;QACN,OAAO,EAAE,6BAAoB;QAC7B,UAAU,EAAE,CAAC,EAAE,WAAW,EAAE,UAAU,EAAoD,EAAE,EAAE;;YAC5F,OAAA,IAAA,mCAAmB,EAAC,WAAW,kCAC1B,UAAU,KACb,GAAG,EAAE,YAAY,EACjB,SAAS,EAAE,QAAQ,EACnB,IAAI,EAAE,IAAA,+BAAc,EAAC,MAAA,UAAU,CAAC,IAAI,mCAAI,4BAAY,CAAC,EACrD,UAAU,EAAE,IAAA,+BAAc,EAAC,MAAA,UAAU,CAAC,UAAU,mCAAI,mCAAmB,CAAC,IACxE,CAAA;SAAA;QAC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C,CAAC;QACL,CAAC;QACD,IAAI,EAAE;YACJ,aAAa,EAAE,6BAAoB;YACnC,UAAU,EAAE,iCAAwB;SACrC;KACF,CAAC;IACF,IAAA,eAAO,EAAC;QACN,OAAO,EAAE,4BAAmB;QAC5B,KAAK,EAAE,IAAI;QACX,UAAU,EAAE,CAAC,EAAE,aAAa,EAAE,EAAE,EAAE;YAChC,OAAO,GAAS,EAAE;gBAChB,OAAO,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE;oBACnC,aAAa,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE;wBAC9B,OAAO,EAAE,CAAC;oBACZ,CAAC,CAAC,CAAC;oBAEH,aAAa,CAAC,IAAI,EAAE,CAAC;gBACvB,CAAC,CAAC,CAAC;YACL,CAAC,CAAA,CAAC;QACJ,CAAC;QACD,IAAI,EAAE;YACJ,aAAa,EAAE,6BAAoB;SACpC;KACF,CAAC;CACM,CAAC"}
|
|
@@ -4,12 +4,13 @@ exports.childAppProviders = void 0;
|
|
|
4
4
|
const dippy_1 = require("@tinkoff/dippy");
|
|
5
5
|
const tokens_1 = require("../../../di/tokens");
|
|
6
6
|
const configManager_1 = require("../../../config/configManager");
|
|
7
|
+
const detectPortSync_1 = require("../../../utils/detectPortSync");
|
|
7
8
|
exports.childAppProviders = [
|
|
8
9
|
(0, dippy_1.provide)({
|
|
9
10
|
provide: tokens_1.CONFIG_MANAGER_TOKEN,
|
|
10
11
|
useFactory: ({ configEntry, parameters }) => {
|
|
11
12
|
var _a;
|
|
12
|
-
return (0, configManager_1.createConfigManager)(configEntry, Object.assign(Object.assign({}, parameters), { env: 'production', staticPort: (_a = parameters.staticPort) !== null && _a !== void 0 ? _a :
|
|
13
|
+
return (0, configManager_1.createConfigManager)(configEntry, Object.assign(Object.assign({}, parameters), { env: 'production', staticPort: (0, detectPortSync_1.detectPortSync)((_a = parameters.staticPort) !== null && _a !== void 0 ? _a : configManager_1.DEFAULT_STATIC_MODULE_PORT), buildType: 'client' }));
|
|
13
14
|
},
|
|
14
15
|
deps: {
|
|
15
16
|
configEntry: tokens_1.CONFIG_ENTRY_TOKEN,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"child-app.js","sourceRoot":"","sources":["../../../../src/api/start-prod/providers/child-app.ts"],"names":[],"mappings":";;;AACA,0CAAyC;AACzC,+CAI4B;AAC5B,
|
|
1
|
+
{"version":3,"file":"child-app.js","sourceRoot":"","sources":["../../../../src/api/start-prod/providers/child-app.ts"],"names":[],"mappings":";;;AACA,0CAAyC;AACzC,+CAI4B;AAC5B,iEAAgG;AAEhG,kEAA+D;AAElD,QAAA,iBAAiB,GAAwB;IACpD,IAAA,eAAO,EAAC;QACN,OAAO,EAAE,6BAAoB;QAC7B,UAAU,EAAE,CAAC,EAAE,WAAW,EAAE,UAAU,EAAE,EAAE,EAAE;;YAC1C,OAAA,IAAA,mCAAmB,EAAC,WAAkC,kCACjD,UAAU,KACb,GAAG,EAAE,YAAY,EACjB,UAAU,EAAE,IAAA,+BAAc,EAAC,MAAA,UAAU,CAAC,UAAU,mCAAI,0CAA0B,CAAC,EAC/E,SAAS,EAAE,QAAQ,IACnB,CAAA;SAAA;QACJ,IAAI,EAAE;YACJ,WAAW,EAAE,2BAAkB;YAC/B,UAAU,EAAE,iCAAwB;SACrC;KACF,CAAC;CACM,CAAC"}
|
|
@@ -24,16 +24,8 @@ exports.sharedProviders = [
|
|
|
24
24
|
useFactory: ({ staticServer, configManager }) => {
|
|
25
25
|
return function staticServerListen() {
|
|
26
26
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
27
|
-
const { staticHost
|
|
28
|
-
|
|
29
|
-
yield (0, listenServer_1.listenServer)(staticServer, staticHost.replace('localhost', '0.0.0.0'), staticPort);
|
|
30
|
-
}
|
|
31
|
-
catch (error) {
|
|
32
|
-
if (error.code === 'EADDRINUSE') {
|
|
33
|
-
throw new Error(`Address '${staticHost}:${staticPort}' in use, either release this port or use options --staticPort --staticHost`);
|
|
34
|
-
}
|
|
35
|
-
throw error;
|
|
36
|
-
}
|
|
27
|
+
const { staticHost, staticPort } = configManager;
|
|
28
|
+
yield (0, listenServer_1.listenServer)(staticServer, staticHost.replace('localhost', '0.0.0.0'), staticPort);
|
|
37
29
|
});
|
|
38
30
|
};
|
|
39
31
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../../../../src/api/start-prod/providers/shared.ts"],"names":[],"mappings":";;;;AACA,0CAAyC;AACzC,8DAA8B;AAC9B,yEAAgD;AAChD,qEAA4C;AAC5C,wDAAwB;AACxB,sCAA2F;AAC3F,+CAA+E;AAC/E,iEAA8D;AAC9D,6DAA0D;AAC1D,iEAA8D;AAC9D,uDAAqE;AAExD,QAAA,eAAe,GAAwB;IAClD,IAAA,eAAO,EAAC;QACN,OAAO,EAAE,4BAAmB;QAC5B,UAAU,EAAE,2BAAY;KACzB,CAAC;IACF,IAAA,eAAO,EAAC;QACN,OAAO,EAAE,2BAAkB;QAC3B,KAAK,EAAE,IAAI;QACX,UAAU,EAAE,CAAC,EAAE,YAAY,EAAE,aAAa,EAAE,EAAE,EAAE;YAC9C,OAAO,SAAe,kBAAkB;;oBACtC,MAAM,EAAE,UAAU,
|
|
1
|
+
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../../../../src/api/start-prod/providers/shared.ts"],"names":[],"mappings":";;;;AACA,0CAAyC;AACzC,8DAA8B;AAC9B,yEAAgD;AAChD,qEAA4C;AAC5C,wDAAwB;AACxB,sCAA2F;AAC3F,+CAA+E;AAC/E,iEAA8D;AAC9D,6DAA0D;AAC1D,iEAA8D;AAC9D,uDAAqE;AAExD,QAAA,eAAe,GAAwB;IAClD,IAAA,eAAO,EAAC;QACN,OAAO,EAAE,4BAAmB;QAC5B,UAAU,EAAE,2BAAY;KACzB,CAAC;IACF,IAAA,eAAO,EAAC;QACN,OAAO,EAAE,2BAAkB;QAC3B,KAAK,EAAE,IAAI;QACX,U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,CAAC,CAAC;gBAC3C,CAAC,CAAA,CAAC,CAAC;gBAEH,IAAI,IAAA,wBAAa,EAAC,aAAa,CAAC,EAAE;oBAChC,MAAM,GAAG,CAAC,QAAQ,CAAC,gBAAa,EAAE;wBAChC,IAAI,EAAE,aAAa,CAAC,SAAS;wBAC7B,MAAM,EAAE,IAAI,aAAa,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,GAAG;qBAC9D,CAAC,CAAC;iBACJ;qBAAM,IAAI,IAAA,qBAAU,EAAC,aAAa,CAAC,EAAE;oBACpC,MAAM,GAAG,CAAC,QAAQ,CAAC,gBAAa,EAAE;wBAChC,IAAI,EAAE,aAAa,CAAC,SAAS;wBAC7B,MAAM,EAAE,IAAI,aAAa,CAAC,IAAI,GAAG;qBAClC,CAAC,CAAC;iBACJ;gBAED,MAAM,GAAG,CAAC,KAAK,EAAE,CAAC;YACpB,CAAC,CAAA,CAAC;QACJ,CAAC;QACD,IAAI,EAAE;YACJ,YAAY,EAAE,4BAAmB;YACjC,aAAa,EAAE,6BAAoB;SACpC;KACF,CAAC;IACF,IAAA,eAAO,EAAC;QACN,OAAO,EAAE,4BAAmB;QAC5B,KAAK,EAAE,IAAI;QACX,UAAU,EAAE,CAAC,EAAE,YAAY,EAAE,EAAE,EAAE;YAC/B,OAAO,GAAS,EAAE;gBAChB,OAAO,IAAA,uBAAU,EAAC,YAAY,CAAC,CAAC;YAClC,CAAC,CAAA,CAAC;QACJ,CAAC;QACD,IAAI,EAAE;YACJ,YAAY,EAAE,4BAAmB;SAClC;KACF,CAAC;CACM,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../../../../src/builder/webpack/providers/build/client.ts"],"names":[],"mappings":";;;;AACA,0CAAyC;AACzC,4DAA4B;AAC5B,8DAA8B;
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../../../../src/builder/webpack/providers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;;;oBAC5C,IAAI,MAAA,aAAa,CAAC,iBAAiB,0CAAE,OAAO,EAAE;wBAC5C,MAAM,IAAA,uBAAU,EAAC;4BACf,UAAU,EAAE,OAAO;4BACnB,cAAc;4BACd,WAAW,EAAE,sBAAsB;4BACnC,WAAW,EAAE,uDAAuD;yBACrE,CAAC,CAAC;qBACJ;;aACF,CAAC;QACJ,CAAC;QACD,IAAI,EAAE;YACJ,aAAa,EAAE,oCAA2B;YAC1C,OAAO,EAAE,2BAAkB;YAC3B,cAAc,EAAE,4BAAmB;SACpC;KACF,CAAC;IACF,IAAA,eAAO,EAAC;QACN,OAAO,EAAE,8BAAqB;QAC9B,KAAK,EAAE,IAAI;QACX,UAAU,EAAE,CAAC,EAAE,eAAe,EAAE,EAAE,EAAE;YAClC,OAAO,SAAS,YAAY;gBAC1B,OAAO,IAAA,uBAAU,EAAC,eAAe,CAAC,CAAC;YACrC,CAAC,CAAC;QACJ,CAAC;QACD,IAAI,EAAE;YACJ,eAAe,EAAE,sCAA6B;SAC/C;KACF,CAAC;IACF,IAAA,eAAO,EAAC;QACN,OAAO,EAAE,4BAAmB;QAC5B,KAAK,EAAE,IAAI;QACX,UAAU,EAAE,CAAC,EAAE,eAAe,EAAE,EAAE,EAAE;YAClC,OAAO,SAAS,YAAY;gBAC1B,OAAO,IAAA,2BAAY,EAAC,eAAe,CAAC,CAAC;YACvC,CAAC,CAAC;QACJ,CAAC;QACD,IAAI,EAAE;YACJ,eAAe,EAAE,sCAA6B;SAC/C;KACF,CAAC;CACH,CAAC"}
|
|
@@ -34,5 +34,8 @@ export type ConfigManager<C extends ConfigEntry = ConfigEntry, E extends Env = E
|
|
|
34
34
|
withSettings(settings: Settings<E>): ConfigManager<C, E>;
|
|
35
35
|
dehydrate(): [C, Settings<E>];
|
|
36
36
|
};
|
|
37
|
+
export declare const DEFAULT_PORT = 3000;
|
|
38
|
+
export declare const DEFAULT_STATIC_PORT = 4000;
|
|
39
|
+
export declare const DEFAULT_STATIC_MODULE_PORT = 4040;
|
|
37
40
|
export declare const createConfigManager: <C extends ConfigEntry = ConfigEntry, E extends Env = Env>(configEntry: C, settings: Settings<E>) => ConfigManager<C, E>;
|
|
38
41
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createConfigManager = void 0;
|
|
3
|
+
exports.createConfigManager = exports.DEFAULT_STATIC_MODULE_PORT = exports.DEFAULT_STATIC_PORT = exports.DEFAULT_PORT = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const nil_1 = tslib_1.__importDefault(require("@tinkoff/utils/is/nil"));
|
|
6
6
|
const array_1 = tslib_1.__importDefault(require("@tinkoff/utils/is/array"));
|
|
@@ -34,6 +34,9 @@ const omitEnvOptions = (env, options) => {
|
|
|
34
34
|
return value;
|
|
35
35
|
}, options);
|
|
36
36
|
};
|
|
37
|
+
exports.DEFAULT_PORT = 3000;
|
|
38
|
+
exports.DEFAULT_STATIC_PORT = 4000;
|
|
39
|
+
exports.DEFAULT_STATIC_MODULE_PORT = 4040;
|
|
37
40
|
const createConfigManager = (configEntry, settings) => {
|
|
38
41
|
var _a, _b, _c, _d, _e, _f;
|
|
39
42
|
const env = (_a = settings.env) !== null && _a !== void 0 ? _a : 'development';
|
|
@@ -57,7 +60,7 @@ const createConfigManager = (configEntry, settings) => {
|
|
|
57
60
|
fileCache: true, showConfig: false, csr: false }), settings), { env,
|
|
58
61
|
rootDir,
|
|
59
62
|
buildType,
|
|
60
|
-
debug, port: Number((_e = settings.port) !== null && _e !== void 0 ? _e :
|
|
63
|
+
debug, port: Number((_e = settings.port) !== null && _e !== void 0 ? _e : exports.DEFAULT_PORT), staticPort: Number((_f = settings.staticPort) !== null && _f !== void 0 ? _f : (type === 'module' ? exports.DEFAULT_STATIC_MODULE_PORT : exports.DEFAULT_STATIC_PORT)), modern, sourceMap: buildType === 'server' && debug
|
|
61
64
|
? true
|
|
62
65
|
: getOption('sourceMap', [settings, normalizedConfigEntry], false), target, buildPath: '', withSettings(overrideSettings) {
|
|
63
66
|
return (0, exports.createConfigManager)(configEntry, Object.assign(Object.assign({}, settings), overrideSettings));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configManager.js","sourceRoot":"","sources":["../../src/config/configManager.ts"],"names":[],"mappings":";;;;AAAA,wEAA0C;AAC1C,4EAA8C;AAC9C,8EAAgD;AAChD,8EAA8C;AAC9C,4EAA+C;AAC/C,+BAA+B;AAI/B,0DAAoE;AACpE,yCAA2E;AAC3E,mFAAmD;AACnD,4DAAyD;AACzD,6CAA0C;AA6B1C,MAAM,SAAS,GAAG,CAAI,UAAkB,EAAE,IAAW,EAAE,IAAO,EAAK,EAAE;IACnE,MAAM,MAAM,GAAG,IAAA,cAAI,EAAC,UAAU,CAAC,CAAC;IAEhC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QACpC,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;QAE9B,IAAI,CAAC,IAAA,aAAK,EAAC,KAAK,CAAC,EAAE;YACjB,OAAO,KAAK,CAAC;SACd;KACF;IAED,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAUF,MAAM,cAAc,GAAG,CACrB,GAAQ,EACR,OAAU,EACU,EAAE;IACtB,OAAO,IAAA,aAAM,EAAC,CAAC,KAAK,EAAE,EAAE;QACtB,IAAI,IAAA,4BAAmB,EAAC,KAAK,CAAC,EAAE;YAC9B,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC;SACnB;QAED,IAAI,IAAA,gBAAQ,EAAC,KAAK,CAAC,IAAI,CAAC,IAAA,eAAO,EAAC,KAAK,CAAC,EAAE;YACtC,OAAO,cAAc,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;SACnC;QAED,OAAO,KAAK,CAAC;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QAC7B,MAAM,CAAC,SAAS,GAAG,IAAA,cAAO,EAAC,OAAO,EAAE,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;KAClE;SAAM,IAAI,IAAA,mBAAQ,EAAC,MAAM,CAAC,EAAE;QAC3B,MAAM,CAAC,SAAS,GAAG,IAAA,cAAO,EAAC,OAAO,EAAE,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC;KAC/F;IAED,IAAI,MAAM,CAAC,UAAU,EAAE;QACrB,IAAA,uBAAU,EAAC,MAAM,CAAC,CAAC;KACpB;IAED,IAAA,mBAAQ,EAAC,MAAM,CAAC,CAAC;IAEjB,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AA5FW,QAAA,mBAAmB,uBA4F9B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const detectPortSync: (port: number) => number;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.detectPortSync = void 0;
|
|
4
|
+
const child_process_1 = require("child_process");
|
|
5
|
+
const detectPortSync = (port) => {
|
|
6
|
+
const commandResult = (0, child_process_1.execSync)(`npx detect-port ${port}`);
|
|
7
|
+
return parseInt(commandResult.toString('utf-8'), 10);
|
|
8
|
+
};
|
|
9
|
+
exports.detectPortSync = detectPortSync;
|
|
10
|
+
//# sourceMappingURL=detectPortSync.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detectPortSync.js","sourceRoot":"","sources":["../../src/utils/detectPortSync.ts"],"names":[],"mappings":";;;AAAA,iDAAyC;AAElC,MAAM,cAAc,GAAG,CAAC,IAAY,EAAU,EAAE;IACrD,MAAM,aAAa,GAAG,IAAA,wBAAQ,EAAC,mBAAmB,IAAI,EAAE,CAAC,CAAC;IAE1D,OAAO,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,EAAE,CAAC,CAAC;AACvD,CAAC,CAAC;AAJW,QAAA,cAAc,kBAIzB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tramvai/cli",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.66.2",
|
|
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.1",
|
|
73
73
|
"@tramvai/build": "3.1.1",
|
|
74
|
-
"@tramvai/react": "2.
|
|
74
|
+
"@tramvai/react": "2.66.2",
|
|
75
75
|
"@tramvai/tools-check-versions": "0.4.8",
|
|
76
76
|
"@tramvai/tools-migrate": "0.6.10",
|
|
77
77
|
"ajv": "^6.12.6",
|
|
@@ -94,6 +94,7 @@
|
|
|
94
94
|
"css-minimizer-webpack-plugin": "^4.0.0",
|
|
95
95
|
"csso-webpack-plugin": "2.0.0-beta.3",
|
|
96
96
|
"death": "^1.1.0",
|
|
97
|
+
"detect-port": "^1.5.1",
|
|
97
98
|
"execa": "^5.1.1",
|
|
98
99
|
"exit": "^0.1.2",
|
|
99
100
|
"express": "^4.18.1",
|
|
@@ -6,7 +6,10 @@ import type { PromiseType } from 'utility-types';
|
|
|
6
6
|
import { getPort } from '@tramvai/internal-test-utils/utils/getPort';
|
|
7
7
|
import { getServerUrl } from '@tramvai/test-integration';
|
|
8
8
|
import { initPlaywright } from '@tramvai/test-pw';
|
|
9
|
+
import { createServer } from '../utils/createServer';
|
|
10
|
+
import { listenServer } from '../utils/listenServer';
|
|
9
11
|
import { getListeningPort } from '../utils/getListeningPort';
|
|
12
|
+
import { stopServer } from '../utils/stopServer';
|
|
10
13
|
|
|
11
14
|
const FIXTURES_DIR = resolve(__dirname, '__fixtures__');
|
|
12
15
|
|
|
@@ -256,6 +259,39 @@ describe('@tramvai/cli start command', () => {
|
|
|
256
259
|
|
|
257
260
|
return close();
|
|
258
261
|
});
|
|
262
|
+
|
|
263
|
+
it('should start the app on the next available port, if default port is busy', async () => {
|
|
264
|
+
const testServerStub = createServer();
|
|
265
|
+
const testStaticServerStub = createServer();
|
|
266
|
+
|
|
267
|
+
// To avoid situation when two subsequent calls
|
|
268
|
+
// of the `detectPortSync` return the same free port.
|
|
269
|
+
await listenServer(testServerStub, '0.0.0.0', getPort() + 50);
|
|
270
|
+
await listenServer(testStaticServerStub, '0.0.0.0', getPort());
|
|
271
|
+
|
|
272
|
+
const { server, staticServer, close } = await start({
|
|
273
|
+
rootDir: FIXTURES_DIR,
|
|
274
|
+
target: 'app',
|
|
275
|
+
resolveSymlinks: false,
|
|
276
|
+
port: getListeningPort(testServerStub),
|
|
277
|
+
staticPort: getListeningPort(testStaticServerStub),
|
|
278
|
+
});
|
|
279
|
+
|
|
280
|
+
const testServer = supertestByPort(getListeningPort(server));
|
|
281
|
+
const testStatic = supertestByPort(getListeningPort(staticServer));
|
|
282
|
+
|
|
283
|
+
expect(server?.address()).toMatchObject({
|
|
284
|
+
port: expect.any(Number),
|
|
285
|
+
});
|
|
286
|
+
expect(staticServer?.address()).toMatchObject({
|
|
287
|
+
port: expect.any(Number),
|
|
288
|
+
});
|
|
289
|
+
|
|
290
|
+
await testServer.get('/').expect(200);
|
|
291
|
+
await testStatic.get('/').expect(404);
|
|
292
|
+
|
|
293
|
+
return Promise.all([close(), stopServer(testServerStub), stopServer(testStaticServerStub)]);
|
|
294
|
+
});
|
|
259
295
|
});
|
|
260
296
|
|
|
261
297
|
describe('module', () => {
|
|
@@ -277,7 +313,7 @@ describe('@tramvai/cli start command', () => {
|
|
|
277
313
|
});
|
|
278
314
|
|
|
279
315
|
it('should start module by specific config', async () => {
|
|
280
|
-
const staticServerPort =
|
|
316
|
+
const staticServerPort = getPort();
|
|
281
317
|
|
|
282
318
|
const { staticServer, close } = await start({
|
|
283
319
|
config: {
|
|
@@ -1,45 +1,36 @@
|
|
|
1
1
|
import type { Provider } from '@tinkoff/dippy';
|
|
2
|
+
import { provide } from '@tinkoff/dippy';
|
|
3
|
+
|
|
2
4
|
import { INIT_HANDLER_TOKEN, CLOSE_HANDLER_TOKEN } from '../../tokens';
|
|
3
|
-
import {
|
|
5
|
+
import { CONFIG_MANAGER_TOKEN, SERVER_TOKEN } from '../../../../di/tokens';
|
|
4
6
|
import { stopServer } from '../../utils/stopServer';
|
|
5
7
|
import { createServer } from '../../utils/createServer';
|
|
6
8
|
import { listenServer } from '../../utils/listenServer';
|
|
7
|
-
import type { Params } from '../../index';
|
|
8
9
|
|
|
9
10
|
export const serverProviders: readonly Provider[] = [
|
|
10
|
-
{
|
|
11
|
+
provide({
|
|
11
12
|
provide: SERVER_TOKEN,
|
|
12
13
|
useFactory: createServer,
|
|
13
|
-
},
|
|
14
|
-
{
|
|
14
|
+
}),
|
|
15
|
+
provide({
|
|
15
16
|
provide: INIT_HANDLER_TOKEN,
|
|
16
17
|
multi: true,
|
|
17
|
-
useFactory: ({ server,
|
|
18
|
+
useFactory: ({ server, configManager }) => {
|
|
18
19
|
return async function staticServerListen() {
|
|
19
|
-
const { host
|
|
20
|
-
|
|
21
|
-
try {
|
|
22
|
-
await listenServer(server, host, port);
|
|
23
|
-
} catch (error) {
|
|
24
|
-
if ((error as any).code === 'EADDRINUSE') {
|
|
25
|
-
throw new Error(
|
|
26
|
-
`Address '${host}:${port}' in use, either release this port or use options --port --host`
|
|
27
|
-
);
|
|
28
|
-
}
|
|
20
|
+
const { host, port } = configManager;
|
|
29
21
|
|
|
30
|
-
|
|
31
|
-
}
|
|
22
|
+
await listenServer(server, host, port);
|
|
32
23
|
};
|
|
33
24
|
},
|
|
34
25
|
deps: {
|
|
35
26
|
server: SERVER_TOKEN,
|
|
36
|
-
|
|
27
|
+
configManager: CONFIG_MANAGER_TOKEN,
|
|
37
28
|
},
|
|
38
|
-
},
|
|
39
|
-
{
|
|
29
|
+
}),
|
|
30
|
+
provide({
|
|
40
31
|
provide: CLOSE_HANDLER_TOKEN,
|
|
41
32
|
multi: true,
|
|
42
|
-
useFactory: ({ server }
|
|
33
|
+
useFactory: ({ server }) => {
|
|
43
34
|
return () => {
|
|
44
35
|
return stopServer(server);
|
|
45
36
|
};
|
|
@@ -47,5 +38,5 @@ export const serverProviders: readonly Provider[] = [
|
|
|
47
38
|
deps: {
|
|
48
39
|
server: SERVER_TOKEN,
|
|
49
40
|
},
|
|
50
|
-
},
|
|
41
|
+
}),
|
|
51
42
|
] as const;
|
|
@@ -1,88 +1,62 @@
|
|
|
1
1
|
import type { Provider } from '@tinkoff/dippy';
|
|
2
|
+
import { provide } from '@tinkoff/dippy';
|
|
3
|
+
|
|
2
4
|
import { CLOSE_HANDLER_TOKEN, INIT_HANDLER_TOKEN } from '../../tokens';
|
|
3
5
|
import {
|
|
4
6
|
CONFIG_MANAGER_TOKEN,
|
|
5
7
|
CONFIG_ENTRY_TOKEN,
|
|
6
8
|
COMMAND_PARAMETERS_TOKEN,
|
|
7
|
-
SERVER_TOKEN,
|
|
8
9
|
STATIC_SERVER_TOKEN,
|
|
9
10
|
} from '../../../../di/tokens';
|
|
10
11
|
import { stopServer } from '../../utils/stopServer';
|
|
11
12
|
import type { ApplicationConfigEntry } from '../../../../typings/configEntry/application';
|
|
12
|
-
import
|
|
13
|
-
|
|
13
|
+
import {
|
|
14
|
+
createConfigManager,
|
|
15
|
+
DEFAULT_PORT,
|
|
16
|
+
DEFAULT_STATIC_PORT,
|
|
17
|
+
} from '../../../../config/configManager';
|
|
14
18
|
import { createServer } from '../../utils/createServer';
|
|
15
19
|
import { listenServer } from '../../utils/listenServer';
|
|
16
|
-
import {
|
|
20
|
+
import { detectPortSync } from '../../../../utils/detectPortSync';
|
|
17
21
|
|
|
18
22
|
export const sharedProviders: readonly Provider[] = [
|
|
19
|
-
{
|
|
23
|
+
provide({
|
|
20
24
|
provide: CONFIG_MANAGER_TOKEN,
|
|
21
|
-
useFactory: ({
|
|
22
|
-
configEntry,
|
|
23
|
-
parameters,
|
|
24
|
-
server,
|
|
25
|
-
staticServer,
|
|
26
|
-
}: {
|
|
27
|
-
configEntry: ApplicationConfigEntry;
|
|
28
|
-
parameters: Params;
|
|
29
|
-
server: typeof SERVER_TOKEN;
|
|
30
|
-
staticServer: typeof STATIC_SERVER_TOKEN;
|
|
31
|
-
}) => {
|
|
32
|
-
return createConfigManager(configEntry, {
|
|
25
|
+
useFactory: ({ configEntry, parameters }) =>
|
|
26
|
+
createConfigManager(configEntry as ApplicationConfigEntry, {
|
|
33
27
|
...parameters,
|
|
34
28
|
env: 'development',
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
});
|
|
39
|
-
},
|
|
29
|
+
port: detectPortSync(parameters.port ?? DEFAULT_PORT),
|
|
30
|
+
staticPort: detectPortSync(parameters.staticPort ?? DEFAULT_STATIC_PORT),
|
|
31
|
+
}),
|
|
40
32
|
deps: {
|
|
41
33
|
configEntry: CONFIG_ENTRY_TOKEN,
|
|
42
34
|
parameters: COMMAND_PARAMETERS_TOKEN,
|
|
43
|
-
staticServer: STATIC_SERVER_TOKEN,
|
|
44
|
-
server: { token: SERVER_TOKEN, optional: true },
|
|
45
35
|
},
|
|
46
|
-
},
|
|
47
|
-
{
|
|
36
|
+
}),
|
|
37
|
+
provide({
|
|
48
38
|
provide: STATIC_SERVER_TOKEN,
|
|
49
39
|
useFactory: createServer,
|
|
50
|
-
},
|
|
51
|
-
{
|
|
40
|
+
}),
|
|
41
|
+
provide({
|
|
52
42
|
provide: INIT_HANDLER_TOKEN,
|
|
53
43
|
multi: true,
|
|
54
|
-
useFactory: ({
|
|
55
|
-
staticServer,
|
|
56
|
-
parameters,
|
|
57
|
-
}: {
|
|
58
|
-
staticServer: typeof STATIC_SERVER_TOKEN;
|
|
59
|
-
parameters: Params;
|
|
60
|
-
}) => {
|
|
44
|
+
useFactory: ({ configManager, staticServer }) => {
|
|
61
45
|
return async function staticServerListen() {
|
|
62
|
-
const { staticHost
|
|
63
|
-
|
|
64
|
-
try {
|
|
65
|
-
await listenServer(staticServer, staticHost.replace('localhost', '0.0.0.0'), staticPort);
|
|
66
|
-
} catch (error) {
|
|
67
|
-
if ((error as any).code === 'EADDRINUSE') {
|
|
68
|
-
throw new Error(
|
|
69
|
-
`Address '${staticHost}:${staticPort}' in use, either release this port or use options --staticPort --staticHost`
|
|
70
|
-
);
|
|
71
|
-
}
|
|
46
|
+
const { staticHost, staticPort } = configManager;
|
|
72
47
|
|
|
73
|
-
|
|
74
|
-
}
|
|
48
|
+
await listenServer(staticServer, staticHost.replace('localhost', '0.0.0.0'), staticPort);
|
|
75
49
|
};
|
|
76
50
|
},
|
|
77
51
|
deps: {
|
|
78
52
|
staticServer: STATIC_SERVER_TOKEN,
|
|
79
|
-
|
|
53
|
+
configManager: CONFIG_MANAGER_TOKEN,
|
|
80
54
|
},
|
|
81
|
-
},
|
|
82
|
-
{
|
|
55
|
+
}),
|
|
56
|
+
provide({
|
|
83
57
|
provide: CLOSE_HANDLER_TOKEN,
|
|
84
58
|
multi: true,
|
|
85
|
-
useFactory: ({ staticServer }
|
|
59
|
+
useFactory: ({ staticServer }) => {
|
|
86
60
|
return () => {
|
|
87
61
|
return stopServer(staticServer);
|
|
88
62
|
};
|
|
@@ -90,5 +64,5 @@ export const sharedProviders: readonly Provider[] = [
|
|
|
90
64
|
deps: {
|
|
91
65
|
staticServer: STATIC_SERVER_TOKEN,
|
|
92
66
|
},
|
|
93
|
-
},
|
|
67
|
+
}),
|
|
94
68
|
] as const;
|
|
@@ -8,68 +8,50 @@ import {
|
|
|
8
8
|
STATIC_SERVER_TOKEN,
|
|
9
9
|
} from '../../../../di/tokens';
|
|
10
10
|
import type { ChildAppConfigEntry } from '../../../../typings/configEntry/child-app';
|
|
11
|
-
import type { Params } from '../../index';
|
|
12
11
|
import { closeWorkerPoolTranspiler } from '../../../../library/webpack/utils/workersPool';
|
|
13
12
|
import { stopServer } from '../../utils/stopServer';
|
|
14
13
|
import { createServer } from '../../utils/createServer';
|
|
15
14
|
import { listenServer } from '../../utils/listenServer';
|
|
16
|
-
import { createConfigManager } from '../../../../config/configManager';
|
|
15
|
+
import { createConfigManager, DEFAULT_STATIC_MODULE_PORT } from '../../../../config/configManager';
|
|
16
|
+
import { detectPortSync } from '../../../../utils/detectPortSync';
|
|
17
17
|
|
|
18
18
|
export const sharedProviders: readonly Provider[] = [
|
|
19
19
|
provide({
|
|
20
20
|
provide: CONFIG_MANAGER_TOKEN,
|
|
21
|
-
useFactory: ({ configEntry, parameters }) =>
|
|
22
|
-
|
|
21
|
+
useFactory: ({ configEntry, parameters }) =>
|
|
22
|
+
createConfigManager(configEntry as ChildAppConfigEntry, {
|
|
23
23
|
...parameters,
|
|
24
24
|
env: 'development',
|
|
25
|
-
port: parameters.port ??
|
|
26
|
-
|
|
27
|
-
});
|
|
28
|
-
},
|
|
25
|
+
port: detectPortSync(parameters.port ?? DEFAULT_STATIC_MODULE_PORT),
|
|
26
|
+
}),
|
|
29
27
|
deps: {
|
|
30
28
|
configEntry: CONFIG_ENTRY_TOKEN,
|
|
31
29
|
parameters: COMMAND_PARAMETERS_TOKEN,
|
|
32
30
|
},
|
|
33
31
|
}),
|
|
34
|
-
{
|
|
32
|
+
provide({
|
|
35
33
|
provide: STATIC_SERVER_TOKEN,
|
|
36
34
|
useFactory: createServer,
|
|
37
|
-
},
|
|
38
|
-
{
|
|
35
|
+
}),
|
|
36
|
+
provide({
|
|
39
37
|
provide: INIT_HANDLER_TOKEN,
|
|
40
38
|
multi: true,
|
|
41
|
-
useFactory: ({
|
|
42
|
-
staticServer,
|
|
43
|
-
parameters,
|
|
44
|
-
}: {
|
|
45
|
-
staticServer: typeof STATIC_SERVER_TOKEN;
|
|
46
|
-
parameters: Params;
|
|
47
|
-
}) => {
|
|
39
|
+
useFactory: ({ staticServer, configManager }) => {
|
|
48
40
|
return async function staticServerListen() {
|
|
49
|
-
const { host
|
|
50
|
-
|
|
51
|
-
try {
|
|
52
|
-
await listenServer(staticServer, host, port);
|
|
53
|
-
} catch (error) {
|
|
54
|
-
if ((error as any).code === 'EADDRINUSE') {
|
|
55
|
-
throw new Error(
|
|
56
|
-
`Address '${host}:${port}' in use, either release this port or use options --port --host`
|
|
57
|
-
);
|
|
58
|
-
}
|
|
41
|
+
const { host, port } = configManager;
|
|
59
42
|
|
|
60
|
-
|
|
61
|
-
}
|
|
43
|
+
await listenServer(staticServer, host, port);
|
|
62
44
|
};
|
|
63
45
|
},
|
|
64
46
|
deps: {
|
|
65
47
|
staticServer: STATIC_SERVER_TOKEN,
|
|
66
|
-
|
|
48
|
+
configManager: CONFIG_MANAGER_TOKEN,
|
|
67
49
|
},
|
|
68
|
-
},
|
|
69
|
-
{
|
|
50
|
+
}),
|
|
51
|
+
provide({
|
|
70
52
|
provide: CLOSE_HANDLER_TOKEN,
|
|
71
53
|
multi: true,
|
|
72
|
-
useFactory: ({ staticServer }
|
|
54
|
+
useFactory: ({ staticServer }) => {
|
|
73
55
|
return () => {
|
|
74
56
|
return stopServer(staticServer);
|
|
75
57
|
};
|
|
@@ -77,7 +59,7 @@ export const sharedProviders: readonly Provider[] = [
|
|
|
77
59
|
deps: {
|
|
78
60
|
staticServer: STATIC_SERVER_TOKEN,
|
|
79
61
|
},
|
|
80
|
-
},
|
|
62
|
+
}),
|
|
81
63
|
provide({
|
|
82
64
|
provide: CLOSE_HANDLER_TOKEN,
|
|
83
65
|
multi: true,
|
|
@@ -7,25 +7,23 @@ import {
|
|
|
7
7
|
COMMAND_PARAMETERS_TOKEN,
|
|
8
8
|
STATIC_SERVER_TOKEN,
|
|
9
9
|
} from '../../../../di/tokens';
|
|
10
|
-
import
|
|
11
|
-
import { createConfigManager } from '../../../../config/configManager';
|
|
10
|
+
import { createConfigManager, DEFAULT_STATIC_MODULE_PORT } from '../../../../config/configManager';
|
|
12
11
|
import { closeWorkerPoolTranspiler } from '../../../../library/webpack/utils/workersPool';
|
|
13
12
|
import { stopServer } from '../../utils/stopServer';
|
|
14
13
|
import { createServer } from '../../utils/createServer';
|
|
15
14
|
import { listenServer } from '../../utils/listenServer';
|
|
15
|
+
import { detectPortSync } from '../../../../utils/detectPortSync';
|
|
16
16
|
import type { ModuleConfigEntry } from '../../../../typings/configEntry/module';
|
|
17
17
|
|
|
18
18
|
export const sharedProviders: readonly Provider[] = [
|
|
19
19
|
provide({
|
|
20
20
|
provide: CONFIG_MANAGER_TOKEN,
|
|
21
|
-
useFactory: ({ configEntry, parameters }) =>
|
|
22
|
-
|
|
21
|
+
useFactory: ({ configEntry, parameters }) =>
|
|
22
|
+
createConfigManager(configEntry as ModuleConfigEntry, {
|
|
23
23
|
...parameters,
|
|
24
24
|
env: 'development',
|
|
25
|
-
port: parameters.port ??
|
|
26
|
-
|
|
27
|
-
});
|
|
28
|
-
},
|
|
25
|
+
port: detectPortSync(parameters.port ?? DEFAULT_STATIC_MODULE_PORT),
|
|
26
|
+
}),
|
|
29
27
|
deps: {
|
|
30
28
|
configEntry: CONFIG_ENTRY_TOKEN,
|
|
31
29
|
parameters: COMMAND_PARAMETERS_TOKEN,
|
|
@@ -38,26 +36,16 @@ export const sharedProviders: readonly Provider[] = [
|
|
|
38
36
|
provide({
|
|
39
37
|
provide: INIT_HANDLER_TOKEN,
|
|
40
38
|
multi: true,
|
|
41
|
-
useFactory: ({ staticServer,
|
|
39
|
+
useFactory: ({ staticServer, configManager }) => {
|
|
42
40
|
return async function staticServerListen() {
|
|
43
|
-
const { host
|
|
44
|
-
|
|
45
|
-
try {
|
|
46
|
-
await listenServer(staticServer, host, port);
|
|
47
|
-
} catch (error) {
|
|
48
|
-
if ((error as any).code === 'EADDRINUSE') {
|
|
49
|
-
throw new Error(
|
|
50
|
-
`Address '${host}:${port}' in use, either release this port or use options --port --host`
|
|
51
|
-
);
|
|
52
|
-
}
|
|
41
|
+
const { host, port } = configManager;
|
|
53
42
|
|
|
54
|
-
|
|
55
|
-
}
|
|
43
|
+
await listenServer(staticServer, host, port);
|
|
56
44
|
};
|
|
57
45
|
},
|
|
58
46
|
deps: {
|
|
59
47
|
staticServer: STATIC_SERVER_TOKEN,
|
|
60
|
-
|
|
48
|
+
configManager: CONFIG_MANAGER_TOKEN,
|
|
61
49
|
},
|
|
62
50
|
}),
|
|
63
51
|
provide({
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import type { Server } from 'net';
|
|
2
2
|
|
|
3
|
-
export const listenServer = (server: Server, host: string, port: number) => {
|
|
3
|
+
export const listenServer = async (server: Server, host: string, port: number): Promise<void> => {
|
|
4
4
|
return new Promise<void>((resolve, reject) => {
|
|
5
5
|
server.once('error', (error) => {
|
|
6
6
|
reject(error);
|
|
7
7
|
});
|
|
8
|
+
|
|
8
9
|
server.listen(port, host, () => {
|
|
9
10
|
resolve();
|
|
10
11
|
});
|
|
@@ -11,23 +11,27 @@ import type { Params } from '../index';
|
|
|
11
11
|
import type { ConfigEntry } from '../../../typings/configEntry/common';
|
|
12
12
|
import { CLOSE_HANDLER_TOKEN, SERVER_PROCESS_TOKEN } from '../tokens';
|
|
13
13
|
import { DEBUG_ARGV } from '../../../config/constants';
|
|
14
|
+
import { detectPortSync } from '../../../utils/detectPortSync';
|
|
14
15
|
import { safeRequire } from '../../../utils/safeRequire';
|
|
15
16
|
import type { ConfigManager } from '../../../config/configManager';
|
|
16
|
-
import {
|
|
17
|
+
import {
|
|
18
|
+
createConfigManager,
|
|
19
|
+
DEFAULT_PORT,
|
|
20
|
+
DEFAULT_STATIC_PORT,
|
|
21
|
+
} from '../../../config/configManager';
|
|
17
22
|
import type { ApplicationConfigEntry } from '../../../typings/configEntry/application';
|
|
18
23
|
|
|
19
24
|
export const applicationsProviders: readonly Provider[] = [
|
|
20
25
|
provide({
|
|
21
26
|
provide: CONFIG_MANAGER_TOKEN,
|
|
22
|
-
useFactory: ({ configEntry, parameters }: { configEntry: ConfigEntry; parameters: Params }) =>
|
|
23
|
-
|
|
27
|
+
useFactory: ({ configEntry, parameters }: { configEntry: ConfigEntry; parameters: Params }) =>
|
|
28
|
+
createConfigManager(configEntry, {
|
|
24
29
|
...parameters,
|
|
25
30
|
env: 'production',
|
|
26
|
-
port: parameters.port ?? 3000,
|
|
27
|
-
staticPort: parameters.staticPort ?? 4000,
|
|
28
31
|
buildType: 'client',
|
|
29
|
-
|
|
30
|
-
|
|
32
|
+
port: detectPortSync(parameters.port ?? DEFAULT_PORT),
|
|
33
|
+
staticPort: detectPortSync(parameters.staticPort ?? DEFAULT_STATIC_PORT),
|
|
34
|
+
}),
|
|
31
35
|
deps: {
|
|
32
36
|
configEntry: CONFIG_ENTRY_TOKEN,
|
|
33
37
|
parameters: COMMAND_PARAMETERS_TOKEN,
|
|
@@ -5,20 +5,20 @@ import {
|
|
|
5
5
|
CONFIG_ENTRY_TOKEN,
|
|
6
6
|
CONFIG_MANAGER_TOKEN,
|
|
7
7
|
} from '../../../di/tokens';
|
|
8
|
-
import { createConfigManager } from '../../../config/configManager';
|
|
8
|
+
import { createConfigManager, DEFAULT_STATIC_MODULE_PORT } from '../../../config/configManager';
|
|
9
9
|
import type { ChildAppConfigEntry } from '../../../typings/configEntry/child-app';
|
|
10
|
+
import { detectPortSync } from '../../../utils/detectPortSync';
|
|
10
11
|
|
|
11
12
|
export const childAppProviders: readonly Provider[] = [
|
|
12
13
|
provide({
|
|
13
14
|
provide: CONFIG_MANAGER_TOKEN,
|
|
14
|
-
useFactory: ({ configEntry, parameters }) =>
|
|
15
|
-
|
|
15
|
+
useFactory: ({ configEntry, parameters }) =>
|
|
16
|
+
createConfigManager(configEntry as ChildAppConfigEntry, {
|
|
16
17
|
...parameters,
|
|
17
18
|
env: 'production',
|
|
18
|
-
staticPort: parameters.staticPort ??
|
|
19
|
+
staticPort: detectPortSync(parameters.staticPort ?? DEFAULT_STATIC_MODULE_PORT),
|
|
19
20
|
buildType: 'client',
|
|
20
|
-
})
|
|
21
|
-
},
|
|
21
|
+
}),
|
|
22
22
|
deps: {
|
|
23
23
|
configEntry: CONFIG_ENTRY_TOKEN,
|
|
24
24
|
parameters: COMMAND_PARAMETERS_TOKEN,
|
|
@@ -21,19 +21,9 @@ export const sharedProviders: readonly Provider[] = [
|
|
|
21
21
|
multi: true,
|
|
22
22
|
useFactory: ({ staticServer, configManager }) => {
|
|
23
23
|
return async function staticServerListen() {
|
|
24
|
-
const { staticHost
|
|
24
|
+
const { staticHost, staticPort } = configManager;
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
await listenServer(staticServer, staticHost.replace('localhost', '0.0.0.0'), staticPort);
|
|
28
|
-
} catch (error) {
|
|
29
|
-
if ((error as any).code === 'EADDRINUSE') {
|
|
30
|
-
throw new Error(
|
|
31
|
-
`Address '${staticHost}:${staticPort}' in use, either release this port or use options --staticPort --staticHost`
|
|
32
|
-
);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
throw error;
|
|
36
|
-
}
|
|
26
|
+
await listenServer(staticServer, staticHost.replace('localhost', '0.0.0.0'), staticPort);
|
|
37
27
|
};
|
|
38
28
|
},
|
|
39
29
|
deps: {
|
|
@@ -2,7 +2,6 @@ import type { Provider } from '@tinkoff/dippy';
|
|
|
2
2
|
import { provide } from '@tinkoff/dippy';
|
|
3
3
|
import rimraf from 'rimraf';
|
|
4
4
|
import webpack from 'webpack';
|
|
5
|
-
import type { ConfigManager } from '../../../../config/configManager';
|
|
6
5
|
import {
|
|
7
6
|
CLI_PACKAGE_MANAGER,
|
|
8
7
|
CLI_ROOT_DIR_TOKEN,
|
|
@@ -90,6 +90,10 @@ export type ConfigManager<
|
|
|
90
90
|
dehydrate(): [C, Settings<E>];
|
|
91
91
|
};
|
|
92
92
|
|
|
93
|
+
export const DEFAULT_PORT = 3000;
|
|
94
|
+
export const DEFAULT_STATIC_PORT = 4000;
|
|
95
|
+
export const DEFAULT_STATIC_MODULE_PORT = 4040;
|
|
96
|
+
|
|
93
97
|
export const createConfigManager = <C extends ConfigEntry = ConfigEntry, E extends Env = Env>(
|
|
94
98
|
configEntry: C,
|
|
95
99
|
settings: Settings<E>
|
|
@@ -134,8 +138,10 @@ export const createConfigManager = <C extends ConfigEntry = ConfigEntry, E exten
|
|
|
134
138
|
rootDir,
|
|
135
139
|
buildType,
|
|
136
140
|
debug,
|
|
137
|
-
port: Number(settings.port ??
|
|
138
|
-
staticPort: Number(
|
|
141
|
+
port: Number(settings.port ?? DEFAULT_PORT),
|
|
142
|
+
staticPort: Number(
|
|
143
|
+
settings.staticPort ?? (type === 'module' ? DEFAULT_STATIC_MODULE_PORT : DEFAULT_STATIC_PORT)
|
|
144
|
+
),
|
|
139
145
|
modern,
|
|
140
146
|
sourceMap:
|
|
141
147
|
buildType === 'server' && debug
|