@tscircuit/cli 0.0.15 → 0.0.17

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 CHANGED
@@ -206,85 +206,6 @@ import {perfectCli} from "perfect-cli";
206
206
 
207
207
  // lib/get-program.ts
208
208
  import {Command} from "commander";
209
- // package.json
210
- var package_default = {
211
- name: "@tscircuit/cli",
212
- version: "0.0.14",
213
- private: false,
214
- type: "module",
215
- description: "Command line tool for developing, publishing and installing tscircuit circuits",
216
- main: "./dist/cli.js",
217
- scripts: {
218
- bootstrap: "bun i --frozen-lockfile && cd dev-server-api && bun i --frozen-lockfile && cd ../dev-server-frontend && bun i --frozen-lockfile",
219
- start: "bun cli.ts",
220
- "start:dev-server:dev": "TSCI_DEV_SERVER_DB=$(pwd)/.tscircuit/dev-server.db concurrently 'cd dev-server-api && bun start' 'cd dev-server-frontend && bun start'",
221
- "start:dev-server": "bun build:dev-server && bun cli.ts dev -y --cwd ./tests/assets/example-project",
222
- "build:dev-server": "cd dev-server-api && bun run build && cd ../dev-server-frontend && bun run build",
223
- "build:cli": "bun build-cli.ts",
224
- build: "bun build:dev-server && npm run build:cli",
225
- "test:init": "bun cli.ts init --dir ./tmp/test --name test"
226
- },
227
- bin: {
228
- tscircuit: "./dist/cli.js",
229
- tsci: "./dist/cli.js"
230
- },
231
- keywords: [
232
- "circuit",
233
- "react",
234
- "electronics",
235
- "pcb",
236
- "schematic"
237
- ],
238
- author: "",
239
- license: "ISC",
240
- dependencies: {
241
- "@edge-runtime/primitives": "^4.1.0",
242
- "@hono/node-server": "^1.8.2",
243
- "@tscircuit/builder": "^1.5.4",
244
- "@tscircuit/react-fiber": "^1.0.6",
245
- axios: "^1.6.7",
246
- "better-sqlite3": "^9.4.3",
247
- chokidar: "^3.6.0",
248
- commander: "^12.0.0",
249
- configstore: "^6.0.0",
250
- dargs: "^8.1.0",
251
- "dax-sh": "^0.39.2",
252
- delay: "^6.0.0",
253
- edgespec: "^0.0.69",
254
- esbuild: "^0.20.2",
255
- glob: "^10.3.10",
256
- hono: "^4.1.0",
257
- ignore: "^5.3.1",
258
- kleur: "^4.1.5",
259
- "kysely-bun-sqlite": "^0.3.2",
260
- lodash: "^4.17.21",
261
- "mime-types": "^2.1.35",
262
- minimist: "^1.2.8",
263
- "node-persist": "^4.0.1",
264
- open: "^10.1.0",
265
- "perfect-cli": "^1.0.16",
266
- prompts: "^2.4.2",
267
- react: "^18.2.0",
268
- semver: "^7.6.0",
269
- zod: "latest"
270
- },
271
- devDependencies: {
272
- "@types/bun": "^1.0.8",
273
- "@types/chokidar": "^2.1.3",
274
- "@types/configstore": "^6.0.2",
275
- "@types/lodash": "^4.14.202",
276
- "@types/mime-types": "^2.1.4",
277
- "@types/minimist": "^1.2.5",
278
- "@types/node": "^20.10.6",
279
- "@types/prompts": "^2.4.9",
280
- "@types/react": "^18.2.64",
281
- "@types/semver": "^7.5.8",
282
- ava: "^6.1.1",
283
- concurrently: "^8.2.2",
284
- tsx: "^4.7.1",
285
- typescript: "^5.3.3"
286
- }
287
- };
288
209
 
289
210
  // lib/cmd-fns/config-reveal-location.ts
290
211
  var configRevealLocation = async (ctx, args2) => {
@@ -294,6 +215,7 @@ var configRevealLocation = async (ctx, args2) => {
294
215
  import {z} from "zod";
295
216
  var configSetRegistry = async (ctx, args2) => {
296
217
  const params = z.object({ server: z.string().url() }).parse(args2);
218
+ ctx.profile_config.clear();
297
219
  ctx.profile_config.set("registry_url", params.server);
298
220
  };
299
221
  // lib/cmd-fns/config-set-session.ts
@@ -454,14 +376,47 @@ var packageReleasesCreate = async (ctx, args2) => {
454
376
  }).then((r) => r.data.package_release);
455
377
  console.log(`Package release created! ${kleur2.gray(package_release.package_release_id)}`);
456
378
  };
457
- // lib/cmd-fns/package-files-list.ts
379
+ // lib/cmd-fns/package-releases-update.ts
458
380
  import {z as z8} from "zod";
