@tscircuit/cli 0.0.8 → 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/bun.lockb +0 -0
- package/dist/cli.js +214 -168
- package/lib/cmd-fns/auth-logout.ts +5 -1
- package/lib/cmd-fns/config-clear.ts +5 -0
- package/lib/cmd-fns/index.ts +2 -0
- package/lib/cmd-fns/open.ts +19 -0
- package/lib/cmd-fns/publish/index.ts +23 -15
- package/lib/cmd-fns/version.ts +6 -0
- package/lib/create-config-manager.ts +89 -0
- package/lib/get-program.ts +3 -3
- package/lib/util/app-context.ts +3 -4
- package/lib/util/create-context-and-run-program.ts +28 -11
- package/package.json +11 -3
- package/tests/open.test.ts +9 -0
package/dist/cli.js
CHANGED
|
@@ -200,7 +200,6 @@ var require_dist = __commonJS((exports, module) => {
|
|
|
200
200
|
});
|
|
201
201
|
|
|
202
202
|
// lib/util/create-context-and-run-program.ts
|
|
203
|
-
import Configstore from "configstore";
|
|
204
203
|
import minimist from "minimist";
|
|
205
204
|
import _ from "lodash";
|
|
206
205
|
import {perfectCli} from "perfect-cli";
|
|
@@ -210,13 +209,13 @@ import {Command} from "commander";
|
|
|
210
209
|
// package.json
|
|
211
210
|
var package_default = {
|
|
212
211
|
name: "@tscircuit/cli",
|
|
213
|
-
version: "0.0.
|
|
212
|
+
version: "0.0.13",
|
|
214
213
|
private: false,
|
|
215
214
|
type: "module",
|
|
216
215
|
description: "Command line tool for developing, publishing and installing tscircuit circuits",
|
|
217
216
|
main: "./dist/cli.js",
|
|
218
217
|
scripts: {
|
|
219
|
-
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",
|
|
220
219
|
start: "bun cli.ts",
|
|
221
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'",
|
|
222
221
|
"start:dev-server": "bun build:dev-server && bun cli.ts dev -y --cwd ./tests/assets/example-project",
|
|
@@ -229,7 +228,7 @@ var package_default = {
|
|
|
229
228
|
tscircuit: "./dist/cli.js",
|
|
230
229
|
tsci: "./dist/cli.js"
|
|
231
230
|
},
|
|
232
|
-
keywords: [],
|
|
231
|
+
keywords: ["circuit", "react", "electronics", "pcb", "schematic"],
|
|
233
232
|
author: "",
|
|
234
233
|
license: "ISC",
|
|
235
234
|
dependencies: {
|
|
@@ -242,9 +241,11 @@ var package_default = {
|
|
|
242
241
|
chokidar: "^3.6.0",
|
|
243
242
|
commander: "^12.0.0",
|
|
244
243
|
configstore: "^6.0.0",
|
|
244
|
+
dargs: "^8.1.0",
|
|
245
245
|
"dax-sh": "^0.39.2",
|
|
246
246
|
delay: "^6.0.0",
|
|
247
247
|
edgespec: "^0.0.69",
|
|
248
|
+
esbuild: "^0.20.2",
|
|
248
249
|
glob: "^10.3.10",
|
|
249
250
|
hono: "^4.1.0",
|
|
250
251
|
ignore: "^5.3.1",
|
|
@@ -280,35 +281,35 @@ var package_default = {
|
|
|
280
281
|
};
|
|
281
282
|
|
|
282
283
|
// lib/cmd-fns/config-reveal-location.ts
|
|
283
|
-
var configRevealLocation = async (ctx,
|
|
284
|
+
var configRevealLocation = async (ctx, args2) => {
|
|
284
285
|
console.log(`tsci config path: ${ctx.global_config.path}`);
|
|
285
286
|
};
|
|
286
287
|
// lib/cmd-fns/config-set-registry.ts
|
|
287
288
|
import {z} from "zod";
|
|
288
|
-
var configSetRegistry = async (ctx,
|
|
289
|
-
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);
|
|
290
291
|
ctx.profile_config.set("registry_url", params.server);
|
|
291
292
|
};
|
|
292
293
|
// lib/cmd-fns/config-set-session.ts
|
|
293
294
|
import {z as z2} from "zod";
|
|
294
|
-
var configSetSession = async (ctx,
|
|
295
|
-
const params = z2.object({ sessionToken: z2.string() }).parse(
|
|
295
|
+
var configSetSession = async (ctx, args2) => {
|
|
296
|
+
const params = z2.object({ sessionToken: z2.string() }).parse(args2);
|
|
296
297
|
ctx.profile_config.set("session_token", params.sessionToken);
|
|
297
298
|
};
|
|
298
299
|
// lib/cmd-fns/config-set-log-requests.ts
|
|
299
300
|
import {z as z3} from "zod";
|
|
300
|
-
var configSetLogRequests = async (ctx,
|
|
301
|
-
const params = z3.object({ logRequests: z3.boolean() }).parse(
|
|
301
|
+
var configSetLogRequests = async (ctx, args2) => {
|
|
302
|
+
const params = z3.object({ logRequests: z3.boolean() }).parse(args2);
|
|
302
303
|
ctx.global_config.set("log_requests", params.logRequests);
|
|
303
304
|
};
|
|
304
305
|
// lib/cmd-fns/config-print-config.ts
|
|
305
306
|
import {readFile} from "fs/promises";
|
|
306
|
-
var configPrintConfig = async (ctx,
|
|
307
|
+
var configPrintConfig = async (ctx, args2) => {
|
|
307
308
|
console.log((await readFile(ctx.global_config.path)).toString());
|
|
308
309
|
};
|
|
309
310
|
// lib/cmd-fns/auth-login.ts
|
|
310
311
|
import delay from "delay";
|
|
311
|
-
var authLogin = async (ctx,
|
|
312
|
+
var authLogin = async (ctx, args2) => {
|
|
312
313
|
const {
|
|
313
314
|
data: { login_page }
|
|
314
315
|
} = await ctx.axios.post("/sessions/login_page/create", {});
|
|
@@ -346,20 +347,23 @@ var authLogin = async (ctx, args) => {
|
|
|
346
347
|
console.log("Ready to use!");
|
|
347
348
|
};
|
|
348
349
|
// lib/cmd-fns/auth-logout.ts
|
|
349
|
-
|
|
350
|
+
import kleur from "kleur";
|
|
351
|
+
var authLogout = async (ctx, args2) => {
|
|
352
|
+
ctx.profile_config.delete("session_token");
|
|
353
|
+
console.log(kleur.green("Logged out!"));
|
|
350
354
|
};
|
|
351
355
|
// lib/cmd-fns/auth-sessions-create.ts
|
|
352
|
-
var authSessionsCreate = async (ctx,
|
|
356
|
+
var authSessionsCreate = async (ctx, args2) => {
|
|
353
357
|
};
|
|
354
358
|
// lib/cmd-fns/auth-sessions-list.ts
|
|
355
|
-
var authSessionsList = async (ctx,
|
|
359
|
+
var authSessionsList = async (ctx, args2) => {
|
|
356
360
|
await ctx.axios.get("/sessions/list");
|
|
357
361
|
};
|
|
358
362
|
// lib/cmd-fns/auth-sessions-get.ts
|
|
359
|
-
var authSessionsGet = async (ctx,
|
|
363
|
+
var authSessionsGet = async (ctx, args2) => {
|
|
360
364
|
};
|
|
361
365
|
// lib/cmd-fns/packages-list.ts
|
|
362
|
-
var packagesList = async (ctx,
|
|
366
|
+
var packagesList = async (ctx, args2) => {
|
|
363
367
|
const {
|
|
364
368
|
data: { packages }
|
|
365
369
|
} = await ctx.axios.post("/packages/list", {});
|
|
@@ -374,9 +378,9 @@ var packagesList = async (ctx, args) => {
|
|
|
374
378
|
};
|
|
375
379
|
// lib/cmd-fns/packages-get.ts
|
|
376
380
|
import {z as z4} from "zod";
|
|
377
|
-
var packagesGet = async (ctx,
|
|
378
|
-
|
|
379
|
-
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);
|
|
380
384
|
const {
|
|
381
385
|
data: { package: pkg }
|
|
382
386
|
} = await ctx.axios.post("/packages/get", params);
|
|
@@ -384,25 +388,25 @@ var packagesGet = async (ctx, args) => {
|
|
|
384
388
|
};
|
|
385
389
|
// lib/cmd-fns/packages-create.ts
|
|
386
390
|
import {z as z5} from "zod";
|
|
387
|
-
var packagesCreate = async (ctx,
|
|
391
|
+
var packagesCreate = async (ctx, args2) => {
|
|
388
392
|
const params = z5.object({
|
|
389
393
|
name: z5.string(),
|
|
390
394
|
description: z5.string().optional(),
|
|
391
395
|
authorAccountId: z5.string().optional()
|
|
392
|
-
}).parse(
|
|
396
|
+
}).parse(args2);
|
|
393
397
|
await ctx.axios.post("/packages/create", params);
|
|
394
398
|
console.log(`Package "${params.name}" created!`);
|
|
395
399
|
};
|
|
396
400
|
// lib/cmd-fns/package-files-upload-directory.ts
|
|
397
|
-
var packageFilesUploadDirectory = async (ctx,
|
|
401
|
+
var packageFilesUploadDirectory = async (ctx, args2) => {
|
|
398
402
|
};
|
|
399
403
|
// lib/cmd-fns/package-releases-list.ts
|
|
400
404
|
import {z as z6} from "zod";
|
|
401
|
-
var packageReleasesList = async (ctx,
|
|
405
|
+
var packageReleasesList = async (ctx, args2) => {
|
|
402
406
|
const params = z6.object({
|
|
403
407
|
packageName: z6.string().optional(),
|
|
404
408
|
verbose: z6.boolean().optional()
|
|
405
|
-
}).parse(
|
|
409
|
+
}).parse(args2);
|
|
406
410
|
const package_releases = await ctx.axios.post("/package_releases/list", {
|
|
407
411
|
package_name: params.packageName
|
|
408
412
|
}).then((r) => r.data.package_releases);
|
|
@@ -417,13 +421,13 @@ var packageReleasesList = async (ctx, args) => {
|
|
|
417
421
|
}
|
|
418
422
|
};
|
|
419
423
|
// lib/cmd-fns/package-releases-get.ts
|
|
420
|
-
var packageReleasesGet = async (ctx,
|
|
424
|
+
var packageReleasesGet = async (ctx, args2) => {
|
|
421
425
|
};
|
|
422
426
|
// lib/cmd-fns/package-releases-create.ts
|
|
423
427
|
import {z as z7} from "zod";
|
|
424
|
-
import
|
|
425
|
-
var packageReleasesCreate = async (ctx,
|
|
426
|
-
|
|
428
|
+
import kleur2 from "kleur";
|
|
429
|
+
var packageReleasesCreate = async (ctx, args2) => {
|
|
430
|
+
args2.version = args2.releaseVersion;
|
|
427
431
|
const params = z7.object({
|
|
428
432
|
packageNameWithVersion: z7.string().optional(),
|
|
429
433
|
packageName: z7.string().optional(),
|
|
@@ -434,7 +438,7 @@ var packageReleasesCreate = async (ctx, args) => {
|
|
|
434
438
|
if (d.packageName && d.version)
|
|
435
439
|
return true;
|
|
436
440
|
return false;
|
|
437
|
-
}, "Either packageNameWithVersion or packageName and version must be provided").parse(
|
|
441
|
+
}, "Either packageNameWithVersion or packageName and version must be provided").parse(args2);
|
|
438
442
|
let { packageNameWithVersion, packageName, version } = params;
|
|
439
443
|
if (!packageNameWithVersion) {
|
|
440
444
|
packageNameWithVersion = `${packageName}@${version}`;
|
|
@@ -442,17 +446,17 @@ var packageReleasesCreate = async (ctx, args) => {
|
|
|
442
446
|
const package_release = await ctx.axios.post("/package_releases/create", {
|
|
443
447
|
package_name_with_version: packageNameWithVersion
|
|
444
448
|
}).then((r) => r.data.package_release);
|
|
445
|
-
console.log(`Package release created! ${
|
|
449
|
+
console.log(`Package release created! ${kleur2.gray(package_release.package_release_id)}`);
|
|
446
450
|
};
|
|
447
451
|
// lib/cmd-fns/package-files-list.ts
|
|
448
452
|
import {z as z8} from "zod";
|
|
449
|
-
var packageFilesList = async (ctx,
|
|
453
|
+
var packageFilesList = async (ctx, args2) => {
|
|
450
454
|
const params = z8.object({
|
|
451
455
|
packageReleaseId: z8.string().optional(),
|
|
452
456
|
packageName: z8.string().optional(),
|
|
453
457
|
packageNameWithVersion: z8.string().optional(),
|
|
454
458
|
verbose: z8.boolean().optional()
|
|
455
|
-
}).parse(
|
|
459
|
+
}).parse(args2);
|
|
456
460
|
const package_files = await ctx.axios.post("/package_files/list", {
|
|
457
461
|
package_release_id: params.packageReleaseId,
|
|
458
462
|
package_name: params.packageName,
|
|
@@ -466,17 +470,17 @@ var packageFilesList = async (ctx, args) => {
|
|
|
466
470
|
}
|
|
467
471
|
};
|
|
468
472
|
// lib/cmd-fns/package-files-get.ts
|
|
469
|
-
var packageFilesGet = async (ctx,
|
|
473
|
+
var packageFilesGet = async (ctx, args2) => {
|
|
470
474
|
};
|
|
471
475
|
// lib/cmd-fns/package-files-download.ts
|
|
472
476
|
import {z as z9} from "zod";
|
|
473
477
|
import * as fs from "fs/promises";
|
|
474
|
-
var packageFilesDownload = async (ctx,
|
|
478
|
+
var packageFilesDownload = async (ctx, args2) => {
|
|
475
479
|
const params = z9.object({
|
|
476
480
|
packageNameWithVersion: z9.string().optional(),
|
|
477
481
|
remoteFilePath: z9.string().optional(),
|
|
478
482
|
output: z9.string().optional()
|
|
479
|
-
}).parse(
|
|
483
|
+
}).parse(args2);
|
|
480
484
|
const { packageNameWithVersion, remoteFilePath } = params;
|
|
481
485
|
const packageContent = await ctx.axios.post("/package_files/download", {
|
|
482
486
|
package_name_with_version: packageNameWithVersion,
|
|
@@ -492,13 +496,13 @@ var packageFilesDownload = async (ctx, args) => {
|
|
|
492
496
|
// lib/cmd-fns/package-files-create.ts
|
|
493
497
|
import {z as z10} from "zod";
|
|
494
498
|
import * as fs2 from "fs/promises";
|
|
495
|
-
import
|
|
496
|
-
var packageFilesCreate = async (ctx,
|
|
499
|
+
import kleur3 from "kleur";
|
|
500
|
+
var packageFilesCreate = async (ctx, args2) => {
|
|
497
501
|
const params = z10.object({
|
|
498
502
|
file: z10.string(),
|
|
499
503
|
packageReleaseId: z10.string().optional(),
|
|
500
504
|
packageNameWithVersion: z10.string().optional()
|
|
501
|
-
}).parse(
|
|
505
|
+
}).parse(args2);
|
|
502
506
|
const { file, packageNameWithVersion, packageReleaseId } = params;
|
|
503
507
|
const fileContent = await fs2.readFile(file);
|
|
504
508
|
const package_file = await ctx.axios.post("/package_files/create", {
|
|
@@ -507,14 +511,14 @@ var packageFilesCreate = async (ctx, args) => {
|
|
|
507
511
|
package_name_with_version: packageNameWithVersion,
|
|
508
512
|
package_release_id: packageReleaseId
|
|
509
513
|
}).then((r) => r.data.package_file);
|
|
510
|
-
console.log(`Package file created ${
|
|
514
|
+
console.log(`Package file created ${kleur3.gray(package_file.package_file_id)}`);
|
|
511
515
|
};
|
|
512
516
|
// lib/cmd-fns/package-examples-list.ts
|
|
513
517
|
import {z as z11} from "zod";
|
|
514
|
-
var packageExamplesList = async (ctx,
|
|
518
|
+
var packageExamplesList = async (ctx, args2) => {
|
|
515
519
|
const params = z11.object({
|
|
516
520
|
packageNameWithVersion: z11.string()
|
|
517
|
-
}).parse(
|
|
521
|
+
}).parse(args2);
|
|
518
522
|
const package_examples = await ctx.axios.post("/package_examples/list", {
|
|
519
523
|
package_name_with_version: params.packageNameWithVersion
|
|
520
524
|
}).then((r) => r.data.package_examples);
|
|
@@ -522,10 +526,10 @@ var packageExamplesList = async (ctx, args) => {
|
|
|
522
526
|
};
|
|
523
527
|
// lib/cmd-fns/package-examples-get.ts
|
|
524
528
|
import {z as z12} from "zod";
|
|
525
|
-
var packageExamplesGet = async (ctx,
|
|
529
|
+
var packageExamplesGet = async (ctx, args2) => {
|
|
526
530
|
const params = z12.object({
|
|
527
531
|
packageExampleId: z12.string().uuid()
|
|
528
|
-
}).parse(
|
|
532
|
+
}).parse(args2);
|
|
529
533
|
const { packageExampleId: package_example_id } = params;
|
|
530
534
|
const package_example = await ctx.axios.post("/package_examples/get", {
|
|
531
535
|
package_example_id
|
|
@@ -585,12 +589,12 @@ console.log(JSON.stringify(elements))
|
|
|
585
589
|
// lib/cmd-fns/package-examples-create.ts
|
|
586
590
|
import {z as z13} from "zod";
|
|
587
591
|
import fs3 from "fs";
|
|
588
|
-
var packageExamplesCreate = async (ctx,
|
|
592
|
+
var packageExamplesCreate = async (ctx, args2) => {
|
|
589
593
|
const params = z13.object({
|
|
590
594
|
packageNameWithVersion: z13.string(),
|
|
591
595
|
file: z13.string(),
|
|
592
596
|
export: z13.string().optional().default("default")
|
|
593
|
-
}).parse(
|
|
597
|
+
}).parse(args2);
|
|
594
598
|
const tscircuit_soup = await soupify({
|
|
595
599
|
filePath: params.file,
|
|
596
600
|
exportName: params.export
|
|
@@ -606,7 +610,7 @@ var packageExamplesCreate = async (ctx, args) => {
|
|
|
606
610
|
console.log(package_example);
|
|
607
611
|
};
|
|
608
612
|
// lib/cmd-fns/publish/index.ts
|
|
609
|
-
import
|
|
613
|
+
import kleur4 from "kleur";
|
|
610
614
|
import {z as z14} from "zod";
|
|
611
615
|
import * as Path2 from "path";
|
|
612
616
|
import * as fs5 from "fs/promises";
|
|
@@ -678,33 +682,29 @@ var inferExportNameFromSource = (sourceContent) => {
|
|
|
678
682
|
import $2 from "dax-sh";
|
|
679
683
|
import semver from "semver";
|
|
680
684
|
import {unlink as unlink2} from "fs/promises";
|
|
681
|
-
|
|
685
|
+
import esbuild from "esbuild";
|
|
686
|
+
var publish = async (ctx, args2) => {
|
|
682
687
|
const params = z14.object({
|
|
683
688
|
increment: z14.boolean().optional(),
|
|
684
689
|
patch: z14.boolean().optional(),
|
|
685
690
|
lock: z14.boolean().optional()
|
|
686
|
-
}).parse(
|
|
691
|
+
}).parse(args2);
|
|
687
692
|
if (typeof Bun === "undefined") {
|
|
688
|
-
console.log(
|
|
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---------------------"));
|
|
689
694
|
process.exit(1);
|
|
690
695
|
}
|
|
691
696
|
const shouldIncrement = params.increment || params.patch;
|
|
692
697
|
if (!await fs5.exists(Path2.join(ctx.cwd, "package.json"))) {
|
|
693
|
-
console.log(
|
|
698
|
+
console.log(kleur4.red("No package.json found in current directory"));
|
|
694
699
|
process.exit(1);
|
|
695
700
|
}
|
|
696
701
|
const packageJson = JSON.parse(await readFileSync(Path2.join(ctx.cwd, "package.json"), "utf-8"));
|
|
697
|
-
await
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
...Object.keys(packageJson.peerDependencies || {}),
|
|
704
|
-
...Object.keys(packageJson.trustedDependencies || {})
|
|
705
|
-
],
|
|
706
|
-
outdir: "dist",
|
|
707
|
-
target: "node"
|
|
702
|
+
await esbuild.build({
|
|
703
|
+
entryPoints: ["index.ts"],
|
|
704
|
+
bundle: true,
|
|
705
|
+
platform: "node",
|
|
706
|
+
packages: "external",
|
|
707
|
+
outdir: "dist"
|
|
708
708
|
});
|
|
709
709
|
let { name, version } = packageJson;
|
|
710
710
|
name = name.replace(/^@/, "");
|
|
@@ -715,7 +715,7 @@ var publish = async (ctx, args) => {
|
|
|
715
715
|
});
|
|
716
716
|
if (!existingPackage) {
|
|
717
717
|
if (!packageJson.name.includes("/")) {
|
|
718
|
-
console.log(
|
|
718
|
+
console.log(kleur4.yellow(`Package name "${packageJson.name}" is not scoped. Scoped package names are recommended on the tscircuit registry.`));
|
|
719
719
|
const myAccount = await ctx.axios.get("/accounts/get").then((r) => r.data.account);
|
|
720
720
|
const newScopedName = `${myAccount.github_username}/${packageJson.name}`;
|
|
721
721
|
const { confirmNameChange } = await prompts({
|
|
@@ -725,7 +725,7 @@ var publish = async (ctx, args) => {
|
|
|
725
725
|
message: `Would you like to change the package name to the scoped name "@${newScopedName}"?`
|
|
726
726
|
});
|
|
727
727
|
if (confirm === undefined) {
|
|
728
|
-
console.log(
|
|
728
|
+
console.log(kleur4.red("Aborted."));
|
|
729
729
|
process.exit(1);
|
|
730
730
|
}
|
|
731
731
|
if (confirmNameChange) {
|
|
@@ -734,7 +734,7 @@ var publish = async (ctx, args) => {
|
|
|
734
734
|
name = newScopedName;
|
|
735
735
|
}
|
|
736
736
|
}
|
|
737
|
-
console.log(
|
|
737
|
+
console.log(kleur4.green(`Creating package "${packageJson.name}" on tscircuit registry...`));
|
|
738
738
|
let description = packageJson.description;
|
|
739
739
|
if (!description) {
|
|
740
740
|
description = (await prompts({
|
|
@@ -753,14 +753,14 @@ var publish = async (ctx, args) => {
|
|
|
753
753
|
throw e;
|
|
754
754
|
});
|
|
755
755
|
if (existingRelease) {
|
|
756
|
-
console.log(
|
|
756
|
+
console.log(kleur4.gray(`Package release already exists: ${name}@${version}`));
|
|
757
757
|
if (shouldIncrement) {
|
|
758
|
-
console.log(
|
|
758
|
+
console.log(kleur4.green(`Incrementing version from ${version} to ${semver.inc(version, "patch")}...`));
|
|
759
759
|
version = semver.inc(version, "patch");
|
|
760
760
|
packageJson.version = version;
|
|
761
761
|
await fs5.writeFile(Path2.join(ctx.cwd, "package.json"), JSON.stringify(packageJson, null, 2));
|
|
762
762
|
} else {
|
|
763
|
-
console.log(
|
|
763
|
+
console.log(kleur4.blue(`Want to increment the version and publish a new release? Use "--increment"!`));
|
|
764
764
|
throw new Error("Package release already exists");
|
|
765
765
|
}
|
|
766
766
|
}
|
|
@@ -770,7 +770,7 @@ var publish = async (ctx, args) => {
|
|
|
770
770
|
}).then((r) => r.data.package_release);
|
|
771
771
|
const filePaths = await getAllPackageFiles(ctx);
|
|
772
772
|
if (!filePaths.includes("README.md")) {
|
|
773
|
-
console.log(
|
|
773
|
+
console.log(kleur4.yellow("No README.md found in package files. A README.md is recommended on the tscircuit registry."));
|
|
774
774
|
const { confirmReadme } = await prompts({
|
|
775
775
|
type: "confirm",
|
|
776
776
|
name: "confirmReadme",
|
|
@@ -778,7 +778,7 @@ var publish = async (ctx, args) => {
|
|
|
778
778
|
message: "Would you like to add a README.md?"
|
|
779
779
|
});
|
|
780
780
|
if (confirmReadme === undefined) {
|
|
781
|
-
console.log(
|
|
781
|
+
console.log(kleur4.red("Aborted."));
|
|
782
782
|
process.exit(1);
|
|
783
783
|
}
|
|
784
784
|
if (confirmReadme) {
|
|
@@ -803,7 +803,7 @@ var publish = async (ctx, args) => {
|
|
|
803
803
|
exportName
|
|
804
804
|
}).catch((e) => e);
|
|
805
805
|
if (tscircuit_soup instanceof Error) {
|
|
806
|
-
console.log(
|
|
806
|
+
console.log(kleur4.red(`Error soupifying ${filePath}: ${tscircuit_soup}, skipping`));
|
|
807
807
|
continue;
|
|
808
808
|
}
|
|
809
809
|
await ctx.axios.post("/package_examples/create", {
|
|
@@ -818,7 +818,7 @@ var publish = async (ctx, args) => {
|
|
|
818
818
|
await fs5.mkdir(Path2.dirname(tmpTarballPath), { recursive: true });
|
|
819
819
|
const npm_pack_outputs = await $2`cd ${ctx.cwd} && npm pack --json --pack-destination ${Path2.dirname(tmpTarballPath)}`.json();
|
|
820
820
|
if (!await fs5.exists(tmpTarballPath)) {
|
|
821
|
-
console.log(
|
|
821
|
+
console.log(kleur4.red(`Couldn't find tarball at ${tmpTarballPath}`));
|
|
822
822
|
process.exit(1);
|
|
823
823
|
}
|
|
824
824
|
await ctx.axios.post("/package_files/create", {
|
|
@@ -834,17 +834,17 @@ var publish = async (ctx, args) => {
|
|
|
834
834
|
is_locked: params.lock ? true : false,
|
|
835
835
|
is_latest: true
|
|
836
836
|
});
|
|
837
|
-
console.log(
|
|
837
|
+
console.log(kleur4.green(`Published ${name}@${version}!\nhttps://registry.tscircuit.com/${name}`));
|
|
838
838
|
};
|
|
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
|
|
@@ -857,7 +857,7 @@ var soupifyCmd = async (ctx, args) => {
|
|
|
857
857
|
};
|
|
858
858
|
// lib/cmd-fns/dev/index.ts
|
|
859
859
|
import {z as z18} from "zod";
|
|
860
|
-
import
|
|
860
|
+
import kleur11 from "kleur";
|
|
861
861
|
import prompts2 from "prompts";
|
|
862
862
|
import open from "open";
|
|
863
863
|
|
|
@@ -868,7 +868,7 @@ import {createWithEdgeSpec} from "edgespec";
|
|
|
868
868
|
import {Kysely, sql, SqliteDialect} from "kysely";
|
|
869
869
|
import {mkdirSync} from "fs";
|
|
870
870
|
import * as Path3 from "path";
|
|
871
|
-
import
|
|
871
|
+
import kleur5 from "kleur";
|
|
872
872
|
import"edgespec/middleware";
|
|
873
873
|
import {z as z16} from "zod";
|
|
874
874
|
import {NotFoundError as NotFoundError2} from "edgespec/middleware";
|
|
@@ -934,7 +934,7 @@ var withErrorResponse = async (req, ctx, next) => {
|
|
|
934
934
|
try {
|
|
935
935
|
return await next(req, ctx);
|
|
936
936
|
} catch (error) {
|
|
937
|
-
console.error(
|
|
937
|
+
console.error(kleur5.red("Intercepted error:"), error);
|
|
938
938
|
if (error instanceof Response) {
|
|
939
939
|
return error;
|
|
940
940
|
}
|
|
@@ -1146,15 +1146,15 @@ var startDevServer = async ({
|
|
|
1146
1146
|
};
|
|
1147
1147
|
|
|
1148
1148
|
// lib/cmd-fns/dev/get-dev-server-axios.ts
|
|
1149
|
-
import
|
|
1149
|
+
import kleur6 from "kleur";
|
|
1150
1150
|
import defaultAxios from "axios";
|
|
1151
1151
|
var getDevServerAxios = ({ serverUrl }) => {
|
|
1152
1152
|
const devServerAxios = defaultAxios.create({
|
|
1153
1153
|
baseURL: serverUrl
|
|
1154
1154
|
});
|
|
1155
1155
|
devServerAxios.interceptors.response.use((res) => res, (err) => {
|
|
1156
|
-
console.log(
|
|
1157
|
-
console.log(
|
|
1156
|
+
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
|
+
console.log(kleur6.yellow("[Request Body]:"), err.config.data);
|
|
1158
1158
|
return Promise.reject(err);
|
|
1159
1159
|
});
|
|
1160
1160
|
return devServerAxios;
|
|
@@ -1165,7 +1165,7 @@ import {join as joinPath2} from "path";
|
|
|
1165
1165
|
import {readdirSync as readdirSync2} from "fs";
|
|
1166
1166
|
|
|
1167
1167
|
// lib/cmd-fns/dev/soupify-and-upload-example-file.ts
|
|
1168
|
-
import
|
|
1168
|
+
import kleur7 from "kleur";
|
|
1169
1169
|
import {join as joinPath} from "path";
|
|
1170
1170
|
import {readFileSync as readFileSync2} from "fs";
|
|
1171
1171
|
var soupifyAndUploadExampleFile = async ({
|
|
@@ -1177,20 +1177,20 @@ var soupifyAndUploadExampleFile = async ({
|
|
|
1177
1177
|
const examplePath = joinPath(examplesDir, exampleFileName);
|
|
1178
1178
|
const exampleContent = readFileSync2(examplePath).toString();
|
|
1179
1179
|
const exportName = inferExportNameFromSource(exampleContent);
|
|
1180
|
-
console.log(
|
|
1180
|
+
console.log(kleur7.gray(`[soupifying] ${exampleFileName}...`));
|
|
1181
1181
|
const soup = await soupify({
|
|
1182
1182
|
filePath: examplePath,
|
|
1183
1183
|
exportName
|
|
1184
1184
|
});
|
|
1185
|
-
console.log(
|
|
1185
|
+
console.log(kleur7.gray(`[uploading ] ${exampleFileName}...`));
|
|
1186
1186
|
await devServerAxios.post("/api/dev_package_examples/create", {
|
|
1187
1187
|
tscircuit_soup: soup,
|
|
1188
1188
|
file_path: examplePath,
|
|
1189
1189
|
export_name: exportName
|
|
1190
1190
|
});
|
|
1191
|
-
console.log(
|
|
1191
|
+
console.log(kleur7.gray(`[ done ] ${exampleFileName}!`));
|
|
1192
1192
|
} catch (e) {
|
|
1193
|
-
console.log(
|
|
1193
|
+
console.log(kleur7.red(e.toString()));
|
|
1194
1194
|
}
|
|
1195
1195
|
};
|
|
1196
1196
|
|
|
@@ -1220,7 +1220,7 @@ import * as Path7 from "path";
|
|
|
1220
1220
|
|
|
1221
1221
|
// lib/cmd-fns/dev/start-watcher.ts
|
|
1222
1222
|
import chokidar from "chokidar";
|
|
1223
|
-
import
|
|
1223
|
+
import kleur8 from "kleur";
|
|
1224
1224
|
var startWatcher = async ({
|
|
1225
1225
|
cwd,
|
|
1226
1226
|
devServerAxios
|
|
@@ -1240,7 +1240,7 @@ var startWatcher = async ({
|
|
|
1240
1240
|
async function uploadInBackground() {
|
|
1241
1241
|
while (upload_queue_state.should_run) {
|
|
1242
1242
|
if (upload_queue_state.dirty) {
|
|
1243
|
-
console.log(
|
|
1243
|
+
console.log(kleur8.yellow("Changes detected, re-uploading examples..."));
|
|
1244
1244
|
upload_queue_state.dirty = false;
|
|
1245
1245
|
await uploadExamplesFromDirectory({ cwd, devServerAxios });
|
|
1246
1246
|
}
|
|
@@ -1259,7 +1259,7 @@ var startWatcher = async ({
|
|
|
1259
1259
|
|
|
1260
1260
|
// lib/cmd-fns/init/create-or-modify-npmrc.ts
|
|
1261
1261
|
import {existsSync, writeFileSync as writeFileSync3} from "fs";
|
|
1262
|
-
import
|
|
1262
|
+
import kleur9 from "kleur";
|
|
1263
1263
|
import * as Path4 from "path";
|
|
1264
1264
|
|
|
1265
1265
|
// lib/cmd-fns/init/get-generated-npmrc.ts
|
|
@@ -1274,7 +1274,7 @@ var createOrModifyNpmrc = async ({ quiet = true }, ctx) => {
|
|
|
1274
1274
|
const npmrcPath = Path4.join(ctx.cwd, ".npmrc");
|
|
1275
1275
|
if (existsSync(npmrcPath)) {
|
|
1276
1276
|
if (!quiet) {
|
|
1277
|
-
console.log(
|
|
1277
|
+
console.log(kleur9.yellow("npmrc already exists, not doing anything"));
|
|
1278
1278
|
}
|
|
1279
1279
|
} else {
|
|
1280
1280
|
writeFileSync3(npmrcPath, getGeneratedNpmrc(ctx));
|
|
@@ -1282,18 +1282,18 @@ var createOrModifyNpmrc = async ({ quiet = true }, ctx) => {
|
|
|
1282
1282
|
};
|
|
1283
1283
|
|
|
1284
1284
|
// lib/cmd-fns/dev/check-if-initialized.ts
|
|
1285
|
-
import
|
|
1285
|
+
import kleur10 from "kleur";
|
|
1286
1286
|
import * as Path5 from "path";
|
|
1287
1287
|
import {existsSync as existsSync2, readFileSync as readFileSync4} from "fs";
|
|
1288
1288
|
var checkIfInitialized = async (ctx) => {
|
|
1289
1289
|
const packageJsonPath = Path5.join(ctx.cwd, "package.json");
|
|
1290
1290
|
if (!existsSync2(packageJsonPath)) {
|
|
1291
|
-
console.error(
|
|
1291
|
+
console.error(kleur10.red(`No package.json found`));
|
|
1292
1292
|
return false;
|
|
1293
1293
|
}
|
|
1294
1294
|
const packageJsonRaw = readFileSync4(packageJsonPath, "utf-8");
|
|
1295
1295
|
if (!packageJsonRaw.includes("tscircuit")) {
|
|
1296
|
-
console.error(
|
|
1296
|
+
console.error(kleur10.red(`No tscircuit dependencies are installed in this project.`));
|
|
1297
1297
|
return false;
|
|
1298
1298
|
}
|
|
1299
1299
|
return true;
|
|
@@ -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) {
|
|
@@ -1456,7 +1456,7 @@ var devCmd = async (ctx, args) => {
|
|
|
1456
1456
|
await createOrModifyNpmrc({ quiet: false }, ctx);
|
|
1457
1457
|
unlink3(Path7.join(cwd, ".tscircuit/dev-server.db")).catch(() => {
|
|
1458
1458
|
});
|
|
1459
|
-
console.log(
|
|
1459
|
+
console.log(kleur11.green(`\n--------------------------------------------\n\nStarting dev server http://localhost:${port}\n\n--------------------------------------------\n\n`));
|
|
1460
1460
|
const serverUrl = `http://localhost:${port}`;
|
|
1461
1461
|
const devServerAxios = getDevServerAxios({ serverUrl });
|
|
1462
1462
|
const server = await startDevServer({ port, devServerAxios });
|
|
@@ -1492,68 +1492,68 @@ var devCmd = async (ctx, args) => {
|
|
|
1492
1492
|
}
|
|
1493
1493
|
};
|
|
1494
1494
|
// lib/cmd-fns/add.ts
|
|
1495
|
-
import
|
|
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);
|
|
1506
1506
|
const flagsString = params.flags.dev ? "--dev" : "";
|
|
1507
1507
|
const cmd = `npm add ${flagsString} ${params.packages.map((p) => `@tsci/${p.replace(/\//, ".")}`).join(" ")}`;
|
|
1508
|
-
console.log(
|
|
1508
|
+
console.log(kleur12.gray(`> ${cmd}`));
|
|
1509
1509
|
await $4`npm add ${flagsString} ${params.packages.map((p) => `@tsci/${p.replace(/\//, ".")}`).join(" ")}`;
|
|
1510
1510
|
};
|
|
1511
1511
|
// lib/cmd-fns/remove.ts
|
|
1512
|
-
import
|
|
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);
|
|
1523
1523
|
const flagsString = "";
|
|
1524
1524
|
const cmd = `npm remove ${flagsString} ${params.packages.map((p) => `@tsci/${p.replace(/\//, ".")}`).join(" ")}`;
|
|
1525
|
-
console.log(
|
|
1525
|
+
console.log(kleur13.gray(`> ${cmd}`));
|
|
1526
1526
|
await $5`npm remove ${flagsString} ${params.packages.map((p) => `@tsci/${p.replace(/\//, ".")}`).join(" ")}`;
|
|
1527
1527
|
};
|
|
1528
1528
|
// lib/cmd-fns/install.ts
|
|
1529
|
-
import
|
|
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);
|
|
1540
1540
|
const flagsString = params.flags.dev ? "--dev" : "";
|
|
1541
1541
|
const cmd = `npm install ${flagsString} ${params.packages.map((p) => `@tsci/${p.replace(/\//, ".")}`).join(" ")}`;
|
|
1542
|
-
console.log(
|
|
1542
|
+
console.log(kleur14.gray(`> ${cmd}`));
|
|
1543
1543
|
await $6`npm install ${flagsString} ${params.packages.map((p) => `@tsci/${p.replace(/\//, ".")}`).join(" ")}`;
|
|
1544
1544
|
};
|
|
1545
1545
|
// lib/cmd-fns/uninstall.ts
|
|
1546
|
-
import
|
|
1546
|
+
import kleur15 from "kleur";
|
|
1547
1547
|
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...`);
|
|
@@ -1562,60 +1562,77 @@ var devServerUpload = async (ctx, args) => {
|
|
|
1562
1562
|
const watcher = await startWatcher({ cwd: params.dir, devServerAxios });
|
|
1563
1563
|
}
|
|
1564
1564
|
};
|
|
1565
|
+
// lib/cmd-fns/open.ts
|
|
1566
|
+
import {existsSync as existsSync4, readFileSync as readFileSync6} from "fs";
|
|
1567
|
+
import kleur16 from "kleur";
|
|
1568
|
+
import * as Path8 from "path";
|
|
1569
|
+
import open2 from "open";
|
|
1570
|
+
var openCmd = async (ctx, args2) => {
|
|
1571
|
+
const packageJsonPath = Path8.join(ctx.cwd, "package.json");
|
|
1572
|
+
if (!existsSync4(packageJsonPath)) {
|
|
1573
|
+
console.log(kleur16.red("No package.json found in current directory"));
|
|
1574
|
+
process.exit(1);
|
|
1575
|
+
}
|
|
1576
|
+
const packageJson = JSON.parse(readFileSync6(packageJsonPath, "utf-8"));
|
|
1577
|
+
const registryUrl = `${ctx.registry_url}/${packageJson.name.replace("@", "")}`;
|
|
1578
|
+
console.log(`Opening ${registryUrl} in your browser...`);
|
|
1579
|
+
await open2(registryUrl);
|
|
1580
|
+
};
|
|
1565
1581
|
// lib/get-program.ts
|
|
1566
1582
|
var getProgram = (ctx) => {
|
|
1567
1583
|
const cmd = new Command("tsci");
|
|
1568
1584
|
cmd.version(package_default.version);
|
|
1569
1585
|
const authCmd = cmd.command("auth");
|
|
1570
|
-
authCmd.command("login").action((
|
|
1571
|
-
authCmd.command("logout").action((
|
|
1586
|
+
authCmd.command("login").action((args2) => authLogin(ctx, args2));
|
|
1587
|
+
authCmd.command("logout").action((args2) => authLogout(ctx, args2));
|
|
1572
1588
|
const configCmd = cmd.command("config");
|
|
1573
|
-
configCmd.command("reveal-location").action((
|
|
1574
|
-
configCmd.command("set-registry").requiredOption("--server <server>", "Registry URL").action((
|
|
1575
|
-
configCmd.command("set-session").requiredOption("--session-token <session_token>", "Session Token").action((
|
|
1576
|
-
configCmd.command("set-log-requests").requiredOption("--log-requests", "Should log requests to registry").action((
|
|
1577
|
-
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));
|
|
1578
1594
|
const authSessionsCmd = authCmd.command("sessions");
|
|
1579
|
-
authSessionsCmd.command("create").action((
|
|
1580
|
-
authSessionsCmd.command("list").action((
|
|
1581
|
-
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));
|
|
1582
1598
|
const packagesCmd = cmd.command("packages");
|
|
1583
|
-
packagesCmd.command("list").action((
|
|
1584
|
-
packagesCmd.command("get").option("--package-id <package_id>", "Package Id").option("--name <name>", "Package name").action((
|
|
1585
|
-
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));
|
|
1586
1602
|
const packageReleases = cmd.command("package_releases");
|
|
1587
|
-
packageReleases.command("list").requiredOption("--package-name <package_name>", "Package name").option("--verbose", "Verbose objects (includes uuids)").action((
|
|
1588
|
-
packageReleases.command("get").action((
|
|
1589
|
-
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));
|
|
1590
1606
|
const packageFiles = cmd.command("package_files");
|
|
1591
|
-
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((
|
|
1592
|
-
packageFiles.command("get").action((
|
|
1593
|
-
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((
|
|
1594
|
-
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((
|
|
1595
|
-
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));
|
|
1596
1612
|
const packageExamples = cmd.command("package_examples");
|
|
1597
|
-
packageExamples.command("list").requiredOption("--package-name-with-version <package_name_with_version>").action((
|
|
1598
|
-
packageExamples.command("get").requiredOption("--package-example-id <package_example_id>").action((
|
|
1599
|
-
packageExamples.command("create").requiredOption("--package-name-with-version <package_name_with_version>").requiredOption("--file <file>").option("--export <export>", "Name of export to soupify").action((
|
|
1600
|
-
cmd.command("publish").option("--increment", "Increase patch version").option("--patch", "Increase patch version").option("--lock", "Lock the release after publishing to prevent changes").action((
|
|
1601
|
-
cmd.command("version").action(() =>
|
|
1602
|
-
cmd.command("login").action((
|
|
1603
|
-
cmd.command("logout").action((
|
|
1604
|
-
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((
|
|
1605
|
-
cmd.command("dev").option("--cwd <cwd>", "Current working directory").option("--port <port>", "Port to run dev server on").action((
|
|
1606
|
-
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));
|
|
1607
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 }));
|
|
1608
1624
|
cmd.command("remove").argument("<packages...>", "Packages to remove").action((packages, flags) => removeCmd(ctx, { packages, flags }));
|
|
1609
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 }));
|
|
1610
1626
|
cmd.command("uninstall").argument("<packages...>", "Packages to uninstall").action((packages, flags) => installCmd(ctx, { packages, flags }));
|
|
1611
1627
|
const devServerCmd = cmd.command("dev-server");
|
|
1612
|
-
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((
|
|
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));
|
|
1613
1630
|
return cmd;
|
|
1614
1631
|
};
|
|
1615
1632
|
|
|
1616
1633
|
// lib/util/create-context-and-run-program.ts
|
|
1617
1634
|
import defaultAxios2 from "axios";
|
|
1618
|
-
import
|
|
1635
|
+
import kleur17 from "kleur";
|
|
1619
1636
|
|
|
1620
1637
|
// lib/param-handlers/interact-for-local-directory.ts
|
|
1621
1638
|
import * as fs6 from "fs/promises";
|
|
@@ -1744,12 +1761,12 @@ var interactForPackageNameWithVersion = async ({
|
|
|
1744
1761
|
]
|
|
1745
1762
|
});
|
|
1746
1763
|
if (selectedPackage.endsWith("@...")) {
|
|
1747
|
-
const { version } = await prompts3({
|
|
1764
|
+
const { version: version2 } = await prompts3({
|
|
1748
1765
|
type: "text",
|
|
1749
1766
|
name: "version",
|
|
1750
1767
|
message: "Enter the version"
|
|
1751
1768
|
});
|
|
1752
|
-
return selectedPackage.replace("@...", `@${
|
|
1769
|
+
return selectedPackage.replace("@...", `@${version2}`);
|
|
1753
1770
|
}
|
|
1754
1771
|
if (selectedPackage === "Enter Manually") {
|
|
1755
1772
|
const { packageName } = await prompts3({
|
|
@@ -1835,21 +1852,40 @@ var PARAM_HANDLERS_BY_PARAM_NAME = {
|
|
|
1835
1852
|
package_example_id: interactForPackageExampleId
|
|
1836
1853
|
};
|
|
1837
1854
|
|
|
1838
|
-
// lib/
|
|
1839
|
-
|
|
1840
|
-
|
|
1855
|
+
// lib/create-config-manager.ts
|
|
1856
|
+
import Configstore from "configstore";
|
|
1857
|
+
var createConfigHandler = ({
|
|
1858
|
+
profile
|
|
1859
|
+
}) => {
|
|
1841
1860
|
const global_config = new Configstore("tsci");
|
|
1842
|
-
const current_profile =
|
|
1861
|
+
const current_profile = profile ?? global_config.get("current_profile") ?? "default";
|
|
1843
1862
|
const profile_config = {
|
|
1844
1863
|
get: (key) => global_config.get(`profiles.${current_profile}.${key}`),
|
|
1845
1864
|
set: (key, value) => global_config.set(`profiles.${current_profile}.${key}`, value)
|
|
1846
1865
|
};
|
|
1866
|
+
return { profile_config, global_config, current_profile };
|
|
1867
|
+
};
|
|
1868
|
+
|
|
1869
|
+
// lib/util/create-context-and-run-program.ts
|
|
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
|
|
1878
|
+
var createContextAndRunProgram = async (process_args) => {
|
|
1879
|
+
const args2 = minimist(process_args);
|
|
1880
|
+
const { global_config, profile_config, current_profile } = createConfigHandler({
|
|
1881
|
+
profile: args2.profile
|
|
1882
|
+
});
|
|
1847
1883
|
const registry_url = profile_config.get("registry_url") ?? "https://registry-api.tscircuit.com";
|
|
1848
|
-
|
|
1849
|
-
for (const key in
|
|
1884
|
+
args2._ = args2._.map((p) => p.toLowerCase().replace(/-/g, "_"));
|
|
1885
|
+
for (const key in args2) {
|
|
1850
1886
|
if (key.includes("-")) {
|
|
1851
|
-
|
|
1852
|
-
delete
|
|
1887
|
+
args2[key.replace(/-/g, "_")] = args2[key];
|
|
1888
|
+
delete args2[key];
|
|
1853
1889
|
}
|
|
1854
1890
|
}
|
|
1855
1891
|
const axios = defaultAxios2.create({
|
|
@@ -1861,35 +1897,45 @@ var createContextAndRunProgram = async (process_args) => {
|
|
|
1861
1897
|
if (global_config.get("log_requests")) {
|
|
1862
1898
|
console.log(`Using registry_url: ${registry_url}`);
|
|
1863
1899
|
axios.interceptors.request.use((req) => {
|
|
1864
|
-
console.log(
|
|
1900
|
+
console.log(kleur17.grey(`[REQ] ${req.method?.toUpperCase()} ${req.url}`));
|
|
1865
1901
|
return req;
|
|
1866
1902
|
});
|
|
1867
1903
|
axios.interceptors.response.use((res) => {
|
|
1868
|
-
console.log(
|
|
1904
|
+
console.log(kleur17.grey(`[RES] ${res.status} ${res.config.method?.toUpperCase()} ${res.config.url}`));
|
|
1869
1905
|
return res;
|
|
1870
1906
|
});
|
|
1871
1907
|
}
|
|
1872
1908
|
axios.interceptors.response.use((res) => res, (err) => {
|
|
1873
|
-
|
|
1874
|
-
|
|
1909
|
+
if (err.config.data?.error?.error_code === "package_not_found" || err.config.data?.error?.error_code === "package_release_not_found") {
|
|
1910
|
+
return Promise.reject(err);
|
|
1911
|
+
}
|
|
1912
|
+
console.log(kleur17.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, '"')));
|
|
1913
|
+
console.log(kleur17.yellow("[Request Body]:"), err.config.data);
|
|
1875
1914
|
return Promise.reject(err);
|
|
1876
1915
|
});
|
|
1877
1916
|
const ctx = {
|
|
1878
|
-
cmd:
|
|
1879
|
-
cwd:
|
|
1880
|
-
|
|
1917
|
+
cmd: args2._,
|
|
1918
|
+
cwd: args2.cwd ?? process.cwd(),
|
|
1919
|
+
current_profile,
|
|
1881
1920
|
registry_url,
|
|
1882
1921
|
axios,
|
|
1883
1922
|
global_config,
|
|
1884
1923
|
profile_config,
|
|
1885
1924
|
args: {
|
|
1886
|
-
cmd:
|
|
1887
|
-
yes:
|
|
1925
|
+
cmd: args2._,
|
|
1926
|
+
yes: args2.y ?? args2.yes,
|
|
1888
1927
|
help: undefined
|
|
1889
1928
|
},
|
|
1890
|
-
params:
|
|
1929
|
+
params: args2
|
|
1891
1930
|
};
|
|
1892
|
-
|
|
1931
|
+
delete args2["cwd"];
|
|
1932
|
+
const { _: positional, ...flagsAndParams } = args2;
|
|
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
|
+
}
|
|
1938
|
+
await perfectCli(getProgram(ctx), args_without_globals, {
|
|
1893
1939
|
async customParamHandler({ commandPath, optionName }, { prompts: prompts3 }) {
|
|
1894
1940
|
const optionNameHandler = PARAM_HANDLERS_BY_PARAM_NAME[_.snakeCase(optionName)];
|
|
1895
1941
|
if (optionNameHandler) {
|