@tscircuit/cli 0.0.394 → 0.1.2

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 (246) hide show
  1. package/.github/workflows/bun-formatcheck.yml +26 -0
  2. package/.github/workflows/bun-pver-release.yml +25 -0
  3. package/.github/workflows/{typecheck.yml → bun-typecheck.yml} +0 -3
  4. package/LICENSE +21 -0
  5. package/README.md +33 -36
  6. package/biome.json +9 -9
  7. package/bun.lockb +0 -0
  8. package/cli/CliContext.ts +8 -0
  9. package/cli/auth/login/register.ts +73 -0
  10. package/cli/auth/logout/register.ts +11 -0
  11. package/cli/auth/register.ts +5 -0
  12. package/cli/clone/register.ts +99 -0
  13. package/cli/config/print/register.ts +12 -0
  14. package/cli/config/register.ts +5 -0
  15. package/cli/dev/register.ts +111 -0
  16. package/cli/main.ts +33 -0
  17. package/dist/main.js +537 -0
  18. package/docs/file-server-api-usage.md +57 -0
  19. package/docs/run-frame-usage.md +14 -0
  20. package/example-dir/manual-edits.json +1 -0
  21. package/example-dir/snippet.d.ts +13 -0
  22. package/example-dir/snippet.tsx +20 -0
  23. package/example-dir/types.d.ts +11 -0
  24. package/lib/cli-config/TypedConfigStore.ts +50 -0
  25. package/lib/cli-config/index.ts +16 -0
  26. package/lib/dependency-analysis/DependencyAnalyzer.ts +129 -0
  27. package/lib/dependency-analysis/getLocalFileDependencies.ts +101 -0
  28. package/lib/dependency-analysis/installNodeModuleTypes.ts +74 -0
  29. package/lib/index.ts +2 -0
  30. package/lib/project-config/index.ts +5 -0
  31. package/lib/registry-api/endpoint-types.ts +20 -0
  32. package/lib/registry-api/get-ky.ts +30 -0
  33. package/lib/server/EventsWatcher.ts +75 -0
  34. package/lib/server/createServer.ts +62 -0
  35. package/lib/site/getIndex.ts +18 -0
  36. package/package.json +27 -144
  37. package/tsconfig.json +25 -22
  38. package/.github/workflows/formatbot.yml +0 -63
  39. package/.github/workflows/release.yml +0 -40
  40. package/.github/workflows/test.yml +0 -32
  41. package/.github/workflows/windows-tests.yml +0 -32
  42. package/.prettierrc +0 -1
  43. package/DEVELOPMENT.md +0 -7
  44. package/api/README.md +0 -3
  45. package/api/db/generic-json-level.ts +0 -123
  46. package/api/db/get-db.ts +0 -26
  47. package/api/db/schema.ts +0 -65
  48. package/api/db/zod-level-db.ts +0 -148
  49. package/api/index.ts +0 -4
  50. package/api/lib/middlewares/with-db.ts +0 -18
  51. package/api/lib/middlewares/with-debug-request-logging.ts +0 -13
  52. package/api/lib/middlewares/with-error-response.ts +0 -37
  53. package/api/lib/with-winter-spec.ts +0 -9
  54. package/api/lib/zod/export_parameters.ts +0 -25
  55. package/api/routes/api/db/download.ts +0 -25
  56. package/api/routes/api/dev_package_examples/create.ts +0 -43
  57. package/api/routes/api/dev_package_examples/get.ts +0 -46
  58. package/api/routes/api/dev_package_examples/list.ts +0 -36
  59. package/api/routes/api/dev_package_examples/update.ts +0 -59
  60. package/api/routes/api/dev_server/reset.ts +0 -13
  61. package/api/routes/api/export_files/create.ts +0 -27
  62. package/api/routes/api/export_files/download.ts +0 -25
  63. package/api/routes/api/export_requests/create.ts +0 -30
  64. package/api/routes/api/export_requests/get.ts +0 -43
  65. package/api/routes/api/export_requests/list.ts +0 -26
  66. package/api/routes/api/export_requests/update.ts +0 -34
  67. package/api/routes/api/health.ts +0 -11
  68. package/api/routes/api/package_info/create.ts +0 -26
  69. package/api/routes/api/package_info/get.ts +0 -16
  70. package/api/routes/health.ts +0 -11
  71. package/api/routes/index.ts +0 -16
  72. package/api/server.ts +0 -20
  73. package/api/static-routes.ts +0 -24
  74. package/api/tests/fixtures/get-test-server.ts +0 -31
  75. package/api/tests/fixtures/start-server.ts +0 -41
  76. package/api/tests/routes/dev_package_examples/create.test.ts +0 -19
  77. package/api/tests/routes/dev_package_examples/get.test.ts +0 -25
  78. package/api/tests/routes/dev_package_examples/list.test.ts +0 -32
  79. package/api/tests/routes/dev_package_examples/update.test.ts +0 -38
  80. package/api/tests/routes/export_files/create.test.ts +0 -18
  81. package/api/tests/routes/export_files/download.test.ts +0 -29
  82. package/api/tests/routes/export_requests/create.test.ts +0 -24
  83. package/api/tests/routes/export_requests/get.test.ts +0 -41
  84. package/api/tests/routes/export_requests/list.test.ts +0 -35
  85. package/api/tests/routes/export_requests/update.test.ts +0 -50
  86. package/api/tests/routes/health.test.ts +0 -10
  87. package/bunfig.toml +0 -2
  88. package/cli/cli.ts +0 -13
  89. package/cli/lib/cmd-fns/add.ts +0 -34
  90. package/cli/lib/cmd-fns/auth-login.ts +0 -59
  91. package/cli/lib/cmd-fns/auth-logout.ts +0 -7
  92. package/cli/lib/cmd-fns/auth-sessions-create.ts +0 -3
  93. package/cli/lib/cmd-fns/auth-sessions-get.ts +0 -3
  94. package/cli/lib/cmd-fns/auth-sessions-list.ts +0 -5
  95. package/cli/lib/cmd-fns/config-clear.ts +0 -5
  96. package/cli/lib/cmd-fns/config-print-config.ts +0 -6
  97. package/cli/lib/cmd-fns/config-reveal-location.ts +0 -5
  98. package/cli/lib/cmd-fns/config-set-log-requests.ts +0 -7
  99. package/cli/lib/cmd-fns/config-set-registry.ts +0 -9
  100. package/cli/lib/cmd-fns/config-set-runtime.ts +0 -7
  101. package/cli/lib/cmd-fns/config-set-session.ts +0 -7
  102. package/cli/lib/cmd-fns/dev/check-if-initialized.ts +0 -22
  103. package/cli/lib/cmd-fns/dev/derive-selector-from-pcb-component-id.ts +0 -23
  104. package/cli/lib/cmd-fns/dev/dev-server-request-handler.ts +0 -61
  105. package/cli/lib/cmd-fns/dev/find-available-port.ts +0 -32
  106. package/cli/lib/cmd-fns/dev/fulfill-export-requests.ts +0 -162
  107. package/cli/lib/cmd-fns/dev/get-dev-server-axios.ts +0 -29
  108. package/cli/lib/cmd-fns/dev/index.ts +0 -168
  109. package/cli/lib/cmd-fns/dev/infer-export-name-from-source.ts +0 -17
  110. package/cli/lib/cmd-fns/dev/mark-all-examples-loading.ts +0 -18
  111. package/cli/lib/cmd-fns/dev/soupify-and-upload-example-file.ts +0 -62
  112. package/cli/lib/cmd-fns/dev/start-dev-server.ts +0 -34
  113. package/cli/lib/cmd-fns/dev/start-edit-event-watcher.ts +0 -347
  114. package/cli/lib/cmd-fns/dev/start-export-request-watcher.ts +0 -33
  115. package/cli/lib/cmd-fns/dev/start-fs-watcher.ts +0 -54
  116. package/cli/lib/cmd-fns/dev/upload-examples-from-directory.ts +0 -42
  117. package/cli/lib/cmd-fns/dev-server-fulfill-export-requests.ts +0 -43
  118. package/cli/lib/cmd-fns/dev-server-upload.ts +0 -56
  119. package/cli/lib/cmd-fns/export-gerbers.ts +0 -28
  120. package/cli/lib/cmd-fns/export-kicad-pcb.ts +0 -36
  121. package/cli/lib/cmd-fns/export-pnp-csv.ts +0 -32
  122. package/cli/lib/cmd-fns/gen-jlcpcb-component.ts +0 -64
  123. package/cli/lib/cmd-fns/go.ts +0 -14
  124. package/cli/lib/cmd-fns/index.ts +0 -46
  125. package/cli/lib/cmd-fns/init/create-or-modify-npmrc.ts +0 -21
  126. package/cli/lib/cmd-fns/init/get-generated-npmrc.ts +0 -8
  127. package/cli/lib/cmd-fns/init/get-generated-readme.ts +0 -41
  128. package/cli/lib/cmd-fns/init/get-generated-tsconfig.ts +0 -34
  129. package/cli/lib/cmd-fns/init/index.ts +0 -193
  130. package/cli/lib/cmd-fns/install.ts +0 -34
  131. package/cli/lib/cmd-fns/lint.ts +0 -43
  132. package/cli/lib/cmd-fns/open.ts +0 -19
  133. package/cli/lib/cmd-fns/package-examples-create.ts +0 -36
  134. package/cli/lib/cmd-fns/package-examples-get.ts +0 -20
  135. package/cli/lib/cmd-fns/package-examples-list.ts +0 -18
  136. package/cli/lib/cmd-fns/package-files-create.ts +0 -31
  137. package/cli/lib/cmd-fns/package-files-download.ts +0 -29
  138. package/cli/lib/cmd-fns/package-files-get.ts +0 -3
  139. package/cli/lib/cmd-fns/package-files-list.ts +0 -28
  140. package/cli/lib/cmd-fns/package-files-upload-directory.ts +0 -6
  141. package/cli/lib/cmd-fns/package-releases-create.ts +0 -35
  142. package/cli/lib/cmd-fns/package-releases-get.ts +0 -3
  143. package/cli/lib/cmd-fns/package-releases-list.ts +0 -32
  144. package/cli/lib/cmd-fns/package-releases-update.ts +0 -45
  145. package/cli/lib/cmd-fns/packages-create.ts +0 -16
  146. package/cli/lib/cmd-fns/packages-get.ts +0 -16
  147. package/cli/lib/cmd-fns/packages-list.ts +0 -16
  148. package/cli/lib/cmd-fns/publish/index.ts +0 -336
  149. package/cli/lib/cmd-fns/remove.ts +0 -31
  150. package/cli/lib/cmd-fns/render.ts +0 -45
  151. package/cli/lib/cmd-fns/soupify.ts +0 -31
  152. package/cli/lib/cmd-fns/uninstall.ts +0 -31
  153. package/cli/lib/cmd-fns/version.ts +0 -38
  154. package/cli/lib/create-config-manager.ts +0 -97
  155. package/cli/lib/export-fns/export-bom-csv.ts +0 -32
  156. package/cli/lib/export-fns/export-gerbers.ts +0 -108
  157. package/cli/lib/export-fns/export-kicad-pcb.ts +0 -32
  158. package/cli/lib/export-fns/export-pnp-csv.ts +0 -31
  159. package/cli/lib/get-program.ts +0 -387
  160. package/cli/lib/param-handlers/index.ts +0 -21
  161. package/cli/lib/param-handlers/interact-for-local-directory.ts +0 -58
  162. package/cli/lib/param-handlers/interact-for-local-file.ts +0 -59
  163. package/cli/lib/param-handlers/interact-for-package-example-id.ts +0 -25
  164. package/cli/lib/param-handlers/interact-for-package-name-with-version.ts +0 -63
  165. package/cli/lib/param-handlers/interact-for-package-name.ts +0 -45
  166. package/cli/lib/param-handlers/interact-for-package-release-id.ts +0 -15
  167. package/cli/lib/param-handlers/interact-for-registry-url.ts +0 -27
  168. package/cli/lib/param-handlers/interact-for-runtime.ts +0 -33
  169. package/cli/lib/param-handlers/param-handler-type.ts +0 -7
  170. package/cli/lib/posthog.ts +0 -23
  171. package/cli/lib/soupify/get-export-name-from-file.ts +0 -29
  172. package/cli/lib/soupify/get-tmp-entrpoint-filepath.ts +0 -15
  173. package/cli/lib/soupify/index.ts +0 -1
  174. package/cli/lib/soupify/run-entrypoint-file.ts +0 -59
  175. package/cli/lib/soupify/soupify-with-core.ts +0 -74
  176. package/cli/lib/soupify/soupify.ts +0 -6
  177. package/cli/lib/util/app-context.ts +0 -17
  178. package/cli/lib/util/create-context-and-run-program.ts +0 -168
  179. package/cli/lib/util/get-all-package-files.ts +0 -66
  180. package/cli/lib/util/lint-project.ts +0 -137
  181. package/cli/tests/export-gerber-keyboard.test.ts +0 -16
  182. package/cli/tests/export-gerber.test.ts +0 -49
  183. package/cli/tests/export-kicad-pcb.test.ts +0 -23
  184. package/cli/tests/export-pnp-csv.test.ts +0 -24
  185. package/cli/tests/fixtures/preload.ts +0 -54
  186. package/cli/tests/init.test.ts +0 -9
  187. package/cli/tests/open.test.ts +0 -9
  188. package/cli/tests/soupify-builder.test.ts +0 -9
  189. package/cli/tests/soupify-core.test.ts +0 -9
  190. package/dist/cli.js +0 -3676
  191. package/docs/EDIT_EVENT_PIPELINE.md +0 -34
  192. package/example-project/README.md +0 -18
  193. package/example-project/examples/basic-capacitor.tsx +0 -5
  194. package/example-project/examples/basic-chip.tsx +0 -26
  195. package/example-project/examples/basic-resistor.tsx +0 -3
  196. package/example-project/examples/macrokeypad.tsx +0 -59
  197. package/example-project/index.ts +0 -1
  198. package/example-project/package.json +0 -5
  199. package/example-project/src/ArduinoProMicroBreakout.tsx +0 -37
  200. package/example-project/src/Key.tsx +0 -46
  201. package/example-project/src/Keyswitch.tsx +0 -26
  202. package/example-project/src/KeyswitchSocket.tsx +0 -56
  203. package/example-project/src/MyCircuit.tsx +0 -38
  204. package/example-project/src/manual-edits.ts +0 -93
  205. package/frontend/README.md +0 -3
  206. package/frontend/bun.lockb +0 -0
  207. package/frontend/components/command-k.tsx +0 -86
  208. package/frontend/components/dialogs/generic-export-dialog.tsx +0 -189
  209. package/frontend/components/dialogs/gerber-export-dialog.tsx +0 -168
  210. package/frontend/components/global-context-providers.tsx +0 -11
  211. package/frontend/components/select-example-search.tsx +0 -118
  212. package/frontend/components/ui/alert-dialog.tsx +0 -139
  213. package/frontend/components/ui/alert.tsx +0 -59
  214. package/frontend/components/ui/breadcrumb.tsx +0 -115
  215. package/frontend/components/ui/button.tsx +0 -57
  216. package/frontend/components/ui/card.tsx +0 -76
  217. package/frontend/components/ui/command.tsx +0 -153
  218. package/frontend/components/ui/context-menu.tsx +0 -202
  219. package/frontend/components/ui/dialog.tsx +0 -120
  220. package/frontend/components/ui/menubar.tsx +0 -238
  221. package/frontend/components/ui/navigation-menu.tsx +0 -128
  222. package/frontend/components/ui/popover.tsx +0 -31
  223. package/frontend/components/ui/select.tsx +0 -162
  224. package/frontend/components/ui/tabs.tsx +0 -53
  225. package/frontend/components/ui/toggle-group.tsx +0 -59
  226. package/frontend/components/ui/toggle.tsx +0 -43
  227. package/frontend/components/ui/tooltip.tsx +0 -28
  228. package/frontend/components.json +0 -17
  229. package/frontend/hooks/toast-if-api-not-connected.ts +0 -23
  230. package/frontend/hooks/use-active-dev-package-example-lite.ts +0 -39
  231. package/frontend/hooks/use-dev-package-examples.tsx +0 -18
  232. package/frontend/hooks/use-global-store.ts +0 -42
  233. package/frontend/index.css +0 -76
  234. package/frontend/index.html +0 -13
  235. package/frontend/lib/utils.ts +0 -6
  236. package/frontend/main.tsx +0 -13
  237. package/frontend/tailwind.config.js +0 -74
  238. package/frontend/views/App.tsx +0 -22
  239. package/frontend/views/Header.tsx +0 -55
  240. package/frontend/views/HeaderMenu.tsx +0 -326
  241. package/frontend/views/MainContentView.tsx +0 -172
  242. package/frontend/vite-env.d.ts +0 -1
  243. package/frontend/vite.config.ts +0 -50
  244. package/renovate.json +0 -16
  245. package/scripts/build-cli.ts +0 -12
  246. package/tsup.config.ts +0 -7
