@vite-hub/cli 0.1.0 → 0.3.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.
package/README.md CHANGED
@@ -9,21 +9,16 @@
9
9
 
10
10
  ## Choose the package
11
11
 
12
- Install `vite-hub` in an application that uses the framework distribution. It includes the CLI and publishes both `vitehub` and `vite-hub` as binary names.
12
+ Install `vite-hub`. It publishes the one `vitehub` binary, which runs this package.
13
13
 
14
14
  ```sh
15
15
  pnpm add vite-hub
16
16
  pnpm vitehub --help
17
17
  ```
18
18
 
19
- Install `@vite-hub/cli` directly when a library or custom Vite integration needs the command runner without the framework distribution. The standalone package publishes the `vitehub` binary and requires Vite. Install Nuxt too when the project has a Nuxt config but no Vite config.
19
+ `@vite-hub/cli` has no binary of its own. A custom entry calls `runViteHubCliEntrypoint()`, as the `vitehub` binary of `vite-hub` does. It requires Vite, and Nuxt when the project has a Nuxt config but no Vite config.
20
20
 
21
- ```sh
22
- pnpm add -D @vite-hub/cli vite
23
- pnpm vitehub --help
24
- ```
25
-
26
- `@vite-hub/cli` requires Node.js 24 or newer. The current `vite-hub` distribution requires Node.js 24.15 or newer.
21
+ `@vite-hub/cli` requires Node.js 22.18 or newer. The current `vite-hub` distribution requires Node.js 22.22 or newer.
27
22
 
28
23
  Print the installed CLI version without loading project config:
29
24
 
@@ -50,18 +45,20 @@ The CLI owns the `inspect` namespace. Plugin command contributions with that nam
50
45
  Usage: vitehub <namespace> <feature> [args...]
51
46
 
52
47
  Available namespaces:
53
- inspect Inspect discovered Definitions and generated Provider Output.
48
+ inspect Inspect discovered Definitions, host resources, server routes, and generated Provider Output.
54
49
  provision Idempotently create missing provider resources.
55
50
  ```
56
51
 
57
52
  ## Inspect the project
58
53
 
59
- `inspect definitions` lists the Definitions that each active package discovered. The Console reads the same package-owned summaries. `inspect provider-output` lists generated Provider Output files and shows which exist. It resolves Vite configuration for build with production mode and loads Nuxt with development disabled, so production-only contributors are included. Other commands use development configuration.
54
+ `inspect definitions` lists the Definitions that each active package discovered. The Console reads the same package-owned summaries. `inspect output` lists generated Provider Output files and shows which exist. `inspect resources` lists the D1, KV, R2, Queue, and Vercel Blob resources that Definitions map to, with each id and its source: config, env, Provision State, generated provider output, or bound by name. It never calls a provider API. `inspect routes` lists the server routes and middleware that ViteHub and other Vite plugins add to the build, with each method, path, owner, and handler file. Routes in `server/routes` and `server/api` are not listed. These three commands resolve Vite configuration for build with production mode and load Nuxt with development disabled, so production-only contributors are included. Other commands use development configuration.
60
55
 
61
56
  ```sh
62
57
  pnpm vitehub inspect definitions --kind queue
63
58
  pnpm vitehub inspect definitions --json
64
- pnpm vitehub inspect provider-output --json
59
+ pnpm vitehub inspect output --json
60
+ pnpm vitehub inspect resources --json
61
+ pnpm vitehub inspect routes
65
62
  ```
66
63
 
67
64
  Human output is the default. `--json` prints a stable object. Both forms redact secret-like keys, Worker `vars` values, and URLs with embedded credentials.
@@ -77,6 +74,44 @@ The Agent integration contributes `info`, `dev`, and `invocations`, plus `channe
77
74
 
