@tscircuit/cli 0.0.145 → 0.0.162

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 (203) hide show
  1. package/.github/workflows/formatbot.yml +1 -1
  2. package/.github/workflows/release.yml +6 -1
  3. package/.github/workflows/test.yml +2 -2
  4. package/.github/workflows/typecheck.yml +29 -0
  5. package/DEVELOPMENT.md +4 -1
  6. package/README.md +2 -6
  7. package/{dev-server-api/src → api}/db/generic-json-level.ts +2 -5
  8. package/{dev-server-api/src → api/lib}/middlewares/with-db.ts +2 -2
  9. package/{dev-server-api → api}/routes/api/db/download.ts +1 -1
  10. package/{dev-server-api → api}/routes/api/dev_package_examples/create.ts +1 -1
  11. package/{dev-server-api → api}/routes/api/dev_package_examples/get.ts +2 -2
  12. package/{dev-server-api → api}/routes/api/dev_package_examples/list.ts +1 -1
  13. package/{dev-server-api → api}/routes/api/dev_package_examples/update.ts +3 -3
  14. package/{dev-server-api → api}/routes/api/dev_server/reset.ts +1 -1
  15. package/{dev-server-api → api}/routes/api/export_files/create.ts +2 -6
  16. package/{dev-server-api → api}/routes/api/export_files/download.ts +1 -3
  17. package/{dev-server-api → api}/routes/api/export_requests/create.ts +3 -4
  18. package/{dev-server-api → api}/routes/api/export_requests/get.ts +3 -6
  19. package/{dev-server-api → api}/routes/api/export_requests/list.ts +2 -3
  20. package/{dev-server-api → api}/routes/api/export_requests/update.ts +3 -5
  21. package/{dev-server-api/routes → api/routes/api}/health.ts +1 -1
  22. package/{dev-server-api → api}/routes/api/package_info/create.ts +1 -1
  23. package/{dev-server-api → api}/routes/api/package_info/get.ts +3 -2
  24. package/{dev-server-api/routes/api → api/routes}/health.ts +1 -1
  25. package/{dev-server-api → api}/routes/index.ts +1 -1
  26. package/{dev-server-api → api}/server.ts +1 -1
  27. package/api/static-routes.ts +24 -0
  28. package/{dev-server-api → api}/tests/fixtures/get-test-server.ts +2 -1
  29. package/api/tests/fixtures/start-server.ts +41 -0
  30. package/{dev-server-api → api}/tests/routes/dev_package_examples/create.test.ts +1 -1
  31. package/{dev-server-api → api}/tests/routes/dev_package_examples/get.test.ts +1 -1
  32. package/{dev-server-api → api}/tests/routes/dev_package_examples/list.test.ts +1 -1
  33. package/{dev-server-api → api}/tests/routes/dev_package_examples/update.test.ts +1 -1
  34. package/{dev-server-api → api}/tests/routes/export_files/create.test.ts +1 -1
  35. package/{dev-server-api → api}/tests/routes/export_files/download.test.ts +1 -1
  36. package/{dev-server-api → api}/tests/routes/export_requests/create.test.ts +1 -1
  37. package/{dev-server-api → api}/tests/routes/export_requests/get.test.ts +1 -1
  38. package/{dev-server-api → api}/tests/routes/export_requests/list.test.ts +1 -1
  39. package/{dev-server-api → api}/tests/routes/export_requests/update.test.ts +1 -1
  40. package/biome.json +8 -3
  41. package/bun.lockb +0 -0
  42. package/{lib → cli/lib}/cmd-fns/add.ts +1 -1
  43. package/{lib → cli/lib}/cmd-fns/dev/dev-server-request-handler.ts +2 -2
  44. package/{lib → cli/lib}/cmd-fns/dev/fulfill-export-requests.ts +13 -13
  45. package/{lib → cli/lib}/cmd-fns/dev/index.ts +1 -1
  46. package/{lib → cli/lib}/cmd-fns/dev/soupify-and-upload-example-file.ts +3 -2
  47. package/{lib → cli/lib}/cmd-fns/dev/start-edit-event-watcher.ts +4 -4
  48. package/{lib → cli/lib}/cmd-fns/dev/start-export-request-watcher.ts +1 -1
  49. package/{lib → cli/lib}/cmd-fns/dev/start-fs-watcher.ts +2 -1
  50. package/{lib → cli/lib}/cmd-fns/dev/upload-examples-from-directory.ts +3 -2
  51. package/{lib → cli/lib}/cmd-fns/export-gerbers.ts +1 -1
  52. package/cli/lib/cmd-fns/go.ts +14 -0
  53. package/{lib → cli/lib}/cmd-fns/index.ts +2 -0
  54. package/{lib → cli/lib}/cmd-fns/init/create-or-modify-npmrc.ts +1 -1
  55. package/{lib → cli/lib}/cmd-fns/init/get-generated-npmrc.ts +1 -1
  56. package/{lib → cli/lib}/cmd-fns/init/index.ts +1 -1
  57. package/{lib → cli/lib}/cmd-fns/install.ts +1 -1
  58. package/{lib → cli/lib}/cmd-fns/lint.ts +1 -1
  59. package/{lib → cli/lib}/cmd-fns/open.ts +1 -1
  60. package/{lib → cli/lib}/cmd-fns/package-examples-create.ts +1 -1
  61. package/{lib → cli/lib}/cmd-fns/publish/index.ts +1 -1
  62. package/{lib → cli/lib}/cmd-fns/remove.ts +1 -1
  63. package/cli/lib/cmd-fns/render.ts +45 -0
  64. package/{lib → cli/lib}/cmd-fns/soupify.ts +1 -1
  65. package/{lib → cli/lib}/cmd-fns/uninstall.ts +1 -1
  66. package/{lib → cli/lib}/cmd-fns/version.ts +6 -7
  67. package/{lib → cli/lib}/export-fns/export-bom-csv.ts +1 -1
  68. package/{lib → cli/lib}/export-fns/export-gerbers.ts +1 -1
  69. package/{lib → cli/lib}/export-fns/export-pnp-csv.ts +1 -1
  70. package/{lib → cli/lib}/get-program.ts +20 -4
  71. package/{lib → cli/lib}/param-handlers/param-handler-type.ts +1 -1
  72. package/{lib → cli/lib}/util/app-context.ts +1 -1
  73. package/{lib → cli/lib}/util/create-context-and-run-program.ts +4 -4
  74. package/{lib → cli/lib}/util/get-all-package-files.ts +1 -1
  75. package/{tests → cli/tests}/open.test.ts +2 -1
  76. package/{tests → cli/tests}/soupify.test.ts +1 -1
  77. package/dist/cli.js +302 -308
  78. package/example-project/package.json +2 -11
  79. package/{dev-server-frontend/src → frontend}/components/command-k.tsx +1 -1
  80. package/{dev-server-frontend/src → frontend}/components/dialogs/generic-export-dialog.tsx +3 -7
  81. package/{dev-server-frontend/src → frontend}/components/dialogs/gerber-export-dialog.tsx +2 -2
  82. package/{dev-server-frontend/src → frontend}/components/select-example-search.tsx +6 -6
  83. package/{dev-server-frontend/src → frontend}/components/ui/alert-dialog.tsx +2 -2
  84. package/{dev-server-frontend/src → frontend}/components/ui/alert.tsx +1 -1
  85. package/{dev-server-frontend/src → frontend}/components/ui/breadcrumb.tsx +1 -1
  86. package/{dev-server-frontend/src → frontend}/components/ui/button.tsx +1 -1
  87. package/{dev-server-frontend/src → frontend}/components/ui/card.tsx +1 -1
  88. package/{dev-server-frontend/src → frontend}/components/ui/command.tsx +2 -2
  89. package/{dev-server-frontend/src → frontend}/components/ui/context-menu.tsx +1 -1
  90. package/{dev-server-frontend/src → frontend}/components/ui/dialog.tsx +1 -1
  91. package/{dev-server-frontend/src → frontend}/components/ui/menubar.tsx +1 -1
  92. package/{dev-server-frontend/src → frontend}/components/ui/navigation-menu.tsx +1 -1
  93. package/{dev-server-frontend/src → frontend}/components/ui/popover.tsx +1 -1
  94. package/{dev-server-frontend/src → frontend}/components/ui/select.tsx +1 -1
  95. package/{dev-server-frontend/src → frontend}/components/ui/tabs.tsx +1 -1
  96. package/{dev-server-frontend/src → frontend}/components/ui/toggle-group.tsx +2 -2
  97. package/{dev-server-frontend/src → frontend}/components/ui/toggle.tsx +1 -1
  98. package/{dev-server-frontend/src → frontend}/components/ui/tooltip.tsx +1 -1
  99. package/{dev-server-frontend → frontend}/index.html +1 -1
  100. package/{dev-server-frontend/src → frontend}/main.tsx +1 -1
  101. package/{dev-server-frontend → frontend}/tailwind.config.js +3 -6
  102. package/frontend/views/App.tsx +22 -0
  103. package/{dev-server-frontend/src → frontend/views}/Header.tsx +5 -5
  104. package/{dev-server-frontend/src → frontend/views}/HeaderMenu.tsx +50 -17
  105. package/{dev-server-frontend/src/ExampleContentView.tsx → frontend/views/MainContentView.tsx} +5 -5
  106. package/frontend/vite.config.ts +50 -0
  107. package/package.json +55 -18
  108. package/scripts/build-cli.ts +12 -0
  109. package/tsconfig.json +5 -96
  110. package/.github/workflows/server-tests.yml +0 -31
  111. package/build-cli.ts +0 -14
  112. package/dev-server-api/bun.lockb +0 -0
  113. package/dev-server-api/edgespec.config.ts +0 -4
  114. package/dev-server-api/package.json +0 -23
  115. package/dev-server-api/src/db/create-schema.ts +0 -54
  116. package/dev-server-api/src/lib/public-mapping/public-map-export-file.ts +0 -17
  117. package/dev-server-api/src/lib/public-mapping/public-map-export-request.ts +0 -23
  118. package/dev-server-api/static-routes.ts +0 -24
  119. package/dev-server-api/tests/fixtures/start-server.ts +0 -20
  120. package/dev-server-api/tsconfig.json +0 -28
  121. package/dev-server-frontend/.eslintrc.cjs +0 -20
  122. package/dev-server-frontend/package-lock.json +0 -8970
  123. package/dev-server-frontend/package.json +0 -70
  124. package/dev-server-frontend/postcss.config.js +0 -6
  125. package/dev-server-frontend/src/App.tsx +0 -22
  126. package/dev-server-frontend/tsconfig.json +0 -29
  127. package/dev-server-frontend/tsconfig.node.json +0 -13
  128. package/dev-server-frontend/vite.config.ts +0 -23
  129. package/example-project/package-lock.json +0 -609
  130. /package/{dev-server-api → api}/README.md +0 -0
  131. /package/{dev-server-api/src → api}/db/get-db.ts +0 -0
  132. /package/{dev-server-api/src → api}/db/schema.ts +0 -0
  133. /package/{dev-server-api/src → api}/db/zod-level-db.ts +0 -0
  134. /package/{dev-server-api → api}/index.ts +0 -0
  135. /package/{dev-server-api/src → api/lib}/middlewares/with-debug-request-logging.ts +0 -0
  136. /package/{dev-server-api/src → api/lib}/middlewares/with-error-response.ts +0 -0
  137. /package/{dev-server-api/src → api/lib}/with-winter-spec.ts +0 -0
  138. /package/{dev-server-api/src → api}/lib/zod/export_parameters.ts +0 -0
  139. /package/{dev-server-api → api}/tests/routes/health.test.ts +0 -0
  140. /package/{cli.ts → cli/cli.ts} +0 -0
  141. /package/{lib → cli/lib}/cmd-fns/auth-login.ts +0 -0
  142. /package/{lib → cli/lib}/cmd-fns/auth-logout.ts +0 -0
  143. /package/{lib → cli/lib}/cmd-fns/auth-sessions-create.ts +0 -0
  144. /package/{lib → cli/lib}/cmd-fns/auth-sessions-get.ts +0 -0
  145. /package/{lib → cli/lib}/cmd-fns/auth-sessions-list.ts +0 -0
  146. /package/{lib → cli/lib}/cmd-fns/config-clear.ts +0 -0
  147. /package/{lib → cli/lib}/cmd-fns/config-print-config.ts +0 -0
  148. /package/{lib → cli/lib}/cmd-fns/config-reveal-location.ts +0 -0
  149. /package/{lib → cli/lib}/cmd-fns/config-set-log-requests.ts +0 -0
  150. /package/{lib → cli/lib}/cmd-fns/config-set-registry.ts +0 -0
  151. /package/{lib → cli/lib}/cmd-fns/config-set-runtime.ts +0 -0
  152. /package/{lib → cli/lib}/cmd-fns/config-set-session.ts +0 -0
  153. /package/{lib → cli/lib}/cmd-fns/dev/check-if-initialized.ts +0 -0
  154. /package/{lib → cli/lib}/cmd-fns/dev/derive-selector-from-pcb-component-id.ts +0 -0
  155. /package/{lib → cli/lib}/cmd-fns/dev/find-available-port.ts +0 -0
  156. /package/{lib → cli/lib}/cmd-fns/dev/get-dev-server-axios.ts +0 -0
  157. /package/{lib → cli/lib}/cmd-fns/dev/infer-export-name-from-source.ts +0 -0
  158. /package/{lib → cli/lib}/cmd-fns/dev/mark-all-examples-loading.ts +0 -0
  159. /package/{lib → cli/lib}/cmd-fns/dev/start-dev-server.ts +0 -0
  160. /package/{lib → cli/lib}/cmd-fns/dev-server-fulfill-export-requests.ts +0 -0
  161. /package/{lib → cli/lib}/cmd-fns/dev-server-upload.ts +0 -0
  162. /package/{lib → cli/lib}/cmd-fns/init/get-generated-readme.ts +0 -0
  163. /package/{lib → cli/lib}/cmd-fns/init/get-generated-tsconfig.ts +0 -0
  164. /package/{lib → cli/lib}/cmd-fns/package-examples-get.ts +0 -0
  165. /package/{lib → cli/lib}/cmd-fns/package-examples-list.ts +0 -0
  166. /package/{lib → cli/lib}/cmd-fns/package-files-create.ts +0 -0
  167. /package/{lib → cli/lib}/cmd-fns/package-files-download.ts +0 -0
  168. /package/{lib → cli/lib}/cmd-fns/package-files-get.ts +0 -0
  169. /package/{lib → cli/lib}/cmd-fns/package-files-list.ts +0 -0
  170. /package/{lib → cli/lib}/cmd-fns/package-files-upload-directory.ts +0 -0
  171. /package/{lib → cli/lib}/cmd-fns/package-releases-create.ts +0 -0
  172. /package/{lib → cli/lib}/cmd-fns/package-releases-get.ts +0 -0
  173. /package/{lib → cli/lib}/cmd-fns/package-releases-list.ts +0 -0
  174. /package/{lib → cli/lib}/cmd-fns/package-releases-update.ts +0 -0
  175. /package/{lib → cli/lib}/cmd-fns/packages-create.ts +0 -0
  176. /package/{lib → cli/lib}/cmd-fns/packages-get.ts +0 -0
  177. /package/{lib → cli/lib}/cmd-fns/packages-list.ts +0 -0
  178. /package/{lib → cli/lib}/create-config-manager.ts +0 -0
  179. /package/{lib → cli/lib}/param-handlers/index.ts +0 -0
  180. /package/{lib → cli/lib}/param-handlers/interact-for-local-directory.ts +0 -0
  181. /package/{lib → cli/lib}/param-handlers/interact-for-local-file.ts +0 -0
  182. /package/{lib → cli/lib}/param-handlers/interact-for-package-example-id.ts +0 -0
  183. /package/{lib → cli/lib}/param-handlers/interact-for-package-name-with-version.ts +0 -0
  184. /package/{lib → cli/lib}/param-handlers/interact-for-package-name.ts +0 -0
  185. /package/{lib → cli/lib}/param-handlers/interact-for-package-release-id.ts +0 -0
  186. /package/{lib → cli/lib}/param-handlers/interact-for-registry-url.ts +0 -0
  187. /package/{lib → cli/lib}/param-handlers/interact-for-runtime.ts +0 -0
  188. /package/{lib → cli/lib}/posthog.ts +0 -0
  189. /package/{lib → cli/lib}/soupify.ts +0 -0
  190. /package/{lib → cli/lib}/util/lint-project.ts +0 -0
  191. /package/{tests → cli/tests}/init.test.ts +0 -0
  192. /package/example-project/examples/{basic-bug.tsx → basic-chip.tsx} +0 -0
  193. /package/{dev-server-frontend → frontend}/README.md +0 -0
  194. /package/{dev-server-frontend → frontend}/bun.lockb +0 -0
  195. /package/{dev-server-frontend/src → frontend}/components/global-context-providers.tsx +0 -0
  196. /package/{dev-server-frontend → frontend}/components.json +0 -0
  197. /package/{dev-server-frontend/src → frontend}/hooks/toast-if-api-not-connected.ts +0 -0
  198. /package/{dev-server-frontend/src → frontend}/hooks/use-active-dev-package-example-lite.ts +0 -0
  199. /package/{dev-server-frontend/src → frontend}/hooks/use-dev-package-examples.tsx +0 -0
  200. /package/{dev-server-frontend/src → frontend}/hooks/use-global-store.ts +0 -0
  201. /package/{dev-server-frontend/src → frontend}/index.css +0 -0
  202. /package/{dev-server-frontend/src → frontend}/lib/utils.ts +0 -0
  203. /package/{dev-server-frontend/src → frontend}/vite-env.d.ts +0 -0
