Skip to content
This repository has been archived by the owner on Jan 2, 2025. It is now read-only.

Commit

Permalink
Merge pull request #189 from tscircuit:new-cli
Browse files Browse the repository at this point in the history
kicad-converter update, delete temporary entrypoint files prior to creating new ones
  • Loading branch information
seveibar authored Sep 20, 2024
2 parents f776903 + b861f38 commit bbea375
Show file tree
Hide file tree
Showing 11 changed files with 29 additions and 108 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/formatbot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,25 +25,25 @@ jobs:
with:
token: ${{ steps.check_fork.outputs.is_fork == 'true' && secrets.GITHUB_TOKEN || secrets.TSCIRCUIT_BOT_GITHUB_TOKEN }}

- name: Setup Node.js
uses: actions/setup-node@v3
- name: Setup bun
uses: oven-sh/setup-bun@v1
with:
node-version: '20'
bun-version: latest

- name: Get @biomejs/biome version
id: get-biome-version
run: echo "BIOME_VERSION=$(node -p "require('./package.json').devDependencies['@biomejs/biome']")" >> $GITHUB_OUTPUT

- name: Install @biomejs/biome
run: npm install @biomejs/biome@${{ steps.get-biome-version.outputs.BIOME_VERSION }}
run: bun install

- name: Run Formatter and autofix
if: steps.check_fork.outputs.is_fork == 'false'
run: npx @biomejs/biome format . --write
run: bunx biome format . --write

- name: Format Check (cannot autofix against forks)
if: steps.check_fork.outputs.is_fork == 'true'
run: npx @biomejs/biome format .
run: bunx biome format .

- name: Restore lock files
if: steps.check_fork.outputs.is_fork == 'false'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ jobs:
run: bun run build

- name: Run tests
run: bun test
run: bun test --timeout 15000
Binary file modified bun.lockb
Binary file not shown.
4 changes: 2 additions & 2 deletions cli/lib/cmd-fns/dev/derive-selector-from-pcb-component-id.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { AnySoupElement } from "@tscircuit/builder"
import type { AnySoupElement } from "@tscircuit/soup"
import { su } from "@tscircuit/soup-util"