78
75
  See the [complete command index](https://vitehub.dev/docs/development/cli#commands) for command availability and the task each command performs.
79
76
 
77
+ ## Link and deploy several hosts
78
+
79
+ `vitehub link` and `vitehub deploy` run before the CLI loads the project config. One app can link one project on each host. `.vitehub/link.json` keeps a target for each host and the default host:
80
+
81
+ ```sh
82
+ pnpm vitehub link --host cloudflare
83
+ pnpm vitehub link --host vercel
84
+ pnpm vitehub deploy # the default target, cloudflare
85
+ pnpm vitehub deploy --host vercel
86
+ ```
87
+
88
+ The first linked host is the default. `vitehub link --host <host> --default` changes it. `vitehub deploy --host <host>` builds with `VITEHUB_HOST=<host>`, and that host wins over `host` in `vitehub()`. With several targets and no default, deploy needs `--host`. Resources such as D1, KV, R2, and libSQL are separate on each host. See [Link a project to its host](https://vitehub.dev/docs/development/cli#link-a-project-to-its-host).
89
+
90
+ On Cloudflare and Vercel, `vitehub deploy` first runs the provision plan of the host with the same credentials, including a `wrangler login`. It lists the resources it creates, asks first unless you pass `--yes`, and records their ids in `.vitehub/provision.json` before the build, so a second deploy creates nothing. `--no-provision` skips it. See [Create the host resources](https://vitehub.dev/docs/development/cli#create-the-host-resources).
91
+
92
+ ## Check and push host env
93
+
94
+ `vitehub env diff` and `vitehub env push` read the env names that the last build wrote to `deployment.json` and the variables of the linked host target. They run before the CLI loads the project config, and they run the host CLI with your login.
95
+
96
+ ```sh
97
+ pnpm vitehub env diff # missing required, missing optional, extra
98
+ pnpm vitehub env push --yes # values from the shell, then .env.production
99
+ pnpm vitehub env diff --host vercel --stage preview
100
+ ```
101
+
102
+ `env diff` compares names only, because hosts do not return values. It exits with 1 when a required name is missing. `env push` reads each value from the shell, then from `.env`, `.env.local`, `.env.<stage>`, and `.env.<stage>.local`, as Vite does. It decrypts dotenvx `encrypted:` values with `DOTENV_PRIVATE_KEY_<STAGE>`. It reads the files in the build's Vite `envDir`, refuses a plaintext secret from a file that git tracks or does not ignore (also through `$NAME` expansion and symlinks), sends each value on stdin or in an API body, prints names only, and never deletes a host variable. See [Check and push host env](https://vitehub.dev/docs/development/cli#check-and-push-host-env).
103
+
104
+ `vitehub deploy` runs the same check after provisioning and the build, before migrations, env writes, or publishing code. `vitehub deploy` reads stage `production`, and `vitehub deploy --preview` reads stage `preview`. A required name that is on neither the host nor a local value stops the deploy. Deploy sets the names that the host lacks from their local values, and `--push-env` also replaces the names that the host has. Cloudflare gets the values with the new version through `wrangler deploy --secrets-file`. With `--yes`, deploy generates a missing `VITEHUB_SECRET`. See [Check Env before a deploy](https://vitehub.dev/docs/development/cli#check-env-before-a-deploy).
105
+
106
+ After the upload, `vitehub deploy` requests the paths of `deploy.check` in `vitehub()`, and the health route with `health`, on the deployed URL. When one does not answer with a `2xx` status, it exits with `SETUP_DEPLOY_CHECK_FAILED` and prints the command that rolls production back to the deployment it replaced, such as `npx wrangler rollback <version-id> --name my-app --yes`. With `deploy: { indexNow: true }` and a string `publicUrl`, a production deploy that passed its checks sends the URLs of `/sitemap.xml` to IndexNow. `--no-check` and `--no-index-now` skip them. See [Check the deployed app](https://vitehub.dev/docs/development/cli#check-the-deployed-app).
107
+
108
+ `--to github` writes the same names to the Actions secrets of a GitHub repository instead of the host, for a deploy that your own workflow runs. It does not set up CI deploy. The repository comes from `--repo owner/name` or the git remote `origin`, `--environment <name>` targets a GitHub deployment environment, and the token comes from `GITHUB_TOKEN`, `GH_TOKEN`, `gh auth token`, or the GitHub App of `@vite-hub/forge`. Each value is sealed with the repository public key before it leaves the CLI.
109
+
110
+ ```sh
111
+ pnpm vitehub env diff --to github
112
+ pnpm vitehub env push --to github --environment production --yes
113
+ ```
114
+
80
115
  ## Run the CLI from code
81
116
 
82
117
  Use `runViteHubCli()` when another command runner needs ViteHub's config discovery and exit code without starting the binary entry point.
@@ -109,7 +144,11 @@ CLI-owned argument and execution defects use stable `CLI_R####` Nostics codes. C
109
144
  - Root and namespace help is human-readable text, not a structured output contract. Use `inspect ... --json` for machine-readable output.
110
145
  - Help loads and executes the local Vite or Nuxt config. A missing dependency or config error can stop help before it prints.
111
146
  - Command effects come from the package that contributes the command. Review command-specific help before applying Database migrations, Channel registration changes, or Provider provisioning.
112
- - `provision run` creates missing resources but does not delete or replace existing resources. Start with `--dry-run` and pass a provider explicitly.
113
- - `provision status` shows recorded ids from `.vitehub/provision.json` and pending plan actions. It never applies actions. Add `--json` to `provision run` or `provision status` for one JSON document on stdout.
147
+ - `provision run` creates missing resources but does not delete or replace existing resources. Start with `--dry-run` and pass `--host cloudflare` or `--host vercel`. It reads the credentials as `vitehub deploy` does: environment variables first, then a `wrangler login`. The old `--provider` flag exits with a `fix:` line. When a step cannot check its resources, `provision run` applies nothing and exits with code 1. The `--json` result has `checked`.
148
+ - `provision status` shows recorded ids from `.vitehub/provision.json` and pending plan actions. It marks a recorded id as `not declared` when no current Definition uses it, for example after a rename, and prints a `fix:` line that says how to delete the resource on the host. It never applies actions, deletes resources, or edits `.vitehub/provision.json`. Add `--json` to `provision run` or `provision status` for one JSON document on stdout.
149
+
150
+ Status also marks an R2 or Queue entry when its key is still declared but its recorded bucket name, jurisdiction, or Queue name differs from current config. After a rename, status defers deletion guidance if a current declaration's resource cannot be verified against config, including when the new key already has a stale id. Verify D1 and KV ids against provider resource names and bindings before deleting anything. `provision run` refreshes R2 and Queue identities for comparison with config. R2 resource identities include jurisdiction; older entries with only a bucket name require checking the jurisdiction manually and receive no deletion guidance while an R2 Store remains declared.
114
151
 
115
152
  Read the [CLI guide](https://vitehub.dev/docs/development/cli) for every public command, examples, and troubleshooting.
153
+
154
+ Cloudflare deploys always re-supply the stage’s local values, including existing Worker secrets, to prevent inheritance from a preview upload. Every existing secret needs a local stage value; otherwise deploy stops with `SETUP_DEPLOY_ENV_STAGE_UNSAFE`. This includes a previously generated `VITEHUB_SECRET`; supply a locally managed value for subsequent deploys.