@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.
- package/.github/workflows/formatbot.yml +41 -0
- package/.github/workflows/release.yml +6 -1
- package/.github/workflows/test.yml +2 -2
- package/.github/workflows/typecheck.yml +29 -0
- package/DEVELOPMENT.md +4 -1
- package/README.md +2 -6
- package/{dev-server-api/src → api}/db/generic-json-level.ts +4 -7
- package/{dev-server-api/src → api}/db/zod-level-db.ts +9 -9
- package/{dev-server-api/src → api/lib}/middlewares/with-db.ts +2 -2
- package/{dev-server-api/src → api/lib}/middlewares/with-debug-request-logging.ts +1 -1
- package/{dev-server-api/src → api/lib}/middlewares/with-error-response.ts +2 -2
- package/{dev-server-api → api}/routes/api/db/download.ts +3 -3
- package/{dev-server-api → api}/routes/api/dev_package_examples/create.ts +1 -1
- package/{dev-server-api → api}/routes/api/dev_package_examples/get.ts +3 -3
- package/{dev-server-api → api}/routes/api/dev_package_examples/list.ts +3 -3
- package/{dev-server-api → api}/routes/api/dev_package_examples/update.ts +4 -4
- package/{dev-server-api → api}/routes/api/dev_server/reset.ts +1 -1
- package/{dev-server-api → api}/routes/api/export_files/create.ts +2 -6
- package/{dev-server-api → api}/routes/api/export_files/download.ts +1 -3
- package/{dev-server-api → api}/routes/api/export_requests/create.ts +3 -4
- package/{dev-server-api → api}/routes/api/export_requests/get.ts +5 -8
- package/{dev-server-api → api}/routes/api/export_requests/list.ts +2 -3
- package/{dev-server-api → api}/routes/api/export_requests/update.ts +3 -5
- package/{dev-server-api/routes → api/routes/api}/health.ts +1 -1
- package/{dev-server-api → api}/routes/api/package_info/create.ts +1 -1
- package/{dev-server-api → api}/routes/api/package_info/get.ts +3 -2
- package/{dev-server-api/routes/api → api/routes}/health.ts +1 -1
- package/{dev-server-api → api}/routes/index.ts +2 -2
- package/{dev-server-api → api}/server.ts +2 -2
- package/api/static-routes.ts +24 -0
- package/{dev-server-api → api}/tests/fixtures/get-test-server.ts +2 -1
- package/api/tests/fixtures/start-server.ts +41 -0
- package/{dev-server-api → api}/tests/routes/dev_package_examples/create.test.ts +2 -2
- package/{dev-server-api → api}/tests/routes/dev_package_examples/get.test.ts +2 -2
- package/{dev-server-api → api}/tests/routes/dev_package_examples/list.test.ts +2 -2
- package/{dev-server-api → api}/tests/routes/dev_package_examples/update.test.ts +3 -3
- package/{dev-server-api → api}/tests/routes/export_files/create.test.ts +1 -1
- package/{dev-server-api → api}/tests/routes/export_files/download.test.ts +3 -3
- package/{dev-server-api → api}/tests/routes/export_requests/create.test.ts +2 -2
- package/{dev-server-api → api}/tests/routes/export_requests/get.test.ts +2 -2
- package/{dev-server-api → api}/tests/routes/export_requests/list.test.ts +1 -1
- package/{dev-server-api → api}/tests/routes/export_requests/update.test.ts +1 -1
- package/biome.json +49 -0
- package/bun.lockb +0 -0
- package/{lib → cli/lib}/cmd-fns/add.ts +2 -2
- package/{lib → cli/lib}/cmd-fns/auth-login.ts +2 -2
- package/{lib → cli/lib}/cmd-fns/dev/check-if-initialized.ts +1 -1
- package/{lib → cli/lib}/cmd-fns/dev/derive-selector-from-pcb-component-id.ts +1 -1
- package/{lib → cli/lib}/cmd-fns/dev/dev-server-request-handler.ts +5 -5
- package/{lib → cli/lib}/cmd-fns/dev/find-available-port.ts +7 -5
- package/{lib → cli/lib}/cmd-fns/dev/fulfill-export-requests.ts +27 -27
- package/{lib → cli/lib}/cmd-fns/dev/get-dev-server-axios.ts +3 -3
- package/{lib → cli/lib}/cmd-fns/dev/index.ts +4 -4
- package/{lib → cli/lib}/cmd-fns/dev/infer-export-name-from-source.ts +2 -2
- package/{lib → cli/lib}/cmd-fns/dev/soupify-and-upload-example-file.ts +6 -5
- package/{lib → cli/lib}/cmd-fns/dev/start-edit-event-watcher.ts +41 -42
- package/{lib → cli/lib}/cmd-fns/dev/start-export-request-watcher.ts +3 -4
- package/{lib → cli/lib}/cmd-fns/dev/start-fs-watcher.ts +2 -1
- package/{lib → cli/lib}/cmd-fns/dev/upload-examples-from-directory.ts +4 -3
- package/{lib → cli/lib}/cmd-fns/dev-server-fulfill-export-requests.ts +3 -3
- package/{lib → cli/lib}/cmd-fns/dev-server-upload.ts +3 -3
- package/{lib → cli/lib}/cmd-fns/export-gerbers.ts +2 -2
- package/cli/lib/cmd-fns/go.ts +14 -0
- package/{lib → cli/lib}/cmd-fns/index.ts +2 -0
- package/{lib → cli/lib}/cmd-fns/init/create-or-modify-npmrc.ts +2 -2
- package/{lib → cli/lib}/cmd-fns/init/get-generated-npmrc.ts +1 -1
- package/{lib → cli/lib}/cmd-fns/init/index.ts +13 -9
- package/{lib → cli/lib}/cmd-fns/install.ts +1 -1
- package/{lib → cli/lib}/cmd-fns/lint.ts +16 -10
- package/{lib → cli/lib}/cmd-fns/open.ts +1 -1
- package/{lib → cli/lib}/cmd-fns/package-examples-create.ts +2 -2
- package/{lib → cli/lib}/cmd-fns/package-files-create.ts +1 -1
- package/{lib → cli/lib}/cmd-fns/package-files-upload-directory.ts +1 -1
- package/{lib → cli/lib}/cmd-fns/package-releases-create.ts +1 -1
- package/{lib → cli/lib}/cmd-fns/package-releases-list.ts +1 -1
- package/{lib → cli/lib}/cmd-fns/publish/index.ts +34 -34
- package/{lib → cli/lib}/cmd-fns/remove.ts +2 -2
- package/cli/lib/cmd-fns/render.ts +45 -0
- package/{lib → cli/lib}/cmd-fns/soupify.ts +2 -2
- package/{lib → cli/lib}/cmd-fns/uninstall.ts +1 -1
- package/{lib → cli/lib}/cmd-fns/version.ts +7 -8
- package/{lib → cli/lib}/create-config-manager.ts +1 -1
- package/{lib → cli/lib}/export-fns/export-bom-csv.ts +3 -3
- package/{lib → cli/lib}/export-fns/export-gerbers.ts +6 -6
- package/{lib → cli/lib}/export-fns/export-pnp-csv.ts +3 -3
- package/{lib → cli/lib}/get-program.ts +37 -21
- package/{lib → cli/lib}/param-handlers/interact-for-package-release-id.ts +2 -3
- package/{lib → cli/lib}/param-handlers/interact-for-runtime.ts +1 -1
- package/{lib → cli/lib}/param-handlers/param-handler-type.ts +1 -1
- package/{lib → cli/lib}/posthog.ts +6 -7
- package/{lib → cli/lib}/soupify.ts +4 -4
- package/{lib → cli/lib}/util/app-context.ts +1 -1
- package/{lib → cli/lib}/util/create-context-and-run-program.ts +14 -10
- package/{lib → cli/lib}/util/get-all-package-files.ts +2 -2
- package/cli/lib/util/lint-project.ts +137 -0
- package/{tests → cli/tests}/init.test.ts +1 -1
- package/{tests → cli/tests}/open.test.ts +2 -1
- package/{tests → cli/tests}/soupify.test.ts +1 -1
- package/dist/cli.js +311 -310
- package/example-project/package.json +2 -11
- package/example-project/src/manual-edits.ts +34 -34
- package/{dev-server-frontend/src → frontend}/components/command-k.tsx +2 -2
- package/{dev-server-frontend/src → frontend}/components/dialogs/generic-export-dialog.tsx +6 -10
- package/{dev-server-frontend/src → frontend}/components/dialogs/gerber-export-dialog.tsx +5 -5
- package/{dev-server-frontend/src → frontend}/components/select-example-search.tsx +7 -7
- package/{dev-server-frontend/src → frontend}/components/ui/alert-dialog.tsx +7 -7
- package/{dev-server-frontend/src → frontend}/components/ui/alert.tsx +2 -2
- package/{dev-server-frontend/src → frontend}/components/ui/breadcrumb.tsx +2 -2
- package/{dev-server-frontend/src → frontend}/components/ui/button.tsx +3 -3
- package/{dev-server-frontend/src → frontend}/components/ui/card.tsx +2 -2
- package/{dev-server-frontend/src → frontend}/components/ui/command.tsx +7 -7
- package/{dev-server-frontend/src → frontend}/components/ui/context-menu.tsx +9 -9
- package/{dev-server-frontend/src → frontend}/components/ui/dialog.tsx +6 -6
- package/{dev-server-frontend/src → frontend}/components/ui/menubar.tsx +13 -13
- package/{dev-server-frontend/src → frontend}/components/ui/navigation-menu.tsx +7 -7
- package/{dev-server-frontend/src → frontend}/components/ui/popover.tsx +2 -2
- package/{dev-server-frontend/src → frontend}/components/ui/select.tsx +7 -7
- package/{dev-server-frontend/src → frontend}/components/ui/tabs.tsx +4 -4
- package/{dev-server-frontend/src → frontend}/components/ui/toggle-group.tsx +3 -3
- package/{dev-server-frontend/src → frontend}/components/ui/toggle.tsx +2 -2
- package/{dev-server-frontend/src → frontend}/components/ui/tooltip.tsx +2 -2
- package/{dev-server-frontend → frontend}/components.json +1 -1
- package/{dev-server-frontend/src → frontend}/hooks/use-active-dev-package-example-lite.ts +2 -2
- package/{dev-server-frontend → frontend}/index.html +1 -1
- package/{dev-server-frontend/src → frontend}/main.tsx +2 -2
- package/{dev-server-frontend → frontend}/tailwind.config.js +4 -7
- package/frontend/views/App.tsx +22 -0
- package/{dev-server-frontend/src → frontend/views}/Header.tsx +5 -5
- package/{dev-server-frontend/src → frontend/views}/HeaderMenu.tsx +51 -23
- package/{dev-server-frontend/src/ExampleContentView.tsx → frontend/views/MainContentView.tsx} +7 -7
- package/frontend/vite.config.ts +50 -0
- package/package.json +57 -18
- package/renovate.json +2 -4
- package/scripts/build-cli.ts +12 -0
- package/tsconfig.json +17 -108
- package/tsup.config.ts +3 -3
- package/.github/workflows/server-tests.yml +0 -31
- package/build-cli.ts +0 -14
- package/dev-server-api/bun.lockb +0 -0
- package/dev-server-api/edgespec.config.ts +0 -4
- package/dev-server-api/package.json +0 -23
- package/dev-server-api/src/db/create-schema.ts +0 -54
- package/dev-server-api/src/lib/public-mapping/public-map-export-file.ts +0 -17
- package/dev-server-api/src/lib/public-mapping/public-map-export-request.ts +0 -23
- package/dev-server-api/static-routes.ts +0 -24
- package/dev-server-api/tests/fixtures/start-server.ts +0 -20
- package/dev-server-api/tsconfig.json +0 -28
- package/dev-server-frontend/.eslintrc.cjs +0 -20
- package/dev-server-frontend/package-lock.json +0 -8970
- package/dev-server-frontend/package.json +0 -70
- package/dev-server-frontend/postcss.config.js +0 -6
- package/dev-server-frontend/src/App.tsx +0 -22
- package/dev-server-frontend/tsconfig.json +0 -29
- package/dev-server-frontend/tsconfig.node.json +0 -13
- package/dev-server-frontend/vite.config.ts +0 -23
- package/example-project/package-lock.json +0 -609
- package/lib/util/lint-project.ts +0 -112
- /package/{dev-server-api → api}/README.md +0 -0
- /package/{dev-server-api/src → api}/db/get-db.ts +0 -0
- /package/{dev-server-api/src → api}/db/schema.ts +0 -0
- /package/{dev-server-api → api}/index.ts +0 -0
- /package/{dev-server-api/src → api/lib}/with-winter-spec.ts +0 -0
- /package/{dev-server-api/src → api}/lib/zod/export_parameters.ts +0 -0
- /package/{dev-server-api → api}/tests/routes/health.test.ts +0 -0
- /package/{cli.ts → cli/cli.ts} +0 -0
- /package/{lib → cli/lib}/cmd-fns/auth-logout.ts +0 -0
- /package/{lib → cli/lib}/cmd-fns/auth-sessions-create.ts +0 -0
- /package/{lib → cli/lib}/cmd-fns/auth-sessions-get.ts +0 -0
- /package/{lib → cli/lib}/cmd-fns/auth-sessions-list.ts +0 -0
- /package/{lib → cli/lib}/cmd-fns/config-clear.ts +0 -0
- /package/{lib → cli/lib}/cmd-fns/config-print-config.ts +0 -0
- /package/{lib → cli/lib}/cmd-fns/config-reveal-location.ts +0 -0
- /package/{lib → cli/lib}/cmd-fns/config-set-log-requests.ts +0 -0
- /package/{lib → cli/lib}/cmd-fns/config-set-registry.ts +0 -0
- /package/{lib → cli/lib}/cmd-fns/config-set-runtime.ts +0 -0
- /package/{lib → cli/lib}/cmd-fns/config-set-session.ts +0 -0
- /package/{lib → cli/lib}/cmd-fns/dev/mark-all-examples-loading.ts +0 -0
- /package/{lib → cli/lib}/cmd-fns/dev/start-dev-server.ts +0 -0
- /package/{lib → cli/lib}/cmd-fns/init/get-generated-readme.ts +0 -0
- /package/{lib → cli/lib}/cmd-fns/init/get-generated-tsconfig.ts +0 -0
- /package/{lib → cli/lib}/cmd-fns/package-examples-get.ts +0 -0
- /package/{lib → cli/lib}/cmd-fns/package-examples-list.ts +0 -0
- /package/{lib → cli/lib}/cmd-fns/package-files-download.ts +0 -0
- /package/{lib → cli/lib}/cmd-fns/package-files-get.ts +0 -0
- /package/{lib → cli/lib}/cmd-fns/package-files-list.ts +0 -0
- /package/{lib → cli/lib}/cmd-fns/package-releases-get.ts +0 -0
- /package/{lib → cli/lib}/cmd-fns/package-releases-update.ts +0 -0
- /package/{lib → cli/lib}/cmd-fns/packages-create.ts +0 -0
- /package/{lib → cli/lib}/cmd-fns/packages-get.ts +0 -0
- /package/{lib → cli/lib}/cmd-fns/packages-list.ts +0 -0
- /package/{lib → cli/lib}/param-handlers/index.ts +0 -0
- /package/{lib → cli/lib}/param-handlers/interact-for-local-directory.ts +0 -0
- /package/{lib → cli/lib}/param-handlers/interact-for-local-file.ts +0 -0
- /package/{lib → cli/lib}/param-handlers/interact-for-package-example-id.ts +0 -0
- /package/{lib → cli/lib}/param-handlers/interact-for-package-name-with-version.ts +0 -0
- /package/{lib → cli/lib}/param-handlers/interact-for-package-name.ts +0 -0
- /package/{lib → cli/lib}/param-handlers/interact-for-registry-url.ts +0 -0
- /package/example-project/examples/{basic-bug.tsx → basic-chip.tsx} +0 -0
- /package/{dev-server-frontend → frontend}/README.md +0 -0
- /package/{dev-server-frontend → frontend}/bun.lockb +0 -0
- /package/{dev-server-frontend/src → frontend}/components/global-context-providers.tsx +0 -0
- /package/{dev-server-frontend/src → frontend}/hooks/toast-if-api-not-connected.ts +0 -0
- /package/{dev-server-frontend/src → frontend}/hooks/use-dev-package-examples.tsx +0 -0
- /package/{dev-server-frontend/src → frontend}/hooks/use-global-store.ts +0 -0
- /package/{dev-server-frontend/src → frontend}/index.css +0 -0
- /package/{dev-server-frontend/src → frontend}/lib/utils.ts +0 -0
- /package/{dev-server-frontend/src → frontend}/vite-env.d.ts +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { DevPackageExample } from "
|
|
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"
|
|
@@ -18,10 +18,9 @@ export const startEditEventWatcher = async (
|
|
|
18
18
|
}: {
|
|
19
19
|
devServerAxios: AxiosInstance
|
|
20
20
|
},
|
|
21
|
-
ctx: AppContext
|
|
21
|
+
ctx: AppContext,
|
|
22
22
|
) => {
|
|
23
23
|
let running = true
|
|
24
|
-
|
|
25
24
|
;(async () => {
|
|
26
25
|
let last_edit_event_update_time: Record<string, string> = {}
|
|
27
26
|
|
|
@@ -44,15 +43,15 @@ export const startEditEventWatcher = async (
|
|
|
44
43
|
) {
|
|
45
44
|
console.log(
|
|
46
45
|
kleur.gray(
|
|
47
|
-
`Edit event detected for dev_package_example ${dev_package_example.dev_package_example_id}
|
|
48
|
-
)
|
|
46
|
+
`Edit event detected for dev_package_example ${dev_package_example.dev_package_example_id}`,
|
|
47
|
+
),
|
|
49
48
|
)
|
|
50
49
|
console.log(
|
|
51
|
-
kleur.gray(` file_path: ${dev_package_example.file_path}`)
|
|
50
|
+
kleur.gray(` file_path: ${dev_package_example.file_path}`),
|
|
52
51
|
)
|
|
53
52
|
|
|
54
53
|
last_edit_event_update_time[dev_package_example_id] =
|
|
55
|
-
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
|
|
56
55
|
|
|
57
56
|
console.log(kleur.gray(` getting new edit events...`))
|
|
58
57
|
|
|
@@ -68,14 +67,14 @@ export const startEditEventWatcher = async (
|
|
|
68
67
|
{
|
|
69
68
|
cwd: ctx.cwd,
|
|
70
69
|
ignore: ["node_modules"],
|
|
71
|
-
}
|
|
70
|
+
},
|
|
72
71
|
)
|
|
73
72
|
|
|
74
73
|
if (manual_edit_files.length === 0) {
|
|
75
74
|
console.log(
|
|
76
75
|
kleur.red(
|
|
77
|
-
`No manual edit files found in "${ctx.cwd}", please create a file "manual-edits.ts" or "*.manual-edits.ts" to persist manual edits
|
|
78
|
-
)
|
|
76
|
+
`No manual edit files found in "${ctx.cwd}", please create a file "manual-edits.ts" or "*.manual-edits.ts" to persist manual edits`,
|
|
77
|
+
),
|
|
79
78
|
)
|
|
80
79
|
continue
|
|
81
80
|
}
|
|
@@ -83,12 +82,12 @@ export const startEditEventWatcher = async (
|
|
|
83
82
|
if (manual_edit_files.length > 1) {
|
|
84
83
|
console.log(
|
|
85
84
|
kleur.red(
|
|
86
|
-
`Multiple manual edit files found, tsci currently doesn't know how to handle this, you should go upvote an issue
|
|
87
|
-
)
|
|
85
|
+
`Multiple manual edit files found, tsci currently doesn't know how to handle this, you should go upvote an issue`,
|
|
86
|
+
),
|
|
88
87
|
)
|
|
89
88
|
for (let i = 0; i < manual_edit_files.length; i++) {
|
|
90
89
|
console.log(
|
|
91
|
-
kleur.gray(` file ${i + 1}: ${manual_edit_files[i]}`)
|
|
90
|
+
kleur.gray(` file ${i + 1}: ${manual_edit_files[i]}`),
|
|
92
91
|
)
|
|
93
92
|
}
|
|
94
93
|
continue
|
|
@@ -97,11 +96,11 @@ export const startEditEventWatcher = async (
|
|
|
97
96
|
const manual_edit_file = manual_edit_files[0]
|
|
98
97
|
const manual_edit_file_content = fs.readFileSync(
|
|
99
98
|
Path.join(ctx.cwd, manual_edit_file),
|
|
100
|
-
"utf-8"
|
|
99
|
+
"utf-8",
|
|
101
100
|
)
|
|
102
101
|
|
|
103
102
|
console.log(
|
|
104
|
-
kleur.gray(` found manual edit file: ${manual_edit_file}`)
|
|
103
|
+
kleur.gray(` found manual edit file: ${manual_edit_file}`),
|
|
105
104
|
)
|
|
106
105
|
|
|
107
106
|
// 2. Convert the edit events into ManualPcbPosition[] and append,
|
|
@@ -118,7 +117,7 @@ export const startEditEventWatcher = async (
|
|
|
118
117
|
|
|
119
118
|
const ts_manual_edits_file = project.createSourceFile(
|
|
120
119
|
"manual-edits.ts",
|
|
121
|
-
manual_edit_file_content
|
|
120
|
+
manual_edit_file_content,
|
|
122
121
|
)
|
|
123
122
|
|
|
124
123
|
// Access the default export declaration
|
|
@@ -129,7 +128,7 @@ export const startEditEventWatcher = async (
|
|
|
129
128
|
// Get the object literal expression from the export default statement
|
|
130
129
|
const object_literal =
|
|
131
130
|
default_export_dec.getFirstChildByKindOrThrow(
|
|
132
|
-
ts.SyntaxKind.ObjectLiteralExpression
|
|
131
|
+
ts.SyntaxKind.ObjectLiteralExpression,
|
|
133
132
|
)
|
|
134
133
|
|
|
135
134
|
// Get the `pcb_placements` property
|
|
@@ -164,25 +163,25 @@ export const startEditEventWatcher = async (
|
|
|
164
163
|
let manual_trace_hints: ManualTraceHint[]
|
|
165
164
|
try {
|
|
166
165
|
pcb_placements = JSON5.parse(
|
|
167
|
-
pcb_placements_ts.getText().replace(/pcb_placements:\s/, "")
|
|
166
|
+
pcb_placements_ts.getText().replace(/pcb_placements:\s/, ""),
|
|
168
167
|
)
|
|
169
168
|
} catch (e: any) {
|
|
170
169
|
console.log(
|
|
171
170
|
kleur.red(
|
|
172
|
-
`Error parsing pcb_placements from manual edits file: ${pcb_placements_ts.getText()} ${e.toString()}
|
|
173
|
-
)
|
|
171
|
+
`Error parsing pcb_placements from manual edits file: ${pcb_placements_ts.getText()} ${e.toString()}`,
|
|
172
|
+
),
|
|
174
173
|
)
|
|
175
174
|
continue
|
|
176
175
|
}
|
|
177
176
|
try {
|
|
178
177
|
in_file_edit_events = JSON5.parse(
|
|
179
|
-
edit_events_ts.getText().replace(/edit_events:\s/, "")
|
|
178
|
+
edit_events_ts.getText().replace(/edit_events:\s/, ""),
|
|
180
179
|
)
|
|
181
180
|
} catch (e: any) {
|
|
182
181
|
console.log(
|
|
183
182
|
kleur.red(
|
|
184
|
-
`Error parsing edit_events from manual edits file: ${edit_events_ts.getText()} ${e.toString()}
|
|
185
|
-
)
|
|
183
|
+
`Error parsing edit_events from manual edits file: ${edit_events_ts.getText()} ${e.toString()}`,
|
|
184
|
+
),
|
|
186
185
|
)
|
|
187
186
|
continue
|
|
188
187
|
}
|
|
@@ -190,13 +189,13 @@ export const startEditEventWatcher = async (
|
|
|
190
189
|
manual_trace_hints = JSON5.parse(
|
|
191
190
|
manual_trace_hints_ts
|
|
192
191
|
.getText()
|
|
193
|
-
.replace(/manual_trace_hints:\s/, "")
|
|
192
|
+
.replace(/manual_trace_hints:\s/, ""),
|
|
194
193
|
)
|
|
195
194
|
} catch (e: any) {
|
|
196
195
|
console.log(
|
|
197
196
|
kleur.red(
|
|
198
|
-
`Error parsing manual_trace_hints from manual edits file: ${pcb_placements_ts.getText()} ${e.toString()}
|
|
199
|
-
)
|
|
197
|
+
`Error parsing manual_trace_hints from manual edits file: ${pcb_placements_ts.getText()} ${e.toString()}`,
|
|
198
|
+
),
|
|
200
199
|
)
|
|
201
200
|
continue
|
|
202
201
|
}
|
|
@@ -204,7 +203,7 @@ export const startEditEventWatcher = async (
|
|
|
204
203
|
const handled_edit_events = new Set<string>(
|
|
205
204
|
pcb_placements
|
|
206
205
|
.map((p) => (p as any)._edit_event_id)
|
|
207
|
-
.concat(in_file_edit_events.map((a) => a.edit_event_id))
|
|
206
|
+
.concat(in_file_edit_events.map((a) => a.edit_event_id)),
|
|
208
207
|
)
|
|
209
208
|
|
|
210
209
|
// Add PCB placements from edit events
|
|
@@ -229,14 +228,14 @@ export const startEditEventWatcher = async (
|
|
|
229
228
|
if (!pcb_component_selector) continue
|
|
230
229
|
|
|
231
230
|
const existing_placement_for_selector = pcb_placements.find(
|
|
232
|
-
(pp) => pp.selector === pcb_component_selector
|
|
231
|
+
(pp) => pp.selector === pcb_component_selector,
|
|
233
232
|
)
|
|
234
233
|
|
|
235
234
|
if (!existing_placement_for_selector) {
|
|
236
235
|
console.log(
|
|
237
236
|
kleur.gray(
|
|
238
|
-
` adding PCB placement from edit event for "${pcb_component_selector}"
|
|
239
|
-
)
|
|
237
|
+
` adding PCB placement from edit event for "${pcb_component_selector}"`,
|
|
238
|
+
),
|
|
240
239
|
)
|
|
241
240
|
|
|
242
241
|
pcb_placements.push({
|
|
@@ -255,14 +254,14 @@ export const startEditEventWatcher = async (
|
|
|
255
254
|
`pcb_placements: ${JSON.stringify(
|
|
256
255
|
pcb_placements,
|
|
257
256
|
null,
|
|
258
|
-
" "
|
|
259
|
-
)}
|
|
257
|
+
" ",
|
|
258
|
+
)}`,
|
|
260
259
|
)
|
|
261
260
|
|
|
262
261
|
// Save the file
|
|
263
262
|
fs.writeFileSync(
|
|
264
263
|
Path.join(ctx.cwd, manual_edit_file),
|
|
265
|
-
ts_manual_edits_file.getFullText()
|
|
264
|
+
ts_manual_edits_file.getFullText(),
|
|
266
265
|
)
|
|
267
266
|
await devServerAxios.post("/api/dev_package_examples/update", {
|
|
268
267
|
dev_package_example_id,
|
|
@@ -274,7 +273,7 @@ export const startEditEventWatcher = async (
|
|
|
274
273
|
) {
|
|
275
274
|
const new_trace_hint = getManualTraceHintFromEvent(
|
|
276
275
|
dev_package_example_full.tscircuit_soup,
|
|
277
|
-
incoming_edit_event
|
|
276
|
+
incoming_edit_event,
|
|
278
277
|
)
|
|
279
278
|
|
|
280
279
|
manual_trace_hints_ts.replaceWithText(
|
|
@@ -283,17 +282,17 @@ export const startEditEventWatcher = async (
|
|
|
283
282
|
.filter(
|
|
284
283
|
(th) =>
|
|
285
284
|
th.pcb_port_selector !==
|
|
286
|
-
new_trace_hint.pcb_port_selector
|
|
285
|
+
new_trace_hint.pcb_port_selector,
|
|
287
286
|
)
|
|
288
287
|
.concat([new_trace_hint]),
|
|
289
288
|
null,
|
|
290
|
-
" "
|
|
291
|
-
)}
|
|
289
|
+
" ",
|
|
290
|
+
)}`,
|
|
292
291
|
)
|
|
293
292
|
|
|
294
293
|
fs.writeFileSync(
|
|
295
294
|
Path.join(ctx.cwd, manual_edit_file),
|
|
296
|
-
ts_manual_edits_file.getFullText()
|
|
295
|
+
ts_manual_edits_file.getFullText(),
|
|
297
296
|
)
|
|
298
297
|
await devServerAxios.post("/api/dev_package_examples/update", {
|
|
299
298
|
dev_package_example_id,
|
|
@@ -304,12 +303,12 @@ export const startEditEventWatcher = async (
|
|
|
304
303
|
// All other events just go to the manual-edits.ts file with
|
|
305
304
|
// in the "edit_events" property
|
|
306
305
|
edit_events_ts.replaceWithText(
|
|
307
|
-
`edit_events: ${JSON.stringify(edit_events, null, " ")}
|
|
306
|
+
`edit_events: ${JSON.stringify(edit_events, null, " ")}`,
|
|
308
307
|
)
|
|
309
308
|
console.log(edit_events_ts.getFullText())
|
|
310
309
|
fs.writeFileSync(
|
|
311
310
|
Path.join(ctx.cwd, manual_edit_file),
|
|
312
|
-
ts_manual_edits_file.getFullText()
|
|
311
|
+
ts_manual_edits_file.getFullText(),
|
|
313
312
|
)
|
|
314
313
|
await devServerAxios.post("/api/dev_package_examples/update", {
|
|
315
314
|
dev_package_example_id,
|
|
@@ -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
|
{
|
|
@@ -9,17 +9,16 @@ export const startExportRequestWatcher = async (
|
|
|
9
9
|
}: {
|
|
10
10
|
devServerAxios: AxiosInstance
|
|
11
11
|
},
|
|
12
|
-
ctx: AppContext
|
|
12
|
+
ctx: AppContext,
|
|
13
13
|
) => {
|
|
14
14
|
let running = true
|
|
15
|
-
|
|
16
15
|
;(async () => {
|
|
17
16
|
while (running) {
|
|
18
17
|
try {
|
|
19
18
|
await fulfillExportRequests({ dev_server_axios: devServerAxios }, ctx)
|
|
20
19
|
} catch (err: any) {
|
|
21
20
|
console.log(
|
|
22
|
-
kleur.red(`Error in export request watcher: ${err.toString()}`)
|
|
21
|
+
kleur.red(`Error in export request watcher: ${err.toString()}`),
|
|
23
22
|
)
|
|
24
23
|
}
|
|
25
24
|
await new Promise((resolve) => setTimeout(resolve, 1000))
|
|
@@ -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:
|
|
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:
|
|
19
|
+
ctx: Pick<AppContext, "runtime" | "params">,
|
|
19
20
|
) => {
|
|
20
21
|
const examplesDir = joinPath(cwd, "examples")
|
|
21
22
|
const exampleFileNames = await readdir(examplesDir).catch((e) => {
|
|
@@ -35,7 +36,7 @@ export const uploadExamplesFromDirectory = async (
|
|
|
35
36
|
examplesDir,
|
|
36
37
|
exampleFileName,
|
|
37
38
|
},
|
|
38
|
-
ctx
|
|
39
|
+
ctx,
|
|
39
40
|
)
|
|
40
41
|
}
|
|
41
42
|
}
|
|
@@ -6,7 +6,7 @@ import { getDevServerAxios } from "./dev/get-dev-server-axios"
|
|
|
6
6
|
|
|
7
7
|
export const devServerFulfillExportRequests = async (
|
|
8
8
|
ctx: AppContext,
|
|
9
|
-
args: any
|
|
9
|
+
args: any,
|
|
10
10
|
) => {
|
|
11
11
|
const params = z.object({}).parse(args)
|
|
12
12
|
|
|
@@ -33,8 +33,8 @@ export const devServerFulfillExportRequests = async (
|
|
|
33
33
|
if (!is_dev_server_healthy) {
|
|
34
34
|
console.log(
|
|
35
35
|
kleur.red(
|
|
36
|
-
`Dev server doesn't seem to be running at ${server_url}. (Could not ping health)
|
|
37
|
-
)
|
|
36
|
+
`Dev server doesn't seem to be running at ${server_url}. (Could not ping health)`,
|
|
37
|
+
),
|
|
38
38
|
)
|
|
39
39
|
process.exit(1)
|
|
40
40
|
}
|
|
@@ -37,8 +37,8 @@ export const devServerUpload = async (ctx: AppContext, args: any) => {
|
|
|
37
37
|
if (!is_dev_server_healthy) {
|
|
38
38
|
console.log(
|
|
39
39
|
kleur.red(
|
|
40
|
-
`Dev server doesn't seem to be running at ${serverUrl}. (Could not ping health)
|
|
41
|
-
)
|
|
40
|
+
`Dev server doesn't seem to be running at ${serverUrl}. (Could not ping health)`,
|
|
41
|
+
),
|
|
42
42
|
)
|
|
43
43
|
process.exit(1)
|
|
44
44
|
}
|
|
@@ -50,7 +50,7 @@ export const devServerUpload = async (ctx: AppContext, args: any) => {
|
|
|
50
50
|
// Start watcher
|
|
51
51
|
const watcher = await startFsWatcher(
|
|
52
52
|
{ cwd: params.dir, devServerAxios },
|
|
53
|
-
ctx
|
|
53
|
+
ctx,
|
|
54
54
|
)
|
|
55
55
|
}
|
|
56
56
|
}
|
|
@@ -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
|
|
@@ -17,6 +17,6 @@ export const exportGerbersCmd = async (ctx: AppContext, args: any) => {
|
|
|
17
17
|
export_name: params.export,
|
|
18
18
|
output_zip_path: params.outputfile,
|
|
19
19
|
},
|
|
20
|
-
ctx
|
|
20
|
+
ctx,
|
|
21
21
|
)
|
|
22
22
|
}
|
|
@@ -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,11 +2,11 @@ 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 },
|
|
9
|
-
ctx: AppContext
|
|
9
|
+
ctx: AppContext,
|
|
10
10
|
) => {
|
|
11
11
|
const npmrcPath = Path.join(ctx.cwd, ".npmrc")
|
|
12
12
|
|
|
@@ -104,10 +104,14 @@ export const initCmd = async (ctx: AppContext, args: any) => {
|
|
|
104
104
|
writeFileSync("package.json", JSON.stringify(packageJson, null, 2))
|
|
105
105
|
|
|
106
106
|
console.log(`Adding ".tscircuit" to .gitignore`)
|
|
107
|
-
appendFileSync(
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
107
|
+
appendFileSync(
|
|
108
|
+
".gitignore",
|
|
109
|
+
"\n.tscircuit\n*.__tmp_entrypoint.tsx\ndist\nnode_modules\n",
|
|
110
|
+
{
|
|
111
|
+
encoding: "utf-8",
|
|
112
|
+
flag: "a+",
|
|
113
|
+
},
|
|
114
|
+
)
|
|
111
115
|
|
|
112
116
|
console.log("Add .npmrc with tscircuit registry...")
|
|
113
117
|
await createOrModifyNpmrc({ quiet: false }, ctx)
|
|
@@ -137,7 +141,7 @@ export default {
|
|
|
137
141
|
// Manual pcb placements, added when you drag a footprint
|
|
138
142
|
pcb_placements: [],
|
|
139
143
|
}
|
|
140
|
-
`.trim()
|
|
144
|
+
`.trim(),
|
|
141
145
|
)
|
|
142
146
|
|
|
143
147
|
writeFileSync(
|
|
@@ -155,7 +159,7 @@ export default {
|
|
|
155
159
|
/>
|
|
156
160
|
</group>
|
|
157
161
|
)
|
|
158
|
-
`.trim()
|
|
162
|
+
`.trim(),
|
|
159
163
|
)
|
|
160
164
|
|
|
161
165
|
writeFileSync("index.ts", `export * from "./lib/MyCircuit"`)
|
|
@@ -163,14 +167,14 @@ export default {
|
|
|
163
167
|
writeFileSync(
|
|
164
168
|
Path.join("examples", "MyExample.tsx"),
|
|
165
169
|
`
|
|
166
|
-
import { MyCircuit } from "lib/MyCircuit"
|
|
170
|
+
import { MyCircuit } from "cli/lib/MyCircuit"
|
|
167
171
|
|
|
168
172
|
export const MyExample = () => (
|
|
169
173
|
<board width="40mm" height="40mm" pcbCenterX={0} pcbCenterY={0}>
|
|
170
174
|
<MyCircuit />
|
|
171
175
|
</board>
|
|
172
176
|
)
|
|
173
|
-
`.trim()
|
|
177
|
+
`.trim(),
|
|
174
178
|
)
|
|
175
179
|
|
|
176
180
|
// Override the README file
|
|
@@ -179,7 +183,7 @@ export const MyExample = () => (
|
|
|
179
183
|
getGeneratedReadme({
|
|
180
184
|
name: params.name!,
|
|
181
185
|
shouldHaveProjectGeneratedNotice: true,
|
|
182
|
-
})
|
|
186
|
+
}),
|
|
183
187
|
)
|
|
184
188
|
|
|
185
189
|
// Open tsconfig.json and modify it to import the tscircuit types
|
|
@@ -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"
|
|
@@ -15,23 +15,29 @@ export const lintCmd = async (ctx: AppContext, args: any) => {
|
|
|
15
15
|
|
|
16
16
|
console.log(kleur.blue("Running tscircuit linter..."))
|
|
17
17
|
|
|
18
|
-
const results = lintProject(cwd, fix)
|
|
18
|
+
const results = lintProject(cwd, fix)
|
|
19
19
|
|
|
20
|
-
let errorCount = 0
|
|
20
|
+
let errorCount = 0
|
|
21
21
|
for (const result of results) {
|
|
22
22
|
if (result.messages.length > 0) {
|
|
23
|
-
console.log(kleur.yellow(`\nFile: ${result.filePath}`))
|
|
23
|
+
console.log(kleur.yellow(`\nFile: ${result.filePath}`))
|
|
24
24
|
for (const message of result.messages) {
|
|
25
|
-
console.log(
|
|
26
|
-
|
|
25
|
+
console.log(
|
|
26
|
+
` Line ${message.line}, Column ${message.column}: ${message.message}`,
|
|
27
|
+
)
|
|
28
|
+
errorCount++
|
|
27
29
|
}
|
|
28
30
|
}
|
|
29
31
|
}
|
|
30
32
|
|
|
31
33
|
if (errorCount > 0) {
|
|
32
|
-
console.log(
|
|
33
|
-
|
|
34
|
+
console.log(
|
|
35
|
+
kleur.yellow(
|
|
36
|
+
`\nFound ${errorCount} issue${errorCount === 1 ? "" : "s"} in your tscircuit code.`,
|
|
37
|
+
),
|
|
38
|
+
)
|
|
39
|
+
process.exit(1)
|
|
34
40
|
} else {
|
|
35
|
-
console.log(kleur.green("\nNo tscircuit-specific issues found!"))
|
|
41
|
+
console.log(kleur.green("\nNo tscircuit-specific issues found!"))
|
|
36
42
|
}
|
|
37
|
-
}
|
|
43
|
+
}
|
|
@@ -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"
|
|
@@ -17,7 +17,7 @@ export const packageExamplesCreate = async (ctx: AppContext, args: any) => {
|
|
|
17
17
|
filePath: params.file,
|
|
18
18
|
exportName: params.export,
|
|
19
19
|
},
|
|
20
|
-
ctx
|
|
20
|
+
ctx,
|
|
21
21
|
)
|
|
22
22
|
|
|
23
23
|
const fileContent = await fs.promises.readFile(params.file, "utf8")
|
|
@@ -26,6 +26,6 @@ export const packageFilesCreate = async (ctx: AppContext, args: any) => {
|
|
|
26
26
|
.then((r) => r.data.package_file)
|
|
27
27
|
|
|
28
28
|
console.log(
|
|
29
|
-
`Package file created ${kleur.gray(package_file.package_file_id)}
|
|
29
|
+
`Package file created ${kleur.gray(package_file.package_file_id)}`,
|
|
30
30
|
)
|
|
31
31
|
}
|
|
@@ -30,6 +30,6 @@ export const packageReleasesCreate = async (ctx: AppContext, args: any) => {
|
|
|
30
30
|
.then((r) => r.data.package_release)
|
|
31
31
|
|
|
32
32
|
console.log(
|
|
33
|
-
`Package release created! ${kleur.gray(package_release.package_release_id)}
|
|
33
|
+
`Package release created! ${kleur.gray(package_release.package_release_id)}`,
|
|
34
34
|
)
|
|
35
35
|
}
|