@pd4castr/cli 1.11.0 → 1.13.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/dist/index.js +280 -94
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -90,6 +90,7 @@ var modelInputSchema = z.union([
|
|
|
90
90
|
]);
|
|
91
91
|
var modelOutputSchema = z.object({
|
|
92
92
|
name: z.string(),
|
|
93
|
+
key: z.string().regex(/^[a-z0-9][a-z0-9_-]*$/).optional(),
|
|
93
94
|
type: z.enum([
|
|
94
95
|
"float",
|
|
95
96
|
"integer",
|
|
@@ -103,6 +104,7 @@ var modelOutputSchema = z.object({
|
|
|
103
104
|
});
|
|
104
105
|
var sensitivitySchema = z.object({
|
|
105
106
|
name: z.string(),
|
|
107
|
+
key: z.string().regex(/^[a-z0-9][a-z0-9_-]*$/).optional(),
|
|
106
108
|
query: z.string()
|
|
107
109
|
});
|
|
108
110
|
var inputAggregationSchema = z.object({
|
|
@@ -132,10 +134,45 @@ var projectConfigSchema = z.object({
|
|
|
132
134
|
outputs: z.array(modelOutputSchema),
|
|
133
135
|
sensitivities: z.array(sensitivitySchema).optional().default([]),
|
|
134
136
|
[CONFIG_WARNING_KEY]: z.string().optional().default(""),
|
|
137
|
+
$$configVersion: z.number().int().min(0).optional().default(0),
|
|
135
138
|
$$id: z.string().nullable().optional().default(null),
|
|
136
139
|
$$modelGroupID: z.string().nullable().optional().default(null),
|
|
137
140
|
$$revision: z.number().int().min(0).nullable().optional().default(null),
|
|
138
141
|
$$dockerImage: z.string().nullable().optional().default(null)
|
|
142
|
+
}).superRefine((data, ctx) => {
|
|
143
|
+
if (data.$$id) {
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
for (const [i, output] of data.outputs.entries()) {
|
|
147
|
+
if (!output.key) {
|
|
148
|
+
ctx.addIssue({
|
|
149
|
+
code: "invalid_format",
|
|
150
|
+
format: "regex",
|
|
151
|
+
pattern: "^[a-z0-9][a-z0-9_-]*$",
|
|
152
|
+
path: [
|
|
153
|
+
"outputs",
|
|
154
|
+
i,
|
|
155
|
+
"key"
|
|
156
|
+
],
|
|
157
|
+
message: "key is required (lowercase alphanumeric with hyphens/underscores)"
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
for (const [i, sensitivity] of data.sensitivities.entries()) {
|
|
162
|
+
if (!sensitivity.key) {
|
|
163
|
+
ctx.addIssue({
|
|
164
|
+
code: "invalid_format",
|
|
165
|
+
format: "regex",
|
|
166
|
+
pattern: "^[a-z0-9][a-z0-9_-]*$",
|
|
167
|
+
path: [
|
|
168
|
+
"sensitivities",
|
|
169
|
+
i,
|
|
170
|
+
"key"
|
|
171
|
+
],
|
|
172
|
+
message: "key is required (lowercase alphanumeric with hyphens/underscores)"
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
}
|
|
139
176
|
});
|
|
140
177
|
|
|
141
178
|
// src/utils/is-existing-path.ts
|
|
@@ -164,6 +201,7 @@ async function loadProjectContext(configPath) {
|
|
|
164
201
|
const config = projectConfigSchema.parse(rawConfig);
|
|
165
202
|
return {
|
|
166
203
|
config,
|
|
204
|
+
configPath: resolvedConfigPath,
|
|
167
205
|
projectRoot
|
|
168
206
|
};
|
|
169
207
|
} catch (error) {
|
|
@@ -298,9 +336,83 @@ function getEnv() {
|
|
|
298
336
|
}
|
|
299
337
|
__name(getEnv, "getEnv");
|
|
300
338
|
|
|
339
|
+
// package.json
|
|
340
|
+
var package_default = {
|
|
341
|
+
name: "@pd4castr/cli",
|
|
342
|
+
version: "1.13.0",
|
|
343
|
+
description: "CLI tool for creating, testing, and publishing pd4castr models",
|
|
344
|
+
license: "MIT",
|
|
345
|
+
main: "dist/index.js",
|
|
346
|
+
private: false,
|
|
347
|
+
type: "module",
|
|
348
|
+
bin: {
|
|
349
|
+
pd4castr: "dist/index.js"
|
|
350
|
+
},
|
|
351
|
+
files: [
|
|
352
|
+
"dist/**/*",
|
|
353
|
+
"LICENSE.md",
|
|
354
|
+
"docs/assets/logo.png"
|
|
355
|
+
],
|
|
356
|
+
engines: {
|
|
357
|
+
node: ">=20.0.0"
|
|
358
|
+
},
|
|
359
|
+
scripts: {
|
|
360
|
+
build: "tsup",
|
|
361
|
+
dev: "tsup --watch",
|
|
362
|
+
pd4castr: "node dist/index.js",
|
|
363
|
+
format: "prettier --write .",
|
|
364
|
+
lint: "eslint .",
|
|
365
|
+
typecheck: "tsc --noEmit",
|
|
366
|
+
prepublishOnly: "pnpm run build"
|
|
367
|
+
},
|
|
368
|
+
dependencies: {
|
|
369
|
+
"@inquirer/prompts": "7.7.1",
|
|
370
|
+
auth0: "4.28.0",
|
|
371
|
+
chalk: "5.6.0",
|
|
372
|
+
commander: "14.0.0",
|
|
373
|
+
execa: "9.6.0",
|
|
374
|
+
express: "4.21.2",
|
|
375
|
+
immer: "10.1.1",
|
|
376
|
+
ky: "1.14.2",
|
|
377
|
+
ora: "8.2.0",
|
|
378
|
+
"promise-retry": "2.0.1",
|
|
379
|
+
slugify: "1.6.6",
|
|
380
|
+
tiged: "2.12.7",
|
|
381
|
+
"tiny-invariant": "1.3.3",
|
|
382
|
+
zod: "4.0.14"
|
|
383
|
+
},
|
|
384
|
+
devDependencies: {
|
|
385
|
+
"@faker-js/faker": "10.0.0",
|
|
386
|
+
"@mswjs/data": "0.16.2",
|
|
387
|
+
"@types/express": "4.17.21",
|
|
388
|
+
"@types/node": "24.1.0",
|
|
389
|
+
"@types/supertest": "6.0.3",
|
|
390
|
+
"hook-std": "3.0.0",
|
|
391
|
+
"jest-extended": "7.0.0",
|
|
392
|
+
memfs: "4.49.0",
|
|
393
|
+
msw: "2.12.9",
|
|
394
|
+
"strip-ansi": "7.1.0",
|
|
395
|
+
supertest: "7.2.2",
|
|
396
|
+
tsup: "8.5.0",
|
|
397
|
+
"type-fest": "4.41.0",
|
|
398
|
+
typescript: "5.8.3",
|
|
399
|
+
vitest: "4.0.18"
|
|
400
|
+
},
|
|
401
|
+
publishConfig: {
|
|
402
|
+
access: "public"
|
|
403
|
+
},
|
|
404
|
+
keywords: [
|
|
405
|
+
"cli",
|
|
406
|
+
"pd4castr"
|
|
407
|
+
]
|
|
408
|
+
};
|
|
409
|
+
|
|
301
410
|
// src/api/api.ts
|
|
302
411
|
var api = ky.create({
|
|
303
|
-
prefixUrl: getEnv().apiURL
|
|
412
|
+
prefixUrl: getEnv().apiURL,
|
|
413
|
+
headers: {
|
|
414
|
+
"X-SDK-Version": `cli/${package_default.version}`
|
|
415
|
+
}
|
|
304
416
|
});
|
|
305
417
|
|
|
306
418
|
// src/api/query-data-fetcher.ts
|
|
@@ -427,7 +539,6 @@ __name(registerFetchCommand, "registerFetchCommand");
|
|
|
427
539
|
// src/commands/init/handle-action.ts
|
|
428
540
|
import path6 from "path";
|
|
429
541
|
import * as inquirer from "@inquirer/prompts";
|
|
430
|
-
import { ExecaError as ExecaError2 } from "execa";
|
|
431
542
|
import ora2 from "ora";
|
|
432
543
|
import tiged from "tiged";
|
|
433
544
|
|
|
@@ -480,16 +591,26 @@ async function handleAction2() {
|
|
|
480
591
|
await fetchTemplate(template, projectName);
|
|
481
592
|
spinner.succeed("Template fetched successfully");
|
|
482
593
|
} catch (error) {
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
594
|
+
if (isDegitError(error)) {
|
|
595
|
+
spinner.fail(formatErrorMessage(DEGIT_CODE_MAP[error.code]));
|
|
596
|
+
} else {
|
|
597
|
+
spinner.fail(formatErrorMessage("UNKNOWN_ERROR"));
|
|
598
|
+
if (error instanceof Error) {
|
|
599
|
+
console.error(error.stack ?? error.message);
|
|
600
|
+
}
|
|
488
601
|
}
|
|
489
602
|
process.exit(1);
|
|
490
603
|
}
|
|
491
604
|
}
|
|
492
605
|
__name(handleAction2, "handleAction");
|
|
606
|
+
var DEGIT_CODE_MAP = {
|
|
607
|
+
COULD_NOT_DOWNLOAD: "TEMPLATE_DOWNLOAD_FAILED",
|
|
608
|
+
COULD_NOT_FETCH: "TEMPLATE_DOWNLOAD_FAILED",
|
|
609
|
+
MISSING_REF: "TEMPLATE_NOT_FOUND",
|
|
610
|
+
BAD_SRC: "TEMPLATE_NOT_FOUND",
|
|
611
|
+
BAD_REF: "TEMPLATE_NOT_FOUND",
|
|
612
|
+
DEST_NOT_EMPTY: "DEST_NOT_EMPTY"
|
|
613
|
+
};
|
|
493
614
|
async function fetchTemplate(template, projectName) {
|
|
494
615
|
const templatePath = getTemplatePath(templates[template]);
|
|
495
616
|
const fetcher = tiged(templatePath, {
|
|
@@ -500,6 +621,20 @@ async function fetchTemplate(template, projectName) {
|
|
|
500
621
|
await fetcher.clone(destination);
|
|
501
622
|
}
|
|
502
623
|
__name(fetchTemplate, "fetchTemplate");
|
|
624
|
+
function isDegitError(error) {
|
|
625
|
+
return error instanceof Error && "code" in error && typeof error.code === "string" && error.code in DEGIT_CODE_MAP;
|
|
626
|
+
}
|
|
627
|
+
__name(isDegitError, "isDegitError");
|
|
628
|
+
var ERROR_MESSAGES = {
|
|
629
|
+
TEMPLATE_DOWNLOAD_FAILED: "Failed to download template. Check your internet connection and try again.",
|
|
630
|
+
TEMPLATE_NOT_FOUND: "Failed to download template. Please try again or report this issue if it persists.",
|
|
631
|
+
DEST_NOT_EMPTY: "Destination directory is not empty.",
|
|
632
|
+
UNKNOWN_ERROR: "An unexpected error occurred. Please try again or report this issue if it persists."
|
|
633
|
+
};
|
|
634
|
+
function formatErrorMessage(code) {
|
|
635
|
+
return `${ERROR_MESSAGES[code]} [CODE:${code}]`;
|
|
636
|
+
}
|
|
637
|
+
__name(formatErrorMessage, "formatErrorMessage");
|
|
503
638
|
|
|
504
639
|
// src/commands/init/index.ts
|
|
505
640
|
function registerInitCommand(program2) {
|
|
@@ -508,7 +643,7 @@ function registerInitCommand(program2) {
|
|
|
508
643
|
__name(registerInitCommand, "registerInitCommand");
|
|
509
644
|
|
|
510
645
|
// src/commands/login/handle-action.ts
|
|
511
|
-
import { ExecaError as
|
|
646
|
+
import { ExecaError as ExecaError2 } from "execa";
|
|
512
647
|
import ora3 from "ora";
|
|
513
648
|
import { ZodError as ZodError3 } from "zod";
|
|
514
649
|
|
|
@@ -624,7 +759,7 @@ async function handleAction3() {
|
|
|
624
759
|
} else if (error instanceof Error) {
|
|
625
760
|
spinner.fail(error.message);
|
|
626
761
|
}
|
|
627
|
-
if (error instanceof Error && error.cause instanceof
|
|
762
|
+
if (error instanceof Error && error.cause instanceof ExecaError2) {
|
|
628
763
|
console.error(error.cause.shortMessage);
|
|
629
764
|
} else if (error instanceof Error && error.cause) {
|
|
630
765
|
console.error(error.cause);
|
|
@@ -641,7 +776,7 @@ function registerLoginCommand(program2) {
|
|
|
641
776
|
__name(registerLoginCommand, "registerLoginCommand");
|
|
642
777
|
|
|
643
778
|
// src/commands/logout/handle-action.ts
|
|
644
|
-
import { ExecaError as
|
|
779
|
+
import { ExecaError as ExecaError3 } from "execa";
|
|
645
780
|
import ora4 from "ora";
|
|
646
781
|
import { ZodError as ZodError4 } from "zod";
|
|
647
782
|
async function handleAction4() {
|
|
@@ -664,7 +799,7 @@ async function handleAction4() {
|
|
|
664
799
|
} else if (error instanceof Error) {
|
|
665
800
|
spinner.fail(error.message);
|
|
666
801
|
}
|
|
667
|
-
if (error instanceof Error && error.cause instanceof
|
|
802
|
+
if (error instanceof Error && error.cause instanceof ExecaError3) {
|
|
668
803
|
console.error(error.cause.shortMessage);
|
|
669
804
|
} else if (error instanceof Error && error.cause) {
|
|
670
805
|
console.error(error.cause);
|
|
@@ -681,7 +816,7 @@ function registerLogoutCommand(program2) {
|
|
|
681
816
|
__name(registerLogoutCommand, "registerLogoutCommand");
|
|
682
817
|
|
|
683
818
|
// src/commands/publish/handle-action.ts
|
|
684
|
-
import { ExecaError as
|
|
819
|
+
import { ExecaError as ExecaError4 } from "execa";
|
|
685
820
|
import express2 from "express";
|
|
686
821
|
import { HTTPError as HTTPError3 } from "ky";
|
|
687
822
|
import ora5 from "ora";
|
|
@@ -840,7 +975,7 @@ async function getModelConfigFromProjectConfig(ctx) {
|
|
|
840
975
|
const sensitivities = await getSensitivitiesWithInlinedSQL(ctx);
|
|
841
976
|
const inputAggregations = await getInputAggregationsWithInlinedSQL(ctx);
|
|
842
977
|
const runDatetimeQuery = await getrunDatetimeQuerySQL(ctx);
|
|
843
|
-
const { $$id, $$modelGroupID, $$revision, $$dockerImage, ...config } = ctx.config;
|
|
978
|
+
const { $$configVersion, $$id, $$modelGroupID, $$revision, $$dockerImage, ...config } = ctx.config;
|
|
844
979
|
return {
|
|
845
980
|
...config,
|
|
846
981
|
id: $$id,
|
|
@@ -1008,7 +1143,7 @@ function getModelSummaryLines(ctx) {
|
|
|
1008
1143
|
] : [],
|
|
1009
1144
|
...ctx.config.sensitivities.length > 0 ? [
|
|
1010
1145
|
` ${chalk2.bold("Sensitivities:")}`,
|
|
1011
|
-
...ctx.config.sensitivities.map((s) => ` \u2022 ${s.name}`)
|
|
1146
|
+
...ctx.config.sensitivities.map((s) => ` \u2022 ${s.name}${s.key ? ` (${s.key})` : ""}`)
|
|
1012
1147
|
] : [],
|
|
1013
1148
|
""
|
|
1014
1149
|
];
|
|
@@ -1405,8 +1540,125 @@ import chalk6 from "chalk";
|
|
|
1405
1540
|
import * as inquirer3 from "@inquirer/prompts";
|
|
1406
1541
|
import chalk4 from "chalk";
|
|
1407
1542
|
|
|
1408
|
-
// src/
|
|
1543
|
+
// src/utils/migrate-config.ts
|
|
1544
|
+
import fs11 from "fs/promises";
|
|
1545
|
+
import invariant4 from "tiny-invariant";
|
|
1546
|
+
|
|
1547
|
+
// src/migrations/01-backfill-output-variable-keys.ts
|
|
1409
1548
|
import invariant2 from "tiny-invariant";
|
|
1549
|
+
var backfillOutputVariableKeys = {
|
|
1550
|
+
version: 1,
|
|
1551
|
+
description: "Backfill output variable keys from published model",
|
|
1552
|
+
migrate(config, ctx) {
|
|
1553
|
+
const outputsMissingKeys = config.outputs.filter((output) => !output.key);
|
|
1554
|
+
if (outputsMissingKeys.length === 0) {
|
|
1555
|
+
return config;
|
|
1556
|
+
}
|
|
1557
|
+
invariant2(ctx.publishedModel, "Published model is required to backfill output variable keys");
|
|
1558
|
+
const publishedKeysByName = /* @__PURE__ */ new Map();
|
|
1559
|
+
for (const published of ctx.publishedModel.outputVariables) {
|
|
1560
|
+
publishedKeysByName.set(published.name, published.key);
|
|
1561
|
+
}
|
|
1562
|
+
const unmatchedOutputs = [];
|
|
1563
|
+
const updatedOutputs = config.outputs.map((output) => {
|
|
1564
|
+
if (output.key) {
|
|
1565
|
+
return output;
|
|
1566
|
+
}
|
|
1567
|
+
const publishedKey = publishedKeysByName.get(output.name);
|
|
1568
|
+
if (publishedKey) {
|
|
1569
|
+
return {
|
|
1570
|
+
...output,
|
|
1571
|
+
key: publishedKey
|
|
1572
|
+
};
|
|
1573
|
+
}
|
|
1574
|
+
unmatchedOutputs.push(output.name);
|
|
1575
|
+
return output;
|
|
1576
|
+
});
|
|
1577
|
+
if (unmatchedOutputs.length > 0) {
|
|
1578
|
+
throw new Error(`The following outputs need a \`key\` defined in .pd4castrrc.json:
|
|
1579
|
+
${unmatchedOutputs.map((name) => ` - ${name}`).join("\n")}
|
|
1580
|
+
|
|
1581
|
+
Set a unique key (lowercase alphanumeric with hyphens/underscores) for each output.`);
|
|
1582
|
+
}
|
|
1583
|
+
return {
|
|
1584
|
+
...config,
|
|
1585
|
+
outputs: updatedOutputs
|
|
1586
|
+
};
|
|
1587
|
+
}
|
|
1588
|
+
};
|
|
1589
|
+
|
|
1590
|
+
// src/migrations/02-backfill-sensitivity-keys.ts
|
|
1591
|
+
import invariant3 from "tiny-invariant";
|
|
1592
|
+
var backfillSensitivityKeys = {
|
|
1593
|
+
version: 2,
|
|
1594
|
+
description: "Backfill sensitivity keys from published model",
|
|
1595
|
+
migrate(config, ctx) {
|
|
1596
|
+
const sensitivitiesMissingKeys = (config.sensitivities ?? []).filter((sensitivity) => !sensitivity.key);
|
|
1597
|
+
if (sensitivitiesMissingKeys.length === 0) {
|
|
1598
|
+
return config;
|
|
1599
|
+
}
|
|
1600
|
+
invariant3(ctx.publishedModel, "Published model is required to backfill sensitivity keys");
|
|
1601
|
+
const publishedKeysByName = /* @__PURE__ */ new Map();
|
|
1602
|
+
for (const published of ctx.publishedModel.sensitivities) {
|
|
1603
|
+
publishedKeysByName.set(published.name, published.key);
|
|
1604
|
+
}
|
|
1605
|
+
const unmatchedSensitivities = [];
|
|
1606
|
+
const updatedSensitivities = config.sensitivities.map((sensitivity) => {
|
|
1607
|
+
if (sensitivity.key) {
|
|
1608
|
+
return sensitivity;
|
|
1609
|
+
}
|
|
1610
|
+
const publishedKey = publishedKeysByName.get(sensitivity.name);
|
|
1611
|
+
if (publishedKey) {
|
|
1612
|
+
return {
|
|
1613
|
+
...sensitivity,
|
|
1614
|
+
key: publishedKey
|
|
1615
|
+
};
|
|
1616
|
+
}
|
|
1617
|
+
unmatchedSensitivities.push(sensitivity.name);
|
|
1618
|
+
return sensitivity;
|
|
1619
|
+
});
|
|
1620
|
+
if (unmatchedSensitivities.length > 0) {
|
|
1621
|
+
throw new Error(`The following sensitivities need a \`key\` defined in .pd4castrrc.json:
|
|
1622
|
+
${unmatchedSensitivities.map((name) => ` - ${name}`).join("\n")}
|
|
1623
|
+
|
|
1624
|
+
Set a unique key (lowercase alphanumeric with hyphens/underscores) for each sensitivity.`);
|
|
1625
|
+
}
|
|
1626
|
+
return {
|
|
1627
|
+
...config,
|
|
1628
|
+
sensitivities: updatedSensitivities
|
|
1629
|
+
};
|
|
1630
|
+
}
|
|
1631
|
+
};
|
|
1632
|
+
|
|
1633
|
+
// src/migrations/index.ts
|
|
1634
|
+
var migrations = [
|
|
1635
|
+
backfillOutputVariableKeys,
|
|
1636
|
+
backfillSensitivityKeys
|
|
1637
|
+
];
|
|
1638
|
+
|
|
1639
|
+
// src/utils/migrate-config.ts
|
|
1640
|
+
async function migrateConfig(ctx, migrationCtx) {
|
|
1641
|
+
const pendingMigrations = migrations.filter((migration) => migration.version > ctx.config.$$configVersion).sort((a, b) => a.version - b.version);
|
|
1642
|
+
if (pendingMigrations.length === 0) {
|
|
1643
|
+
return;
|
|
1644
|
+
}
|
|
1645
|
+
let config = ctx.config;
|
|
1646
|
+
for (const migration of pendingMigrations) {
|
|
1647
|
+
config = migration.migrate(config, migrationCtx);
|
|
1648
|
+
}
|
|
1649
|
+
const lastMigration = pendingMigrations.at(-1);
|
|
1650
|
+
invariant4(lastMigration, "expected at least one pending migration");
|
|
1651
|
+
config = {
|
|
1652
|
+
...config,
|
|
1653
|
+
$$configVersion: lastMigration.version
|
|
1654
|
+
};
|
|
1655
|
+
ctx.config = config;
|
|
1656
|
+
await fs11.writeFile(ctx.configPath, JSON.stringify(config, null, 2) + "\n", "utf8");
|
|
1657
|
+
}
|
|
1658
|
+
__name(migrateConfig, "migrateConfig");
|
|
1659
|
+
|
|
1660
|
+
// src/commands/publish/utils/validate-local-model-state.ts
|
|
1661
|
+
import invariant5 from "tiny-invariant";
|
|
1410
1662
|
|
|
1411
1663
|
// src/api/get-model.ts
|
|
1412
1664
|
async function getModel(modelId, authCtx) {
|
|
@@ -1422,7 +1674,7 @@ __name(getModel, "getModel");
|
|
|
1422
1674
|
|
|
1423
1675
|
// src/commands/publish/utils/validate-local-model-state.ts
|
|
1424
1676
|
async function validateLocalModelState(ctx, authCtx) {
|
|
1425
|
-
|
|
1677
|
+
invariant5(ctx.config.$$id, "model ID is required to fetch published model");
|
|
1426
1678
|
const currentModel = await getModel(ctx.config.$$id, authCtx);
|
|
1427
1679
|
if (currentModel.revision !== ctx.config.$$revision) {
|
|
1428
1680
|
throw new Error(`OUT OF SYNC: Local revision (${ctx.config.$$revision}) does not match the current published revision (${currentModel.revision})`);
|
|
@@ -1430,6 +1682,7 @@ async function validateLocalModelState(ctx, authCtx) {
|
|
|
1430
1682
|
if (currentModel.modelGroupId !== ctx.config.$$modelGroupID) {
|
|
1431
1683
|
throw new Error(`OUT OF SYNC: Local model group ID (${ctx.config.$$modelGroupID}) does not match the current published model group ID (${currentModel.modelGroupId})`);
|
|
1432
1684
|
}
|
|
1685
|
+
return currentModel;
|
|
1433
1686
|
}
|
|
1434
1687
|
__name(validateLocalModelState, "validateLocalModelState");
|
|
1435
1688
|
|
|
@@ -1449,7 +1702,10 @@ async function handleModelRevisionCreateFlow(options, app, spinner, ctx, authCtx
|
|
|
1449
1702
|
throw new Error("Model revision update cancelled");
|
|
1450
1703
|
}
|
|
1451
1704
|
spinner.start("Validating local model state...");
|
|
1452
|
-
await validateLocalModelState(ctx, authCtx);
|
|
1705
|
+
const publishedModel = await validateLocalModelState(ctx, authCtx);
|
|
1706
|
+
await migrateConfig(ctx, {
|
|
1707
|
+
publishedModel
|
|
1708
|
+
});
|
|
1453
1709
|
spinner.succeed("Local model is synced with published model");
|
|
1454
1710
|
const dockerImage = getDockerImage(ctx);
|
|
1455
1711
|
if (!options.skipChecks) {
|
|
@@ -1537,7 +1793,10 @@ async function handleModelRevisionUpdateFlow(options, app, spinner, ctx, authCtx
|
|
|
1537
1793
|
throw new Error("Model revision update cancelled");
|
|
1538
1794
|
}
|
|
1539
1795
|
spinner.start("Validating local model state...");
|
|
1540
|
-
await validateLocalModelState(ctx, authCtx);
|
|
1796
|
+
const publishedModel = await validateLocalModelState(ctx, authCtx);
|
|
1797
|
+
await migrateConfig(ctx, {
|
|
1798
|
+
publishedModel
|
|
1799
|
+
});
|
|
1541
1800
|
spinner.succeed("Local model is synced with published model");
|
|
1542
1801
|
const dockerImage = getDockerImage(ctx);
|
|
1543
1802
|
if (!options.skipChecks) {
|
|
@@ -1724,7 +1983,7 @@ async function handleAction5(options) {
|
|
|
1724
1983
|
} else if (error instanceof Error) {
|
|
1725
1984
|
spinner.fail(error.message);
|
|
1726
1985
|
}
|
|
1727
|
-
if (error instanceof Error && error.cause instanceof
|
|
1986
|
+
if (error instanceof Error && error.cause instanceof ExecaError4) {
|
|
1728
1987
|
console.error(error.cause.stderr);
|
|
1729
1988
|
} else if (error instanceof Error && error.cause) {
|
|
1730
1989
|
console.error(error.cause);
|
|
@@ -1748,7 +2007,7 @@ __name(registerPublishCommand, "registerPublishCommand");
|
|
|
1748
2007
|
|
|
1749
2008
|
// src/commands/test/handle-action.ts
|
|
1750
2009
|
import path16 from "path";
|
|
1751
|
-
import { ExecaError as
|
|
2010
|
+
import { ExecaError as ExecaError5 } from "execa";
|
|
1752
2011
|
import express3 from "express";
|
|
1753
2012
|
import ora6 from "ora";
|
|
1754
2013
|
import { ZodError as ZodError6 } from "zod";
|
|
@@ -1879,7 +2138,7 @@ ${clickHereLink} to view output (${fileLink})
|
|
|
1879
2138
|
} else if (error instanceof Error) {
|
|
1880
2139
|
spinner.fail(error.message);
|
|
1881
2140
|
}
|
|
1882
|
-
if (error instanceof Error && error.cause instanceof
|
|
2141
|
+
if (error instanceof Error && error.cause instanceof ExecaError5) {
|
|
1883
2142
|
console.error(error.cause.stderr);
|
|
1884
2143
|
} else if (error instanceof Error && error.cause) {
|
|
1885
2144
|
console.error(error.cause);
|
|
@@ -1903,79 +2162,6 @@ __name(registerTestCommand, "registerTestCommand");
|
|
|
1903
2162
|
|
|
1904
2163
|
// src/program.ts
|
|
1905
2164
|
import { Command } from "commander";
|
|
1906
|
-
|
|
1907
|
-
// package.json
|
|
1908
|
-
var package_default = {
|
|
1909
|
-
name: "@pd4castr/cli",
|
|
1910
|
-
version: "1.11.0",
|
|
1911
|
-
description: "CLI tool for creating, testing, and publishing pd4castr models",
|
|
1912
|
-
license: "MIT",
|
|
1913
|
-
main: "dist/index.js",
|
|
1914
|
-
private: false,
|
|
1915
|
-
type: "module",
|
|
1916
|
-
bin: {
|
|
1917
|
-
pd4castr: "dist/index.js"
|
|
1918
|
-
},
|
|
1919
|
-
files: [
|
|
1920
|
-
"dist/**/*",
|
|
1921
|
-
"LICENSE.md",
|
|
1922
|
-
"docs/assets/logo.png"
|
|
1923
|
-
],
|
|
1924
|
-
engines: {
|
|
1925
|
-
node: ">=20.0.0"
|
|
1926
|
-
},
|
|
1927
|
-
scripts: {
|
|
1928
|
-
build: "tsup",
|
|
1929
|
-
dev: "tsup --watch",
|
|
1930
|
-
pd4castr: "node dist/index.js",
|
|
1931
|
-
format: "prettier --write .",
|
|
1932
|
-
lint: "eslint .",
|
|
1933
|
-
typecheck: "tsc --noEmit",
|
|
1934
|
-
prepublishOnly: "yarn build"
|
|
1935
|
-
},
|
|
1936
|
-
dependencies: {
|
|
1937
|
-
"@inquirer/prompts": "7.7.1",
|
|
1938
|
-
auth0: "4.28.0",
|
|
1939
|
-
chalk: "5.6.0",
|
|
1940
|
-
commander: "14.0.0",
|
|
1941
|
-
execa: "9.6.0",
|
|
1942
|
-
express: "4.21.2",
|
|
1943
|
-
immer: "10.1.1",
|
|
1944
|
-
ky: "1.14.2",
|
|
1945
|
-
ora: "8.2.0",
|
|
1946
|
-
"promise-retry": "2.0.1",
|
|
1947
|
-
slugify: "1.6.6",
|
|
1948
|
-
tiged: "2.12.7",
|
|
1949
|
-
"tiny-invariant": "1.3.3",
|
|
1950
|
-
zod: "4.0.14"
|
|
1951
|
-
},
|
|
1952
|
-
devDependencies: {
|
|
1953
|
-
"@faker-js/faker": "10.0.0",
|
|
1954
|
-
"@mswjs/data": "0.16.2",
|
|
1955
|
-
"@types/express": "4.17.21",
|
|
1956
|
-
"@types/node": "24.1.0",
|
|
1957
|
-
"@types/supertest": "6.0.3",
|
|
1958
|
-
"hook-std": "3.0.0",
|
|
1959
|
-
"jest-extended": "7.0.0",
|
|
1960
|
-
memfs: "4.49.0",
|
|
1961
|
-
msw: "2.12.9",
|
|
1962
|
-
"strip-ansi": "7.1.0",
|
|
1963
|
-
supertest: "7.2.2",
|
|
1964
|
-
tsup: "8.5.0",
|
|
1965
|
-
"type-fest": "4.41.0",
|
|
1966
|
-
typescript: "5.8.3",
|
|
1967
|
-
vitest: "4.0.18"
|
|
1968
|
-
},
|
|
1969
|
-
publishConfig: {
|
|
1970
|
-
access: "public"
|
|
1971
|
-
},
|
|
1972
|
-
keywords: [
|
|
1973
|
-
"cli",
|
|
1974
|
-
"pd4castr"
|
|
1975
|
-
]
|
|
1976
|
-
};
|
|
1977
|
-
|
|
1978
|
-
// src/program.ts
|
|
1979
2165
|
var program = new Command();
|
|
1980
2166
|
program.name("pd4castr").description("CLI tool for pd4castr").version(package_default.version);
|
|
1981
2167
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pd4castr/cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.13.0",
|
|
4
4
|
"description": "CLI tool for creating, testing, and publishing pd4castr models",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"format": "prettier --write .",
|
|
25
25
|
"lint": "eslint .",
|
|
26
26
|
"typecheck": "tsc --noEmit",
|
|
27
|
-
"prepublishOnly": "
|
|
27
|
+
"prepublishOnly": "pnpm run build"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@inquirer/prompts": "7.7.1",
|