@gjsify/cli 0.40.0 → 0.42.0

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 (72) hide show
  1. package/README.md +79 -33
  2. package/dist/cli.gjs.mjs +1043 -404
  3. package/lib/actions/build.d.ts +14 -0
  4. package/lib/actions/build.js +54 -7
  5. package/lib/bundler-pick.js +10 -2
  6. package/lib/cli-app.js +3 -1
  7. package/lib/commands/browse.js +1 -1
  8. package/lib/commands/create.d.ts +3 -0
  9. package/lib/commands/create.js +49 -6
  10. package/lib/commands/debug.js +1 -1
  11. package/lib/commands/dev.d.ts +13 -0
  12. package/lib/commands/dev.js +132 -0
  13. package/lib/commands/dlx.js +1 -1
  14. package/lib/commands/index.d.ts +2 -0
  15. package/lib/commands/index.js +2 -0
  16. package/lib/commands/install.d.ts +1 -0
  17. package/lib/commands/install.js +32 -1
  18. package/lib/commands/prune.d.ts +11 -0
  19. package/lib/commands/prune.js +84 -0
  20. package/lib/commands/run.js +38 -85
  21. package/lib/commands/self-update.d.ts +1 -0
  22. package/lib/commands/self-update.js +55 -0
  23. package/lib/commands/ship.js +6 -1
  24. package/lib/commands/showcase.js +1 -1
  25. package/lib/commands/storybook.js +17 -74
  26. package/lib/commands/test.js +12 -16
  27. package/lib/commands/tsc.js +96 -45
  28. package/lib/config.js +4 -0
  29. package/lib/templates/install.mjs.tmpl +8 -3
  30. package/lib/types/config-data.d.ts +27 -0
  31. package/lib/utils/app-metadata.js +27 -6
  32. package/lib/utils/check-system-deps.d.ts +2 -2
  33. package/lib/utils/check-system-deps.js +92 -13
  34. package/lib/utils/daemon-command.d.ts +7 -0
  35. package/lib/utils/daemon-command.js +30 -0
  36. package/lib/utils/dev-plan.d.ts +52 -0
  37. package/lib/utils/dev-plan.js +117 -0
  38. package/lib/utils/gi-runtime-paths.d.ts +27 -0
  39. package/lib/utils/gi-runtime-paths.js +84 -0
  40. package/lib/utils/gi-typelib.d.ts +49 -0
  41. package/lib/utils/gi-typelib.js +160 -0
  42. package/lib/utils/install-provenance.d.ts +44 -0
  43. package/lib/utils/install-provenance.js +106 -0
  44. package/lib/utils/node-script.d.ts +4 -1
  45. package/lib/utils/node-script.js +27 -3
  46. package/lib/utils/npm-oidc.js +8 -5
  47. package/lib/utils/prune-prefix.d.ts +83 -0
  48. package/lib/utils/prune-prefix.js +333 -0
  49. package/lib/utils/run-gjs.d.ts +12 -1
  50. package/lib/utils/run-gjs.js +24 -31
  51. package/lib/utils/run-node.d.ts +9 -4
  52. package/lib/utils/run-node.js +34 -41
  53. package/lib/utils/ship/depends.d.ts +5 -0
  54. package/lib/utils/ship/depends.js +38 -0
  55. package/lib/utils/ship/discover.js +106 -1
  56. package/lib/utils/ship/launcher.js +27 -4
  57. package/lib/utils/ship/payload.d.ts +35 -0
  58. package/lib/utils/ship/payload.js +84 -0
  59. package/lib/utils/ship/plan.js +20 -0
  60. package/lib/utils/ship/settings.d.ts +8 -1
  61. package/lib/utils/ship/settings.js +13 -1
  62. package/lib/utils/ship/types.d.ts +19 -0
  63. package/lib/utils/simple-command.d.ts +16 -0
  64. package/lib/utils/simple-command.js +77 -0
  65. package/lib/utils/spawn.d.ts +7 -1
  66. package/lib/utils/spawn.js +34 -7
  67. package/lib/utils/system-gi.d.ts +24 -0
  68. package/lib/utils/system-gi.js +14 -3
  69. package/lib/utils/watch-loop.d.ts +91 -0
  70. package/lib/utils/watch-loop.js +207 -0
  71. package/package.json +27 -18
  72. package/lib/templates/app/desktop.tmpl +0 -10
