@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,5 +1,5 @@
|
|
|
1
1
|
import { it, expect } from "bun:test"
|
|
2
|
-
import { getTestFixture } from "tests/fixtures/get-test-server"
|
|
2
|
+
import { getTestFixture } from "api/tests/fixtures/get-test-server"
|
|
3
3
|
|
|
4
4
|
it("POST /api/dev_package_examples/create", async () => {
|
|
5
5
|
const { axios } = await getTestFixture()
|
|
@@ -20,6 +20,6 @@ it("POST /api/dev_package_examples/create", async () => {
|
|
|
20
20
|
.then((r) => r.data)
|
|
21
21
|
|
|
22
22
|
expect(res.dev_package_example.file_path).toEqual(
|
|
23
|
-
"examples/basic-resistor.tsx"
|
|
23
|
+
"examples/basic-resistor.tsx",
|
|
24
24
|
)
|
|
25
25
|
})
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { it, expect } from "bun:test"
|
|
2
|
-
import { getTestFixture } from "tests/fixtures/get-test-server"
|
|
2
|
+
import { getTestFixture } from "api/tests/fixtures/get-test-server"
|
|
3
3
|
|
|
4
4
|
it("GET /api/dev_package_examples/list", async () => {
|
|
5
5
|
const { axios } = await getTestFixture()
|
|
@@ -22,7 +22,7 @@ it("GET /api/dev_package_examples/list", async () => {
|
|
|
22
22
|
expect(res.dev_package_examples.length).toBeGreaterThan(0)
|
|
23
23
|
|
|
24
24
|
const example = res.dev_package_examples.find(
|
|
25
|
-
(e: any) => e.file_path === "examples/test-example.tsx"
|
|
25
|
+
(e: any) => e.file_path === "examples/test-example.tsx",
|
|
26
26
|
)
|
|
27
27
|
expect(example).toBeDefined()
|
|
28
28
|
expect(example.export_name).toBe("default")
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { it, expect } from "bun:test"
|
|
2
|
-
import { getTestFixture } from "tests/fixtures/get-test-server"
|
|
2
|
+
import { getTestFixture } from "api/tests/fixtures/get-test-server"
|
|
3
3
|
|
|
4
4
|
it("POST /api/dev_package_examples/update", async () => {
|
|
5
5
|
const { axios } = await getTestFixture()
|
|
@@ -23,7 +23,7 @@ it("POST /api/dev_package_examples/update", async () => {
|
|
|
23
23
|
|
|
24
24
|
expect(res.dev_package_example.completed_edit_events).toEqual([])
|
|
25
25
|
expect(res.dev_package_example.edit_events_last_applied_at).toEqual(
|
|
26
|
-
"2023-01-01T00:00:00.000Z"
|
|
26
|
+
"2023-01-01T00:00:00.000Z",
|
|
27
27
|
)
|
|
28
28
|
|
|
29
29
|
const getRes = await axios.post("/api/dev_package_examples/get", {
|
|
@@ -33,6 +33,6 @@ it("POST /api/dev_package_examples/update", async () => {
|
|
|
33
33
|
expect(getRes.status).toBe(200)
|
|
34
34
|
expect(getRes.data.dev_package_example.completed_edit_events).toEqual([])
|
|
35
35
|
expect(getRes.data.dev_package_example.edit_events_last_applied_at).toEqual(
|
|
36
|
-
"2023-01-01T00:00:00.000Z"
|
|
36
|
+
"2023-01-01T00:00:00.000Z",
|
|
37
37
|
)
|
|
38
38
|
})
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { it, expect } from "bun:test"
|
|
2
|
-
import { getTestFixture } from "tests/fixtures/get-test-server"
|
|
2
|
+
import { getTestFixture } from "api/tests/fixtures/get-test-server"
|
|
3
3
|
|
|
4
4
|
it("POST /api/export_files/create", async () => {
|
|
5
5
|
const { axios } = await getTestFixture()
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { it, expect } from "bun:test"
|
|
2
|
-
import { getTestFixture } from "tests/fixtures/get-test-server"
|
|
2
|
+
import { getTestFixture } from "api/tests/fixtures/get-test-server"
|
|
3
3
|
|
|
4
4
|
it("GET /api/export_files/download", async () => {
|
|
5
5
|
const { axios } = await getTestFixture()
|
|
@@ -16,13 +16,13 @@ it("GET /api/export_files/download", async () => {
|
|
|
16
16
|
|
|
17
17
|
const downloadRes = await axios
|
|
18
18
|
.get(
|
|
19
|
-
`/api/export_files/download?export_file_id=${res.export_file.export_file_id}
|
|
19
|
+
`/api/export_files/download?export_file_id=${res.export_file.export_file_id}`,
|
|
20
20
|
)
|
|
21
21
|
.then((r) => r.data)
|
|
22
22
|
|
|
23
23
|
// Convert downloadRes to base64 string
|
|
24
24
|
const downloadResBase64 = Buffer.from(downloadRes, "binary").toString(
|
|
25
|
-
"base64"
|
|
25
|
+
"base64",
|
|
26
26
|
)
|
|
27
27
|
|
|
28
28
|
expect(downloadResBase64).toEqual(exampleBase64)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { it, expect } from "bun:test"
|
|
2
|
-
import { getTestFixture } from "tests/fixtures/get-test-server"
|
|
2
|
+
import { getTestFixture } from "api/tests/fixtures/get-test-server"
|
|
3
3
|
|
|
4
4
|
it("POST /api/export_requests/create", async () => {
|
|
5
5
|
const { axios } = await getTestFixture()
|
|
@@ -13,7 +13,7 @@ it("POST /api/export_requests/create", async () => {
|
|
|
13
13
|
expect(res.status).toBe(200)
|
|
14
14
|
expect(res.data.export_request).toBeDefined()
|
|
15
15
|
expect(res.data.export_request.example_file_path).toBe(
|
|
16
|
-
"examples/test-example.tsx"
|
|
16
|
+
"examples/test-example.tsx",
|
|
17
17
|
)
|
|
18
18
|
expect(res.data.export_request.export_name).toBe("default")
|
|
19
19
|
expect(res.data.export_request.export_parameters).toMatchObject({
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { it, expect } from "bun:test"
|
|
2
|
-
import { getTestFixture } from "tests/fixtures/get-test-server"
|
|
2
|
+
import { getTestFixture } from "api/tests/fixtures/get-test-server"
|
|
3
3
|
|
|
4
4
|
it("GET /api/export_requests/get", async () => {
|
|
5
5
|
const { axios } = await getTestFixture()
|
|
@@ -22,7 +22,7 @@ it("GET /api/export_requests/get", async () => {
|
|
|
22
22
|
expect(getRes.data.export_request).toBeDefined()
|
|
23
23
|
expect(getRes.data.export_request.export_request_id).toBe(exportRequestId)
|
|
24
24
|
expect(getRes.data.export_request.example_file_path).toBe(
|
|
25
|
-
"examples/test-example.tsx"
|
|
25
|
+
"examples/test-example.tsx",
|
|
26
26
|
)
|
|
27
27
|
expect(getRes.data.export_request.export_name).toBe("default")
|
|
28
28
|
expect(getRes.data.export_request.export_parameters).toMatchObject({
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { it, expect } from "bun:test"
|
|
2
|
-
import { getTestFixture } from "tests/fixtures/get-test-server"
|
|
2
|
+
import { getTestFixture } from "api/tests/fixtures/get-test-server"
|
|
3
3
|
|
|
4
4
|
it("GET /api/export_requests/list", async () => {
|
|
5
5
|
const { axios } = await getTestFixture()
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { it, expect } from "bun:test"
|
|
2
|
-
import { getTestFixture } from "tests/fixtures/get-test-server"
|
|
2
|
+
import { getTestFixture } from "api/tests/fixtures/get-test-server"
|
|
3
3
|
|
|
4
4
|
it("POST /api/export_requests/update", async () => {
|
|
5
5
|
const { axios } = await getTestFixture()
|
package/biome.json
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://biomejs.dev/schemas/1.7.3/schema.json",
|
|
3
|
+
"organizeImports": {
|
|
4
|
+
"enabled": true
|
|
5
|
+
},
|
|
6
|
+
"formatter": {
|
|
7
|
+
"enabled": true,
|
|
8
|
+
"indentStyle": "space"
|
|
9
|
+
},
|
|
10
|
+
"files": {
|
|
11
|
+
"ignore": [
|
|
12
|
+
"cosmos-export",
|
|
13
|
+
"dist",
|
|
14
|
+
"package.json",
|
|
15
|
+
"tsconfig.json",
|
|
16
|
+
"static-routes.ts"
|
|
17
|
+
]
|
|
18
|
+
},
|
|
19
|
+
"javascript": {
|
|
20
|
+
"formatter": {
|
|
21
|
+
"jsxQuoteStyle": "double",
|
|
22
|
+
"quoteProperties": "asNeeded",
|
|
23
|
+
"trailingCommas": "all",
|
|
24
|
+
"semicolons": "asNeeded",
|
|
25
|
+
"arrowParentheses": "always",
|
|
26
|
+
"bracketSpacing": true,
|
|
27
|
+
"bracketSameLine": false
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
"linter": {
|
|
31
|
+
"enabled": false,
|
|
32
|
+
"rules": {
|
|
33
|
+
"suspicious": {
|
|
34
|
+
"noExplicitAny": "off"
|
|
35
|
+
},
|
|
36
|
+
"style": {
|
|
37
|
+
"noNonNullAssertion": "off",
|
|
38
|
+
"useFilenamingConvention": {
|
|
39
|
+
"level": "error",
|
|
40
|
+
"options": {
|
|
41
|
+
"strictCase": true,
|
|
42
|
+
"requireAscii": true,
|
|
43
|
+
"filenameCases": ["kebab-case", "export"]
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
package/bun.lockb
CHANGED
|
Binary file
|
|
@@ -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"
|
|
@@ -29,6 +29,6 @@ export const addCmd = async (ctx: AppContext, args: any) => {
|
|
|
29
29
|
console.log(kleur.gray(`> ${cmd}`))
|
|
30
30
|
|
|
31
31
|
await $`npm add ${flagsString} ${params.packages.map(
|
|
32
|
-
(p) => `@tsci/${p.replace(/\//, ".")}
|
|
32
|
+
(p) => `@tsci/${p.replace(/\//, ".")}`,
|
|
33
33
|
)}`
|
|
34
34
|
}
|
|
@@ -22,7 +22,7 @@ export const authLogin = async (ctx: AppContext, args: any) => {
|
|
|
22
22
|
headers: {
|
|
23
23
|
Authorization: `Bearer ${login_page.login_page_auth_token}`,
|
|
24
24
|
},
|
|
25
|
-
}
|
|
25
|
+
},
|
|
26
26
|
)
|
|
27
27
|
|
|
28
28
|
if (new_login_page.was_login_successful) {
|
|
@@ -48,7 +48,7 @@ export const authLogin = async (ctx: AppContext, args: any) => {
|
|
|
48
48
|
headers: {
|
|
49
49
|
Authorization: `Bearer ${login_page.login_page_auth_token}`,
|
|
50
50
|
},
|
|
51
|
-
}
|
|
51
|
+
},
|
|
52
52
|
)
|
|
53
53
|
|
|
54
54
|
ctx.profile_config.set("session_token", session.token)
|
|
@@ -13,7 +13,7 @@ export const checkIfInitialized = async (ctx: AppContext) => {
|
|
|
13
13
|
const packageJsonRaw = readFileSync(packageJsonPath, "utf-8")
|
|
14
14
|
if (!packageJsonRaw.includes("tscircuit")) {
|
|
15
15
|
console.error(
|
|
16
|
-
kleur.red(`No tscircuit dependencies are installed in this project.`)
|
|
16
|
+
kleur.red(`No tscircuit dependencies are installed in this project.`),
|
|
17
17
|
)
|
|
18
18
|
return false
|
|
19
19
|
}
|
|
@@ -13,7 +13,7 @@ export const deriveSelectorFromPcbComponentId = ({
|
|
|
13
13
|
})
|
|
14
14
|
if (!source_component) {
|
|
15
15
|
throw new Error(
|
|
16
|
-
`Could not find source component for pcb_component_id="${pcb_component_id}"
|
|
16
|
+
`Could not find source component for pcb_component_id="${pcb_component_id}"`,
|
|
17
17
|
)
|
|
18
18
|
}
|
|
19
19
|
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import apiServer from "
|
|
2
|
-
import frontendVfs from "
|
|
1
|
+
import apiServer from "api/index"
|
|
2
|
+
import frontendVfs from "frontend/dist/bundle"
|
|
3
3
|
import EdgeRuntimePrimitives from "@edge-runtime/primitives"
|
|
4
4
|
import mime from "mime-types"
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Handles all requests to :3020, then proxies...
|
|
8
|
-
*
|
|
8
|
+
*
|
|
9
9
|
* /api/* : to the api server
|
|
10
10
|
* /* : to the static frontend bundle inside dev-server-frontend
|
|
11
|
-
*
|
|
11
|
+
*
|
|
12
12
|
*/
|
|
13
13
|
export const devServerRequestHandler = async (bunReq: Request) => {
|
|
14
14
|
const url = new URL(bunReq.url)
|
|
@@ -48,7 +48,7 @@ export const devServerRequestHandler = async (bunReq: Request) => {
|
|
|
48
48
|
headers: {
|
|
49
49
|
"Content-Type": mime.lookup(frontendPath) || "text/plain",
|
|
50
50
|
},
|
|
51
|
-
}
|
|
51
|
+
},
|
|
52
52
|
)
|
|
53
53
|
} else {
|
|
54
54
|
return new Response(null, {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import net from
|
|
1
|
+
import net from "net"
|
|
2
2
|
|
|
3
3
|
const MAX_PORT = 65535 // Maximum valid port number
|
|
4
4
|
|
|
@@ -12,19 +12,21 @@ export const findAvailablePort = async (startPort: number): Promise<number> => {
|
|
|
12
12
|
port++
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
throw new Error(
|
|
15
|
+
throw new Error(
|
|
16
|
+
`Unable to find an available port in range ${startPort}-${MAX_PORT}`,
|
|
17
|
+
)
|
|
16
18
|
}
|
|
17
19
|
|
|
18
20
|
const isPortInUse = (port: number): Promise<boolean> => {
|
|
19
21
|
return new Promise((resolve) => {
|
|
20
22
|
const server = net.createServer()
|
|
21
|
-
server.once(
|
|
23
|
+
server.once("error", () => {
|
|
22
24
|
resolve(true)
|
|
23
25
|
})
|
|
24
|
-
server.once(
|
|
26
|
+
server.once("listening", () => {
|
|
25
27
|
server.close()
|
|
26
28
|
resolve(false)
|
|
27
29
|
})
|
|
28
30
|
server.listen(port)
|
|
29
31
|
})
|
|
30
|
-
}
|
|
32
|
+
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { AppContext } from "../../util/app-context"
|
|
2
2
|
import kleur from "kleur"
|
|
3
|
-
import { exportGerbersToZipBuffer } from "lib/export-fns/export-gerbers"
|
|
3
|
+
import { exportGerbersToZipBuffer } from "cli/lib/export-fns/export-gerbers"
|
|
4
4
|
import { AxiosInstance } from "axios"
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
5
|
+
import { exportPnpCsvToBuffer } from "cli/lib/export-fns/export-pnp-csv"
|
|
6
|
+
import { exportBomCsvToBuffer } from "cli/lib/export-fns/export-bom-csv"
|
|
7
|
+
import { soupify } from "cli/lib/soupify"
|
|
8
|
+
import { ExportRequest } from "api/db/schema"
|
|
9
9
|
|
|
10
10
|
export const uploadBufferToExportFile = async ({
|
|
11
11
|
dev_server_axios,
|
|
@@ -40,7 +40,7 @@ export const fulfillExportRequests = async (
|
|
|
40
40
|
}: {
|
|
41
41
|
dev_server_axios: AxiosInstance
|
|
42
42
|
},
|
|
43
|
-
ctx: AppContext
|
|
43
|
+
ctx: AppContext,
|
|
44
44
|
) => {
|
|
45
45
|
const export_requests: ExportRequest[] = await dev_server_axios
|
|
46
46
|
.post("/api/export_requests/list", {
|
|
@@ -51,11 +51,11 @@ export const fulfillExportRequests = async (
|
|
|
51
51
|
for (const export_request of export_requests) {
|
|
52
52
|
console.log(
|
|
53
53
|
kleur.gray(
|
|
54
|
-
`Fulfilling export request ${export_request.export_request_id}
|
|
55
|
-
)
|
|
54
|
+
`Fulfilling export request ${export_request.export_request_id}`,
|
|
55
|
+
),
|
|
56
56
|
)
|
|
57
57
|
console.log(
|
|
58
|
-
kleur.gray(` example_file_path: ${export_request.example_file_path}`)
|
|
58
|
+
kleur.gray(` example_file_path: ${export_request.example_file_path}`),
|
|
59
59
|
)
|
|
60
60
|
|
|
61
61
|
if (export_request.export_parameters.should_export_gerber_zip) {
|
|
@@ -73,16 +73,16 @@ export const fulfillExportRequests = async (
|
|
|
73
73
|
}
|
|
74
74
|
const zip_buffer = await exportGerbersToZipBuffer(
|
|
75
75
|
{
|
|
76
|
-
example_file_path: export_request.example_file_path
|
|
77
|
-
export_name: export_request.export_name
|
|
76
|
+
example_file_path: export_request.example_file_path!,
|
|
77
|
+
export_name: export_request.export_name!,
|
|
78
78
|
},
|
|
79
|
-
ctx
|
|
79
|
+
ctx,
|
|
80
80
|
)
|
|
81
81
|
|
|
82
82
|
console.log(
|
|
83
83
|
kleur.gray(
|
|
84
|
-
` uploading zip "${export_request.export_parameters.gerbers_zip_file_name}" to dev server
|
|
85
|
-
)
|
|
84
|
+
` uploading zip "${export_request.export_parameters.gerbers_zip_file_name}" to dev server...`,
|
|
85
|
+
),
|
|
86
86
|
)
|
|
87
87
|
|
|
88
88
|
await uploadBufferToExportFile({
|
|
@@ -97,14 +97,14 @@ export const fulfillExportRequests = async (
|
|
|
97
97
|
console.log(kleur.gray(`\n exporting pick'n'place...`))
|
|
98
98
|
const csv_buffer = await exportPnpCsvToBuffer(
|
|
99
99
|
{
|
|
100
|
-
example_file_path: export_request.example_file_path
|
|
101
|
-
export_name: export_request.export_name
|
|
100
|
+
example_file_path: export_request.example_file_path!,
|
|
101
|
+
export_name: export_request.export_name!,
|
|
102
102
|
},
|
|
103
|
-
ctx
|
|
103
|
+
ctx,
|
|
104
104
|
)
|
|
105
|
-
|
|
105
|
+
|
|
106
106
|
const pnpFileName = `${export_request.export_name}-${export_request.export_parameters.pnp_csv_file_name!}`
|
|
107
|
-
|
|
107
|
+
|
|
108
108
|
await uploadBufferToExportFile({
|
|
109
109
|
dev_server_axios,
|
|
110
110
|
file_buffer: csv_buffer,
|
|
@@ -117,14 +117,14 @@ export const fulfillExportRequests = async (
|
|
|
117
117
|
console.log(kleur.gray(`\n exporting bill of materials...`))
|
|
118
118
|
const csv_buffer = await exportBomCsvToBuffer(
|
|
119
119
|
{
|
|
120
|
-
example_file_path: export_request.example_file_path
|
|
121
|
-
export_name: export_request.export_name
|
|
120
|
+
example_file_path: export_request.example_file_path!,
|
|
121
|
+
export_name: export_request.export_name!,
|
|
122
122
|
},
|
|
123
|
-
ctx
|
|
123
|
+
ctx,
|
|
124
124
|
)
|
|
125
|
-
|
|
125
|
+
|
|
126
126
|
const bomFileName = `${export_request.export_name}-${export_request.export_parameters.bom_csv_file_name!}`
|
|
127
|
-
|
|
127
|
+
|
|
128
128
|
await uploadBufferToExportFile({
|
|
129
129
|
dev_server_axios,
|
|
130
130
|
file_buffer: csv_buffer,
|
|
@@ -137,10 +137,10 @@ export const fulfillExportRequests = async (
|
|
|
137
137
|
console.log(kleur.gray(`\n exporting soup...`))
|
|
138
138
|
const soup = await soupify(
|
|
139
139
|
{
|
|
140
|
-
filePath: export_request.example_file_path
|
|
141
|
-
exportName: export_request.export_name
|
|
140
|
+
filePath: export_request.example_file_path!,
|
|
141
|
+
exportName: export_request.export_name!,
|
|
142
142
|
},
|
|
143
|
-
ctx
|
|
143
|
+
ctx,
|
|
144
144
|
)
|
|
145
145
|
|
|
146
146
|
await uploadBufferToExportFile({
|
|
@@ -18,12 +18,12 @@ export const getDevServerAxios = ({ serverUrl }: { serverUrl: string }) => {
|
|
|
18
18
|
err.config.url
|
|
19
19
|
}\n\n${JSON.stringify(err.response?.data, null, " ")}`
|
|
20
20
|
.replace(/\\n/g, "\n")
|
|
21
|
-
.replace(/\\"/g, '"')
|
|
22
|
-
)
|
|
21
|
+
.replace(/\\"/g, '"'),
|
|
22
|
+
),
|
|
23
23
|
)
|
|
24
24
|
console.log(kleur.yellow("[Request Body]:"), err.config.data)
|
|
25
25
|
return Promise.reject(err)
|
|
26
|
-
}
|
|
26
|
+
},
|
|
27
27
|
)
|
|
28
28
|
return devServerAxios
|
|
29
29
|
}
|
|
@@ -2,7 +2,7 @@ import crypto from "crypto"
|
|
|
2
2
|
import $ from "dax-sh"
|
|
3
3
|
import fs from "fs"
|
|
4
4
|
import kleur from "kleur"
|
|
5
|
-
import posthog from "lib/posthog"
|
|
5
|
+
import posthog from "cli/lib/posthog"
|
|
6
6
|
import open from "open"
|
|
7
7
|
import * as Path from "path"
|
|
8
8
|
import prompts from "prompts"
|
|
@@ -77,8 +77,8 @@ export const devCmd = async (ctx: AppContext, args: any) => {
|
|
|
77
77
|
|
|
78
78
|
console.log(
|
|
79
79
|
kleur.green(
|
|
80
|
-
`\n--------------------------------------------\n\nStarting dev server http://127.0.0.1:${port}\n\n--------------------------------------------\n\n
|
|
81
|
-
)
|
|
80
|
+
`\n--------------------------------------------\n\nStarting dev server http://127.0.0.1:${port}\n\n--------------------------------------------\n\n`,
|
|
81
|
+
),
|
|
82
82
|
)
|
|
83
83
|
const serverUrl = `http://127.0.0.1:${port}`
|
|
84
84
|
const devServerAxios = getDevServerAxios({ serverUrl })
|
|
@@ -101,7 +101,7 @@ export const devCmd = async (ctx: AppContext, args: any) => {
|
|
|
101
101
|
{
|
|
102
102
|
package_name: packageName,
|
|
103
103
|
},
|
|
104
|
-
ctx
|
|
104
|
+
ctx,
|
|
105
105
|
)
|
|
106
106
|
|
|
107
107
|
// Soupify all examples
|
|
@@ -3,14 +3,14 @@ export const inferExportNameFromSource = (sourceContent: string): string => {
|
|
|
3
3
|
return "default"
|
|
4
4
|
}
|
|
5
5
|
const matches = Array.from(
|
|
6
|
-
sourceContent.matchAll(/export\s+(const|function)\s+([A-Z]\w+)\s*=?/g)
|
|
6
|
+
sourceContent.matchAll(/export\s+(const|function)\s+([A-Z]\w+)\s*=?/g),
|
|
7
7
|
).map((m) => m[2])
|
|
8
8
|
if (matches.length === 0) {
|
|
9
9
|
throw new Error(`No export detected in "${sourceContent}"`)
|
|
10
10
|
}
|
|
11
11
|
if (matches.length > 1) {
|
|
12
12
|
throw new Error(
|
|
13
|
-
`Multiple exports detected in "${sourceContent}", only single exports currently working
|
|
13
|
+
`Multiple exports detected in "${sourceContent}", only single exports currently working`,
|
|
14
14
|
)
|
|
15
15
|
}
|
|
16
16
|
return matches[0]
|
|
@@ -2,8 +2,9 @@ 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 { inferExportNameFromSource } from "./infer-export-name-from-source"
|
|
7
|
+
import { AppContext } from "cli/lib/util/app-context"
|
|
7
8
|
|
|
8
9
|
export const soupifyAndUploadExampleFile = async (
|
|
9
10
|
{
|
|
@@ -15,7 +16,7 @@ export const soupifyAndUploadExampleFile = async (
|
|
|
15
16
|
exampleFileName: string
|
|
16
17
|
devServerAxios: AxiosInstance
|
|
17
18
|
},
|
|
18
|
-
ctx:
|
|
19
|
+
ctx: Pick<AppContext, "runtime" | "params">,
|
|
19
20
|
) => {
|
|
20
21
|
try {
|
|
21
22
|
const startTime = Date.now()
|
|
@@ -30,7 +31,7 @@ export const soupifyAndUploadExampleFile = async (
|
|
|
30
31
|
filePath: examplePath,
|
|
31
32
|
exportName,
|
|
32
33
|
},
|
|
33
|
-
ctx
|
|
34
|
+
ctx,
|
|
34
35
|
)
|
|
35
36
|
.then((soup) => ({ soup, error: null }))
|
|
36
37
|
.catch((e) => ({ error: e, soup: undefined }))
|
|
@@ -52,8 +53,8 @@ export const soupifyAndUploadExampleFile = async (
|
|
|
52
53
|
kleur.gray(
|
|
53
54
|
`[ done ] [ ${Math.round(timeTaken)
|
|
54
55
|
.toString()
|
|
55
|
-
.padStart(5, " ")}ms ] ${exampleFileName}
|
|
56
|
-
)
|
|
56
|
+
.padStart(5, " ")}ms ] ${exampleFileName}!`,
|
|
57
|
+
),
|
|
57
58
|
)
|
|
58
59
|
} catch (e: any) {
|
|
59
60
|
console.log(kleur.red(`[ error ] ${e.toString()}`))
|