@tscircuit/cli 0.0.144 → 0.0.145
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/formatbot.yml +41 -0
- package/biome.json +44 -0
- package/bun.lockb +0 -0
- package/dev-server-api/bun.lockb +0 -0
- package/dev-server-api/routes/api/db/download.ts +2 -2
- package/dev-server-api/routes/api/dev_package_examples/get.ts +1 -1
- package/dev-server-api/routes/api/dev_package_examples/list.ts +2 -2
- package/dev-server-api/routes/api/dev_package_examples/update.ts +1 -1
- package/dev-server-api/routes/api/export_requests/get.ts +2 -2
- package/dev-server-api/routes/index.ts +1 -1
- package/dev-server-api/server.ts +1 -1
- package/dev-server-api/src/db/create-schema.ts +4 -4
- package/dev-server-api/src/db/generic-json-level.ts +2 -2
- package/dev-server-api/src/db/zod-level-db.ts +9 -9
- package/dev-server-api/src/middlewares/with-debug-request-logging.ts +1 -1
- package/dev-server-api/src/middlewares/with-error-response.ts +2 -2
- package/dev-server-api/tests/fixtures/start-server.ts +1 -1
- package/dev-server-api/tests/routes/dev_package_examples/create.test.ts +1 -1
- package/dev-server-api/tests/routes/dev_package_examples/get.test.ts +1 -1
- package/dev-server-api/tests/routes/dev_package_examples/list.test.ts +1 -1
- package/dev-server-api/tests/routes/dev_package_examples/update.test.ts +2 -2
- package/dev-server-api/tests/routes/export_files/download.test.ts +2 -2
- package/dev-server-api/tests/routes/export_requests/create.test.ts +1 -1
- package/dev-server-api/tests/routes/export_requests/get.test.ts +1 -1
- package/dev-server-frontend/.eslintrc.cjs +10 -10
- package/dev-server-frontend/components.json +1 -1
- package/dev-server-frontend/src/ExampleContentView.tsx +2 -2
- package/dev-server-frontend/src/HeaderMenu.tsx +2 -7
- package/dev-server-frontend/src/components/command-k.tsx +1 -1
- package/dev-server-frontend/src/components/dialogs/generic-export-dialog.tsx +3 -3
- package/dev-server-frontend/src/components/dialogs/gerber-export-dialog.tsx +3 -3
- package/dev-server-frontend/src/components/select-example-search.tsx +1 -1
- package/dev-server-frontend/src/components/ui/alert-dialog.tsx +5 -5
- package/dev-server-frontend/src/components/ui/alert.tsx +1 -1
- package/dev-server-frontend/src/components/ui/breadcrumb.tsx +1 -1
- package/dev-server-frontend/src/components/ui/button.tsx +2 -2
- package/dev-server-frontend/src/components/ui/card.tsx +1 -1
- package/dev-server-frontend/src/components/ui/command.tsx +5 -5
- package/dev-server-frontend/src/components/ui/context-menu.tsx +8 -8
- package/dev-server-frontend/src/components/ui/dialog.tsx +5 -5
- package/dev-server-frontend/src/components/ui/menubar.tsx +12 -12
- package/dev-server-frontend/src/components/ui/navigation-menu.tsx +6 -6
- package/dev-server-frontend/src/components/ui/popover.tsx +1 -1
- package/dev-server-frontend/src/components/ui/select.tsx +6 -6
- package/dev-server-frontend/src/components/ui/tabs.tsx +3 -3
- package/dev-server-frontend/src/components/ui/toggle-group.tsx +1 -1
- package/dev-server-frontend/src/components/ui/toggle.tsx +1 -1
- package/dev-server-frontend/src/components/ui/tooltip.tsx +1 -1
- package/dev-server-frontend/src/hooks/use-active-dev-package-example-lite.ts +2 -2
- package/dev-server-frontend/src/main.tsx +1 -1
- package/dev-server-frontend/tailwind.config.js +5 -5
- package/dev-server-frontend/tsconfig.json +1 -1
- package/dist/cli.js +14 -7
- package/example-project/src/manual-edits.ts +34 -34
- package/lib/cmd-fns/add.ts +1 -1
- package/lib/cmd-fns/auth-login.ts +2 -2
- package/lib/cmd-fns/dev/check-if-initialized.ts +1 -1
- package/lib/cmd-fns/dev/derive-selector-from-pcb-component-id.ts +1 -1
- package/lib/cmd-fns/dev/dev-server-request-handler.ts +3 -3
- package/lib/cmd-fns/dev/find-available-port.ts +7 -5
- package/lib/cmd-fns/dev/fulfill-export-requests.ts +14 -14
- package/lib/cmd-fns/dev/get-dev-server-axios.ts +3 -3
- package/lib/cmd-fns/dev/index.ts +3 -3
- package/lib/cmd-fns/dev/infer-export-name-from-source.ts +2 -2
- package/lib/cmd-fns/dev/soupify-and-upload-example-file.ts +4 -4
- package/lib/cmd-fns/dev/start-edit-event-watcher.ts +37 -38
- package/lib/cmd-fns/dev/start-export-request-watcher.ts +2 -3
- package/lib/cmd-fns/dev/start-fs-watcher.ts +1 -1
- package/lib/cmd-fns/dev/upload-examples-from-directory.ts +2 -2
- package/lib/cmd-fns/dev-server-fulfill-export-requests.ts +3 -3
- package/lib/cmd-fns/dev-server-upload.ts +3 -3
- package/lib/cmd-fns/export-gerbers.ts +1 -1
- package/lib/cmd-fns/init/create-or-modify-npmrc.ts +1 -1
- package/lib/cmd-fns/init/index.ts +12 -8
- package/lib/cmd-fns/lint.ts +15 -9
- package/lib/cmd-fns/package-examples-create.ts +1 -1
- package/lib/cmd-fns/package-files-create.ts +1 -1
- package/lib/cmd-fns/package-files-upload-directory.ts +1 -1
- package/lib/cmd-fns/package-releases-create.ts +1 -1
- package/lib/cmd-fns/package-releases-list.ts +1 -1
- package/lib/cmd-fns/publish/index.ts +33 -33
- package/lib/cmd-fns/remove.ts +1 -1
- package/lib/cmd-fns/soupify.ts +1 -1
- package/lib/cmd-fns/version.ts +1 -1
- package/lib/create-config-manager.ts +1 -1
- package/lib/export-fns/export-bom-csv.ts +2 -2
- package/lib/export-fns/export-gerbers.ts +5 -5
- package/lib/export-fns/export-pnp-csv.ts +2 -2
- package/lib/get-program.ts +17 -17
- package/lib/param-handlers/interact-for-package-release-id.ts +2 -3
- package/lib/param-handlers/interact-for-runtime.ts +1 -1
- package/lib/posthog.ts +6 -7
- package/lib/soupify.ts +4 -4
- package/lib/util/create-context-and-run-program.ts +10 -6
- package/lib/util/get-all-package-files.ts +1 -1
- package/lib/util/lint-project.ts +79 -54
- package/package.json +4 -2
- package/renovate.json +2 -4
- package/tests/init.test.ts +1 -1
- package/tsconfig.json +13 -13
- package/tsup.config.ts +3 -3
|
@@ -15,43 +15,43 @@ export default {
|
|
|
15
15
|
|
|
16
16
|
// Manual pcb placements, added when you drag a footprint
|
|
17
17
|
pcb_placements: [
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
},
|
|
25
|
-
"relative_to": "group_center"
|
|
18
|
+
{
|
|
19
|
+
_edit_event_id: "0.6668756126702717",
|
|
20
|
+
selector: ".U2",
|
|
21
|
+
center: {
|
|
22
|
+
x: -5.004250626566417,
|
|
23
|
+
y: 0.13319298245614064,
|
|
26
24
|
},
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
25
|
+
relative_to: "group_center",
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
_edit_event_id: "0.867524742177592",
|
|
29
|
+
selector: ".R1",
|
|
30
|
+
center: {
|
|
31
|
+
x: 2.8351077694235585,
|
|
32
|
+
y: 0,
|
|
35
33
|
},
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
34
|
+
relative_to: "group_center",
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
_edit_event_id: "0.4555106760070762",
|
|
38
|
+
selector: ".C1",
|
|
39
|
+
center: {
|
|
40
|
+
x: 0,
|
|
41
|
+
y: 2.6666666666666665,
|
|
44
42
|
},
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
54
|
-
|
|
43
|
+
relative_to: "group_center",
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
_edit_event_id: "0.6123290063979561",
|
|
47
|
+
selector: ".R2",
|
|
48
|
+
center: {
|
|
49
|
+
x: 13.457749922536511,
|
|
50
|
+
y: 5.576084911465589,
|
|
51
|
+
},
|
|
52
|
+
relative_to: "group_center",
|
|
53
|
+
},
|
|
54
|
+
],
|
|
55
55
|
manual_trace_hints: [],
|
|
56
56
|
edit_events: [],
|
|
57
57
|
}
|
package/lib/cmd-fns/add.ts
CHANGED
|
@@ -22,7 +22,7 @@ export const authLogin = async (ctx: AppContext, args: any) => {
|
|
|
22
22
|
headers: {
|
|
23
23
|
Authorization: `Bearer ${login_page.login_page_auth_token}`,
|
|
24
24
|
},
|
|
25
|
-
}
|
|
25
|
+
},
|
|
26
26
|
)
|
|
27
27
|
|
|
28
28
|
if (new_login_page.was_login_successful) {
|
|
@@ -48,7 +48,7 @@ export const authLogin = async (ctx: AppContext, args: any) => {
|
|
|
48
48
|
headers: {
|
|
49
49
|
Authorization: `Bearer ${login_page.login_page_auth_token}`,
|
|
50
50
|
},
|
|
51
|
-
}
|
|
51
|
+
},
|
|
52
52
|
)
|
|
53
53
|
|
|
54
54
|
ctx.profile_config.set("session_token", session.token)
|
|
@@ -13,7 +13,7 @@ export const checkIfInitialized = async (ctx: AppContext) => {
|
|
|
13
13
|
const packageJsonRaw = readFileSync(packageJsonPath, "utf-8")
|
|
14
14
|
if (!packageJsonRaw.includes("tscircuit")) {
|
|
15
15
|
console.error(
|
|
16
|
-
kleur.red(`No tscircuit dependencies are installed in this project.`)
|
|
16
|
+
kleur.red(`No tscircuit dependencies are installed in this project.`),
|
|
17
17
|
)
|
|
18
18
|
return false
|
|
19
19
|
}
|
|
@@ -13,7 +13,7 @@ export const deriveSelectorFromPcbComponentId = ({
|
|
|
13
13
|
})
|
|
14
14
|
if (!source_component) {
|
|
15
15
|
throw new Error(
|
|
16
|
-
`Could not find source component for pcb_component_id="${pcb_component_id}"
|
|
16
|
+
`Could not find source component for pcb_component_id="${pcb_component_id}"`,
|
|
17
17
|
)
|
|
18
18
|
}
|
|
19
19
|
|
|
@@ -5,10 +5,10 @@ import mime from "mime-types"
|
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Handles all requests to :3020, then proxies...
|
|
8
|
-
*
|
|
8
|
+
*
|
|
9
9
|
* /api/* : to the api server
|
|
10
10
|
* /* : to the static frontend bundle inside dev-server-frontend
|
|
11
|
-
*
|
|
11
|
+
*
|
|
12
12
|
*/
|
|
13
13
|
export const devServerRequestHandler = async (bunReq: Request) => {
|
|
14
14
|
const url = new URL(bunReq.url)
|
|
@@ -48,7 +48,7 @@ export const devServerRequestHandler = async (bunReq: Request) => {
|
|
|
48
48
|
headers: {
|
|
49
49
|
"Content-Type": mime.lookup(frontendPath) || "text/plain",
|
|
50
50
|
},
|
|
51
|
-
}
|
|
51
|
+
},
|
|
52
52
|
)
|
|
53
53
|
} else {
|
|
54
54
|
return new Response(null, {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import net from
|
|
1
|
+
import net from "net"
|
|
2
2
|
|
|
3
3
|
const MAX_PORT = 65535 // Maximum valid port number
|
|
4
4
|
|
|
@@ -12,19 +12,21 @@ export const findAvailablePort = async (startPort: number): Promise<number> => {
|
|
|
12
12
|
port++
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
throw new Error(
|
|
15
|
+
throw new Error(
|
|
16
|
+
`Unable to find an available port in range ${startPort}-${MAX_PORT}`,
|
|
17
|
+
)
|
|
16
18
|
}
|
|
17
19
|
|
|
18
20
|
const isPortInUse = (port: number): Promise<boolean> => {
|
|
19
21
|
return new Promise((resolve) => {
|
|
20
22
|
const server = net.createServer()
|
|
21
|
-
server.once(
|
|
23
|
+
server.once("error", () => {
|
|
22
24
|
resolve(true)
|
|
23
25
|
})
|
|
24
|
-
server.once(
|
|
26
|
+
server.once("listening", () => {
|
|
25
27
|
server.close()
|
|
26
28
|
resolve(false)
|
|
27
29
|
})
|
|
28
30
|
server.listen(port)
|
|
29
31
|
})
|
|
30
|
-
}
|
|
32
|
+
}
|
|
@@ -40,7 +40,7 @@ export const fulfillExportRequests = async (
|
|
|
40
40
|
}: {
|
|
41
41
|
dev_server_axios: AxiosInstance
|
|
42
42
|
},
|
|
43
|
-
ctx: AppContext
|
|
43
|
+
ctx: AppContext,
|
|
44
44
|
) => {
|
|
45
45
|
const export_requests: ExportRequest[] = await dev_server_axios
|
|
46
46
|
.post("/api/export_requests/list", {
|
|
@@ -51,11 +51,11 @@ export const fulfillExportRequests = async (
|
|
|
51
51
|
for (const export_request of export_requests) {
|
|
52
52
|
console.log(
|
|
53
53
|
kleur.gray(
|
|
54
|
-
`Fulfilling export request ${export_request.export_request_id}
|
|
55
|
-
)
|
|
54
|
+
`Fulfilling export request ${export_request.export_request_id}`,
|
|
55
|
+
),
|
|
56
56
|
)
|
|
57
57
|
console.log(
|
|
58
|
-
kleur.gray(` example_file_path: ${export_request.example_file_path}`)
|
|
58
|
+
kleur.gray(` example_file_path: ${export_request.example_file_path}`),
|
|
59
59
|
)
|
|
60
60
|
|
|
61
61
|
if (export_request.export_parameters.should_export_gerber_zip) {
|
|
@@ -76,13 +76,13 @@ export const fulfillExportRequests = async (
|
|
|
76
76
|
example_file_path: export_request.example_file_path,
|
|
77
77
|
export_name: export_request.export_name,
|
|
78
78
|
},
|
|
79
|
-
ctx
|
|
79
|
+
ctx,
|
|
80
80
|
)
|
|
81
81
|
|
|
82
82
|
console.log(
|
|
83
83
|
kleur.gray(
|
|
84
|
-
` uploading zip "${export_request.export_parameters.gerbers_zip_file_name}" to dev server
|
|
85
|
-
)
|
|
84
|
+
` uploading zip "${export_request.export_parameters.gerbers_zip_file_name}" to dev server...`,
|
|
85
|
+
),
|
|
86
86
|
)
|
|
87
87
|
|
|
88
88
|
await uploadBufferToExportFile({
|
|
@@ -100,11 +100,11 @@ export const fulfillExportRequests = async (
|
|
|
100
100
|
example_file_path: export_request.example_file_path,
|
|
101
101
|
export_name: export_request.export_name,
|
|
102
102
|
},
|
|
103
|
-
ctx
|
|
103
|
+
ctx,
|
|
104
104
|
)
|
|
105
|
-
|
|
105
|
+
|
|
106
106
|
const pnpFileName = `${export_request.export_name}-${export_request.export_parameters.pnp_csv_file_name!}`
|
|
107
|
-
|
|
107
|
+
|
|
108
108
|
await uploadBufferToExportFile({
|
|
109
109
|
dev_server_axios,
|
|
110
110
|
file_buffer: csv_buffer,
|
|
@@ -120,11 +120,11 @@ export const fulfillExportRequests = async (
|
|
|
120
120
|
example_file_path: export_request.example_file_path,
|
|
121
121
|
export_name: export_request.export_name,
|
|
122
122
|
},
|
|
123
|
-
ctx
|
|
123
|
+
ctx,
|
|
124
124
|
)
|
|
125
|
-
|
|
125
|
+
|
|
126
126
|
const bomFileName = `${export_request.export_name}-${export_request.export_parameters.bom_csv_file_name!}`
|
|
127
|
-
|
|
127
|
+
|
|
128
128
|
await uploadBufferToExportFile({
|
|
129
129
|
dev_server_axios,
|
|
130
130
|
file_buffer: csv_buffer,
|
|
@@ -140,7 +140,7 @@ export const fulfillExportRequests = async (
|
|
|
140
140
|
filePath: export_request.example_file_path,
|
|
141
141
|
exportName: export_request.export_name,
|
|
142
142
|
},
|
|
143
|
-
ctx
|
|
143
|
+
ctx,
|
|
144
144
|
)
|
|
145
145
|
|
|
146
146
|
await uploadBufferToExportFile({
|
|
@@ -18,12 +18,12 @@ export const getDevServerAxios = ({ serverUrl }: { serverUrl: string }) => {
|
|
|
18
18
|
err.config.url
|
|
19
19
|
}\n\n${JSON.stringify(err.response?.data, null, " ")}`
|
|
20
20
|
.replace(/\\n/g, "\n")
|
|
21
|
-
.replace(/\\"/g, '"')
|
|
22
|
-
)
|
|
21
|
+
.replace(/\\"/g, '"'),
|
|
22
|
+
),
|
|
23
23
|
)
|
|
24
24
|
console.log(kleur.yellow("[Request Body]:"), err.config.data)
|
|
25
25
|
return Promise.reject(err)
|
|
26
|
-
}
|
|
26
|
+
},
|
|
27
27
|
)
|
|
28
28
|
return devServerAxios
|
|
29
29
|
}
|
package/lib/cmd-fns/dev/index.ts
CHANGED
|
@@ -77,8 +77,8 @@ export const devCmd = async (ctx: AppContext, args: any) => {
|
|
|
77
77
|
|
|
78
78
|
console.log(
|
|
79
79
|
kleur.green(
|
|
80
|
-
`\n--------------------------------------------\n\nStarting dev server http://127.0.0.1:${port}\n\n--------------------------------------------\n\n
|
|
81
|
-
)
|
|
80
|
+
`\n--------------------------------------------\n\nStarting dev server http://127.0.0.1:${port}\n\n--------------------------------------------\n\n`,
|
|
81
|
+
),
|
|
82
82
|
)
|
|
83
83
|
const serverUrl = `http://127.0.0.1:${port}`
|
|
84
84
|
const devServerAxios = getDevServerAxios({ serverUrl })
|
|
@@ -101,7 +101,7 @@ export const devCmd = async (ctx: AppContext, args: any) => {
|
|
|
101
101
|
{
|
|
102
102
|
package_name: packageName,
|
|
103
103
|
},
|
|
104
|
-
ctx
|
|
104
|
+
ctx,
|
|
105
105
|
)
|
|
106
106
|
|
|
107
107
|
// Soupify all examples
|
|
@@ -3,14 +3,14 @@ export const inferExportNameFromSource = (sourceContent: string): string => {
|
|
|
3
3
|
return "default"
|
|
4
4
|
}
|
|
5
5
|
const matches = Array.from(
|
|
6
|
-
sourceContent.matchAll(/export\s+(const|function)\s+([A-Z]\w+)\s*=?/g)
|
|
6
|
+
sourceContent.matchAll(/export\s+(const|function)\s+([A-Z]\w+)\s*=?/g),
|
|
7
7
|
).map((m) => m[2])
|
|
8
8
|
if (matches.length === 0) {
|
|
9
9
|
throw new Error(`No export detected in "${sourceContent}"`)
|
|
10
10
|
}
|
|
11
11
|
if (matches.length > 1) {
|
|
12
12
|
throw new Error(
|
|
13
|
-
`Multiple exports detected in "${sourceContent}", only single exports currently working
|
|
13
|
+
`Multiple exports detected in "${sourceContent}", only single exports currently working`,
|
|
14
14
|
)
|
|
15
15
|
}
|
|
16
16
|
return matches[0]
|
|
@@ -15,7 +15,7 @@ export const soupifyAndUploadExampleFile = async (
|
|
|
15
15
|
exampleFileName: string
|
|
16
16
|
devServerAxios: AxiosInstance
|
|
17
17
|
},
|
|
18
|
-
ctx: { runtime: "node" | "bun" }
|
|
18
|
+
ctx: { runtime: "node" | "bun" },
|
|
19
19
|
) => {
|
|
20
20
|
try {
|
|
21
21
|
const startTime = Date.now()
|
|
@@ -30,7 +30,7 @@ export const soupifyAndUploadExampleFile = async (
|
|
|
30
30
|
filePath: examplePath,
|
|
31
31
|
exportName,
|
|
32
32
|
},
|
|
33
|
-
ctx
|
|
33
|
+
ctx,
|
|
34
34
|
)
|
|
35
35
|
.then((soup) => ({ soup, error: null }))
|
|
36
36
|
.catch((e) => ({ error: e, soup: undefined }))
|
|
@@ -52,8 +52,8 @@ export const soupifyAndUploadExampleFile = async (
|
|
|
52
52
|
kleur.gray(
|
|
53
53
|
`[ done ] [ ${Math.round(timeTaken)
|
|
54
54
|
.toString()
|
|
55
|
-
.padStart(5, " ")}ms ] ${exampleFileName}
|
|
56
|
-
)
|
|
55
|
+
.padStart(5, " ")}ms ] ${exampleFileName}!`,
|
|
56
|
+
),
|
|
57
57
|
)
|
|
58
58
|
} catch (e: any) {
|
|
59
59
|
console.log(kleur.red(`[ error ] ${e.toString()}`))
|
|
@@ -18,10 +18,9 @@ export const startEditEventWatcher = async (
|
|
|
18
18
|
}: {
|
|
19
19
|
devServerAxios: AxiosInstance
|
|
20
20
|
},
|
|
21
|
-
ctx: AppContext
|
|
21
|
+
ctx: AppContext,
|
|
22
22
|
) => {
|
|
23
23
|
let running = true
|
|
24
|
-
|
|
25
24
|
;(async () => {
|
|
26
25
|
let last_edit_event_update_time: Record<string, string> = {}
|
|
27
26
|
|
|
@@ -44,11 +43,11 @@ export const startEditEventWatcher = async (
|
|
|
44
43
|
) {
|
|
45
44
|
console.log(
|
|
46
45
|
kleur.gray(
|
|
47
|
-
`Edit event detected for dev_package_example ${dev_package_example.dev_package_example_id}
|
|
48
|
-
)
|
|
46
|
+
`Edit event detected for dev_package_example ${dev_package_example.dev_package_example_id}`,
|
|
47
|
+
),
|
|
49
48
|
)
|
|
50
49
|
console.log(
|
|
51
|
-
kleur.gray(` file_path: ${dev_package_example.file_path}`)
|
|
50
|
+
kleur.gray(` file_path: ${dev_package_example.file_path}`),
|
|
52
51
|
)
|
|
53
52
|
|
|
54
53
|
last_edit_event_update_time[dev_package_example_id] =
|
|
@@ -68,14 +67,14 @@ export const startEditEventWatcher = async (
|
|
|
68
67
|
{
|
|
69
68
|
cwd: ctx.cwd,
|
|
70
69
|
ignore: ["node_modules"],
|
|
71
|
-
}
|
|
70
|
+
},
|
|
72
71
|
)
|
|
73
72
|
|
|
74
73
|
if (manual_edit_files.length === 0) {
|
|
75
74
|
console.log(
|
|
76
75
|
kleur.red(
|
|
77
|
-
`No manual edit files found in "${ctx.cwd}", please create a file "manual-edits.ts" or "*.manual-edits.ts" to persist manual edits
|
|
78
|
-
)
|
|
76
|
+
`No manual edit files found in "${ctx.cwd}", please create a file "manual-edits.ts" or "*.manual-edits.ts" to persist manual edits`,
|
|
77
|
+
),
|
|
79
78
|
)
|
|
80
79
|
continue
|
|
81
80
|
}
|
|
@@ -83,12 +82,12 @@ export const startEditEventWatcher = async (
|
|
|
83
82
|
if (manual_edit_files.length > 1) {
|
|
84
83
|
console.log(
|
|
85
84
|
kleur.red(
|
|
86
|
-
`Multiple manual edit files found, tsci currently doesn't know how to handle this, you should go upvote an issue
|
|
87
|
-
)
|
|
85
|
+
`Multiple manual edit files found, tsci currently doesn't know how to handle this, you should go upvote an issue`,
|
|
86
|
+
),
|
|
88
87
|
)
|
|
89
88
|
for (let i = 0; i < manual_edit_files.length; i++) {
|
|
90
89
|
console.log(
|
|
91
|
-
kleur.gray(` file ${i + 1}: ${manual_edit_files[i]}`)
|
|
90
|
+
kleur.gray(` file ${i + 1}: ${manual_edit_files[i]}`),
|
|
92
91
|
)
|
|
93
92
|
}
|
|
94
93
|
continue
|
|
@@ -97,11 +96,11 @@ export const startEditEventWatcher = async (
|
|
|
97
96
|
const manual_edit_file = manual_edit_files[0]
|
|
98
97
|
const manual_edit_file_content = fs.readFileSync(
|
|
99
98
|
Path.join(ctx.cwd, manual_edit_file),
|
|
100
|
-
"utf-8"
|
|
99
|
+
"utf-8",
|
|
101
100
|
)
|
|
102
101
|
|
|
103
102
|
console.log(
|
|
104
|
-
kleur.gray(` found manual edit file: ${manual_edit_file}`)
|
|
103
|
+
kleur.gray(` found manual edit file: ${manual_edit_file}`),
|
|
105
104
|
)
|
|
106
105
|
|
|
107
106
|
// 2. Convert the edit events into ManualPcbPosition[] and append,
|
|
@@ -118,7 +117,7 @@ export const startEditEventWatcher = async (
|
|
|
118
117
|
|
|
119
118
|
const ts_manual_edits_file = project.createSourceFile(
|
|
120
119
|
"manual-edits.ts",
|
|
121
|
-
manual_edit_file_content
|
|
120
|
+
manual_edit_file_content,
|
|
122
121
|
)
|
|
123
122
|
|
|
124
123
|
// Access the default export declaration
|
|
@@ -129,7 +128,7 @@ export const startEditEventWatcher = async (
|
|
|
129
128
|
// Get the object literal expression from the export default statement
|
|
130
129
|
const object_literal =
|
|
131
130
|
default_export_dec.getFirstChildByKindOrThrow(
|
|
132
|
-
ts.SyntaxKind.ObjectLiteralExpression
|
|
131
|
+
ts.SyntaxKind.ObjectLiteralExpression,
|
|
133
132
|
)
|
|
134
133
|
|
|
135
134
|
// Get the `pcb_placements` property
|
|
@@ -164,25 +163,25 @@ export const startEditEventWatcher = async (
|
|
|
164
163
|
let manual_trace_hints: ManualTraceHint[]
|
|
165
164
|
try {
|
|
166
165
|
pcb_placements = JSON5.parse(
|
|
167
|
-
pcb_placements_ts.getText().replace(/pcb_placements:\s/, "")
|
|
166
|
+
pcb_placements_ts.getText().replace(/pcb_placements:\s/, ""),
|
|
168
167
|
)
|
|
169
168
|
} catch (e: any) {
|
|
170
169
|
console.log(
|
|
171
170
|
kleur.red(
|
|
172
|
-
`Error parsing pcb_placements from manual edits file: ${pcb_placements_ts.getText()} ${e.toString()}
|
|
173
|
-
)
|
|
171
|
+
`Error parsing pcb_placements from manual edits file: ${pcb_placements_ts.getText()} ${e.toString()}`,
|
|
172
|
+
),
|
|
174
173
|
)
|
|
175
174
|
continue
|
|
176
175
|
}
|
|
177
176
|
try {
|
|
178
177
|
in_file_edit_events = JSON5.parse(
|
|
179
|
-
edit_events_ts.getText().replace(/edit_events:\s/, "")
|
|
178
|
+
edit_events_ts.getText().replace(/edit_events:\s/, ""),
|
|
180
179
|
)
|
|
181
180
|
} catch (e: any) {
|
|
182
181
|
console.log(
|
|
183
182
|
kleur.red(
|
|
184
|
-
`Error parsing edit_events from manual edits file: ${edit_events_ts.getText()} ${e.toString()}
|
|
185
|
-
)
|
|
183
|
+
`Error parsing edit_events from manual edits file: ${edit_events_ts.getText()} ${e.toString()}`,
|
|
184
|
+
),
|
|
186
185
|
)
|
|
187
186
|
continue
|
|
188
187
|
}
|
|
@@ -190,13 +189,13 @@ export const startEditEventWatcher = async (
|
|
|
190
189
|
manual_trace_hints = JSON5.parse(
|
|
191
190
|
manual_trace_hints_ts
|
|
192
191
|
.getText()
|
|
193
|
-
.replace(/manual_trace_hints:\s/, "")
|
|
192
|
+
.replace(/manual_trace_hints:\s/, ""),
|
|
194
193
|
)
|
|
195
194
|
} catch (e: any) {
|
|
196
195
|
console.log(
|
|
197
196
|
kleur.red(
|
|
198
|
-
`Error parsing manual_trace_hints from manual edits file: ${pcb_placements_ts.getText()} ${e.toString()}
|
|
199
|
-
)
|
|
197
|
+
`Error parsing manual_trace_hints from manual edits file: ${pcb_placements_ts.getText()} ${e.toString()}`,
|
|
198
|
+
),
|
|
200
199
|
)
|
|
201
200
|
continue
|
|
202
201
|
}
|
|
@@ -204,7 +203,7 @@ export const startEditEventWatcher = async (
|
|
|
204
203
|
const handled_edit_events = new Set<string>(
|
|
205
204
|
pcb_placements
|
|
206
205
|
.map((p) => (p as any)._edit_event_id)
|
|
207
|
-
.concat(in_file_edit_events.map((a) => a.edit_event_id))
|
|
206
|
+
.concat(in_file_edit_events.map((a) => a.edit_event_id)),
|
|
208
207
|
)
|
|
209
208
|
|
|
210
209
|
// Add PCB placements from edit events
|
|
@@ -229,14 +228,14 @@ export const startEditEventWatcher = async (
|
|
|
229
228
|
if (!pcb_component_selector) continue
|
|
230
229
|
|
|
231
230
|
const existing_placement_for_selector = pcb_placements.find(
|
|
232
|
-
(pp) => pp.selector === pcb_component_selector
|
|
231
|
+
(pp) => pp.selector === pcb_component_selector,
|
|
233
232
|
)
|
|
234
233
|
|
|
235
234
|
if (!existing_placement_for_selector) {
|
|
236
235
|
console.log(
|
|
237
236
|
kleur.gray(
|
|
238
|
-
` adding PCB placement from edit event for "${pcb_component_selector}"
|
|
239
|
-
)
|
|
237
|
+
` adding PCB placement from edit event for "${pcb_component_selector}"`,
|
|
238
|
+
),
|
|
240
239
|
)
|
|
241
240
|
|
|
242
241
|
pcb_placements.push({
|
|
@@ -255,14 +254,14 @@ export const startEditEventWatcher = async (
|
|
|
255
254
|
`pcb_placements: ${JSON.stringify(
|
|
256
255
|
pcb_placements,
|
|
257
256
|
null,
|
|
258
|
-
" "
|
|
259
|
-
)}
|
|
257
|
+
" ",
|
|
258
|
+
)}`,
|
|
260
259
|
)
|
|
261
260
|
|
|
262
261
|
// Save the file
|
|
263
262
|
fs.writeFileSync(
|
|
264
263
|
Path.join(ctx.cwd, manual_edit_file),
|
|
265
|
-
ts_manual_edits_file.getFullText()
|
|
264
|
+
ts_manual_edits_file.getFullText(),
|
|
266
265
|
)
|
|
267
266
|
await devServerAxios.post("/api/dev_package_examples/update", {
|
|
268
267
|
dev_package_example_id,
|
|
@@ -274,7 +273,7 @@ export const startEditEventWatcher = async (
|
|
|
274
273
|
) {
|
|
275
274
|
const new_trace_hint = getManualTraceHintFromEvent(
|
|
276
275
|
dev_package_example_full.tscircuit_soup,
|
|
277
|
-
incoming_edit_event
|
|
276
|
+
incoming_edit_event,
|
|
278
277
|
)
|
|
279
278
|
|
|
280
279
|
manual_trace_hints_ts.replaceWithText(
|
|
@@ -283,17 +282,17 @@ export const startEditEventWatcher = async (
|
|
|
283
282
|
.filter(
|
|
284
283
|
(th) =>
|
|
285
284
|
th.pcb_port_selector !==
|
|
286
|
-
new_trace_hint.pcb_port_selector
|
|
285
|
+
new_trace_hint.pcb_port_selector,
|
|
287
286
|
)
|
|
288
287
|
.concat([new_trace_hint]),
|
|
289
288
|
null,
|
|
290
|
-
" "
|
|
291
|
-
)}
|
|
289
|
+
" ",
|
|
290
|
+
)}`,
|
|
292
291
|
)
|
|
293
292
|
|
|
294
293
|
fs.writeFileSync(
|
|
295
294
|
Path.join(ctx.cwd, manual_edit_file),
|
|
296
|
-
ts_manual_edits_file.getFullText()
|
|
295
|
+
ts_manual_edits_file.getFullText(),
|
|
297
296
|
)
|
|
298
297
|
await devServerAxios.post("/api/dev_package_examples/update", {
|
|
299
298
|
dev_package_example_id,
|
|
@@ -304,12 +303,12 @@ export const startEditEventWatcher = async (
|
|
|
304
303
|
// All other events just go to the manual-edits.ts file with
|
|
305
304
|
// in the "edit_events" property
|
|
306
305
|
edit_events_ts.replaceWithText(
|
|
307
|
-
`edit_events: ${JSON.stringify(edit_events, null, " ")}
|
|
306
|
+
`edit_events: ${JSON.stringify(edit_events, null, " ")}`,
|
|
308
307
|
)
|
|
309
308
|
console.log(edit_events_ts.getFullText())
|
|
310
309
|
fs.writeFileSync(
|
|
311
310
|
Path.join(ctx.cwd, manual_edit_file),
|
|
312
|
-
ts_manual_edits_file.getFullText()
|
|
311
|
+
ts_manual_edits_file.getFullText(),
|
|
313
312
|
)
|
|
314
313
|
await devServerAxios.post("/api/dev_package_examples/update", {
|
|
315
314
|
dev_package_example_id,
|
|
@@ -9,17 +9,16 @@ export const startExportRequestWatcher = async (
|
|
|
9
9
|
}: {
|
|
10
10
|
devServerAxios: AxiosInstance
|
|
11
11
|
},
|
|
12
|
-
ctx: AppContext
|
|
12
|
+
ctx: AppContext,
|
|
13
13
|
) => {
|
|
14
14
|
let running = true
|
|
15
|
-
|
|
16
15
|
;(async () => {
|
|
17
16
|
while (running) {
|
|
18
17
|
try {
|
|
19
18
|
await fulfillExportRequests({ dev_server_axios: devServerAxios }, ctx)
|
|
20
19
|
} catch (err: any) {
|
|
21
20
|
console.log(
|
|
22
|
-
kleur.red(`Error in export request watcher: ${err.toString()}`)
|
|
21
|
+
kleur.red(`Error in export request watcher: ${err.toString()}`),
|
|
23
22
|
)
|
|
24
23
|
}
|
|
25
24
|
await new Promise((resolve) => setTimeout(resolve, 1000))
|
|
@@ -11,7 +11,7 @@ export const startFsWatcher = async (
|
|
|
11
11
|
cwd: string
|
|
12
12
|
devServerAxios: AxiosInstance
|
|
13
13
|
},
|
|
14
|
-
ctx: { runtime: "node" | "bun" }
|
|
14
|
+
ctx: { runtime: "node" | "bun" },
|
|
15
15
|
) => {
|
|
16
16
|
const watcher = chokidar.watch([`${cwd}/**/*.tsx`, `${cwd}/**/*.ts`], {
|
|
17
17
|
ignored: /node_modules/,
|
|
@@ -15,7 +15,7 @@ export const uploadExamplesFromDirectory = async (
|
|
|
15
15
|
cwd: string
|
|
16
16
|
devServerAxios: AxiosInstance
|
|
17
17
|
},
|
|
18
|
-
ctx: { runtime: "node" | "bun" }
|
|
18
|
+
ctx: { runtime: "node" | "bun" },
|
|
19
19
|
) => {
|
|
20
20
|
const examplesDir = joinPath(cwd, "examples")
|
|
21
21
|
const exampleFileNames = await readdir(examplesDir).catch((e) => {
|
|
@@ -35,7 +35,7 @@ export const uploadExamplesFromDirectory = async (
|
|
|
35
35
|
examplesDir,
|
|
36
36
|
exampleFileName,
|
|
37
37
|
},
|
|
38
|
-
ctx
|
|
38
|
+
ctx,
|
|
39
39
|
)
|
|
40
40
|
}
|
|
41
41
|
}
|
|
@@ -6,7 +6,7 @@ import { getDevServerAxios } from "./dev/get-dev-server-axios"
|
|
|
6
6
|
|
|
7
7
|
export const devServerFulfillExportRequests = async (
|
|
8
8
|
ctx: AppContext,
|
|
9
|
-
args: any
|
|
9
|
+
args: any,
|
|
10
10
|
) => {
|
|
11
11
|
const params = z.object({}).parse(args)
|
|
12
12
|
|
|
@@ -33,8 +33,8 @@ export const devServerFulfillExportRequests = async (
|
|
|
33
33
|
if (!is_dev_server_healthy) {
|
|
34
34
|
console.log(
|
|
35
35
|
kleur.red(
|
|
36
|
-
`Dev server doesn't seem to be running at ${server_url}. (Could not ping health)
|
|
37
|
-
)
|
|
36
|
+
`Dev server doesn't seem to be running at ${server_url}. (Could not ping health)`,
|
|
37
|
+
),
|
|
38
38
|
)
|
|
39
39
|
process.exit(1)
|
|
40
40
|
}
|
|
@@ -37,8 +37,8 @@ export const devServerUpload = async (ctx: AppContext, args: any) => {
|
|
|
37
37
|
if (!is_dev_server_healthy) {
|
|
38
38
|
console.log(
|
|
39
39
|
kleur.red(
|
|
40
|
-
`Dev server doesn't seem to be running at ${serverUrl}. (Could not ping health)
|
|
41
|
-
)
|
|
40
|
+
`Dev server doesn't seem to be running at ${serverUrl}. (Could not ping health)`,
|
|
41
|
+
),
|
|
42
42
|
)
|
|
43
43
|
process.exit(1)
|
|
44
44
|
}
|
|
@@ -50,7 +50,7 @@ export const devServerUpload = async (ctx: AppContext, args: any) => {
|
|
|
50
50
|
// Start watcher
|
|
51
51
|
const watcher = await startFsWatcher(
|
|
52
52
|
{ cwd: params.dir, devServerAxios },
|
|
53
|
-
ctx
|
|
53
|
+
ctx,
|
|
54
54
|
)
|
|
55
55
|
}
|
|
56
56
|
}
|