@tscircuit/cli 0.1.82 → 0.1.84

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 +23 -11
  2. package/package.json +1 -1
package/dist/main.js CHANGED
@@ -433425,7 +433425,7 @@ import readline from "node:readline";
433425
433425
  import { execSync as execSync2 } from "node:child_process";
433426
433426
  var import_semver = __toESM2(require_semver2(), 1);
433427
433427
  // package.json
433428
- var version = "0.1.81";
433428
+ var version = "0.1.83";
433429
433429
  var package_default = {
433430
433430
  name: "@tscircuit/cli",
433431
433431
  version,
@@ -437918,9 +437918,14 @@ var prettyResponseErrorHook = async (_request, _options, response) => {
437918
437918
  } catch (e) {}
437919
437919
  }
437920
437920
  };
437921
- var getKy = () => {
437921
+ var getRegistryApiKy = ({
437922
+ sessionToken
437923
+ } = {}) => {
437922
437924
  return distribution_default.create({
437923
437925
  prefixUrl: getRegistryApiUrl(),
437926
+ headers: {
437927
+ ...sessionToken ? { Authorization: `Bearer ${sessionToken}` } : {}
437928
+ },
437924
437929
  hooks: {
437925
437930
  afterResponse: [prettyResponseErrorHook]
437926
437931
  }
@@ -438733,7 +438738,7 @@ var pushSnippet = async ({
438733
438738
  onError(`File not found: ${snippetFilePath}`);
438734
438739
  return onExit(1);
438735
438740
  }
438736
- const ky2 = getKy();
438741
+ const ky2 = getRegistryApiKy({ sessionToken });
438737
438742
  const currentUsername = cliConfig.get("githubUsername");
438738
438743
  let unscopedPackageName = getUnscopedPackageName(packageJson.name ?? "");
438739
438744
  const packageJsonAuthor = getPackageAuthor(packageJson.name ?? "");
@@ -438781,8 +438786,7 @@ var pushSnippet = async ({
438781
438786
  }
438782
438787
  };
438783
438788
  const doesPackageExist = await ky2.post("packages/get", {
438784
- json: { name: scopedPackageName },
438785
- headers: { Authorization: `Bearer ${sessionToken}` }
438789
+ json: { name: scopedPackageName }
438786
438790
  }).json().then((response) => {
438787
438791
  debug("doesPackageExist", response);
438788
438792
  return true;
@@ -439117,7 +439121,7 @@ var registerAuthLogin = (program3) => {
439117
439121
  console.log("Already logged in! Use 'tsci logout' if you need to switch accounts.");
439118
439122
  return;
439119
439123
  }
439120
- const ky2 = getKy();
439124
+ const ky2 = getRegistryApiKy();
439121
439125
  const { login_page } = await ky2.post("sessions/login_page/create", {
439122
439126
  json: {}
439123
439127
  }).json();
@@ -439188,15 +439192,23 @@ var registerConfigPrint = (program3) => {
439188
439192
  import * as fs19 from "node:fs";
439189
439193
  import * as path19 from "node:path";
439190
439194
  var registerClone = (program3) => {
439191
- program3.command("clone").description("Clone a snippet from the registry").argument("<snippet>", "Snippet to clone (e.g. author/snippetName)").action(async (snippetPath) => {
439192
- const match = snippetPath.match(/^(?:@tsci\/)?([^/.]+)[/.](.+)$/);
439193
- if (!match) {
439194
- console.error("Invalid snippet path. Use format: author/snippetName, author.snippetName, or @tsci/author.snippetName");
439195
+ program3.command("clone").description("Clone a snippet from the registry").argument("<snippet>", "Snippet to clone (e.g. author/snippetName or https://tscircuit.com/author/snippetName)").action(async (snippetPath) => {
439196
+ const urlMatch = snippetPath.match(/^https:\/\/tscircuit\.com\/([^\/]+)\/([^\/]+)\/?$/i);
439197
+ const originalMatch = !urlMatch && snippetPath.match(/^(?:@tsci\/)?([^/.]+)[/.]([^/.]+)$/);
439198
+ if (!urlMatch && !originalMatch) {
439199
+ console.error(`Invalid snippet path "${snippetPath}". Accepted formats:
439200
+ - author/snippetName
439201
+ - author.snippetName
439202
+ - @tsci/author.snippetName
439203
+ - https://tscircuit.com/author/snippetName`);
439195
439204
  process.exit(1);
439196
439205
  }
439206
+ const match = urlMatch || originalMatch;
439207
+ if (!match)
439208
+ throw new Error("No valid match found");
439197
439209
  const [, author, snippetName] = match;
439198
439210
  console.log(`Cloning ${author}/${snippetName}...`);
439199
- const ky2 = getKy();
439211
+ const ky2 = getRegistryApiKy();
439200
439212
  let packageFileList;
439201
439213
  try {
439202
439214
  packageFileList = await ky2.post("package_files/list", {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tscircuit/cli",
3
- "version": "0.1.82",
3
+ "version": "0.1.84",
4
4
  "main": "dist/main.js",
5
5
  "devDependencies": {
6
6
  "@babel/standalone": "^7.26.9",