@@ -1,387 +0,0 @@
1
- import { Command } from "commander"
2
- import * as CMDFN from "cli/lib/cmd-fns"
3
- import type { AppContext } from "./util/app-context"
4
-
5
- export const getProgram = (ctx: AppContext) => {
6
- const cmd = new Command("tsci").description(
7
- "Develop, test and manage tscircuit packages",
8
- )
9
-
10
- cmd
11
- .command("dev")
12
- .description("Run development server in current directory")
13
- .option("--cwd <cwd>", "Current working directory")
14
- .option("--port <port>", "Port to run dev server on")
15
- .option("--no-core", "Use @tscircuit/core beta", false)
16
- .option("--no-cleanup", "Don't cleanup temporary files (for debugging)")
17
- .action((args) => CMDFN.dev(ctx, args))
18
-
19
- cmd
20
- .command("init")
21
- .description("Initialize a new tscircuit project")
22
- .option("--name <name>", "Name of the project")
23
- .option(
24
- "--runtime <runtime>",
25
- "Runtime to use (attempts to bun, otherwise node/tsx)",
26
- )
27
- .option(
28
- "--dir <dir>",
29
- "Directory to initialize (defaults to ./<name> or . if name not provided)",
30
- )
31
- .action((args) => CMDFN.init(ctx, args))
32
-
33
- cmd
34
- .command("add")
35
- .description("Add a package from the tscircuit registry")
36
- .argument(
37
- "<packages...>",
38
- "Packages to install from registry.tscircuit.com, optionally with version",
39
- )
40
- .option("-D, --dev", "Add to devDependencies")
41
- .action((packages, flags) => CMDFN.add(ctx, { packages, flags }))
42
-
43
- cmd
44
- .command("remove")
45
- .description("Remove/uninstall a package")
46
- .argument("<packages...>", "Packages to remove")
47
- .action((packages, flags) => CMDFN.remove(ctx, { packages, flags }))
48
-
49
- cmd
50
- .command("lint")
51
- .description("Lint all TypeScript files in the project")
52
- .option("--fix", "Automatically fix problems")
53
- .action((args) => CMDFN.lint(ctx, args))
54
-
55
- cmd
56
- .command("go")
57
- .description("Open browser to the TSCircuit Get Started tutorial")
58
- .action((args) => CMDFN.go(ctx, args))
59
-
60
- cmd
61
- .command("render")
62
- .description("Render circuit as image")
63
- .requiredOption("--input <input>", "Input TypeScript file path")
64
- .option("--pcb", "Render PCB view")
65
- .option("--schematic", "Render schematic view")
66
- .option("--output <output>", "Output file path")
67
- .option("-t, --type <type>", "Output file type (png or svg)")
68
- .action((args) => CMDFN.render(ctx, args))
69
-
70
- const genCmd = cmd.command("gen").description("Generate components")
71
- genCmd
72
- .command("jlcpcb <jlcpcbPartNumberOrUrl>")
73
- .description("Generate JLCPCB-specific files")
74
- .action((partNumberOrUrl, args) =>
75
- CMDFN.genJlcpcbComponent(ctx, { partNumberOrUrl, ...args }),
76
- )
77
-
78
- const authCmd = cmd.command("auth").description("Login/logout")
79
- authCmd
80
- .command("login")
81
- .description("Authenticate CLI, login to registry")
82
- .action((args) => CMDFN.authLogin(ctx, args))
83
- authCmd
84
- .command("logout")
85
- .description("Clear local authentication")
86
- .action((args) => CMDFN.authLogout(ctx, args))
87
-
88
- const configCmd = cmd
89
- .command("config")
90
- .description("Manage the local tsci configuration")
91
-
92
- configCmd
93
- .command("reveal-location")
94
- .description("Log the location of the config file")
95
- .action((args) => CMDFN.configRevealLocation(ctx, args))
96
- configCmd
97
- .command("set-registry")
98
- .description("Set the registry API url")
99
- .requiredOption("--server <server>", "Registry URL")
100
- .action((args) => CMDFN.configSetRegistry(ctx, args))
101
- configCmd
102
- .command("set-session")
103
- .description("Set the session token manually")
104
- .requiredOption("--session-token <session_token>", "Session Token")
105
- .action((args) => CMDFN.configSetSession(ctx, args))
106
- configCmd
107
- .command("set-runtime")
108
- .description("Set runtime to use, bun or node")
109
- .requiredOption(
110
- "--runtime <runtime>",
111
- "Bun or node. Setting to bun generally doubles soupification speed.",
112
- )
113
- .action((args) => CMDFN.configSetRuntime(ctx, args))
114
- configCmd
115
- .command("set-log-requests")
116
- .description("Set whether to log requests to registry (noisy)")
117
- .requiredOption("--log-requests", "Should log requests to registry")
118
- .action((args) => CMDFN.configSetLogRequests(ctx, args))
119
- configCmd
120
- .command("print-config")
121
- .description("Print the current config")
122
- .action((args) => CMDFN.configPrintConfig(ctx, args))
123
- configCmd
124
- .command("clear")
125
-
126
- .action((args) => CMDFN.configClear(ctx, args))
127
-
128
- // const authSessionsCmd = authCmd.command("sessions")
129
- // authSessionsCmd
130
- // .command("create")
131
- // .action((args) => CMDFN.authSessionsCreate(ctx, args))
132
- // authSessionsCmd
133
- // .command("list")
134
- // .action((args) => CMDFN.authSessionsList(ctx, args))
135
- // authSessionsCmd
136
- // .command("get")
137
- // .action((args) => CMDFN.authSessionsGet(ctx, args))
138
-
139
- const packagesCmd = cmd.command("packages").description("Manage packages")
140
-
141
- packagesCmd.command("list").action((args) => CMDFN.packagesList(ctx, args))
142
- packagesCmd
143
- .command("get")
144
- .description("Get information about a package")
145
- .option("--package-id <package_id>", "Package Id")
146
- .option("--name <name>", "Package name")
147
- .action((args) => CMDFN.packagesGet(ctx, args))
148
- packagesCmd
149
- .command("create")
150
- .description("Create a new package")
151
- .requiredOption("--name <name>", "Package name")
152
- .option("--author-id <author_account_id>", "Author Id")
153
- .option("--description <description>", "Package description")
154
- .action((args) => CMDFN.packagesCreate(ctx, args))
155
-
156
- const packageReleases = cmd.command("package_releases")
157
-
158
- packageReleases
159
- .command("list")
160
- .description("List all package releases for a package")
161
- .requiredOption("--package-name <package_name>", "Package name")
162
- .option("--verbose", "Verbose objects (includes uuids)")
163
- .action((args) => CMDFN.packageReleasesList(ctx, args))
164
- // packageReleases
165
- // .command("get")
166
- // .description("Get information about a package release")
167
- // .action((args) => CMDFN.packageReleasesGet(ctx, args))
168
- packageReleases
169
- .command("create")
170
- .description("Create a new package release")
171
- .option(
172
- "-p, --package-name-with-version <package_name_with_version>",
173
- "Package name and version",
174
- )
175
- .option("--package-name <package_name>", "Package name")
176
- .option("--release-version <release_version>", "Version to publish")
177
- .action((args) => CMDFN.packageReleasesCreate(ctx, args))
178
- packageReleases
179
- .command("update")
180
- .description("Update a package release")
181
- .option(
182
- "-p, --package-name-with-version <package_name_with_version>",
183
- "Package name and version",
184
- )
185
- .option("--is-latest", "Make package release the latest version")
186
- .option("--is-locked", "Lock the release")
187
- .action((args) => CMDFN.packageReleasesUpdate(ctx, args))
188
-
189
- const packageFiles = cmd
190
- .command("package_files")
191
- .description("Manage package release files")
192
-
193
- packageFiles
194
- .command("list")
195
- .description("List all files for a package release")
196
- .option(
197
- "--package-name-with-version <package_name_with_version>",
198
- "Package name with version",
199
- )
200
- .option(
201
- "--package-name <package_name>",
202
- "Package name (use latest version)",
203
- )
204
- .option("--package-release-id <package_release_id>", "Package Release Id")
205
- .action((args) => CMDFN.packageFilesList(ctx, args))
206
- // packageFiles.command("get").action((args) => CMDFN.packageFilesGet(ctx, args))
207
- packageFiles
208
- .command("download")
209
- .description("Download a file from a package release")
210
- .requiredOption(
211
- "--package-name-with-version <package_name_with_version>",
212
- "Package name and version",
213
- )
214
- .requiredOption("--remote-file-path <remote_file_path>", "Remote file path")
215
- .option(
216
- "--output <output>",
217
- "Output file path (optional), prints to stdout if not provided",
218
- )
219
- .action((args) => CMDFN.packageFilesDownload(ctx, args))
220
- packageFiles
221
- .command("create")
222
- .description("Create/upload a new package file")
223
- .option(
224
- "-p, --package-release-id <package_release_id>",
225
- "Package Release Id",
226
- )
227
- .option(
228
- "--package-name-with-version <package_name_with_version>",
229
- "Package name with version e.g. @tscircuit/arduino@1.2.3",
230
- )
231
- .requiredOption("--file <file>", "File to upload")
232
- .action((args) => CMDFN.packageFilesCreate(ctx, args))
233
-
234
- // packageFiles
235
- // .command("upload-directory")
236
- // .description("Upload a directory of files to a package release")
237
- // .requiredOption("--dir <dir>", "Directory to upload")
238
- // .action((args) => CMDFN.packageFilesUploadDirectory(ctx, args))
239
-
240
- const packageExamples = cmd
241
- .command("package_examples")
242
- .description("Manage package release examples")
243
-
244
- packageExamples
245
- .command("list")
246
- .description("List all examples for a package")
247
- .requiredOption("--package-name-with-version <package_name_with_version>")
248
- .action((args) => CMDFN.packageExamplesList(ctx, args))
249
- packageExamples
250
- .command("get")
251
- .description("Get information about a package example")
252
- .requiredOption("--package-example-id <package_example_id>")
253
- .action((args) => CMDFN.packageExamplesGet(ctx, args))
254
- packageExamples
255
- .command("create")
256
- .description("Create a new package example")
257
- .requiredOption("--package-name-with-version <package_name_with_version>")
258
- .requiredOption("--file <file>")
259
- .option("--export <export>", "Name of export to soupify")
260
- .action((args) => CMDFN.packageExamplesCreate(ctx, args))
261
-
262
- cmd
263
- .command("publish")
264
- .description("Publish a package release to the tscircuit registry")
265
- .option("--increment", "Increase patch version", true)
266
- .option("--patch", "Increase patch version")
267
- .option("--lock", "Lock the release after publishing to prevent changes")
268
- .action((args) => CMDFN.publish(ctx, args))
269
-
270
- cmd
271
- .command("version")
272
- .description("Print current version")
273
- .option("--show-latest", "Show latest versions of dependencies")
274
- .action((args) => CMDFN.version(ctx, args))
275
-
276
- cmd
277
- .command("login")
278
- .description("Authenticate CLI, login to registry")
279
- .action((args) => CMDFN.authLogin(ctx, args))
280
- cmd
281
- .command("logout")
282
- .description("Clear your local authentication")
283
- .action((args) => CMDFN.authLogout(ctx, args))
284
-
285
- const exportCmd = cmd
286
- .command("export")
287
- .description("Export Gerbers, Drill Files, Netlists and more")
288
-
289
- exportCmd
290
- .command("gerbers")
291
- .description("Export Gerber files from an example file")
292
- .option(
293
- "--file <file>",
294
- "Input example file (deprecated, use --input instead)",
295
- )
296
- .option("--input <input>", "Input example file")
297
- .option(
298
- "--export <export_name>",
299
- "Name of export to soupify, if not specified, soupify the default/only export",
300
- )
301
- .option("--outputfile <outputfile>", "Output file name", "gerbers.zip")
302
- .action((args) => CMDFN.exportGerbers(ctx, args))
303
-
304
- exportCmd
305
- .command("kicad_pcb")
306
- .description("Export KiCad PCB file from an example file")
307
- .option("--input <input>", "Input example file")
308
- .option(
309
- "--export <export_name>",
310
- "Name of export to soupify, if not specified, soupify the default/only export",
311
- )
312
- .option("--outputfile <outputfile>", "Output file name", "output.kicad_pcb")
313
- .action((args) => CMDFN.exportKicadPcb(ctx, args))
314
-
315
- exportCmd
316
- .command("pnp_csv")
317
- .description("Export Plug n Play CSV file from an example file")
318
- .option("--input <input>", "Input example file")
319
- .option(
320
- "--export <export_name>",
321
- "Name of export to soupify, if not specified, soupify the default/only export",
322
- )
323
- .option("--outputfile <outputfile>", "Output file name", "pnp.csv")
324
- .action((args) => CMDFN.exportPnpCsv(ctx, args))
325
-
326
- cmd
327
- .command("soupify")
328
- .description("Convert an example file to tscircuit soup")
329
- .requiredOption("--file <file>", "Input example files")
330
- .option("--output <output.json>", "Output file")
331
- .option("--no-core", "Use @tscircuit/core to build (future version)", false)
332
- .option(
333
- "--export <export_name>",
334
- "Name of export to soupify, if not specified, soupify the default/only export",
335
- )
336
- .action((args) => CMDFN.soupify(ctx, args))
337
-
338
- cmd
339
- .command("install")
340
- .description("Install a package from the tscircuit registry")
341
- .argument(
342
- "<packages...>",
343
- "Packages to install from registry.tscircuit.com, optionally with version",
344
- )
345
- .option("-D, --dev", "Add to devDependencies")
346
- .action((packages, flags) => CMDFN.install(ctx, { packages, flags }))
347
-
348
- cmd
349
- .command("uninstall")
350
- .description("Uninstall a package")
351
- .argument("<packages...>", "Packages to uninstall")
352
- .action((packages, flags) => CMDFN.install(ctx, { packages, flags }))
353
-
354
- const devServerCmd = cmd
355
- .command("dev-server")
356
- .description("(Advanced) Manage the development server")
357
-
358
- devServerCmd
359
- .command("upload")
360
- .description("Upload a directory to the dev server")
361
- .option(
362
- "--dir <dir>",
363
- "Directory to upload (defaults to current directory)",
364
- )
365
- .option("-w, --watch", "Watch for changes")
366
- .option("-p, --port", "Port dev server is running on (default: 3020)")
367
- .action((args) => CMDFN.devServerUpload(ctx, args))
368
-
369
- devServerCmd
370
- .command("fulfill-export-requests")
371
- .action((args) => CMDFN.devServerFulfillExportRequests(ctx, args))
372
-
373
- cmd
374
- .command("open")
375
- .description("Open browser to package on tscircuit registry")
376
- .action((args) => CMDFN.open(ctx, args))
377
-
378
- function recursiveUnhelp(cmd: Command) {
379
- cmd.helpCommand(false)
380
- for (const c of cmd.commands) {
381
- recursiveUnhelp(c)
382
- }
383
- }
384
- recursiveUnhelp(cmd)
385
-
386
- return cmd
387
- }
@@ -1,21 +0,0 @@
1
- import { interactForLocalDirectory } from "./interact-for-local-directory"
2
- import { interactForLocalFile } from "./interact-for-local-file"
3
- import { interactForPackageExampleId } from "./interact-for-package-example-id"
4
- import { interactForPackageName } from "./interact-for-package-name"
5
- import { interactForPackageNameWithVersion } from "./interact-for-package-name-with-version"
6
- import { interactForPackageReleaseId } from "./interact-for-package-release-id"
7
- import { interactForRegistryUrl } from "./interact-for-registry-url"
8
- import { interactForRuntime } from "./interact-for-runtime"
9
- import { ParamHandler } from "./param-handler-type"
10
-
11
- export const PARAM_HANDLERS_BY_PARAM_NAME: Record<string, ParamHandler> = {
12
- file: interactForLocalFile,
13
- cwd: interactForLocalDirectory,
14
- dir: interactForLocalDirectory,
15
- registry_url: interactForRegistryUrl,
16
- runtime: interactForRuntime,
17
- package_release_id: interactForPackageReleaseId,
18
- package_name: interactForPackageName,
19
- package_name_with_version: interactForPackageNameWithVersion,
20
- package_example_id: interactForPackageExampleId,
21
- }
@@ -1,58 +0,0 @@
1
- import { ParamHandler } from "./param-handler-type"
2
- import * as fs from "fs/promises"
3
-
4
- export const interactForLocalDirectory: ParamHandler = async ({ prompts }) => {
5
- const { selectionMode } = await prompts({
6
- type: "select",
7
- name: "selectionMode",
8
- message: "Select a directory",
9
- choices: [
10
- { title: "Manually Enter Path", value: "manual" },
11
- { title: "Browse for Directory", value: "browse" },
12
- ],
13
- })
14
-
15
- if (selectionMode === "manual") {
16
- const { manualPath } = await prompts({
17
- type: "text",
18
- name: "manualPath",
19
- message: "Enter the path to the directory",
20
- })
21
- return manualPath
22
- }
23
-
24
- let currentDirectory = "."
25
- while (true) {
26
- const files = await fs.readdir(currentDirectory)
27
- const dirChoices = files
28
- .filter((d) => !d.includes("."))
29
- .map((file) => ({ title: file, value: file }))
30
- const { selectedDir } = await prompts({
31
- type: "autocomplete",
32
- name: "selectedDir",
33
- message: "Select a directory",
34
- initial: "__select__",
35
- choices: [
36
- { title: ".. (Go Up)", value: ".." },
37
- { title: `["${currentDirectory}"]`, value: "__select__" },
38
- ...dirChoices,
39
- ],
40
- })
41
- if (selectedDir === "..") {
42
- // Go up one directory
43
- const lastIndex = currentDirectory.lastIndexOf("/")
44
- currentDirectory = currentDirectory.substring(0, lastIndex)
45
- } else if (selectedDir === "__select__") {
46
- return currentDirectory
47
- } else {
48
- // Check if selectedFile is a file or directory
49
- const stats = await fs.stat(`${currentDirectory}/${selectedDir}`)
50
- if (stats.isFile()) {
51
- throw new Error("Selected file is a file, not a directory")
52
- } else {
53
- // Go into the selected directory
54
- currentDirectory = `${currentDirectory}/${selectedDir}`
55
- }
56
- }
57
- }
58
- }
@@ -1,59 +0,0 @@
1
- import { ParamHandler } from "./param-handler-type"
2
- import * as fs from "fs/promises"
3
-
4
- // Use prompts to allow searching for a file
5
- // 1. Show a prompt with two options
6
- // - "Manually Enter Path"
7
- // - "Browse for File"
8
- // 2. If Browse for File is selected, show all the files in the current
9
- // directory with the "autocomplete" prompts type, then allow the user
10
- // to select a file or directory
11
- export const interactForLocalFile: ParamHandler = async ({ prompts }) => {
12
- const { selectionMode } = await prompts({
13
- type: "select",
14
- name: "selectionMode",
15
- message: "Select a file",
16
- choices: [
17
- { title: "Manually Enter Path", value: "manual" },
18
- { title: "Browse for File", value: "browse" },
19
- ],
20
- })
21
-
22
- if (selectionMode === "manual") {
23
- const { manualPath } = await prompts({
24
- type: "text",
25
- name: "manualPath",
26
- message: "Enter the path to the file",
27
- })
28
- return manualPath
29
- }
30
-
31
- let currentDirectory = "."
32
- while (true) {
33
- const files = await fs.readdir(currentDirectory)
34
- const { selectedFile } = await prompts({
35
- type: "autocomplete",
36
- name: "selectedFile",
37
- message: "Select a file or directory",
38
- choices: [
39
- { title: ".. (Go Up)", value: ".." },
40
- ...files.map((file) => ({ title: file, value: file })),
41
- ],
42
- })
43
- if (selectedFile === "..") {
44
- // Go up one directory
45
- const lastIndex = currentDirectory.lastIndexOf("/")
46
- currentDirectory = currentDirectory.substring(0, lastIndex)
47
- } else {
48
- // Check if selectedFile is a file or directory
49
- const stats = await fs.stat(`${currentDirectory}/${selectedFile}`)
50
- if (stats.isFile()) {
51
- // Break out of the loop and return the selected file
52
- return `${currentDirectory}/${selectedFile}`
53
- } else {
54
- // Go into the selected directory
55
- currentDirectory = `${currentDirectory}/${selectedFile}`
56
- }
57
- }
58
- }
59
- }
@@ -1,25 +0,0 @@
1
- import { interactForPackageReleaseId } from "./interact-for-package-release-id"
2
- import { ParamHandler } from "./param-handler-type"
3
-
4
- export const interactForPackageExampleId: ParamHandler = async (params) => {
5
- const { prompts, ctx } = params
6
- const package_release_id = await interactForPackageReleaseId(params)
7
-
8
- const package_examples = await ctx.axios
9
- .post("/package_examples/list", {
10
- package_release_id,
11
- })
12
- .then((r) => r.data.package_examples)
13
-
14
- const { package_example_id } = await prompts({
15
- type: "autocomplete",
16
- name: "package_example_id",
17
- message: "Select a package example",
18
- choices: package_examples.map((p: any) => ({
19
- title: `${p.file_path} (${p.export_name})`,
20
- value: p.package_example_id,
21
- })),
22
- })
23
-
24
- return package_example_id
25
- }
@@ -1,63 +0,0 @@
1
- import { ParamHandler } from "./param-handler-type"
2
-
3
- export const interactForPackageNameWithVersion: ParamHandler = async ({
4
- prompts,
5
- ctx,
6
- }) => {
7
- // Find all package names by this user
8
- const myPackages: Array<{ name: string; latest_version: string }> =
9
- await ctx.axios
10
- .post("/packages/list", {
11
- is_writable: true,
12
- })
13
- .then((r) => r.data.packages)
14
-
15
- // Autocomplete prompts with all packages, first option is "Enter Manually"
16
- const { selectedPackage } = await prompts({
17
- type: "autocomplete",
18
- name: "selectedPackage",
19
- message: "Select a package",
20
- choices: [
21
- {
22
- title: "Enter Manually",
23
- value: null,
24
- },
25
- ...myPackages.flatMap((p) => [
26
- {
27
- title: `${p.name}@${p.latest_version}`,
28
- value: `${p.name}@${p.latest_version}`,
29
- },
30
- {
31
- title: `${p.name}@...`,
32
- value: `${p.name}@...`,
33
- },
34
- ]),
35
- ],
36
- })
37
-
38
- if (selectedPackage.endsWith("@...")) {
39
- // TODO Poll for all versions available
40
-
41
- const { version } = await prompts({
42
- type: "text",
43
- name: "version",
44
- message: "Enter the version",
45
- })
46
-
47
- return selectedPackage.replace("@...", `@${version}`)
48
- }
49
-
50
- if (selectedPackage === "Enter Manually") {
51
- const { packageName } = await prompts({
52
- type: "text",
53
- name: "packageName",
54
- message: "Enter the package name",
55
- })
56
-
57
- return packageName
58
- }
59
-
60
- // TODO cache recently selected packages
61
-
62
- return selectedPackage
63
- }
@@ -1,45 +0,0 @@
1
- import { ParamHandler } from "./param-handler-type"
2
- import * as fs from "fs/promises"
3
-
4
- export const interactForPackageName: ParamHandler = async ({
5
- prompts,
6
- ctx,
7
- }) => {
8
- // Find all package names by this user
9
- const myPackages: Array<{ name: string }> = await ctx.axios
10
- .post("/packages/list", {
11
- is_writable: true,
12
- })
13
- .then((r) => r.data.packages)
14
-
15
- // Autocomplete prompts with all packages, first option is "Enter Manually"
16
- const { selectedPackage } = await prompts({
17
- type: "autocomplete",
18
- name: "selectedPackage",
19
- message: "Select a package",
20
- choices: [
21
- {
22
- title: "Enter Manually",
23
- value: null,
24
- },
25
- ...myPackages.map((p) => ({
26
- title: p.name,
27
- value: p.name,
28
- })),
29
- ],
30
- })
31
-
32
- if (selectedPackage === "Enter Manually") {
33
- const { packageName } = await prompts({
34
- type: "text",
35
- name: "packageName",
36
- message: "Enter the package name",
37
- })
38
-
39
- return packageName
40
- }
41
-
42
- // TODO cache recently selected packages
43
-
44
- return selectedPackage
45
- }
@@ -1,15 +0,0 @@
1
- import { interactForPackageNameWithVersion } from "./interact-for-package-name-with-version"
2
- import { ParamHandler } from "./param-handler-type"
3
-
4
- export const interactForPackageReleaseId: ParamHandler = async (params) => {
5
- const { ctx, prompts } = params
6
-
7
- const package_name_with_version =
8
- await interactForPackageNameWithVersion(params)
9
-
10
- return await ctx.axios
11
- .post("/package_releases/get", {
12
- package_name_with_version,
13
- })
14
- .then((r) => r.data.package_release.package_release_id)
15
- }