export const deriveSelectorFromPcbComponentId = ({
Expand All @@ -8,7 +8,7 @@ export const deriveSelectorFromPcbComponentId = ({
soup: AnySoupElement[]
pcb_component_id: string
}) => {
const source_component = su(soup).source_component.getUsing({
const source_component = su(soup as any).source_component.getUsing({
pcb_component_id,
})
if (!source_component) {
Expand Down
4 changes: 3 additions & 1 deletion cli/lib/soupify/get-tmp-entrpoint-filepath.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Path from "node:path"
import fs from "fs/promises"

export const getTmpEntrypointFilePath = (filePath: string) => {
export const getTmpEntrypointFilePath = async (filePath: string) => {
const tmpEntrypointPath = Path.resolve(
Path.dirname(filePath),
Path.basename(filePath).replace(/\.[^\.]+$/, "") + ".__tmp_entrypoint.tsx",
Expand All @@ -9,5 +10,6 @@ export const getTmpEntrypointFilePath = (filePath: string) => {
Path.dirname(filePath),
Path.basename(filePath).replace(/\.[^\.]+$/, "") + ".__tmp_output.json",
)

return { tmpEntrypointPath, tmpOutputPath }
}
7 changes: 6 additions & 1 deletion cli/lib/soupify/soupify-with-core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import Debug from "debug"
import { getExportNameFromFile } from "./get-export-name-from-file"
import { getTmpEntrypointFilePath } from "./get-tmp-entrpoint-filepath"
import { runEntrypointFile } from "./run-entrypoint-file"
import fs from "node:fs/promises"

const debug = Debug("tscircuit:soupify")

Expand All @@ -25,7 +26,11 @@ export const soupifyWithCore = async (
exportName ??= await getExportNameFromFile(filePath)

const { tmpEntrypointPath, tmpOutputPath } =
getTmpEntrypointFilePath(filePath)
await getTmpEntrypointFilePath(filePath)

// Remove existing entrypoint or tmp output files
await fs.unlink(tmpEntrypointPath).catch(() => {})
await fs.unlink(tmpOutputPath).catch(() => {})

debug(`writing to ${tmpEntrypointPath}`)
writeFileSync(
Expand Down
2 changes: 1 addition & 1 deletion cli/lib/soupify/soupify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export const soupifyWithBuilder = async (
exportName ??= await getExportNameFromFile(filePath)

const { tmpEntrypointPath, tmpOutputPath } =
getTmpEntrypointFilePath(filePath)
await getTmpEntrypointFilePath(filePath)

debug(`writing to ${tmpEntrypointPath}`)
writeFileSync(
Expand Down
8 changes: 1 addition & 7 deletions example-project/src/MyCircuit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,7 @@ import { layout } from "@tscircuit/layout"
import manual_edits from "./manual-edits"

export const MyCircuit = () => (
<board
width="40mm"
height="40mm"
pcbX={0}
pcbY={0}
layout={layout().manualEdits(manual_edits)}
>
<board width="40mm" height="40mm" pcbX={0} pcbY={0}>
<resistor
name="R1"
resistance="20kohm"
Expand Down
83 changes: 1 addition & 82 deletions example-project/src/manual-edits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,87 +52,6 @@ export default {
relative_to: "group_center",
},
],
manual_trace_hints: [
{
pcb_port_selector: ".D9 > .pin2",
offsets: [
{
x: 38.92169691522466,
y: -2.3377796771400057,
via: false,
},
{
x: 37.986379705415004,
y: -2.4045880492692646,
via: true,
},
{
x: 35.04681133172754,
y: -2.5048006074631566,
via: true,
},
],
},
{
pcb_port_selector: ".D8 > .pin2",
offsets: [
{
x: 39.368100153443855,
y: 11.075329302388642,
via: false,
},
{
x: 39.0431504551313,
y: -2.4100831775825498,
via: false,
},
],
},
{
pcb_port_selector: ".D6 > .pin2",
offsets: [
{
x: 27.898990889830188,
y: -7.126105014672912,
via: true,
},
],
},
{
pcb_port_selector: ".D7 > .pin2",
offsets: [
{
x: -8.911022990918022,
y: 12.104068965358355,
via: true,
},
{
x: 31.337860341638805,
y: 8.65338014408593,
via: true,
},
{
x: 40.284252655475,
y: 7.931249822789734,
via: false,
},
{
x: 39.96330584601003,
y: -2.4995214848219867,
via: false,
},
],
},
{
pcb_port_selector: ".SW6 > .pin1",
offsets: [
{
x: 14.242563958561936,
y: -0.4071654915144425,
via: false,
},
],
},
],
manual_trace_hints: [],
edit_events: [],
}
4 changes: 2 additions & 2 deletions frontend/views/HeaderMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -294,8 +294,8 @@ export const HeaderMenu = () => {
@tscircuit/cli v{cliPackageJson.version}
</MenubarItem>
<MenubarItem disabled>
@tscircuit/builder v
{cliPackageJson.dependencies?.["@tscircuit/builder"]?.replace(
@tscircuit/core v
{cliPackageJson.dependencies?.["@tscircuit/core"]?.replace(
/\^/g,
"",
)}
Expand Down
11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
"build:dev-server": "bun run build:api && bun run build:frontend",
"build:api": "cd api && winterspec bundle-routes -i ./routes -o ./static-routes.ts",
"build:frontend": "vite build --config frontend/vite.config.ts && make-vfs --content-format string --dir frontend/dist --outfile ./frontend/dist/bundle.ts",
"test:init": "bun cli/cli.ts init --dir ./tmp/test --name test",
"update-deps": "bun add @tscircuit/builder@latest @tscircuit/react-fiber@latest @tscircuit/schematic-viewer@latest @tscircuit/pcb-viewer@latest @tscircuit/table-viewer@latest @tscircuit/3d-viewer@latest",
"format": "biome format . --write"
},
"bin": {
Expand All @@ -38,11 +36,13 @@
"@edge-runtime/primitives": "^4.1.0",
"@hono/node-server": "^1.8.2",
"@tscircuit/builder": "*",
"@tscircuit/core": "^0.0.62",
"@tscircuit/core": "^0.0.69",
"@tscircuit/props": "^0.0.62",
"@tscircuit/soup": "^0.0.71",
"archiver": "^7.0.1",
"axios": "^1.6.7",
"chokidar": "^3.6.0",
"circuit-json-to-connectivity-map": "^0.0.16",
"circuit-json-to-gerber": "^0.0.4",
"circuit-to-png": "^0.0.3",
"circuit-to-svg": "^0.0.22",
Expand All @@ -58,7 +58,7 @@
"hono": "^4.1.0",
"ignore": "^5.3.1",
"json5": "^2.2.3",
"kicad-converter": "^0.0.4",
"kicad-converter": "^0.0.7",
"kleur": "^4.1.5",
"lodash": "^4.17.21",
"memory-level": "^1.0.0",
Expand All @@ -67,6 +67,7 @@
"node-persist": "^4.0.1",
"open": "^10.1.0",
"perfect-cli": "^1.0.20",
"performance-now": "^2.1.0",
"posthog-node": "^4.0.1",
"prompts": "^2.4.2",
"redaxios": "^0.5.1",
Expand All @@ -84,7 +85,7 @@
"@tscircuit/soup-util": "*"
},
"devDependencies": {
"@biomejs/biome": "^1.9.1",
"@biomejs/biome": "^1.9.2",
"@headlessui/react": "^1.7.18",
"@radix-ui/react-alert-dialog": "^1.0.5",
"@radix-ui/react-context-menu": "^2.1.5",
Expand Down

0 comments on commit bbea375

Please sign in to comment.