@tolstoy-ai/cli 0.1.0 → 0.1.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/build/cli.js +20 -17
- package/package.json +2 -2
package/build/cli.js
CHANGED
|
@@ -28418,6 +28418,7 @@ var CLI_REGISTRY = [
|
|
|
28418
28418
|
|
|
28419
28419
|
// src/command-builder.ts
|
|
28420
28420
|
var camelToKebab = (str) => str.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
|
|
28421
|
+
var zodTypeName = (schema) => schema._def?.typeName ?? "";
|
|
28421
28422
|
var unwrapZodType = (schema) => {
|
|
28422
28423
|
let isOptional = false;
|
|
28423
28424
|
let defaultValue;
|
|
@@ -28427,19 +28428,20 @@ var unwrapZodType = (schema) => {
|
|
|
28427
28428
|
if (current._def.description) {
|
|
28428
28429
|
description = current._def.description;
|
|
28429
28430
|
}
|
|
28430
|
-
|
|
28431
|
+
const tn = zodTypeName(current);
|
|
28432
|
+
if (tn === "ZodOptional") {
|
|
28431
28433
|
isOptional = true;
|
|
28432
28434
|
current = current._def.innerType;
|
|
28433
|
-
} else if (
|
|
28435
|
+
} else if (tn === "ZodDefault") {
|
|
28434
28436
|
isOptional = true;
|
|
28435
28437
|
defaultValue = current._def.defaultValue();
|
|
28436
28438
|
current = current._def.innerType;
|
|
28437
|
-
} else if (
|
|
28439
|
+
} else if (tn === "ZodNullable") {
|
|
28438
28440
|
isOptional = true;
|
|
28439
28441
|
current = current._def.innerType;
|
|
28440
|
-
} else if (
|
|
28442
|
+
} else if (tn === "ZodEffects") {
|
|
28441
28443
|
current = current._def.schema;
|
|
28442
|
-
} else if (
|
|
28444
|
+
} else if (tn === "ZodPipeline") {
|
|
28443
28445
|
current = current._def.in;
|
|
28444
28446
|
} else {
|
|
28445
28447
|
break;
|
|
@@ -28448,21 +28450,22 @@ var unwrapZodType = (schema) => {
|
|
|
28448
28450
|
return { inner: current, isOptional, defaultValue, description };
|
|
28449
28451
|
};
|
|
28450
28452
|
var getZodFlagType = (schema) => {
|
|
28451
|
-
|
|
28452
|
-
if (
|
|
28453
|
-
if (
|
|
28454
|
-
if (
|
|
28455
|
-
if (
|
|
28456
|
-
if (
|
|
28457
|
-
if (
|
|
28453
|
+
const tn = zodTypeName(schema);
|
|
28454
|
+
if (tn === "ZodString") return { type: "string" };
|
|
28455
|
+
if (tn === "ZodNumber") return { type: "number" };
|
|
28456
|
+
if (tn === "ZodBoolean") return { type: "boolean" };
|
|
28457
|
+
if (tn === "ZodEnum") return { type: "string", enumValues: schema._def.values };
|
|
28458
|
+
if (tn === "ZodNativeEnum") return { type: "string", enumValues: Object.values(schema._def.values) };
|
|
28459
|
+
if (tn === "ZodArray") return { type: "array" };
|
|
28460
|
+
if (tn === "ZodLiteral") {
|
|
28458
28461
|
const val = schema._def.value;
|
|
28459
28462
|
if (typeof val === "boolean") return { type: "boolean" };
|
|
28460
28463
|
if (typeof val === "number") return { type: "number" };
|
|
28461
28464
|
return { type: "string" };
|
|
28462
28465
|
}
|
|
28463
|
-
if (
|
|
28466
|
+
if (tn === "ZodUnion") {
|
|
28464
28467
|
const options = schema._def.options;
|
|
28465
|
-
const allLiterals = options.every((o) => o
|
|
28468
|
+
const allLiterals = options.every((o) => zodTypeName(o) === "ZodLiteral");
|
|
28466
28469
|
if (allLiterals) {
|
|
28467
28470
|
return { type: "string", enumValues: options.map((o) => String(o._def.value)) };
|
|
28468
28471
|
}
|
|
@@ -28471,7 +28474,7 @@ var getZodFlagType = (schema) => {
|
|
|
28471
28474
|
};
|
|
28472
28475
|
var AUTO_RESOLVED_FIELDS = /* @__PURE__ */ new Set(["appKey", "appUrl"]);
|
|
28473
28476
|
var extractFlags = (schema) => {
|
|
28474
|
-
if (
|
|
28477
|
+
if (zodTypeName(schema) !== "ZodObject") return [];
|
|
28475
28478
|
const shape = schema._def.shape();
|
|
28476
28479
|
const flags = [];
|
|
28477
28480
|
for (const [key, fieldSchema] of Object.entries(shape)) {
|
|
@@ -28745,7 +28748,7 @@ var printError = (message) => {
|
|
|
28745
28748
|
};
|
|
28746
28749
|
|
|
28747
28750
|
// src/cli.ts
|
|
28748
|
-
var VERSION = "0.1.
|
|
28751
|
+
var VERSION = "0.1.1";
|
|
28749
28752
|
var GLOBAL_FLAGS = ["--api-key", "--json", "--dry-run", "--verbose", "--help", "--version"];
|
|
28750
28753
|
var extractGlobalFlag = (argv, flag) => {
|
|
28751
28754
|
const idx = argv.indexOf(flag);
|
|
@@ -28958,7 +28961,7 @@ var handleAuth = (argv) => {
|
|
|
28958
28961
|
process.exit(1);
|
|
28959
28962
|
};
|
|
28960
28963
|
var makeFieldsOptional = (schema, fieldNames) => {
|
|
28961
|
-
if (
|
|
28964
|
+
if (schema._def?.typeName !== "ZodObject") return schema;
|
|
28962
28965
|
const shape = schema._def.shape();
|
|
28963
28966
|
const newShape = {};
|
|
28964
28967
|
for (const [key, value] of Object.entries(shape)) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tolstoy-ai/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"bin": {
|
|
5
5
|
"tolstoy": "./build/cli.js"
|
|
6
6
|
},
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"prebuild": "pnpm generate:registry",
|
|
17
17
|
"build": "rm -rf build && esbuild src/cli.ts --bundle --platform=node --target=node20 --outfile=build/cli.js --format=cjs --banner:js='#!/usr/bin/env node'",
|
|
18
18
|
"lint": "biome check --max-diagnostics=none .",
|
|
19
|
-
"deploy:prod": "npm publish --access public"
|
|
19
|
+
"deploy:prod": "npm publish --access public 2>&1 || echo 'Publish skipped (version may already exist)'"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
22
|
"@tolstoy/api-commons": "workspace:*",
|