@tscircuit/cli 0.0.144 → 0.0.161

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 (207) hide show
  1. package/.github/workflows/formatbot.yml +41 -0
  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 +4 -7
  8. package/{dev-server-api/src → api}/db/zod-level-db.ts +9 -9
  9. package/{dev-server-api/src → api/lib}/middlewares/with-db.ts +2 -2
  10. package/{dev-server-api/src → api/lib}/middlewares/with-debug-request-logging.ts +1 -1
  11. package/{dev-server-api/src → api/lib}/middlewares/with-error-response.ts +2 -2
  12. package/{dev-server-api → api}/routes/api/db/download.ts +3 -3
  13. package/{dev-server-api → api}/routes/api/dev_package_examples/create.ts +1 -1
  14. package/{dev-server-api → api}/routes/api/dev_package_examples/get.ts +3 -3
  15. package/{dev-server-api → api}/routes/api/dev_package_examples/list.ts +3 -3
  16. package/{dev-server-api → api}/routes/api/dev_package_examples/update.ts +4 -4
  17. package/{dev-server-api → api}/routes/api/dev_server/reset.ts +1 -1
  18. package/{dev-server-api → api}/routes/api/export_files/create.ts +2 -6
  19. package/{dev-server-api → api}/routes/api/export_files/download.ts +1 -3
  20. package/{dev-server-api → api}/routes/api/export_requests/create.ts +3 -4
  21. package/{dev-server-api → api}/routes/api/export_requests/get.ts +5 -8
  22. package/{dev-server-api → api}/routes/api/export_requests/list.ts +2 -3
  23. package/{dev-server-api → api}/routes/api/export_requests/update.ts +3 -5
  24. package/{dev-server-api/routes → api/routes/api}/health.ts +1 -1
  25. package/{dev-server-api → api}/routes/api/package_info/create.ts +1 -1
  26. package/{dev-server-api → api}/routes/api/package_info/get.ts +3 -2
  27. package/{dev-server-api/routes/api → api/routes}/health.ts +1 -1
  28. package/{dev-server-api → api}/routes/index.ts +2 -2
  29. package/{dev-server-api → api}/server.ts +2 -2
  30. package/api/static-routes.ts +24 -0
  31. package/{dev-server-api → api}/tests/fixtures/get-test-server.ts +2 -1
  32. package/api/tests/fixtures/start-server.ts +41 -0
  33. package/{dev-server-api → api}/tests/routes/dev_package_examples/create.test.ts +2 -2
  34. package/{dev-server-api → api}/tests/routes/dev_package_examples/get.test.ts +2 -2
  35. package/{dev-server-api → api}/tests/routes/dev_package_examples/list.test.ts +2 -2
  36. package/{dev-server-api → api}/tests/routes/dev_package_examples/update.test.ts +3 -3
  37. package/{dev-server-api → api}/tests/routes/export_files/create.test.ts +1 -1
  38. package/{dev-server-api → api}/tests/routes/export_files/download.test.ts +3 -3
  39. package/{dev-server-api → api}/tests/routes/export_requests/create.test.ts +2 -2
  40. package/{dev-server-api → api}/tests/routes/export_requests/get.test.ts +2 -2
  41. package/{dev-server-api → api}/tests/routes/export_requests/list.test.ts +1 -1
  42. package/{dev-server-api → api}/tests/routes/export_requests/update.test.ts +1 -1
  43. package/biome.json +49 -0
  44. package/bun.lockb +0 -0
  45. package/{lib → cli/lib}/cmd-fns/add.ts +2 -2
  46. package/{lib → cli/lib}/cmd-fns/auth-login.ts +2 -2
  47. package/{lib → cli/lib}/cmd-fns/dev/check-if-initialized.ts +1 -1
  48. package/{lib → cli/lib}/cmd-fns/dev/derive-selector-from-pcb-component-id.ts +1 -1
  49. package/{lib → cli/lib}/cmd-fns/dev/dev-server-request-handler.ts +5 -5
  50. package/{lib → cli/lib}/cmd-fns/dev/find-available-port.ts +7 -5
  51. package/{lib → cli/lib}/cmd-fns/dev/fulfill-export-requests.ts +27 -27
  52. package/{lib → cli/lib}/cmd-fns/dev/get-dev-server-axios.ts +3 -3
  53. package/{lib → cli/lib}/cmd-fns/dev/index.ts +4 -4
  54. package/{lib → cli/lib}/cmd-fns/dev/infer-export-name-from-source.ts +2 -2
  55. package/{lib → cli/lib}/cmd-fns/dev/soupify-and-upload-example-file.ts +6 -5
  56. package/{lib → cli/lib}/cmd-fns/dev/start-edit-event-watcher.ts +41 -42
  57. package/{lib → cli/lib}/cmd-fns/dev/start-export-request-watcher.ts +3 -4
  58. package/{lib → cli/lib}/cmd-fns/dev/start-fs-watcher.ts +2 -1
  59. package/{lib → cli/lib}/cmd-fns/dev/upload-examples-from-directory.ts +4 -3
  60. package/{lib → cli/lib}/cmd-fns/dev-server-fulfill-export-requests.ts +3 -3
  61. package/{lib → cli/lib}/cmd-fns/dev-server-upload.ts +3 -3
  62. package/{lib → cli/lib}/cmd-fns/export-gerbers.ts +2 -2
  63. package/cli/lib/cmd-fns/go.ts +14 -0
  64. package/{lib → cli/lib}/cmd-fns/index.ts +2 -0
  65. package/{lib → cli/lib}/cmd-fns/init/create-or-modify-npmrc.ts +2 -2
  66. package/{lib → cli/lib}/cmd-fns/init/get-generated-npmrc.ts +1 -1
  67. package/{lib → cli/lib}/cmd-fns/init/index.ts +13 -9
  68. package/{lib → cli/lib}/cmd-fns/install.ts +1 -1
  69. package/{lib → cli/lib}/cmd-fns/lint.ts +16 -10
  70. package/{lib → cli/lib}/cmd-fns/open.ts +1 -1
  71. package/{lib → cli/lib}/cmd-fns/package-examples-create.ts +2 -2
  72. package/{lib → cli/lib}/cmd-fns/package-files-create.ts +1 -1
  73. package/{lib → cli/lib}/cmd-fns/package-files-upload-directory.ts +1 -1
  74. package/{lib → cli/lib}/cmd-fns/package-releases-create.ts +1 -1
  75. package/{lib → cli/lib}/cmd-fns/package-releases-list.ts +1 -1
  76. package/{lib → cli/lib}/cmd-fns/publish/index.ts +34 -34
  77. package/{lib → cli/lib}/cmd-fns/remove.ts +2 -2
  78. package/cli/lib/cmd-fns/render.ts +45 -0
  79. package/{lib → cli/lib}/cmd-fns/soupify.ts +2 -2
  80. package/{lib → cli/lib}/cmd-fns/uninstall.ts +1 -1
  81. package/{lib → cli/lib}/cmd-fns/version.ts +7 -8
  82. package/{lib → cli/lib}/create-config-manager.ts +1 -1
  83. package/{lib → cli/lib}/export-fns/export-bom-csv.ts +3 -3
  84. package/{lib → cli/lib}/export-fns/export-gerbers.ts +6 -6
  85. package/{lib → cli/lib}/export-fns/export-pnp-csv.ts +3 -3
  86. package/{lib → cli/lib}/get-program.ts +37 -21
  87. package/{lib → cli/lib}/param-handlers/interact-for-package-release-id.ts +2 -3
  88. package/{lib → cli/lib}/param-handlers/interact-for-runtime.ts +1 -1
  89. package/{lib → cli/lib}/param-handlers/param-handler-type.ts +1 -1
  90. package/{lib → cli/lib}/posthog.ts +6 -7
  91. package/{lib → cli/lib}/soupify.ts +4 -4
  92. package/{lib → cli/lib}/util/app-context.ts +1 -1
  93. package/{lib → cli/lib}/util/create-context-and-run-program.ts +14 -10
  94. package/{lib → cli/lib}/util/get-all-package-files.ts +2 -2
  95. package/cli/lib/util/lint-project.ts +137 -0
  96. package/{tests → cli/tests}/init.test.ts +1 -1
  97. package/{tests → cli/tests}/open.test.ts +2 -1
  98. package/{tests → cli/tests}/soupify.test.ts +1 -1
  99. package/dist/cli.js +311 -310
  100. package/example-project/package.json +2 -11
  101. package/example-project/src/manual-edits.ts +34 -34
  102. package/{dev-server-frontend/src → frontend}/components/command-k.tsx +2 -2
  103. package/{dev-server-frontend/src → frontend}/components/dialogs/generic-export-dialog.tsx +6 -10
  104. package/{dev-server-frontend/src → frontend}/components/dialogs/gerber-export-dialog.tsx +5 -5
  105. package/{dev-server-frontend/src → frontend}/components/select-example-search.tsx +7 -7
  106. package/{dev-server-frontend/src → frontend}/components/ui/alert-dialog.tsx +7 -7
  107. package/{dev-server-frontend/src → frontend}/components/ui/alert.tsx +2 -2
  108. package/{dev-server-frontend/src → frontend}/components/ui/breadcrumb.tsx +2 -2
  109. package/{dev-server-frontend/src → frontend}/components/ui/button.tsx +3 -3
  110. package/{dev-server-frontend/src → frontend}/components/ui/card.tsx +2 -2
  111. package/{dev-server-frontend/src → frontend}/components/ui/command.tsx +7 -7
  112. package/{dev-server-frontend/src → frontend}/components/ui/context-menu.tsx +9 -9
  113. package/{dev-server-frontend/src → frontend}/components/ui/dialog.tsx +6 -6
  114. package/{dev-server-frontend/src → frontend}/components/ui/menubar.tsx +13 -13
  115. package/{dev-server-frontend/src → frontend}/components/ui/navigation-menu.tsx +7 -7
  116. package/{dev-server-frontend/src → frontend}/components/ui/popover.tsx +2 -2
  117. package/{dev-server-frontend/src → frontend}/components/ui/select.tsx +7 -7
  118. package/{dev-server-frontend/src → frontend}/components/ui/tabs.tsx +4 -4
  119. package/{dev-server-frontend/src → frontend}/components/ui/toggle-group.tsx +3 -3
  120. package/{dev-server-frontend/src → frontend}/components/ui/toggle.tsx +2 -2
  121. package/{dev-server-frontend/src → frontend}/components/ui/tooltip.tsx +2 -2
  122. package/{dev-server-frontend → frontend}/components.json +1 -1
  123. package/{dev-server-frontend/src → frontend}/hooks/use-active-dev-package-example-lite.ts +2 -2
  124. package/{dev-server-frontend → frontend}/index.html +1 -1
  125. package/{dev-server-frontend/src → frontend}/main.tsx +2 -2
  126. package/{dev-server-frontend → frontend}/tailwind.config.js +4 -7
  127. package/frontend/views/App.tsx +22 -0
  128. package/{dev-server-frontend/src → frontend/views}/Header.tsx +5 -5
  129. package/{dev-server-frontend/src → frontend/views}/HeaderMenu.tsx +51 -23
  130. package/{dev-server-frontend/src/ExampleContentView.tsx → frontend/views/MainContentView.tsx} +7 -7
  131. package/frontend/vite.config.ts +50 -0
  132. package/package.json +57 -18
  133. package/renovate.json +2 -4
  134. package/scripts/build-cli.ts +12 -0
  135. package/tsconfig.json +17 -108
  136. package/tsup.config.ts +3 -3
  137. package/.github/workflows/server-tests.yml +0 -31
  138. package/build-cli.ts +0 -14
  139. package/dev-server-api/bun.lockb +0 -0
  140. package/dev-server-api/edgespec.config.ts +0 -4
  141. package/dev-server-api/package.json +0 -23
  142. package/dev-server-api/src/db/create-schema.ts +0 -54
  143. package/dev-server-api/src/lib/public-mapping/public-map-export-file.ts +0 -17
  144. package/dev-server-api/src/lib/public-mapping/public-map-export-request.ts +0 -23
  145. package/dev-server-api/static-routes.ts +0 -24
  146. package/dev-server-api/tests/fixtures/start-server.ts +0 -20
  147. package/dev-server-api/tsconfig.json +0 -28
  148. package/dev-server-frontend/.eslintrc.cjs +0 -20
  149. package/dev-server-frontend/package-lock.json +0 -8970
  150. package/dev-server-frontend/package.json +0 -70
  151. package/dev-server-frontend/postcss.config.js +0 -6
  152. package/dev-server-frontend/src/App.tsx +0 -22
  153. package/dev-server-frontend/tsconfig.json +0 -29
  154. package/dev-server-frontend/tsconfig.node.json +0 -13
  155. package/dev-server-frontend/vite.config.ts +0 -23
  156. package/example-project/package-lock.json +0 -609
  157. package/lib/util/lint-project.ts +0 -112
  158. /package/{dev-server-api → api}/README.md +0 -0
  159. /package/{dev-server-api/src → api}/db/get-db.ts +0 -0
  160. /package/{dev-server-api/src → api}/db/schema.ts +0 -0
  161. /package/{dev-server-api → api}/index.ts +0 -0
  162. /package/{dev-server-api/src → api/lib}/with-winter-spec.ts +0 -0
  163. /package/{dev-server-api/src → api}/lib/zod/export_parameters.ts +0 -0
  164. /package/{dev-server-api → api}/tests/routes/health.test.ts +0 -0
  165. /package/{cli.ts → cli/cli.ts} +0 -0
  166. /package/{lib → cli/lib}/cmd-fns/auth-logout.ts +0 -0
  167. /package/{lib → cli/lib}/cmd-fns/auth-sessions-create.ts +0 -0
  168. /package/{lib → cli/lib}/cmd-fns/auth-sessions-get.ts +0 -0
  169. /package/{lib → cli/lib}/cmd-fns/auth-sessions-list.ts +0 -0
  170. /package/{lib → cli/lib}/cmd-fns/config-clear.ts +0 -0
  171. /package/{lib → cli/lib}/cmd-fns/config-print-config.ts +0 -0
  172. /package/{lib → cli/lib}/cmd-fns/config-reveal-location.ts +0 -0
  173. /package/{lib → cli/lib}/cmd-fns/config-set-log-requests.ts +0 -0
  174. /package/{lib → cli/lib}/cmd-fns/config-set-registry.ts +0 -0
  175. /package/{lib → cli/lib}/cmd-fns/config-set-runtime.ts +0 -0
  176. /package/{lib → cli/lib}/cmd-fns/config-set-session.ts +0 -0
  177. /package/{lib → cli/lib}/cmd-fns/dev/mark-all-examples-loading.ts +0 -0
  178. /package/{lib → cli/lib}/cmd-fns/dev/start-dev-server.ts +0 -0
  179. /package/{lib → cli/lib}/cmd-fns/init/get-generated-readme.ts +0 -0
  180. /package/{lib → cli/lib}/cmd-fns/init/get-generated-tsconfig.ts +0 -0
  181. /package/{lib → cli/lib}/cmd-fns/package-examples-get.ts +0 -0
  182. /package/{lib → cli/lib}/cmd-fns/package-examples-list.ts +0 -0
  183. /package/{lib → cli/lib}/cmd-fns/package-files-download.ts +0 -0
  184. /package/{lib → cli/lib}/cmd-fns/package-files-get.ts +0 -0
  185. /package/{lib → cli/lib}/cmd-fns/package-files-list.ts +0 -0
  186. /package/{lib → cli/lib}/cmd-fns/package-releases-get.ts +0 -0
  187. /package/{lib → cli/lib}/cmd-fns/package-releases-update.ts +0 -0
  188. /package/{lib → cli/lib}/cmd-fns/packages-create.ts +0 -0
  189. /package/{lib → cli/lib}/cmd-fns/packages-get.ts +0 -0
  190. /package/{lib → cli/lib}/cmd-fns/packages-list.ts +0 -0
  191. /package/{lib → cli/lib}/param-handlers/index.ts +0 -0
  192. /package/{lib → cli/lib}/param-handlers/interact-for-local-directory.ts +0 -0
  193. /package/{lib → cli/lib}/param-handlers/interact-for-local-file.ts +0 -0
  194. /package/{lib → cli/lib}/param-handlers/interact-for-package-example-id.ts +0 -0
  195. /package/{lib → cli/lib}/param-handlers/interact-for-package-name-with-version.ts +0 -0
  196. /package/{lib → cli/lib}/param-handlers/interact-for-package-name.ts +0 -0
  197. /package/{lib → cli/lib}/param-handlers/interact-for-registry-url.ts +0 -0
  198. /package/example-project/examples/{basic-bug.tsx → basic-chip.tsx} +0 -0
  199. /package/{dev-server-frontend → frontend}/README.md +0 -0
  200. /package/{dev-server-frontend → frontend}/bun.lockb +0 -0
  201. /package/{dev-server-frontend/src → frontend}/components/global-context-providers.tsx +0 -0
  202. /package/{dev-server-frontend/src → frontend}/hooks/toast-if-api-not-connected.ts +0 -0
  203. /package/{dev-server-frontend/src → frontend}/hooks/use-dev-package-examples.tsx +0 -0
  204. /package/{dev-server-frontend/src → frontend}/hooks/use-global-store.ts +0 -0
  205. /package/{dev-server-frontend/src → frontend}/index.css +0 -0
  206. /package/{dev-server-frontend/src → frontend}/lib/utils.ts +0 -0
  207. /package/{dev-server-frontend/src → frontend}/vite-env.d.ts +0 -0
