@tscircuit/cli 0.0.113 → 0.0.115
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/test.yml +28 -0
- package/bun.lockb +0 -0
- package/dev-server-api/bun.lockb +0 -0
- package/dev-server-api/index.ts +3 -5
- package/dev-server-api/package.json +4 -3
- package/dev-server-api/routes/api/package_info/create.ts +28 -0
- package/dev-server-api/routes/api/package_info/get.ts +18 -0
- package/dev-server-api/src/db/create-schema.ts +5 -0
- package/dev-server-api/src/db/get-db.ts +15 -7
- package/dev-server-api/src/lib/zod/export_package_info.ts +5 -0
- package/dev-server-api/static-routes.ts +22 -0
- package/dev-server-frontend/bun.lockb +0 -0
- package/dev-server-frontend/package-lock.json +3891 -347
- package/dev-server-frontend/package.json +2 -1
- package/dev-server-frontend/src/ExampleContentView.tsx +8 -8
- package/dev-server-frontend/src/HeaderMenu.tsx +26 -7
- package/dist/cli.js +1370 -651
- package/lib/cmd-fns/dev/dev-server-request-handler.ts +9 -2
- package/lib/cmd-fns/dev/index.ts +26 -12
- package/package.json +2 -2
- package/tests/soupify.test.ts +1 -1
|
@@ -3,13 +3,20 @@ import frontendVfs from "../../../dev-server-frontend/dist/bundle"
|
|
|
3
3
|
import EdgeRuntimePrimitives from "@edge-runtime/primitives"
|
|
4
4
|
import mime from "mime-types"
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* Handles all requests to :3020, then proxies...
|
|
8
|
+
*
|
|
9
|
+
* /api/* : to the api server
|
|
10
|
+
* /* : to the static frontend bundle inside dev-server-frontend
|
|
11
|
+
*
|
|
12
|
+
*/
|
|
6
13
|
export const devServerRequestHandler = async (bunReq: Request) => {
|
|
7
14
|
const url = new URL(bunReq.url)
|
|
8
15
|
const requestType = url.pathname.startsWith("/api")
|
|
9
16
|
? "api"
|
|
10
17
|
: url.pathname.startsWith("/preview")
|
|
11
|
-
|
|
12
|
-
|
|
18
|
+
? "preview"
|
|
19
|
+
: "other"
|
|
13
20
|
|
|
14
21
|
if (requestType === "api") {
|
|
15
22
|
// We have to shim Bun's Request until they fix the issue where
|
package/lib/cmd-fns/dev/index.ts
CHANGED
|
@@ -1,20 +1,21 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import $ from "dax-sh"
|
|
2
|
+
import fs from 'fs'
|
|
3
|
+
import { unlink } from "fs/promises"
|
|
3
4
|
import kleur from "kleur"
|
|
4
|
-
import prompts from "prompts"
|
|
5
5
|
import open from "open"
|
|
6
|
-
import { startDevServer } from "./start-dev-server"
|
|
7
|
-
import { getDevServerAxios } from "./get-dev-server-axios"
|
|
8
|
-
import { uploadExamplesFromDirectory } from "./upload-examples-from-directory"
|
|
9
|
-
import { unlink } from "fs/promises"
|
|
10
6
|
import * as Path from "path"
|
|
11
|
-
import
|
|
7
|
+
import prompts from "prompts"
|
|
8
|
+
import { z } from "zod"
|
|
9
|
+
import { AppContext } from "../../util/app-context"
|
|
10
|
+
import { initCmd } from "../init"
|
|
12
11
|
import { createOrModifyNpmrc } from "../init/create-or-modify-npmrc"
|
|
13
12
|
import { checkIfInitialized } from "./check-if-initialized"
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import $ from "dax-sh"
|
|
13
|
+
import { getDevServerAxios } from "./get-dev-server-axios"
|
|
14
|
+
import { startDevServer } from "./start-dev-server"
|
|
17
15
|
import { startEditEventWatcher } from "./start-edit-event-watcher"
|
|
16
|
+
import { startExportRequestWatcher } from "./start-export-request-watcher"
|
|
17
|
+
import { startFsWatcher } from "./start-fs-watcher"
|
|
18
|
+
import { uploadExamplesFromDirectory } from "./upload-examples-from-directory"
|
|
18
19
|
|
|
19
20
|
export const devCmd = async (ctx: AppContext, args: any) => {
|
|
20
21
|
const params = z
|
|
@@ -57,7 +58,7 @@ export const devCmd = async (ctx: AppContext, args: any) => {
|
|
|
57
58
|
// TODO
|
|
58
59
|
|
|
59
60
|
// Delete old .tscircuit/dev-server.sqlite
|
|
60
|
-
unlink(Path.join(cwd, ".tscircuit/dev-server.sqlite")).catch(() => {})
|
|
61
|
+
unlink(Path.join(cwd, ".tscircuit/dev-server.sqlite")).catch(() => { })
|
|
61
62
|
|
|
62
63
|
console.log(
|
|
63
64
|
kleur.green(
|
|
@@ -71,6 +72,19 @@ export const devCmd = async (ctx: AppContext, args: any) => {
|
|
|
71
72
|
|
|
72
73
|
// Reset the database, allows migration to re-run
|
|
73
74
|
await devServerAxios.post("/api/dev_server/reset")
|
|
75
|
+
.catch(e => {
|
|
76
|
+
console.log("Failed to reset database, continuing anyway...")
|
|
77
|
+
})
|
|
78
|
+
|
|
79
|
+
// 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'))
|
|
82
|
+
const packageName = packageJson.name
|
|
83
|
+
|
|
84
|
+
console.log(`Adding package info...`)
|
|
85
|
+
await devServerAxios.post("/api/package_info/create", {
|
|
86
|
+
package_name: packageName
|
|
87
|
+
}, ctx)
|
|
74
88
|
|
|
75
89
|
// Soupify all examples
|
|
76
90
|
console.log(`Loading examples...`)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tscircuit/cli",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.115",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "Command line tool for developing, publishing and installing tscircuit circuits",
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"semver": "^7.6.0",
|
|
66
66
|
"ts-morph": "^22.0.0",
|
|
67
67
|
"tsup": "^8.0.2",
|
|
68
|
-
"winterspec": "
|
|
68
|
+
"winterspec": "0.0.81",
|
|
69
69
|
"zod": "latest"
|
|
70
70
|
},
|
|
71
71
|
"peerDependencies": {
|
package/tests/soupify.test.ts
CHANGED
|
@@ -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/
|
|
6
|
+
await $`bun cli.ts soupify -y --file ./tests/assets/example-project/examples/basic-bug.tsx`.text()
|
|
7
7
|
|
|
8
8
|
expect(result).toContain("10kohm")
|
|
9
9
|
})
|