@tscircuit/cli 0.0.4 → 0.0.6

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 (36) hide show
  1. package/README.md +31 -22
  2. package/bun.lockb +0 -0
  3. package/dev-server-frontend/bun.lockb +0 -0
  4. package/lib/cmd-fns/add.ts +34 -0
  5. package/lib/cmd-fns/config-reveal-location.ts +1 -1
  6. package/lib/cmd-fns/dev/check-if-initialized.ts +22 -0
  7. package/lib/cmd-fns/dev/dev-server-request-handler.ts +54 -0
  8. package/lib/cmd-fns/dev/get-dev-server-axios.ts +25 -0
  9. package/lib/cmd-fns/dev/index.ts +33 -156
  10. package/lib/cmd-fns/dev/infer-export-name-from-source.ts +17 -0
  11. package/lib/cmd-fns/dev/soupify-and-upload-example-file.ts +38 -0
  12. package/lib/cmd-fns/dev/start-dev-server.ts +34 -0
  13. package/lib/cmd-fns/dev/start-watcher.ts +48 -0
  14. package/lib/cmd-fns/dev/upload-examples-from-directory.ts +26 -0
  15. package/lib/cmd-fns/dev-server-upload.ts +26 -0
  16. package/lib/cmd-fns/index.ts +5 -0
  17. package/lib/cmd-fns/init/create-or-modify-npmrc.ts +21 -0
  18. package/lib/cmd-fns/init/get-generated-npmrc.ts +8 -0
  19. package/lib/cmd-fns/init/get-generated-readme.ts +34 -0
  20. package/lib/cmd-fns/init/get-generated-tsconfig.ts +34 -0
  21. package/lib/cmd-fns/{init.ts → init/index.ts} +19 -64
  22. package/lib/cmd-fns/install.ts +34 -0
  23. package/lib/cmd-fns/publish/index.ts +296 -0
  24. package/lib/cmd-fns/remove.ts +31 -0
  25. package/lib/cmd-fns/uninstall.ts +31 -0
  26. package/lib/get-program.ts +48 -7
  27. package/lib/util/create-context-and-run-program.ts +1 -1
  28. package/lib/util/get-all-package-files.ts +35 -0
  29. package/package.json +13 -6
  30. package/tests/assets/example-project/README.md +18 -0
  31. package/tests/assets/example-project/index.ts +1 -0
  32. package/tests/assets/example-project/package.json +2 -1
  33. package/tests/assets/example-project/src/MyCircuit.tsx +1 -1
  34. package/tests/init.test.ts +1 -1
  35. package/dist/cli.js +0 -1465
  36. package/lib/cmd-fns/publish.ts +0 -3
@@ -21,7 +21,7 @@ import * as CMDFN from "lib/cmd-fns"
21
21
  // | /package_examples/create | Create a new package example |
22
22
 
