@tscircuit/cli 0.1.698 → 0.1.699

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.
Files changed (2) hide show
  1. package/dist/main.js +73 -83
  2. package/package.json +1 -1
package/dist/main.js CHANGED
@@ -74113,7 +74113,7 @@ var getGlobalDepsInstallCommand = (packageManager, deps) => {
74113
74113
  import { execSync as execSync2 } from "node:child_process";
74114
74114
  var import_semver2 = __toESM2(require_semver2(), 1);
74115
74115
  // package.json
74116
- var version = "0.1.697";
74116
+ var version = "0.1.698";
74117
74117
  var package_default = {
74118
74118
  name: "@tscircuit/cli",
74119
74119
  version,
@@ -74303,6 +74303,76 @@ var updateTsci = async () => {
74303
74303
  return true;
74304
74304
  };
74305
74305
 
74306
+ // lib/registry-api/get-ky.ts
74307
+ class PrettyHttpError extends Error {
74308
+ request;
74309
+ response;
74310
+ constructor(message, request, response) {
74311
+ super(message);
74312
+ this.request = request;
74313
+ this.response = response;
74314
+ }
74315
+ get status() {
74316
+ return this.response.status;
74317
+ }
74318
+ get url() {
74319
+ return this.response.url;
74320
+ }
74321
+ get method() {
74322
+ return this.request.method;
74323
+ }
74324
+ get pathname() {
74325
+ return new URL(this.response.url).pathname;
74326
+ }
74327
+ }
74328
+ var prettyResponseErrorHook = async (request, _options, response) => {
74329
+ if (!response.ok) {
74330
+ const errorData = await response.json();
74331
+ let requestBody = "";
74332
+ try {
74333
+ requestBody = await request.clone().text();
74334
+ } catch {}
74335
+ const apiError = errorData?.error;
74336
+ const errorString = apiError ? `
74337
+ ${apiError.error_code}: ${apiError.message}` : "";
74338
+ throw new PrettyHttpError(`FAIL [${response.status}]: ${request.method} ${new URL(request.url).pathname}${errorString}${requestBody ? `
74339
+
74340
+ Request Body:
74341
+ ${requestBody}` : ""}
74342
+
74343
+ ${JSON.stringify(errorData, null, 2)}`, request, response);
74344
+ }
74345
+ };
74346
+ var getRegistryApiKy = ({
74347
+ sessionToken
74348
+ } = {}) => {
74349
+ return distribution_default.create({
74350
+ prefixUrl: getRegistryApiUrl(),
74351
+ headers: {
74352
+ ...sessionToken ? { Authorization: `Bearer ${sessionToken}` } : {}
74353
+ },
74354
+ hooks: {
74355
+ afterResponse: [prettyResponseErrorHook]
74356
+ }
74357
+ });
74358
+ };
74359
+
74360
+ // lib/registry-api/fetch-account.ts
74361
+ var fetchAccount = async () => {
74362
+ const sessionToken = getSessionToken();
74363
+ if (!sessionToken)
74364
+ return null;
74365
+ try {
74366
+ const ky2 = getRegistryApiKy({ sessionToken });
74367
+ const { account } = await ky2.post("accounts/get", {
74368
+ json: { account_id: cliConfig.get("accountId") }
74369
+ }).json();
74370
+ return account;
74371
+ } catch {
74372
+ return null;
74373
+ }
74374
+ };
74375
+
74306
74376
  // cli/init/register.ts
74307
74377
  var registerInit = (program3) => {
74308
74378
  program3.command("init").description("Initialize a new TSCircuit project in the specified directory (or current directory if none is provided)").argument("[directory]", "Directory name (optional, defaults to current directory)").option("-y, --yes", "Use defaults and skip prompts").option("--no-install", "Skip installing dependencies").action(async (directory, options) => {
@@ -74349,18 +74419,8 @@ var registerInit = (program3) => {
74349
74419
  message: "Package name",
74350
74420
  initial: defaultPackageName
74351
74421
  });
74352
- let authorName = cliConfig.get("githubUsername");
74353
- if (!authorName) {
74354
- const token2 = getSessionToken();
74355
- if (token2) {
74356
- try {
74357
- const decoded = jwtDecode(token2);
74358
- if (decoded.github_username) {
74359
- authorName = decoded.github_username;
74360
- }
74361
- } catch {}
74362
- }
74363
- }
74422
+ const account = await fetchAccount();
74423
+ let authorName = account?.tscircuit_handle;
74364
74424
  fs7.mkdirSync(projectDir, { recursive: true });
74365
74425
  writeFileIfNotExists(path10.join(projectDir, "index.tsx"), `
74366
74426
  export default () => (
@@ -77636,60 +77696,6 @@ function watch(paths, options = {}) {
77636
77696
  return watcher;
77637
77697
  }
77638
77698
 
77639
- // lib/registry-api/get-ky.ts
77640
- class PrettyHttpError extends Error {
77641
- request;
77642
- response;
77643
- constructor(message, request, response) {
77644
- super(message);
77645
- this.request = request;
77646
- this.response = response;
77647
- }
77648
- get status() {
77649
- return this.response.status;
77650
- }
77651
- get url() {
77652
- return this.response.url;
77653
- }
77654
- get method() {
77655
- return this.request.method;
77656
- }
77657
- get pathname() {
77658
- return new URL(this.response.url).pathname;
77659
- }
77660
- }
77661
- var prettyResponseErrorHook = async (request, _options, response) => {
77662
- if (!response.ok) {
77663
- const errorData = await response.json();
77664
- let requestBody = "";
77665
- try {
77666
- requestBody = await request.clone().text();
77667
- } catch {}
77668
- const apiError = errorData?.error;
77669
- const errorString = apiError ? `
77670
- ${apiError.error_code}: ${apiError.message}` : "";
77671
- throw new PrettyHttpError(`FAIL [${response.status}]: ${request.method} ${new URL(request.url).pathname}${errorString}${requestBody ? `
77672
-
77673
- Request Body:
77674
- ${requestBody}` : ""}
77675
-
77676
- ${JSON.stringify(errorData, null, 2)}`, request, response);
77677
- }
77678
- };
77679
- var getRegistryApiKy = ({
77680
- sessionToken
77681
- } = {}) => {
77682
- return distribution_default.create({
77683
- prefixUrl: getRegistryApiUrl(),
77684
- headers: {
77685
- ...sessionToken ? { Authorization: `Bearer ${sessionToken}` } : {}
77686
- },
77687
- hooks: {
77688
- afterResponse: [prettyResponseErrorHook]
77689
- }
77690
- });
77691
- };
77692
-
77693
77699
  // lib/shared/push-snippet.ts
77694
77700
  var import_semver3 = __toESM2(require_semver2(), 1);
77695
77701
  import * as fs13 from "node:fs";
@@ -79827,22 +79833,6 @@ function createDelay({ clearTimeout: defaultClear, setTimeout: defaultSet } = {}
79827
79833
  var delay2 = createDelay();
79828
79834
  var delay_default = delay2;
79829
79835
 
79830
- // lib/registry-api/fetch-account.ts
79831
- var fetchAccount = async () => {
79832
- const sessionToken = getSessionToken();
79833
- if (!sessionToken)
79834
- return null;
79835
- try {
79836
- const ky2 = getRegistryApiKy({ sessionToken });
79837
- const { account } = await ky2.post("accounts/get", {
79838
- json: { account_id: cliConfig.get("accountId") }
79839
- }).json();
79840
- return account;
79841
- } catch {
79842
- return null;
79843
- }
79844
- };
79845
-
79846
79836
  // cli/auth/setup-npmrc/setup-npmrc.ts
79847
79837
  import * as fs21 from "node:fs";
79848
79838
  import * as path23 from "node:path";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tscircuit/cli",
3
- "version": "0.1.698",
3
+ "version": "0.1.699",
4
4
  "main": "dist/main.js",
5
5
  "devDependencies": {
6
6
  "@babel/standalone": "^7.26.9",