@tscircuit/cli 0.0.16 → 0.0.17

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/cli.js CHANGED
@@ -215,6 +215,7 @@ var configRevealLocation = async (ctx, args2) => {
215
215
  import {z} from "zod";
216
216
  var configSetRegistry = async (ctx, args2) => {
217
217
  const params = z.object({ server: z.string().url() }).parse(args2);
218
+ ctx.profile_config.clear();
218
219
  ctx.profile_config.set("registry_url", params.server);
219
220
  };
220
221
  // lib/cmd-fns/config-set-session.ts
@@ -1545,7 +1546,7 @@ var openCmd = async (ctx, args2) => {
1545
1546
  // package.json
1546
1547
  var package_default = {
1547
1548
  name: "@tscircuit/cli",
1548
- version: "0.0.15",
1549
+ version: "0.0.16",
1549
1550
  private: false,
1550
1551
  type: "module",
1551
1552
  description: "Command line tool for developing, publishing and installing tscircuit circuits",
@@ -1889,11 +1890,36 @@ var interactForPackageName = async ({
1889
1890
  return selectedPackage;
1890
1891
  };
1891
1892
 
1893
+ // lib/param-handlers/interact-for-registry-url.ts
1894
+ var interactForRegistryUrl = async (params) => {
1895
+ const { prompts: prompts3, ctx } = params;
1896
+ const { registry_url } = await prompts3({
1897
+ type: "select",
1898
+ name: "registry_url",
1899
+ message: "Select a package example",
1900
+ choices: [
1901
+ "https://registry.tscircuit.com",
1902
+ "http://localhost:3100",
1903
+ "other"
1904
+ ].map((a) => ({ title: a, value: a }))
1905
+ });
1906
+ if (registry_url === "other") {
1907
+ const { registry_url: registry_url2 } = await prompts3({
1908
+ type: "text",
1909
+ name: "registry_url",
1910
+ message: "Enter the registry url"
1911
+ });
1912
+ return registry_url2;
1913
+ }
1914
+ return registry_url;
1915
+ };
1916
+
1892
1917
  // lib/param-handlers/index.ts
1893
1918
  var PARAM_HANDLERS_BY_PARAM_NAME = {
1894
1919
  file: interactForLocalFile,
1895
1920
  cwd: interactForLocalDirectory,
1896
1921
  dir: interactForLocalDirectory,
1922
+ registry_url: interactForRegistryUrl,
1897
1923
  package_release_id: interactForPackageReleaseId,
1898
1924
  package_name: interactForPackageName,
1899
1925
  package_name_with_version: interactForPackageNameWithVersion,
@@ -1909,7 +1935,14 @@ var createConfigHandler = ({
1909
1935
  const current_profile = profile ?? global_config.get("current_profile") ?? "default";
1910
1936
  const profile_config = {
1911
1937
  get: (key) => global_config.get(`profiles.${current_profile}.${key}`),
1912
- set: (key, value) => global_config.set(`profiles.${current_profile}.${key}`, value)
1938
+ set: (key, value) => global_config.set(`profiles.${current_profile}.${key}`, value),
1939
+ clear: () => {
1940
+ for (const key of Object.keys(global_config.all)) {
1941
+ if (key.startsWith(`profiles.${current_profile}`)) {
1942
+ global_config.delete(key);
1943
+ }
1944
+ }
1945
+ }
1913
1946
  };
1914
1947
  return { profile_config, global_config, current_profile };
1915
1948
  };
@@ -1979,7 +2012,10 @@ var createContextAndRunProgram = async (process_args) => {
1979
2012
  }
1980
2013
  await perfectCli(getProgram(ctx), args_without_globals, {
1981
2014
  async customParamHandler({ commandPath, optionName }, { prompts: prompts3 }) {
1982
- const optionNameHandler = PARAM_HANDLERS_BY_PARAM_NAME[_.snakeCase(optionName)];
2015
+ let optionNameHandler = PARAM_HANDLERS_BY_PARAM_NAME[_.snakeCase(optionName)];
2016
+ if (commandPath.join(" ") === "config set-registry" && optionName === "server") {
2017
+ optionNameHandler = PARAM_HANDLERS_BY_PARAM_NAME["registry_url"];
2018
+ }
1983
2019
  if (optionNameHandler) {
1984
2020
  return optionNameHandler({ prompts: prompts3, ctx });
1985
2021
  }
@@ -3,5 +3,7 @@ import { z } from "zod"
3
3
 
4
4
  export const configSetRegistry = async (ctx: AppContext, args: any) => {
5
5
  const params = z.object({ server: z.string().url() }).parse(args)
6
+ // don't want to re-use auth token
7
+ ctx.profile_config.clear()
6
8
  ctx.profile_config.set("registry_url", params.server)
7
9
  }
@@ -83,6 +83,13 @@ export const createConfigHandler = ({
83
83
  (global_config as any).get(`profiles.${current_profile}.${key}`),
84
84
  set: (key: string, value: any) =>
85
85
  (global_config as any).set(`profiles.${current_profile}.${key}`, value),
86
+ clear: () => {
87
+ for (const key of Object.keys(global_config.all)) {
88
+ if (key.startsWith(`profiles.${current_profile}`)) {
89
+ global_config.delete(key as any)
90
+ }
91
+ }
92
+ },
86
93
  } as any
87
94
 
88
95
  return { profile_config, global_config, current_profile }
@@ -4,12 +4,14 @@ import { interactForPackageExampleId } from "./interact-for-package-example-id"
4
4
  import { interactForPackageName } from "./interact-for-package-name"
5
5
  import { interactForPackageNameWithVersion } from "./interact-for-package-name-with-version"
6
6
  import { interactForPackageReleaseId } from "./interact-for-package-release-id"
7
+ import { interactForRegistryUrl } from "./interact-for-registry-url"
7
8
  import { ParamHandler } from "./param-handler-type"
8
9
 
9
10
  export const PARAM_HANDLERS_BY_PARAM_NAME: Record<string, ParamHandler> = {
10
11
  file: interactForLocalFile,
11
12
  cwd: interactForLocalDirectory,
12
13
  dir: interactForLocalDirectory,
14
+ registry_url: interactForRegistryUrl,
13
15
  package_release_id: interactForPackageReleaseId,
14
16
  package_name: interactForPackageName,
15
17
  package_name_with_version: interactForPackageNameWithVersion,
@@ -0,0 +1,28 @@
1
+ import { interactForPackageReleaseId } from "./interact-for-package-release-id"
2
+ import { ParamHandler } from "./param-handler-type"
3
+
4
+ export const interactForRegistryUrl: ParamHandler = async (params) => {
5
+ const { prompts, ctx } = params
6
+
7
+ const { registry_url } = await prompts({
8
+ type: "select",
9
+ name: "registry_url",
10
+ message: "Select a package example",
11
+ choices: [
12
+ "https://registry.tscircuit.com",
13
+ "http://localhost:3100",
14
+ "other",
15
+ ].map((a) => ({ title: a, value: a })),
16
+ })
17
+
18
+ if (registry_url === "other") {
19
+ const { registry_url } = await prompts({
20
+ type: "text",
21
+ name: "registry_url",
22
+ message: "Enter the registry url",
23
+ })
24
+ return registry_url
25
+ }
26
+
27
+ return registry_url
28
+ }
@@ -123,9 +123,16 @@ export const createContextAndRunProgram = async (process_args: any) => {
123
123
 
124
124
  await perfectCli(getProgram(ctx), args_without_globals, {
125
125
  async customParamHandler({ commandPath, optionName }, { prompts }) {
126
- const optionNameHandler =
126
+ let optionNameHandler =
127
127
  PARAM_HANDLERS_BY_PARAM_NAME[_.snakeCase(optionName)]
128
128
 
129
+ if (
130
+ commandPath.join(" ") === "config set-registry" &&
131
+ optionName === "server"
132
+ ) {
133
+ optionNameHandler = PARAM_HANDLERS_BY_PARAM_NAME["registry_url"]
134
+ }
135
+
129
136
  if (optionNameHandler) {
130
137
  return optionNameHandler({ prompts, ctx })
131
138
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tscircuit/cli",
3
- "version": "0.0.16",
3
+ "version": "0.0.17",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Command line tool for developing, publishing and installing tscircuit circuits",