@tscircuit/cli 0.0.116 → 0.0.119

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.
Files changed (58) hide show
  1. package/.github/workflows/release.yml +1 -1
  2. package/.github/workflows/server-tests.yml +31 -0
  3. package/.github/workflows/test.yml +4 -1
  4. package/README.md +1 -2
  5. package/bun.lockb +0 -0
  6. package/dev-server-api/bun.lockb +0 -0
  7. package/dev-server-api/package.json +2 -4
  8. package/dev-server-api/routes/api/db/download.ts +25 -0
  9. package/dev-server-api/routes/api/dev_package_examples/create.ts +15 -25
  10. package/dev-server-api/routes/api/dev_package_examples/get.ts +12 -21
  11. package/dev-server-api/routes/api/dev_package_examples/list.ts +17 -22
  12. package/dev-server-api/routes/api/dev_package_examples/update.ts +39 -37
  13. package/dev-server-api/routes/api/dev_server/reset.ts +6 -8
  14. package/dev-server-api/routes/api/export_files/create.ts +10 -13
  15. package/dev-server-api/routes/api/export_files/download.ts +10 -7
  16. package/dev-server-api/routes/api/export_requests/create.ts +11 -15
  17. package/dev-server-api/routes/api/export_requests/get.ts +24 -15
  18. package/dev-server-api/routes/api/export_requests/list.ts +9 -10
  19. package/dev-server-api/routes/api/export_requests/update.ts +18 -18
  20. package/dev-server-api/routes/api/package_info/create.ts +9 -11
  21. package/dev-server-api/routes/api/package_info/get.ts +5 -8
  22. package/dev-server-api/routes/index.ts +16 -0
  23. package/dev-server-api/server.ts +1 -1
  24. package/dev-server-api/src/db/get-db.ts +11 -102
  25. package/dev-server-api/src/db/schema.ts +65 -0
  26. package/dev-server-api/src/db/zod-level-db.ts +146 -0
  27. package/dev-server-api/src/middlewares/with-db.ts +7 -3
  28. package/dev-server-api/static-routes.ts +3 -1
  29. package/dev-server-api/tests/fixtures/get-test-server.ts +30 -0
  30. package/dev-server-api/tests/fixtures/start-server.ts +20 -0
  31. package/dev-server-api/tests/routes/dev_package_examples/create.test.ts +19 -0
  32. package/dev-server-api/tests/routes/dev_package_examples/get.test.ts +25 -0
  33. package/dev-server-api/tests/routes/dev_package_examples/list.test.ts +32 -0
  34. package/dev-server-api/tests/routes/dev_package_examples/update.test.ts +28 -0
  35. package/dev-server-api/tests/routes/export_files/create.test.ts +18 -0
  36. package/dev-server-api/tests/routes/export_files/download.test.ts +29 -0
  37. package/dev-server-api/tests/routes/export_requests/create.test.ts +24 -0
  38. package/dev-server-api/tests/routes/export_requests/get.test.ts +41 -0
  39. package/dev-server-api/tests/routes/export_requests/list.test.ts +35 -0
  40. package/dev-server-api/tests/routes/export_requests/update.test.ts +50 -0
  41. package/dev-server-api/tests/routes/health.test.ts +10 -0
  42. package/dist/cli.js +487 -368
  43. package/lib/cmd-fns/dev/index.ts +14 -11
  44. package/package.json +6 -8
  45. package/tests/open.test.ts +1 -2
  46. package/tests/soupify.test.ts +1 -1
  47. package/dev-server-api/src/lib/zod/export_file.ts +0 -8
  48. package/dev-server-api/src/lib/zod/export_package_info.ts +0 -5
  49. package/dev-server-api/src/lib/zod/export_request.ts +0 -21
  50. /package/{tests/assets/example-project → example-project}/README.md +0 -0
  51. /package/{tests/assets/example-project → example-project}/examples/basic-bug.tsx +0 -0
  52. /package/{tests/assets/example-project → example-project}/examples/basic-capacitor.tsx +0 -0
  53. /package/{tests/assets/example-project → example-project}/examples/basic-resistor.tsx +0 -0
  54. /package/{tests/assets/example-project → example-project}/index.ts +0 -0
  55. /package/{tests/assets/example-project → example-project}/package-lock.json +0 -0
  56. /package/{tests/assets/example-project → example-project}/package.json +0 -0
  57. /package/{tests/assets/example-project → example-project}/src/MyCircuit.tsx +0 -0
  58. /package/{tests/assets/example-project → example-project}/src/manual-edits.ts +0 -0
