@tscircuit/cli 0.0.393 → 0.1.1
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/bun-formatcheck.yml +26 -0
- package/.github/workflows/bun-pver-release.yml +25 -0
- package/.github/workflows/{typecheck.yml → bun-typecheck.yml} +0 -3
- package/LICENSE +21 -0
- package/README.md +30 -36
- package/biome.json +9 -9
- package/bun.lockb +0 -0
- package/cli/CliContext.ts +8 -0
- package/cli/auth/login/register.ts +73 -0
- package/cli/auth/logout/register.ts +11 -0
- package/cli/auth/register.ts +5 -0
- package/cli/config/print/register.ts +12 -0
- package/cli/config/register.ts +5 -0
- package/cli/dev/register.ts +111 -0
- package/cli/main.ts +31 -0
- package/dist/main.js +473 -0
- package/docs/file-server-api-usage.md +57 -0
- package/docs/run-frame-usage.md +14 -0
- package/example-dir/manual-edits.json +1 -0
- package/example-dir/snippet.d.ts +13 -0
- package/example-dir/snippet.tsx +20 -0
- package/example-dir/types.d.ts +11 -0
- package/lib/cli-config/TypedConfigStore.ts +50 -0
- package/lib/cli-config/index.ts +16 -0
- package/lib/dependency-analysis/DependencyAnalyzer.ts +129 -0
- package/lib/dependency-analysis/getLocalFileDependencies.ts +101 -0
- package/lib/dependency-analysis/installNodeModuleTypes.ts +74 -0
- package/lib/index.ts +2 -0
- package/lib/project-config/index.ts +5 -0
- package/lib/registry-api/endpoint-types.ts +20 -0
- package/lib/registry-api/get-ky.ts +30 -0
- package/lib/server/EventsWatcher.ts +75 -0
- package/lib/server/createServer.ts +62 -0
- package/lib/site/getIndex.ts +18 -0
- package/package.json +27 -144
- package/tsconfig.json +25 -22
- package/.github/workflows/formatbot.yml +0 -63
- package/.github/workflows/release.yml +0 -40
- package/.github/workflows/test.yml +0 -32
- package/.github/workflows/windows-tests.yml +0 -32
- package/.prettierrc +0 -1
- package/DEVELOPMENT.md +0 -7
- package/api/README.md +0 -3
- package/api/db/generic-json-level.ts +0 -123
- package/api/db/get-db.ts +0 -26
- package/api/db/schema.ts +0 -65
- package/api/db/zod-level-db.ts +0 -148
- package/api/index.ts +0 -4
- package/api/lib/middlewares/with-db.ts +0 -18
- package/api/lib/middlewares/with-debug-request-logging.ts +0 -13
- package/api/lib/middlewares/with-error-response.ts +0 -37
- package/api/lib/with-winter-spec.ts +0 -9
- package/api/lib/zod/export_parameters.ts +0 -25
- package/api/routes/api/db/download.ts +0 -25
- package/api/routes/api/dev_package_examples/create.ts +0 -43
- package/api/routes/api/dev_package_examples/get.ts +0 -46
- package/api/routes/api/dev_package_examples/list.ts +0 -36
- package/api/routes/api/dev_package_examples/update.ts +0 -59
- package/api/routes/api/dev_server/reset.ts +0 -13
- package/api/routes/api/export_files/create.ts +0 -27
- package/api/routes/api/export_files/download.ts +0 -25
- package/api/routes/api/export_requests/create.ts +0 -30
- package/api/routes/api/export_requests/get.ts +0 -43
- package/api/routes/api/export_requests/list.ts +0 -26
- package/api/routes/api/export_requests/update.ts +0 -34
- package/api/routes/api/health.ts +0 -11
- package/api/routes/api/package_info/create.ts +0 -26
- package/api/routes/api/package_info/get.ts +0 -16
- package/api/routes/health.ts +0 -11
- package/api/routes/index.ts +0 -16
- package/api/server.ts +0 -20
- package/api/static-routes.ts +0 -24
- package/api/tests/fixtures/get-test-server.ts +0 -31
- package/api/tests/fixtures/start-server.ts +0 -41
- package/api/tests/routes/dev_package_examples/create.test.ts +0 -19
- package/api/tests/routes/dev_package_examples/get.test.ts +0 -25
- package/api/tests/routes/dev_package_examples/list.test.ts +0 -32
- package/api/tests/routes/dev_package_examples/update.test.ts +0 -38
- package/api/tests/routes/export_files/create.test.ts +0 -18
- package/api/tests/routes/export_files/download.test.ts +0 -29
- package/api/tests/routes/export_requests/create.test.ts +0 -24
- package/api/tests/routes/export_requests/get.test.ts +0 -41
- package/api/tests/routes/export_requests/list.test.ts +0 -35
- package/api/tests/routes/export_requests/update.test.ts +0 -50
- package/api/tests/routes/health.test.ts +0 -10
- package/bunfig.toml +0 -2
- package/cli/cli.ts +0 -13
- package/cli/lib/cmd-fns/add.ts +0 -34
- package/cli/lib/cmd-fns/auth-login.ts +0 -59
- package/cli/lib/cmd-fns/auth-logout.ts +0 -7
- package/cli/lib/cmd-fns/auth-sessions-create.ts +0 -3
- package/cli/lib/cmd-fns/auth-sessions-get.ts +0 -3
- package/cli/lib/cmd-fns/auth-sessions-list.ts +0 -5
- package/cli/lib/cmd-fns/config-clear.ts +0 -5
- package/cli/lib/cmd-fns/config-print-config.ts +0 -6
- package/cli/lib/cmd-fns/config-reveal-location.ts +0 -5
- package/cli/lib/cmd-fns/config-set-log-requests.ts +0 -7
- package/cli/lib/cmd-fns/config-set-registry.ts +0 -9
- package/cli/lib/cmd-fns/config-set-runtime.ts +0 -7
- package/cli/lib/cmd-fns/config-set-session.ts +0 -7
- package/cli/lib/cmd-fns/dev/check-if-initialized.ts +0 -22
- package/cli/lib/cmd-fns/dev/derive-selector-from-pcb-component-id.ts +0 -23
- package/cli/lib/cmd-fns/dev/dev-server-request-handler.ts +0 -61
- package/cli/lib/cmd-fns/dev/find-available-port.ts +0 -32
- package/cli/lib/cmd-fns/dev/fulfill-export-requests.ts +0 -162
- package/cli/lib/cmd-fns/dev/get-dev-server-axios.ts +0 -29
- package/cli/lib/cmd-fns/dev/index.ts +0 -168
- package/cli/lib/cmd-fns/dev/infer-export-name-from-source.ts +0 -17
- package/cli/lib/cmd-fns/dev/mark-all-examples-loading.ts +0 -18
- package/cli/lib/cmd-fns/dev/soupify-and-upload-example-file.ts +0 -62
- package/cli/lib/cmd-fns/dev/start-dev-server.ts +0 -34
- package/cli/lib/cmd-fns/dev/start-edit-event-watcher.ts +0 -347
- package/cli/lib/cmd-fns/dev/start-export-request-watcher.ts +0 -33
- package/cli/lib/cmd-fns/dev/start-fs-watcher.ts +0 -54
- package/cli/lib/cmd-fns/dev/upload-examples-from-directory.ts +0 -42
- package/cli/lib/cmd-fns/dev-server-fulfill-export-requests.ts +0 -43
- package/cli/lib/cmd-fns/dev-server-upload.ts +0 -56
- package/cli/lib/cmd-fns/export-gerbers.ts +0 -28
- package/cli/lib/cmd-fns/export-kicad-pcb.ts +0 -36
- package/cli/lib/cmd-fns/export-pnp-csv.ts +0 -32
- package/cli/lib/cmd-fns/gen-jlcpcb-component.ts +0 -64
- package/cli/lib/cmd-fns/go.ts +0 -14
- package/cli/lib/cmd-fns/index.ts +0 -46
- package/cli/lib/cmd-fns/init/create-or-modify-npmrc.ts +0 -21
- package/cli/lib/cmd-fns/init/get-generated-npmrc.ts +0 -8
- package/cli/lib/cmd-fns/init/get-generated-readme.ts +0 -41
- package/cli/lib/cmd-fns/init/get-generated-tsconfig.ts +0 -34
- package/cli/lib/cmd-fns/init/index.ts +0 -193
- package/cli/lib/cmd-fns/install.ts +0 -34
- package/cli/lib/cmd-fns/lint.ts +0 -43
- package/cli/lib/cmd-fns/open.ts +0 -19
- package/cli/lib/cmd-fns/package-examples-create.ts +0 -36
- package/cli/lib/cmd-fns/package-examples-get.ts +0 -20
- package/cli/lib/cmd-fns/package-examples-list.ts +0 -18
- package/cli/lib/cmd-fns/package-files-create.ts +0 -31
- package/cli/lib/cmd-fns/package-files-download.ts +0 -29
- package/cli/lib/cmd-fns/package-files-get.ts +0 -3
- package/cli/lib/cmd-fns/package-files-list.ts +0 -28
- package/cli/lib/cmd-fns/package-files-upload-directory.ts +0 -6
- package/cli/lib/cmd-fns/package-releases-create.ts +0 -35
- package/cli/lib/cmd-fns/package-releases-get.ts +0 -3
- package/cli/lib/cmd-fns/package-releases-list.ts +0 -32
- package/cli/lib/cmd-fns/package-releases-update.ts +0 -45
- package/cli/lib/cmd-fns/packages-create.ts +0 -16
- package/cli/lib/cmd-fns/packages-get.ts +0 -16
- package/cli/lib/cmd-fns/packages-list.ts +0 -16
- package/cli/lib/cmd-fns/publish/index.ts +0 -336
- package/cli/lib/cmd-fns/remove.ts +0 -31
- package/cli/lib/cmd-fns/render.ts +0 -45
- package/cli/lib/cmd-fns/soupify.ts +0 -31
- package/cli/lib/cmd-fns/uninstall.ts +0 -31
- package/cli/lib/cmd-fns/version.ts +0 -38
- package/cli/lib/create-config-manager.ts +0 -97
- package/cli/lib/export-fns/export-bom-csv.ts +0 -32
- package/cli/lib/export-fns/export-gerbers.ts +0 -108
- package/cli/lib/export-fns/export-kicad-pcb.ts +0 -32
- package/cli/lib/export-fns/export-pnp-csv.ts +0 -31
- package/cli/lib/get-program.ts +0 -387
- package/cli/lib/param-handlers/index.ts +0 -21
- package/cli/lib/param-handlers/interact-for-local-directory.ts +0 -58
- package/cli/lib/param-handlers/interact-for-local-file.ts +0 -59
- package/cli/lib/param-handlers/interact-for-package-example-id.ts +0 -25
- package/cli/lib/param-handlers/interact-for-package-name-with-version.ts +0 -63
- package/cli/lib/param-handlers/interact-for-package-name.ts +0 -45
- package/cli/lib/param-handlers/interact-for-package-release-id.ts +0 -15
- package/cli/lib/param-handlers/interact-for-registry-url.ts +0 -27
- package/cli/lib/param-handlers/interact-for-runtime.ts +0 -33
- package/cli/lib/param-handlers/param-handler-type.ts +0 -7
- package/cli/lib/posthog.ts +0 -23
- package/cli/lib/soupify/get-export-name-from-file.ts +0 -29
- package/cli/lib/soupify/get-tmp-entrpoint-filepath.ts +0 -15
- package/cli/lib/soupify/index.ts +0 -1
- package/cli/lib/soupify/run-entrypoint-file.ts +0 -59
- package/cli/lib/soupify/soupify-with-core.ts +0 -74
- package/cli/lib/soupify/soupify.ts +0 -6
- package/cli/lib/util/app-context.ts +0 -17
- package/cli/lib/util/create-context-and-run-program.ts +0 -168
- package/cli/lib/util/get-all-package-files.ts +0 -66
- package/cli/lib/util/lint-project.ts +0 -137
- package/cli/tests/export-gerber-keyboard.test.ts +0 -16
- package/cli/tests/export-gerber.test.ts +0 -49
- package/cli/tests/export-kicad-pcb.test.ts +0 -23
- package/cli/tests/export-pnp-csv.test.ts +0 -24
- package/cli/tests/fixtures/preload.ts +0 -54
- package/cli/tests/init.test.ts +0 -9
- package/cli/tests/open.test.ts +0 -9
- package/cli/tests/soupify-builder.test.ts +0 -9
- package/cli/tests/soupify-core.test.ts +0 -9
- package/dist/cli.js +0 -3676
- package/docs/EDIT_EVENT_PIPELINE.md +0 -34
- package/example-project/README.md +0 -18
- package/example-project/examples/basic-capacitor.tsx +0 -5
- package/example-project/examples/basic-chip.tsx +0 -26
- package/example-project/examples/basic-resistor.tsx +0 -3
- package/example-project/examples/macrokeypad.tsx +0 -59
- package/example-project/index.ts +0 -1
- package/example-project/package.json +0 -5
- package/example-project/src/ArduinoProMicroBreakout.tsx +0 -37
- package/example-project/src/Key.tsx +0 -46
- package/example-project/src/Keyswitch.tsx +0 -26
- package/example-project/src/KeyswitchSocket.tsx +0 -56
- package/example-project/src/MyCircuit.tsx +0 -38
- package/example-project/src/manual-edits.ts +0 -93
- package/frontend/README.md +0 -3
- package/frontend/bun.lockb +0 -0
- package/frontend/components/command-k.tsx +0 -86
- package/frontend/components/dialogs/generic-export-dialog.tsx +0 -189
- package/frontend/components/dialogs/gerber-export-dialog.tsx +0 -168
- package/frontend/components/global-context-providers.tsx +0 -11
- package/frontend/components/select-example-search.tsx +0 -118
- package/frontend/components/ui/alert-dialog.tsx +0 -139
- package/frontend/components/ui/alert.tsx +0 -59
- package/frontend/components/ui/breadcrumb.tsx +0 -115
- package/frontend/components/ui/button.tsx +0 -57
- package/frontend/components/ui/card.tsx +0 -76
- package/frontend/components/ui/command.tsx +0 -153
- package/frontend/components/ui/context-menu.tsx +0 -202
- package/frontend/components/ui/dialog.tsx +0 -120
- package/frontend/components/ui/menubar.tsx +0 -238
- package/frontend/components/ui/navigation-menu.tsx +0 -128
- package/frontend/components/ui/popover.tsx +0 -31
- package/frontend/components/ui/select.tsx +0 -162
- package/frontend/components/ui/tabs.tsx +0 -53
- package/frontend/components/ui/toggle-group.tsx +0 -59
- package/frontend/components/ui/toggle.tsx +0 -43
- package/frontend/components/ui/tooltip.tsx +0 -28
- package/frontend/components.json +0 -17
- package/frontend/hooks/toast-if-api-not-connected.ts +0 -23
- package/frontend/hooks/use-active-dev-package-example-lite.ts +0 -39
- package/frontend/hooks/use-dev-package-examples.tsx +0 -18
- package/frontend/hooks/use-global-store.ts +0 -42
- package/frontend/index.css +0 -76
- package/frontend/index.html +0 -13
- package/frontend/lib/utils.ts +0 -6
- package/frontend/main.tsx +0 -13
- package/frontend/tailwind.config.js +0 -74
- package/frontend/views/App.tsx +0 -22
- package/frontend/views/Header.tsx +0 -55
- package/frontend/views/HeaderMenu.tsx +0 -326
- package/frontend/views/MainContentView.tsx +0 -172
- package/frontend/vite-env.d.ts +0 -1
- package/frontend/vite.config.ts +0 -50
- package/renovate.json +0 -15
- package/scripts/build-cli.ts +0 -12
- package/tsup.config.ts +0 -7
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { AxiosInstance } from "axios"
|
|
2
|
-
import { devServerRequestHandler } from "./dev-server-request-handler"
|
|
3
|
-
|
|
4
|
-
export const startDevServer = async ({
|
|
5
|
-
port,
|
|
6
|
-
devServerAxios,
|
|
7
|
-
}: {
|
|
8
|
-
port: number
|
|
9
|
-
devServerAxios: AxiosInstance
|
|
10
|
-
}) => {
|
|
11
|
-
let server: any
|
|
12
|
-
if (typeof Bun !== "undefined") {
|
|
13
|
-
server = Bun.serve({
|
|
14
|
-
fetch: devServerRequestHandler,
|
|
15
|
-
development: false,
|
|
16
|
-
port,
|
|
17
|
-
})
|
|
18
|
-
} else {
|
|
19
|
-
// Hono messes up the globals, only import it if we don't have Bun
|
|
20
|
-
const { Hono } = await import("hono")
|
|
21
|
-
const { serve } = await import("@hono/node-server")
|
|
22
|
-
const honoApp = new Hono()
|
|
23
|
-
honoApp.all("/*", (c) => devServerRequestHandler(c.req.raw))
|
|
24
|
-
server = serve({
|
|
25
|
-
fetch: honoApp.fetch,
|
|
26
|
-
port,
|
|
27
|
-
})
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
console.log("Running health check against dev server...")
|
|
31
|
-
await devServerAxios.get("/api/health")
|
|
32
|
-
|
|
33
|
-
return server
|
|
34
|
-
}
|
|
@@ -1,347 +0,0 @@
|
|
|
1
|
-
import type { DevPackageExample } from "api/db/schema"
|
|
2
|
-
import type { AxiosInstance } from "axios"
|
|
3
|
-
import kleur from "kleur"
|
|
4
|
-
import { AppContext } from "cli/lib/util/app-context"
|
|
5
|
-
import fg from "fast-glob"
|
|
6
|
-
import fs from "fs"
|
|
7
|
-
import { Project, ts } from "ts-morph"
|
|
8
|
-
import * as Path from "path/posix"
|
|
9
|
-
import { deriveSelectorFromPcbComponentId } from "./derive-selector-from-pcb-component-id"
|
|
10
|
-
import type { EditEvent } from "@tscircuit/manual-edit-events"
|
|
11
|
-
import {
|
|
12
|
-
getManualTraceHintFromEvent,
|
|
13
|
-
ManualTraceHint,
|
|
14
|
-
ManualEditFile,
|
|
15
|
-
} from "@tscircuit/layout"
|
|
16
|
-
import JSON5 from "json5"
|
|
17
|
-
import Debug from "debug"
|
|
18
|
-
|
|
19
|
-
const debug = Debug("tscircuit:cli:edit-event-watcher")
|
|
20
|
-
|
|
21
|
-
type ManualPcbPosition = Required<ManualEditFile>["pcb_placements"][number]
|
|
22
|
-
|
|
23
|
-
export const startEditEventWatcher = async (
|
|
24
|
-
{
|
|
25
|
-
devServerAxios,
|
|
26
|
-
}: {
|
|
27
|
-
devServerAxios: AxiosInstance
|
|
28
|
-
},
|
|
29
|
-
ctx: AppContext,
|
|
30
|
-
) => {
|
|
31
|
-
let running = true
|
|
32
|
-
;(async () => {
|
|
33
|
-
let last_edit_event_update_time: Record<string, string> = {}
|
|
34
|
-
|
|
35
|
-
while (running) {
|
|
36
|
-
try {
|
|
37
|
-
const dev_package_examples: DevPackageExample[] = await devServerAxios
|
|
38
|
-
.post("/api/dev_package_examples/list", {})
|
|
39
|
-
.then((r) => r.data.dev_package_examples)
|
|
40
|
-
|
|
41
|
-
for (const dev_package_example of dev_package_examples) {
|
|
42
|
-
const dev_package_example_id: number =
|
|
43
|
-
dev_package_example.dev_package_example_id as any
|
|
44
|
-
|
|
45
|
-
const last_recorded_update_time =
|
|
46
|
-
last_edit_event_update_time[dev_package_example_id]
|
|
47
|
-
|
|
48
|
-
if (
|
|
49
|
-
last_recorded_update_time !==
|
|
50
|
-
dev_package_example.edit_events_last_updated_at
|
|
51
|
-
) {
|
|
52
|
-
console.log(
|
|
53
|
-
kleur.gray(
|
|
54
|
-
`Edit event detected for dev_package_example ${dev_package_example.dev_package_example_id}`,
|
|
55
|
-
),
|
|
56
|
-
)
|
|
57
|
-
debug(`file_path: ${dev_package_example.file_path}`)
|
|
58
|
-
|
|
59
|
-
last_edit_event_update_time[dev_package_example_id] =
|
|
60
|
-
dev_package_example.edit_events_last_updated_at! // TODO last_edit_event_updated_at
|
|
61
|
-
|
|
62
|
-
debug(` getting new edit events...`)
|
|
63
|
-
|
|
64
|
-
const dev_package_example_full = await devServerAxios
|
|
65
|
-
.post("/api/dev_package_examples/get", {
|
|
66
|
-
dev_package_example_id,
|
|
67
|
-
})
|
|
68
|
-
.then((r) => r.data.dev_package_example)
|
|
69
|
-
|
|
70
|
-
// 1. Find the *.manual-edits.ts, if there are multiple error
|
|
71
|
-
const manual_edit_files = fg.sync(
|
|
72
|
-
["**/*.manual-edits.ts", "**/manual-edits.ts"],
|
|
73
|
-
{
|
|
74
|
-
cwd: ctx.cwd,
|
|
75
|
-
ignore: ["node_modules"],
|
|
76
|
-
},
|
|
77
|
-
)
|
|
78
|
-
|
|
79
|
-
if (manual_edit_files.length === 0) {
|
|
80
|
-
console.log(
|
|
81
|
-
kleur.red(
|
|
82
|
-
`No manual edit files found in "${ctx.cwd}", please create a file "manual-edits.ts" or "*.manual-edits.ts" to persist manual edits`,
|
|
83
|
-
),
|
|
84
|
-
)
|
|
85
|
-
continue
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
if (manual_edit_files.length > 1) {
|
|
89
|
-
console.log(
|
|
90
|
-
kleur.red(
|
|
91
|
-
`Multiple manual edit files found, tsci currently doesn't know how to handle this, you should go upvote an issue`,
|
|
92
|
-
),
|
|
93
|
-
)
|
|
94
|
-
for (let i = 0; i < manual_edit_files.length; i++) {
|
|
95
|
-
console.log(
|
|
96
|
-
kleur.gray(` file ${i + 1}: ${manual_edit_files[i]}`),
|
|
97
|
-
)
|
|
98
|
-
}
|
|
99
|
-
continue
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
const manual_edit_file = manual_edit_files[0]
|
|
103
|
-
const manual_edit_file_content = fs.readFileSync(
|
|
104
|
-
Path.join(ctx.cwd, manual_edit_file),
|
|
105
|
-
"utf-8",
|
|
106
|
-
)
|
|
107
|
-
|
|
108
|
-
debug(` found manual edit file: ${manual_edit_file}`)
|
|
109
|
-
|
|
110
|
-
// 2. Convert the edit events into ManualPcbPosition[] and append,
|
|
111
|
-
// removing any old placements/positions for the same selector.
|
|
112
|
-
// We can completely rewrite the file here for now (we'll need
|
|
113
|
-
// to preserve comments etc. later)
|
|
114
|
-
|
|
115
|
-
const edit_events: EditEvent[] =
|
|
116
|
-
dev_package_example_full.completed_edit_events ?? []
|
|
117
|
-
|
|
118
|
-
if (edit_events.length === 0) continue
|
|
119
|
-
|
|
120
|
-
const project = new Project()
|
|
121
|
-
|
|
122
|
-
const ts_manual_edits_file = project.createSourceFile(
|
|
123
|
-
"manual-edits.ts",
|
|
124
|
-
manual_edit_file_content,
|
|
125
|
-
)
|
|
126
|
-
|
|
127
|
-
// Access the default export declaration
|
|
128
|
-
const default_export_dec = ts_manual_edits_file
|
|
129
|
-
.getDefaultExportSymbol()!
|
|
130
|
-
.getDeclarations()[0]
|
|
131
|
-
|
|
132
|
-
// Get the object literal expression from the export default statement
|
|
133
|
-
const object_literal =
|
|
134
|
-
default_export_dec.getFirstChildByKindOrThrow(
|
|
135
|
-
ts.SyntaxKind.ObjectLiteralExpression,
|
|
136
|
-
)
|
|
137
|
-
|
|
138
|
-
// Get the `pcb_placements` property
|
|
139
|
-
const pcb_placements_ts =
|
|
140
|
-
object_literal.getPropertyOrThrow("pcb_placements")
|
|
141
|
-
|
|
142
|
-
if (object_literal.getProperty("edit_events") === undefined) {
|
|
143
|
-
object_literal.addPropertyAssignment({
|
|
144
|
-
name: "edit_events",
|
|
145
|
-
initializer: "[]",
|
|
146
|
-
})
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
const edit_events_ts =
|
|
150
|
-
object_literal.getPropertyOrThrow("edit_events")
|
|
151
|
-
|
|
152
|
-
if (
|
|
153
|
-
object_literal.getProperty("manual_trace_hints") === undefined
|
|
154
|
-
) {
|
|
155
|
-
object_literal.addPropertyAssignment({
|
|
156
|
-
name: "manual_trace_hints",
|
|
157
|
-
initializer: "[]",
|
|
158
|
-
})
|
|
159
|
-
}
|
|
160
|
-
const manual_trace_hints_ts =
|
|
161
|
-
object_literal.getPropertyOrThrow("manual_trace_hints")
|
|
162
|
-
|
|
163
|
-
let pcb_placements: (ManualPcbPosition & {
|
|
164
|
-
_edit_event_id?: string
|
|
165
|
-
})[]
|
|
166
|
-
let in_file_edit_events: EditEvent[]
|
|
167
|
-
let manual_trace_hints: ManualTraceHint[]
|
|
168
|
-
try {
|
|
169
|
-
pcb_placements = JSON5.parse(
|
|
170
|
-
pcb_placements_ts.getText().replace(/pcb_placements:\s/, ""),
|
|
171
|
-
)
|
|
172
|
-
} catch (e: any) {
|
|
173
|
-
console.log(
|
|
174
|
-
kleur.red(
|
|
175
|
-
`Error parsing pcb_placements from manual edits file: ${pcb_placements_ts.getText()} ${e.toString()}`,
|
|
176
|
-
),
|
|
177
|
-
)
|
|
178
|
-
continue
|
|
179
|
-
}
|
|
180
|
-
try {
|
|
181
|
-
in_file_edit_events = JSON5.parse(
|
|
182
|
-
edit_events_ts.getText().replace(/edit_events:\s/, ""),
|
|
183
|
-
)
|
|
184
|
-
} catch (e: any) {
|
|
185
|
-
console.log(
|
|
186
|
-
kleur.red(
|
|
187
|
-
`Error parsing edit_events from manual edits file: ${edit_events_ts.getText()} ${e.toString()}`,
|
|
188
|
-
),
|
|
189
|
-
)
|
|
190
|
-
continue
|
|
191
|
-
}
|
|
192
|
-
try {
|
|
193
|
-
manual_trace_hints = JSON5.parse(
|
|
194
|
-
manual_trace_hints_ts
|
|
195
|
-
.getText()
|
|
196
|
-
.replace(/manual_trace_hints:\s/, ""),
|
|
197
|
-
)
|
|
198
|
-
} catch (e: any) {
|
|
199
|
-
console.log(
|
|
200
|
-
kleur.red(
|
|
201
|
-
`Error parsing manual_trace_hints from manual edits file: ${pcb_placements_ts.getText()} ${e.toString()}`,
|
|
202
|
-
),
|
|
203
|
-
)
|
|
204
|
-
continue
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
const handled_edit_events = new Set<string>(
|
|
208
|
-
pcb_placements
|
|
209
|
-
.map((p) => (p as any)._edit_event_id)
|
|
210
|
-
.concat(in_file_edit_events.map((a) => a.edit_event_id)),
|
|
211
|
-
)
|
|
212
|
-
|
|
213
|
-
// Add PCB placements from edit events
|
|
214
|
-
for (const incoming_edit_event of edit_events) {
|
|
215
|
-
if (handled_edit_events.has(incoming_edit_event.edit_event_id))
|
|
216
|
-
continue
|
|
217
|
-
|
|
218
|
-
debug(
|
|
219
|
-
`incoming_edit_event: ${JSON.stringify(incoming_edit_event)}`,
|
|
220
|
-
)
|
|
221
|
-
|
|
222
|
-
if (
|
|
223
|
-
incoming_edit_event.pcb_edit_event_type ===
|
|
224
|
-
"edit_component_location"
|
|
225
|
-
) {
|
|
226
|
-
// TODO Figure out a good selector for this pcb_component
|
|
227
|
-
let pcb_component_selector: string | null = null
|
|
228
|
-
if (incoming_edit_event.pcb_component_id) {
|
|
229
|
-
pcb_component_selector = deriveSelectorFromPcbComponentId({
|
|
230
|
-
soup: dev_package_example_full.tscircuit_soup,
|
|
231
|
-
pcb_component_id: incoming_edit_event.pcb_component_id,
|
|
232
|
-
})
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
debug(
|
|
236
|
-
`edit event pcb_component_selector: "${pcb_component_selector}"`,
|
|
237
|
-
)
|
|
238
|
-
|
|
239
|
-
// TODO we'll need to work past this for edit_event_type=edit_trace
|
|
240
|
-
if (!pcb_component_selector) continue
|
|
241
|
-
|
|
242
|
-
const existing_placement_for_selector = pcb_placements.find(
|
|
243
|
-
(pp) => pp.selector === pcb_component_selector,
|
|
244
|
-
)
|
|
245
|
-
|
|
246
|
-
if (!existing_placement_for_selector) {
|
|
247
|
-
console.log(
|
|
248
|
-
kleur.gray(
|
|
249
|
-
` adding PCB placement from edit event for "${pcb_component_selector}"`,
|
|
250
|
-
),
|
|
251
|
-
)
|
|
252
|
-
|
|
253
|
-
pcb_placements.push({
|
|
254
|
-
_edit_event_id: incoming_edit_event.edit_event_id,
|
|
255
|
-
selector: pcb_component_selector,
|
|
256
|
-
center: incoming_edit_event.new_center,
|
|
257
|
-
relative_to: "group_center",
|
|
258
|
-
})
|
|
259
|
-
} else {
|
|
260
|
-
existing_placement_for_selector.center =
|
|
261
|
-
incoming_edit_event.new_center
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
// Edit the pcb placements object
|
|
265
|
-
pcb_placements_ts.replaceWithText(
|
|
266
|
-
`pcb_placements: ${JSON.stringify(
|
|
267
|
-
pcb_placements,
|
|
268
|
-
null,
|
|
269
|
-
" ",
|
|
270
|
-
)}`,
|
|
271
|
-
)
|
|
272
|
-
|
|
273
|
-
// Save the file
|
|
274
|
-
fs.writeFileSync(
|
|
275
|
-
Path.join(ctx.cwd, manual_edit_file),
|
|
276
|
-
ts_manual_edits_file.getFullText(),
|
|
277
|
-
)
|
|
278
|
-
await devServerAxios.post("/api/dev_package_examples/update", {
|
|
279
|
-
dev_package_example_id,
|
|
280
|
-
edit_events_last_applied_at:
|
|
281
|
-
dev_package_example.edit_events_last_updated_at,
|
|
282
|
-
})
|
|
283
|
-
} else if (
|
|
284
|
-
incoming_edit_event.pcb_edit_event_type === "edit_trace_hint"
|
|
285
|
-
) {
|
|
286
|
-
const new_trace_hint = getManualTraceHintFromEvent(
|
|
287
|
-
dev_package_example_full.tscircuit_soup,
|
|
288
|
-
incoming_edit_event,
|
|
289
|
-
)
|
|
290
|
-
|
|
291
|
-
manual_trace_hints_ts.replaceWithText(
|
|
292
|
-
`manual_trace_hints: ${JSON.stringify(
|
|
293
|
-
manual_trace_hints
|
|
294
|
-
.filter(
|
|
295
|
-
(th) =>
|
|
296
|
-
th.pcb_port_selector !==
|
|
297
|
-
new_trace_hint.pcb_port_selector,
|
|
298
|
-
)
|
|
299
|
-
.concat([new_trace_hint]),
|
|
300
|
-
null,
|
|
301
|
-
" ",
|
|
302
|
-
)}`,
|
|
303
|
-
)
|
|
304
|
-
|
|
305
|
-
fs.writeFileSync(
|
|
306
|
-
Path.join(ctx.cwd, manual_edit_file),
|
|
307
|
-
ts_manual_edits_file.getFullText(),
|
|
308
|
-
)
|
|
309
|
-
await devServerAxios.post("/api/dev_package_examples/update", {
|
|
310
|
-
dev_package_example_id,
|
|
311
|
-
edit_events_last_applied_at:
|
|
312
|
-
dev_package_example.edit_events_last_updated_at,
|
|
313
|
-
})
|
|
314
|
-
} else {
|
|
315
|
-
// All other events just go to the manual-edits.ts file with
|
|
316
|
-
// in the "edit_events" property
|
|
317
|
-
edit_events_ts.replaceWithText(
|
|
318
|
-
`edit_events: ${JSON.stringify(edit_events, null, " ")}`,
|
|
319
|
-
)
|
|
320
|
-
console.log(edit_events_ts.getFullText())
|
|
321
|
-
fs.writeFileSync(
|
|
322
|
-
Path.join(ctx.cwd, manual_edit_file),
|
|
323
|
-
ts_manual_edits_file.getFullText(),
|
|
324
|
-
)
|
|
325
|
-
await devServerAxios.post("/api/dev_package_examples/update", {
|
|
326
|
-
dev_package_example_id,
|
|
327
|
-
edit_events_last_applied_at:
|
|
328
|
-
dev_package_example.edit_events_last_updated_at,
|
|
329
|
-
})
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
}
|
|
334
|
-
} catch (err: any) {
|
|
335
|
-
console.log(kleur.red(`Error in edit event watcher: ${err.toString()}`))
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
await new Promise((resolve) => setTimeout(resolve, 100))
|
|
339
|
-
}
|
|
340
|
-
})()
|
|
341
|
-
|
|
342
|
-
return {
|
|
343
|
-
stop: () => {
|
|
344
|
-
running = false
|
|
345
|
-
},
|
|
346
|
-
}
|
|
347
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { AxiosInstance } from "axios"
|
|
2
|
-
import kleur from "kleur"
|
|
3
|
-
import { fulfillExportRequests } from "./fulfill-export-requests"
|
|
4
|
-
import { AppContext } from "cli/lib/util/app-context"
|
|
5
|
-
|
|
6
|
-
export const startExportRequestWatcher = async (
|
|
7
|
-
{
|
|
8
|
-
devServerAxios,
|
|
9
|
-
}: {
|
|
10
|
-
devServerAxios: AxiosInstance
|
|
11
|
-
},
|
|
12
|
-
ctx: AppContext,
|
|
13
|
-
) => {
|
|
14
|
-
let running = true
|
|
15
|
-
;(async () => {
|
|
16
|
-
while (running) {
|
|
17
|
-
try {
|
|
18
|
-
await fulfillExportRequests({ dev_server_axios: devServerAxios }, ctx)
|
|
19
|
-
} catch (err: any) {
|
|
20
|
-
console.log(
|
|
21
|
-
kleur.red(`Error in export request watcher: ${err.toString()}`),
|
|
22
|
-
)
|
|
23
|
-
}
|
|
24
|
-
await new Promise((resolve) => setTimeout(resolve, 1000))
|
|
25
|
-
}
|
|
26
|
-
})()
|
|
27
|
-
|
|
28
|
-
return {
|
|
29
|
-
stop: () => {
|
|
30
|
-
running = false
|
|
31
|
-
},
|
|
32
|
-
}
|
|
33
|
-
}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { AxiosInstance } from "axios"
|
|
2
|
-
import chokidar from "chokidar"
|
|
3
|
-
import { uploadExamplesFromDirectory } from "./upload-examples-from-directory"
|
|
4
|
-
import kleur from "kleur"
|
|
5
|
-
import { AppContext } from "cli/lib/util/app-context"
|
|
6
|
-
|
|
7
|
-
export const startFsWatcher = async (
|
|
8
|
-
{
|
|
9
|
-
cwd,
|
|
10
|
-
devServerAxios,
|
|
11
|
-
}: {
|
|
12
|
-
cwd: string
|
|
13
|
-
devServerAxios: AxiosInstance
|
|
14
|
-
},
|
|
15
|
-
ctx: Pick<AppContext, "runtime" | "params">,
|
|
16
|
-
) => {
|
|
17
|
-
const watcher = chokidar.watch([`${cwd}/**/*.tsx`, `${cwd}/**/*.ts`], {
|
|
18
|
-
ignored: /node_modules/,
|
|
19
|
-
persistent: true,
|
|
20
|
-
})
|
|
21
|
-
|
|
22
|
-
const upload_queue_state = {
|
|
23
|
-
dirty: false,
|
|
24
|
-
should_run: true,
|
|
25
|
-
}
|
|
26
|
-
watcher.on("change", async (path) => {
|
|
27
|
-
console.log(path)
|
|
28
|
-
if (path.endsWith(".__tmp_entrypoint.tsx")) return
|
|
29
|
-
console.log(`File ${path} has been changed`)
|
|
30
|
-
// TODO analyze to determine which examples were impacted
|
|
31
|
-
upload_queue_state.dirty = true
|
|
32
|
-
})
|
|
33
|
-
|
|
34
|
-
async function uploadInBackground() {
|
|
35
|
-
while (upload_queue_state.should_run) {
|
|
36
|
-
if (upload_queue_state.dirty) {
|
|
37
|
-
console.log(kleur.yellow("Changes detected, re-uploading examples..."))
|
|
38
|
-
upload_queue_state.dirty = false
|
|
39
|
-
await uploadExamplesFromDirectory({ cwd, devServerAxios }, ctx)
|
|
40
|
-
}
|
|
41
|
-
await new Promise((resolve) => setTimeout(resolve, 100))
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
const _backgroundUploaderPromise = uploadInBackground()
|
|
46
|
-
|
|
47
|
-
return {
|
|
48
|
-
_backgroundUploaderPromise,
|
|
49
|
-
stop: () => {
|
|
50
|
-
upload_queue_state.should_run = false
|
|
51
|
-
watcher.close()
|
|
52
|
-
},
|
|
53
|
-
}
|
|
54
|
-
}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import kleur from "kleur"
|
|
2
|
-
import { join as joinPath } from "path/posix"
|
|
3
|
-
import { AxiosInstance } from "axios"
|
|
4
|
-
import { readdirSync, readFileSync } from "fs"
|
|
5
|
-
import { soupify } from "cli/lib/soupify"
|
|
6
|
-
import { soupifyAndUploadExampleFile } from "./soupify-and-upload-example-file"
|
|
7
|
-
import { markAllExamplesLoading } from "./mark-all-examples-loading"
|
|
8
|
-
import { readdir } from "fs/promises"
|
|
9
|
-
import { AppContext } from "cli/lib/util/app-context"
|
|
10
|
-
|
|
11
|
-
export const uploadExamplesFromDirectory = async (
|
|
12
|
-
{
|
|
13
|
-
cwd,
|
|
14
|
-
devServerAxios,
|
|
15
|
-
}: {
|
|
16
|
-
cwd: string
|
|
17
|
-
devServerAxios: AxiosInstance
|
|
18
|
-
},
|
|
19
|
-
ctx: Pick<AppContext, "runtime" | "params">,
|
|
20
|
-
) => {
|
|
21
|
-
const examplesDir = joinPath(cwd, "examples")
|
|
22
|
-
const exampleFileNames = await readdir(examplesDir).catch((e) => {
|
|
23
|
-
console.log(kleur.red(`Error reading examples directory: "${examplesDir}"`))
|
|
24
|
-
throw e
|
|
25
|
-
})
|
|
26
|
-
|
|
27
|
-
// Mark all examples as being "reloaded" in the database
|
|
28
|
-
await markAllExamplesLoading({ devServerAxios })
|
|
29
|
-
|
|
30
|
-
for (const exampleFileName of exampleFileNames) {
|
|
31
|
-
if (exampleFileName.endsWith(".__tmp_entrypoint.tsx")) continue
|
|
32
|
-
if (!exampleFileName.endsWith(".tsx")) continue
|
|
33
|
-
await soupifyAndUploadExampleFile(
|
|
34
|
-
{
|
|
35
|
-
devServerAxios,
|
|
36
|
-
examplesDir,
|
|
37
|
-
exampleFileName,
|
|
38
|
-
},
|
|
39
|
-
ctx,
|
|
40
|
-
)
|
|
41
|
-
}
|
|
42
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import kleur from "kleur"
|
|
2
|
-
import { z } from "zod"
|
|
3
|
-
import { AppContext } from "../util/app-context"
|
|
4
|
-
import { fulfillExportRequests } from "./dev/fulfill-export-requests"
|
|
5
|
-
import { getDevServerAxios } from "./dev/get-dev-server-axios"
|
|
6
|
-
|
|
7
|
-
export const devServerFulfillExportRequests = async (
|
|
8
|
-
ctx: AppContext,
|
|
9
|
-
args: any,
|
|
10
|
-
) => {
|
|
11
|
-
const params = z.object({}).parse(args)
|
|
12
|
-
|
|
13
|
-
let server_url = `http://127.0.0.1:3020`
|
|
14
|
-
let dev_server_axios = getDevServerAxios({ serverUrl: server_url })
|
|
15
|
-
|
|
16
|
-
const checkHealth = () =>
|
|
17
|
-
dev_server_axios
|
|
18
|
-
.get("/api/health")
|
|
19
|
-
.then(() => true)
|
|
20
|
-
.catch((e) => false)
|
|
21
|
-
|
|
22
|
-
let is_dev_server_healthy = await checkHealth()
|
|
23
|
-
|
|
24
|
-
if (!is_dev_server_healthy) {
|
|
25
|
-
// attempt to use development-mode port, e.g. if someone ran
|
|
26
|
-
// npm run start:dev-server:dev
|
|
27
|
-
const devModeServerUrl = "http://127.0.0.1:3021"
|
|
28
|
-
dev_server_axios = getDevServerAxios({ serverUrl: devModeServerUrl })
|
|
29
|
-
is_dev_server_healthy = await checkHealth()
|
|
30
|
-
if (is_dev_server_healthy) server_url = devModeServerUrl
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
if (!is_dev_server_healthy) {
|
|
34
|
-
console.log(
|
|
35
|
-
kleur.red(
|
|
36
|
-
`Dev server doesn't seem to be running at ${server_url}. (Could not ping health)`,
|
|
37
|
-
),
|
|
38
|
-
)
|
|
39
|
-
process.exit(1)
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
await fulfillExportRequests({ dev_server_axios }, ctx)
|
|
43
|
-
}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import kleur from "kleur"
|
|
2
|
-
import { z } from "zod"
|
|
3
|
-
import { AppContext } from "../util/app-context"
|
|
4
|
-
import { getDevServerAxios } from "./dev/get-dev-server-axios"
|
|
5
|
-
import { startFsWatcher } from "./dev/start-fs-watcher"
|
|
6
|
-
import { uploadExamplesFromDirectory } from "./dev/upload-examples-from-directory"
|
|
7
|
-
|
|
8
|
-
export const devServerUpload = async (ctx: AppContext, args: any) => {
|
|
9
|
-
const params = z
|
|
10
|
-
.object({
|
|
11
|
-
dir: z.string().optional().default(ctx.cwd),
|
|
12
|
-
port: z.coerce.number().optional().nullable().default(null),
|
|
13
|
-
watch: z.boolean().optional().default(false),
|
|
14
|
-
})
|
|
15
|
-
.parse(args)
|
|
16
|
-
|
|
17
|
-
let serverUrl = `http://127.0.0.1:${params.port ?? 3020}`
|
|
18
|
-
let devServerAxios = getDevServerAxios({ serverUrl })
|
|
19
|
-
|
|
20
|
-
const checkHealth = () =>
|
|
21
|
-
devServerAxios
|
|
22
|
-
.get("/api/health")
|
|
23
|
-
.then(() => true)
|
|
24
|
-
.catch((e) => false)
|
|
25
|
-
|
|
26
|
-
let is_dev_server_healthy = await checkHealth()
|
|
27
|
-
|
|
28
|
-
if (!is_dev_server_healthy && !params.port) {
|
|
29
|
-
// attempt to use development-mode port, e.g. if someone ran
|
|
30
|
-
// npm run start:dev-server:dev
|
|
31
|
-
const devModeServerUrl = "http://127.0.0.1:3021"
|
|
32
|
-
devServerAxios = getDevServerAxios({ serverUrl: devModeServerUrl })
|
|
33
|
-
is_dev_server_healthy = await checkHealth()
|
|
34
|
-
if (is_dev_server_healthy) serverUrl = devModeServerUrl
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
if (!is_dev_server_healthy) {
|
|
38
|
-
console.log(
|
|
39
|
-
kleur.red(
|
|
40
|
-
`Dev server doesn't seem to be running at ${serverUrl}. (Could not ping health)`,
|
|
41
|
-
),
|
|
42
|
-
)
|
|
43
|
-
process.exit(1)
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
console.log(`Loading examples...`)
|
|
47
|
-
await uploadExamplesFromDirectory({ devServerAxios, cwd: params.dir }, ctx)
|
|
48
|
-
|
|
49
|
-
if (params.watch) {
|
|
50
|
-
// Start watcher
|
|
51
|
-
const watcher = await startFsWatcher(
|
|
52
|
-
{ cwd: params.dir, devServerAxios },
|
|
53
|
-
ctx,
|
|
54
|
-
)
|
|
55
|
-
}
|
|
56
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { AppContext } from "../util/app-context"
|
|
2
|
-
import { z } from "zod"
|
|
3
|
-
import { exportGerbersToFile } from "cli/lib/export-fns/export-gerbers"
|
|
4
|
-
|
|
5
|
-
export const exportGerbersCmd = async (ctx: AppContext, args: any) => {
|
|
6
|
-
const params = z
|
|
7
|
-
.object({
|
|
8
|
-
file: z.string().optional(),
|
|
9
|
-
input: z.string().optional(),
|
|
10
|
-
export: z.string().optional(),
|
|
11
|
-
outputfile: z.string().optional().default("gerbers.zip"),
|
|
12
|
-
})
|
|
13
|
-
.refine((data) => data.file || data.input, {
|
|
14
|
-
message: "Either 'file' or 'input' must be provided",
|
|
15
|
-
})
|
|
16
|
-
.parse(args)
|
|
17
|
-
|
|
18
|
-
const inputFile = params.input || params.file
|
|
19
|
-
|
|
20
|
-
await exportGerbersToFile(
|
|
21
|
-
{
|
|
22
|
-
example_file_path: inputFile!,
|
|
23
|
-
export_name: params.export,
|
|
24
|
-
output_zip_path: params.outputfile,
|
|
25
|
-
},
|
|
26
|
-
ctx,
|
|
27
|
-
)
|
|
28
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { AppContext } from "../util/app-context"
|
|
2
|
-
import { z } from "zod"
|
|
3
|
-
import { soupify } from "cli/lib/soupify"
|
|
4
|
-
import {
|
|
5
|
-
convertCircuitJsonToKiCadPcb,
|
|
6
|
-
convertKiCadPcbToSExprString,
|
|
7
|
-
} from "kicad-converter"
|
|
8
|
-
import fs from "fs/promises"
|
|
9
|
-
import kleur from "kleur"
|
|
10
|
-
|
|
11
|
-
export const exportKicadPcb = async (ctx: AppContext, args: any) => {
|
|
12
|
-
const params = z
|
|
13
|
-
.object({
|
|
14
|
-
input: z.string(),
|
|
15
|
-
export: z.string().optional(),
|
|
16
|
-
outputfile: z.string().default("output.kicad_pcb"),
|
|
17
|
-
})
|
|
18
|
-
.parse(args)
|
|
19
|
-
|
|
20
|
-
console.log(kleur.gray("[soupifying]..."))
|
|
21
|
-
const soup = await soupify(
|
|
22
|
-
{
|
|
23
|
-
filePath: params.input,
|
|
24
|
-
exportName: params.export,
|
|
25
|
-
},
|
|
26
|
-
ctx,
|
|
27
|
-
)
|
|
28
|
-
|
|
29
|
-
console.log(kleur.gray("[converting to KiCad PCB]..."))
|
|
30
|
-
const kicadPcb = convertCircuitJsonToKiCadPcb(soup)
|
|
31
|
-
|
|
32
|
-
console.log(kleur.gray(`[writing to ${params.outputfile}]...`))
|
|
33
|
-
await fs.writeFile(params.outputfile, convertKiCadPcbToSExprString(kicadPcb))
|
|
34
|
-
|
|
35
|
-
console.log(kleur.green(`KiCad PCB file exported to ${params.outputfile}`))
|
|
36
|
-
}
|