459
- var packageFilesList = async (ctx, args2) => {
381
+ var packageReleasesUpdate = async (ctx, args2) => {
460
382
  const params = z8.object({
461
- packageReleaseId: z8.string().optional(),
462
- packageName: z8.string().optional(),
463
383
  packageNameWithVersion: z8.string().optional(),
464
- verbose: z8.boolean().optional()
384
+ packageName: z8.string().optional(),
385
+ version: z8.string().optional(),
386
+ isLatest: z8.boolean().optional(),
387
+ isLocked: z8.boolean().optional()
388
+ }).refine((d) => {
389
+ if (d.packageNameWithVersion)
390
+ return true;
391
+ if (d.packageName && d.version)
392
+ return true;
393
+ return false;
394
+ }, "Either packageNameWithVersion or packageName and version must be provided").parse(args2);
395
+ let { packageNameWithVersion, packageName, version } = params;
396
+ if (!packageNameWithVersion) {
397
+ packageNameWithVersion = `${packageName}@${version}`;
398
+ }
399
+ const delta = {};
400
+ if (params.isLatest !== undefined) {
401
+ delta.is_latest = params.isLatest;
402
+ }
403
+ if (params.isLocked !== undefined) {
404
+ delta.is_locked = params.isLocked;
405
+ }
406
+ await ctx.axios.post("/package_releases/update", {
407
+ package_name_with_version: packageNameWithVersion,
408
+ ...delta
409
+ });
410
+ console.log(`Package release updated!`);
411
+ };
412
+ // lib/cmd-fns/package-files-list.ts
413
+ import {z as z9} from "zod";
414
+ var packageFilesList = async (ctx, args2) => {
415
+ const params = z9.object({
416
+ packageReleaseId: z9.string().optional(),
417
+ packageName: z9.string().optional(),
418
+ packageNameWithVersion: z9.string().optional(),
419
+ verbose: z9.boolean().optional()
465
420
  }).parse(args2);
466
421
  const package_files = await ctx.axios.post("/package_files/list", {
467
422
  package_release_id: params.packageReleaseId,
@@ -479,13 +434,13 @@ var packageFilesList = async (ctx, args2) => {
479
434
  var packageFilesGet = async (ctx, args2) => {
480
435
  };
481
436
  // lib/cmd-fns/package-files-download.ts
482
- import {z as z9} from "zod";
437
+ import {z as z10} from "zod";
483
438
  import * as fs from "fs/promises";
484
439
  var packageFilesDownload = async (ctx, args2) => {
485
- const params = z9.object({
486
- packageNameWithVersion: z9.string().optional(),
487
- remoteFilePath: z9.string().optional(),
488
- output: z9.string().optional()
440
+ const params = z10.object({
441
+ packageNameWithVersion: z10.string().optional(),
442
+ remoteFilePath: z10.string().optional(),
443
+ output: z10.string().optional()
489
444
  }).parse(args2);
490
445
  const { packageNameWithVersion, remoteFilePath } = params;
491
446
  const packageContent = await ctx.axios.post("/package_files/download", {
@@ -500,14 +455,14 @@ var packageFilesDownload = async (ctx, args2) => {
500
455
  }
501
456
  };
502
457
  // lib/cmd-fns/package-files-create.ts
503
- import {z as z10} from "zod";
458
+ import {z as z11} from "zod";
504
459
  import * as fs2 from "fs/promises";
505
460
  import kleur3 from "kleur";
506
461
  var packageFilesCreate = async (ctx, args2) => {
507
- const params = z10.object({
508
- file: z10.string(),
509
- packageReleaseId: z10.string().optional(),
510
- packageNameWithVersion: z10.string().optional()
462
+ const params = z11.object({
463
+ file: z11.string(),
464
+ packageReleaseId: z11.string().optional(),
465
+ packageNameWithVersion: z11.string().optional()
511
466
  }).parse(args2);
512
467
  const { file, packageNameWithVersion, packageReleaseId } = params;
513
468
  const fileContent = await fs2.readFile(file);
@@ -520,10 +475,10 @@ var packageFilesCreate = async (ctx, args2) => {
520
475
  console.log(`Package file created ${kleur3.gray(package_file.package_file_id)}`);
521
476
  };
522
477
  // lib/cmd-fns/package-examples-list.ts
523
- import {z as z11} from "zod";
478
+ import {z as z12} from "zod";
524
479
  var packageExamplesList = async (ctx, args2) => {
525
- const params = z11.object({
526
- packageNameWithVersion: z11.string()
480
+ const params = z12.object({
481
+ packageNameWithVersion: z12.string()
527
482
  }).parse(args2);
528
483
  const package_examples = await ctx.axios.post("/package_examples/list", {
529
484
  package_name_with_version: params.packageNameWithVersion
@@ -531,10 +486,10 @@ var packageExamplesList = async (ctx, args2) => {
531
486
  console.log(package_examples);
532
487
  };
533
488
  // lib/cmd-fns/package-examples-get.ts
534
- import {z as z12} from "zod";
489
+ import {z as z13} from "zod";
535
490
  var packageExamplesGet = async (ctx, args2) => {
536
- const params = z12.object({
537
- packageExampleId: z12.string().uuid()
491
+ const params = z13.object({
492
+ packageExampleId: z13.string().uuid()
538
493
  }).parse(args2);
539
494
  const { packageExampleId: package_example_id } = params;
540
495
  const package_example = await ctx.axios.post("/package_examples/get", {
@@ -593,13 +548,13 @@ console.log(JSON.stringify(elements))
593
548
  };
594
549
 
595
550
  // lib/cmd-fns/package-examples-create.ts
596
- import {z as z13} from "zod";
551
+ import {z as z14} from "zod";
597
552
  import fs3 from "fs";
598
553
  var packageExamplesCreate = async (ctx, args2) => {
599
- const params = z13.object({
600
- packageNameWithVersion: z13.string(),
601
- file: z13.string(),
602
- export: z13.string().optional().default("default")
554
+ const params = z14.object({
555
+ packageNameWithVersion: z14.string(),
556
+ file: z14.string(),
557
+ export: z14.string().optional().default("default")
603
558
  }).parse(args2);
604
559
  const tscircuit_soup = await soupify({
605
560
  filePath: params.file,
@@ -617,7 +572,7 @@ var packageExamplesCreate = async (ctx, args2) => {
617
572
  };
618
573
  // lib/cmd-fns/publish/index.ts
619
574
  import kleur4 from "kleur";
620
- import {z as z14} from "zod";
575
+ import {z as z15} from "zod";
621
576
  import * as Path2 from "path";
622
577
  import * as fs5 from "fs/promises";
623
578
  import {readFileSync} from "fs";
@@ -693,10 +648,10 @@ import semver from "semver";
693
648
  import {unlink as unlink2} from "fs/promises";
694
649
  import esbuild from "esbuild";
695
650
  var publish = async (ctx, args2) => {
696
- const params = z14.object({
697
- increment: z14.boolean().optional(),
698
- patch: z14.boolean().optional(),
699
- lock: z14.boolean().optional()
651
+ const params = z15.object({
652
+ increment: z15.boolean().optional(),
653
+ patch: z15.boolean().optional(),
654
+ lock: z15.boolean().optional()
700
655
  }).parse(args2);
701
656
  if (typeof Bun === "undefined") {
702
657
  console.log(kleur4.red("\n\n----------------------------------\nBun is currently required for publishing packages to the tscircuit registry. Try installing bun:\nhhttps://bun.sh/docs/installation\n\n---------------------"));
@@ -846,13 +801,13 @@ var publish = async (ctx, args2) => {
846
801
  console.log(kleur4.green(`Published ${name}@${version}!\nhttps://registry.tscircuit.com/${name}`));
847
802
  };
848
803
  // lib/cmd-fns/soupify.ts
849
- import {z as z15} from "zod";
804
+ import {z as z16} from "zod";
850
805
  import {writeFileSync as writeFileSync2} from "fs";
851
806
  var soupifyCmd = async (ctx, args2) => {
852
- const params = z15.object({
853
- file: z15.string(),
854
- export: z15.string().optional(),
855
- output: z15.string().optional()
807
+ const params = z16.object({
808
+ file: z16.string(),
809
+ export: z16.string().optional(),
810
+ output: z16.string().optional()
856
811
  }).parse(args2);
857
812
  const soup = await soupify({
858
813
  filePath: params.file,
@@ -865,7 +820,7 @@ var soupifyCmd = async (ctx, args2) => {
865
820
  }
866
821
  };
867
822
  // lib/cmd-fns/dev/index.ts
868
- import {z as z18} from "zod";
823
+ import {z as z19} from "zod";
869
824
  import kleur11 from "kleur";
870
825
  import prompts2 from "prompts";
871
826
  import open from "open";
@@ -879,7 +834,7 @@ import {mkdirSync} from "fs";
879
834
  import * as Path3 from "path";
880
835
  import kleur5 from "kleur";
881
836
  import"edgespec/middleware";
882
- import {z as z16} from "zod";
837
+ import {z as z17} from "zod";
883
838
  import {NotFoundError as NotFoundError2} from "edgespec/middleware";
884
839
  import {z as z22} from "zod";
885
840
  import {z as z32} from "zod";
@@ -962,17 +917,17 @@ var withEdgeSpec = createWithEdgeSpec({
962
917
  });
963
918
  var create_default = withEdgeSpec({
964
919
  methods: ["POST"],
965
- jsonBody: z16.object({
966
- file_path: z16.string(),
967
- export_name: z16.string().default("default"),
968
- tscircuit_soup: z16.any()
920
+ jsonBody: z17.object({
921
+ file_path: z17.string(),
922
+ export_name: z17.string().default("default"),
923
+ tscircuit_soup: z17.any()
969
924
  }),
970
- jsonResponse: z16.object({
971
- dev_package_example: z16.object({
972
- dev_package_example_id: z16.coerce.number(),
973
- file_path: z16.string(),
974
- tscircuit_soup: z16.any(),
975
- last_updated_at: z16.string().datetime()
925
+ jsonResponse: z17.object({
926
+ dev_package_example: z17.object({
927
+ dev_package_example_id: z17.coerce.number(),
928
+ file_path: z17.string(),
929
+ tscircuit_soup: z17.any(),
930
+ last_updated_at: z17.string().datetime()
976
931
  })
977
932
  }),
978
933
  auth: "none"
@@ -1161,6 +1116,7 @@ var getDevServerAxios = ({ serverUrl }) => {
1161
1116
  const devServerAxios = defaultAxios.create({
1162
1117
  baseURL: serverUrl
1163
1118
  });
1119
+ devServerAxios.defaults.headers.common["Accept-Encoding"] = "gzip";
1164
1120
  devServerAxios.interceptors.response.use((res) => res, (err) => {
1165
1121
  console.log(kleur6.red(`[ERR] ${err.response?.status} ${err.config.method?.toUpperCase()} ${err.config.url}\n\n${JSON.stringify(err.response?.data, null, " ")}`.replace(/\\n/g, "\n").replace(/\\"/g, '"')));
1166
1122
  console.log(kleur6.yellow("[Request Body]:"), err.config.data);
@@ -1309,7 +1265,7 @@ var checkIfInitialized = async (ctx) => {
1309
1265
  };
1310
1266
 
1311
1267
  // lib/cmd-fns/init/index.ts
1312
- import {z as z17} from "zod";
1268
+ import {z as z18} from "zod";
1313
1269
  import {
1314
1270
  readFileSync as readFileSync5,
1315
1271
  writeFileSync as writeFileSync4,
@@ -1357,10 +1313,10 @@ var getGeneratedTsconfig = () => `
1357
1313
 
1358
1314
  // lib/cmd-fns/init/index.ts
1359
1315
  var initCmd = async (ctx, args2) => {
1360
- const params = z17.object({
1361
- name: z17.string().optional(),
1362
- dir: z17.string().optional(),
1363
- runtime: z17.enum(["bun", "node"]).optional()
1316
+ const params = z18.object({
1317
+ name: z18.string().optional(),
1318
+ dir: z18.string().optional(),
1319
+ runtime: z18.enum(["bun", "node"]).optional()
1364
1320
  }).parse(args2);
1365
1321
  if (params.name && !params.dir) {
1366
1322
  params.dir = `./${params.name.split("/").pop()}`;
@@ -1443,9 +1399,9 @@ export const MyExample = () => (
1443
1399
 
1444
1400
  // lib/cmd-fns/dev/index.ts
1445
1401
  var devCmd = async (ctx, args2) => {
1446
- const params = z18.object({
1447
- cwd: z18.string().optional().default(process.cwd()),
1448
- port: z18.coerce.number().optional().default(3020)
1402
+ const params = z19.object({
1403
+ cwd: z19.string().optional().default(process.cwd()),
1404
+ port: z19.coerce.number().optional().default(3020)
1449
1405
  }).parse(args2);
1450
1406
  const { cwd, port } = params;
1451
1407
  const isInitialized = await checkIfInitialized(ctx);
@@ -1502,12 +1458,12 @@ var devCmd = async (ctx, args2) => {
1502
1458
  };
1503
1459
  // lib/cmd-fns/add.ts
1504
1460
  import kleur12 from "kleur";
1505
- import {z as z19} from "zod";
1461
+ import {z as z20} from "zod";
1506
1462
  import $4 from "dax-sh";
1507
1463
  var addCmd = async (ctx, args2) => {
1508
- const params = z19.object({
1509
- packages: z19.array(z19.string()),
1510
- flags: z19.object({ dev: z19.boolean().optional().default(false) }).optional().default({})
1464
+ const params = z20.object({
1465
+ packages: z20.array(z20.string()),
1466
+ flags: z20.object({ dev: z20.boolean().optional().default(false) }).optional().default({})
1511
1467
  }).parse(args2);
1512
1468
  params.packages = params.packages.map((p) => p.replace(/^@/, ""));
1513
1469
  await createOrModifyNpmrc({ quiet: true }, ctx);
@@ -1519,12 +1475,12 @@ var addCmd = async (ctx, args2) => {
1519
1475
  };
1520
1476
  // lib/cmd-fns/remove.ts
1521
1477
  import kleur13 from "kleur";
1522
- import {z as z20} from "zod";
1478
+ import {z as z21} from "zod";
1523
1479
  import $5 from "dax-sh";
1524
1480
  var removeCmd = async (ctx, args2) => {
1525
- const params = z20.object({
1526
- packages: z20.array(z20.string()),
1527
- flags: z20.object({}).optional().default({})
1481
+ const params = z21.object({
1482
+ packages: z21.array(z21.string()),
1483
+ flags: z21.object({}).optional().default({})
1528
1484
  }).parse(args2);
1529
1485
  params.packages = params.packages.map((p) => p.replace(/^@/, ""));
1530
1486
  await createOrModifyNpmrc({ quiet: true }, ctx);
@@ -1536,12 +1492,12 @@ var removeCmd = async (ctx, args2) => {
1536
1492
  };
1537
1493
  // lib/cmd-fns/install.ts
1538
1494
  import kleur14 from "kleur";
1539
- import {z as z21} from "zod";
1495
+ import {z as z23} from "zod";
1540
1496
  import $6 from "dax-sh";
1541
1497
  var installCmd = async (ctx, args2) => {
1542
- const params = z21.object({
1543
- packages: z21.array(z21.string()),
1544
- flags: z21.object({ dev: z21.boolean().optional().default(false) }).optional().default({})
1498
+ const params = z23.object({
1499
+ packages: z23.array(z23.string()),
1500
+ flags: z23.object({ dev: z23.boolean().optional().default(false) }).optional().default({})
1545
1501
  }).parse(args2);
1546
1502
  params.packages = params.packages.map((p) => p.replace(/^@/, ""));
1547
1503
  await createOrModifyNpmrc({ quiet: true }, ctx);
@@ -1553,15 +1509,15 @@ var installCmd = async (ctx, args2) => {
1553
1509
  };
1554
1510
  // lib/cmd-fns/uninstall.ts
1555
1511
  import kleur15 from "kleur";
1556
- import {z as z23} from "zod";
1512
+ import {z as z25} from "zod";
1557
1513
  import $7 from "dax-sh";
1558
1514
  // lib/cmd-fns/dev-server-upload.ts
1559
- import {z as z25} from "zod";
1515
+ import {z as z26} from "zod";
1560
1516
  var devServerUpload = async (ctx, args2) => {
1561
- const params = z25.object({
1562
- dir: z25.string().optional().default(ctx.cwd),
1563
- port: z25.coerce.number().optional().default(3020),
1564
- watch: z25.boolean().optional().default(false)
1517
+ const params = z26.object({
1518
+ dir: z26.string().optional().default(ctx.cwd),
1519
+ port: z26.coerce.number().optional().default(3020),
1520
+ watch: z26.boolean().optional().default(false)
1565
1521
  }).parse(args2);
1566
1522
  const serverUrl = `http://localhost:${params.port}`;
1567
1523
  const devServerAxios = getDevServerAxios({ serverUrl });
@@ -1587,10 +1543,93 @@ var openCmd = async (ctx, args2) => {
1587
1543
  console.log(`Opening ${registryUrl} in your browser...`);
1588
1544
  await open2(registryUrl);
1589
1545
  };
1546
+ // package.json
1547
+ var package_default = {
1548
+ name: "@tscircuit/cli",
1549
+ version: "0.0.16",
1550
+ private: false,
1551
+ type: "module",
1552
+ description: "Command line tool for developing, publishing and installing tscircuit circuits",
1553
+ main: "./dist/cli.js",
1554
+ scripts: {
1555
+ bootstrap: "bun i --frozen-lockfile && cd dev-server-api && bun i --frozen-lockfile && cd ../dev-server-frontend && bun i --frozen-lockfile",
1556
+ start: "bun cli.ts",
1557
+ "start:dev-server:dev": "TSCI_DEV_SERVER_DB=$(pwd)/.tscircuit/dev-server.db concurrently 'cd dev-server-api && bun start' 'cd dev-server-frontend && bun start'",
1558
+ "start:dev-server": "bun build:dev-server && bun cli.ts dev -y --cwd ./tests/assets/example-project",
1559
+ "build:dev-server": "cd dev-server-api && bun run build && cd ../dev-server-frontend && bun run build",
1560
+ "build:cli": "bun build-cli.ts",
1561
+ build: "bun build:dev-server && npm run build:cli",
1562
+ "test:init": "bun cli.ts init --dir ./tmp/test --name test"
1563
+ },
1564
+ bin: {
1565
+ tscircuit: "./dist/cli.js",
1566
+ tsci: "./dist/cli.js"
1567
+ },
1568
+ keywords: [
1569
+ "circuit",
1570
+ "react",
1571
+ "electronics",
1572
+ "pcb",
1573
+ "schematic"
1574
+ ],
1575
+ author: "",
1576
+ license: "ISC",
1577
+ dependencies: {
1578
+ "@edge-runtime/primitives": "^4.1.0",
1579
+ "@hono/node-server": "^1.8.2",
1580
+ "@tscircuit/builder": "^1.5.4",
1581
+ "@tscircuit/react-fiber": "^1.0.6",
1582
+ axios: "^1.6.7",
1583
+ "better-sqlite3": "^9.4.3",
1584
+ chokidar: "^3.6.0",
1585
+ commander: "^12.0.0",
1586
+ configstore: "^6.0.0",
1587
+ dargs: "^8.1.0",
1588
+ "dax-sh": "^0.39.2",
1589
+ delay: "^6.0.0",
1590
+ edgespec: "^0.0.69",
1591
+ esbuild: "^0.20.2",
1592
+ glob: "^10.3.10",
1593
+ hono: "^4.1.0",
1594
+ ignore: "^5.3.1",
1595
+ kleur: "^4.1.5",
1596
+ "kysely-bun-sqlite": "^0.3.2",
1597
+ lodash: "^4.17.21",
1598
+ "mime-types": "^2.1.35",
1599
+ minimist: "^1.2.8",
1600
+ "node-persist": "^4.0.1",
1601
+ open: "^10.1.0",
1602
+ "perfect-cli": "^1.0.16",
1603
+ prompts: "^2.4.2",
1604
+ react: "^18.2.0",
1605
+ semver: "^7.6.0",
1606
+ zod: "latest"
1607
+ },
1608
+ devDependencies: {
1609
+ "@types/bun": "^1.0.8",
1610
+ "@types/chokidar": "^2.1.3",
1611
+ "@types/configstore": "^6.0.2",
1612
+ "@types/lodash": "^4.14.202",
1613
+ "@types/mime-types": "^2.1.4",
1614
+ "@types/minimist": "^1.2.5",
1615
+ "@types/node": "^20.10.6",
1616
+ "@types/prompts": "^2.4.9",
1617
+ "@types/react": "^18.2.64",
1618
+ "@types/semver": "^7.5.8",
1619
+ ava: "^6.1.1",
1620
+ concurrently: "^8.2.2",
1621
+ tsx: "^4.7.1",
1622
+ typescript: "^5.3.3"
1623
+ }
1624
+ };
1625
+
1626
+ // lib/cmd-fns/version.ts
1627
+ var versionCmd = async (ctx, args2) => {
1628
+ console.log(`tsci v${package_default.version}`);
1629
+ };
1590
1630
  // lib/get-program.ts
1591
1631
  var getProgram = (ctx) => {
1592
1632
  const cmd = new Command("tsci");
1593
- cmd.version(package_default.version);
1594
1633
  const authCmd = cmd.command("auth");
1595
1634
  authCmd.command("login").action((args2) => authLogin(ctx, args2));
1596
1635
  authCmd.command("logout").action((args2) => authLogout(ctx, args2));
@@ -1612,6 +1651,7 @@ var getProgram = (ctx) => {
1612
1651
  packageReleases.command("list").requiredOption("--package-name <package_name>", "Package name").option("--verbose", "Verbose objects (includes uuids)").action((args2) => packageReleasesList(ctx, args2));
1613
1652
  packageReleases.command("get").action((args2) => packageReleasesGet(ctx, args2));
1614
1653
  packageReleases.command("create").option("-p, --package-name-with-version <package_name_with_version>", "Package name and version").option("--package-name <package_name>", "Package name").option("--release-version <release_version>", "Version to publish").action((args2) => packageReleasesCreate(ctx, args2));
1654
+ packageReleases.command("update").option("-p, --package-name-with-version <package_name_with_version>", "Package name and version").option("--is-latest", "Make package release the latest version").option("--is-locked", "Lock the release").action((args2) => packageReleasesUpdate(ctx, args2));
1615
1655
  const packageFiles = cmd.command("package_files");
1616
1656
  packageFiles.command("list").option("--package-name-with-version <package_name_with_version>", "Package name with version").option("--package-name <package_name>", "Package name (use latest version)").option("--package-release-id <package_release_id>", "Package Release Id").action((args2) => packageFilesList(ctx, args2));
1617
1657
  packageFiles.command("get").action((args2) => packageFilesGet(ctx, args2));
@@ -1623,7 +1663,7 @@ var getProgram = (ctx) => {
1623
1663
  packageExamples.command("get").requiredOption("--package-example-id <package_example_id>").action((args2) => packageExamplesGet(ctx, args2));
1624
1664
  packageExamples.command("create").requiredOption("--package-name-with-version <package_name_with_version>").requiredOption("--file <file>").option("--export <export>", "Name of export to soupify").action((args2) => packageExamplesCreate(ctx, args2));
1625
1665
  cmd.command("publish").option("--increment", "Increase patch version").option("--patch", "Increase patch version").option("--lock", "Lock the release after publishing to prevent changes").action((args2) => publish(ctx, args2));
1626
- cmd.command("version").action(() => undefined(ctx, args));
1666
+ cmd.command("version").action(() => versionCmd(ctx, args));
1627
1667
  cmd.command("login").action((args2) => authLogin(ctx, args2));
1628
1668
  cmd.command("logout").action((args2) => authLogout(ctx, args2));
1629
1669
  cmd.command("soupify").requiredOption("--file <file>", "Input example files").option("--export <export_name>", "Name of export to soupify, if not specified, soupify the default/only export").action((args2) => soupifyCmd(ctx, args2));
@@ -1770,12 +1810,12 @@ var interactForPackageNameWithVersion = async ({
1770
1810
  ]
1771
1811
  });
1772
1812
  if (selectedPackage.endsWith("@...")) {
1773
- const { version: version2 } = await prompts3({
1813
+ const { version } = await prompts3({
1774
1814
  type: "text",
1775
1815
  name: "version",
1776
1816
  message: "Enter the version"
1777
1817
  });
1778
- return selectedPackage.replace("@...", `@${version2}`);
1818
+ return selectedPackage.replace("@...", `@${version}`);
1779
1819
  }
1780
1820
  if (selectedPackage === "Enter Manually") {
1781
1821
  const { packageName } = await prompts3({
@@ -1850,11 +1890,36 @@ var interactForPackageName = async ({
1850
1890
  return selectedPackage;
1851
1891
  };
1852
1892
 
1893
+ // lib/param-handlers/interact-for-registry-url.ts
1894
+ var interactForRegistryUrl = async (params) => {
1895
+ const { prompts: prompts3, ctx } = params;
1896
+ const { registry_url } = await prompts3({
1897
+ type: "select",
1898
+ name: "registry_url",
1899
+ message: "Select a package example",
1900
+ choices: [
1901
+ "https://registry.tscircuit.com",
1902
+ "http://localhost:3100",
1903
+ "other"
1904
+ ].map((a) => ({ title: a, value: a }))
1905
+ });
1906
+ if (registry_url === "other") {
1907
+ const { registry_url: registry_url2 } = await prompts3({
1908
+ type: "text",
1909
+ name: "registry_url",
1910
+ message: "Enter the registry url"
1911
+ });
1912
+ return registry_url2;
1913
+ }
1914
+ return registry_url;
1915
+ };
1916
+
1853
1917
  // lib/param-handlers/index.ts
1854
1918
  var PARAM_HANDLERS_BY_PARAM_NAME = {
1855
1919
  file: interactForLocalFile,
1856
1920
  cwd: interactForLocalDirectory,
1857
1921
  dir: interactForLocalDirectory,
1922
+ registry_url: interactForRegistryUrl,
1858
1923
  package_release_id: interactForPackageReleaseId,
1859
1924
  package_name: interactForPackageName,
1860
1925
  package_name_with_version: interactForPackageNameWithVersion,
@@ -1870,20 +1935,20 @@ var createConfigHandler = ({
1870
1935
  const current_profile = profile ?? global_config.get("current_profile") ?? "default";
1871
1936
  const profile_config = {
1872
1937
  get: (key) => global_config.get(`profiles.${current_profile}.${key}`),
1873
- set: (key, value) => global_config.set(`profiles.${current_profile}.${key}`, value)
1938
+ set: (key, value) => global_config.set(`profiles.${current_profile}.${key}`, value),
1939
+ clear: () => {
1940
+ for (const key of Object.keys(global_config.all)) {
1941
+ if (key.startsWith(`profiles.${current_profile}`)) {
1942
+ global_config.delete(key);
1943
+ }
1944
+ }
1945
+ }
1874
1946
  };
1875
1947
  return { profile_config, global_config, current_profile };
1876
1948
  };
1877
1949
 
1878
1950
  // lib/util/create-context-and-run-program.ts
1879
1951
  import dargs from "dargs";
1880
-
1881
- // lib/cmd-fns/version.ts
1882
- var versionCmd = async (ctx, args2) => {
1883
- console.log(`tsci v${package_default.version}`);
1884
- };
1885
-
1886
- // lib/util/create-context-and-run-program.ts
1887
1952
  var createContextAndRunProgram = async (process_args) => {
1888
1953
  const args2 = minimist(process_args);
1889
1954
  const { global_config, profile_config, current_profile } = createConfigHandler({
@@ -1903,6 +1968,7 @@ var createContextAndRunProgram = async (process_args) => {
1903
1968
  Authorization: `Bearer ${profile_config.get("session_token")}`
1904
1969
  }
1905
1970
  });
1971
+ axios.defaults.headers.common["Accept-Encoding"] = "gzip";
1906
1972
  if (global_config.get("log_requests")) {
1907
1973
  console.log(`Using registry_url: ${registry_url}`);
1908
1974
  axios.interceptors.request.use((req) => {
@@ -1946,7 +2012,10 @@ var createContextAndRunProgram = async (process_args) => {
1946
2012
  }
1947
2013
  await perfectCli(getProgram(ctx), args_without_globals, {
1948
2014
  async customParamHandler({ commandPath, optionName }, { prompts: prompts3 }) {
1949
- const optionNameHandler = PARAM_HANDLERS_BY_PARAM_NAME[_.snakeCase(optionName)];
2015
+ let optionNameHandler = PARAM_HANDLERS_BY_PARAM_NAME[_.snakeCase(optionName)];
2016
+ if (commandPath.join(" ") === "config set-registry" && optionName === "server") {
2017
+ optionNameHandler = PARAM_HANDLERS_BY_PARAM_NAME["registry_url"];
2018
+ }
1950
2019
  if (optionNameHandler) {
1951
2020
  return optionNameHandler({ prompts: prompts3, ctx });
1952
2021
  }
@@ -3,5 +3,7 @@ import { z } from "zod"
3
3
 
4
4
  export const configSetRegistry = async (ctx: AppContext, args: any) => {
5
5
  const params = z.object({ server: z.string().url() }).parse(args)
6
+ // don't want to re-use auth token
7
+ ctx.profile_config.clear()
6
8
  ctx.profile_config.set("registry_url", params.server)
7
9
  }
@@ -5,6 +5,10 @@ export const getDevServerAxios = ({ serverUrl }: { serverUrl: string }) => {
5
5
  const devServerAxios = defaultAxios.create({
6
6
  baseURL: serverUrl,
7
7
  })
8
+
9
+ // https://github.com/oven-sh/bun/issues/267
10
+ devServerAxios.defaults.headers.common["Accept-Encoding"] = "gzip"
11
+
8
12
  devServerAxios.interceptors.response.use(
9
13
  (res) => res,
10
14
  (err) => {
@@ -15,6 +15,7 @@ export { packageFilesUploadDirectory } from "./package-files-upload-directory"
15
15
  export { packageReleasesList } from "./package-releases-list"
16
16
  export { packageReleasesGet } from "./package-releases-get"
17
17
  export { packageReleasesCreate } from "./package-releases-create"
18
+ export { packageReleasesUpdate } from "./package-releases-update"
18
19
  export { packageFilesList } from "./package-files-list"
19
20
  export { packageFilesGet } from "./package-files-get"
20
21
  export { packageFilesDownload } from "./package-files-download"
@@ -33,3 +34,4 @@ export { uninstallCmd as uninstall } from "./uninstall"
33
34
  export { devServerUpload } from "./dev-server-upload"
34
35
  export { configClear } from "./config-clear"
35
36
  export { openCmd as open } from "./open"
37
+ export { versionCmd as version } from "./version"
@@ -0,0 +1,45 @@
1
+ import { AppContext } from "../util/app-context"
2
+ import { z } from "zod"
3
+ import kleur from "kleur"
4
+
5
+ export const packageReleasesUpdate = async (ctx: AppContext, args: any) => {
6
+ const params = z
7
+ .object({
8
+ packageNameWithVersion: z.string().optional(),
9
+ packageName: z.string().optional(),
10
+ version: z.string().optional(),
11
+ isLatest: z.boolean().optional(),
12
+ isLocked: z.boolean().optional(),
13
+ })
14
+ .refine((d) => {
15
+ if (d.packageNameWithVersion) return true
16
+ if (d.packageName && d.version) return true
17
+ return false
18
+ }, "Either packageNameWithVersion or packageName and version must be provided")
19
+ .parse(args)
20
+
21
+ let { packageNameWithVersion, packageName, version } = params
22
+
23
+ if (!packageNameWithVersion) {
24
+ packageNameWithVersion = `${packageName}@${version}`
25
+ }
26
+
27
+ const delta: {
28
+ is_latest?: boolean
29
+ is_locked?: boolean
30
+ } = {}
31
+
32
+ if (params.isLatest !== undefined) {
33
+ delta.is_latest = params.isLatest
34
+ }
35
+ if (params.isLocked !== undefined) {
36
+ delta.is_locked = params.isLocked
37
+ }
38
+
39
+ await ctx.axios.post("/package_releases/update", {
40
+ package_name_with_version: packageNameWithVersion,
41
+ ...delta,
42
+ })
43
+
44
+ console.log(`Package release updated!`)
45
+ }
@@ -83,6 +83,13 @@ export const createConfigHandler = ({
83
83
  (global_config as any).get(`profiles.${current_profile}.${key}`),
84
84
  set: (key: string, value: any) =>
85
85
  (global_config as any).set(`profiles.${current_profile}.${key}`, value),
86
+ clear: () => {
87
+ for (const key of Object.keys(global_config.all)) {
88
+ if (key.startsWith(`profiles.${current_profile}`)) {
89
+ global_config.delete(key as any)
90
+ }
91
+ }
92
+ },
86
93
  } as any
87
94
 
88
95
  return { profile_config, global_config, current_profile }
@@ -23,8 +23,6 @@ import * as CMDFN from "lib/cmd-fns"
23
23
  export const getProgram = (ctx: AppContext) => {
24
24
  const cmd = new Command("tsci")
25
25
 
26
- cmd.version(packageJson.version)
27
-
28
26
  const authCmd = cmd.command("auth")
29
27
  authCmd.command("login").action((args) => CMDFN.authLogin(ctx, args))
30
28
  authCmd.command("logout").action((args) => CMDFN.authLogout(ctx, args))
@@ -96,6 +94,15 @@ export const getProgram = (ctx: AppContext) => {
96
94
  .option("--package-name <package_name>", "Package name")
97
95
  .option("--release-version <release_version>", "Version to publish")
98
96
  .action((args) => CMDFN.packageReleasesCreate(ctx, args))
97
+ packageReleases
98
+ .command("update")
99
+ .option(
100
+ "-p, --package-name-with-version <package_name_with_version>",
101
+ "Package name and version"
102
+ )
103
+ .option("--is-latest", "Make package release the latest version")
104
+ .option("--is-locked", "Lock the release")
105
+ .action((args) => CMDFN.packageReleasesUpdate(ctx, args))
99
106
 
100
107
  const packageFiles = cmd.command("package_files")
101
108
 
@@ -4,12 +4,14 @@ import { interactForPackageExampleId } from "./interact-for-package-example-id"
4
4
  import { interactForPackageName } from "./interact-for-package-name"
5
5
  import { interactForPackageNameWithVersion } from "./interact-for-package-name-with-version"
6
6
  import { interactForPackageReleaseId } from "./interact-for-package-release-id"
7
+ import { interactForRegistryUrl } from "./interact-for-registry-url"
7
8
  import { ParamHandler } from "./param-handler-type"
8
9
 
9
10
  export const PARAM_HANDLERS_BY_PARAM_NAME: Record<string, ParamHandler> = {
10
11
  file: interactForLocalFile,
11
12
  cwd: interactForLocalDirectory,
12
13
  dir: interactForLocalDirectory,
14
+ registry_url: interactForRegistryUrl,
13
15
  package_release_id: interactForPackageReleaseId,
14
16
  package_name: interactForPackageName,
15
17
  package_name_with_version: interactForPackageNameWithVersion,
@@ -0,0 +1,28 @@
1
+ import { interactForPackageReleaseId } from "./interact-for-package-release-id"
2
+ import { ParamHandler } from "./param-handler-type"
3
+
4
+ export const interactForRegistryUrl: ParamHandler = async (params) => {
5
+ const { prompts, ctx } = params
6
+
7
+ const { registry_url } = await prompts({
8
+ type: "select",
9
+ name: "registry_url",
10
+ message: "Select a package example",
11
+ choices: [
12
+ "https://registry.tscircuit.com",
13
+ "http://localhost:3100",
14
+ "other",
15
+ ].map((a) => ({ title: a, value: a })),
16
+ })
17
+
18
+ if (registry_url === "other") {
19
+ const { registry_url } = await prompts({
20
+ type: "text",
21
+ name: "registry_url",
22
+ message: "Enter the registry url",
23
+ })
24
+ return registry_url
25
+ }
26
+
27
+ return registry_url
28
+ }
@@ -48,6 +48,9 @@ export const createContextAndRunProgram = async (process_args: any) => {
48
48
  },
49
49
  })
50
50
 
51
+ // https://github.com/oven-sh/bun/issues/267
52
+ axios.defaults.headers.common["Accept-Encoding"] = "gzip"
53
+
51
54
  if (global_config.get("log_requests")) {
52
55
  console.log(`Using registry_url: ${registry_url}`)
53
56
  axios.interceptors.request.use((req) => {
@@ -120,9 +123,16 @@ export const createContextAndRunProgram = async (process_args: any) => {
120
123
 
121
124
  await perfectCli(getProgram(ctx), args_without_globals, {
122
125
  async customParamHandler({ commandPath, optionName }, { prompts }) {
123
- const optionNameHandler =
126
+ let optionNameHandler =
124
127
  PARAM_HANDLERS_BY_PARAM_NAME[_.snakeCase(optionName)]
125
128
 
129
+ if (
130
+ commandPath.join(" ") === "config set-registry" &&
131
+ optionName === "server"
132
+ ) {
133
+ optionNameHandler = PARAM_HANDLERS_BY_PARAM_NAME["registry_url"]
134
+ }
135
+
126
136
  if (optionNameHandler) {
127
137
  return optionNameHandler({ prompts, ctx })
128
138
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tscircuit/cli",
3
- "version": "0.0.15",
3
+ "version": "0.0.17",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Command line tool for developing, publishing and installing tscircuit circuits",