@tscircuit/cli 0.0.394 → 0.1.2
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 +33 -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/clone/register.ts +99 -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 +33 -0
- package/dist/main.js +537 -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 -16
- package/scripts/build-cli.ts +0 -12
- package/tsup.config.ts +0 -7
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import kleur from "kleur"
|
|
2
|
-
import { AppContext } from "cli/lib/util/app-context"
|
|
3
|
-
import { z } from "zod"
|
|
4
|
-
import { createOrModifyNpmrc } from "./init/create-or-modify-npmrc"
|
|
5
|
-
import $ from "dax-sh"
|
|
6
|
-
|
|
7
|
-
export const uninstallCmd = async (ctx: AppContext, args: any) => {
|
|
8
|
-
const params = z
|
|
9
|
-
.object({
|
|
10
|
-
packages: z.array(z.string()),
|
|
11
|
-
flags: z.object({}).optional().default({}),
|
|
12
|
-
})
|
|
13
|
-
.parse(args)
|
|
14
|
-
|
|
15
|
-
params.packages = params.packages.map((p) => p.replace(/^@/, ""))
|
|
16
|
-
|
|
17
|
-
await createOrModifyNpmrc({ quiet: true }, ctx)
|
|
18
|
-
|
|
19
|
-
$.cd(ctx.cwd)
|
|
20
|
-
|
|
21
|
-
const flagsString = ""
|
|
22
|
-
|
|
23
|
-
const cmd = `npm uninstall ${flagsString} ${params.packages
|
|
24
|
-
.map((p) => `@tsci/${p.replace(/\//, ".")}`)
|
|
25
|
-
.join(" ")}`
|
|
26
|
-
console.log(kleur.gray(`> ${cmd}`))
|
|
27
|
-
|
|
28
|
-
await $`npm uninstall ${flagsString} ${params.packages
|
|
29
|
-
.map((p) => `@tsci/${p.replace(/\//, ".")}`)
|
|
30
|
-
.join(" ")}`
|
|
31
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import type { AppContext } from "cli/lib/util/app-context"
|
|
2
|
-
import cliPackageJson from "package.json"
|
|
3
|
-
|
|
4
|
-
export const versionCmd = async (ctx: AppContext, args: any) => {
|
|
5
|
-
if (typeof global !== "undefined" && (global as any).TSCIRCUIT_VERSION) {
|
|
6
|
-
console.log(`tscircuit@${(global as any).TSCIRCUIT_VERSION}`)
|
|
7
|
-
console.log("")
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
const table: { name: string; current: string; latest?: string }[] = []
|
|
11
|
-
|
|
12
|
-
table.push({ name: "@tscircuit/cli", current: cliPackageJson.version })
|
|
13
|
-
table.push({
|
|
14
|
-
name: "@tscircuit/core",
|
|
15
|
-
current: cliPackageJson.dependencies["@tscircuit/core"],
|
|
16
|
-
})
|
|
17
|
-
table.push({
|
|
18
|
-
name: "@tscircuit/schematic-viewer",
|
|
19
|
-
current: cliPackageJson.devDependencies["@tscircuit/schematic-viewer"],
|
|
20
|
-
})
|
|
21
|
-
table.push({
|
|
22
|
-
name: "@tscircuit/pcb-viewer",
|
|
23
|
-
current: cliPackageJson.devDependencies["@tscircuit/pcb-viewer"],
|
|
24
|
-
})
|
|
25
|
-
|
|
26
|
-
if (args.showLatest) {
|
|
27
|
-
// Get the latest version for each package
|
|
28
|
-
for (const row of table) {
|
|
29
|
-
const { name } = row
|
|
30
|
-
const { data: packageInfo } = await ctx.axios.get(
|
|
31
|
-
"https://registry.npmjs.org/" + name,
|
|
32
|
-
)
|
|
33
|
-
row.latest = packageInfo["dist-tags"].latest
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
console.table(table)
|
|
38
|
-
}
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
import Configstore from "configstore"
|
|
2
|
-
|
|
3
|
-
interface ProfileConfigProps {
|
|
4
|
-
session_token?: string
|
|
5
|
-
registry_url?: string
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
interface GlobalConfigProps {
|
|
9
|
-
current_profile?: string
|
|
10
|
-
log_requests?: boolean
|
|
11
|
-
runtime?: "bun" | "node"
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
interface TypedConfigstore<T extends Record<string, any>> {
|
|
15
|
-
/**
|
|
16
|
-
* Get the path to the config file. Can be used to show the user
|
|
17
|
-
* where it is, or better, open it for them.
|
|
18
|
-
*/
|
|
19
|
-
path: string
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Get all items as an object or replace the current config with an object.
|
|
23
|
-
*/
|
|
24
|
-
all: any
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Get the item count
|
|
28
|
-
*/
|
|
29
|
-
size: number
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Get an item
|
|
33
|
-
* @param key The string key to get
|
|
34
|
-
* @return The contents of the config from key $key
|
|
35
|
-
*/
|
|
36
|
-
get(key: keyof T): any
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Set an item
|
|
40
|
-
* @param key The string key
|
|
41
|
-
* @param val The value to set
|
|
42
|
-
*/
|
|
43
|
-
set<K extends keyof T>(key: K, val: T[K]): void
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Determines if a key is present in the config
|
|
47
|
-
* @param key The string key to test for
|
|
48
|
-
* @return True if the key is present
|
|
49
|
-
*/
|
|
50
|
-
has(key: keyof T): boolean
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Delete an item.
|
|
54
|
-
* @param key The key to delete
|
|
55
|
-
*/
|
|
56
|
-
delete(key: keyof T): void
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Clear the config.
|
|
60
|
-
* Equivalent to <code>Configstore.all = {};</code>
|
|
61
|
-
*/
|
|
62
|
-
clear(): void
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
export interface ContextConfigProps {
|
|
66
|
-
profile_config: TypedConfigstore<ProfileConfigProps>
|
|
67
|
-
global_config: TypedConfigstore<GlobalConfigProps>
|
|
68
|
-
current_profile: string
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
export const createConfigHandler = ({
|
|
72
|
-
profile,
|
|
73
|
-
}: {
|
|
74
|
-
profile?: string
|
|
75
|
-
}): ContextConfigProps => {
|
|
76
|
-
const global_config: TypedConfigstore<GlobalConfigProps> = new Configstore(
|
|
77
|
-
"tsci",
|
|
78
|
-
)
|
|
79
|
-
const current_profile =
|
|
80
|
-
profile ?? global_config.get("current_profile") ?? "default"
|
|
81
|
-
|
|
82
|
-
const profile_config: TypedConfigstore<ProfileConfigProps> = {
|
|
83
|
-
get: (key: string) =>
|
|
84
|
-
(global_config as any).get(`profiles.${current_profile}.${key}`),
|
|
85
|
-
set: (key: string, value: any) =>
|
|
86
|
-
(global_config as any).set(`profiles.${current_profile}.${key}`, value),
|
|
87
|
-
clear: () => {
|
|
88
|
-
for (const key of Object.keys(global_config.all)) {
|
|
89
|
-
if (key.startsWith(`profiles.${current_profile}`)) {
|
|
90
|
-
global_config.delete(key as any)
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
},
|
|
94
|
-
} as any
|
|
95
|
-
|
|
96
|
-
return { profile_config, global_config, current_profile }
|
|
97
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { AppContext } from "../util/app-context"
|
|
2
|
-
import { soupify } from "cli/lib/soupify"
|
|
3
|
-
import kleur from "kleur"
|
|
4
|
-
import {
|
|
5
|
-
convertCircuitJsonToBomRows,
|
|
6
|
-
convertBomRowsToCsv,
|
|
7
|
-
} from "circuit-json-to-bom-csv"
|
|
8
|
-
|
|
9
|
-
export const exportBomCsvToBuffer = async (
|
|
10
|
-
params: {
|
|
11
|
-
example_file_path: string
|
|
12
|
-
export_name?: string
|
|
13
|
-
},
|
|
14
|
-
ctx: AppContext,
|
|
15
|
-
) => {
|
|
16
|
-
console.log(kleur.gray("[soupifying]..."))
|
|
17
|
-
const soup = await soupify(
|
|
18
|
-
{
|
|
19
|
-
filePath: params.example_file_path,
|
|
20
|
-
exportName: params.export_name,
|
|
21
|
-
},
|
|
22
|
-
ctx,
|
|
23
|
-
)
|
|
24
|
-
|
|
25
|
-
console.log(kleur.gray("[soup to bom rows]..."))
|
|
26
|
-
const bom_rows = await convertCircuitJsonToBomRows({ circuitJson: soup })
|
|
27
|
-
|
|
28
|
-
console.log(kleur.gray("[bom rows to csv]..."))
|
|
29
|
-
const bom_csv = await convertBomRowsToCsv(bom_rows)
|
|
30
|
-
|
|
31
|
-
return Buffer.from(bom_csv, "utf-8")
|
|
32
|
-
}
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
import { AppContext } from "../util/app-context"
|
|
2
|
-
import { z } from "zod"
|
|
3
|
-
import * as Path from "path/posix"
|
|
4
|
-
import { unlink } from "node:fs/promises"
|
|
5
|
-
import { soupify } from "cli/lib/soupify"
|
|
6
|
-
import * as fs from "fs"
|
|
7
|
-
import {
|
|
8
|
-
stringifyGerberCommandLayers,
|
|
9
|
-
convertSoupToGerberCommands,
|
|
10
|
-
convertSoupToExcellonDrillCommands,
|
|
11
|
-
stringifyExcellonDrill,
|
|
12
|
-
} from "circuit-json-to-gerber"
|
|
13
|
-
import kleur from "kleur"
|
|
14
|
-
import archiver from "archiver"
|
|
15
|
-
|
|
16
|
-
export const exportGerbersToFile = async (
|
|
17
|
-
params: {
|
|
18
|
-
example_file_path: string
|
|
19
|
-
export_name?: string
|
|
20
|
-
output_zip_path: string
|
|
21
|
-
},
|
|
22
|
-
ctx: AppContext,
|
|
23
|
-
) => {
|
|
24
|
-
console.log(kleur.gray("[soupifying]..."))
|
|
25
|
-
const soup = await soupify(
|
|
26
|
-
{
|
|
27
|
-
filePath: params.example_file_path,
|
|
28
|
-
exportName: params.export_name,
|
|
29
|
-
},
|
|
30
|
-
ctx,
|
|
31
|
-
)
|
|
32
|
-
|
|
33
|
-
console.log(kleur.gray("[soup to gerber json]..."))
|
|
34
|
-
const gerber_layer_cmds = convertSoupToGerberCommands(soup, {
|
|
35
|
-
flip_y_axis: false,
|
|
36
|
-
})
|
|
37
|
-
|
|
38
|
-
console.log(kleur.gray("[soup to drl json]..."))
|
|
39
|
-
const drill_cmds = convertSoupToExcellonDrillCommands({
|
|
40
|
-
soup,
|
|
41
|
-
is_plated: true,
|
|
42
|
-
flip_y_axis: false,
|
|
43
|
-
})
|
|
44
|
-
|
|
45
|
-
console.log(kleur.gray("[stringify gerber json]..."))
|
|
46
|
-
const gerber_file_contents = stringifyGerberCommandLayers(gerber_layer_cmds)
|
|
47
|
-
console.log(kleur.gray("[stringify drl json]..."))
|
|
48
|
-
const drill_file_contents = {
|
|
49
|
-
plated: stringifyExcellonDrill(drill_cmds),
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
console.log(kleur.gray("[writing gerbers to tmp dir]..."))
|
|
53
|
-
const tempDir = Path.join(".tscircuit", "tmp-gerber-export")
|
|
54
|
-
fs.rmSync(tempDir, { recursive: true, force: true })
|
|
55
|
-
fs.mkdirSync(tempDir, { recursive: true })
|
|
56
|
-
for (const [fileName, fileContents] of Object.entries(gerber_file_contents)) {
|
|
57
|
-
const filePath = Path.join(tempDir, fileName)
|
|
58
|
-
await fs.writeFileSync(`${filePath}.gbr`, fileContents)
|
|
59
|
-
}
|
|
60
|
-
for (const [fileName, fileContents] of Object.entries(drill_file_contents)) {
|
|
61
|
-
const filePath = Path.join(tempDir, fileName)
|
|
62
|
-
await fs.writeFileSync(`${filePath}.drl`, fileContents)
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
console.log(kleur.gray("[zipping tmp dir]..."))
|
|
66
|
-
console.log(kleur.gray(" writing to " + params.output_zip_path))
|
|
67
|
-
const output = fs.createWriteStream(params.output_zip_path)
|
|
68
|
-
|
|
69
|
-
const archive = archiver("zip", {
|
|
70
|
-
zlib: { level: 9 },
|
|
71
|
-
})
|
|
72
|
-
|
|
73
|
-
archive.pipe(output)
|
|
74
|
-
archive.directory(tempDir, false)
|
|
75
|
-
|
|
76
|
-
await new Promise((resolve, reject) => {
|
|
77
|
-
output.on("close", resolve)
|
|
78
|
-
output.on("finish", resolve)
|
|
79
|
-
output.on("end", resolve)
|
|
80
|
-
output.on("error", reject)
|
|
81
|
-
archive.finalize()
|
|
82
|
-
})
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
export const exportGerbersToZipBuffer = async (
|
|
86
|
-
params: {
|
|
87
|
-
example_file_path: string
|
|
88
|
-
export_name?: string
|
|
89
|
-
},
|
|
90
|
-
ctx: AppContext,
|
|
91
|
-
) => {
|
|
92
|
-
const tempDir = Path.join(".tscircuit", "tmp-gerber-zip")
|
|
93
|
-
fs.mkdirSync(tempDir, { recursive: true })
|
|
94
|
-
await exportGerbersToFile(
|
|
95
|
-
{
|
|
96
|
-
example_file_path: params.example_file_path,
|
|
97
|
-
export_name: params.export_name,
|
|
98
|
-
output_zip_path: Path.join(tempDir, "gerbers.zip"),
|
|
99
|
-
},
|
|
100
|
-
ctx,
|
|
101
|
-
)
|
|
102
|
-
|
|
103
|
-
const buffer = fs.readFileSync(Path.join(tempDir, "gerbers.zip"))
|
|
104
|
-
|
|
105
|
-
fs.rmSync(tempDir, { recursive: true })
|
|
106
|
-
|
|
107
|
-
return buffer
|
|
108
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { AppContext } from "../util/app-context"
|
|
2
|
-
import { soupify } from "cli/lib/soupify"
|
|
3
|
-
import {
|
|
4
|
-
convertCircuitJsonToKiCadPcb,
|
|
5
|
-
convertKiCadPcbToSExprString,
|
|
6
|
-
} from "kicad-converter"
|
|
7
|
-
import kleur from "kleur"
|
|
8
|
-
|
|
9
|
-
export const exportKicadPcbToBuffer = async (
|
|
10
|
-
params: {
|
|
11
|
-
example_file_path: string
|
|
12
|
-
export_name?: string
|
|
13
|
-
},
|
|
14
|
-
ctx: AppContext,
|
|
15
|
-
) => {
|
|
16
|
-
console.log(kleur.gray("[soupifying]..."))
|
|
17
|
-
const soup = await soupify(
|
|
18
|
-
{
|
|
19
|
-
filePath: params.example_file_path,
|
|
20
|
-
exportName: params.export_name,
|
|
21
|
-
},
|
|
22
|
-
ctx,
|
|
23
|
-
)
|
|
24
|
-
|
|
25
|
-
console.log(kleur.gray("[converting to KiCad PCB]..."))
|
|
26
|
-
const kicadPcb = convertCircuitJsonToKiCadPcb(soup)
|
|
27
|
-
|
|
28
|
-
console.log(kleur.gray("[converting to S-expression string]..."))
|
|
29
|
-
const kicadPcbString = convertKiCadPcbToSExprString(kicadPcb)
|
|
30
|
-
|
|
31
|
-
return Buffer.from(kicadPcbString, "utf-8")
|
|
32
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { AppContext } from "../util/app-context"
|
|
2
|
-
import { z } from "zod"
|
|
3
|
-
import * as Path from "path/posix"
|
|
4
|
-
import { unlink } from "node:fs/promises"
|
|
5
|
-
import { soupify } from "cli/lib/soupify"
|
|
6
|
-
import { convertCircuitJsonToPickAndPlaceCsv } from "circuit-json-to-pnp-csv"
|
|
7
|
-
import * as fs from "fs"
|
|
8
|
-
import kleur from "kleur"
|
|
9
|
-
import archiver from "archiver"
|
|
10
|
-
|
|
11
|
-
export const exportPnpCsvToBuffer = async (
|
|
12
|
-
params: {
|
|
13
|
-
example_file_path: string
|
|
14
|
-
export_name?: string
|
|
15
|
-
},
|
|
16
|
-
ctx: AppContext,
|
|
17
|
-
) => {
|
|
18
|
-
console.log(kleur.gray("[soupifying]..."))
|
|
19
|
-
const soup = await soupify(
|
|
20
|
-
{
|
|
21
|
-
filePath: params.example_file_path,
|
|
22
|
-
exportName: params.export_name,
|
|
23
|
-
},
|
|
24
|
-
ctx,
|
|
25
|
-
)
|
|
26
|
-
|
|
27
|
-
console.log(kleur.gray("[soup to pnp csv string]..."))
|
|
28
|
-
const pnp_csv = await convertCircuitJsonToPickAndPlaceCsv(soup)
|
|
29
|
-
|
|
30
|
-
return Buffer.from(pnp_csv, "utf-8")
|
|
31
|
-
}
|