@@ -1,7 +1,7 @@
1
- import { DevPackageExample } from "@server/db/get-db"
2
- import { AxiosInstance } from "axios"
1
+ import type { DevPackageExample } from "api/db/schema"
2
+ import type { AxiosInstance } from "axios"
3
3
  import kleur from "kleur"
4
- import { AppContext } from "lib/util/app-context"
4
+ import { AppContext } from "cli/lib/util/app-context"
5
5
  import fg from "fast-glob"
6
6
  import fs from "fs"
7
7
  import { Project, ts } from "ts-morph"
@@ -51,7 +51,7 @@ export const startEditEventWatcher = async (
51
51
  )
52
52
 
53
53
  last_edit_event_update_time[dev_package_example_id] =
54
- dev_package_example.edit_events_last_updated_at // TODO last_edit_event_updated_at
54
+ dev_package_example.edit_events_last_updated_at! // TODO last_edit_event_updated_at
55
55
 
56
56
  console.log(kleur.gray(` getting new edit events...`))
57
57
 
@@ -1,7 +1,7 @@
1
1
  import { AxiosInstance } from "axios"
2
2
  import kleur from "kleur"
3
3
  import { fulfillExportRequests } from "./fulfill-export-requests"
4
- import { AppContext } from "lib/util/app-context"
4
+ import { AppContext } from "cli/lib/util/app-context"
5
5
 
