@tradejs/cli 3.1.1 → 3.1.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/dist/cli.js +106 -2
- package/dist/scripts/runtimeConfig.js +106 -1
- package/package.json +7 -7
package/dist/cli.js
CHANGED
|
@@ -28101,10 +28101,11 @@ var init_runtimeScorecard2 = __esm({
|
|
|
28101
28101
|
// src/scripts/runtimeConfig.ts
|
|
28102
28102
|
var runtimeConfig_exports = {};
|
|
28103
28103
|
__export(runtimeConfig_exports, {
|
|
28104
|
+
buildBootstrapRuntimeDeployment: () => buildBootstrapRuntimeDeployment,
|
|
28104
28105
|
main: () => main37,
|
|
28105
28106
|
runtimeConfig: () => runtimeConfig
|
|
28106
28107
|
});
|
|
28107
|
-
var import_config9, import_promises28, import_node_path23, import_runtimeDeployments2, import_runtimeStrategyConfigs2, import_runtimeStrategyReleases, import_runtimeStrategies, import_strategies11, argv, action, option, hasFlag, required2, projectRoot12, userName2, OPERATIONAL_CONFIG_KEYS, toReleaseConfig, writeMigrationBackup, publish, migrate, publishDraft, updateControlState, rollback, verify, inspect, runtimeConfig, main37;
|
|
28108
|
+
var import_config9, import_promises28, import_node_path23, import_runtimeDeployments2, import_runtimeStrategyConfigs2, import_runtimeStrategyReleases, import_runtimeStrategies, import_strategies11, argv, action, option, hasFlag, required2, projectRoot12, userName2, OPERATIONAL_CONFIG_KEYS, toReleaseConfig, writeMigrationBackup, publish, buildBootstrapRuntimeDeployment, bootstrap, migrate, publishDraft, updateControlState, rollback, verify, inspect, runtimeConfig, main37;
|
|
28108
28109
|
var init_runtimeConfig = __esm({
|
|
28109
28110
|
"src/scripts/runtimeConfig.ts"() {
|
|
28110
28111
|
"use strict";
|
|
@@ -28176,6 +28177,108 @@ var init_runtimeConfig = __esm({
|
|
|
28176
28177
|
createdBy: `cli:${userName2}`
|
|
28177
28178
|
});
|
|
28178
28179
|
};
|
|
28180
|
+
buildBootstrapRuntimeDeployment = ({
|
|
28181
|
+
deploymentId,
|
|
28182
|
+
label,
|
|
28183
|
+
connectorName,
|
|
28184
|
+
provider,
|
|
28185
|
+
accountId,
|
|
28186
|
+
strategyName,
|
|
28187
|
+
releaseVersion,
|
|
28188
|
+
config: config2
|
|
28189
|
+
}) => ({
|
|
28190
|
+
id: deploymentId,
|
|
28191
|
+
label,
|
|
28192
|
+
connectorName,
|
|
28193
|
+
provider,
|
|
28194
|
+
accountId,
|
|
28195
|
+
universe: config2.UNIVERSE,
|
|
28196
|
+
interval: String(config2.INTERVAL),
|
|
28197
|
+
enabled: true,
|
|
28198
|
+
strategies: [
|
|
28199
|
+
{
|
|
28200
|
+
strategyName,
|
|
28201
|
+
releaseVersion,
|
|
28202
|
+
controlState: "entries_paused"
|
|
28203
|
+
}
|
|
28204
|
+
]
|
|
28205
|
+
});
|
|
28206
|
+
bootstrap = async () => {
|
|
28207
|
+
const strategyName = required2("strategy");
|
|
28208
|
+
const deploymentId = required2("deployment");
|
|
28209
|
+
const accountId = required2("account");
|
|
28210
|
+
const connectorName = option("connector") ?? "bybit";
|
|
28211
|
+
const provider = option("provider") ?? connectorName;
|
|
28212
|
+
const label = option("label") ?? deploymentId;
|
|
28213
|
+
const configFile = import_node_path23.default.resolve(projectRoot12, required2("file"));
|
|
28214
|
+
const sourceConfig = JSON.parse(
|
|
28215
|
+
await (0, import_promises28.readFile)(configFile, "utf8")
|
|
28216
|
+
);
|
|
28217
|
+
const existingDeployment = await (0, import_runtimeDeployments2.getRuntimeDeployment)(userName2, deploymentId);
|
|
28218
|
+
if (existingDeployment) {
|
|
28219
|
+
throw new Error(
|
|
28220
|
+
`Deployment already exists: ${deploymentId}; publish a release and switch its pointer instead`
|
|
28221
|
+
);
|
|
28222
|
+
}
|
|
28223
|
+
const releaseConfig = await toReleaseConfig(strategyName, sourceConfig);
|
|
28224
|
+
const previewDeployment = buildBootstrapRuntimeDeployment({
|
|
28225
|
+
deploymentId,
|
|
28226
|
+
label,
|
|
28227
|
+
connectorName,
|
|
28228
|
+
provider,
|
|
28229
|
+
accountId,
|
|
28230
|
+
strategyName,
|
|
28231
|
+
releaseVersion: 1,
|
|
28232
|
+
config: releaseConfig
|
|
28233
|
+
});
|
|
28234
|
+
if (!hasFlag("write")) {
|
|
28235
|
+
console.log(
|
|
28236
|
+
JSON.stringify(
|
|
28237
|
+
{
|
|
28238
|
+
dryRun: true,
|
|
28239
|
+
releaseConfig,
|
|
28240
|
+
deployment: {
|
|
28241
|
+
...previewDeployment,
|
|
28242
|
+
strategies: previewDeployment.strategies.map((strategy) => ({
|
|
28243
|
+
...strategy,
|
|
28244
|
+
releaseVersion: "<allocated on write>"
|
|
28245
|
+
}))
|
|
28246
|
+
}
|
|
28247
|
+
},
|
|
28248
|
+
null,
|
|
28249
|
+
2
|
|
28250
|
+
)
|
|
28251
|
+
);
|
|
28252
|
+
return;
|
|
28253
|
+
}
|
|
28254
|
+
const backupPath = await writeMigrationBackup({
|
|
28255
|
+
userName: userName2,
|
|
28256
|
+
capturedAt: Date.now(),
|
|
28257
|
+
reason: "bootstrap",
|
|
28258
|
+
sourceConfig
|
|
28259
|
+
});
|
|
28260
|
+
const release = await publish({ strategyName, sourceConfig });
|
|
28261
|
+
const deployment = await (0, import_runtimeDeployments2.saveRuntimeDeployment)(
|
|
28262
|
+
userName2,
|
|
28263
|
+
buildBootstrapRuntimeDeployment({
|
|
28264
|
+
deploymentId,
|
|
28265
|
+
label,
|
|
28266
|
+
connectorName,
|
|
28267
|
+
provider,
|
|
28268
|
+
accountId,
|
|
28269
|
+
strategyName,
|
|
28270
|
+
releaseVersion: release.releaseVersion,
|
|
28271
|
+
config: release.config
|
|
28272
|
+
})
|
|
28273
|
+
);
|
|
28274
|
+
console.log(
|
|
28275
|
+
JSON.stringify(
|
|
28276
|
+
{ bootstrapped: true, backupPath, release, deployment },
|
|
28277
|
+
null,
|
|
28278
|
+
2
|
|
28279
|
+
)
|
|
28280
|
+
);
|
|
28281
|
+
};
|
|
28179
28282
|
migrate = async () => {
|
|
28180
28283
|
const strategyName = required2("strategy");
|
|
28181
28284
|
const configId = option("config") ?? "config";
|
|
@@ -28345,6 +28448,7 @@ var init_runtimeConfig = __esm({
|
|
|
28345
28448
|
console.log(JSON.stringify({ userName: userName2, deployments, releases }, null, 2));
|
|
28346
28449
|
};
|
|
28347
28450
|
runtimeConfig = async () => {
|
|
28451
|
+
if (action === "bootstrap") return bootstrap();
|
|
28348
28452
|
if (action === "migrate") return migrate();
|
|
28349
28453
|
if (action === "publish-draft") return publishDraft();
|
|
28350
28454
|
if (action === "verify") return verify();
|
|
@@ -28353,7 +28457,7 @@ var init_runtimeConfig = __esm({
|
|
|
28353
28457
|
if (action === "rollback") return rollback();
|
|
28354
28458
|
if (action === "inspect") return inspect();
|
|
28355
28459
|
throw new Error(
|
|
28356
|
-
"Usage: tradejs runtime-config inspect|verify|migrate|publish-draft|pause|resume|rollback"
|
|
28460
|
+
"Usage: tradejs runtime-config inspect|verify|bootstrap|migrate|publish-draft|pause|resume|rollback"
|
|
28357
28461
|
);
|
|
28358
28462
|
};
|
|
28359
28463
|
main37 = runtimeConfig;
|
|
@@ -30,6 +30,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// src/scripts/runtimeConfig.ts
|
|
31
31
|
var runtimeConfig_exports = {};
|
|
32
32
|
__export(runtimeConfig_exports, {
|
|
33
|
+
buildBootstrapRuntimeDeployment: () => buildBootstrapRuntimeDeployment,
|
|
33
34
|
main: () => main,
|
|
34
35
|
runtimeConfig: () => runtimeConfig
|
|
35
36
|
});
|
|
@@ -102,6 +103,108 @@ var publish = async ({
|
|
|
102
103
|
createdBy: `cli:${userName}`
|
|
103
104
|
});
|
|
104
105
|
};
|
|
106
|
+
var buildBootstrapRuntimeDeployment = ({
|
|
107
|
+
deploymentId,
|
|
108
|
+
label,
|
|
109
|
+
connectorName,
|
|
110
|
+
provider,
|
|
111
|
+
accountId,
|
|
112
|
+
strategyName,
|
|
113
|
+
releaseVersion,
|
|
114
|
+
config
|
|
115
|
+
}) => ({
|
|
116
|
+
id: deploymentId,
|
|
117
|
+
label,
|
|
118
|
+
connectorName,
|
|
119
|
+
provider,
|
|
120
|
+
accountId,
|
|
121
|
+
universe: config.UNIVERSE,
|
|
122
|
+
interval: String(config.INTERVAL),
|
|
123
|
+
enabled: true,
|
|
124
|
+
strategies: [
|
|
125
|
+
{
|
|
126
|
+
strategyName,
|
|
127
|
+
releaseVersion,
|
|
128
|
+
controlState: "entries_paused"
|
|
129
|
+
}
|
|
130
|
+
]
|
|
131
|
+
});
|
|
132
|
+
var bootstrap = async () => {
|
|
133
|
+
const strategyName = required("strategy");
|
|
134
|
+
const deploymentId = required("deployment");
|
|
135
|
+
const accountId = required("account");
|
|
136
|
+
const connectorName = option("connector") ?? "bybit";
|
|
137
|
+
const provider = option("provider") ?? connectorName;
|
|
138
|
+
const label = option("label") ?? deploymentId;
|
|
139
|
+
const configFile = import_node_path.default.resolve(projectRoot, required("file"));
|
|
140
|
+
const sourceConfig = JSON.parse(
|
|
141
|
+
await (0, import_promises.readFile)(configFile, "utf8")
|
|
142
|
+
);
|
|
143
|
+
const existingDeployment = await (0, import_runtimeDeployments.getRuntimeDeployment)(userName, deploymentId);
|
|
144
|
+
if (existingDeployment) {
|
|
145
|
+
throw new Error(
|
|
146
|
+
`Deployment already exists: ${deploymentId}; publish a release and switch its pointer instead`
|
|
147
|
+
);
|
|
148
|
+
}
|
|
149
|
+
const releaseConfig = await toReleaseConfig(strategyName, sourceConfig);
|
|
150
|
+
const previewDeployment = buildBootstrapRuntimeDeployment({
|
|
151
|
+
deploymentId,
|
|
152
|
+
label,
|
|
153
|
+
connectorName,
|
|
154
|
+
provider,
|
|
155
|
+
accountId,
|
|
156
|
+
strategyName,
|
|
157
|
+
releaseVersion: 1,
|
|
158
|
+
config: releaseConfig
|
|
159
|
+
});
|
|
160
|
+
if (!hasFlag("write")) {
|
|
161
|
+
console.log(
|
|
162
|
+
JSON.stringify(
|
|
163
|
+
{
|
|
164
|
+
dryRun: true,
|
|
165
|
+
releaseConfig,
|
|
166
|
+
deployment: {
|
|
167
|
+
...previewDeployment,
|
|
168
|
+
strategies: previewDeployment.strategies.map((strategy) => ({
|
|
169
|
+
...strategy,
|
|
170
|
+
releaseVersion: "<allocated on write>"
|
|
171
|
+
}))
|
|
172
|
+
}
|
|
173
|
+
},
|
|
174
|
+
null,
|
|
175
|
+
2
|
|
176
|
+
)
|
|
177
|
+
);
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
const backupPath = await writeMigrationBackup({
|
|
181
|
+
userName,
|
|
182
|
+
capturedAt: Date.now(),
|
|
183
|
+
reason: "bootstrap",
|
|
184
|
+
sourceConfig
|
|
185
|
+
});
|
|
186
|
+
const release = await publish({ strategyName, sourceConfig });
|
|
187
|
+
const deployment = await (0, import_runtimeDeployments.saveRuntimeDeployment)(
|
|
188
|
+
userName,
|
|
189
|
+
buildBootstrapRuntimeDeployment({
|
|
190
|
+
deploymentId,
|
|
191
|
+
label,
|
|
192
|
+
connectorName,
|
|
193
|
+
provider,
|
|
194
|
+
accountId,
|
|
195
|
+
strategyName,
|
|
196
|
+
releaseVersion: release.releaseVersion,
|
|
197
|
+
config: release.config
|
|
198
|
+
})
|
|
199
|
+
);
|
|
200
|
+
console.log(
|
|
201
|
+
JSON.stringify(
|
|
202
|
+
{ bootstrapped: true, backupPath, release, deployment },
|
|
203
|
+
null,
|
|
204
|
+
2
|
|
205
|
+
)
|
|
206
|
+
);
|
|
207
|
+
};
|
|
105
208
|
var migrate = async () => {
|
|
106
209
|
const strategyName = required("strategy");
|
|
107
210
|
const configId = option("config") ?? "config";
|
|
@@ -271,6 +374,7 @@ var inspect = async () => {
|
|
|
271
374
|
console.log(JSON.stringify({ userName, deployments, releases }, null, 2));
|
|
272
375
|
};
|
|
273
376
|
var runtimeConfig = async () => {
|
|
377
|
+
if (action === "bootstrap") return bootstrap();
|
|
274
378
|
if (action === "migrate") return migrate();
|
|
275
379
|
if (action === "publish-draft") return publishDraft();
|
|
276
380
|
if (action === "verify") return verify();
|
|
@@ -279,12 +383,13 @@ var runtimeConfig = async () => {
|
|
|
279
383
|
if (action === "rollback") return rollback();
|
|
280
384
|
if (action === "inspect") return inspect();
|
|
281
385
|
throw new Error(
|
|
282
|
-
"Usage: tradejs runtime-config inspect|verify|migrate|publish-draft|pause|resume|rollback"
|
|
386
|
+
"Usage: tradejs runtime-config inspect|verify|bootstrap|migrate|publish-draft|pause|resume|rollback"
|
|
283
387
|
);
|
|
284
388
|
};
|
|
285
389
|
var main = runtimeConfig;
|
|
286
390
|
// Annotate the CommonJS export names for ESM import in node:
|
|
287
391
|
0 && (module.exports = {
|
|
392
|
+
buildBootstrapRuntimeDeployment,
|
|
288
393
|
main,
|
|
289
394
|
runtimeConfig
|
|
290
395
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tradejs/cli",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.2",
|
|
4
4
|
"description": "Official CLI for the TradeJS TypeScript framework: infra setup, backtests, signals, bots, and ML workflows.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"tradejs",
|
|
@@ -32,13 +32,13 @@
|
|
|
32
32
|
"tradejs": "dist/cli.js"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@tradejs/connectors": "^3.1.
|
|
36
|
-
"@tradejs/core": "^3.1.
|
|
37
|
-
"@tradejs/indicators": "^3.1.
|
|
38
|
-
"@tradejs/infra": "^3.1.
|
|
39
|
-
"@tradejs/node": "^3.1.
|
|
35
|
+
"@tradejs/connectors": "^3.1.2",
|
|
36
|
+
"@tradejs/core": "^3.1.2",
|
|
37
|
+
"@tradejs/indicators": "^3.1.2",
|
|
38
|
+
"@tradejs/infra": "^3.1.2",
|
|
39
|
+
"@tradejs/node": "^3.1.2",
|
|
40
40
|
"@tradejs/strategy-kit": "^3.0.0",
|
|
41
|
-
"@tradejs/types": "^3.1.
|
|
41
|
+
"@tradejs/types": "^3.1.2",
|
|
42
42
|
"args": "^5.0.3",
|
|
43
43
|
"bcryptjs": "^2.4.3",
|
|
44
44
|
"chalk": "4.1.2",
|