@tramvai/cli 3.12.0 → 3.14.0
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/shared.d.ts.map +1 -1
- package/lib/api/start/providers/application/shared.js +5 -3
- package/lib/api/start/providers/application/shared.js.map +1 -1
- package/lib/api/start/providers/child-app/shared.d.ts.map +1 -1
- package/lib/api/start/providers/child-app/shared.js +6 -4
- package/lib/api/start/providers/child-app/shared.js.map +1 -1
- package/lib/api/start/providers/module/shared.d.ts.map +1 -1
- package/lib/api/start/providers/module/shared.js +6 -4
- package/lib/api/start/providers/module/shared.js.map +1 -1
- package/lib/api/start/utils/stopServer.d.ts.map +1 -1
- package/lib/api/start/utils/stopServer.js.map +1 -1
- package/lib/api/start-prod/application.d.ts.map +1 -1
- package/lib/api/start-prod/application.js +0 -2
- package/lib/api/start-prod/application.js.map +1 -1
- package/lib/api/start-prod/providers/shared.d.ts.map +1 -1
- package/lib/api/start-prod/providers/shared.js +3 -1
- package/lib/api/start-prod/providers/shared.js.map +1 -1
- package/lib/commands/analyze/command.d.ts.map +1 -1
- package/lib/commands/analyze/command.js +2 -0
- package/lib/commands/analyze/command.js.map +1 -1
- package/lib/commands/build/command.d.ts.map +1 -1
- package/lib/commands/build/command.js +2 -0
- package/lib/commands/build/command.js.map +1 -1
- package/lib/commands/start/command.d.ts.map +1 -1
- package/lib/commands/start/command.js +2 -0
- package/lib/commands/start/command.js.map +1 -1
- package/lib/commands/start-prod/command.d.ts.map +1 -1
- package/lib/commands/start-prod/command.js +2 -0
- package/lib/commands/start-prod/command.js.map +1 -1
- package/lib/commands/static/application.d.ts.map +1 -1
- package/lib/commands/static/application.js +8 -3
- package/lib/commands/static/application.js.map +1 -1
- package/lib/di/providers/network.d.ts.map +1 -1
- package/lib/di/providers/network.js +6 -0
- package/lib/di/providers/network.js.map +1 -1
- package/lib/models/port-manager.d.ts +21 -7
- package/lib/models/port-manager.d.ts.map +1 -1
- package/lib/models/port-manager.js +140 -26
- package/lib/models/port-manager.js.map +1 -1
- package/lib/schema/autogeneratedSchema.json +15 -15
- package/lib/validators/commands/checkSwcDependencies.d.ts +3 -0
- package/lib/validators/commands/checkSwcDependencies.d.ts.map +1 -0
- package/lib/validators/commands/checkSwcDependencies.js +40 -0
- package/lib/validators/commands/checkSwcDependencies.js.map +1 -0
- package/package.json +5 -2
- package/schema.json +15 -15
- package/src/api/benchmark/__integration__/start.test.ts +0 -2
- package/src/api/start/__integration__/start.test.ts +14 -95
- package/src/api/start/providers/application/shared.ts +4 -2
- package/src/api/start/providers/child-app/shared.ts +5 -2
- package/src/api/start/providers/module/shared.ts +5 -2
- package/src/api/start/utils/stopServer.ts +1 -0
- package/src/api/start-prod/application.ts +1 -4
- package/src/api/start-prod/providers/shared.ts +5 -2
- package/src/commands/analyze/command.ts +2 -0
- package/src/commands/build/command.ts +2 -0
- package/src/commands/start/command.ts +2 -0
- package/src/commands/start-prod/command.ts +2 -0
- package/src/commands/static/application.ts +10 -4
- package/src/di/providers/network.ts +6 -0
- package/src/library/swc/__integration__/swc.start.test.ts +0 -2
- package/src/models/port-manager.ts +154 -35
- package/src/schema/autogeneratedSchema.json +15 -15
- package/src/validators/commands/checkSwcDependencies.spec.ts +117 -0
- package/src/validators/commands/checkSwcDependencies.ts +40 -0
|
@@ -2,13 +2,19 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PortManager = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
+
const fs_extra_1 = require("fs-extra");
|
|
6
|
+
const path_1 = require("path");
|
|
7
|
+
const find_cache_dir_1 = tslib_1.__importDefault(require("find-cache-dir"));
|
|
5
8
|
const detect_port_1 = tslib_1.__importDefault(require("detect-port"));
|
|
9
|
+
const proper_lockfile_1 = require("proper-lockfile");
|
|
6
10
|
class PortManager {
|
|
7
|
-
constructor({ configEntry, commandParams }) {
|
|
11
|
+
constructor({ configEntry, commandParams, logger }) {
|
|
8
12
|
this.port = null;
|
|
9
13
|
this.staticPort = null;
|
|
10
14
|
this.configEntry = configEntry;
|
|
11
15
|
this.commandParams = commandParams;
|
|
16
|
+
this.logger = logger;
|
|
17
|
+
this.cachePath = (0, path_1.join)((0, find_cache_dir_1.default)({ cwd: __dirname, create: true, name: 'tramvai' }), 'used-ports');
|
|
12
18
|
}
|
|
13
19
|
/**
|
|
14
20
|
* Try to detect port considering the fact, that if user requests
|
|
@@ -18,55 +24,163 @@ class PortManager {
|
|
|
18
24
|
* because we must pass a final number to the config manager.
|
|
19
25
|
*/
|
|
20
26
|
computeAvailablePorts() {
|
|
27
|
+
var _a;
|
|
21
28
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
29
|
+
yield this.createCacheFile();
|
|
30
|
+
const release = yield this.lockCacheFile();
|
|
31
|
+
try {
|
|
32
|
+
if (this.commandParams.port !== undefined && this.commandParams.port !== 0) {
|
|
33
|
+
// @ts-expect-error There is a string actually
|
|
34
|
+
this.port = parseInt(this.commandParams.port, 10);
|
|
35
|
+
}
|
|
36
|
+
if (this.commandParams.staticPort !== undefined && this.commandParams.staticPort !== 0) {
|
|
37
|
+
// @ts-expect-error There is a string actually
|
|
38
|
+
this.staticPort = parseInt(this.commandParams.staticPort, 10);
|
|
39
|
+
}
|
|
40
|
+
switch (this.configEntry.type) {
|
|
41
|
+
case 'child-app':
|
|
42
|
+
yield this.forChildApp();
|
|
43
|
+
break;
|
|
44
|
+
case 'module':
|
|
45
|
+
yield this.forModule();
|
|
46
|
+
break;
|
|
47
|
+
case 'application':
|
|
48
|
+
yield this.forApplication();
|
|
49
|
+
break;
|
|
50
|
+
default:
|
|
51
|
+
break;
|
|
52
|
+
}
|
|
53
|
+
yield this.appendCacheFile([this.port, this.staticPort].join(','));
|
|
25
54
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
55
|
+
catch (error) {
|
|
56
|
+
this.logger.event({
|
|
57
|
+
type: 'warning',
|
|
58
|
+
event: 'PORT_MANAGER:GET_AVAILABLE_PORTS',
|
|
59
|
+
message: `Can't get free ports for ${this.configEntry.type}:`,
|
|
60
|
+
payload: (_a = error.message) !== null && _a !== void 0 ? _a : '',
|
|
61
|
+
});
|
|
29
62
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
63
|
+
finally {
|
|
64
|
+
yield release();
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Cleanup a cache file by removing ports were written previously.
|
|
70
|
+
*/
|
|
71
|
+
cleanup() {
|
|
72
|
+
var _a;
|
|
73
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
74
|
+
const release = yield this.lockCacheFile();
|
|
75
|
+
try {
|
|
76
|
+
const cache = yield this.readCacheFile();
|
|
77
|
+
yield this.writeCacheFile(cache
|
|
78
|
+
.filter(Boolean)
|
|
79
|
+
.filter((port) => port !== this.port.toString() && port !== this.staticPort.toString())
|
|
80
|
+
.join(','));
|
|
81
|
+
}
|
|
82
|
+
catch (error) {
|
|
83
|
+
this.logger.event({
|
|
84
|
+
type: 'warning',
|
|
85
|
+
event: 'PORT_MANAGER:CLEANUP',
|
|
86
|
+
message: "Can't perform a cleanup of previously used ports:",
|
|
87
|
+
payload: (_a = error.message) !== null && _a !== void 0 ? _a : '',
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
finally {
|
|
91
|
+
yield release();
|
|
42
92
|
}
|
|
43
93
|
});
|
|
44
94
|
}
|
|
45
95
|
forApplication() {
|
|
46
96
|
var _a, _b;
|
|
47
97
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
48
|
-
this.port = (_a = this.port) !== null && _a !== void 0 ? _a : (yield
|
|
49
|
-
this.staticPort =
|
|
98
|
+
this.port = (_a = this.port) !== null && _a !== void 0 ? _a : (yield this.resolveFreePort(PortManager.DEFAULT_PORT));
|
|
99
|
+
this.staticPort =
|
|
100
|
+
(_b = this.staticPort) !== null && _b !== void 0 ? _b : (yield this.resolveFreePort(PortManager.DEFAULT_STATIC_PORT));
|
|
50
101
|
});
|
|
51
102
|
}
|
|
52
103
|
forModule() {
|
|
53
104
|
var _a, _b;
|
|
54
105
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
55
|
-
this.port = (_a = this.port) !== null && _a !== void 0 ? _a : (yield
|
|
56
|
-
this.staticPort =
|
|
106
|
+
this.port = (_a = this.port) !== null && _a !== void 0 ? _a : (yield this.resolveFreePort(PortManager.DEFAULT_MODULE_PORT));
|
|
107
|
+
this.staticPort =
|
|
108
|
+
(_b = this.staticPort) !== null && _b !== void 0 ? _b : (yield this.resolveFreePort(PortManager.DEFAULT_MODULE_STATIC_PORT));
|
|
57
109
|
});
|
|
58
110
|
}
|
|
59
111
|
forChildApp() {
|
|
60
112
|
var _a, _b;
|
|
61
113
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
62
|
-
this.port = (_a = this.port) !== null && _a !== void 0 ? _a : (yield
|
|
63
|
-
this.staticPort =
|
|
114
|
+
this.port = (_a = this.port) !== null && _a !== void 0 ? _a : (yield this.resolveFreePort(PortManager.DEFAULT_MODULE_PORT));
|
|
115
|
+
this.staticPort =
|
|
116
|
+
(_b = this.staticPort) !== null && _b !== void 0 ? _b : (yield this.resolveFreePort(PortManager.DEFAULT_MODULE_STATIC_PORT));
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
lockCacheFile() {
|
|
120
|
+
return (0, proper_lockfile_1.lock)(this.cachePath, { retries: 10 });
|
|
121
|
+
}
|
|
122
|
+
createCacheFile() {
|
|
123
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
124
|
+
try {
|
|
125
|
+
yield (0, fs_extra_1.access)(this.cachePath);
|
|
126
|
+
}
|
|
127
|
+
catch (error) {
|
|
128
|
+
yield (0, fs_extra_1.outputFile)(this.cachePath, '');
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
readCacheFile() {
|
|
133
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
134
|
+
try {
|
|
135
|
+
const content = yield (0, fs_extra_1.readFile)(this.cachePath, { encoding: 'utf-8' });
|
|
136
|
+
return content.split(',');
|
|
137
|
+
}
|
|
138
|
+
catch (error) {
|
|
139
|
+
return [];
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
writeCacheFile(content) {
|
|
144
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
145
|
+
yield (0, fs_extra_1.outputFile)(this.cachePath, content);
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
appendCacheFile(content) {
|
|
149
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
150
|
+
yield (0, fs_extra_1.appendFile)(this.cachePath, `,${content}`);
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
resolveFreePort(initial) {
|
|
154
|
+
var _a;
|
|
155
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
156
|
+
try {
|
|
157
|
+
const cache = yield this.readCacheFile();
|
|
158
|
+
let port = yield (0, detect_port_1.default)(initial);
|
|
159
|
+
let attempts = 1;
|
|
160
|
+
while (cache.includes(port.toString())) {
|
|
161
|
+
if (attempts >= 3) {
|
|
162
|
+
throw new Error(`Max attempts exceeded (${attempts})`);
|
|
163
|
+
}
|
|
164
|
+
port = yield (0, detect_port_1.default)(0);
|
|
165
|
+
attempts++;
|
|
166
|
+
}
|
|
167
|
+
return port;
|
|
168
|
+
}
|
|
169
|
+
catch (error) {
|
|
170
|
+
this.logger.event({
|
|
171
|
+
type: 'info',
|
|
172
|
+
event: 'PORT_MANAGER:RESOLVE_FREE_PORT',
|
|
173
|
+
message: "Can't resolve a free port, fallback to an initial one:",
|
|
174
|
+
payload: (_a = error.message) !== null && _a !== void 0 ? _a : '',
|
|
175
|
+
});
|
|
176
|
+
return initial;
|
|
177
|
+
}
|
|
64
178
|
});
|
|
65
179
|
}
|
|
66
180
|
}
|
|
67
181
|
exports.PortManager = PortManager;
|
|
68
182
|
PortManager.DEFAULT_PORT = 3000;
|
|
69
|
-
PortManager.DEFAULT_MODULE_PORT =
|
|
183
|
+
PortManager.DEFAULT_MODULE_PORT = 3040;
|
|
70
184
|
PortManager.DEFAULT_STATIC_PORT = 4000;
|
|
71
185
|
PortManager.DEFAULT_MODULE_STATIC_PORT = 4040;
|
|
72
186
|
//# sourceMappingURL=port-manager.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"port-manager.js","sourceRoot":"","sources":["../../src/models/port-manager.ts"],"names":[],"mappings":";;;;AAAA,sEAAqC;
|
|
1
|
+
{"version":3,"file":"port-manager.js","sourceRoot":"","sources":["../../src/models/port-manager.ts"],"names":[],"mappings":";;;;AAAA,uCAAoE;AACpE,+BAA4B;AAC5B,4EAA0C;AAC1C,sEAAqC;AACrC,qDAAuC;AAavC,MAAa,WAAW;IActB,YAAY,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,EAA6B;QAHtE,SAAI,GAAkB,IAAI,CAAC;QAC3B,eAAU,GAAkB,IAAI,CAAC;QAGtC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QAErB,IAAI,CAAC,SAAS,GAAG,IAAA,WAAI,EACnB,IAAA,wBAAY,EAAC,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,EAC/D,YAAY,CACb,CAAC;IACJ,CAAC;IAED;;;;;;OAMG;IACU,qBAAqB;;;YAChC,MAA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|
"additionalProperties": false
|
|
1150
1150
|
},
|
|
1151
|
-
"__@replace@
|
|
1151
|
+
"__@replace@6852": {
|
|
1152
1152
|
"type": "object",
|
|
1153
1153
|
"additionalProperties": false
|
|
1154
1154
|
},
|
|
1155
|
-
"__@search@
|
|
1155
|
+
"__@search@6855": {
|
|
1156
1156
|
"type": "object",
|
|
1157
1157
|
"additionalProperties": false
|
|
1158
1158
|
},
|
|
1159
|
-
"__@split@
|
|
1159
|
+
"__@split@6857": {
|
|
1160
1160
|
"type": "object",
|
|
1161
1161
|
"additionalProperties": false
|
|
1162
1162
|
},
|
|
1163
|
-
"__@matchAll@
|
|
1163
|
+
"__@matchAll@6859": {
|
|
1164
1164
|
"type": "object",
|
|
1165
1165
|
"additionalProperties": false
|
|
1166
1166
|
}
|
|
@@ -1814,23 +1814,23 @@
|
|
|
1814
1814
|
"dotAll": {
|
|
1815
1815
|
"type": "boolean"
|
|
1816
1816
|
},
|
|
1817
|
-
"__@match@
|
|
1817
|
+
"__@match@6850": {
|
|
1818
1818
|
"type": "object",
|
|
1819
1819
|
"additionalProperties": false
|
|
1820
1820
|
},
|
|
1821
|
-
"__@replace@
|
|
1821
|
+
"__@replace@6852": {
|
|
1822
1822
|
"type": "object",
|
|
1823
1823
|
"additionalProperties": false
|
|
1824
1824
|
},
|
|
1825
|
-
"__@search@
|
|
1825
|
+
"__@search@6855": {
|
|
1826
1826
|
"type": "object",
|
|
1827
1827
|
"additionalProperties": false
|
|
1828
1828
|
},
|
|
1829
|
-
"__@split@
|
|
1829
|
+
"__@split@6857": {
|
|
1830
1830
|
"type": "object",
|
|
1831
1831
|
"additionalProperties": false
|
|
1832
1832
|
},
|
|
1833
|
-
"__@matchAll@
|
|
1833
|
+
"__@matchAll@6859": {
|
|
1834
1834
|
"type": "object",
|
|
1835
1835
|
"additionalProperties": false
|
|
1836
1836
|
}
|
|
@@ -2484,23 +2484,23 @@
|
|
|
2484
2484
|
"dotAll": {
|
|
2485
2485
|
"type": "boolean"
|
|
2486
2486
|
},
|
|
2487
|
-
"__@match@
|
|
2487
|
+
"__@match@6850": {
|
|
2488
2488
|
"type": "object",
|
|
2489
2489
|
"additionalProperties": false
|
|
2490
2490
|
},
|
|
2491
|
-
"__@replace@
|
|
2491
|
+
"__@replace@6852": {
|
|
2492
2492
|
"type": "object",
|
|
2493
2493
|
"additionalProperties": false
|
|
2494
2494
|
},
|
|
2495
|
-
"__@search@
|
|
2495
|
+
"__@search@6855": {
|
|
2496
2496
|
"type": "object",
|
|
2497
2497
|
"additionalProperties": false
|
|
2498
2498
|
},
|
|
2499
|
-
"__@split@
|
|
2499
|
+
"__@split@6857": {
|
|
2500
2500
|
"type": "object",
|
|
2501
2501
|
"additionalProperties": false
|
|
2502
2502
|
},
|
|
2503
|
-
"__@matchAll@
|
|
2503
|
+
"__@matchAll@6859": {
|
|
2504
2504
|
"type": "object",
|
|
2505
2505
|
"additionalProperties": false
|
|
2506
2506
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkSwcDependencies.d.ts","sourceRoot":"","sources":["../../../src/validators/commands/checkSwcDependencies.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAE/C,eAAO,MAAM,oBAAoB,EAAE,SAoClC,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.checkSwcDependencies = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const resolve_1 = require("resolve");
|
|
6
|
+
const checkSwcDependencies = () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
7
|
+
const rootDir = process.cwd();
|
|
8
|
+
const packagePath = `@swc/core/package.json`;
|
|
9
|
+
const pathFromCli = (0, resolve_1.sync)(packagePath);
|
|
10
|
+
const pathFromRoot = (0, resolve_1.sync)(packagePath, { basedir: rootDir });
|
|
11
|
+
const pathFromRootToIntegration = (0, resolve_1.sync)(`@tramvai/swc-integration/package.json`, {
|
|
12
|
+
basedir: rootDir,
|
|
13
|
+
});
|
|
14
|
+
let versionFromIntegration = '';
|
|
15
|
+
let versionFromRoot = '_from_root_version_';
|
|
16
|
+
let versionFromCli = '_from_cli_version_';
|
|
17
|
+
try {
|
|
18
|
+
versionFromIntegration = require(pathFromRootToIntegration).dependencies['@swc/core'];
|
|
19
|
+
versionFromRoot = require(pathFromRoot).version;
|
|
20
|
+
versionFromCli = require(pathFromCli).version;
|
|
21
|
+
}
|
|
22
|
+
catch (e) { }
|
|
23
|
+
const allVersionsAreCorrect = versionFromRoot === versionFromCli && versionFromCli === versionFromIntegration;
|
|
24
|
+
if (!versionFromIntegration || allVersionsAreCorrect) {
|
|
25
|
+
return {
|
|
26
|
+
name: 'checkSwcDependencies',
|
|
27
|
+
status: 'ok',
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
return {
|
|
31
|
+
name: 'checkSwcDependencies',
|
|
32
|
+
status: 'error',
|
|
33
|
+
message: `Version of @swc/core mismatch between
|
|
34
|
+
@tramvai/swc-integration (version: ${versionFromIntegration}),
|
|
35
|
+
@tramvai/cli (version: ${versionFromCli}) and
|
|
36
|
+
process.cwd() (version: ${versionFromRoot})`,
|
|
37
|
+
};
|
|
38
|
+
});
|
|
39
|
+
exports.checkSwcDependencies = checkSwcDependencies;
|
|
40
|
+
//# sourceMappingURL=checkSwcDependencies.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkSwcDependencies.js","sourceRoot":"","sources":["../../../src/validators/commands/checkSwcDependencies.ts"],"names":[],"mappings":";;;;AAAA,qCAA0C;AAGnC,MAAM,oBAAoB,GAAc,GAAS,EAAE;IACxD,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;IAC9B,MAAM,WAAW,GAAG,wBAAwB,CAAC;IAC7C,MAAM,WAAW,GAAG,IAAA,cAAO,EAAC,WAAW,CAAC,CAAC;IACzC,MAAM,YAAY,GAAG,IAAA,cAAO,EAAC,WAAW,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC;IAChE,MAAM,yBAAyB,GAAG,IAAA,cAAO,EAAC,uCAAuC,EAAE;QACjF,OAAO,EAAE,OAAO;KACjB,CAAC,CAAC;IAEH,IAAI,sBAAsB,GAAG,EAAE,CAAC;IAChC,IAAI,eAAe,GAAG,qBAAqB,CAAC;IAC5C,IAAI,cAAc,GAAG,oBAAoB,CAAC;IAC1C,IAAI;QACF,sBAAsB,GAAG,OAAO,CAAC,yBAAyB,CAAC,CAAC,YAAY,CAAC,WAAW,CAAC,CAAC;QACtF,eAAe,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC,OAAO,CAAC;QAChD,cAAc,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC;KAC/C;IAAC,OAAO,CAAC,EAAE,GAAE;IAEd,MAAM,qBAAqB,GACzB,eAAe,KAAK,cAAc,IAAI,cAAc,KAAK,sBAAsB,CAAC;IAElF,IAAI,CAAC,sBAAsB,IAAI,qBAAqB,EAAE;QACpD,OAAO;YACL,IAAI,EAAE,sBAAsB;YAC5B,MAAM,EAAE,IAAI;SACb,CAAC;KACH;IAED,OAAO;QACL,IAAI,EAAE,sBAAsB;QAC5B,MAAM,EAAE,OAAO;QACf,OAAO,EAAE;qCACwB,sBAAsB;yBAClC,cAAc;0BACb,eAAe,GAAG;KACzC,CAAC;AACJ,CAAC,CAAA,CAAC;AApCW,QAAA,oBAAoB,wBAoC/B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tramvai/cli",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.14.0",
|
|
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": "2.0.2",
|
|
73
73
|
"@tramvai/build": "4.0.1",
|
|
74
|
-
"@tramvai/react": "3.
|
|
74
|
+
"@tramvai/react": "3.14.0",
|
|
75
75
|
"@tramvai/tools-check-versions": "0.5.3",
|
|
76
76
|
"@tramvai/tools-migrate": "0.7.3",
|
|
77
77
|
"ajv": "^8.12.0",
|
|
@@ -139,6 +139,7 @@
|
|
|
139
139
|
"prettyoutput": "^1.2.0",
|
|
140
140
|
"process": "^0.11.10",
|
|
141
141
|
"promise-queue": "^2.2.5",
|
|
142
|
+
"proper-lockfile": "^4.1.2",
|
|
142
143
|
"react-refresh": "^0.14.0",
|
|
143
144
|
"resolve": "^1.22.4",
|
|
144
145
|
"rimraf": "^3.0.2",
|
|
@@ -174,6 +175,7 @@
|
|
|
174
175
|
"@swc/core": "1.3.62",
|
|
175
176
|
"@tramvai/tools-generate-schema": "0.2.1",
|
|
176
177
|
"@types/compression": "^1.7.2",
|
|
178
|
+
"@types/detect-port": "^1.3.5",
|
|
177
179
|
"@types/express": "^4.17.13",
|
|
178
180
|
"@types/find-cache-dir": "^3.2.1",
|
|
179
181
|
"@types/fs-extra": "^9.0.13",
|
|
@@ -181,6 +183,7 @@
|
|
|
181
183
|
"@types/glob": "^7.2.0",
|
|
182
184
|
"@types/http-proxy": "^1.17.9",
|
|
183
185
|
"@types/inquirer": "^7.3.3",
|
|
186
|
+
"@types/proper-lockfile": "^4.1.4",
|
|
184
187
|
"@types/resolve": "^1.20.2",
|
|
185
188
|
"@types/rimraf": "^3.0.2",
|
|
186
189
|
"@types/semver": "^7.3.12",
|
package/schema.json
CHANGED
|
@@ -1166,23 +1166,23 @@
|
|
|
1166
1166
|
"dotAll": {
|
|
1167
1167
|
"type": "boolean"
|
|
1168
1168
|
},
|
|
1169
|
-
"__@match@
|
|
1169
|
+
"__@match@6850": {
|
|
1170
1170
|
"type": "object",
|
|
1171
1171
|
"additionalProperties": false
|
|
1172
1172
|
},
|
|
1173
|
-
"__@replace@
|
|
1173
|
+
"__@replace@6852": {
|
|
1174
1174
|
"type": "object",
|
|
1175
1175
|
"additionalProperties": false
|
|
1176
1176
|
},
|
|
1177
|
-
"__@search@
|
|
1177
|
+
"__@search@6855": {
|
|
1178
1178
|
"type": "object",
|
|
1179
1179
|
"additionalProperties": false
|
|
1180
1180
|
},
|
|
1181
|
-
"__@split@
|
|
1181
|
+
"__@split@6857": {
|
|
1182
1182
|
"type": "object",
|
|
1183
1183
|
"additionalProperties": false
|
|
1184
1184
|
},
|
|
1185
|
-
"__@matchAll@
|
|
1185
|
+
"__@matchAll@6859": {
|
|
1186
1186
|
"type": "object",
|
|
1187
1187
|
"additionalProperties": false
|
|
1188
1188
|
}
|
|
@@ -1845,23 +1845,23 @@
|
|
|
1845
1845
|
"dotAll": {
|
|
1846
1846
|
"type": "boolean"
|
|
1847
1847
|
},
|
|
1848
|
-
"__@match@
|
|
1848
|
+
"__@match@6850": {
|
|
1849
1849
|
"type": "object",
|
|
1850
1850
|
"additionalProperties": false
|
|
1851
1851
|
},
|
|
1852
|
-
"__@replace@
|
|
1852
|
+
"__@replace@6852": {
|
|
1853
1853
|
"type": "object",
|
|
1854
1854
|
"additionalProperties": false
|
|
1855
1855
|
},
|
|
1856
|
-
"__@search@
|
|
1856
|
+
"__@search@6855": {
|
|
1857
1857
|
"type": "object",
|
|
1858
1858
|
"additionalProperties": false
|
|
1859
1859
|
},
|
|
1860
|
-
"__@split@
|
|
1860
|
+
"__@split@6857": {
|
|
1861
1861
|
"type": "object",
|
|
1862
1862
|
"additionalProperties": false
|
|
1863
1863
|
},
|
|
1864
|
-
"__@matchAll@
|
|
1864
|
+
"__@matchAll@6859": {
|
|
1865
1865
|
"type": "object",
|
|
1866
1866
|
"additionalProperties": false
|
|
1867
1867
|
}
|
|
@@ -2524,23 +2524,23 @@
|
|
|
2524
2524
|
"dotAll": {
|
|
2525
2525
|
"type": "boolean"
|
|
2526
2526
|
},
|
|
2527
|
-
"__@match@
|
|
2527
|
+
"__@match@6850": {
|
|
2528
2528
|
"type": "object",
|
|
2529
2529
|
"additionalProperties": false
|
|
2530
2530
|
},
|
|
2531
|
-
"__@replace@
|
|
2531
|
+
"__@replace@6852": {
|
|
2532
2532
|
"type": "object",
|
|
2533
2533
|
"additionalProperties": false
|
|
2534
2534
|
},
|
|
2535
|
-
"__@search@
|
|
2535
|
+
"__@search@6855": {
|
|
2536
2536
|
"type": "object",
|
|
2537
2537
|
"additionalProperties": false
|
|
2538
2538
|
},
|
|
2539
|
-
"__@split@
|
|
2539
|
+
"__@split@6857": {
|
|
2540
2540
|
"type": "object",
|
|
2541
2541
|
"additionalProperties": false
|
|
2542
2542
|
},
|
|
2543
|
-
"__@matchAll@
|
|
2543
|
+
"__@matchAll@6859": {
|
|
2544
2544
|
"type": "object",
|
|
2545
2545
|
"additionalProperties": false
|
|
2546
2546
|
}
|