@tscircuit/cli 0.0.112 → 0.0.114

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.
@@ -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
- ? "preview"
12
- : "other"
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
@@ -1,20 +1,21 @@
1
- import { AppContext } from "../../util/app-context"
2
- import { z } from "zod"
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 { startFsWatcher } from "./start-fs-watcher"
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 { initCmd } from "../init"
15
- import { startExportRequestWatcher } from "./start-export-request-watcher"
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.112",
3
+ "version": "0.0.114",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Command line tool for developing, publishing and installing tscircuit circuits",
@@ -65,6 +65,7 @@
65
65
  "semver": "^7.6.0",
66
66
  "ts-morph": "^22.0.0",
67
67
  "tsup": "^8.0.2",
68
+ "winterspec": "^0.0.80",
68
69
  "zod": "latest"
69
70
  },
70
71
  "peerDependencies": {