@tscircuit/cli 0.0.9 → 0.0.14
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/.github/workflows/release.yml +35 -0
- package/dist/cli.js +118 -107
- package/lib/cmd-fns/version.ts +6 -0
- package/lib/get-program.ts +1 -3
- package/lib/util/create-context-and-run-program.ts +6 -0
- package/package.json +9 -3
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
name: Release Workflow
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- main
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
build_and_release:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
|
|
12
|
+
steps:
|
|
13
|
+
- name: Checkout code
|
|
14
|
+
uses: actions/checkout@v2
|
|
15
|
+
|
|
16
|
+
- uses: actions/setup-node@v4
|
|
17
|
+
with:
|
|
18
|
+
node-version: 20
|
|
19
|
+
registry-url: https://registry.npmjs.org/
|
|
20
|
+
|
|
21
|
+
- name: Setup bun
|
|
22
|
+
uses: oven-sh/setup-bun@v1
|
|
23
|
+
with:
|
|
24
|
+
bun-version: latest
|
|
25
|
+
|
|
26
|
+
- name: Install project dependencies
|
|
27
|
+
run: bun run bootstrap
|
|
28
|
+
|
|
29
|
+
- name: Build project
|
|
30
|
+
run: bun run build
|
|
31
|
+
|
|
32
|
+
- name: Run pver release
|
|
33
|
+
run: npx pver release
|
|
34
|
+
env:
|
|
35
|
+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
package/dist/cli.js
CHANGED
|
@@ -209,13 +209,13 @@ import {Command} from "commander";
|
|
|
209
209
|
// package.json
|
|
210
210
|
var package_default = {
|
|
211
211
|
name: "@tscircuit/cli",
|
|
212
|
-
version: "0.0.
|
|
212
|
+
version: "0.0.13",
|
|
213
213
|
private: false,
|
|
214
214
|
type: "module",
|
|
215
215
|
description: "Command line tool for developing, publishing and installing tscircuit circuits",
|
|
216
216
|
main: "./dist/cli.js",
|
|
217
217
|
scripts: {
|
|
218
|
-
bootstrap: "bun i && cd dev-server-api && bun i && cd ../dev-server-frontend && bun i",
|
|
218
|
+
bootstrap: "bun i --frozen-lockfile && cd dev-server-api && bun i --frozen-lockfile && cd ../dev-server-frontend && bun i --frozen-lockfile",
|
|
219
219
|
start: "bun cli.ts",
|
|
220
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
221
|
"start:dev-server": "bun build:dev-server && bun cli.ts dev -y --cwd ./tests/assets/example-project",
|
|
@@ -228,7 +228,7 @@ var package_default = {
|
|
|
228
228
|
tscircuit: "./dist/cli.js",
|
|
229
229
|
tsci: "./dist/cli.js"
|
|
230
230
|
},
|
|
231
|
-
keywords: [],
|
|
231
|
+
keywords: ["circuit", "react", "electronics", "pcb", "schematic"],
|
|
232
232
|
author: "",
|
|
233
233
|
license: "ISC",
|
|
234
234
|
dependencies: {
|
|
@@ -281,35 +281,35 @@ var package_default = {
|
|
|
281
281
|
};
|
|
282
282
|
|
|
283
283
|
// lib/cmd-fns/config-reveal-location.ts
|
|
284
|
-
var configRevealLocation = async (ctx,
|
|
284
|
+
var configRevealLocation = async (ctx, args2) => {
|
|
285
285
|
console.log(`tsci config path: ${ctx.global_config.path}`);
|
|
286
286
|
};
|
|
287
287
|
// lib/cmd-fns/config-set-registry.ts
|
|
288
288
|
import {z} from "zod";
|
|
289
|
-
var configSetRegistry = async (ctx,
|
|
290
|
-
const params = z.object({ server: z.string().url() }).parse(
|
|
289
|
+
var configSetRegistry = async (ctx, args2) => {
|
|
290
|
+
const params = z.object({ server: z.string().url() }).parse(args2);
|
|
291
291
|
ctx.profile_config.set("registry_url", params.server);
|
|
292
292
|
};
|
|
293
293
|
// lib/cmd-fns/config-set-session.ts
|
|
294
294
|
import {z as z2} from "zod";
|
|
295
|
-
var configSetSession = async (ctx,
|
|
296
|
-
const params = z2.object({ sessionToken: z2.string() }).parse(
|
|
295
|
+
var configSetSession = async (ctx, args2) => {
|
|
296
|
+
const params = z2.object({ sessionToken: z2.string() }).parse(args2);
|
|
297
297
|
ctx.profile_config.set("session_token", params.sessionToken);
|
|
298
298
|
};
|
|
299
299
|
// lib/cmd-fns/config-set-log-requests.ts
|
|
300
300
|
import {z as z3} from "zod";
|
|
301
|
-
var configSetLogRequests = async (ctx,
|
|
302
|
-
const params = z3.object({ logRequests: z3.boolean() }).parse(
|
|
301
|
+
var configSetLogRequests = async (ctx, args2) => {
|
|
302
|
+
const params = z3.object({ logRequests: z3.boolean() }).parse(args2);
|
|
303
303
|
ctx.global_config.set("log_requests", params.logRequests);
|
|
304
304
|
};
|
|
305
305
|
// lib/cmd-fns/config-print-config.ts
|
|
306
306
|
import {readFile} from "fs/promises";
|
|
307
|
-
var configPrintConfig = async (ctx,
|
|
307
|
+
var configPrintConfig = async (ctx, args2) => {
|
|
308
308
|
console.log((await readFile(ctx.global_config.path)).toString());
|
|
309
309
|
};
|
|
310
310
|
// lib/cmd-fns/auth-login.ts
|
|
311
311
|
import delay from "delay";
|
|
312
|
-
var authLogin = async (ctx,
|
|
312
|
+
var authLogin = async (ctx, args2) => {
|
|
313
313
|
const {
|
|
314
314
|
data: { login_page }
|
|
315
315
|
} = await ctx.axios.post("/sessions/login_page/create", {});
|
|
@@ -348,22 +348,22 @@ var authLogin = async (ctx, args) => {
|
|
|
348
348
|
};
|
|
349
349
|
// lib/cmd-fns/auth-logout.ts
|
|
350
350
|
import kleur from "kleur";
|
|
351
|
-
var authLogout = async (ctx,
|
|
351
|
+
var authLogout = async (ctx, args2) => {
|
|
352
352
|
ctx.profile_config.delete("session_token");
|
|
353
353
|
console.log(kleur.green("Logged out!"));
|
|
354
354
|
};
|
|
355
355
|
// lib/cmd-fns/auth-sessions-create.ts
|
|
356
|
-
var authSessionsCreate = async (ctx,
|
|
356
|
+
var authSessionsCreate = async (ctx, args2) => {
|
|
357
357
|
};
|
|
358
358
|
// lib/cmd-fns/auth-sessions-list.ts
|
|
359
|
-
var authSessionsList = async (ctx,
|
|
359
|
+
var authSessionsList = async (ctx, args2) => {
|
|
360
360
|
await ctx.axios.get("/sessions/list");
|
|
361
361
|
};
|
|
362
362
|
// lib/cmd-fns/auth-sessions-get.ts
|
|
363
|
-
var authSessionsGet = async (ctx,
|
|
363
|
+
var authSessionsGet = async (ctx, args2) => {
|
|
364
364
|
};
|
|
365
365
|
// lib/cmd-fns/packages-list.ts
|
|
366
|
-
var packagesList = async (ctx,
|
|
366
|
+
var packagesList = async (ctx, args2) => {
|
|
367
367
|
const {
|
|
368
368
|
data: { packages }
|
|
369
369
|
} = await ctx.axios.post("/packages/list", {});
|
|
@@ -378,9 +378,9 @@ var packagesList = async (ctx, args) => {
|
|
|
378
378
|
};
|
|
379
379
|
// lib/cmd-fns/packages-get.ts
|
|
380
380
|
import {z as z4} from "zod";
|
|
381
|
-
var packagesGet = async (ctx,
|
|
382
|
-
|
|
383
|
-
const params = z4.object({ package_id: z4.string() }).or(z4.object({ name: z4.string() })).parse(
|
|
381
|
+
var packagesGet = async (ctx, args2) => {
|
|
382
|
+
args2.packageId = args2.package_id;
|
|
383
|
+
const params = z4.object({ package_id: z4.string() }).or(z4.object({ name: z4.string() })).parse(args2);
|
|
384
384
|
const {
|
|
385
385
|
data: { package: pkg }
|
|
386
386
|
} = await ctx.axios.post("/packages/get", params);
|
|
@@ -388,25 +388,25 @@ var packagesGet = async (ctx, args) => {
|
|
|
388
388
|
};
|
|
389
389
|
// lib/cmd-fns/packages-create.ts
|
|
390
390
|
import {z as z5} from "zod";
|
|
391
|
-
var packagesCreate = async (ctx,
|
|
391
|
+
var packagesCreate = async (ctx, args2) => {
|
|
392
392
|
const params = z5.object({
|
|
393
393
|
name: z5.string(),
|
|
394
394
|
description: z5.string().optional(),
|
|
395
395
|
authorAccountId: z5.string().optional()
|
|
396
|
-
}).parse(
|
|
396
|
+
}).parse(args2);
|
|
397
397
|
await ctx.axios.post("/packages/create", params);
|
|
398
398
|
console.log(`Package "${params.name}" created!`);
|
|
399
399
|
};
|
|
400
400
|
// lib/cmd-fns/package-files-upload-directory.ts
|
|
401
|
-
var packageFilesUploadDirectory = async (ctx,
|
|
401
|
+
var packageFilesUploadDirectory = async (ctx, args2) => {
|
|
402
402
|
};
|
|
403
403
|
// lib/cmd-fns/package-releases-list.ts
|
|
404
404
|
import {z as z6} from "zod";
|
|
405
|
-
var packageReleasesList = async (ctx,
|
|
405
|
+
var packageReleasesList = async (ctx, args2) => {
|
|
406
406
|
const params = z6.object({
|
|
407
407
|
packageName: z6.string().optional(),
|
|
408
408
|
verbose: z6.boolean().optional()
|
|
409
|
-
}).parse(
|
|
409
|
+
}).parse(args2);
|
|
410
410
|
const package_releases = await ctx.axios.post("/package_releases/list", {
|
|
411
411
|
package_name: params.packageName
|
|
412
412
|
}).then((r) => r.data.package_releases);
|
|
@@ -421,13 +421,13 @@ var packageReleasesList = async (ctx, args) => {
|
|
|
421
421
|
}
|
|
422
422
|
};
|
|
423
423
|
// lib/cmd-fns/package-releases-get.ts
|
|
424
|
-
var packageReleasesGet = async (ctx,
|
|
424
|
+
var packageReleasesGet = async (ctx, args2) => {
|
|
425
425
|
};
|
|
426
426
|
// lib/cmd-fns/package-releases-create.ts
|
|
427
427
|
import {z as z7} from "zod";
|
|
428
428
|
import kleur2 from "kleur";
|
|
429
|
-
var packageReleasesCreate = async (ctx,
|
|
430
|
-
|
|
429
|
+
var packageReleasesCreate = async (ctx, args2) => {
|
|
430
|
+
args2.version = args2.releaseVersion;
|
|
431
431
|
const params = z7.object({
|
|
432
432
|
packageNameWithVersion: z7.string().optional(),
|
|
433
433
|
packageName: z7.string().optional(),
|
|
@@ -438,7 +438,7 @@ var packageReleasesCreate = async (ctx, args) => {
|
|
|
438
438
|
if (d.packageName && d.version)
|
|
439
439
|
return true;
|
|
440
440
|
return false;
|
|
441
|
-
}, "Either packageNameWithVersion or packageName and version must be provided").parse(
|
|
441
|
+
}, "Either packageNameWithVersion or packageName and version must be provided").parse(args2);
|
|
442
442
|
let { packageNameWithVersion, packageName, version } = params;
|
|
443
443
|
if (!packageNameWithVersion) {
|
|
444
444
|
packageNameWithVersion = `${packageName}@${version}`;
|
|
@@ -450,13 +450,13 @@ var packageReleasesCreate = async (ctx, args) => {
|
|
|
450
450
|
};
|
|
451
451
|
// lib/cmd-fns/package-files-list.ts
|
|
452
452
|
import {z as z8} from "zod";
|
|
453
|
-
var packageFilesList = async (ctx,
|
|
453
|
+
var packageFilesList = async (ctx, args2) => {
|
|
454
454
|
const params = z8.object({
|
|
455
455
|
packageReleaseId: z8.string().optional(),
|
|
456
456
|
packageName: z8.string().optional(),
|
|
457
457
|
packageNameWithVersion: z8.string().optional(),
|
|
458
458
|
verbose: z8.boolean().optional()
|
|
459
|
-
}).parse(
|
|
459
|
+
}).parse(args2);
|
|
460
460
|
const package_files = await ctx.axios.post("/package_files/list", {
|
|
461
461
|
package_release_id: params.packageReleaseId,
|
|
462
462
|
package_name: params.packageName,
|
|
@@ -470,17 +470,17 @@ var packageFilesList = async (ctx, args) => {
|
|
|
470
470
|
}
|
|
471
471
|
};
|
|
472
472
|
// lib/cmd-fns/package-files-get.ts
|
|
473
|
-
var packageFilesGet = async (ctx,
|
|
473
|
+
var packageFilesGet = async (ctx, args2) => {
|
|
474
474
|
};
|
|
475
475
|
// lib/cmd-fns/package-files-download.ts
|
|
476
476
|
import {z as z9} from "zod";
|
|
477
477
|
import * as fs from "fs/promises";
|
|
478
|
-
var packageFilesDownload = async (ctx,
|
|
478
|
+
var packageFilesDownload = async (ctx, args2) => {
|
|
479
479
|
const params = z9.object({
|
|
480
480
|
packageNameWithVersion: z9.string().optional(),
|
|
481
481
|
remoteFilePath: z9.string().optional(),
|
|
482
482
|
output: z9.string().optional()
|
|
483
|
-
}).parse(
|
|
483
|
+
}).parse(args2);
|
|
484
484
|
const { packageNameWithVersion, remoteFilePath } = params;
|
|
485
485
|
const packageContent = await ctx.axios.post("/package_files/download", {
|
|
486
486
|
package_name_with_version: packageNameWithVersion,
|
|
@@ -497,12 +497,12 @@ var packageFilesDownload = async (ctx, args) => {
|
|
|
497
497
|
import {z as z10} from "zod";
|
|
498
498
|
import * as fs2 from "fs/promises";
|
|
499
499
|
import kleur3 from "kleur";
|
|
500
|
-
var packageFilesCreate = async (ctx,
|
|
500
|
+
var packageFilesCreate = async (ctx, args2) => {
|
|
501
501
|
const params = z10.object({
|
|
502
502
|
file: z10.string(),
|
|
503
503
|
packageReleaseId: z10.string().optional(),
|
|
504
504
|
packageNameWithVersion: z10.string().optional()
|
|
505
|
-
}).parse(
|
|
505
|
+
}).parse(args2);
|
|
506
506
|
const { file, packageNameWithVersion, packageReleaseId } = params;
|
|
507
507
|
const fileContent = await fs2.readFile(file);
|
|
508
508
|
const package_file = await ctx.axios.post("/package_files/create", {
|
|
@@ -515,10 +515,10 @@ var packageFilesCreate = async (ctx, args) => {
|
|
|
515
515
|
};
|
|
516
516
|
// lib/cmd-fns/package-examples-list.ts
|
|
517
517
|
import {z as z11} from "zod";
|
|
518
|
-
var packageExamplesList = async (ctx,
|
|
518
|
+
var packageExamplesList = async (ctx, args2) => {
|
|
519
519
|
const params = z11.object({
|
|
520
520
|
packageNameWithVersion: z11.string()
|
|
521
|
-
}).parse(
|
|
521
|
+
}).parse(args2);
|
|
522
522
|
const package_examples = await ctx.axios.post("/package_examples/list", {
|
|
523
523
|
package_name_with_version: params.packageNameWithVersion
|
|
524
524
|
}).then((r) => r.data.package_examples);
|
|
@@ -526,10 +526,10 @@ var packageExamplesList = async (ctx, args) => {
|
|
|
526
526
|
};
|
|
527
527
|
// lib/cmd-fns/package-examples-get.ts
|
|
528
528
|
import {z as z12} from "zod";
|
|
529
|
-
var packageExamplesGet = async (ctx,
|
|
529
|
+
var packageExamplesGet = async (ctx, args2) => {
|
|
530
530
|
const params = z12.object({
|
|
531
531
|
packageExampleId: z12.string().uuid()
|
|
532
|
-
}).parse(
|
|
532
|
+
}).parse(args2);
|
|
533
533
|
const { packageExampleId: package_example_id } = params;
|
|
534
534
|
const package_example = await ctx.axios.post("/package_examples/get", {
|
|
535
535
|
package_example_id
|
|
@@ -589,12 +589,12 @@ console.log(JSON.stringify(elements))
|
|
|
589
589
|
// lib/cmd-fns/package-examples-create.ts
|
|
590
590
|
import {z as z13} from "zod";
|
|
591
591
|
import fs3 from "fs";
|
|
592
|
-
var packageExamplesCreate = async (ctx,
|
|
592
|
+
var packageExamplesCreate = async (ctx, args2) => {
|
|
593
593
|
const params = z13.object({
|
|
594
594
|
packageNameWithVersion: z13.string(),
|
|
595
595
|
file: z13.string(),
|
|
596
596
|
export: z13.string().optional().default("default")
|
|
597
|
-
}).parse(
|
|
597
|
+
}).parse(args2);
|
|
598
598
|
const tscircuit_soup = await soupify({
|
|
599
599
|
filePath: params.file,
|
|
600
600
|
exportName: params.export
|
|
@@ -683,12 +683,12 @@ import $2 from "dax-sh";
|
|
|
683
683
|
import semver from "semver";
|
|
684
684
|
import {unlink as unlink2} from "fs/promises";
|
|
685
685
|
import esbuild from "esbuild";
|
|
686
|
-
var publish = async (ctx,
|
|
686
|
+
var publish = async (ctx, args2) => {
|
|
687
687
|
const params = z14.object({
|
|
688
688
|
increment: z14.boolean().optional(),
|
|
689
689
|
patch: z14.boolean().optional(),
|
|
690
690
|
lock: z14.boolean().optional()
|
|
691
|
-
}).parse(
|
|
691
|
+
}).parse(args2);
|
|
692
692
|
if (typeof Bun === "undefined") {
|
|
693
693
|
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---------------------"));
|
|
694
694
|
process.exit(1);
|
|
@@ -839,12 +839,12 @@ var publish = async (ctx, args) => {
|
|
|
839
839
|
// lib/cmd-fns/soupify.ts
|
|
840
840
|
import {z as z15} from "zod";
|
|
841
841
|
import {writeFileSync as writeFileSync2} from "fs";
|
|
842
|
-
var soupifyCmd = async (ctx,
|
|
842
|
+
var soupifyCmd = async (ctx, args2) => {
|
|
843
843
|
const params = z15.object({
|
|
844
844
|
file: z15.string(),
|
|
845
845
|
export: z15.string().optional(),
|
|
846
846
|
output: z15.string().optional()
|
|
847
|
-
}).parse(
|
|
847
|
+
}).parse(args2);
|
|
848
848
|
const soup = await soupify({
|
|
849
849
|
filePath: params.file,
|
|
850
850
|
exportName: params.export
|
|
@@ -1347,12 +1347,12 @@ var getGeneratedTsconfig = () => `
|
|
|
1347
1347
|
`.trim();
|
|
1348
1348
|
|
|
1349
1349
|
// lib/cmd-fns/init/index.ts
|
|
1350
|
-
var initCmd = async (ctx,
|
|
1350
|
+
var initCmd = async (ctx, args2) => {
|
|
1351
1351
|
const params = z17.object({
|
|
1352
1352
|
name: z17.string().optional(),
|
|
1353
1353
|
dir: z17.string().optional(),
|
|
1354
1354
|
runtime: z17.enum(["bun", "node"]).optional()
|
|
1355
|
-
}).parse(
|
|
1355
|
+
}).parse(args2);
|
|
1356
1356
|
if (params.name && !params.dir) {
|
|
1357
1357
|
params.dir = `./${params.name.split("/").pop()}`;
|
|
1358
1358
|
} else if (!params.dir) {
|
|
@@ -1433,11 +1433,11 @@ export const MyExample = () => (
|
|
|
1433
1433
|
};
|
|
1434
1434
|
|
|
1435
1435
|
// lib/cmd-fns/dev/index.ts
|
|
1436
|
-
var devCmd = async (ctx,
|
|
1436
|
+
var devCmd = async (ctx, args2) => {
|
|
1437
1437
|
const params = z18.object({
|
|
1438
1438
|
cwd: z18.string().optional().default(process.cwd()),
|
|
1439
1439
|
port: z18.coerce.number().optional().default(3020)
|
|
1440
|
-
}).parse(
|
|
1440
|
+
}).parse(args2);
|
|
1441
1441
|
const { cwd, port } = params;
|
|
1442
1442
|
const isInitialized = await checkIfInitialized(ctx);
|
|
1443
1443
|
if (!isInitialized) {
|
|
@@ -1495,11 +1495,11 @@ var devCmd = async (ctx, args) => {
|
|
|
1495
1495
|
import kleur12 from "kleur";
|
|
1496
1496
|
import {z as z19} from "zod";
|
|
1497
1497
|
import $4 from "dax-sh";
|
|
1498
|
-
var addCmd = async (ctx,
|
|
1498
|
+
var addCmd = async (ctx, args2) => {
|
|
1499
1499
|
const params = z19.object({
|
|
1500
1500
|
packages: z19.array(z19.string()),
|
|
1501
1501
|
flags: z19.object({ dev: z19.boolean().optional().default(false) }).optional().default({})
|
|
1502
|
-
}).parse(
|
|
1502
|
+
}).parse(args2);
|
|
1503
1503
|
params.packages = params.packages.map((p) => p.replace(/^@/, ""));
|
|
1504
1504
|
await createOrModifyNpmrc({ quiet: true }, ctx);
|
|
1505
1505
|
$4.cd(ctx.cwd);
|
|
@@ -1512,11 +1512,11 @@ var addCmd = async (ctx, args) => {
|
|
|
1512
1512
|
import kleur13 from "kleur";
|
|
1513
1513
|
import {z as z20} from "zod";
|
|
1514
1514
|
import $5 from "dax-sh";
|
|
1515
|
-
var removeCmd = async (ctx,
|
|
1515
|
+
var removeCmd = async (ctx, args2) => {
|
|
1516
1516
|
const params = z20.object({
|
|
1517
1517
|
packages: z20.array(z20.string()),
|
|
1518
1518
|
flags: z20.object({}).optional().default({})
|
|
1519
|
-
}).parse(
|
|
1519
|
+
}).parse(args2);
|
|
1520
1520
|
params.packages = params.packages.map((p) => p.replace(/^@/, ""));
|
|
1521
1521
|
await createOrModifyNpmrc({ quiet: true }, ctx);
|
|
1522
1522
|
$5.cd(ctx.cwd);
|
|
@@ -1529,11 +1529,11 @@ var removeCmd = async (ctx, args) => {
|
|
|
1529
1529
|
import kleur14 from "kleur";
|
|
1530
1530
|
import {z as z21} from "zod";
|
|
1531
1531
|
import $6 from "dax-sh";
|
|
1532
|
-
var installCmd = async (ctx,
|
|
1532
|
+
var installCmd = async (ctx, args2) => {
|
|
1533
1533
|
const params = z21.object({
|
|
1534
1534
|
packages: z21.array(z21.string()),
|
|
1535
1535
|
flags: z21.object({ dev: z21.boolean().optional().default(false) }).optional().default({})
|
|
1536
|
-
}).parse(
|
|
1536
|
+
}).parse(args2);
|
|
1537
1537
|
params.packages = params.packages.map((p) => p.replace(/^@/, ""));
|
|
1538
1538
|
await createOrModifyNpmrc({ quiet: true }, ctx);
|
|
1539
1539
|
$6.cd(ctx.cwd);
|
|
@@ -1548,12 +1548,12 @@ import {z as z23} from "zod";
|
|
|
1548
1548
|
import $7 from "dax-sh";
|
|
1549
1549
|
// lib/cmd-fns/dev-server-upload.ts
|
|
1550
1550
|
import {z as z25} from "zod";
|
|
1551
|
-
var devServerUpload = async (ctx,
|
|
1551
|
+
var devServerUpload = async (ctx, args2) => {
|
|
1552
1552
|
const params = z25.object({
|
|
1553
1553
|
dir: z25.string().optional().default(ctx.cwd),
|
|
1554
1554
|
port: z25.coerce.number().optional().default(3020),
|
|
1555
1555
|
watch: z25.boolean().optional().default(false)
|
|
1556
|
-
}).parse(
|
|
1556
|
+
}).parse(args2);
|
|
1557
1557
|
const serverUrl = `http://localhost:${params.port}`;
|
|
1558
1558
|
const devServerAxios = getDevServerAxios({ serverUrl });
|
|
1559
1559
|
console.log(`Loading examples...`);
|
|
@@ -1567,7 +1567,7 @@ import {existsSync as existsSync4, readFileSync as readFileSync6} from "fs";
|
|
|
1567
1567
|
import kleur16 from "kleur";
|
|
1568
1568
|
import * as Path8 from "path";
|
|
1569
1569
|
import open2 from "open";
|
|
1570
|
-
var openCmd = async (ctx,
|
|
1570
|
+
var openCmd = async (ctx, args2) => {
|
|
1571
1571
|
const packageJsonPath = Path8.join(ctx.cwd, "package.json");
|
|
1572
1572
|
if (!existsSync4(packageJsonPath)) {
|
|
1573
1573
|
console.log(kleur16.red("No package.json found in current directory"));
|
|
@@ -1583,50 +1583,50 @@ var getProgram = (ctx) => {
|
|
|
1583
1583
|
const cmd = new Command("tsci");
|
|
1584
1584
|
cmd.version(package_default.version);
|
|
1585
1585
|
const authCmd = cmd.command("auth");
|
|
1586
|
-
authCmd.command("login").action((
|
|
1587
|
-
authCmd.command("logout").action((
|
|
1586
|
+
authCmd.command("login").action((args2) => authLogin(ctx, args2));
|
|
1587
|
+
authCmd.command("logout").action((args2) => authLogout(ctx, args2));
|
|
1588
1588
|
const configCmd = cmd.command("config");
|
|
1589
|
-
configCmd.command("reveal-location").action((
|
|
1590
|
-
configCmd.command("set-registry").requiredOption("--server <server>", "Registry URL").action((
|
|
1591
|
-
configCmd.command("set-session").requiredOption("--session-token <session_token>", "Session Token").action((
|
|
1592
|
-
configCmd.command("set-log-requests").requiredOption("--log-requests", "Should log requests to registry").action((
|
|
1593
|
-
configCmd.command("print-config").action((
|
|
1589
|
+
configCmd.command("reveal-location").action((args2) => configRevealLocation(ctx, args2));
|
|
1590
|
+
configCmd.command("set-registry").requiredOption("--server <server>", "Registry URL").action((args2) => configSetRegistry(ctx, args2));
|
|
1591
|
+
configCmd.command("set-session").requiredOption("--session-token <session_token>", "Session Token").action((args2) => configSetSession(ctx, args2));
|
|
1592
|
+
configCmd.command("set-log-requests").requiredOption("--log-requests", "Should log requests to registry").action((args2) => configSetLogRequests(ctx, args2));
|
|
1593
|
+
configCmd.command("print-config").action((args2) => configPrintConfig(ctx, args2));
|
|
1594
1594
|
const authSessionsCmd = authCmd.command("sessions");
|
|
1595
|
-
authSessionsCmd.command("create").action((
|
|
1596
|
-
authSessionsCmd.command("list").action((
|
|
1597
|
-
authSessionsCmd.command("get").action((
|
|
1595
|
+
authSessionsCmd.command("create").action((args2) => authSessionsCreate(ctx, args2));
|
|
1596
|
+
authSessionsCmd.command("list").action((args2) => authSessionsList(ctx, args2));
|
|
1597
|
+
authSessionsCmd.command("get").action((args2) => authSessionsGet(ctx, args2));
|
|
1598
1598
|
const packagesCmd = cmd.command("packages");
|
|
1599
|
-
packagesCmd.command("list").action((
|
|
1600
|
-
packagesCmd.command("get").option("--package-id <package_id>", "Package Id").option("--name <name>", "Package name").action((
|
|
1601
|
-
packagesCmd.command("create").requiredOption("--name <name>", "Package name").option("--author-id <author_account_id>", "Author Id").option("--description <description>", "Package description").action((
|
|
1599
|
+
packagesCmd.command("list").action((args2) => packagesList(ctx, args2));
|
|
1600
|
+
packagesCmd.command("get").option("--package-id <package_id>", "Package Id").option("--name <name>", "Package name").action((args2) => packagesGet(ctx, args2));
|
|
1601
|
+
packagesCmd.command("create").requiredOption("--name <name>", "Package name").option("--author-id <author_account_id>", "Author Id").option("--description <description>", "Package description").action((args2) => packagesCreate(ctx, args2));
|
|
1602
1602
|
const packageReleases = cmd.command("package_releases");
|
|
1603
|
-
packageReleases.command("list").requiredOption("--package-name <package_name>", "Package name").option("--verbose", "Verbose objects (includes uuids)").action((
|
|
1604
|
-
packageReleases.command("get").action((
|
|
1605
|
-
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((
|
|
1603
|
+
packageReleases.command("list").requiredOption("--package-name <package_name>", "Package name").option("--verbose", "Verbose objects (includes uuids)").action((args2) => packageReleasesList(ctx, args2));
|
|
1604
|
+
packageReleases.command("get").action((args2) => packageReleasesGet(ctx, args2));
|
|
1605
|
+
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));
|
|
1606
1606
|
const packageFiles = cmd.command("package_files");
|
|
1607
|
-
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((
|
|
1608
|
-
packageFiles.command("get").action((
|
|
1609
|
-
packageFiles.command("download").requiredOption("--package-name-with-version <package_name_with_version>", "Package name and version").requiredOption("--remote-file-path <remote_file_path>", "Remote file path").option("--output <output>", "Output file path (optional), prints to stdout if not provided").action((
|
|
1610
|
-
packageFiles.command("create").option("-p, --package-release-id <package_release_id>", "Package Release Id").option("--package-name-with-version <package_name_with_version>", "Package name with version e.g. @tscircuit/arduino@1.2.3").requiredOption("--file <file>", "File to upload").action((
|
|
1611
|
-
packageFiles.command("upload-directory").requiredOption("--dir <dir>", "Directory to upload").action((
|
|
1607
|
+
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
|
+
packageFiles.command("get").action((args2) => packageFilesGet(ctx, args2));
|
|
1609
|
+
packageFiles.command("download").requiredOption("--package-name-with-version <package_name_with_version>", "Package name and version").requiredOption("--remote-file-path <remote_file_path>", "Remote file path").option("--output <output>", "Output file path (optional), prints to stdout if not provided").action((args2) => packageFilesDownload(ctx, args2));
|
|
1610
|
+
packageFiles.command("create").option("-p, --package-release-id <package_release_id>", "Package Release Id").option("--package-name-with-version <package_name_with_version>", "Package name with version e.g. @tscircuit/arduino@1.2.3").requiredOption("--file <file>", "File to upload").action((args2) => packageFilesCreate(ctx, args2));
|
|
1611
|
+
packageFiles.command("upload-directory").requiredOption("--dir <dir>", "Directory to upload").action((args2) => packageFilesUploadDirectory(ctx, args2));
|
|
1612
1612
|
const packageExamples = cmd.command("package_examples");
|
|
1613
|
-
packageExamples.command("list").requiredOption("--package-name-with-version <package_name_with_version>").action((
|
|
1614
|
-
packageExamples.command("get").requiredOption("--package-example-id <package_example_id>").action((
|
|
1615
|
-
packageExamples.command("create").requiredOption("--package-name-with-version <package_name_with_version>").requiredOption("--file <file>").option("--export <export>", "Name of export to soupify").action((
|
|
1616
|
-
cmd.command("publish").option("--increment", "Increase patch version").option("--patch", "Increase patch version").option("--lock", "Lock the release after publishing to prevent changes").action((
|
|
1617
|
-
cmd.command("version").action(() =>
|
|
1618
|
-
cmd.command("login").action((
|
|
1619
|
-
cmd.command("logout").action((
|
|
1620
|
-
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((
|
|
1621
|
-
cmd.command("dev").option("--cwd <cwd>", "Current working directory").option("--port <port>", "Port to run dev server on").action((
|
|
1622
|
-
cmd.command("init").option("--name <name>", "Name of the project").option("--runtime <runtime>", "Runtime to use (attempts to bun, otherwise node/tsx)").option("--dir <dir>", "Directory to initialize (defaults to ./<name> or . if name not provided)").action((
|
|
1613
|
+
packageExamples.command("list").requiredOption("--package-name-with-version <package_name_with_version>").action((args2) => packageExamplesList(ctx, args2));
|
|
1614
|
+
packageExamples.command("get").requiredOption("--package-example-id <package_example_id>").action((args2) => packageExamplesGet(ctx, args2));
|
|
1615
|
+
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
|
+
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(() => undefined(ctx, args));
|
|
1618
|
+
cmd.command("login").action((args2) => authLogin(ctx, args2));
|
|
1619
|
+
cmd.command("logout").action((args2) => authLogout(ctx, args2));
|
|
1620
|
+
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));
|
|
1621
|
+
cmd.command("dev").option("--cwd <cwd>", "Current working directory").option("--port <port>", "Port to run dev server on").action((args2) => devCmd(ctx, args2));
|
|
1622
|
+
cmd.command("init").option("--name <name>", "Name of the project").option("--runtime <runtime>", "Runtime to use (attempts to bun, otherwise node/tsx)").option("--dir <dir>", "Directory to initialize (defaults to ./<name> or . if name not provided)").action((args2) => initCmd(ctx, args2));
|
|
1623
1623
|
cmd.command("add").argument("<packages...>", "Packages to install from registry.tscircuit.com, optionally with version").option("-D, --dev", "Add to devDependencies").action((packages, flags) => addCmd(ctx, { packages, flags }));
|
|
1624
1624
|
cmd.command("remove").argument("<packages...>", "Packages to remove").action((packages, flags) => removeCmd(ctx, { packages, flags }));
|
|
1625
1625
|
cmd.command("install").argument("<packages...>", "Packages to install from registry.tscircuit.com, optionally with version").option("-D, --dev", "Add to devDependencies").action((packages, flags) => installCmd(ctx, { packages, flags }));
|
|
1626
1626
|
cmd.command("uninstall").argument("<packages...>", "Packages to uninstall").action((packages, flags) => installCmd(ctx, { packages, flags }));
|
|
1627
1627
|
const devServerCmd = cmd.command("dev-server");
|
|
1628
|
-
devServerCmd.command("upload").option("--dir <dir>", "Directory to upload (defaults to current directory)").option("-w, --watch", "Watch for changes").option("-p, --port", "Port dev server is running on (default: 3020)").action((
|
|
1629
|
-
cmd.command("open").action((
|
|
1628
|
+
devServerCmd.command("upload").option("--dir <dir>", "Directory to upload (defaults to current directory)").option("-w, --watch", "Watch for changes").option("-p, --port", "Port dev server is running on (default: 3020)").action((args2) => devServerUpload(ctx, args2));
|
|
1629
|
+
cmd.command("open").action((args2) => openCmd(ctx, args2));
|
|
1630
1630
|
return cmd;
|
|
1631
1631
|
};
|
|
1632
1632
|
|
|
@@ -1761,12 +1761,12 @@ var interactForPackageNameWithVersion = async ({
|
|
|
1761
1761
|
]
|
|
1762
1762
|
});
|
|
1763
1763
|
if (selectedPackage.endsWith("@...")) {
|
|
1764
|
-
const { version } = await prompts3({
|
|
1764
|
+
const { version: version2 } = await prompts3({
|
|
1765
1765
|
type: "text",
|
|
1766
1766
|
name: "version",
|
|
1767
1767
|
message: "Enter the version"
|
|
1768
1768
|
});
|
|
1769
|
-
return selectedPackage.replace("@...", `@${
|
|
1769
|
+
return selectedPackage.replace("@...", `@${version2}`);
|
|
1770
1770
|
}
|
|
1771
1771
|
if (selectedPackage === "Enter Manually") {
|
|
1772
1772
|
const { packageName } = await prompts3({
|
|
@@ -1868,17 +1868,24 @@ var createConfigHandler = ({
|
|
|
1868
1868
|
|
|
1869
1869
|
// lib/util/create-context-and-run-program.ts
|
|
1870
1870
|
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
|
|
1871
1878
|
var createContextAndRunProgram = async (process_args) => {
|
|
1872
|
-
const
|
|
1879
|
+
const args2 = minimist(process_args);
|
|
1873
1880
|
const { global_config, profile_config, current_profile } = createConfigHandler({
|
|
1874
|
-
profile:
|
|
1881
|
+
profile: args2.profile
|
|
1875
1882
|
});
|
|
1876
1883
|
const registry_url = profile_config.get("registry_url") ?? "https://registry-api.tscircuit.com";
|
|
1877
|
-
|
|
1878
|
-
for (const key in
|
|
1884
|
+
args2._ = args2._.map((p) => p.toLowerCase().replace(/-/g, "_"));
|
|
1885
|
+
for (const key in args2) {
|
|
1879
1886
|
if (key.includes("-")) {
|
|
1880
|
-
|
|
1881
|
-
delete
|
|
1887
|
+
args2[key.replace(/-/g, "_")] = args2[key];
|
|
1888
|
+
delete args2[key];
|
|
1882
1889
|
}
|
|
1883
1890
|
}
|
|
1884
1891
|
const axios = defaultAxios2.create({
|
|
@@ -1907,23 +1914,27 @@ var createContextAndRunProgram = async (process_args) => {
|
|
|
1907
1914
|
return Promise.reject(err);
|
|
1908
1915
|
});
|
|
1909
1916
|
const ctx = {
|
|
1910
|
-
cmd:
|
|
1911
|
-
cwd:
|
|
1917
|
+
cmd: args2._,
|
|
1918
|
+
cwd: args2.cwd ?? process.cwd(),
|
|
1912
1919
|
current_profile,
|
|
1913
1920
|
registry_url,
|
|
1914
1921
|
axios,
|
|
1915
1922
|
global_config,
|
|
1916
1923
|
profile_config,
|
|
1917
1924
|
args: {
|
|
1918
|
-
cmd:
|
|
1919
|
-
yes:
|
|
1925
|
+
cmd: args2._,
|
|
1926
|
+
yes: args2.y ?? args2.yes,
|
|
1920
1927
|
help: undefined
|
|
1921
1928
|
},
|
|
1922
|
-
params:
|
|
1929
|
+
params: args2
|
|
1923
1930
|
};
|
|
1924
|
-
delete
|
|
1925
|
-
const { _: positional, ...flagsAndParams } =
|
|
1931
|
+
delete args2["cwd"];
|
|
1932
|
+
const { _: positional, ...flagsAndParams } = args2;
|
|
1926
1933
|
const args_without_globals = positional.concat(dargs(flagsAndParams));
|
|
1934
|
+
if (args2["version"] && args2._.length === 2) {
|
|
1935
|
+
await versionCmd(ctx, {});
|
|
1936
|
+
process.exit(0);
|
|
1937
|
+
}
|
|
1927
1938
|
await perfectCli(getProgram(ctx), args_without_globals, {
|
|
1928
1939
|
async customParamHandler({ commandPath, optionName }, { prompts: prompts3 }) {
|
|
1929
1940
|
const optionNameHandler = PARAM_HANDLERS_BY_PARAM_NAME[_.snakeCase(optionName)];
|
package/lib/get-program.ts
CHANGED
|
@@ -166,9 +166,7 @@ export const getProgram = (ctx: AppContext) => {
|
|
|
166
166
|
.option("--lock", "Lock the release after publishing to prevent changes")
|
|
167
167
|
.action((args) => CMDFN.publish(ctx, args))
|
|
168
168
|
|
|
169
|
-
cmd
|
|
170
|
-
.command("version")
|
|
171
|
-
.action(() => console.log(`tsci v${packageJson.version}`))
|
|
169
|
+
cmd.command("version").action(() => CMDFN.version(ctx, args))
|
|
172
170
|
|
|
173
171
|
cmd.command("login").action((args) => CMDFN.authLogin(ctx, args))
|
|
174
172
|
cmd.command("logout").action((args) => CMDFN.authLogout(ctx, args))
|
|
@@ -10,6 +10,7 @@ import kleur from "kleur"
|
|
|
10
10
|
import { PARAM_HANDLERS_BY_PARAM_NAME } from "lib/param-handlers"
|
|
11
11
|
import { createConfigHandler } from "lib/create-config-manager"
|
|
12
12
|
import dargs from "dargs"
|
|
13
|
+
import { versionCmd } from "lib/cmd-fns/version"
|
|
13
14
|
|
|
14
15
|
export type CliArgs = {
|
|
15
16
|
cmd: string[]
|
|
@@ -112,6 +113,11 @@ export const createContextAndRunProgram = async (process_args: any) => {
|
|
|
112
113
|
const { _: positional, ...flagsAndParams } = args
|
|
113
114
|
const args_without_globals = positional.concat(dargs(flagsAndParams))
|
|
114
115
|
|
|
116
|
+
if (args["version"] && args._.length === 2) {
|
|
117
|
+
await versionCmd(ctx, {})
|
|
118
|
+
process.exit(0)
|
|
119
|
+
}
|
|
120
|
+
|
|
115
121
|
await perfectCli(getProgram(ctx), args_without_globals, {
|
|
116
122
|
async customParamHandler({ commandPath, optionName }, { prompts }) {
|
|
117
123
|
const optionNameHandler =
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tscircuit/cli",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.14",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "Command line tool for developing, publishing and installing tscircuit circuits",
|
|
7
7
|
"main": "./dist/cli.js",
|
|
8
8
|
"scripts": {
|
|
9
|
-
"bootstrap": "bun i && cd dev-server-api && bun i && cd ../dev-server-frontend && bun i",
|
|
9
|
+
"bootstrap": "bun i --frozen-lockfile && cd dev-server-api && bun i --frozen-lockfile && cd ../dev-server-frontend && bun i --frozen-lockfile",
|
|
10
10
|
"start": "bun cli.ts",
|
|
11
11
|
"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'",
|
|
12
12
|
"start:dev-server": "bun build:dev-server && bun cli.ts dev -y --cwd ./tests/assets/example-project",
|
|
@@ -19,7 +19,13 @@
|
|
|
19
19
|
"tscircuit": "./dist/cli.js",
|
|
20
20
|
"tsci": "./dist/cli.js"
|
|
21
21
|
},
|
|
22
|
-
"keywords": [
|
|
22
|
+
"keywords": [
|
|
23
|
+
"circuit",
|
|
24
|
+
"react",
|
|
25
|
+
"electronics",
|
|
26
|
+
"pcb",
|
|
27
|
+
"schematic"
|
|
28
|
+
],
|
|
23
29
|
"author": "",
|
|
24
30
|
"license": "ISC",
|
|
25
31
|
"dependencies": {
|