@tramvai/cli 2.147.1 → 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-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/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/config.js +8 -2
- package/lib/models/config.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/topLevelSchema.d.ts +3 -0
- package/lib/schema/topLevelSchema.js +3 -0
- package/lib/schema/topLevelSchema.js.map +1 -1
- 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 +4 -5
- package/schema.json +3 -0
- 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/config.spec.ts +83 -0
- package/src/models/config.ts +8 -2
- package/src/models/port-manager.ts +79 -0
- package/src/schema/topLevelSchema.js +3 -0
- package/src/schema/tramvai.spec.ts +8 -2
- package/src/utils/detectPortSync.ts +0 -24
package/lib/models/config.js
CHANGED
|
@@ -62,8 +62,14 @@ class ConfigManager {
|
|
|
62
62
|
const entry = configParameters.projects[projectName];
|
|
63
63
|
configParameters.projects[projectName] = (0, merge_1.merge)(projectsConfig, entry);
|
|
64
64
|
});
|
|
65
|
-
const ajv = new ajv_1.default({
|
|
66
|
-
|
|
65
|
+
const ajv = new ajv_1.default({
|
|
66
|
+
useDefaults: true,
|
|
67
|
+
allowUnionTypes: true,
|
|
68
|
+
strict: true,
|
|
69
|
+
strictSchema: false,
|
|
70
|
+
});
|
|
71
|
+
ajv.addKeyword({
|
|
72
|
+
keyword: 'cli_overridable',
|
|
67
73
|
modifying: true,
|
|
68
74
|
errors: false,
|
|
69
75
|
validate(schemaValue, currentValue, propSchema) {
|
package/lib/models/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/models/config.ts"],"names":[],"mappings":";;;;AAAA,sDAAsB;AACtB,8EAAgD;AAChD,4EAA8C;AAC9C,yEAAyC;AAGzC,0DAAoE;AACpE,gEAA6D;AAC7D,0CAAuC;AACvC,+CAA2C;AAE3C,MAAa,aAAa;IAKxB,YAAY,EAAE,MAAM,EAAE,cAAc,EAAoD;QACtF,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;QAErC,IAAI,CAAC,cAAc,EAAE,CAAC;IACxB,CAAC;IAED,GAAG;QACD,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED,GAAG,CAAC,MAAc;QAChB,IAAI,CAAC,MAAM,GAAG,IAAA,aAAK,EAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC3C,CAAC;IAED,UAAU,CAAC,WAAmB;QAC5B,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;QAEhD,IAAI,CAAC,KAAK,EAAE;YACV,OAAO,CAAC,KAAK,CAAC,yCAAyC,EAAE,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAA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,CAAC;QACrC,MAAM,KAAK,GAAG,QAAQ,CAAC,gBAAgB,CAAC,CAAC;QAEzC,8EAA8E;QAC9E,IAAI,CAAC,MAAM,GAAG,gBAAgB,CAAC;QAE/B,IAAI,CAAC,KAAK,EAAE;YACV,MAAM,aAAa,GAAG,QAAQ,CAAC,MAAM;iBAClC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;gBACb,IAAI,OAAO,GAAG,GAAG,CAAC,UAAU,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;gBAEtC,IAAI,KAAK,CAAC,OAAO,KAAK,uCAAuC,EAAE;oBAC7D,OAAO,IAAI,wBAAyB,KAAK,CAAC,MAAc,CAAC,kBAAkB,YAAY,CAAC;iBACzF;gBAED,OAAO,OAAO,CAAC;YACjB,CAAC,CAAC;iBACD,IAAI,CAAC,IAAI,CAAC,CAAC;YAEd,MAAM,IAAI,KAAK,CAAC;;;EAGpB,aAAa;CACd,CAAC,CAAC;SACE;IACH,CAAC;CACF;AA5ID,sCA4IC"}
|
|
@@ -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,CAAC,aAAa,CAAC,IAAI,KAAK,CAAC,EAAE;gBAC1E,8CAA8C;gBAC9C,IAAI,CAAC,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;aACnD;YAED,IAAI,IAAI,CAAC,aAAa,CAAC,UAAU,KAAK,SAAS,IAAI,IAAI,CAAC,aAAa,CAAC,UAAU,KAAK,CAAC,EAAE;gBACtF,8CAA8C;gBAC9C,IAAI,CAAC,UAAU,GAAG,QAAQ,CAAC,IAAI,CAAC,aAAa,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;aAC/D;YAED,QAAQ,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE;gBAC7B,KAAK,WAAW;oBACd,MAAM,IAAI,CAAC,WAAW,EAAE,CAAC;oBACzB,MAAM;gBAER,KAAK,QAAQ;oBACX,MAAM,IAAI,CAAC,SAAS,EAAE,CAAC;oBACvB,MAAM;gBAER,KAAK,aAA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|
|
17
17
|
if: {
|
|
18
|
+
type: string;
|
|
18
19
|
properties: {
|
|
19
20
|
type: {
|
|
20
21
|
const: string;
|
|
@@ -24,6 +25,7 @@ declare function _exports(autogeneratedSchema: any): {
|
|
|
24
25
|
then: any;
|
|
25
26
|
else: {
|
|
26
27
|
if: {
|
|
28
|
+
type: string;
|
|
27
29
|
properties: {
|
|
28
30
|
type: {
|
|
29
31
|
const: string;
|
|
@@ -33,6 +35,7 @@ declare function _exports(autogeneratedSchema: any): {
|
|
|
33
35
|
then: any;
|
|
34
36
|
else: {
|
|
35
37
|
if: {
|
|
38
|
+
type: string;
|
|
36
39
|
properties: {
|
|
37
40
|
type: {
|
|
38
41
|
const: string;
|
|
@@ -18,6 +18,7 @@ module.exports = (autogeneratedSchema) => {
|
|
|
18
18
|
patternProperties: {
|
|
19
19
|
'^[$a-zA-Z_-][0-9a-zA-Z_$-]*$': {
|
|
20
20
|
if: {
|
|
21
|
+
type: 'object',
|
|
21
22
|
properties: {
|
|
22
23
|
type: { const: 'application' },
|
|
23
24
|
},
|
|
@@ -25,6 +26,7 @@ module.exports = (autogeneratedSchema) => {
|
|
|
25
26
|
then: autogeneratedSchema.properties.application,
|
|
26
27
|
else: {
|
|
27
28
|
if: {
|
|
29
|
+
type: 'object',
|
|
28
30
|
properties: {
|
|
29
31
|
type: { const: 'module' },
|
|
30
32
|
},
|
|
@@ -32,6 +34,7 @@ module.exports = (autogeneratedSchema) => {
|
|
|
32
34
|
then: autogeneratedSchema.properties.module,
|
|
33
35
|
else: {
|
|
34
36
|
if: {
|
|
37
|
+
type: 'object',
|
|
35
38
|
properties: {
|
|
36
39
|
type: { const: 'child-app' },
|
|
37
40
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"topLevelSchema.js","sourceRoot":"","sources":["../../src/schema/topLevelSchema.js"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,GAAG,CAAC,mBAAmB,EAAE,EAAE;IACvC,6CAA6C;IAC7C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CACD,IAAI,EAAE,mBAAmB,CAAC,UAAU,CAAC,WAAW,CAAC;gCACjD,IAAI,EAAE,mBAAmB,CAAC,UAAU,CAAC,OAAO;6BAC7C;yBACF;qBACF;iBACF;gBACD,OAAO,EAAE,EAAE;aACZ;YACD,UAAU,EAAE;gBACV,IAAI,EAAE,QAAQ;gBACd,oBAAoB,EAAE,KAAK;gBAC3B,UAAU,EAAE;oBACV,aAAa,EAAE;wBACb,KAAK,EAAE,wDAAwD;wBAC/D,IAAI,EAAE,OAAO;wBACb,KAAK,EAAE;4BACL,IAAI,EAAE,QAAQ;yBACf;qBACF;oBACD,aAAa,EAAE;wBACb,KAAK,EAAE,qDAAqD;wBAC5D,IAAI,EAAE,OAAO;wBACb,KAAK,EAAE;4BACL,IAAI,EAAE,QAAQ;yBACf;qBACF;iBACF;aACF;SACF;KACF,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -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.
|
|
3
|
+
"version": "2.148.1",
|
|
4
4
|
"description": "Cli инструмент для сборки и запуска приложений",
|
|
5
5
|
"files": [
|
|
6
6
|
"src",
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"@svgr/webpack": "^8.1.0",
|
|
63
63
|
"@tinkoff/browserslist-config": "0.2.7",
|
|
64
64
|
"@tinkoff/dippy": "0.8.15",
|
|
65
|
-
"@tinkoff/is-modern-lib": "2.0.
|
|
65
|
+
"@tinkoff/is-modern-lib": "2.0.13",
|
|
66
66
|
"@tinkoff/logger": "0.10.67",
|
|
67
67
|
"@tinkoff/minicss-class-generator": "0.2.5",
|
|
68
68
|
"@tinkoff/package-manager-wrapper": "0.1.9",
|
|
@@ -71,10 +71,10 @@
|
|
|
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.
|
|
74
|
+
"@tramvai/react": "2.148.1",
|
|
75
75
|
"@tramvai/tools-check-versions": "0.4.18",
|
|
76
76
|
"@tramvai/tools-migrate": "0.6.22",
|
|
77
|
-
"ajv": "^
|
|
77
|
+
"ajv": "^8.12.0",
|
|
78
78
|
"ansi-escapes": "^4.3.2",
|
|
79
79
|
"autoprefixer": "^10.4.8",
|
|
80
80
|
"babel-loader": "^8.2.5",
|
|
@@ -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
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
"patternProperties": {
|
|
18
18
|
"^[$a-zA-Z_-][0-9a-zA-Z_$-]*$": {
|
|
19
19
|
"if": {
|
|
20
|
+
"type": "object",
|
|
20
21
|
"properties": {
|
|
21
22
|
"type": {
|
|
22
23
|
"const": "application"
|
|
@@ -1433,6 +1434,7 @@
|
|
|
1433
1434
|
},
|
|
1434
1435
|
"else": {
|
|
1435
1436
|
"if": {
|
|
1437
|
+
"type": "object",
|
|
1436
1438
|
"properties": {
|
|
1437
1439
|
"type": {
|
|
1438
1440
|
"const": "module"
|
|
@@ -2102,6 +2104,7 @@
|
|
|
2102
2104
|
},
|
|
2103
2105
|
"else": {
|
|
2104
2106
|
"if": {
|
|
2107
|
+
"type": "object",
|
|
2105
2108
|
"properties": {
|
|
2106
2109
|
"type": {
|
|
2107
2110
|
"const": "child-app"
|
|
@@ -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':
|
|
@@ -6,39 +6,31 @@ import {
|
|
|
6
6
|
COMMAND_PARAMETERS_TOKEN,
|
|
7
7
|
CONFIG_ENTRY_TOKEN,
|
|
8
8
|
CONFIG_MANAGER_TOKEN,
|
|
9
|
+
PORT_MANAGER_TOKEN,
|
|
9
10
|
} from '../../../di/tokens';
|
|
10
|
-
import type {
|
|
11
|
-
import type { ConfigEntry } from '../../../typings/configEntry/common';
|
|
11
|
+
import type { ApplicationConfigEntry } from '../../../typings/configEntry/application';
|
|
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';
|
|
15
14
|
import { safeRequire } from '../../../utils/safeRequire';
|
|
16
15
|
import type { ConfigManager } from '../../../config/configManager';
|
|
17
|
-
import {
|
|
18
|
-
createConfigManager,
|
|
19
|
-
DEFAULT_PORT,
|
|
20
|
-
DEFAULT_STATIC_PORT,
|
|
21
|
-
} from '../../../config/configManager';
|
|
22
|
-
import type { ApplicationConfigEntry } from '../../../typings/configEntry/application';
|
|
16
|
+
import { createConfigManager } from '../../../config/configManager';
|
|
23
17
|
|
|
24
18
|
export const applicationsProviders: readonly Provider[] = [
|
|
25
19
|
provide({
|
|
26
20
|
provide: CONFIG_MANAGER_TOKEN,
|
|
27
|
-
useFactory: ({ configEntry, parameters
|
|
28
|
-
createConfigManager(configEntry, {
|
|
21
|
+
useFactory: ({ configEntry, parameters, portManager }) =>
|
|
22
|
+
createConfigManager(configEntry as ApplicationConfigEntry, {
|
|
29
23
|
...parameters,
|
|
30
24
|
appEnv: parameters.env,
|
|
31
25
|
env: 'production',
|
|
32
26
|
buildType: 'client',
|
|
33
|
-
port:
|
|
34
|
-
staticPort:
|
|
35
|
-
request: parameters.staticPort,
|
|
36
|
-
fallback: DEFAULT_STATIC_PORT,
|
|
37
|
-
}),
|
|
27
|
+
port: portManager.port,
|
|
28
|
+
staticPort: portManager.staticPort,
|
|
38
29
|
}),
|
|
39
30
|
deps: {
|
|
40
31
|
configEntry: CONFIG_ENTRY_TOKEN,
|
|
41
32
|
parameters: COMMAND_PARAMETERS_TOKEN,
|
|
33
|
+
portManager: PORT_MANAGER_TOKEN,
|
|
42
34
|
},
|
|
43
35
|
}),
|
|
44
36
|
provide({
|
|
@@ -4,28 +4,27 @@ import {
|
|
|
4
4
|
COMMAND_PARAMETERS_TOKEN,
|
|
5
5
|
CONFIG_ENTRY_TOKEN,
|
|
6
6
|
CONFIG_MANAGER_TOKEN,
|
|
7
|
+
PORT_MANAGER_TOKEN,
|
|
7
8
|
} from '../../../di/tokens';
|
|
8
|
-
import { createConfigManager
|
|
9
|
+
import { createConfigManager } from '../../../config/configManager';
|
|
9
10
|
import type { ChildAppConfigEntry } from '../../../typings/configEntry/child-app';
|
|
10
|
-
import { detectPortSync } from '../../../utils/detectPortSync';
|
|
11
11
|
|
|
12
12
|
export const childAppProviders: readonly Provider[] = [
|
|
13
13
|
provide({
|
|
14
14
|
provide: CONFIG_MANAGER_TOKEN,
|
|
15
|
-
useFactory: ({ configEntry, parameters }) =>
|
|
15
|
+
useFactory: ({ configEntry, parameters, portManager }) =>
|
|
16
16
|
createConfigManager(configEntry as ChildAppConfigEntry, {
|
|
17
17
|
...parameters,
|
|
18
18
|
appEnv: parameters.env,
|
|
19
19
|
env: 'production',
|
|
20
20
|
buildType: 'client',
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
fallback: DEFAULT_STATIC_MODULE_PORT,
|
|
24
|
-
}),
|
|
21
|
+
port: portManager.port,
|
|
22
|
+
staticPort: portManager.staticPort,
|
|
25
23
|
}),
|
|
26
24
|
deps: {
|
|
27
25
|
configEntry: CONFIG_ENTRY_TOKEN,
|
|
28
26
|
parameters: COMMAND_PARAMETERS_TOKEN,
|
|
27
|
+
portManager: PORT_MANAGER_TOKEN,
|
|
29
28
|
},
|
|
30
29
|
}),
|
|
31
30
|
] as const;
|