23
23
  export const getProgram = (ctx: AppContext) => {
24
- const cmd = new Command("tsck")
24
+ const cmd = new Command("tsci")
25
25
 
26
26
  cmd.version(packageJson.version)
27
27
 
@@ -139,7 +139,7 @@ export const getProgram = (ctx: AppContext) => {
139
139
 
140
140
  packageFiles
141
141
  .command("upload-directory")
142
- .requiredOption("--directory <directory>", "Directory to upload")
142
+ .requiredOption("--dir <dir>", "Directory to upload")
143
143
  .action((args) => CMDFN.packageFilesUploadDirectory(ctx, args))
144
144
 
145
145
  const packageExamples = cmd.command("package_examples")
@@ -159,11 +159,16 @@ export const getProgram = (ctx: AppContext) => {
159
159
  .option("--export <export>", "Name of export to soupify")
160
160
  .action((args) => CMDFN.packageExamplesCreate(ctx, args))
161
161
 
162
- cmd.command("publish").action((args) => CMDFN.publish(ctx, args))
162
+ cmd
163
+ .command("publish")
164
+ .option("--increment", "Increase patch version")
165
+ .option("--patch", "Increase patch version")
166
+ .option("--lock", "Lock the release after publishing to prevent changes")
167
+ .action((args) => CMDFN.publish(ctx, args))
163
168
 
164
169
  cmd
165
170
  .command("version")
166
- .action(() => console.log(`tsck v${packageJson.version}`))
171
+ .action(() => console.log(`tsci v${packageJson.version}`))
167
172
 
168
173
  cmd.command("login").action((args) => CMDFN.authLogin(ctx, args))
169
174
  cmd.command("logout").action((args) => CMDFN.authLogout(ctx, args))
@@ -196,9 +201,45 @@ export const getProgram = (ctx: AppContext) => {
196
201
  )
197
202
  .action((args) => CMDFN.init(ctx, args))
198
203
 
199
- cmd.command("add").action((args) => {})
200
- cmd.command("remove").action((args) => {})
201
- cmd.command("install").action((args) => {})
204
+ cmd
205
+ .command("add")
206
+ .argument(
207
+ "<packages...>",
208
+ "Packages to install from registry.tscircuit.com, optionally with version"
209
+ )
210
+ .option("-D, --dev", "Add to devDependencies")
211
+ .action((packages, flags) => CMDFN.add(ctx, { packages, flags }))
212
+
213
+ cmd
214
+ .command("remove")
215
+ .argument("<packages...>", "Packages to remove")
216
+ .action((packages, flags) => CMDFN.remove(ctx, { packages, flags }))
217
+
218
+ cmd
219
+ .command("install")
220
+ .argument(
221
+ "<packages...>",
222
+ "Packages to install from registry.tscircuit.com, optionally with version"
223
+ )
224
+ .option("-D, --dev", "Add to devDependencies")
225
+ .action((packages, flags) => CMDFN.install(ctx, { packages, flags }))
226
+
227
+ cmd
228
+ .command("uninstall")
229
+ .argument("<packages...>", "Packages to uninstall")
230
+ .action((packages, flags) => CMDFN.install(ctx, { packages, flags }))
231
+
232
+ const devServerCmd = cmd.command("dev-server")
233
+
234
+ devServerCmd
235
+ .command("upload")
236
+ .option(
237
+ "--dir <dir>",
238
+ "Directory to upload (defaults to current directory)"
239
+ )
240
+ .option("-w, --watch", "Watch for changes")
241
+ .option("-p, --port", "Port dev server is running on (default: 3020)")
242
+ .action((args) => CMDFN.devServerUpload(ctx, args))
202
243
 
203
244
  return cmd
204
245
  }
@@ -18,7 +18,7 @@ export type CliArgs = {
18
18
  export const createContextAndRunProgram = async (process_args: any) => {
19
19
  const args = minimist(process_args)
20
20
 
21
- const global_config = new Configstore("tsck")
21
+ const global_config = new Configstore("tsci")
22
22
  const current_profile =
23
23
  args.profile ?? global_config.get("current_profile") ?? "default"
24
24
  const profile_config: typeof global_config = {
@@ -0,0 +1,35 @@
1
+ import * as fs from "fs/promises"
2
+ import { AppContext } from "./app-context"
3
+ import * as Glob from "glob"
4
+ import ignore from "ignore"
5
+
6
+ /**
7
+ * Get all package files
8
+ *
9
+ * Package files are any files that aren't explicitly ignored in the
10
+ * .npmignore (or if that doesn't exist, the .gitignore). All package
11
+ * files must have a .ts or .tsx extension.
12
+ *
13
+ * Returns an array of files paths.
14
+ */
15
+ export const getAllPackageFiles = async (
16
+ ctx: AppContext
17
+ ): Promise<Array<string>> => {
18
+ const gitignore = await fs
19
+ .readFile("./.gitignore")
20
+ .then((b) => b.toString().split("\n").filter(Boolean))
21
+ .catch((e) => null)
22
+
23
+ const npmignore = await fs
24
+ .readFile("./.promptignore")
25
+ .then((b) => b.toString().split("\n").filter(Boolean))
26
+ .catch((e) => null)
27
+
28
+ const ig = ignore().add([
29
+ ...(npmignore ?? gitignore ?? []),
30
+ ".tscircuit",
31
+ "node_modules/*",
32
+ ])
33
+
34
+ return Glob.globSync("**/*.{ts,tsx,md}", {}).filter((fp) => !ig.ignores(fp))
35
+ }
package/package.json CHANGED
@@ -1,22 +1,23 @@
1
1
  {
2
2
  "name": "@tscircuit/cli",
3
- "version": "0.0.4",
3
+ "version": "0.0.6",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Command line tool for developing, publishing and installing tscircuit circuits",
7
7
  "main": "./dist/cli.js",
8
8
  "scripts": {
9
+ "bootstrap": "bun i && cd dev-server-api && bun i && cd ../dev-server-frontend && bun i",
9
10
  "start": "bun cli.ts",
10
11
  "start:dev-server:dev": "TSCI_DEV_SERVER_DB=$(pwd)/.tscircuit/dev-server.db concurrently 'cd dev-server-api && bun start' 'cd dev-server-frontend && bun start'",
11
12
  "start:dev-server": "bun build:dev-server && bun cli.ts dev -y --cwd ./tests/assets/example-project",
12
13
  "build:dev-server": "cd dev-server-api && bun run build && cd ../dev-server-frontend && bun run build",
13
14
  "build:cli": "bun build-cli.ts",
14
- "build": "bun build:dev-server && npm run build:cli"
15
+ "build": "bun build:dev-server && npm run build:cli",
16
+ "test:init": "bun cli.ts init --dir ./tmp/test --name test"
15
17
  },
16
18
  "bin": {
17
19
  "tscircuit": "./dist/cli.js",
18
- "tsci": "./dist/cli.js",
19
- "tsck": "./dist/cli.js"
20
+ "tsci": "./dist/cli.js"
20
21
  },
21
22
  "keywords": [],
22
23
  "author": "",
@@ -28,12 +29,15 @@
28
29
  "@tscircuit/react-fiber": "^1.0.6",
29
30
  "axios": "^1.6.7",
30
31
  "better-sqlite3": "^9.4.3",
32
+ "chokidar": "^3.6.0",
31
33
  "commander": "^12.0.0",
32
34
  "configstore": "^6.0.0",
33
35
  "dax-sh": "^0.39.2",
34
36
  "delay": "^6.0.0",
35
37
  "edgespec": "^0.0.69",
38
+ "glob": "^10.3.10",
36
39
  "hono": "^4.1.0",
40
+ "ignore": "^5.3.1",
37
41
  "kleur": "^4.1.5",
38
42
  "kysely-bun-sqlite": "^0.3.2",
39
43
  "lodash": "^4.17.21",
@@ -41,13 +45,15 @@
41
45
  "minimist": "^1.2.8",
42
46
  "node-persist": "^4.0.1",
43
47
  "open": "^10.1.0",
44
- "perfect-cli": "1.0.13",
48
+ "perfect-cli": "^1.0.16",
45
49
  "prompts": "^2.4.2",
46
50
  "react": "^18.2.0",
51
+ "semver": "^7.6.0",
47
52
  "zod": "latest"
48
53
  },
49
54
  "devDependencies": {
50
55
  "@types/bun": "^1.0.8",
56
+ "@types/chokidar": "^2.1.3",
51
57
  "@types/configstore": "^6.0.2",
52
58
  "@types/lodash": "^4.14.202",
53
59
  "@types/mime-types": "^2.1.4",
@@ -55,9 +61,10 @@
55
61
  "@types/node": "^20.10.6",
56
62
  "@types/prompts": "^2.4.9",
57
63
  "@types/react": "^18.2.64",
64
+ "@types/semver": "^7.5.8",
58
65
  "ava": "^6.1.1",
59
66
  "concurrently": "^8.2.2",
60
67
  "tsx": "^4.7.1",
61
68
  "typescript": "^5.3.3"
62
69
  }
63
- }
70
+ }
@@ -0,0 +1,18 @@
1
+ # seveibar/example-project-3
2
+
3
+ To develop and view the examples, run `tsci dev` and open [http://localhost:3020](http://localhost:3020) in your browser.
4
+
5
+ ## Developing
6
+
7
+ You should install an editor like [VS Code](https://code.visualstudio.com/) with a typescript extension. Many web developers already have this.
8
+
9
+ Usually, you'll want to develop some named circuits inside of the `lib` directory,
10
+ export them in the `index.ts` file, then show how to use them in the `examples` directory.
11
+
12
+ Any file in `examples` will be automatically loaded and appear in the browser preview when you run `tsci dev`. It auto-reloads when you make changes, no need to reload the page or re-run the command.
13
+
14
+ > [!TIP] Make sure to replace this README with some details about your project and how to use it.
15
+
16
+ ## Publishing
17
+
18
+ After you're satisfied with your project, publish it on the [tscircuit registry](https://registry.tscircuit.com) with `tsci publish`
@@ -0,0 +1 @@
1
+ export * from "./src/MyCircuit"
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "example-project",
3
- "version": "1.2.3",
3
+ "version": "1.2.26",
4
+ "main": "dist/index.js",
4
5
  "dependencies": {
5
6
  "@tscircuit/builder": "^1.5.4",
6
7
  "@tscircuit/react-fiber": "^1.0.6"
@@ -1,5 +1,5 @@
1
1
  import "@tscircuit/react-fiber"
2
2
 
3
3
  export const MyCircuit = () => (
4
- <resistor name="R1" resistance="10kohm" footprint="0805" />
4
+ <resistor name="R2" resistance="20kohm" footprint="0805" />
5
5
  )
@@ -1,7 +1,7 @@
1
1
  import { test, expect, describe } from "bun:test"
2
2
  import { $ } from "bun"
3
3
 
4
- test.skip("tsck init", async () => {
4
+ test.skip("tsci init", async () => {
5
5
  await $`rm -rf ./tests/example-init`
6
6
  console.log(
7
7
  await $`bun cli.ts init --name init-test --dir ./tests/example-init`.text()