@@ -1,5 +1,5 @@
1
1
  import $ from "dax-sh"
2
- import fs from 'fs'
2
+ import fs from "fs"
3
3
  import { unlink } from "fs/promises"
4
4
  import kleur from "kleur"
5
5
  import open from "open"
@@ -58,7 +58,7 @@ export const devCmd = async (ctx: AppContext, args: any) => {
58
58
  // TODO
59
59
 
60
60
  // Delete old .tscircuit/dev-server.sqlite
61
- unlink(Path.join(cwd, ".tscircuit/dev-server.sqlite")).catch(() => { })
61
+ // unlink(Path.join(cwd, ".tscircuit/dev-server.sqlite")).catch(() => { })
62
62
 
63
63
  console.log(
64
64
  kleur.green(
@@ -71,20 +71,23 @@ export const devCmd = async (ctx: AppContext, args: any) => {
71
71
  const server = await startDevServer({ port, devServerAxios })
72
72
 
73
73
  // Reset the database, allows migration to re-run
74
- await devServerAxios.post("/api/dev_server/reset")
75
- .catch(e => {
76
- console.log("Failed to reset database, continuing anyway...")
77
- })
74
+ await devServerAxios.post("/api/dev_server/reset").catch((e) => {
75
+ console.log("Failed to reset database, continuing anyway...")
76
+ })
78
77
 
79
78
  // Add package name to the package_info table
80
- const packageJsonPath = Path.resolve(cwd, 'package.json')
81
- const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'))
79
+ const packageJsonPath = Path.resolve(cwd, "package.json")
80
+ const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf-8"))
82
81
  const packageName = packageJson.name
83
82
 
84
83
  console.log(`Adding package info...`)
85
- await devServerAxios.post("/api/package_info/create", {
86
- package_name: packageName
87
- }, ctx)
84
+ await devServerAxios.post(
85
+ "/api/package_info/create",
86
+ {
87
+ package_name: packageName,
88
+ },
89
+ ctx
90
+ )
88
91
 
89
92
  // Soupify all examples
90
93
  console.log(`Loading examples...`)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tscircuit/cli",
3
- "version": "0.0.116",
3
+ "version": "0.0.119",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Command line tool for developing, publishing and installing tscircuit circuits",
@@ -9,16 +9,16 @@
9
9
  "bootstrap": "bun i && cd dev-server-api && bun i && cd ../dev-server-frontend && bun i",
10
10
  "bootstrap:ci": "bun i --frozen-lockfile && cd dev-server-api && bun i --frozen-lockfile && cd ../dev-server-frontend && bun i --frozen-lockfile",
11
11
  "start": "bun cli.ts",
12
- "dev": "TSCI_DEV_SERVER_DB=$(pwd)/.tscircuit/dev-server.sqlite concurrently 'cd dev-server-api && bun run build && bun start' 'cd dev-server-frontend && bun start' 'bun run dev-with-test-project'",
12
+ "dev": "TSCI_DEV_SERVER_DB=$(pwd)/.tscircuit/devdb concurrently 'cd dev-server-api && bun run build && bun start' 'cd dev-server-frontend && bun start' 'bun run dev-with-test-project'",
13
13
  "clear": "rm -rf .tscircuit ./dev-server-api/.edgespec",
14
- "start:dev-server": "bun build:dev-server && bun cli.ts dev -y --cwd ./tests/assets/example-project",
14
+ "start:dev-server": "bun build:dev-server && bun cli.ts dev -y --cwd ./example-project",
15
15
  "build:dev-server": "cd dev-server-api && bun run build && cd ../dev-server-frontend && bun run build",
16
16
  "build:dev-server:api": "cd dev-server-api && bun run build",
17
17
  "build:cli": "bun build-cli.ts",
18
18
  "build": "bun build:dev-server && npm run build:cli",
19
- "dev-with-test-project": "bun cli.ts dev --cwd ./tests/assets/example-project",
19
+ "dev-with-test-project": "bun cli.ts dev --cwd ./example-project",
20
20
  "test:init": "bun cli.ts init --dir ./tmp/test --name test",
21
- "update-deps": "bun add @tscircuit/builder@latest @tscircuit/react-fiber@latest && cd dev-server-frontend && bun run update-deps && cd ../tests/assets/example-project && bun run update-deps"
21
+ "update-deps": "bun add @tscircuit/builder@latest @tscircuit/react-fiber@latest && cd dev-server-frontend && bun run update-deps && cd ../example-project && bun run update-deps"
22
22
  },
23
23
  "bin": {
24
24
  "tsci": "./dist/cli.js"
@@ -37,7 +37,6 @@
37
37
  "@hono/node-server": "^1.8.2",
38
38
  "archiver": "^7.0.1",
39
39
  "axios": "^1.6.7",
40
- "better-sqlite3": "^11.1.2",
41
40
  "chokidar": "^3.6.0",
42
41
  "commander": "^12.0.0",
43
42
  "configstore": "^6.0.0",
@@ -53,7 +52,6 @@
53
52
  "ignore": "^5.3.1",
54
53
  "json5": "^2.2.3",
55
54
  "kleur": "^4.1.5",
56
- "kysely-bun-sqlite": "^0.3.2",
57
55
  "lodash": "^4.17.21",
58
56
  "mime-types": "^2.1.35",
59
57
  "minimist": "^1.2.8",
@@ -79,7 +77,7 @@
79
77
  "@tscircuit/builder": "*",
80
78
  "@tscircuit/layout": "^0.0.24",
81
79
  "@tscircuit/react-fiber": "*",
82
- "@tscircuit/soup-util": "^0.0.1",
80
+ "@tscircuit/soup-util": "^0.0.11",
83
81
  "@tscircuit/manual-edit-events": "^0.0.4",
84
82
  "@types/archiver": "^6.0.2",
85
83
  "@types/bun": "^1.0.8",
@@ -2,8 +2,7 @@ import { test, expect } from "bun:test"
2
2
  import { $ } from "bun"
3
3
 
4
4
  test("tsci open", async () => {
5
- const result =
6
- await $`bun cli.ts open -y --cwd ./tests/assets/example-project`.text()
5
+ const result = await $`bun cli.ts open -y --cwd ./example-project`.text()
7
6
  expect(result).toContain("http")
8
7
  expect(result).toContain("example-project")
9
8
  })
@@ -3,7 +3,7 @@ import { $ } from "bun"
3
3
 
4
4
  test("soupify", async () => {
5
5
  const result =
6
- await $`bun cli.ts soupify -y --file ./tests/assets/example-project/examples/basic-bug.tsx`.text()
6
+ await $`bun cli.ts soupify -y --file ./example-project/examples/basic-bug.tsx`.text()
7
7
 
8
8
  expect(result).toContain("10kohm")
9
9
  })
@@ -1,8 +0,0 @@
1
- import { z } from "zod"
2
-
3
- export const export_file = z.object({
4
- export_file_id: z.number().int(),
5
- export_request_id: z.number().int(),
6
- file_name: z.string(),
7
- created_at: z.string(),
8
- })
@@ -1,5 +0,0 @@
1
- import { z } from "zod"
2
-
3
- export const export_package_info = z.object({
4
- name: z.string()
5
- })
@@ -1,21 +0,0 @@
1
- import { z } from "zod"
2
- import { export_parameters } from "./export_parameters"
3
-
4
- export const export_request = z.object({
5
- export_request_id: z.coerce.number(),
6
- is_complete: z.boolean(),
7
- created_at: z.string(),
8
- export_name: z.string(),
9
- example_file_path: z.string(),
10
- export_parameters,
11
- file_summary: z
12
- .array(
13
- z.object({
14
- file_name: z.string(),
15
- export_file_id: z.number().int(),
16
- })
17
- )
18
- .optional(),
19
- })
20
-
21
- export type ExportRequest = z.infer<typeof export_request>