circuit-json-to-step 0.0.2 → 0.0.4
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 +77 -0
- package/.github/workflows/bun-test.yml +31 -0
- package/.github/workflows/bun-typecheck.yml +26 -0
- package/README.md +1 -3
- package/bunfig.toml +2 -2
- package/dist/index.d.ts +6 -0
- package/dist/index.js +465 -40
- package/lib/index.ts +33 -5
- package/lib/mesh-generation.ts +29 -1
- package/lib/step-model-merger/excluded-entity-types.ts +27 -0
- package/lib/step-model-merger/read-step-file.ts +23 -0
- package/lib/step-model-merger/types.ts +46 -0
- package/lib/step-model-merger/vector-utils.ts +74 -0
- package/lib/step-model-merger.ts +394 -0
- package/lib/step-text-utils.ts +6 -0
- package/package.json +8 -3
- package/test/basics/basics01/__snapshots__/basics01.snap.png +0 -0
- package/test/basics/basics01/basics01.test.ts +3 -2
- package/test/basics/basics02/__snapshots__/basics02.snap.png +0 -0
- package/test/basics/basics02/basics02.test.ts +3 -2
- package/test/basics/basics03/__snapshots__/basics03.snap.png +0 -0
- package/test/basics/basics03/basics03.test.ts +3 -2
- package/test/basics/basics04/__snapshots__/basics04.snap.png +0 -0
- package/test/basics/basics04/basics04.test.ts +3 -2
- package/test/basics/basics05/__snapshots__/basics05.snap.png +0 -0
- package/test/basics/basics05/basics05.json +40 -0
- package/test/basics/basics05/basics05.test.ts +55 -0
- package/test/fixtures/kicad-models/Panasonic_EVQPUJ_EVQPUA.step +3093 -0
- package/test/fixtures/kicad-models/R_0603_1608Metric.step +1049 -0
- package/test/fixtures/kicad-models/SW_Push_1P1T_NO_CK_KMR2.step +2916 -0
- package/test/fixtures/png-matcher.ts +173 -0
- package/test/fixtures/step-snapshot.ts +249 -0
- package/test/repros/kicad-step/__snapshots__/kicad-step-board.snap.png +0 -0
- package/test/repros/kicad-step/__snapshots__/resistor-fixture.snap.png +0 -0
- package/test/repros/kicad-step/__snapshots__/switch-fixture.snap.png +0 -0
- package/test/repros/kicad-step/kicad-step.json +163 -0
- package/test/repros/kicad-step/kicad-step.test.ts +211 -0
- package/test/repros/repro01/__snapshots__/repro01.snap.png +0 -0
- package/test/repros/repro01/repro01.test.ts +3 -2
- package/test/utils/load-step-files.ts +41 -0
- package/types/occt-import-js.d.ts +33 -0
- package/.claude/settings.local.json +0 -16
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Created using @tscircuit/plop (npm install -g @tscircuit/plop)
|
|
2
|
+
name: Format Check
|
|
3
|
+
|
|
4
|
+
on:
|
|
5
|
+
push:
|
|
6
|
+
branches: [main]
|
|
7
|
+
pull_request:
|
|
8
|
+
branches: [main]
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
format-check:
|
|
12
|
+
runs-on: ubuntu-latest
|
|
13
|
+
|
|
14
|
+
steps:
|
|
15
|
+
- uses: actions/checkout@v4
|
|
16
|
+
|
|
17
|
+
- name: Setup bun
|
|
18
|
+
uses: oven-sh/setup-bun@v2
|
|
19
|
+
with:
|
|
20
|
+
bun-version: latest
|
|
21
|
+
|
|
22
|
+
- name: Install dependencies
|
|
23
|
+
run: bun install
|
|
24
|
+
|
|
25
|
+
- name: Run format check
|
|
26
|
+
run: bun run format:check
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# Created using @tscircuit/plop (npm install -g @tscircuit/plop)
|
|
2
|
+
name: Publish to npm
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- main
|
|
7
|
+
workflow_dispatch:
|
|
8
|
+
|
|
9
|
+
env:
|
|
10
|
+
UPSTREAM_REPOS: "" # comma-separated list, e.g. "eval,tscircuit,docs"
|
|
11
|
+
UPSTREAM_PACKAGES_TO_UPDATE: "" # comma-separated list, e.g. "@tscircuit/core,@tscircuit/protos"
|
|
12
|
+
|
|
13
|
+
jobs:
|
|
14
|
+
publish:
|
|
15
|
+
runs-on: ubuntu-latest
|
|
16
|
+
if: ${{ !(github.event_name == 'push' && startsWith(github.event.head_commit.message, 'v')) }}
|
|
17
|
+
steps:
|
|
18
|
+
- uses: actions/checkout@v4
|
|
19
|
+
with:
|
|
20
|
+
token: ${{ secrets.TSCIRCUIT_BOT_GITHUB_TOKEN }}
|
|
21
|
+
- name: Setup bun
|
|
22
|
+
uses: oven-sh/setup-bun@v2
|
|
23
|
+
with:
|
|
24
|
+
bun-version: latest
|
|
25
|
+
- uses: actions/setup-node@v3
|
|
26
|
+
with:
|
|
27
|
+
node-version: 20
|
|
28
|
+
registry-url: https://registry.npmjs.org/
|
|
29
|
+
- run: npm install -g pver
|
|
30
|
+
- run: bun install --frozen-lockfile
|
|
31
|
+
- run: bun run build
|
|
32
|
+
- run: pver release --no-push-main
|
|
33
|
+
env:
|
|
34
|
+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
35
|
+
GITHUB_TOKEN: ${{ secrets.TSCIRCUIT_BOT_GITHUB_TOKEN }}
|
|
36
|
+
|
|
37
|
+
- name: Get package version
|
|
38
|
+
id: package-version
|
|
39
|
+
run: |
|
|
40
|
+
VERSION=$(node -p "require('./package.json').version")
|
|
41
|
+
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
|
|
42
|
+
|
|
43
|
+
- name: Create Pull Request
|
|
44
|
+
id: create-pr
|
|
45
|
+
uses: peter-evans/create-pull-request@v5
|
|
46
|
+
with:
|
|
47
|
+
commit-message: "chore: bump version to ${{ steps.package-version.outputs.version }}"
|
|
48
|
+
title: "chore: bump version to ${{ steps.package-version.outputs.version }}"
|
|
49
|
+
body: "Automated package update"
|
|
50
|
+
branch: bump-version-${{ github.run_number }}
|
|
51
|
+
base: main
|
|
52
|
+
token: ${{ secrets.TSCIRCUIT_BOT_GITHUB_TOKEN }}
|
|
53
|
+
committer: tscircuitbot <githubbot@tscircuit.com>
|
|
54
|
+
author: tscircuitbot <githubbot@tscircuit.com>
|
|
55
|
+
|
|
56
|
+
- name: Enable auto-merge
|
|
57
|
+
if: steps.create-pr.outputs.pull-request-number != ''
|
|
58
|
+
run: |
|
|
59
|
+
gh pr merge ${{ steps.create-pr.outputs.pull-request-number }} --auto --squash --delete-branch
|
|
60
|
+
env:
|
|
61
|
+
GH_TOKEN: ${{ secrets.TSCIRCUIT_BOT_GITHUB_TOKEN }}
|
|
62
|
+
|
|
63
|
+
# - name: Trigger upstream repo updates
|
|
64
|
+
# if: env.UPSTREAM_REPOS && env.UPSTREAM_PACKAGES_TO_UPDATE
|
|
65
|
+
# run: |
|
|
66
|
+
# IFS=',' read -ra REPOS <<< "${{ env.UPSTREAM_REPOS }}"
|
|
67
|
+
# for repo in "${REPOS[@]}"; do
|
|
68
|
+
# if [[ -n "$repo" ]]; then
|
|
69
|
+
# echo "Triggering update for repo: $repo"
|
|
70
|
+
# curl -X POST \
|
|
71
|
+
# -H "Accept: application/vnd.github.v3+json" \
|
|
72
|
+
# -H "Authorization: token ${{ secrets.TSCIRCUIT_BOT_GITHUB_TOKEN }}" \
|
|
73
|
+
# -H "Content-Type: application/json" \
|
|
74
|
+
# "https://api.github.com/repos/tscircuit/$repo/actions/workflows/update-package.yml/dispatches" \
|
|
75
|
+
# -d "{\"ref\":\"main\",\"inputs\":{\"package_names\":\"${{ env.UPSTREAM_PACKAGES_TO_UPDATE }}\"}}"
|
|
76
|
+
# fi
|
|
77
|
+
# done
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# Created using @tscircuit/plop (npm install -g @tscircuit/plop)
|
|
2
|
+
name: Bun Test
|
|
3
|
+
|
|
4
|
+
on:
|
|
5
|
+
pull_request:
|
|
6
|
+
push:
|
|
7
|
+
branches:
|
|
8
|
+
- main
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
test:
|
|
12
|
+
runs-on: ubuntu-latest
|
|
13
|
+
timeout-minutes: 5
|
|
14
|
+
|
|
15
|
+
# Skip test for PRs that not chore: bump version
|
|
16
|
+
if: "${{ github.event_name != 'pull_request' || github.event.pull_request.title != 'chore: bump version' }}"
|
|
17
|
+
|
|
18
|
+
steps:
|
|
19
|
+
- name: Checkout code
|
|
20
|
+
uses: actions/checkout@v4
|
|
21
|
+
|
|
22
|
+
- name: Setup bun
|
|
23
|
+
uses: oven-sh/setup-bun@v2
|
|
24
|
+
with:
|
|
25
|
+
bun-version: latest
|
|
26
|
+
|
|
27
|
+
- name: Install dependencies
|
|
28
|
+
run: bun install
|
|
29
|
+
|
|
30
|
+
- name: Run tests
|
|
31
|
+
run: bun test
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Created using @tscircuit/plop (npm install -g @tscircuit/plop)
|
|
2
|
+
name: Type Check
|
|
3
|
+
|
|
4
|
+
on:
|
|
5
|
+
push:
|
|
6
|
+
branches: [main]
|
|
7
|
+
pull_request:
|
|
8
|
+
branches: [main]
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
type-check:
|
|
12
|
+
runs-on: ubuntu-latest
|
|
13
|
+
|
|
14
|
+
steps:
|
|
15
|
+
- uses: actions/checkout@v4
|
|
16
|
+
|
|
17
|
+
- name: Setup bun
|
|
18
|
+
uses: oven-sh/setup-bun@v2
|
|
19
|
+
with:
|
|
20
|
+
bun-version: latest
|
|
21
|
+
|
|
22
|
+
- name: Install dependencies
|
|
23
|
+
run: bun i
|
|
24
|
+
|
|
25
|
+
- name: Run type check
|
|
26
|
+
run: bunx tsc --noEmit
|
package/README.md
CHANGED
|
@@ -16,7 +16,6 @@ bun add circuit-json-to-step
|
|
|
16
16
|
|
|
17
17
|
```typescript
|
|
18
18
|
import { circuitJsonToStep } from "circuit-json-to-step"
|
|
19
|
-
import { writeFileSync } from "fs"
|
|
20
19
|
|
|
21
20
|
const circuitJson = [
|
|
22
21
|
{
|
|
@@ -43,8 +42,7 @@ const stepText = await circuitJsonToStep(circuitJson, {
|
|
|
43
42
|
boardThickness: 1.6,
|
|
44
43
|
productName: "MyPCB",
|
|
45
44
|
})
|
|
46
|
-
|
|
47
|
-
writeFileSync("output.step", stepText)
|
|
45
|
+
await Bun.write("output.step", stepText)
|
|
48
46
|
```
|
|
49
47
|
|
|
50
48
|
## Related Projects
|
package/bunfig.toml
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -13,6 +13,12 @@ interface CircuitJsonToStepOptions {
|
|
|
13
13
|
includeComponents?: boolean;
|
|
14
14
|
/** Include external model meshes from model_*_url fields (default: false). Only applicable when includeComponents is true. */
|
|
15
15
|
includeExternalMeshes?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Pre-loaded STEP file contents, keyed by URL/path.
|
|
18
|
+
* If a URL is found here, the content is used directly instead of fetching.
|
|
19
|
+
* Useful for tests that need to load local files.
|
|
20
|
+
*/
|
|
21
|
+
fsMap?: Record<string, string>;
|
|
16
22
|
}
|
|
17
23
|
/**
|
|
18
24
|
* Converts circuit JSON to STEP format, creating holes in a PCB board
|