@@ -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"
@@ -31,7 +31,7 @@ export const publish = async (ctx: AppContext, args: any) => {
31
31
  }
32
32
 
33
33
  const packageJson = JSON.parse(
34
- await readFileSync(Path.join(ctx.cwd, "package.json"), "utf-8")
34
+ await readFileSync(Path.join(ctx.cwd, "package.json"), "utf-8"),
35
35
  )
36
36
 
37
37
  if (!packageJson.version) {
@@ -40,7 +40,7 @@ export const publish = async (ctx: AppContext, args: any) => {
40
40
  packageJson.version = "0.0.1"
41
41
  await fs.writeFile(
42
42
  Path.join(ctx.cwd, "package.json"),
43
- JSON.stringify(packageJson, null, 2)
43
+ JSON.stringify(packageJson, null, 2),
44
44
  )
45
45
  }
46
46
 
@@ -60,44 +60,44 @@ export const publish = async (ctx: AppContext, args: any) => {
60
60
  delete packageJson.module
61
61
  await fs.writeFile(
62
62
  Path.join(ctx.cwd, "package.json"),
63
- JSON.stringify(packageJson, null, 2)
63
+ JSON.stringify(packageJson, null, 2),
64
64
  )
65
65
  }
66
66
 
67
67
  if (packageJson.main !== "./dist/index.cjs") {
68
68
  console.log(
69
69
  kleur.yellow(
70
- `package.json "main" field is not set to "./dist/index.cjs". Setting it...`
71
- )
70
+ `package.json "main" field is not set to "./dist/index.cjs". Setting it...`,
71
+ ),
72
72
  )
73
73
  packageJson.main = "./dist/index.cjs"
74
74
  await fs.writeFile(
75
75
  Path.join(ctx.cwd, "package.json"),
76
- JSON.stringify(packageJson, null, 2)
76
+ JSON.stringify(packageJson, null, 2),
77
77
  )
78
78
  }