6
6
  export const startExportRequestWatcher = async (
7
7
  {
@@ -2,6 +2,7 @@ import { AxiosInstance } from "axios"
2
2
  import chokidar from "chokidar"
3
3
  import { uploadExamplesFromDirectory } from "./upload-examples-from-directory"
4
4
  import kleur from "kleur"
5
+ import { AppContext } from "cli/lib/util/app-context"
5
6
 
6
7
  export const startFsWatcher = async (
7
8
  {
@@ -11,7 +12,7 @@ export const startFsWatcher = async (
11
12
  cwd: string
12
13
  devServerAxios: AxiosInstance
13
14
  },
14
- ctx: { runtime: "node" | "bun" },
15
+ ctx: Pick<AppContext, "runtime" | "params">,
15
16
  ) => {
16
17
  const watcher = chokidar.watch([`${cwd}/**/*.tsx`, `${cwd}/**/*.ts`], {
17
18
  ignored: /node_modules/,
@@ -2,10 +2,11 @@ import kleur from "kleur"
2
2
  import { join as joinPath } from "path"
3
3
  import { AxiosInstance } from "axios"
4
4
  import { readdirSync, readFileSync } from "fs"
5
- import { soupify } from "lib/soupify"
5
+ import { soupify } from "cli/lib/soupify"
6
6
  import { soupifyAndUploadExampleFile } from "./soupify-and-upload-example-file"
7
7
  import { markAllExamplesLoading } from "./mark-all-examples-loading"
8
8
  import { readdir } from "fs/promises"
9
+ import { AppContext } from "cli/lib/util/app-context"
9
10
 
10
11
  export const uploadExamplesFromDirectory = async (
11
12
  {
@@ -15,7 +16,7 @@ export const uploadExamplesFromDirectory = async (
15
16
  cwd: string
16
17
  devServerAxios: AxiosInstance
17
18
  },
18
- ctx: { runtime: "node" | "bun" },
19
+ ctx: Pick<AppContext, "runtime" | "params">,
19
20
  ) => {
20
21
  const examplesDir = joinPath(cwd, "examples")
21
22
  const exampleFileNames = await readdir(examplesDir).catch((e) => {
@@ -1,6 +1,6 @@
1
1
  import { AppContext } from "../util/app-context"
2
2
  import { z } from "zod"
3
- import { exportGerbersToFile } from "lib/export-fns/export-gerbers"
3
+ import { exportGerbersToFile } from "cli/lib/export-fns/export-gerbers"
4
4
 
5
5
  export const exportGerbersCmd = async (ctx: AppContext, args: any) => {
6
6
  const params = z
@@ -0,0 +1,14 @@
1
+ import kleur from "kleur"
2
+ import type { AppContext } from "cli/lib/util/app-context"
3
+ import open from "open"
4
+
5
+ export const goCmd = async (ctx: AppContext, args: any) => {
6
+ const tutorialUrl = "https://docs.tscircuit.com/quickstart"
7
+
8
+ console.log(
9
+ kleur.cyan(
10
+ "Opening the TSCircuit Getting Started tutorial in your browser...",
11
+ ),
12
+ )
13
+ await open(tutorialUrl)
14
+ }
@@ -29,6 +29,7 @@ export { soupifyCmd as soupify } from "./soupify"
29
29
  export { devCmd as dev } from "./dev"
30
30
  export { initCmd as init } from "./init"
31
31
  export { addCmd as add } from "./add"
32
+ export { goCmd as go } from "./go"
32
33
  export { removeCmd as remove } from "./remove"
33
34
  export { installCmd as install } from "./install"
34
35
  export { uninstallCmd as uninstall } from "./uninstall"
@@ -39,3 +40,4 @@ export { versionCmd as version } from "./version"
39
40
  export { exportGerbersCmd as exportGerbers } from "./export-gerbers"
40
41
  export { devServerFulfillExportRequests } from "./dev-server-fulfill-export-requests"
41
42
  export { lintCmd as lint } from "./lint"
43
+ export { renderCmd as render } from "./render"
@@ -2,7 +2,7 @@ import { existsSync, writeFileSync } from "fs"
2
2
  import kleur from "kleur"
3
3
  import * as Path from "path"
4
4
  import { getGeneratedNpmrc } from "./get-generated-npmrc"
5
- import { AppContext } from "lib/util/app-context"
5
+ import { AppContext } from "cli/lib/util/app-context"
6
6
 
7
7
  export const createOrModifyNpmrc = async (
8
8
  { quiet = true }: { quiet?: boolean },
@@ -1,4 +1,4 @@
1
- import { AppContext } from "lib/util/app-context"
1
+ import { AppContext } from "cli/lib/util/app-context"
2
2
 
3
3
  export const getGeneratedNpmrc = (ctx: AppContext) =>
4
4
  `
@@ -167,7 +167,7 @@ export default {
167
167
  writeFileSync(
168
168
  Path.join("examples", "MyExample.tsx"),
169
169
  `
170
- import { MyCircuit } from "lib/MyCircuit"
170
+ import { MyCircuit } from "cli/lib/MyCircuit"
171
171
 
172
172
  export const MyExample = () => (
173
173
  <board width="40mm" height="40mm" pcbCenterX={0} pcbCenterY={0}>
@@ -1,5 +1,5 @@
1
1
  import kleur from "kleur"
2
- import { AppContext } from "lib/util/app-context"
2
+ import { AppContext } from "cli/lib/util/app-context"
3
3
  import { z } from "zod"
4
4
  import { createOrModifyNpmrc } from "./init/create-or-modify-npmrc"
5
5
  import $ from "dax-sh"
@@ -1,4 +1,4 @@
1
- import { AppContext } from "lib/util/app-context"
1
+ import { AppContext } from "cli/lib/util/app-context"
2
2
  import { z } from "zod"
3
3
  import kleur from "kleur"
4
4
  import { lintProject } from "../util/lint-project"
@@ -1,6 +1,6 @@
1
1
  import { existsSync, readFileSync } from "fs"
2
2
  import kleur from "kleur"
3
- import { AppContext } from "lib/util/app-context"
3
+ import { AppContext } from "cli/lib/util/app-context"
4
4
  import * as Path from "path"
5
5
  import open from "open"
6
6
 
@@ -1,4 +1,4 @@
1
- import { soupify } from "lib/soupify"
1
+ import { soupify } from "cli/lib/soupify"
2
2
  import { AppContext } from "../util/app-context"
3
3
  import { z } from "zod"
4
4
  import fs from "fs"
@@ -4,7 +4,7 @@ import { AppContext } from "../../util/app-context"
4
4
  import * as Path from "path"
5
5
  import * as fs from "fs/promises"
6
6
  import { existsSync, readFileSync } from "fs"
7
- import { getAllPackageFiles } from "lib/util/get-all-package-files"
7
+ import { getAllPackageFiles } from "cli/lib/util/get-all-package-files"
8
8
  import prompts from "prompts"
9
9
  import { getGeneratedReadme } from "../init/get-generated-readme"
10
10
  import { soupify } from "../../soupify"
@@ -1,5 +1,5 @@
1
1
  import kleur from "kleur"
2
- import { AppContext } from "lib/util/app-context"
2
+ import { AppContext } from "cli/lib/util/app-context"
3
3
  import { z } from "zod"
4
4
  import { createOrModifyNpmrc } from "./init/create-or-modify-npmrc"
5
5
  import $ from "dax-sh"
@@ -0,0 +1,45 @@
1
+ import { circuitToPng } from "circuit-to-png"
2
+ import fs from "fs"
3
+ import { soupify } from "cli/lib/soupify"
4
+ import type { AppContext } from "cli/lib/util/app-context"
5
+ import path from "path"
6
+
7
+ export const renderCmd = async (
8
+ ctx: AppContext,
9
+ args: {
10
+ input: string
11
+ pcb?: boolean
12
+ schematic?: boolean
13
+ output?: string
14
+ type?: string
15
+ },
16
+ ) => {
17
+ const inputFile = path.resolve(args.input)
18
+ let outputFile = args.output
19
+ const outputType =
20
+ args.type || path.extname(args.output || "").slice(1) || "png"
21
+
22
+ if (!outputFile) {
23
+ const inputBase = path.basename(inputFile, path.extname(inputFile))
24
+ outputFile = `${inputBase}.${outputType}`
25
+ }
26
+
27
+ if (!args.pcb && !args.schematic) {
28
+ console.error("Error: You must specify either --pcb or --schematic")
29
+ process.exit(1)
30
+ }
31
+
32
+ const viewType = args.pcb ? "pcb" : "schematic"
33
+
34
+ console.log(`Rendering ${viewType} view of ${inputFile} to ${outputFile}`)
35
+ const soup = await soupify(
36
+ {
37
+ filePath: inputFile,
38
+ },
39
+ ctx,
40
+ )
41
+
42
+ const soupBuffer = circuitToPng(soup, viewType)
43
+
44
+ fs.writeFileSync(outputFile, soupBuffer)
45
+ }
@@ -2,7 +2,7 @@ import { AppContext } from "../util/app-context"
2
2
  import { z } from "zod"
3
3
  import * as Path from "path"
4
4
  import { unlink } from "node:fs/promises"
5
- import { soupify } from "lib/soupify"
5
+ import { soupify } from "cli/lib/soupify"
6
6
  import { writeFileSync } from "fs"
7
7
 
8
8
  export const soupifyCmd = async (ctx: AppContext, args: any) => {
@@ -1,5 +1,5 @@
1
1
  import kleur from "kleur"
2
- import { AppContext } from "lib/util/app-context"
2
+ import { AppContext } from "cli/lib/util/app-context"
3
3
  import { z } from "zod"
4
4
  import { createOrModifyNpmrc } from "./init/create-or-modify-npmrc"
5
5
  import $ from "dax-sh"
@@ -1,6 +1,5 @@
1
- import { AppContext } from "lib/util/app-context"
2
- import cliPackageJson from "./../../package.json"
3
- import frontendPackageJson from "dev-server-frontend/package.json"
1
+ import type { AppContext } from "cli/lib/util/app-context"
2
+ import cliPackageJson from "package.json"
4
3
 
5
4
  export const versionCmd = async (ctx: AppContext, args: any) => {
6
5
  if (typeof global !== "undefined" && (global as any).TSCIRCUIT_VERSION) {
@@ -13,19 +12,19 @@ export const versionCmd = async (ctx: AppContext, args: any) => {
13
12
  table.push({ name: "@tscircuit/cli", current: cliPackageJson.version })
14
13
  table.push({
15
14
  name: "@tscircuit/react-fiber",
16
- current: cliPackageJson.dependencies["@tscircuit/react-fiber"],
15
+ current: cliPackageJson.devDependencies["@tscircuit/react-fiber"],
17
16
  })
18
17
  table.push({
19
18
  name: "@tscircuit/schematic-viewer",
20
- current: frontendPackageJson.dependencies["@tscircuit/schematic-viewer"],
19
+ current: cliPackageJson.devDependencies["@tscircuit/schematic-viewer"],
21
20
  })
22
21
  table.push({
23
22
  name: "@tscircuit/pcb-viewer",
24
- current: frontendPackageJson.dependencies["@tscircuit/pcb-viewer"],
23
+ current: cliPackageJson.devDependencies["@tscircuit/pcb-viewer"],
25
24
  })
26
25
  table.push({
27
26
  name: "@tscircuit/builder",
28
- current: cliPackageJson.dependencies["@tscircuit/builder"],
27
+ current: cliPackageJson.devDependencies["@tscircuit/builder"],
29
28
  })
30
29
 
31
30
  if (args.showLatest) {
@@ -1,5 +1,5 @@
1
1
  import { AppContext } from "../util/app-context"
2
- import { soupify } from "lib/soupify"
2
+ import { soupify } from "cli/lib/soupify"
3
3
  import { convertSoupToBomRows, convertBomRowsToCsv } from "@tscircuit/builder"
4
4
  import kleur from "kleur"
5
5
 
@@ -2,7 +2,7 @@ import { AppContext } from "../util/app-context"
2
2
  import { z } from "zod"
3
3
  import * as Path from "path"
4
4
  import { unlink } from "node:fs/promises"
5
- import { soupify } from "lib/soupify"
5
+ import { soupify } from "cli/lib/soupify"
6
6
  import * as fs from "fs"
7
7
  import {
8
8
  stringifyGerberCommandLayers,
@@ -2,7 +2,7 @@ import { AppContext } from "../util/app-context"
2
2
  import { z } from "zod"
3
3
  import * as Path from "path"
4
4
  import { unlink } from "node:fs/promises"
5
- import { soupify } from "lib/soupify"
5
+ import { soupify } from "cli/lib/soupify"
6
6
  import * as fs from "fs"
7
7
  import {
8
8
  stringifyGerberCommandLayers,
@@ -1,7 +1,6 @@
1
1
  import { Command } from "commander"
2
- import packageJson from "../package.json"
3
- import { AppContext } from "./util/app-context"
4
- import * as CMDFN from "lib/cmd-fns"
2
+ import * as CMDFN from "cli/lib/cmd-fns"
3
+ import type { AppContext } from "./util/app-context"
5
4
 
6
5
  export const getProgram = (ctx: AppContext) => {
7
6
  const cmd = new Command("tsci").description(
@@ -52,6 +51,21 @@ export const getProgram = (ctx: AppContext) => {
52
51
  .option("--fix", "Automatically fix problems")
53
52
  .action((args) => CMDFN.lint(ctx, args))
54
53
 
54
+ cmd
55
+ .command("go")
56
+ .description("Open browser to the TSCircuit Get Started tutorial")
57
+ .action((args) => CMDFN.go(ctx, args))
58
+
59
+ cmd
60
+ .command("render")
61
+ .description("Render circuit as image")
62
+ .requiredOption("--input <input>", "Input TypeScript file path")
63
+ .option("--pcb", "Render PCB view")
64
+ .option("--schematic", "Render schematic view")
65
+ .option("--output <output>", "Output file path")
66
+ .option("-t, --type <type>", "Output file type (png or svg)")
67
+ .action((args) => CMDFN.render(ctx, args))
68
+
55
69
  const authCmd = cmd.command("auth").description("Login/logout")
56
70
  authCmd
57
71
  .command("login")
@@ -327,7 +341,9 @@ export const getProgram = (ctx: AppContext) => {
327
341
 
328
342
  function recursiveUnhelp(cmd: Command) {
329
343
  cmd.helpCommand(false)
330
- cmd.commands.forEach((c) => recursiveUnhelp(c))
344
+ for (const c of cmd.commands) {
345
+ recursiveUnhelp(c)
346
+ }
331
347
  }
332
348
  recursiveUnhelp(cmd)
333
349
 
@@ -1,4 +1,4 @@
1
- import { AppContext } from "lib/util/app-context"
1
+ import { AppContext } from "cli/lib/util/app-context"
2
2
  import prompts from "prompts"
3
3
 
4
4
  export type ParamHandler = (params: {
@@ -1,6 +1,6 @@
1
1
  import { AxiosInstance } from "axios"
2
2
  import Configstore from "configstore"
3
- import { ContextConfigProps } from "lib/create-config-manager"
3
+ import { ContextConfigProps } from "cli/lib/create-config-manager"
4
4
 
5
5
  export type AppContext = {
6
6
  args: any
@@ -1,5 +1,5 @@
1
1
  import Configstore from "configstore"
2
- import { AppContext } from "./app-context"
2
+ import type { AppContext } from "./app-context"
3
3
  import minimist from "minimist"
4
4
  import _ from "lodash"
5
5
  import prompts from "prompts"
@@ -7,10 +7,10 @@ import { perfectCli } from "perfect-cli"
7
7
  import { getProgram } from "../get-program"
8
8
  import defaultAxios from "axios"
9
9
  import kleur from "kleur"
10
- import { PARAM_HANDLERS_BY_PARAM_NAME } from "lib/param-handlers"
11
- import { createConfigHandler } from "lib/create-config-manager"
10
+ import { PARAM_HANDLERS_BY_PARAM_NAME } from "cli/lib/param-handlers"
11
+ import { createConfigHandler } from "cli/lib/create-config-manager"
12
12
  import dargs from "dargs"
13
- import { versionCmd } from "lib/cmd-fns/version"
13
+ import { versionCmd } from "cli/lib/cmd-fns/version"
14
14
 
15
15
  export type CliArgs = {
16
16
  cmd: string[]
@@ -56,7 +56,7 @@ const ensureNodeModulesIgnored = async () => {
56
56
  if (!gitignore.includes("node_modules/")) {
57
57
  await fs.appendFile(gitignorePath, "\nnode_modules/\n")
58
58
  }
59
- } catch (err) {
59
+ } catch (err: any) {
60
60
  if (err.code === "ENOENT") {
61
61
  await fs.writeFile(gitignorePath, "node_modules/\n")
62
62
  } else {
@@ -1,7 +1,8 @@
1
1
  import { test, expect } from "bun:test"
2
2
  import { $ } from "bun"
3
3
 
4
- test("tsci open", async () => {
4
+ // This test annoyingly opens a browser window, unskip if you're testing it
5
+ test.skip("tsci open", async () => {
5
6
  const result = await $`bun cli.ts open -y --cwd ./example-project`.text()
6
7
  expect(result).toContain("http")
7
8
  expect(result).toContain("example-project")
@@ -3,7 +3,7 @@ import { $ } from "bun"
3
3
 
4
4
  test("soupify", async () => {
5
5
  const result =
6
- await $`bun cli.ts soupify -y --file ./example-project/examples/basic-bug.tsx`.text()
6
+ await $`bun cli/cli.ts soupify -y --file ./example-project/examples/basic-chip.tsx`.text()
7
7
 
8
8
  expect(result).toContain("10kohm")
9
9
  })