package/README.md CHANGED
@@ -1,58 +1,104 @@
1
1
  # @gjsify/cli
2
2
 
3
- CLI tool for building and running GJS applications. Bundles TypeScript/JavaScript using esbuild with automatic Node.js to GJS module aliasing.
3
+ CLI tool for building and running GJS applications. Bundles TypeScript/JavaScript with
4
+ [Rolldown](https://rolldown.rs/), resolving each `node:*` import onto gjsify's
5
+ GNOME-backed implementation for a GJS target and onto the runtime's own for a Node,
6
+ Bun or Deno one — from unchanged source.
4
7
 
5
8
  Part of the [gjsify](https://github.com/gjsify/gjsify) project — Node.js and Web APIs for GJS (GNOME JavaScript).
6
9
 
7
10
  ## Installation
8
11
 
12
+ The CLI runs on GJS, Node.js, Bun and Deno, and it installs on all four. On a GNOME box
13
+ `gjs` ≥ 1.86 and `curl` are enough — no Node.js at install time or ever after:
14
+
15
+ ```bash
16
+ curl -fsSL https://github.com/gjsify/gjsify/releases/latest/download/install.mjs \
17
+ -o /tmp/g.mjs && gjs -m /tmp/g.mjs && rm /tmp/g.mjs
18
+ ```
19
+
20
+ That lays the CLI down under `~/.local/share/gjsify/global/` with a launcher at
21
+ `~/.local/bin/gjsify`; `gjsify self-update` refreshes it in place. Windows has no `gjs`
22
+ binary, so take one of the other three there. Pick a single route — each of them puts its
23
+ own `gjsify` launcher on your PATH:
24
+
25
+ **npm**
26
+
27
+ ```bash
28
+ npm install -g @gjsify/cli
29
+ ```
30
+
31
+ **Bun**
32
+
9
33
  ```bash
10
- gjsify install @gjsify/cli
34
+ bun add -g @gjsify/cli
35
+ ```
36
+
37
+ **Deno**
11
38
 
12
- # npm or yarn also work (e.g. adding it to an existing project):
13
- npm install @gjsify/cli
14
- yarn add @gjsify/cli
39
+ ```bash
40
+ deno install -g -A -n gjsify npm:@gjsify/cli
15
41
  ```
16
42
 
43
+ Whichever route you pick you get the same `gjsify` command, and the runtime you installed
44
+ with becomes the one it builds for by default. To pin the CLI per project instead of
45
+ globally, add it as a dev dependency (`npm install -D @gjsify/cli`) — that is how every
46
+ scaffolded template is wired. PATH notes and the update command for each route:
47
+ [Install & Update](https://gjsify.github.io/gjsify/guides/install/).
48
+
17
49
  ## Usage
18
50
 
19
51
  ```bash
20
- # Build a GJS application
21
- npx @gjsify/cli build src/index.ts
52
+ gjsify create my-app --template gtk-minimal # scaffold a GTK 4 + TypeScript app
53
+ cd my-app
54
+ gjsify install # resolve npm deps, no npm required
55
+ gjsify run dev # watch, rebuild and relaunch on change
56
+ ```
22
57
 
23
- # Run a built GJS application (sets up the native-prebuild environment)
24
- npx @gjsify/cli run dist/index.js
58
+ `create` writes the build scripts too, so `gjsify run build`, `run start` and `run check`
59
+ work from there on. Reaching for the underlying commands directly:
25
60
 
26
- # Show environment info for a bundle
27
- npx @gjsify/cli info dist/index.js
61
+ ```bash
62
+ gjsify build src/index.ts --app gjs --outfile dist/index.gjs.js
63
+ gjsify run dist/index.gjs.js # launch it, with the native-prebuild environment set
64
+ gjsify info dist/index.gjs.js # print that environment instead of launching
65
+ gjsify ship # package the built app as a .deb and an .rpm
28
66
  ```
29
67
 
68
+ `ship` runs the project's own `build` script, stages one payload and wraps it per format,
69
+ with no manifest to maintain — see [Ship your app](https://gjsify.github.io/gjsify/ship/).
70
+ Every command and flag is in the
71
+ [CLI Reference](https://gjsify.github.io/gjsify/cli-reference/).
72
+
73
+ Without a global install, reach the CLI through your runtime's package runner instead:
74
+ `npx @gjsify/cli@latest …`, `bunx @gjsify/cli@latest …` or
75
+ `deno run -A --reload --min-dep-age=0 npm:@gjsify/cli@latest …`. Keep the `@latest` tag,
76
+ and on Deno those two extra flags: all three runners reuse a cached copy of an unpinned
77
+ bin, and Deno adds a second rule that refuses anything published in the last 24 hours.
78
+ Neither one tells you it happened — the
79
+ [measurement](https://gjsify.github.io/gjsify/guides/install/#which-version-do-npx-bunx-and-deno-run-give-you)
80
+ is in the install guide.
81
+
30
82
  ## Native prebuilds
31
83
 
32
84
  Packages that ship compiled artifacts declare them with
33
85
  `"gjsify": { "prebuilds": "prebuilds", "platforms": ["linux-x64", "darwin-arm64", …] }`
34
- and stage them under `prebuilds/<os>-<arch>/`. `run`, `info`, `tsc` and the bin launchers
35
- `install` writes all resolve that directory for the running host.
36
-
37
- There is ONE `<os>-<arch>` spelling: `${process.platform}-${process.arch}` — `linux-x64`,
38
- `linux-arm64`, `darwin-arm64`, `win32-x64`. It is what a running process can compute about
39
- itself, so resolution needs no translation. (`ppc64`, `s390x` and `riscv64` are spelled the
40
- same in every vocabulary.) The resolver still probes a package's own `gjsify.platforms`
41
- entry first, and falls back to the retired uname spelling (`linux-x86_64`), so a tarball
42
- published before the rename keeps loading.
43
-
44
- The environment they export is `GI_TYPELIB_PATH` plus the library-search variable the host's
45
- dynamic loader actually reads:
46
-
47
- | host | variable | separator |
48
- |---|---|---|
49
- | Linux | `LD_LIBRARY_PATH` | `:` |
50
- | macOS | `DYLD_LIBRARY_PATH` (`dyld` ignores `LD_LIBRARY_PATH`) | `:` |
51
- | Windows | `PATH` (`LoadLibrary` has no dedicated variable) | `;` |
52
-
53
- A package with no artifact for your host is skipped — every native bridge is optional at
54
- runtime. Which artifacts exist per package is tracked in
55
- [Platform Support](https://gjsify.github.io/gjsify/platform-support/).
86
+ and stage them under `prebuilds/<os>-<arch>[-musl]/`. `run`, `info`, `tsc` and the bin
87
+ launchers `install` writes all resolve that directory for the running host, and export
88
+ `GI_TYPELIB_PATH` plus the library-search variable the host's dynamic loader actually
89
+ reads — `LD_LIBRARY_PATH` on Linux, `DYLD_LIBRARY_PATH` on macOS (dyld ignores the Linux
90
+ one), `PATH` on Windows (`LoadLibrary` has no dedicated variable).
91
+
92
+ The target is spelled `${process.platform}-${process.arch}`, which is what a running
93
+ process can compute about itself, so locating the directory needs no translation step. The
94
+ resolver still probes a package's own declared spelling first and the retired uname one
95
+ (`linux-x86_64`) last, so a tarball published before the rename keeps loading. A package
96
+ with no artifact for your host is skipped — every native bridge is optional at runtime.
97
+
98
+ - How the lookup works, and how to set the same environment by hand:
99
+ [How It Works](https://gjsify.github.io/gjsify/how-it-works/#native-prebuilds-and-gjsify-run)
100
+ - Which artifacts exist per package:
101
+ [Platform Support](https://gjsify.github.io/gjsify/platform-support/)
56
102
 
57
103
  ## License
58
104