79
79
  if (packageJson.types !== "./index.ts") {
80
80
  console.log(
81
81
  kleur.yellow(
82
- `package.json "types" field is not set to "./index.ts". Setting it...`
83
- )
82
+ `package.json "types" field is not set to "./index.ts". Setting it...`,
83
+ ),
84
84
  )
85
85
  packageJson.types = "./index.ts"
86
86
  await fs.writeFile(
87
87
  Path.join(ctx.cwd, "package.json"),
88
- JSON.stringify(packageJson, null, 2)
88
+ JSON.stringify(packageJson, null, 2),
89
89
  )
90
90
  }
91
91
  if (!packageJson.files) {
92
92
  console.log(
93
93
  kleur.yellow(
94
- `package.json "files" field is not set. Setting it to ["./dist", "index.ts", "./lib"]...`
95
- )
94
+ `package.json "files" field is not set. Setting it to ["./dist", "index.ts", "./lib"]...`,
95
+ ),
96
96
  )
97
97
  packageJson.files = ["dist", "index.ts", "lib"]
98
98
  await fs.writeFile(
99
99
  Path.join(ctx.cwd, "package.json"),
100
- JSON.stringify(packageJson, null, 2)
100
+ JSON.stringify(packageJson, null, 2),
101
101
  )
102
102
  }
