@tscircuit/cli 0.0.135 → 0.0.137

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.
@@ -1,6 +1,6 @@
1
1
  # seveibar/example-project-3
2
2
 
3
- To develop and view the examples, run `tsci dev` and open [http://localhost:3020](http://localhost:3020) in your browser.
3
+ To develop and view the examples, run `tsci dev` and open [http://127.0.0.1:3020](http://127.0.0.1:3020) in your browser.
4
4
 
5
5
  ## Developing
6
6
 
@@ -1,7 +1,8 @@
1
+ import crypto from "crypto"
1
2
  import $ from "dax-sh"
2
3
  import fs from "fs"
3
- import { unlink } from "fs/promises"
4
4
  import kleur from "kleur"
5
+ import posthog from "lib/posthog"
5
6
  import open from "open"
6
7
  import * as Path from "path"
7
8
  import prompts from "prompts"
@@ -10,15 +11,13 @@ import { AppContext } from "../../util/app-context"
10
11
  import { initCmd } from "../init"
11
12
  import { createOrModifyNpmrc } from "../init/create-or-modify-npmrc"
12
13
  import { checkIfInitialized } from "./check-if-initialized"
14
+ import { findAvailablePort } from "./find-available-port"
13
15
  import { getDevServerAxios } from "./get-dev-server-axios"
14
16
  import { startDevServer } from "./start-dev-server"
15
17
  import { startEditEventWatcher } from "./start-edit-event-watcher"
16
18
  import { startExportRequestWatcher } from "./start-export-request-watcher"
17
19
  import { startFsWatcher } from "./start-fs-watcher"
18
20
  import { uploadExamplesFromDirectory } from "./upload-examples-from-directory"
19
- import posthog from "lib/posthog"
20
- import crypto from 'crypto'
21
- import { findAvailablePort } from "./find-available-port"
22
21
 
23
22
  export const devCmd = async (ctx: AppContext, args: any) => {
24
23
  const params = z
@@ -33,14 +32,14 @@ export const devCmd = async (ctx: AppContext, args: any) => {
33
32
  // Find an available port
34
33
  port = await findAvailablePort(port)
35
34
 
36
- const projectHash = crypto.createHash('md5').update(cwd).digest('hex')
35
+ const projectHash = crypto.createHash("md5").update(cwd).digest("hex")
37
36
 
38
37
  posthog.capture({
39
38
  distinctId: projectHash,
40
- event: 'tsci_dev_started',
39
+ event: "tsci_dev_started",
41
40
  properties: {
42
41
  port: port,
43
- }
42
+ },
44
43
  })
45
44
 
46
45
  // In the future we should automatically run "tsci init" if the directory
@@ -78,10 +77,10 @@ export const devCmd = async (ctx: AppContext, args: any) => {
78
77
 
79
78
  console.log(
80
79
  kleur.green(
81
- `\n--------------------------------------------\n\nStarting dev server http://localhost:${port}\n\n--------------------------------------------\n\n`
80
+ `\n--------------------------------------------\n\nStarting dev server http://127.0.0.1:${port}\n\n--------------------------------------------\n\n`
82
81
  )
83
82
  )
84
- const serverUrl = `http://localhost:${port}`
83
+ const serverUrl = `http://127.0.0.1:${port}`
85
84
  const devServerAxios = getDevServerAxios({ serverUrl })
86
85
 
87
86
  const server = await startDevServer({ port, devServerAxios })
@@ -138,13 +137,13 @@ export const devCmd = async (ctx: AppContext, args: any) => {
138
137
  open(serverUrl)
139
138
  posthog.capture({
140
139
  distinctId: projectHash,
141
- event: 'tsci_dev_open_browser'
140
+ event: "tsci_dev_open_browser",
142
141
  })
143
142
  } else if (action === "open-in-vs-code") {
144
143
  await $`code ${cwd}`
145
144
  posthog.capture({
146
145
  distinctId: projectHash,
147
- event: 'tsci_dev_open_vscode'
146
+ event: "tsci_dev_open_vscode",
148
147
  })
149
148
  } else if (!action || action === "stop") {
150
149
  if (server.stop) server.stop()
@@ -152,16 +151,16 @@ export const devCmd = async (ctx: AppContext, args: any) => {
152
151
  fs_watcher.stop()
153
152
  er_watcher.stop()
154
153
  ee_watcher.stop()
155
-
154
+
156
155
  posthog.capture({
157
156
  distinctId: projectHash,
158
- event: 'tsci_dev_stopped'
157
+ event: "tsci_dev_stopped",
159
158
  })
160
-
159
+
161
160
  if (posthog.shutdown) {
162
161
  await posthog.shutdown()
163
162
  }
164
-
163
+
165
164
  break
166
165
  }
167
166
  }
@@ -1,8 +1,8 @@
1
- import { AppContext } from "../util/app-context"
2
- import { z } from "zod"
3
- import { getDevServerAxios } from "./dev/get-dev-server-axios"
4
1
  import kleur from "kleur"
2
+ import { z } from "zod"
3
+ import { AppContext } from "../util/app-context"
5
4
  import { fulfillExportRequests } from "./dev/fulfill-export-requests"
5
+ import { getDevServerAxios } from "./dev/get-dev-server-axios"
6
6
 
7
7
  export const devServerFulfillExportRequests = async (
8
8
  ctx: AppContext,
@@ -10,7 +10,7 @@ export const devServerFulfillExportRequests = async (
10
10
  ) => {
11
11
  const params = z.object({}).parse(args)
12
12
 
13
- let server_url = `http://localhost:3020`
13
+ let server_url = `http://127.0.0.1:3020`
14
14
  let dev_server_axios = getDevServerAxios({ serverUrl: server_url })
15
15
 
16
16
  const checkHealth = () =>
@@ -24,7 +24,7 @@ export const devServerFulfillExportRequests = async (
24
24
  if (!is_dev_server_healthy) {
25
25
  // attempt to use development-mode port, e.g. if someone ran
26
26
  // npm run start:dev-server:dev
27
- const devModeServerUrl = "http://localhost:3021"
27
+ const devModeServerUrl = "http://127.0.0.1:3021"
28
28
  dev_server_axios = getDevServerAxios({ serverUrl: devModeServerUrl })
29
29
  is_dev_server_healthy = await checkHealth()
30
30
  if (is_dev_server_healthy) server_url = devModeServerUrl
@@ -1,10 +1,9 @@
1
- import { AppContext } from "../util/app-context"
1
+ import kleur from "kleur"
2
2
  import { z } from "zod"
3
+ import { AppContext } from "../util/app-context"
3
4
  import { getDevServerAxios } from "./dev/get-dev-server-axios"
4
- import { uploadExamplesFromDirectory } from "./dev/upload-examples-from-directory"
5
5
  import { startFsWatcher } from "./dev/start-fs-watcher"
6
- import kleur from "kleur"
7
- import { AxiosInstance } from "axios"
6
+ import { uploadExamplesFromDirectory } from "./dev/upload-examples-from-directory"
8
7
 
9
8
  export const devServerUpload = async (ctx: AppContext, args: any) => {
10
9
  const params = z
@@ -15,7 +14,7 @@ export const devServerUpload = async (ctx: AppContext, args: any) => {
15
14
  })
16
15
  .parse(args)
17
16
 
18
- let serverUrl = `http://localhost:${params.port ?? 3020}`
17
+ let serverUrl = `http://127.0.0.1:${params.port ?? 3020}`
19
18
  let devServerAxios = getDevServerAxios({ serverUrl })
20
19
 
21
20
  const checkHealth = () =>
@@ -29,7 +28,7 @@ export const devServerUpload = async (ctx: AppContext, args: any) => {
29
28
  if (!is_dev_server_healthy && !params.port) {
30
29
  // attempt to use development-mode port, e.g. if someone ran
31
30
  // npm run start:dev-server:dev
32
- const devModeServerUrl = "http://localhost:3021"
31
+ const devModeServerUrl = "http://127.0.0.1:3021"
33
32
  devServerAxios = getDevServerAxios({ serverUrl: devModeServerUrl })
34
33
  is_dev_server_healthy = await checkHealth()
35
34
  if (is_dev_server_healthy) serverUrl = devModeServerUrl
@@ -19,7 +19,7 @@ ${
19
19
  ? `\n\n> This project was generated using [tsci](https://github.com/tscircuit/tscircuit)\n`
20
20
  : ""
21
21
  }
22
- To develop and view the examples, run \`tsci dev\` and open [http://localhost:3020](http://localhost:3020) in your browser.
22
+ To develop and view the examples, run \`tsci dev\` and open [http://127.0.0.1:3020](http://127.0.0.1:3020) in your browser.
23
23
 
24
24
  ## Developing
25
25
 
@@ -1,4 +1,3 @@
1
- import { interactForPackageReleaseId } from "./interact-for-package-release-id"
2
1
  import { ParamHandler } from "./param-handler-type"
3
2
 
4
3
  export const interactForRegistryUrl: ParamHandler = async (params) => {
@@ -10,7 +9,7 @@ export const interactForRegistryUrl: ParamHandler = async (params) => {
10
9
  message: "Select a package example",
11
10
  choices: [
12
11
  "https://registry-api.tscircuit.com",
13
- "http://localhost:3100",
12
+ "http://127.0.0.1:3100",
14
13
  "other",
15
14
  ].map((a) => ({ title: a, value: a })),
16
15
  })
@@ -81,6 +81,11 @@ export const createContextAndRunProgram = async (process_args: any) => {
81
81
  }
82
82
  // end ignores ---
83
83
 
84
+ if (err.response?.status === 401) {
85
+ console.log(kleur.red("Authentication failed. Please run 'tsci login' to authenticate yourself."))
86
+ process.exit(1)
87
+ }
88
+
84
89
  console.log(
85
90
  kleur.red(
86
91
  `[ERR] ${err.response?.status} ${err.config.method?.toUpperCase()} ${
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tscircuit/cli",
3
- "version": "0.0.135",
3
+ "version": "0.0.137",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Command line tool for developing, publishing and installing tscircuit circuits",