@tscircuit/cli 0.1.698 → 0.1.700
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/main.js +87 -88
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -73219,17 +73219,15 @@ var getSessionToken = () => {
|
|
|
73219
73219
|
var setSessionToken = (token) => {
|
|
73220
73220
|
cliConfig.set("sessionToken", token);
|
|
73221
73221
|
const decoded = jwtDecode(token);
|
|
73222
|
-
|
|
73222
|
+
if (decoded.tscircuit_handle)
|
|
73223
|
+
cliConfig.set("tscircuitHandle", decoded.tscircuit_handle);
|
|
73223
73224
|
if (decoded.account_id)
|
|
73224
73225
|
cliConfig.set("accountId", decoded.account_id);
|
|
73225
73226
|
if (decoded.session_id)
|
|
73226
73227
|
cliConfig.set("sessionId", decoded.session_id);
|
|
73227
73228
|
};
|
|
73228
73229
|
var clearSession = () => {
|
|
73229
|
-
cliConfig.
|
|
73230
|
-
cliConfig.delete("githubUsername");
|
|
73231
|
-
cliConfig.delete("accountId");
|
|
73232
|
-
cliConfig.delete("sessionId");
|
|
73230
|
+
cliConfig.clear();
|
|
73233
73231
|
};
|
|
73234
73232
|
var getRegistryApiUrl = () => {
|
|
73235
73233
|
return cliConfig.get("registryApiUrl") ?? "https://registry-api.tscircuit.com";
|
|
@@ -74113,7 +74111,7 @@ var getGlobalDepsInstallCommand = (packageManager, deps) => {
|
|
|
74113
74111
|
import { execSync as execSync2 } from "node:child_process";
|
|
74114
74112
|
var import_semver2 = __toESM2(require_semver2(), 1);
|
|
74115
74113
|
// package.json
|
|
74116
|
-
var version = "0.1.
|
|
74114
|
+
var version = "0.1.699";
|
|
74117
74115
|
var package_default = {
|
|
74118
74116
|
name: "@tscircuit/cli",
|
|
74119
74117
|
version,
|
|
@@ -74303,6 +74301,76 @@ var updateTsci = async () => {
|
|
|
74303
74301
|
return true;
|
|
74304
74302
|
};
|
|
74305
74303
|
|
|
74304
|
+
// lib/registry-api/get-ky.ts
|
|
74305
|
+
class PrettyHttpError extends Error {
|
|
74306
|
+
request;
|
|
74307
|
+
response;
|
|
74308
|
+
constructor(message, request, response) {
|
|
74309
|
+
super(message);
|
|
74310
|
+
this.request = request;
|
|
74311
|
+
this.response = response;
|
|
74312
|
+
}
|
|
74313
|
+
get status() {
|
|
74314
|
+
return this.response.status;
|
|
74315
|
+
}
|
|
74316
|
+
get url() {
|
|
74317
|
+
return this.response.url;
|
|
74318
|
+
}
|
|
74319
|
+
get method() {
|
|
74320
|
+
return this.request.method;
|
|
74321
|
+
}
|
|
74322
|
+
get pathname() {
|
|
74323
|
+
return new URL(this.response.url).pathname;
|
|
74324
|
+
}
|
|
74325
|
+
}
|
|
74326
|
+
var prettyResponseErrorHook = async (request, _options, response) => {
|
|
74327
|
+
if (!response.ok) {
|
|
74328
|
+
const errorData = await response.json();
|
|
74329
|
+
let requestBody = "";
|
|
74330
|
+
try {
|
|
74331
|
+
requestBody = await request.clone().text();
|
|
74332
|
+
} catch {}
|
|
74333
|
+
const apiError = errorData?.error;
|
|
74334
|
+
const errorString = apiError ? `
|
|
74335
|
+
${apiError.error_code}: ${apiError.message}` : "";
|
|
74336
|
+
throw new PrettyHttpError(`FAIL [${response.status}]: ${request.method} ${new URL(request.url).pathname}${errorString}${requestBody ? `
|
|
74337
|
+
|
|
74338
|
+
Request Body:
|
|
74339
|
+
${requestBody}` : ""}
|
|
74340
|
+
|
|
74341
|
+
${JSON.stringify(errorData, null, 2)}`, request, response);
|
|
74342
|
+
}
|
|
74343
|
+
};
|
|
74344
|
+
var getRegistryApiKy = ({
|
|
74345
|
+
sessionToken
|
|
74346
|
+
} = {}) => {
|
|
74347
|
+
return distribution_default.create({
|
|
74348
|
+
prefixUrl: getRegistryApiUrl(),
|
|
74349
|
+
headers: {
|
|
74350
|
+
...sessionToken ? { Authorization: `Bearer ${sessionToken}` } : {}
|
|
74351
|
+
},
|
|
74352
|
+
hooks: {
|
|
74353
|
+
afterResponse: [prettyResponseErrorHook]
|
|
74354
|
+
}
|
|
74355
|
+
});
|
|
74356
|
+
};
|
|
74357
|
+
|
|
74358
|
+
// lib/registry-api/fetch-account.ts
|
|
74359
|
+
var fetchAccount = async () => {
|
|
74360
|
+
const sessionToken = getSessionToken();
|
|
74361
|
+
if (!sessionToken)
|
|
74362
|
+
return null;
|
|
74363
|
+
try {
|
|
74364
|
+
const ky2 = getRegistryApiKy({ sessionToken });
|
|
74365
|
+
const { account } = await ky2.post("accounts/get", {
|
|
74366
|
+
json: { account_id: cliConfig.get("accountId") }
|
|
74367
|
+
}).json();
|
|
74368
|
+
return account;
|
|
74369
|
+
} catch {
|
|
74370
|
+
return null;
|
|
74371
|
+
}
|
|
74372
|
+
};
|
|
74373
|
+
|
|
74306
74374
|
// cli/init/register.ts
|
|
74307
74375
|
var registerInit = (program3) => {
|
|
74308
74376
|
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,16 +74417,11 @@ var registerInit = (program3) => {
|
|
|
74349
74417
|
message: "Package name",
|
|
74350
74418
|
initial: defaultPackageName
|
|
74351
74419
|
});
|
|
74352
|
-
let authorName = cliConfig.get("
|
|
74420
|
+
let authorName = cliConfig.get("tscircuitHandle");
|
|
74353
74421
|
if (!authorName) {
|
|
74354
|
-
const
|
|
74355
|
-
if (
|
|
74356
|
-
|
|
74357
|
-
const decoded = jwtDecode(token2);
|
|
74358
|
-
if (decoded.github_username) {
|
|
74359
|
-
authorName = decoded.github_username;
|
|
74360
|
-
}
|
|
74361
|
-
} catch {}
|
|
74422
|
+
const account = await fetchAccount();
|
|
74423
|
+
if (account?.tscircuit_handle) {
|
|
74424
|
+
authorName = account.tscircuit_handle;
|
|
74362
74425
|
}
|
|
74363
74426
|
}
|
|
74364
74427
|
fs7.mkdirSync(projectDir, { recursive: true });
|
|
@@ -77636,60 +77699,6 @@ function watch(paths, options = {}) {
|
|
|
77636
77699
|
return watcher;
|
|
77637
77700
|
}
|
|
77638
77701
|
|
|
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
77702
|
// lib/shared/push-snippet.ts
|
|
77694
77703
|
var import_semver3 = __toESM2(require_semver2(), 1);
|
|
77695
77704
|
import * as fs13 from "node:fs";
|
|
@@ -78492,7 +78501,11 @@ var pushSnippet = async ({
|
|
|
78492
78501
|
return onExit(1);
|
|
78493
78502
|
}
|
|
78494
78503
|
const ky2 = getRegistryApiKy({ sessionToken });
|
|
78495
|
-
const currentUsername = cliConfig.get("
|
|
78504
|
+
const currentUsername = cliConfig.get("tscircuitHandle");
|
|
78505
|
+
if (!currentUsername) {
|
|
78506
|
+
onError("You need to set your tscircuit handle to publish packages");
|
|
78507
|
+
return onExit(1);
|
|
78508
|
+
}
|
|
78496
78509
|
let unscopedPackageName = getUnscopedPackageName(packageJson.name ?? "");
|
|
78497
78510
|
const packageJsonAuthor = getPackageAuthor(packageJson.name ?? "");
|
|
78498
78511
|
if (unscopedPackageName) {
|
|
@@ -78531,7 +78544,7 @@ var pushSnippet = async ({
|
|
|
78531
78544
|
const hasOrgAccess = await checkOrgAccess(ky2, packageJsonAuthor);
|
|
78532
78545
|
if (hasOrgAccess) {
|
|
78533
78546
|
accountName = packageJsonAuthor;
|
|
78534
|
-
console.log(kleur_default.gray(`Publishing to org "${packageJsonAuthor}" (user: ${
|
|
78547
|
+
console.log(kleur_default.gray(`Publishing to org "${packageJsonAuthor}" (user: ${accountName})`));
|
|
78535
78548
|
} else {
|
|
78536
78549
|
onError(`You don't have access to the org "${packageJsonAuthor}". Either:
|
|
78537
78550
|
` + ` 1. Get added as a member of the "${packageJsonAuthor}" org, or
|
|
@@ -78692,7 +78705,9 @@ var pushSnippet = async ({
|
|
|
78692
78705
|
}
|
|
78693
78706
|
});
|
|
78694
78707
|
onSuccess([
|
|
78695
|
-
|
|
78708
|
+
`
|
|
78709
|
+
`,
|
|
78710
|
+
kleur_default.bold().green(`"${tsciPackageName}@${releaseVersion}" published!`),
|
|
78696
78711
|
kleur_default.underline(kleur_default.blue(`https://tscircuit.com/${scopedPackageName}`))
|
|
78697
78712
|
].join(`
|
|
78698
78713
|
`));
|
|
@@ -79827,22 +79842,6 @@ function createDelay({ clearTimeout: defaultClear, setTimeout: defaultSet } = {}
|
|
|
79827
79842
|
var delay2 = createDelay();
|
|
79828
79843
|
var delay_default = delay2;
|
|
79829
79844
|
|
|
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
79845
|
// cli/auth/setup-npmrc/setup-npmrc.ts
|
|
79847
79846
|
import * as fs21 from "node:fs";
|
|
79848
79847
|
import * as path23 from "node:path";
|