103
103
 
@@ -119,8 +119,8 @@ export const publish = async (ctx: AppContext, args: any) => {
119
119
  if (!packageJson.name.includes("/")) {
120
120
  console.log(
121
121
  kleur.yellow(
122
- `Package name "${packageJson.name}" is not scoped. Scoped package names are recommended on the tscircuit registry.`
123
- )
122
+ `Package name "${packageJson.name}" is not scoped. Scoped package names are recommended on the tscircuit registry.`,
123
+ ),
124
124
  )
125
125
  const myAccount = await ctx.axios
126
126
  .get("/accounts/get")
@@ -143,7 +143,7 @@ export const publish = async (ctx: AppContext, args: any) => {
143
143
  packageJson.name = `@${newScopedName}`
144
144
  await fs.writeFile(
145
145
  Path.join(ctx.cwd, "package.json"),
146
- JSON.stringify(packageJson, null, 2)
146
+ JSON.stringify(packageJson, null, 2),
147
147
  )
148
148
  name = newScopedName
149
149
  }
@@ -151,8 +151,8 @@ export const publish = async (ctx: AppContext, args: any) => {
151
151
 
152
152
  console.log(
153
153
  kleur.green(
154
- `Creating package "${packageJson.name}" on tscircuit registry...`
155
- )
154
+ `Creating package "${packageJson.name}" on tscircuit registry...`,
155
+ ),
156
156
  )
157
157
  let description = packageJson.description
158
158
  if (!description) {
@@ -182,28 +182,28 @@ export const publish = async (ctx: AppContext, args: any) => {
182
182
  // 3. If it does, ask to increment the version or update the existing release, if increment is specified, increment the version automatically
183
183
  if (existingRelease) {
184
184
  console.log(
185
- kleur.gray(`Package release already exists: ${name}@${version}`)
185
+ kleur.gray(`Package release already exists: ${name}@${version}`),
186
186
  )
187
187
  if (shouldIncrement) {
188
188
  console.log(
189
189
  kleur.green(
190
190
  `Incrementing version from ${version} to ${semver.inc(
191
191
  version,
192
- "patch"
193
- )}...`
194
- )
192
+ "patch",
193
+ )}...`,
194
+ ),
195
195
  )
196
196
  version = semver.inc(version, "patch")
197
197
  packageJson.version = version
198
198
  await fs.writeFile(
199
199
  Path.join(ctx.cwd, "package.json"),
200
- JSON.stringify(packageJson, null, 2)
200
+ JSON.stringify(packageJson, null, 2),
201
201
  )
202
202
  } else {
203
203
  console.log(
204
204
  kleur.blue(
205
- `Want to increment the version and publish a new release? Use "--increment"!`
206
- )
205
+ `Want to increment the version and publish a new release? Use "--increment"!`,
206
+ ),
207
207
  )
208
208
 
209
209
  throw new Error("Package release already exists")
@@ -221,8 +221,8 @@ export const publish = async (ctx: AppContext, args: any) => {
221
221
  if (!filePaths.includes("README.md")) {
222
222
  console.log(
223
223
  kleur.yellow(
224
- "No README.md found in package files. A README.md is recommended on the tscircuit registry."
225
- )
224
+ "No README.md found in package files. A README.md is recommended on the tscircuit registry.",
225
+ ),
226
226
  )
227
227
  const { confirmReadme } = await prompts({
228
228
  type: "confirm",
@@ -239,7 +239,7 @@ export const publish = async (ctx: AppContext, args: any) => {
239
239
  if (confirmReadme) {
240
240
  await fs.writeFile(
241
241
  Path.join(ctx.cwd, "README.md"),
242
- getGeneratedReadme({ name })
242
+ getGeneratedReadme({ name }),
243
243
  )
244
244
  filePaths.push("README.md")
245
245
  }
@@ -270,12 +270,12 @@ export const publish = async (ctx: AppContext, args: any) => {
270
270
  filePath,
271
271
  exportName,
272
272
  },
273
- ctx
273
+ ctx,
274
274
  ).catch((e) => e)
275
275
 
276
276
  if (tscircuit_soup instanceof Error) {
277
277
  console.log(
278
- kleur.red(`Error soupifying ${filePath}: ${tscircuit_soup}, skipping`)
278
+ kleur.red(`Error soupifying ${filePath}: ${tscircuit_soup}, skipping`),
279
279
  )
280
280
  continue
281
281
  }
@@ -295,13 +295,13 @@ export const publish = async (ctx: AppContext, args: any) => {
295
295
  const tmpTarballPath = Path.join(
296
296
  ctx.cwd,
297
297
  ".tscircuit/tmp",
298
- `${name.replace(/\//g, "-")}-${version}.tgz`
298
+ `${name.replace(/\//g, "-")}-${version}.tgz`,
299
299
  )
300
300
  await fs.mkdir(Path.dirname(tmpTarballPath), { recursive: true })
301
301
  const npm_pack_outputs = await $`cd ${
302
302
  ctx.cwd
303
303
  } && npm pack --json --pack-destination ${Path.dirname(
304
- tmpTarballPath
304
+ tmpTarballPath,
305
305
  )}`.json()
306
306
 
307
307
  if (!existsSync(tmpTarballPath)) {
@@ -330,7 +330,7 @@ export const publish = async (ctx: AppContext, args: any) => {
330
330
 
331
331
  console.log(
332
332
  kleur.green(
333
- `Published ${name}@${version}!\nhttps://registry.tscircuit.com/${name}`
334
- )
333
+ `Published ${name}@${version}!\nhttps://registry.tscircuit.com/${name}`,
334
+ ),
335
335
  )
336
336
  }
@@ -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"
@@ -26,6 +26,6 @@ export const removeCmd = async (ctx: AppContext, args: any) => {
26
26
  console.log(kleur.gray(`> ${cmd}`))
27
27
 
28
28
  await $`npm remove ${flagsString} ${params.packages.map(
29
- (p) => `@tsci/${p.replace(/\//, ".")}`
29
+ (p) => `@tsci/${p.replace(/\//, ".")}`,
30
30
  )}`
31
31
  }
@@ -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) => {
@@ -19,7 +19,7 @@ export const soupifyCmd = async (ctx: AppContext, args: any) => {
19
19
  filePath: params.file,
20
20
  exportName: params.export,
21
21
  },
22
- ctx
22
+ ctx,
23
23
  )
24
24
 
25
25
  if (params.output) {
@@ -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) {
@@ -33,7 +32,7 @@ export const versionCmd = async (ctx: AppContext, args: any) => {
33
32
  for (const row of table) {
34
33
  const { name } = row
35
34
  const { data: packageInfo } = await ctx.axios.get(
36
- "https://registry.npmjs.org/" + name
35
+ "https://registry.npmjs.org/" + name,
37
36
  )
38
37
  row.latest = packageInfo["dist-tags"].latest
39
38
  }
@@ -74,7 +74,7 @@ export const createConfigHandler = ({
74
74
  profile?: string
75
75
  }): ContextConfigProps => {
76
76
  const global_config: TypedConfigstore<GlobalConfigProps> = new Configstore(
77
- "tsci"
77
+ "tsci",
78
78
  )
79
79
  const current_profile =
80
80
  profile ?? global_config.get("current_profile") ?? "default"
@@ -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
 
@@ -8,7 +8,7 @@ export const exportBomCsvToBuffer = async (
8
8
  example_file_path: string
9
9
  export_name?: string
10
10
  },
11
- ctx: AppContext
11
+ ctx: AppContext,
12
12
  ) => {
13
13
  console.log(kleur.gray("[soupifying]..."))
14
14
  const soup = await soupify(
@@ -16,7 +16,7 @@ export const exportBomCsvToBuffer = async (
16
16
  filePath: params.example_file_path,
17
17
  exportName: params.export_name,
18
18
  },
19
- ctx
19
+ ctx,
20
20
  )
21
21
 
22
22
  console.log(kleur.gray("[soup to bom rows]..."))
@@ -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,
@@ -19,7 +19,7 @@ export const exportGerbersToFile = async (
19
19
  export_name?: string
20
20
  output_zip_path: string
21
21
  },
22
- ctx: AppContext
22
+ ctx: AppContext,
23
23
  ) => {
24
24
  console.log(kleur.gray("[soupifying]..."))
25
25
  const soup = await soupify(
@@ -27,7 +27,7 @@ export const exportGerbersToFile = async (
27
27
  filePath: params.example_file_path,
28
28
  exportName: params.export_name,
29
29
  },
30
- ctx
30
+ ctx,
31
31
  )
32
32
 
33
33
  console.log(kleur.gray("[soup to gerber json]..."))
@@ -67,7 +67,7 @@ export const exportGerbersToFile = async (
67
67
 
68
68
  if (typeof Bun !== "undefined") {
69
69
  throw new Error(
70
- `Exporting gerbers doesn't currently work with Bun (bug w/ archiver module)`
70
+ `Exporting gerbers doesn't currently work with Bun (bug w/ archiver module)`,
71
71
  )
72
72
  }
73
73
 
@@ -92,7 +92,7 @@ export const exportGerbersToZipBuffer = async (
92
92
  example_file_path: string
93
93
  export_name?: string
94
94
  },
95
- ctx: AppContext
95
+ ctx: AppContext,
96
96
  ) => {
97
97
  const tempDir = Path.join(".tscircuit", "tmp-gerber-zip")
98
98
  fs.mkdirSync(tempDir, { recursive: true })
@@ -103,7 +103,7 @@ export const exportGerbersToZipBuffer = async (
103
103
  export_name: params.export_name,
104
104
  output_zip_path: Path.join(tempDir, "gerbers.zip"),
105
105
  },
106
- ctx
106
+ ctx,
107
107
  )
108
108
 
109
109
  const buffer = fs.readFileSync(Path.join(tempDir, "gerbers.zip"))
@@ -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,
@@ -17,7 +17,7 @@ export const exportPnpCsvToBuffer = async (
17
17
  example_file_path: string
18
18
  export_name?: string
19
19
  },
20
- ctx: AppContext
20
+ ctx: AppContext,
21
21
  ) => {
22
22
  console.log(kleur.gray("[soupifying]..."))
23
23
  const soup = await soupify(
@@ -25,7 +25,7 @@ export const exportPnpCsvToBuffer = async (
25
25
  filePath: params.example_file_path,
26
26
  exportName: params.export_name,
27
27
  },
28
- ctx
28
+ ctx,
29
29
  )
30
30
 
31
31
  console.log(kleur.gray("[soup to pnp csv string]..."))
@@ -1,11 +1,10 @@
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(
8
- "Develop, test and manage tscircuit packages"
7
+ "Develop, test and manage tscircuit packages",
9
8
  )
10
9
 
11
10
  cmd
@@ -22,11 +21,11 @@ export const getProgram = (ctx: AppContext) => {
22
21
  .option("--name <name>", "Name of the project")
23
22
  .option(
24
23
  "--runtime <runtime>",
25
- "Runtime to use (attempts to bun, otherwise node/tsx)"
24
+ "Runtime to use (attempts to bun, otherwise node/tsx)",
26
25
  )
27
26
  .option(
28
27
  "--dir <dir>",
29
- "Directory to initialize (defaults to ./<name> or . if name not provided)"
28
+ "Directory to initialize (defaults to ./<name> or . if name not provided)",
30
29
  )
31
30
  .action((args) => CMDFN.init(ctx, args))
32
31
 
@@ -35,7 +34,7 @@ export const getProgram = (ctx: AppContext) => {
35
34
  .description("Add a package from the tscircuit registry")
36
35
  .argument(
37
36
  "<packages...>",
38
- "Packages to install from registry.tscircuit.com, optionally with version"
37
+ "Packages to install from registry.tscircuit.com, optionally with version",
39
38
  )
40
39
  .option("-D, --dev", "Add to devDependencies")
41
40
  .action((packages, flags) => CMDFN.add(ctx, { packages, flags }))
@@ -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")
@@ -85,7 +99,7 @@ export const getProgram = (ctx: AppContext) => {
85
99
  .description("Set runtime to use, bun or node")
86
100
  .requiredOption(
87
101
  "--runtime <runtime>",
88
- "Bun or node. Setting to bun generally doubles soupification speed."
102
+ "Bun or node. Setting to bun generally doubles soupification speed.",
89
103
  )
90
104
  .action((args) => CMDFN.configSetRuntime(ctx, args))
91
105
  configCmd
@@ -147,7 +161,7 @@ export const getProgram = (ctx: AppContext) => {
147
161
  .description("Create a new package release")
148
162
  .option(
149
163
  "-p, --package-name-with-version <package_name_with_version>",
150
- "Package name and version"
164
+ "Package name and version",
151
165
  )
152
166
  .option("--package-name <package_name>", "Package name")
153
167
  .option("--release-version <release_version>", "Version to publish")
@@ -157,7 +171,7 @@ export const getProgram = (ctx: AppContext) => {
157
171
  .description("Update a package release")
158
172
  .option(
159
173
  "-p, --package-name-with-version <package_name_with_version>",
160
- "Package name and version"
174
+ "Package name and version",
161
175
  )
162
176
  .option("--is-latest", "Make package release the latest version")
163
177
  .option("--is-locked", "Lock the release")
@@ -172,11 +186,11 @@ export const getProgram = (ctx: AppContext) => {
172
186
  .description("List all files for a package release")
173
187
  .option(
174
188
  "--package-name-with-version <package_name_with_version>",
175
- "Package name with version"
189
+ "Package name with version",
176
190
  )
177
191
  .option(
178
192
  "--package-name <package_name>",
179
- "Package name (use latest version)"
193
+ "Package name (use latest version)",
180
194
  )
181
195
  .option("--package-release-id <package_release_id>", "Package Release Id")
182
196
  .action((args) => CMDFN.packageFilesList(ctx, args))
@@ -186,12 +200,12 @@ export const getProgram = (ctx: AppContext) => {
186
200
  .description("Download a file from a package release")
187
201
  .requiredOption(
188
202
  "--package-name-with-version <package_name_with_version>",
189
- "Package name and version"
203
+ "Package name and version",
190
204
  )
191
205
  .requiredOption("--remote-file-path <remote_file_path>", "Remote file path")
192
206
  .option(
193
207
  "--output <output>",
194
- "Output file path (optional), prints to stdout if not provided"
208
+ "Output file path (optional), prints to stdout if not provided",
195
209
  )
196
210
  .action((args) => CMDFN.packageFilesDownload(ctx, args))
197
211
  packageFiles
@@ -199,11 +213,11 @@ export const getProgram = (ctx: AppContext) => {
199
213
  .description("Create/upload a new package file")
200
214
  .option(
201
215
  "-p, --package-release-id <package_release_id>",
202
- "Package Release Id"
216
+ "Package Release Id",
203
217
  )
204
218
  .option(
205
219
  "--package-name-with-version <package_name_with_version>",
206
- "Package name with version e.g. @tscircuit/arduino@1.2.3"
220
+ "Package name with version e.g. @tscircuit/arduino@1.2.3",
207
221
  )
208
222
  .requiredOption("--file <file>", "File to upload")
209
223
  .action((args) => CMDFN.packageFilesCreate(ctx, args))
@@ -269,7 +283,7 @@ export const getProgram = (ctx: AppContext) => {
269
283
  .requiredOption("--file <file>", "Input example files")
270
284
  .option(
271
285
  "--export <export_name>",
272
- "Name of export to soupify, if not specified, soupify the default/only export"
286
+ "Name of export to soupify, if not specified, soupify the default/only export",
273
287
  )
274
288
  .option("--outputfile <outputfile>", "Output file name", "gerbers.zip")
275
289
  .action((args) => CMDFN.exportGerbers(ctx, args))
@@ -281,7 +295,7 @@ export const getProgram = (ctx: AppContext) => {
281
295
  .option("--output <output.json>", "Output file")
282
296
  .option(
283
297
  "--export <export_name>",
284
- "Name of export to soupify, if not specified, soupify the default/only export"
298
+ "Name of export to soupify, if not specified, soupify the default/only export",
285
299
  )
286
300
  .action((args) => CMDFN.soupify(ctx, args))
287
301
 
@@ -290,7 +304,7 @@ export const getProgram = (ctx: AppContext) => {
290
304
  .description("Install a package from the tscircuit registry")
291
305
  .argument(
292
306
  "<packages...>",
293
- "Packages to install from registry.tscircuit.com, optionally with version"
307
+ "Packages to install from registry.tscircuit.com, optionally with version",
294
308
  )
295
309
  .option("-D, --dev", "Add to devDependencies")
296
310
  .action((packages, flags) => CMDFN.install(ctx, { packages, flags }))
@@ -310,7 +324,7 @@ export const getProgram = (ctx: AppContext) => {
310
324
  .description("Upload a directory to the dev server")
311
325
  .option(
312
326
  "--dir <dir>",
313
- "Directory to upload (defaults to current directory)"
327
+ "Directory to upload (defaults to current directory)",
314
328
  )
315
329
  .option("-w, --watch", "Watch for changes")
316
330
  .option("-p, --port", "Port dev server is running on (default: 3020)")
@@ -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
 
@@ -4,9 +4,8 @@ import { ParamHandler } from "./param-handler-type"
4
4
  export const interactForPackageReleaseId: ParamHandler = async (params) => {
5
5
  const { ctx, prompts } = params
6
6
 
7
- const package_name_with_version = await interactForPackageNameWithVersion(
8
- params
9
- )
7
+ const package_name_with_version =
8
+ await interactForPackageNameWithVersion(params)
10
9
 
11
10
  return await ctx.axios
12
11
  .post("/package_releases/get", {
@@ -9,7 +9,7 @@ export const interactForRuntime: ParamHandler = async (params) => {
9
9
 
10
10
  if (!bunVersion) {
11
11
  console.log(
12
- kleur.red(`BUN IS NOT INSTALLED! Install bun first https://bun.sh/`)
12
+ kleur.red(`BUN IS NOT INSTALLED! Install bun first https://bun.sh/`),
13
13
  )
14
14
  }
15
15
 
@@ -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: {