@tscircuit/cli 0.0.63 → 0.0.65
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/bun.lockb +0 -0
- package/dev-server-api/src/lib/zod/export_parameters.ts +7 -0
- package/dev-server-api/src/lib/zod/export_request.ts +2 -0
- package/dev-server-frontend/bun.lockb +0 -0
- package/dev-server-frontend/package-lock.json +54 -6
- package/dev-server-frontend/package.json +1 -1
- package/dev-server-frontend/src/ExampleContentView.tsx +2 -0
- package/dev-server-frontend/src/HeaderMenu.tsx +26 -6
- package/dev-server-frontend/src/components/dialogs/generic-export-dialog.tsx +188 -0
- package/dev-server-frontend/tsconfig.json +3 -0
- package/dist/cli.js +133 -56
- package/lib/cmd-fns/dev/fulfill-export-requests.ts +90 -26
- package/lib/cmd-fns/export-gerbers.ts +1 -1
- package/lib/export-fns/export-bom-csv.ts +30 -0
- package/lib/{export-gerbers.ts → export-fns/export-gerbers.ts} +1 -1
- package/lib/export-fns/export-pnp-csv.ts +35 -0
- package/package.json +3 -3
- package/tests/assets/example-project/package-lock.json +467 -0
- package/tests/assets/example-project/package.json +3 -3
- package/tests/assets/example-project/src/MyCircuit.tsx +10 -1
- package/tsconfig.json +3 -1
|
@@ -1,7 +1,37 @@
|
|
|
1
1
|
import { AppContext } from "../../util/app-context"
|
|
2
2
|
import kleur from "kleur"
|
|
3
|
-
import { exportGerbersToZipBuffer } from "lib/export-gerbers"
|
|
3
|
+
import { exportGerbersToZipBuffer } from "lib/export-fns/export-gerbers"
|
|
4
4
|
import { AxiosInstance } from "axios"
|
|
5
|
+
import { ExportRequest } from "@server/lib/zod/export_request"
|
|
6
|
+
import { exportPnpCsvToBuffer } from "lib/export-fns/export-pnp-csv"
|
|
7
|
+
import { exportBomCsvToBuffer } from "lib/export-fns/export-bom-csv"
|
|
8
|
+
|
|
9
|
+
export const uploadBufferToExportFile = async ({
|
|
10
|
+
dev_server_axios,
|
|
11
|
+
file_buffer,
|
|
12
|
+
file_name,
|
|
13
|
+
export_request_id,
|
|
14
|
+
}: {
|
|
15
|
+
dev_server_axios: AxiosInstance
|
|
16
|
+
file_buffer: Buffer
|
|
17
|
+
file_name: string
|
|
18
|
+
export_request_id: number
|
|
19
|
+
}) => {
|
|
20
|
+
await dev_server_axios.post("/api/export_files/create", {
|
|
21
|
+
file_content_base64: file_buffer.toString("base64"),
|
|
22
|
+
file_name: file_name,
|
|
23
|
+
export_request_id: export_request_id,
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
console.log(kleur.gray(` marking export request as complete...`))
|
|
27
|
+
|
|
28
|
+
await dev_server_axios.post("/api/export_requests/update", {
|
|
29
|
+
export_request_id: export_request_id,
|
|
30
|
+
is_complete: true,
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
console.log(kleur.green(` done`))
|
|
34
|
+
}
|
|
5
35
|
|
|
6
36
|
export const fulfillExportRequests = async (
|
|
7
37
|
{
|
|
@@ -11,46 +41,80 @@ export const fulfillExportRequests = async (
|
|
|
11
41
|
},
|
|
12
42
|
ctx: AppContext
|
|
13
43
|
) => {
|
|
14
|
-
const export_requests = await dev_server_axios
|
|
44
|
+
const export_requests: ExportRequest[] = await dev_server_axios
|
|
15
45
|
.post("/api/export_requests/list", {
|
|
16
46
|
is_complete: false,
|
|
17
47
|
})
|
|
18
48
|
.then((r) => r.data.export_requests)
|
|
19
49
|
|
|
20
50
|
for (const export_request of export_requests) {
|
|
21
|
-
console.log(
|
|
51
|
+
console.log(
|
|
52
|
+
kleur.gray(
|
|
53
|
+
`Fulfilling export request ${export_request.export_request_id}`
|
|
54
|
+
)
|
|
55
|
+
)
|
|
22
56
|
console.log(
|
|
23
57
|
kleur.gray(` example_file_path: ${export_request.example_file_path}`)
|
|
24
58
|
)
|
|
25
59
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
60
|
+
if (export_request.export_parameters.should_export_gerber_zip) {
|
|
61
|
+
console.log(kleur.gray(`\n exporting gerbers...`))
|
|
62
|
+
const zip_buffer = await exportGerbersToZipBuffer(
|
|
63
|
+
{
|
|
64
|
+
example_file_path: export_request.example_file_path,
|
|
65
|
+
export_name: export_request.export_name,
|
|
66
|
+
},
|
|
67
|
+
ctx
|
|
68
|
+
)
|
|
34
69
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
70
|
+
console.log(
|
|
71
|
+
kleur.gray(
|
|
72
|
+
` uploading zip "${export_request.export_parameters.gerbers_zip_file_name}" to dev server...`
|
|
73
|
+
)
|
|
38
74
|
)
|
|
39
|
-
)
|
|
40
75
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
76
|
+
await uploadBufferToExportFile({
|
|
77
|
+
dev_server_axios,
|
|
78
|
+
file_buffer: zip_buffer,
|
|
79
|
+
file_name: export_request.export_parameters.gerbers_zip_file_name!,
|
|
80
|
+
export_request_id: export_request.export_request_id,
|
|
81
|
+
})
|
|
82
|
+
}
|
|
46
83
|
|
|
47
|
-
|
|
84
|
+
if (export_request.export_parameters.should_export_pnp_csv) {
|
|
85
|
+
console.log(kleur.gray(`\n exporting pick'n'place...`))
|
|
86
|
+
const csv_buffer = await exportPnpCsvToBuffer(
|
|
87
|
+
{
|
|
88
|
+
example_file_path: export_request.example_file_path,
|
|
89
|
+
export_name: export_request.export_name,
|
|
90
|
+
},
|
|
91
|
+
ctx
|
|
92
|
+
)
|
|
48
93
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
94
|
+
await uploadBufferToExportFile({
|
|
95
|
+
dev_server_axios,
|
|
96
|
+
file_buffer: csv_buffer,
|
|
97
|
+
file_name: export_request.export_parameters.pnp_csv_file_name!,
|
|
98
|
+
export_request_id: export_request.export_request_id,
|
|
99
|
+
})
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
if (export_request.export_parameters.should_export_bom_csv) {
|
|
103
|
+
console.log(kleur.gray(`\n exporting bill of materials...`))
|
|
104
|
+
const csv_buffer = await exportBomCsvToBuffer(
|
|
105
|
+
{
|
|
106
|
+
example_file_path: export_request.example_file_path,
|
|
107
|
+
export_name: export_request.export_name,
|
|
108
|
+
},
|
|
109
|
+
ctx
|
|
110
|
+
)
|
|
53
111
|
|
|
54
|
-
|
|
112
|
+
await uploadBufferToExportFile({
|
|
113
|
+
dev_server_axios,
|
|
114
|
+
file_buffer: csv_buffer,
|
|
115
|
+
file_name: export_request.export_parameters.bom_csv_file_name!,
|
|
116
|
+
export_request_id: export_request.export_request_id,
|
|
117
|
+
})
|
|
118
|
+
}
|
|
55
119
|
}
|
|
56
120
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AppContext } from "../util/app-context"
|
|
2
2
|
import { z } from "zod"
|
|
3
|
-
import { exportGerbersToFile } from "lib/export-gerbers"
|
|
3
|
+
import { exportGerbersToFile } from "lib/export-fns/export-gerbers"
|
|
4
4
|
|
|
5
5
|
export const exportGerbersCmd = async (ctx: AppContext, args: any) => {
|
|
6
6
|
const params = z
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { AppContext } from "../util/app-context"
|
|
2
|
+
import { soupify } from "lib/soupify"
|
|
3
|
+
import { convertSoupToBomRows, convertBomRowsToCsv } from "@tscircuit/builder"
|
|
4
|
+
import kleur from "kleur"
|
|
5
|
+
|
|
6
|
+
export const exportBomCsvToBuffer = async (
|
|
7
|
+
params: {
|
|
8
|
+
example_file_path: string
|
|
9
|
+
export_name?: string
|
|
10
|
+
},
|
|
11
|
+
ctx: AppContext
|
|
12
|
+
) => {
|
|
13
|
+
console.log(kleur.gray("[soupifying]..."))
|
|
14
|
+
const soup = await soupify(
|
|
15
|
+
{
|
|
16
|
+
filePath: params.example_file_path,
|
|
17
|
+
exportName: params.export_name,
|
|
18
|
+
},
|
|
19
|
+
ctx
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
console.log(kleur.gray("[soup to bom rows]..."))
|
|
23
|
+
// @ts-ignore
|
|
24
|
+
const bom_rows = await convertSoupToBomRows({ soup })
|
|
25
|
+
|
|
26
|
+
console.log(kleur.gray("[bom rows to csv]..."))
|
|
27
|
+
const bom_csv = await convertBomRowsToCsv(bom_rows)
|
|
28
|
+
|
|
29
|
+
return Buffer.from(bom_csv, "utf-8")
|
|
30
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { AppContext } from "../util/app-context"
|
|
2
|
+
import { z } from "zod"
|
|
3
|
+
import * as Path from "path"
|
|
4
|
+
import { unlink } from "node:fs/promises"
|
|
5
|
+
import { soupify } from "lib/soupify"
|
|
6
|
+
import * as fs from "fs"
|
|
7
|
+
import {
|
|
8
|
+
stringifyGerberCommandLayers,
|
|
9
|
+
convertSoupToGerberCommands,
|
|
10
|
+
convertSoupToPickAndPlaceCsv,
|
|
11
|
+
} from "@tscircuit/builder"
|
|
12
|
+
import kleur from "kleur"
|
|
13
|
+
import archiver from "archiver"
|
|
14
|
+
|
|
15
|
+
export const exportPnpCsvToBuffer = async (
|
|
16
|
+
params: {
|
|
17
|
+
example_file_path: string
|
|
18
|
+
export_name?: string
|
|
19
|
+
},
|
|
20
|
+
ctx: AppContext
|
|
21
|
+
) => {
|
|
22
|
+
console.log(kleur.gray("[soupifying]..."))
|
|
23
|
+
const soup = await soupify(
|
|
24
|
+
{
|
|
25
|
+
filePath: params.example_file_path,
|
|
26
|
+
exportName: params.export_name,
|
|
27
|
+
},
|
|
28
|
+
ctx
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
console.log(kleur.gray("[soup to pnp csv string]..."))
|
|
32
|
+
const pnp_csv = await convertSoupToPickAndPlaceCsv(soup)
|
|
33
|
+
|
|
34
|
+
return Buffer.from(pnp_csv, "utf-8")
|
|
35
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tscircuit/cli",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.65",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "Command line tool for developing, publishing and installing tscircuit circuits",
|
|
@@ -35,8 +35,8 @@
|
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@edge-runtime/primitives": "^4.1.0",
|
|
37
37
|
"@hono/node-server": "^1.8.2",
|
|
38
|
-
"@tscircuit/builder": "
|
|
39
|
-
"@tscircuit/react-fiber": "
|
|
38
|
+
"@tscircuit/builder": "^1.5.60",
|
|
39
|
+
"@tscircuit/react-fiber": "^1.0.34",
|
|
40
40
|
"archiver": "^7.0.1",
|
|
41
41
|
"axios": "^1.6.7",
|
|
42
42
|
"better-sqlite3": "^9.4.3",
|