@tscircuit/cli 0.0.14 → 0.0.16
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 +200 -158
- package/lib/cmd-fns/dev/get-dev-server-axios.ts +4 -0
- package/lib/cmd-fns/index.ts +2 -0
- package/lib/cmd-fns/init/get-generated-readme.ts +6 -0
- package/lib/cmd-fns/package-releases-update.ts +45 -0
- package/lib/get-program.ts +9 -2
- package/lib/util/create-context-and-run-program.ts +3 -0
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -206,79 +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.13",
|
|
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: ["circuit", "react", "electronics", "pcb", "schematic"],
|
|
232
|
-
author: "",
|
|
233
|
-
license: "ISC",
|
|
234
|
-
dependencies: {
|
|
235
|
-
"@edge-runtime/primitives": "^4.1.0",
|
|
236
|
-
"@hono/node-server": "^1.8.2",
|
|
237
|
-
"@tscircuit/builder": "^1.5.4",
|
|
238
|
-
"@tscircuit/react-fiber": "^1.0.6",
|
|
239
|
-
axios: "^1.6.7",
|
|
240
|
-
"better-sqlite3": "^9.4.3",
|
|
241
|
-
chokidar: "^3.6.0",
|
|
242
|
-
commander: "^12.0.0",
|
|
243
|
-
configstore: "^6.0.0",
|
|
244
|
-
dargs: "^8.1.0",
|
|
245
|
-
"dax-sh": "^0.39.2",
|
|
246
|
-
delay: "^6.0.0",
|
|
247
|
-
edgespec: "^0.0.69",
|
|
248
|
-
esbuild: "^0.20.2",
|
|
249
|
-
glob: "^10.3.10",
|
|
250
|
-
hono: "^4.1.0",
|
|
251
|
-
ignore: "^5.3.1",
|
|
252
|
-
kleur: "^4.1.5",
|
|
253
|
-
"kysely-bun-sqlite": "^0.3.2",
|
|
254
|
-
lodash: "^4.17.21",
|
|
255
|
-
"mime-types": "^2.1.35",
|
|
256
|
-
minimist: "^1.2.8",
|
|
257
|
-
"node-persist": "^4.0.1",
|
|
258
|
-
open: "^10.1.0",
|
|
259
|
-
"perfect-cli": "^1.0.16",
|
|
260
|
-
prompts: "^2.4.2",
|
|
261
|
-
react: "^18.2.0",
|
|
262
|
-
semver: "^7.6.0",
|
|
263
|
-
zod: "latest"
|
|
264
|
-
},
|
|
265
|
-
devDependencies: {
|
|
266
|
-
"@types/bun": "^1.0.8",
|
|
267
|
-
"@types/chokidar": "^2.1.3",
|
|
268
|
-
"@types/configstore": "^6.0.2",
|
|
269
|
-
"@types/lodash": "^4.14.202",
|
|
270
|
-
"@types/mime-types": "^2.1.4",
|
|
271
|
-
"@types/minimist": "^1.2.5",
|
|
272
|
-
"@types/node": "^20.10.6",
|
|
273
|
-
"@types/prompts": "^2.4.9",
|
|
274
|
-
"@types/react": "^18.2.64",
|
|
275
|
-
"@types/semver": "^7.5.8",
|
|
276
|
-
ava: "^6.1.1",
|
|
277
|
-
concurrently: "^8.2.2",
|
|
278
|
-
tsx: "^4.7.1",
|
|
279
|
-
typescript: "^5.3.3"
|
|
280
|
-
}
|
|
281
|
-
};
|
|
282
209
|
|
|
283
210
|
// lib/cmd-fns/config-reveal-location.ts
|
|
284
211
|
var configRevealLocation = async (ctx, args2) => {
|
|
@@ -448,14 +375,47 @@ var packageReleasesCreate = async (ctx, args2) => {
|
|
|
448
375
|
}).then((r) => r.data.package_release);
|
|
449
376
|
console.log(`Package release created! ${kleur2.gray(package_release.package_release_id)}`);
|
|
450
377
|
};
|
|
451
|
-
// lib/cmd-fns/package-
|
|
378
|
+
// lib/cmd-fns/package-releases-update.ts
|
|
452
379
|
import {z as z8} from "zod";
|
|
453
|
-
var
|
|
380
|
+
var packageReleasesUpdate = async (ctx, args2) => {
|
|
454
381
|
const params = z8.object({
|
|
455
|
-
packageReleaseId: z8.string().optional(),
|
|
456
|
-
packageName: z8.string().optional(),
|
|
457
382
|
packageNameWithVersion: z8.string().optional(),
|
|
458
|
-
|
|
383
|
+
packageName: z8.string().optional(),
|
|
384
|
+
version: z8.string().optional(),
|
|
385
|
+
isLatest: z8.boolean().optional(),
|
|
386
|
+
isLocked: z8.boolean().optional()
|
|
387
|
+
}).refine((d) => {
|
|
388
|
+
if (d.packageNameWithVersion)
|
|
389
|
+
return true;
|
|
390
|
+
if (d.packageName && d.version)
|
|
391
|
+
return true;
|
|
392
|
+
return false;
|
|
393
|
+
}, "Either packageNameWithVersion or packageName and version must be provided").parse(args2);
|
|
394
|
+
let { packageNameWithVersion, packageName, version } = params;
|
|
395
|
+
if (!packageNameWithVersion) {
|
|
396
|
+
packageNameWithVersion = `${packageName}@${version}`;
|
|
397
|
+
}
|
|
398
|
+
const delta = {};
|
|
399
|
+
if (params.isLatest !== undefined) {
|
|
400
|
+
delta.is_latest = params.isLatest;
|
|
401
|
+
}
|
|
402
|
+
if (params.isLocked !== undefined) {
|
|
403
|
+
delta.is_locked = params.isLocked;
|
|
404
|
+
}
|
|
405
|
+
await ctx.axios.post("/package_releases/update", {
|
|
406
|
+
package_name_with_version: packageNameWithVersion,
|
|
407
|
+
...delta
|
|
408
|
+
});
|
|
409
|
+
console.log(`Package release updated!`);
|
|
410
|
+
};
|
|
411
|
+
// lib/cmd-fns/package-files-list.ts
|
|
412
|
+
import {z as z9} from "zod";
|
|
413
|
+
var packageFilesList = async (ctx, args2) => {
|
|
414
|
+
const params = z9.object({
|
|
415
|
+
packageReleaseId: z9.string().optional(),
|
|
416
|
+
packageName: z9.string().optional(),
|
|
417
|
+
packageNameWithVersion: z9.string().optional(),
|
|
418
|
+
verbose: z9.boolean().optional()
|
|
459
419
|
}).parse(args2);
|
|
460
420
|
const package_files = await ctx.axios.post("/package_files/list", {
|
|
461
421
|
package_release_id: params.packageReleaseId,
|
|
@@ -473,13 +433,13 @@ var packageFilesList = async (ctx, args2) => {
|
|
|
473
433
|
var packageFilesGet = async (ctx, args2) => {
|
|
474
434
|
};
|
|
475
435
|
// lib/cmd-fns/package-files-download.ts
|
|
476
|
-
import {z as
|
|
436
|
+
import {z as z10} from "zod";
|
|
477
437
|
import * as fs from "fs/promises";
|
|
478
438
|
var packageFilesDownload = async (ctx, args2) => {
|
|
479
|
-
const params =
|
|
480
|
-
packageNameWithVersion:
|
|
481
|
-
remoteFilePath:
|
|
482
|
-
output:
|
|
439
|
+
const params = z10.object({
|
|
440
|
+
packageNameWithVersion: z10.string().optional(),
|
|
441
|
+
remoteFilePath: z10.string().optional(),
|
|
442
|
+
output: z10.string().optional()
|
|
483
443
|
}).parse(args2);
|
|
484
444
|
const { packageNameWithVersion, remoteFilePath } = params;
|
|
485
445
|
const packageContent = await ctx.axios.post("/package_files/download", {
|
|
@@ -494,14 +454,14 @@ var packageFilesDownload = async (ctx, args2) => {
|
|
|
494
454
|
}
|
|
495
455
|
};
|
|
496
456
|
// lib/cmd-fns/package-files-create.ts
|
|
497
|
-
import {z as
|
|
457
|
+
import {z as z11} from "zod";
|
|
498
458
|
import * as fs2 from "fs/promises";
|
|
499
459
|
import kleur3 from "kleur";
|
|
500
460
|
var packageFilesCreate = async (ctx, args2) => {
|
|
501
|
-
const params =
|
|
502
|
-
file:
|
|
503
|
-
packageReleaseId:
|
|
504
|
-
packageNameWithVersion:
|
|
461
|
+
const params = z11.object({
|
|
462
|
+
file: z11.string(),
|
|
463
|
+
packageReleaseId: z11.string().optional(),
|
|
464
|
+
packageNameWithVersion: z11.string().optional()
|
|
505
465
|
}).parse(args2);
|
|
506
466
|
const { file, packageNameWithVersion, packageReleaseId } = params;
|
|
507
467
|
const fileContent = await fs2.readFile(file);
|
|
@@ -514,10 +474,10 @@ var packageFilesCreate = async (ctx, args2) => {
|
|
|
514
474
|
console.log(`Package file created ${kleur3.gray(package_file.package_file_id)}`);
|
|
515
475
|
};
|
|
516
476
|
// lib/cmd-fns/package-examples-list.ts
|
|
517
|
-
import {z as
|
|
477
|
+
import {z as z12} from "zod";
|
|
518
478
|
var packageExamplesList = async (ctx, args2) => {
|
|
519
|
-
const params =
|
|
520
|
-
packageNameWithVersion:
|
|
479
|
+
const params = z12.object({
|
|
480
|
+
packageNameWithVersion: z12.string()
|
|
521
481
|
}).parse(args2);
|
|
522
482
|
const package_examples = await ctx.axios.post("/package_examples/list", {
|
|
523
483
|
package_name_with_version: params.packageNameWithVersion
|
|
@@ -525,10 +485,10 @@ var packageExamplesList = async (ctx, args2) => {
|
|
|
525
485
|
console.log(package_examples);
|
|
526
486
|
};
|
|
527
487
|
// lib/cmd-fns/package-examples-get.ts
|
|
528
|
-
import {z as
|
|
488
|
+
import {z as z13} from "zod";
|
|
529
489
|
var packageExamplesGet = async (ctx, args2) => {
|
|
530
|
-
const params =
|
|
531
|
-
packageExampleId:
|
|
490
|
+
const params = z13.object({
|
|
491
|
+
packageExampleId: z13.string().uuid()
|
|
532
492
|
}).parse(args2);
|
|
533
493
|
const { packageExampleId: package_example_id } = params;
|
|
534
494
|
const package_example = await ctx.axios.post("/package_examples/get", {
|
|
@@ -587,13 +547,13 @@ console.log(JSON.stringify(elements))
|
|
|
587
547
|
};
|
|
588
548
|
|
|
589
549
|
// lib/cmd-fns/package-examples-create.ts
|
|
590
|
-
import {z as
|
|
550
|
+
import {z as z14} from "zod";
|
|
591
551
|
import fs3 from "fs";
|
|
592
552
|
var packageExamplesCreate = async (ctx, args2) => {
|
|
593
|
-
const params =
|
|
594
|
-
packageNameWithVersion:
|
|
595
|
-
file:
|
|
596
|
-
export:
|
|
553
|
+
const params = z14.object({
|
|
554
|
+
packageNameWithVersion: z14.string(),
|
|
555
|
+
file: z14.string(),
|
|
556
|
+
export: z14.string().optional().default("default")
|
|
597
557
|
}).parse(args2);
|
|
598
558
|
const tscircuit_soup = await soupify({
|
|
599
559
|
filePath: params.file,
|
|
@@ -611,7 +571,7 @@ var packageExamplesCreate = async (ctx, args2) => {
|
|
|
611
571
|
};
|
|
612
572
|
// lib/cmd-fns/publish/index.ts
|
|
613
573
|
import kleur4 from "kleur";
|
|
614
|
-
import {z as
|
|
574
|
+
import {z as z15} from "zod";
|
|
615
575
|
import * as Path2 from "path";
|
|
616
576
|
import * as fs5 from "fs/promises";
|
|
617
577
|
import {readFileSync} from "fs";
|
|
@@ -641,6 +601,9 @@ var getGeneratedReadme = ({
|
|
|
641
601
|
}) => {
|
|
642
602
|
return `
|
|
643
603
|
# ${name}
|
|
604
|
+
|
|
605
|
+
[})](https://registry.tscircuit.com/${name.replace("@", "")})
|
|
606
|
+
|
|
644
607
|
${shouldHaveProjectGeneratedNotice ? `\n\n> This project was generated using [tsci](https://github.com/tscircuit/tscircuit)\n` : ""}
|
|
645
608
|
To develop and view the examples, run \`tsci dev\` and open [http://localhost:3020](http://localhost:3020) in your browser.
|
|
646
609
|
|
|
@@ -684,10 +647,10 @@ import semver from "semver";
|
|
|
684
647
|
import {unlink as unlink2} from "fs/promises";
|
|
685
648
|
import esbuild from "esbuild";
|
|
686
649
|
var publish = async (ctx, args2) => {
|
|
687
|
-
const params =
|
|
688
|
-
increment:
|
|
689
|
-
patch:
|
|
690
|
-
lock:
|
|
650
|
+
const params = z15.object({
|
|
651
|
+
increment: z15.boolean().optional(),
|
|
652
|
+
patch: z15.boolean().optional(),
|
|
653
|
+
lock: z15.boolean().optional()
|
|
691
654
|
}).parse(args2);
|
|
692
655
|
if (typeof Bun === "undefined") {
|
|
693
656
|
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---------------------"));
|
|
@@ -837,13 +800,13 @@ var publish = async (ctx, args2) => {
|
|
|
837
800
|
console.log(kleur4.green(`Published ${name}@${version}!\nhttps://registry.tscircuit.com/${name}`));
|
|
838
801
|
};
|
|
839
802
|
// lib/cmd-fns/soupify.ts
|
|
840
|
-
import {z as
|
|
803
|
+
import {z as z16} from "zod";
|
|
841
804
|
import {writeFileSync as writeFileSync2} from "fs";
|
|
842
805
|
var soupifyCmd = async (ctx, args2) => {
|
|
843
|
-
const params =
|
|
844
|
-
file:
|
|
845
|
-
export:
|
|
846
|
-
output:
|
|
806
|
+
const params = z16.object({
|
|
807
|
+
file: z16.string(),
|
|
808
|
+
export: z16.string().optional(),
|
|
809
|
+
output: z16.string().optional()
|
|
847
810
|
}).parse(args2);
|
|
848
811
|
const soup = await soupify({
|
|
849
812
|
filePath: params.file,
|
|
@@ -856,7 +819,7 @@ var soupifyCmd = async (ctx, args2) => {
|
|
|
856
819
|
}
|
|
857
820
|
};
|
|
858
821
|
// lib/cmd-fns/dev/index.ts
|
|
859
|
-
import {z as
|
|
822
|
+
import {z as z19} from "zod";
|
|
860
823
|
import kleur11 from "kleur";
|
|
861
824
|
import prompts2 from "prompts";
|
|
862
825
|
import open from "open";
|
|
@@ -870,7 +833,7 @@ import {mkdirSync} from "fs";
|
|
|
870
833
|
import * as Path3 from "path";
|
|
871
834
|
import kleur5 from "kleur";
|
|
872
835
|
import"edgespec/middleware";
|
|
873
|
-
import {z as
|
|
836
|
+
import {z as z17} from "zod";
|
|
874
837
|
import {NotFoundError as NotFoundError2} from "edgespec/middleware";
|
|
875
838
|
import {z as z22} from "zod";
|
|
876
839
|
import {z as z32} from "zod";
|
|
@@ -953,17 +916,17 @@ var withEdgeSpec = createWithEdgeSpec({
|
|
|
953
916
|
});
|
|
954
917
|
var create_default = withEdgeSpec({
|
|
955
918
|
methods: ["POST"],
|
|
956
|
-
jsonBody:
|
|
957
|
-
file_path:
|
|
958
|
-
export_name:
|
|
959
|
-
tscircuit_soup:
|
|
919
|
+
jsonBody: z17.object({
|
|
920
|
+
file_path: z17.string(),
|
|
921
|
+
export_name: z17.string().default("default"),
|
|
922
|
+
tscircuit_soup: z17.any()
|
|
960
923
|
}),
|
|
961
|
-
jsonResponse:
|
|
962
|
-
dev_package_example:
|
|
963
|
-
dev_package_example_id:
|
|
964
|
-
file_path:
|
|
965
|
-
tscircuit_soup:
|
|
966
|
-
last_updated_at:
|
|
924
|
+
jsonResponse: z17.object({
|
|
925
|
+
dev_package_example: z17.object({
|
|
926
|
+
dev_package_example_id: z17.coerce.number(),
|
|
927
|
+
file_path: z17.string(),
|
|
928
|
+
tscircuit_soup: z17.any(),
|
|
929
|
+
last_updated_at: z17.string().datetime()
|
|
967
930
|
})
|
|
968
931
|
}),
|
|
969
932
|
auth: "none"
|
|
@@ -1152,6 +1115,7 @@ var getDevServerAxios = ({ serverUrl }) => {
|
|
|
1152
1115
|
const devServerAxios = defaultAxios.create({
|
|
1153
1116
|
baseURL: serverUrl
|
|
1154
1117
|
});
|
|
1118
|
+
devServerAxios.defaults.headers.common["Accept-Encoding"] = "gzip";
|
|
1155
1119
|
devServerAxios.interceptors.response.use((res) => res, (err) => {
|
|
1156
1120
|
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, '"')));
|
|
1157
1121
|
console.log(kleur6.yellow("[Request Body]:"), err.config.data);
|
|
@@ -1300,7 +1264,7 @@ var checkIfInitialized = async (ctx) => {
|
|
|
1300
1264
|
};
|
|
1301
1265
|
|
|
1302
1266
|
// lib/cmd-fns/init/index.ts
|
|
1303
|
-
import {z as
|
|
1267
|
+
import {z as z18} from "zod";
|
|
1304
1268
|
import {
|
|
1305
1269
|
readFileSync as readFileSync5,
|
|
1306
1270
|
writeFileSync as writeFileSync4,
|
|
@@ -1348,10 +1312,10 @@ var getGeneratedTsconfig = () => `
|
|
|
1348
1312
|
|
|
1349
1313
|
// lib/cmd-fns/init/index.ts
|
|
1350
1314
|
var initCmd = async (ctx, args2) => {
|
|
1351
|
-
const params =
|
|
1352
|
-
name:
|
|
1353
|
-
dir:
|
|
1354
|
-
runtime:
|
|
1315
|
+
const params = z18.object({
|
|
1316
|
+
name: z18.string().optional(),
|
|
1317
|
+
dir: z18.string().optional(),
|
|
1318
|
+
runtime: z18.enum(["bun", "node"]).optional()
|
|
1355
1319
|
}).parse(args2);
|
|
1356
1320
|
if (params.name && !params.dir) {
|
|
1357
1321
|
params.dir = `./${params.name.split("/").pop()}`;
|
|
@@ -1434,9 +1398,9 @@ export const MyExample = () => (
|
|
|
1434
1398
|
|
|
1435
1399
|
// lib/cmd-fns/dev/index.ts
|
|
1436
1400
|
var devCmd = async (ctx, args2) => {
|
|
1437
|
-
const params =
|
|
1438
|
-
cwd:
|
|
1439
|
-
port:
|
|
1401
|
+
const params = z19.object({
|
|
1402
|
+
cwd: z19.string().optional().default(process.cwd()),
|
|
1403
|
+
port: z19.coerce.number().optional().default(3020)
|
|
1440
1404
|
}).parse(args2);
|
|
1441
1405
|
const { cwd, port } = params;
|
|
1442
1406
|
const isInitialized = await checkIfInitialized(ctx);
|
|
@@ -1493,12 +1457,12 @@ var devCmd = async (ctx, args2) => {
|
|
|
1493
1457
|
};
|
|
1494
1458
|
// lib/cmd-fns/add.ts
|
|
1495
1459
|
import kleur12 from "kleur";
|
|
1496
|
-
import {z as
|
|
1460
|
+
import {z as z20} from "zod";
|
|
1497
1461
|
import $4 from "dax-sh";
|
|
1498
1462
|
var addCmd = async (ctx, args2) => {
|
|
1499
|
-
const params =
|
|
1500
|
-
packages:
|
|
1501
|
-
flags:
|
|
1463
|
+
const params = z20.object({
|
|
1464
|
+
packages: z20.array(z20.string()),
|
|
1465
|
+
flags: z20.object({ dev: z20.boolean().optional().default(false) }).optional().default({})
|
|
1502
1466
|
}).parse(args2);
|
|
1503
1467
|
params.packages = params.packages.map((p) => p.replace(/^@/, ""));
|
|
1504
1468
|
await createOrModifyNpmrc({ quiet: true }, ctx);
|
|
@@ -1510,12 +1474,12 @@ var addCmd = async (ctx, args2) => {
|
|
|
1510
1474
|
};
|
|
1511
1475
|
// lib/cmd-fns/remove.ts
|
|
1512
1476
|
import kleur13 from "kleur";
|
|
1513
|
-
import {z as
|
|
1477
|
+
import {z as z21} from "zod";
|
|
1514
1478
|
import $5 from "dax-sh";
|
|
1515
1479
|
var removeCmd = async (ctx, args2) => {
|
|
1516
|
-
const params =
|
|
1517
|
-
packages:
|
|
1518
|
-
flags:
|
|
1480
|
+
const params = z21.object({
|
|
1481
|
+
packages: z21.array(z21.string()),
|
|
1482
|
+
flags: z21.object({}).optional().default({})
|
|
1519
1483
|
}).parse(args2);
|
|
1520
1484
|
params.packages = params.packages.map((p) => p.replace(/^@/, ""));
|
|
1521
1485
|
await createOrModifyNpmrc({ quiet: true }, ctx);
|
|
@@ -1527,12 +1491,12 @@ var removeCmd = async (ctx, args2) => {
|
|
|
1527
1491
|
};
|
|
1528
1492
|
// lib/cmd-fns/install.ts
|
|
1529
1493
|
import kleur14 from "kleur";
|
|
1530
|
-
import {z as
|
|
1494
|
+
import {z as z23} from "zod";
|
|
1531
1495
|
import $6 from "dax-sh";
|
|
1532
1496
|
var installCmd = async (ctx, args2) => {
|
|
1533
|
-
const params =
|
|
1534
|
-
packages:
|
|
1535
|
-
flags:
|
|
1497
|
+
const params = z23.object({
|
|
1498
|
+
packages: z23.array(z23.string()),
|
|
1499
|
+
flags: z23.object({ dev: z23.boolean().optional().default(false) }).optional().default({})
|
|
1536
1500
|
}).parse(args2);
|
|
1537
1501
|
params.packages = params.packages.map((p) => p.replace(/^@/, ""));
|
|
1538
1502
|
await createOrModifyNpmrc({ quiet: true }, ctx);
|
|
@@ -1544,15 +1508,15 @@ var installCmd = async (ctx, args2) => {
|
|
|
1544
1508
|
};
|
|
1545
1509
|
// lib/cmd-fns/uninstall.ts
|
|
1546
1510
|
import kleur15 from "kleur";
|
|
1547
|
-
import {z as
|
|
1511
|
+
import {z as z25} from "zod";
|
|
1548
1512
|
import $7 from "dax-sh";
|
|
1549
1513
|
// lib/cmd-fns/dev-server-upload.ts
|
|
1550
|
-
import {z as
|
|
1514
|
+
import {z as z26} from "zod";
|
|
1551
1515
|
var devServerUpload = async (ctx, args2) => {
|
|
1552
|
-
const params =
|
|
1553
|
-
dir:
|
|
1554
|
-
port:
|
|
1555
|
-
watch:
|
|
1516
|
+
const params = z26.object({
|
|
1517
|
+
dir: z26.string().optional().default(ctx.cwd),
|
|
1518
|
+
port: z26.coerce.number().optional().default(3020),
|
|
1519
|
+
watch: z26.boolean().optional().default(false)
|
|
1556
1520
|
}).parse(args2);
|
|
1557
1521
|
const serverUrl = `http://localhost:${params.port}`;
|
|
1558
1522
|
const devServerAxios = getDevServerAxios({ serverUrl });
|
|
@@ -1578,10 +1542,93 @@ var openCmd = async (ctx, args2) => {
|
|
|
1578
1542
|
console.log(`Opening ${registryUrl} in your browser...`);
|
|
1579
1543
|
await open2(registryUrl);
|
|
1580
1544
|
};
|
|
1545
|
+
// package.json
|
|
1546
|
+
var package_default = {
|
|
1547
|
+
name: "@tscircuit/cli",
|
|
1548
|
+
version: "0.0.15",
|
|
1549
|
+
private: false,
|
|
1550
|
+
type: "module",
|
|
1551
|
+
description: "Command line tool for developing, publishing and installing tscircuit circuits",
|
|
1552
|
+
main: "./dist/cli.js",
|
|
1553
|
+
scripts: {
|
|
1554
|
+
bootstrap: "bun i --frozen-lockfile && cd dev-server-api && bun i --frozen-lockfile && cd ../dev-server-frontend && bun i --frozen-lockfile",
|
|
1555
|
+
start: "bun cli.ts",
|
|
1556
|
+
"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'",
|
|
1557
|
+
"start:dev-server": "bun build:dev-server && bun cli.ts dev -y --cwd ./tests/assets/example-project",
|
|
1558
|
+
"build:dev-server": "cd dev-server-api && bun run build && cd ../dev-server-frontend && bun run build",
|
|
1559
|
+
"build:cli": "bun build-cli.ts",
|
|
1560
|
+
build: "bun build:dev-server && npm run build:cli",
|
|
1561
|
+
"test:init": "bun cli.ts init --dir ./tmp/test --name test"
|
|
1562
|
+
},
|
|
1563
|
+
bin: {
|
|
1564
|
+
tscircuit: "./dist/cli.js",
|
|
1565
|
+
tsci: "./dist/cli.js"
|
|
1566
|
+
},
|
|
1567
|
+
keywords: [
|
|
1568
|
+
"circuit",
|
|
1569
|
+
"react",
|
|
1570
|
+
"electronics",
|
|
1571
|
+
"pcb",
|
|
1572
|
+
"schematic"
|
|
1573
|
+
],
|
|
1574
|
+
author: "",
|
|
1575
|
+
license: "ISC",
|
|
1576
|
+
dependencies: {
|
|
1577
|
+
"@edge-runtime/primitives": "^4.1.0",
|
|
1578
|
+
"@hono/node-server": "^1.8.2",
|
|
1579
|
+
"@tscircuit/builder": "^1.5.4",
|
|
1580
|
+
"@tscircuit/react-fiber": "^1.0.6",
|
|
1581
|
+
axios: "^1.6.7",
|
|
1582
|
+
"better-sqlite3": "^9.4.3",
|
|
1583
|
+
chokidar: "^3.6.0",
|
|
1584
|
+
commander: "^12.0.0",
|
|
1585
|
+
configstore: "^6.0.0",
|
|
1586
|
+
dargs: "^8.1.0",
|
|
1587
|
+
"dax-sh": "^0.39.2",
|
|
1588
|
+
delay: "^6.0.0",
|
|
1589
|
+
edgespec: "^0.0.69",
|
|
1590
|
+
esbuild: "^0.20.2",
|
|
1591
|
+
glob: "^10.3.10",
|
|
1592
|
+
hono: "^4.1.0",
|
|
1593
|
+
ignore: "^5.3.1",
|
|
1594
|
+
kleur: "^4.1.5",
|
|
1595
|
+
"kysely-bun-sqlite": "^0.3.2",
|
|
1596
|
+
lodash: "^4.17.21",
|
|
1597
|
+
"mime-types": "^2.1.35",
|
|
1598
|
+
minimist: "^1.2.8",
|
|
1599
|
+
"node-persist": "^4.0.1",
|
|
1600
|
+
open: "^10.1.0",
|
|
1601
|
+
"perfect-cli": "^1.0.16",
|
|
1602
|
+
prompts: "^2.4.2",
|
|
1603
|
+
react: "^18.2.0",
|
|
1604
|
+
semver: "^7.6.0",
|
|
1605
|
+
zod: "latest"
|
|
1606
|
+
},
|
|
1607
|
+
devDependencies: {
|
|
1608
|
+
"@types/bun": "^1.0.8",
|
|
1609
|
+
"@types/chokidar": "^2.1.3",
|
|
1610
|
+
"@types/configstore": "^6.0.2",
|
|
1611
|
+
"@types/lodash": "^4.14.202",
|
|
1612
|
+
"@types/mime-types": "^2.1.4",
|
|
1613
|
+
"@types/minimist": "^1.2.5",
|
|
1614
|
+
"@types/node": "^20.10.6",
|
|
1615
|
+
"@types/prompts": "^2.4.9",
|
|
1616
|
+
"@types/react": "^18.2.64",
|
|
1617
|
+
"@types/semver": "^7.5.8",
|
|
1618
|
+
ava: "^6.1.1",
|
|
1619
|
+
concurrently: "^8.2.2",
|
|
1620
|
+
tsx: "^4.7.1",
|
|
1621
|
+
typescript: "^5.3.3"
|
|
1622
|
+
}
|
|
1623
|
+
};
|
|
1624
|
+
|
|
1625
|
+
// lib/cmd-fns/version.ts
|
|
1626
|
+
var versionCmd = async (ctx, args2) => {
|
|
1627
|
+
console.log(`tsci v${package_default.version}`);
|
|
1628
|
+
};
|
|
1581
1629
|
// lib/get-program.ts
|
|
1582
1630
|
var getProgram = (ctx) => {
|
|
1583
1631
|
const cmd = new Command("tsci");
|
|
1584
|
-
cmd.version(package_default.version);
|
|
1585
1632
|
const authCmd = cmd.command("auth");
|
|
1586
1633
|
authCmd.command("login").action((args2) => authLogin(ctx, args2));
|
|
1587
1634
|
authCmd.command("logout").action((args2) => authLogout(ctx, args2));
|
|
@@ -1603,6 +1650,7 @@ var getProgram = (ctx) => {
|
|
|
1603
1650
|
packageReleases.command("list").requiredOption("--package-name <package_name>", "Package name").option("--verbose", "Verbose objects (includes uuids)").action((args2) => packageReleasesList(ctx, args2));
|
|
1604
1651
|
packageReleases.command("get").action((args2) => packageReleasesGet(ctx, args2));
|
|
1605
1652
|
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));
|
|
1653
|
+
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));
|
|
1606
1654
|
const packageFiles = cmd.command("package_files");
|
|
1607
1655
|
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));
|
|
1608
1656
|
packageFiles.command("get").action((args2) => packageFilesGet(ctx, args2));
|
|
@@ -1614,7 +1662,7 @@ var getProgram = (ctx) => {
|
|
|
1614
1662
|
packageExamples.command("get").requiredOption("--package-example-id <package_example_id>").action((args2) => packageExamplesGet(ctx, args2));
|
|
1615
1663
|
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));
|
|
1616
1664
|
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));
|
|
1617
|
-
cmd.command("version").action(() =>
|
|
1665
|
+
cmd.command("version").action(() => versionCmd(ctx, args));
|
|
1618
1666
|
cmd.command("login").action((args2) => authLogin(ctx, args2));
|
|
1619
1667
|
cmd.command("logout").action((args2) => authLogout(ctx, args2));
|
|
1620
1668
|
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));
|
|
@@ -1761,12 +1809,12 @@ var interactForPackageNameWithVersion = async ({
|
|
|
1761
1809
|
]
|
|
1762
1810
|
});
|
|
1763
1811
|
if (selectedPackage.endsWith("@...")) {
|
|
1764
|
-
const { version
|
|
1812
|
+
const { version } = await prompts3({
|
|
1765
1813
|
type: "text",
|
|
1766
1814
|
name: "version",
|
|
1767
1815
|
message: "Enter the version"
|
|
1768
1816
|
});
|
|
1769
|
-
return selectedPackage.replace("@...", `@${
|
|
1817
|
+
return selectedPackage.replace("@...", `@${version}`);
|
|
1770
1818
|
}
|
|
1771
1819
|
if (selectedPackage === "Enter Manually") {
|
|
1772
1820
|
const { packageName } = await prompts3({
|
|
@@ -1868,13 +1916,6 @@ var createConfigHandler = ({
|
|
|
1868
1916
|
|
|
1869
1917
|
// lib/util/create-context-and-run-program.ts
|
|
1870
1918
|
import dargs from "dargs";
|
|
1871
|
-
|
|
1872
|
-
// lib/cmd-fns/version.ts
|
|
1873
|
-
var versionCmd = async (ctx, args2) => {
|
|
1874
|
-
console.log(`tsci v${package_default.version}`);
|
|
1875
|
-
};
|
|
1876
|
-
|
|
1877
|
-
// lib/util/create-context-and-run-program.ts
|
|
1878
1919
|
var createContextAndRunProgram = async (process_args) => {
|
|
1879
1920
|
const args2 = minimist(process_args);
|
|
1880
1921
|
const { global_config, profile_config, current_profile } = createConfigHandler({
|
|
@@ -1894,6 +1935,7 @@ var createContextAndRunProgram = async (process_args) => {
|
|
|
1894
1935
|
Authorization: `Bearer ${profile_config.get("session_token")}`
|
|
1895
1936
|
}
|
|
1896
1937
|
});
|
|
1938
|
+
axios.defaults.headers.common["Accept-Encoding"] = "gzip";
|
|
1897
1939
|
if (global_config.get("log_requests")) {
|
|
1898
1940
|
console.log(`Using registry_url: ${registry_url}`);
|
|
1899
1941
|
axios.interceptors.request.use((req) => {
|
|
@@ -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) => {
|
package/lib/cmd-fns/index.ts
CHANGED
|
@@ -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"
|
|
@@ -7,6 +7,12 @@ export const getGeneratedReadme = ({
|
|
|
7
7
|
}) => {
|
|
8
8
|
return `
|
|
9
9
|
# ${name}
|
|
10
|
+
|
|
11
|
+
[})](https://registry.tscircuit.com/${name.replace("@", "")})
|
|
15
|
+
|
|
10
16
|
${
|
|
11
17
|
shouldHaveProjectGeneratedNotice
|
|
12
18
|
? `\n\n> This project was generated using [tsci](https://github.com/tscircuit/tscircuit)\n`
|
|
@@ -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
|
+
}
|
package/lib/get-program.ts
CHANGED
|
@@ -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
|
|
|
@@ -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) => {
|