diff --git a/.github/workflows/deploy-site.yml b/.github/workflows/deploy-site.yml index 8dd7a99..7e6ac4e 100644 --- a/.github/workflows/deploy-site.yml +++ b/.github/workflows/deploy-site.yml @@ -39,7 +39,7 @@ jobs: - uses: taiki-e/install-action@v2 with: tool: just - - run: cargo install fusor-cli --version 0.1.4 --locked + - run: cargo install fusor-cli --version 0.1.5 --locked - run: fusor install --manifest-path apps/Cargo.toml -p hypercmd-docs --locked - run: npm install --global vercel@59.23.2 - run: vercel pull --yes --environment=${{ inputs.environment }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5305cc3..6726cf8 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -127,3 +127,15 @@ jobs: else cargo publish --workspace --locked "${skip[@]}" fi + + ready: + if: github.event_name == 'release' + needs: [attach, crates-io] + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - uses: actions/checkout@v4 + - run: gh release upload "$GITHUB_REF_NAME" install.sh --clobber --repo "$GITHUB_REPOSITORY" + env: + GH_TOKEN: ${{ github.token }} diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 3fae8db..9be5bc5 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -41,7 +41,7 @@ The workflow caches Cargo downloads and installed tools, but not `apps/target`: cache action removes Fusor's ownership manifests from site staging directories. For a local deployment, install the site prerequisites with -`cargo install fusor-cli --version 0.1.4 --locked` and +`cargo install fusor-cli --version 0.1.5 --locked` and `fusor install --manifest-path apps/Cargo.toml -p hypercmd-docs --locked`. Install Vercel CLI 59.23.2, then run `vercel login` and `vercel link --yes --scope pirela --project hypercmd` once. Run @@ -72,7 +72,14 @@ linked) and macOS (Apple Silicon and Intel), installs each archive with `install.sh` and creates a new app with it. Once every platform passes, it attaches the archives and their `.sha256` checksums to the release, checks that the tag matches the version, runs `just check` and a dry run, and publishes to -crates.io. Rerunning a stopped release skips crates already published. +crates.io. After both uploads and crate publication succeed, it attaches `install.sh`. +The CLI treats that final asset as the release readiness signal for upgrades and +version notifications. Rerunning a stopped release skips crates already published. + +The CLI embeds the root installer through `crates/hypercmd-cli/install.sh`, a symlink +that Cargo flattens into the package archive. Edit the root script. `just cli` exercises +upgrades between two builds of the real CLI using local release archives and an HTTP +fixture selected by `HYPERCMD_RELEASE_URL` and `HYPERCMD_DOWNLOAD_BASE`. To try the binaries without releasing, run the `Release` workflow by hand from the Actions tab; it keeps the archives as workflow artifacts and publishes diff --git a/Cargo.lock b/Cargo.lock index a0dea25..6ef24b5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -367,9 +367,9 @@ dependencies = [ [[package]] name = "fusor-async" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "804497a690960b93fe23366f41f968d923e60e9025eee19180e9d63f2a7d70d2" +checksum = "646fff2a46bb22563d2803c7bb2d47d606a63b4d1ae087a17e88535271ec5739" dependencies = [ "derive-where", "fusor-core", @@ -378,9 +378,9 @@ dependencies = [ [[package]] name = "fusor-build" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61e853f1efe0a7a43a69c1b0ba429a65e3fb2b059a9839522bea725452a325d5" +checksum = "9519b7630353b2f0d12255e4a94a102b0ab0d973623b138a5a6b4d8d8744d6b5" dependencies = [ "fusor-core", "fusor-islands", @@ -397,18 +397,18 @@ dependencies = [ [[package]] name = "fusor-components" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ff376904a2eadb6a540744719429734482d2e736a0773377d9853fe170613f5" +checksum = "b2fccd168a90d8d305d3c1cbcd5240cbf6c7642bd7e6d1cad82cd25be5f0a2d6" dependencies = [ "fusor-core", ] [[package]] name = "fusor-core" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36cc8392e17b5eea5f45606a51bb8736042bd19175f20fb63ee82fc1787561eb" +checksum = "99e9a5d9f8a49db0ed7132c1c8061c16797a97ec1fdfac621b25e39fa24d1c7c" dependencies = [ "fusor-macros", "js-sys", @@ -418,9 +418,9 @@ dependencies = [ [[package]] name = "fusor-islands" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09040f3dfaa95e41e54a4ba1005a88e017910b0eceee4e700c5f04be3c47ce22" +checksum = "74305bb3cb2e04df2c6ba06e13cbe536aca92046e61377eee4142e8dfd2eddd8" dependencies = [ "fusor-core", "serde", @@ -429,9 +429,9 @@ dependencies = [ [[package]] name = "fusor-macros" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebdbd0919aeab94a1589b0952a9711e7d46aab3123a0c2c02ba3b0683d814490" +checksum = "7116a1002c31d1027dd6da5844b8133b5d81c098c6720567c5cd8b8f8e5245d8" dependencies = [ "proc-macro2", "quote", @@ -440,9 +440,9 @@ dependencies = [ [[package]] name = "fusor-router" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1cbb73da8ceba9583442a661d65d9d1256ee2863a55ee1ec95f8e5d4b4507070" +checksum = "e86cf63dfe536faf9cb7b4d7ecfd0f3da3abaf005e9551889be82c4ea64982d9" dependencies = [ "form_urlencoded", "fusor-core", @@ -541,7 +541,7 @@ checksum = "428502d3ec1742c35e015871aef742bc4722a9acfcb616b8ff79b519922e1c36" [[package]] name = "hypercmd" -version = "0.1.1" +version = "0.1.2" dependencies = [ "crossterm", "fusor-async", @@ -563,7 +563,7 @@ dependencies = [ [[package]] name = "hypercmd-build" -version = "0.1.1" +version = "0.1.2" dependencies = [ "fusor-build", "proc-macro2", @@ -576,19 +576,22 @@ dependencies = [ [[package]] name = "hypercmd-cli" -version = "0.1.1" +version = "0.1.2" dependencies = [ "clap", "fusor-build", "hypercmd-build", + "portable-pty", + "semver", "serde", "serde_json", + "tempfile", "toml", ] [[package]] name = "hypercmd-job-controls" -version = "0.1.1" +version = "0.1.2" dependencies = [ "fusor-build", "fusor-components", @@ -929,6 +932,16 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" +[[package]] +name = "semver" +version = "1.0.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a7852d02fc848982e0c167ef163aaff9cd91dc640ba85e263cb1ce46fae51cd" +dependencies = [ + "serde", + "serde_core", +] + [[package]] name = "serde" version = "1.0.229" diff --git a/Cargo.toml b/Cargo.toml index e31fb28..cfefca1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,7 +4,7 @@ exclude = ["tests/consumer", "tests/browser-consumer", "apps"] resolver = "2" [workspace.package] -version = "0.1.1" +version = "0.1.2" edition = "2024" rust-version = "1.85" license = "MIT" @@ -35,19 +35,19 @@ struct_excessive_bools = "deny" excessive_nesting = "deny" [workspace.dependencies] -hypercmd = { path = "crates/hypercmd", version = "=0.1.1", default-features = false } -hypercmd-build = { path = "crates/hypercmd-build", version = "=0.1.1" } -hypercmd-job-controls = { path = "examples/job-controls", version = "=0.1.1" } +hypercmd = { path = "crates/hypercmd", version = "=0.1.2", default-features = false } +hypercmd-build = { path = "crates/hypercmd-build", version = "=0.1.2" } +hypercmd-job-controls = { path = "examples/job-controls", version = "=0.1.2" } portable-pty = "=0.9.0" rustix = "=1.1.4" tempfile = "=3.23.0" -fusor = { package = "fusor-core", version = "=0.1.4", default-features = false } -fusor-build = { version = "=0.1.4" } -fusor-components = { version = "=0.1.4", default-features = false } -fusor-router = { version = "=0.1.4", default-features = false } -fusor-async = { version = "=0.1.4", default-features = false } -fusor-test = { version = "=0.1.4", default-features = false } -fusor-std = { version = "=0.1.4", default-features = false } +fusor = { package = "fusor-core", version = "=0.1.5", default-features = false } +fusor-build = { version = "=0.1.5" } +fusor-components = { version = "=0.1.5", default-features = false } +fusor-router = { version = "=0.1.5", default-features = false } +fusor-async = { version = "=0.1.5", default-features = false } +fusor-test = { version = "=0.1.5", default-features = false } +fusor-std = { version = "=0.1.5", default-features = false } proc-macro2 = "1.0.103" quote = "1.0.42" syn = { version = "2.0.111", features = ["full"] } diff --git a/README.md b/README.md index c071d6f..7e4a885 100644 --- a/README.md +++ b/README.md @@ -82,6 +82,9 @@ curl -fsSL https://raw.githubusercontent.com/fusor-rs/hypercmd/main/install.sh | The installer downloads the latest release, verifies its checksum, and puts `hypercmd` in `.hypercmd/bin` under your home directory; it prints the line to add to your `PATH`. The script is [install.sh](install.sh) if you want to read it first. With Rust installed, `cargo install hypercmd-cli` works too. +Run `hypercmd upgrade` to upgrade the CLI. Interactive commands warn when a newer +release is available, checking at most once a day. See [CLI upgrades](docs/cli.md#hypercmd-upgrade). + Create and run an app: ```sh @@ -100,12 +103,12 @@ again. See the [CLI reference](docs/cli.md) for commands and options. ```toml [dependencies] -hypercmd = "=0.1.1" -fusor = { package = "fusor-core", version = "=0.1.4", default-features = false } -fusor-components = { version = "=0.1.4", default-features = false } +hypercmd = "=0.1.2" +fusor = { package = "fusor-core", version = "=0.1.5", default-features = false } +fusor-components = { version = "=0.1.5", default-features = false } [build-dependencies] -hypercmd-build = "=0.1.1" +hypercmd-build = "=0.1.2" [package.metadata.hypercmd] entry = "ui/app.html" # the template diff --git a/apps/Cargo.lock b/apps/Cargo.lock index 5824d13..101bea0 100644 --- a/apps/Cargo.lock +++ b/apps/Cargo.lock @@ -196,7 +196,7 @@ dependencies = [ [[package]] name = "docs-base" version = "0.1.0" -source = "git+https://github.com/fusor-rs/docs-base?rev=e2c7b3939721002ea2aa7556d8e4409aa131472b#e2c7b3939721002ea2aa7556d8e4409aa131472b" +source = "git+https://github.com/fusor-rs/docs-base?rev=78990c2b07d510abc76224e82ca933f89f423850#78990c2b07d510abc76224e82ca933f89f423850" dependencies = [ "fusor-build", "fusor-components", @@ -208,7 +208,7 @@ dependencies = [ [[package]] name = "docs-base-build" version = "0.1.0" -source = "git+https://github.com/fusor-rs/docs-base?rev=e2c7b3939721002ea2aa7556d8e4409aa131472b#e2c7b3939721002ea2aa7556d8e4409aa131472b" +source = "git+https://github.com/fusor-rs/docs-base?rev=78990c2b07d510abc76224e82ca933f89f423850#78990c2b07d510abc76224e82ca933f89f423850" dependencies = [ "proc-macro2", "pulldown-cmark", @@ -276,9 +276,9 @@ dependencies = [ [[package]] name = "fusor-async" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "804497a690960b93fe23366f41f968d923e60e9025eee19180e9d63f2a7d70d2" +checksum = "646fff2a46bb22563d2803c7bb2d47d606a63b4d1ae087a17e88535271ec5739" dependencies = [ "derive-where", "fusor-core", @@ -287,9 +287,9 @@ dependencies = [ [[package]] name = "fusor-build" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61e853f1efe0a7a43a69c1b0ba429a65e3fb2b059a9839522bea725452a325d5" +checksum = "9519b7630353b2f0d12255e4a94a102b0ab0d973623b138a5a6b4d8d8744d6b5" dependencies = [ "fusor-core", "fusor-islands", @@ -306,18 +306,18 @@ dependencies = [ [[package]] name = "fusor-components" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ff376904a2eadb6a540744719429734482d2e736a0773377d9853fe170613f5" +checksum = "b2fccd168a90d8d305d3c1cbcd5240cbf6c7642bd7e6d1cad82cd25be5f0a2d6" dependencies = [ "fusor-core", ] [[package]] name = "fusor-core" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36cc8392e17b5eea5f45606a51bb8736042bd19175f20fb63ee82fc1787561eb" +checksum = "99e9a5d9f8a49db0ed7132c1c8061c16797a97ec1fdfac621b25e39fa24d1c7c" dependencies = [ "fusor-macros", "js-sys", @@ -327,9 +327,9 @@ dependencies = [ [[package]] name = "fusor-islands" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09040f3dfaa95e41e54a4ba1005a88e017910b0eceee4e700c5f04be3c47ce22" +checksum = "74305bb3cb2e04df2c6ba06e13cbe536aca92046e61377eee4142e8dfd2eddd8" dependencies = [ "fusor-core", "serde", @@ -338,9 +338,9 @@ dependencies = [ [[package]] name = "fusor-macros" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebdbd0919aeab94a1589b0952a9711e7d46aab3123a0c2c02ba3b0683d814490" +checksum = "7116a1002c31d1027dd6da5844b8133b5d81c098c6720567c5cd8b8f8e5245d8" dependencies = [ "proc-macro2", "quote", @@ -349,9 +349,9 @@ dependencies = [ [[package]] name = "fusor-router" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1cbb73da8ceba9583442a661d65d9d1256ee2863a55ee1ec95f8e5d4b4507070" +checksum = "e86cf63dfe536faf9cb7b4d7ecfd0f3da3abaf005e9551889be82c4ea64982d9" dependencies = [ "form_urlencoded", "fusor-core", @@ -441,7 +441,7 @@ checksum = "428502d3ec1742c35e015871aef742bc4722a9acfcb616b8ff79b519922e1c36" [[package]] name = "hypercmd" -version = "0.1.1" +version = "0.1.2" dependencies = [ "fusor-async", "fusor-core", @@ -458,7 +458,7 @@ dependencies = [ [[package]] name = "hypercmd-build" -version = "0.1.1" +version = "0.1.2" dependencies = [ "fusor-build", "proc-macro2", @@ -470,7 +470,7 @@ dependencies = [ [[package]] name = "hypercmd-docs" -version = "0.1.1" +version = "0.1.2" dependencies = [ "docs-base", "docs-base-build", @@ -483,7 +483,7 @@ dependencies = [ [[package]] name = "hypercmd-landing" -version = "0.1.1" +version = "0.1.2" dependencies = [ "docs-base-build", "fusor-build", diff --git a/apps/docs/Cargo.toml b/apps/docs/Cargo.toml index 58f79c5..033b83c 100644 --- a/apps/docs/Cargo.toml +++ b/apps/docs/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "hypercmd-docs" -version = "0.1.1" +version = "0.1.2" edition = "2024" rust-version = "1.85" publish = false @@ -9,15 +9,15 @@ publish = false crate-type = ["cdylib", "rlib"] [dependencies] -docs-base = { git = "https://github.com/fusor-rs/docs-base", rev = "e2c7b3939721002ea2aa7556d8e4409aa131472b" } -fusor = { package = "fusor-core", version = "=0.1.4", features = ["dom", "derive"] } -fusor-components = { version = "=0.1.4", features = ["browser"] } -fusor-router = { version = "=0.1.4", features = ["browser"] } +docs-base = { git = "https://github.com/fusor-rs/docs-base", rev = "78990c2b07d510abc76224e82ca933f89f423850" } +fusor = { package = "fusor-core", version = "=0.1.5", features = ["dom", "derive"] } +fusor-components = { version = "=0.1.5", features = ["browser"] } +fusor-router = { version = "=0.1.5", features = ["browser"] } wasm-bindgen = "=0.2.117" [build-dependencies] -docs-base-build = { git = "https://github.com/fusor-rs/docs-base", rev = "e2c7b3939721002ea2aa7556d8e4409aa131472b" } -fusor-build = "=0.1.4" +docs-base-build = { git = "https://github.com/fusor-rs/docs-base", rev = "78990c2b07d510abc76224e82ca933f89f423850" } +fusor-build = "=0.1.5" [package.metadata.fusor] entry = "web/index.html" diff --git a/apps/docs/build.rs b/apps/docs/build.rs index 08d1ea5..88bf517 100644 --- a/apps/docs/build.rs +++ b/apps/docs/build.rs @@ -28,5 +28,6 @@ fn main() -> Result<(), Box> { )?; println!("cargo:rerun-if-changed=../../assets/brand/hypercmd.svg"); fs::copy(root.join("assets/brand/hypercmd.svg"), "public/favicon.svg")?; - fusor_build::compile_app() + fusor_build::compile_app()?; + Ok(()) } diff --git a/apps/landing/Cargo.toml b/apps/landing/Cargo.toml index b3d203a..ab4a4cc 100644 --- a/apps/landing/Cargo.toml +++ b/apps/landing/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "hypercmd-landing" -version = "0.1.1" +version = "0.1.2" edition = "2024" rust-version = "1.85" publish = false @@ -9,16 +9,16 @@ publish = false crate-type = ["cdylib", "rlib"] [dependencies] -fusor = { package = "fusor-core", version = "=0.1.4", features = ["dom", "derive"] } -fusor-components = { version = "=0.1.4", features = ["browser"] } +fusor = { package = "fusor-core", version = "=0.1.5", features = ["dom", "derive"] } +fusor-components = { version = "=0.1.5", features = ["browser"] } hypercmd = { path = "../../crates/hypercmd", default-features = false } wasm-bindgen = "=0.2.117" wasm-bindgen-futures = "=0.4.67" web-sys = { version = "=0.3.94", features = ["Window", "Navigator", "Clipboard", "HtmlInputElement"] } [build-dependencies] -docs-base-build = { git = "https://github.com/fusor-rs/docs-base", rev = "e2c7b3939721002ea2aa7556d8e4409aa131472b" } -fusor-build = "=0.1.4" +docs-base-build = { git = "https://github.com/fusor-rs/docs-base", rev = "78990c2b07d510abc76224e82ca933f89f423850" } +fusor-build = "=0.1.5" hypercmd-build = { path = "../../crates/hypercmd-build" } quote = "=1.0.47" diff --git a/apps/landing/build.rs b/apps/landing/build.rs index b26dcec..6ba8014 100644 --- a/apps/landing/build.rs +++ b/apps/landing/build.rs @@ -42,7 +42,8 @@ fn main() -> Result<(), Box> { highlighted_examples()?; project_files()?; hypercmd_build::compile_app()?; - fusor_build::compile_app() + fusor_build::compile_app()?; + Ok(()) } fn highlighted_examples() -> Result<(), Box> { diff --git a/crates/hypercmd-build/src/backend.rs b/crates/hypercmd-build/src/backend.rs index a610517..0b781bd 100644 --- a/crates/hypercmd-build/src/backend.rs +++ b/crates/hypercmd-build/src/backend.rs @@ -52,7 +52,7 @@ impl Backend for HypercmdBackend { } } fn version(&self) -> u32 { - 2 + 3 } fn name(&self) -> &str { "hypercmd terminal-v1" diff --git a/crates/hypercmd-build/src/lib.rs b/crates/hypercmd-build/src/lib.rs index 6b4a00f..d525a94 100644 --- a/crates/hypercmd-build/src/lib.rs +++ b/crates/hypercmd-build/src/lib.rs @@ -82,8 +82,8 @@ pub fn compile_app() -> Result<()> { path.path().hash(&mut hash); backend.file.set(hash.finish()); generate(html, &backend) - }) - .map(|_| ()) + })?; + Ok(()) } fn styles(root: &Path, config: &Config) -> Result { diff --git a/crates/hypercmd-cli/Cargo.toml b/crates/hypercmd-cli/Cargo.toml index ea24f2a..6febe4d 100644 --- a/crates/hypercmd-cli/Cargo.toml +++ b/crates/hypercmd-cli/Cargo.toml @@ -22,6 +22,11 @@ clap = { version = "=4.5.53", features = ["derive"] } serde.workspace = true serde_json.workspace = true toml.workspace = true +semver = { version = "=1.0.28", features = ["serde"] } +tempfile.workspace = true + +[dev-dependencies] +portable-pty.workspace = true [lints] workspace = true diff --git a/crates/hypercmd-cli/install.sh b/crates/hypercmd-cli/install.sh new file mode 120000 index 0000000..c6fc13a --- /dev/null +++ b/crates/hypercmd-cli/install.sh @@ -0,0 +1 @@ +../../install.sh \ No newline at end of file diff --git a/crates/hypercmd-cli/src/cargo.rs b/crates/hypercmd-cli/src/cargo.rs index b431444..bf00d51 100644 --- a/crates/hypercmd-cli/src/cargo.rs +++ b/crates/hypercmd-cli/src/cargo.rs @@ -129,8 +129,8 @@ fn load_maps(out_dir: &Path, maps: &mut Maps) { if !manifest.exists() { return; } - let result = OutputManifest::read(&manifest).and_then(|manifest| { - manifest + let result = (|| { + OutputManifest::read(&manifest)? .sources .into_iter() .map(|source| { @@ -143,7 +143,7 @@ fn load_maps(out_dir: &Path, maps: &mut Maps) { )) }) .collect::>>() - }); + })(); match result { Ok(entries) => maps.extend(entries), Err(error) => eprintln!( diff --git a/crates/hypercmd-cli/src/main.rs b/crates/hypercmd-cli/src/main.rs index 023637a..4adae71 100644 --- a/crates/hypercmd-cli/src/main.rs +++ b/crates/hypercmd-cli/src/main.rs @@ -1,6 +1,7 @@ //! The hypercmd command-line tool: create, check, run and build terminal apps. mod cargo; mod new; +mod upgrade; use clap::{Parser, Subcommand}; use std::{ffi::OsString, fs, path::PathBuf, process::ExitCode}; @@ -48,10 +49,18 @@ enum Action { }, /// List the supported HTML elements and CSS properties Profile, + /// Upgrade the installed CLI to the latest stable release + Upgrade, } fn main() -> ExitCode { - match run(Cli::parse().command) { + let action = Cli::parse().command; + let offline = matches!(&action, Action::Check { args } + if args.iter().any(|argument| argument == "--offline" || argument == "--frozen")); + if !offline && !matches!(action, Action::Upgrade) { + upgrade::notify(); + } + match run(action) { Ok(()) => ExitCode::SUCCESS, Err(error) => { eprintln!("hypercmd: {error}"); @@ -62,6 +71,7 @@ fn main() -> ExitCode { fn run(action: Action) -> Result { match action { + Action::Upgrade => upgrade::run(), Action::New { path, hypercmd_path, diff --git a/crates/hypercmd-cli/src/new.rs b/crates/hypercmd-cli/src/new.rs index 375ba28..0d15f49 100644 --- a/crates/hypercmd-cli/src/new.rs +++ b/crates/hypercmd-cli/src/new.rs @@ -7,7 +7,7 @@ use std::{ use toml::{Table, Value}; /// The fusor release this hypercmd is built against; a test keeps it in sync. -pub(crate) const FUSOR_VERSION: &str = "0.1.4"; +pub(crate) const FUSOR_VERSION: &str = "0.1.5"; const BUILD_RS: &str = "fn main() -> Result<(), Box> { hypercmd_build::compile_app() diff --git a/crates/hypercmd-cli/src/upgrade.rs b/crates/hypercmd-cli/src/upgrade.rs new file mode 100644 index 0000000..e905909 --- /dev/null +++ b/crates/hypercmd-cli/src/upgrade.rs @@ -0,0 +1,212 @@ +use crate::Result; +use semver::Version; +use serde::{Deserialize, Serialize}; +use std::{ + env, + ffi::OsStr, + fs, + io::{self, ErrorKind, IsTerminal}, + path::{Path, PathBuf}, + process::Command, + time::{Duration, SystemTime, UNIX_EPOCH}, +}; + +const CURRENT_VERSION: &str = env!("CARGO_PKG_VERSION"); +const CHECK_INTERVAL: Duration = Duration::from_secs(24 * 60 * 60); +const NOTIFICATION_TIMEOUT: Duration = Duration::from_secs(2); +const UPGRADE_TIMEOUT: Duration = Duration::from_secs(30); +// The release workflow uploads this only after binaries and crates are published. +const READY_ASSET: &str = "install.sh"; + +#[derive(Deserialize)] +struct Release { + tag_name: String, + draft: bool, + prerelease: bool, + assets: Vec, +} + +#[derive(Deserialize)] +struct Asset { + name: String, +} + +#[derive(Deserialize, Serialize)] +struct VersionCheck { + checked_at: u64, + available: Option, +} + +pub(crate) fn run() -> Result { + let current = Version::parse(CURRENT_VERSION)?; + let Some(version) = latest(¤t, UPGRADE_TIMEOUT)? else { + println!("hypercmd {current} is already up to date."); + return Ok(()); + }; + let executable = fs::canonicalize(env::current_exe()?)?; + println!("Upgrading hypercmd {current} → {version}"); + let status = match cargo_installation(&executable)? { + Some(root) => Command::new(env::var_os("CARGO").unwrap_or_else(|| "cargo".into())) + .args(["install", env!("CARGO_PKG_NAME"), "--locked", "--version"]) + .arg(format!("={version}")) + .arg("--root") + .arg(root) + .status()?, + None => installer() + .arg(version.to_string()) + .env("HYPERCMD_BIN", &executable) + .status()?, + }; + if !status.success() { + return Err( + format!("upgrade failed ({status}); see the messages above and try again").into(), + ); + } + Ok(()) +} + +pub(crate) fn notify() { + if env::var_os("CI").is_some() || !io::stderr().is_terminal() || !io::stdout().is_terminal() { + return; + } + // An unavailable cache must not prevent the user's command from running. + if let Ok(Some(version)) = notification() { + eprintln!("⚠️ New version available: {CURRENT_VERSION} → {version}. Run hypercmd upgrade"); + } +} + +fn notification() -> Result> { + let current = Version::parse(CURRENT_VERSION)?; + let directory = env::var_os("XDG_CACHE_HOME") + .map(PathBuf::from) + .or_else(|| env::var_os("HOME").map(|home| PathBuf::from(home).join(".cache"))) + .ok_or("no home or cache directory is configured")? + .join("hypercmd"); + let path = directory.join("version.json"); + let previous = match fs::read(&path) { + Ok(bytes) => { + // A corrupt cache is disposable; the next check reconstructs it. + serde_json::from_slice::(&bytes).ok() + } + Err(error) if error.kind() == ErrorKind::NotFound => None, + Err(error) => return Err(error.into()), + }; + let now = SystemTime::now().duration_since(UNIX_EPOCH)?.as_secs(); + let recent = previous.as_ref().is_some_and(|check| { + now.checked_sub(check.checked_at) + .is_some_and(|age| age < CHECK_INTERVAL.as_secs()) + }); + let available = if recent { + previous.and_then(|check| check.available) + } else { + fs::create_dir_all(&directory)?; + let cache = tempfile::NamedTempFile::new_in(&directory)?; + let available = match latest(¤t, NOTIFICATION_TIMEOUT) { + Ok(available) => available, + // Offline and rate-limited checks retain the last known release. + Err(_) => previous.and_then(|check| check.available), + }; + let check = VersionCheck { + checked_at: now, + available, + }; + serde_json::to_writer(&cache, &check)?; + cache.persist(path)?; + check.available + }; + Ok(available.filter(|version| version.cmp_precedence(¤t).is_gt())) +} + +fn latest(current: &Version, timeout: Duration) -> Result> { + let repository = env!("CARGO_PKG_REPOSITORY") + .strip_prefix("https://github.com/") + .expect("the workspace repository is hosted on GitHub"); + let url = env::var_os("HYPERCMD_RELEASE_URL").unwrap_or_else(|| { + format!("https://api.github.com/repos/{repository}/releases/latest").into() + }); + let output = Command::new("curl") + .args([ + "--fail", + "--silent", + "--show-error", + "--location", + "--max-time", + ]) + .arg(timeout.as_secs().to_string()) + .arg(url) + .output()?; + if !output.status.success() { + return Err(format!( + "could not check for a release; try again later: {}", + String::from_utf8_lossy(&output.stderr).trim() + ) + .into()); + } + let release: Release = serde_json::from_slice(&output.stdout)?; + let version = Version::parse(release.tag_name.trim_start_matches('v'))?; + if release.draft || release.prerelease || !version.pre.is_empty() { + return Err("the latest release is not stable; try again after it is published".into()); + } + if !version.cmp_precedence(current).is_gt() { + return Ok(None); + } + let output = installer() + .arg("--archive") + .arg(version.to_string()) + .output()?; + if !output.status.success() { + return Err(String::from_utf8(output.stderr)?.into()); + } + let archive = String::from_utf8(output.stdout)?; + for required in [ + READY_ASSET, + archive.trim(), + &format!("{}.sha256", archive.trim()), + ] { + if !release.assets.iter().any(|asset| asset.name == required) { + return Err( + format!("release {version} is still being published; try again later").into(), + ); + } + } + Ok(Some(version)) +} + +fn installer() -> Command { + let mut command = Command::new("sh"); + command.args(["-c", include_str!("../install.sh"), "hypercmd-installer"]); + command +} + +fn cargo_installation(executable: &Path) -> Result> { + let Some(directory) = executable.parent().filter(|path| path.ends_with("bin")) else { + return Ok(None); + }; + let root = directory + .parent() + .ok_or("the installation has no parent directory")?; + if !root.join(".crates.toml").try_exists()? { + return Ok(None); + } + let output = Command::new(env::var_os("CARGO").unwrap_or_else(|| "cargo".into())) + .args(["install", "--list", "--root"]) + .arg(root) + .output()?; + if !output.status.success() { + return Err(format!( + "could not inspect the Cargo installation: {}", + String::from_utf8_lossy(&output.stderr).trim() + ) + .into()); + } + let package = format!("{} v", env!("CARGO_PKG_NAME")); + let listing = String::from_utf8(output.stdout)?; + let mut lines = listing.lines(); + if !lines.any(|line| line.starts_with(&package)) { + return Ok(None); + } + Ok(lines + .take_while(|line| line.starts_with(' ')) + .any(|line| Some(OsStr::new(line.trim())) == executable.file_name()) + .then_some(root)) +} diff --git a/docs/cli.md b/docs/cli.md index 93ac187..f886845 100644 --- a/docs/cli.md +++ b/docs/cli.md @@ -97,6 +97,37 @@ Prints the supported HTML elements and CSS properties with accepted values. It d build an application. The [HTML and CSS reference](profile.md) explains layout behavior and unsupported features. +## hypercmd upgrade + +```sh +hypercmd upgrade +``` + +Upgrades the installed CLI to the latest stable release. An equal or older release +leaves the installation unchanged. Cargo installations upgrade through Cargo in their +existing installation root. Other installations download the matching macOS or Linux +archive, verify its SHA-256 checksum and version, and replace the running executable. +The replacement is staged in the same directory so a failed download or verification +leaves the installed CLI intact. Symlinks continue to point to the upgraded executable. + +The command uses the same `curl`, `tar` and checksum tools as `install.sh`. Its +installation directory must be writable. Upgrading the CLI does not change existing +projects' dependency versions. + +Interactive commands print a warning when a newer release is available: + +```text +⚠️ New version available: 0.1.2 → 0.1.3. Run hypercmd upgrade +``` + +Release checks run at most once per 24 hours with a two-second network timeout. +Results are cached under `$XDG_CACHE_HOME/hypercmd`, or `~/.cache/hypercmd` when that +variable is unset. Failed checks preserve the last known release and do not fail the +command. Automatic checks are skipped in CI, when stdout or stderr is redirected, +for help and version output, and for `check --offline` or `check --frozen`. +`upgrade` always checks for a release directly. A release is offered after its +platform archive, checksum and final installer asset are present. + ## Help and version ```sh diff --git a/docs/consumption.md b/docs/consumption.md index 9b2d0c7..4956cc8 100644 --- a/docs/consumption.md +++ b/docs/consumption.md @@ -29,7 +29,7 @@ terminal styles are compiled into the library's generated component. ## Cargo archives -Hypercmd gets fusor from crates.io, pinned to an exact version (`=0.1.4`; the `=` tells +Hypercmd gets fusor from crates.io, pinned to an exact version (`=0.1.5`; the `=` tells Cargo to accept only that version). `just packages` creates Cargo `.crate` archives, the source packages Cargo publishes, for diff --git a/examples/job-controls/src/lib.rs b/examples/job-controls/src/lib.rs index 7d97f98..40ae33a 100644 --- a/examples/job-controls/src/lib.rs +++ b/examples/job-controls/src/lib.rs @@ -65,7 +65,7 @@ mod row { clippy::too_many_lines, clippy::excessive_nesting, clippy::redundant_clone, - reason = "fusor-build 0.1.4's DOM codegen leaves these unsuppressed in generated mount code" + reason = "fusor-build 0.1.5's DOM codegen leaves these unsuppressed in generated mount code" )] mod dom { use super::JobRow; diff --git a/install.sh b/install.sh index 7b721ef..719aaaa 100644 --- a/install.sh +++ b/install.sh @@ -11,8 +11,10 @@ repository="fusor-rs/hypercmd" # Overridable so the release workflow can test this script against the archives # it has just built, before they are published. download_base="${HYPERCMD_DOWNLOAD_BASE:-https://github.com/$repository/releases/download}" -install_dir="${HYPERCMD_INSTALL:-$HOME/.hypercmd}" version="${1:-${HYPERCMD_VERSION:-}}" +if [ "$version" = "--archive" ]; then + version="$2" +fi fail() { echo "error: $*" >&2 @@ -46,8 +48,16 @@ case "$version" in esac archive="hypercmd-${version#v}-$target.tar.gz" +if [ "${1:-}" = "--archive" ]; then + echo "$archive" + exit 0 +fi + url="$download_base/$version/$archive" -temporary=$(mktemp -d) +executable="${HYPERCMD_BIN:-${HYPERCMD_INSTALL:-$HOME/.hypercmd}/bin/hypercmd}" +bin_dir=$(dirname "$executable") +mkdir -p "$bin_dir" +temporary=$(mktemp -d "$bin_dir/.hypercmd-XXXXXX") trap 'rm -rf "$temporary"' EXIT echo "Downloading hypercmd $version for $target" @@ -64,19 +74,29 @@ else fi [ "$expected" = "$actual" ] || fail "checksum mismatch for $archive; the download is corrupt or was tampered with" -tar -xzf "$temporary/$archive" -C "$temporary" -mkdir -p "$install_dir/bin" -mv "$temporary/hypercmd-${version#v}-$target/hypercmd" "$install_dir/bin/hypercmd" -chmod +x "$install_dir/bin/hypercmd" +member="${archive%.tar.gz}/hypercmd" +tar -xzf "$temporary/$archive" -C "$temporary" "$member" +replacement="$temporary/$member" +[ -f "$replacement" ] && [ ! -L "$replacement" ] || + fail "archive has no regular hypercmd executable" +chmod +x "$replacement" +installed_version=$("$replacement" --version) || fail "downloaded hypercmd could not run" +[ "$installed_version" = "hypercmd ${version#v}" ] || + fail "downloaded hypercmd has the wrong version" +mv -f "$replacement" "$executable" -echo "Installed $("$install_dir/bin/hypercmd" --version) to $install_dir/bin" +echo "Installed $installed_version to $bin_dir" + +if [ -n "${HYPERCMD_BIN:-}" ]; then + exit 0 +fi case ":$PATH:" in - *":$install_dir/bin:"*) ;; + *":$bin_dir:"*) ;; *) echo echo "Add hypercmd to your PATH, for example in ~/.zshrc or ~/.bashrc:" - echo " export PATH=\"$install_dir/bin:\$PATH\"" + echo " export PATH=\"$bin_dir:\$PATH\"" ;; esac diff --git a/justfile b/justfile index cec52c0..cb03f5d 100644 --- a/justfile +++ b/justfile @@ -6,6 +6,7 @@ check: lint consumer cli packages msrv landing-check docs-check # A new app from the CLI must check cleanly against this checkout. cli: cargo run -p hypercmd-cli --locked -- new "$(mktemp -d)/starter" --hypercmd-path . + node scripts/upgrade.mjs lint: cargo fmt --all -- --check @@ -93,7 +94,7 @@ setup-browser: rustup target add wasm32-unknown-unknown rustup target add --toolchain 1.85 wasm32-unknown-unknown cargo install wasm-bindgen-cli --version 0.2.117 --locked - cargo install fusor-cli --version 0.1.4 --locked + cargo install fusor-cli --version 0.1.5 --locked npm ci npx playwright install chromium diff --git a/scripts/packages.mjs b/scripts/packages.mjs index ef250b1..ad8d667 100644 --- a/scripts/packages.mjs +++ b/scripts/packages.mjs @@ -64,12 +64,12 @@ edition = "2024" rust-version = "1.85" [workspace] [dependencies] -hypercmd = "=0.1.1" -hypercmd-job-controls = { version = "=0.1.1", features = ["terminal"] } -fusor = { package = "fusor-core", version = "=0.1.4", default-features = false } -fusor-components = { version = "=0.1.4", default-features = false } +hypercmd = "=0.1.2" +hypercmd-job-controls = { version = "=0.1.2", features = ["terminal"] } +fusor = { package = "fusor-core", version = "=0.1.5", default-features = false } +fusor-components = { version = "=0.1.5", default-features = false } [build-dependencies] -hypercmd-build = "=0.1.1" +hypercmd-build = "=0.1.2" [package.metadata.hypercmd] entry = "ui/app.html" `); diff --git a/scripts/upgrade.mjs b/scripts/upgrade.mjs new file mode 100644 index 0000000..d78915a --- /dev/null +++ b/scripts/upgrade.mjs @@ -0,0 +1,196 @@ +import assert from 'node:assert/strict'; +import { spawn } from 'node:child_process'; +import { createHash } from 'node:crypto'; +import { once } from 'node:events'; +import { copyFileSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, realpathSync, + rmSync, symlinkSync, writeFileSync } from 'node:fs'; +import { createServer } from 'node:http'; +import { tmpdir } from 'node:os'; +import { basename, dirname, join, resolve } from 'node:path'; +import { pathToFileURL } from 'node:url'; + +const root = resolve(import.meta.dirname, '..'); +const work = realpathSync(mkdtempSync(join(tmpdir(), 'hypercmd-upgrade-'))); +const installer = join(root, 'install.sh'); +const binary = join(root, 'target/debug/hypercmd'); +const previousVersion = '0.0.0'; +const installed = join(work, 'custom location/bin/hypercmd'); +const environment = { ...process.env, XDG_CACHE_HOME: join(work, 'cache'), + HYPERCMD_INSTALL: join(work, 'default'), + HYPERCMD_DOWNLOAD_BASE: pathToFileURL(join(work, 'releases')).href }; +delete environment.CI; +delete environment.HYPERCMD_BIN; +let release; +let requests = 0; +let responseStatus = 200; +const server = createServer((request, response) => { + requests += 1; + response.writeHead(responseStatus, { 'Content-Type': 'application/json' }); + response.end(JSON.stringify(release)); +}); + +function run(command, args, env = environment, expectedStatus = 0) { + return new Promise((resolve, reject) => { + const child = spawn(command, args, { cwd: root, env, stdio: ['ignore', 'pipe', 'pipe'] }); + let stdout = ''; + let stderr = ''; + child.stdout.on('data', bytes => { stdout += bytes; }); + child.stderr.on('data', bytes => { stderr += bytes; }); + child.on('error', reject); + child.on('close', status => { + try { + assert.equal(status, expectedStatus, `${command} ${args.join(' ')}\n${stdout}\n${stderr}`); + resolve({ stdout, stderr }); + } catch (error) { reject(error); } + }); + }); +} + +async function previousBinary(packageMetadata) { + const dependencies = packageMetadata.dependencies + .map(dependency => { + const fields = { version: dependency.req, package: dependency.name, + 'default-features': dependency.uses_default_features, features: dependency.features }; + if (dependency.path) fields.path = dependency.path; + const entries = Object.entries(fields) + .map(([name, value]) => `${name} = ${JSON.stringify(value)}`); + return `${dependency.rename ?? dependency.name} = { ${entries.join(', ')} }`; + }).join('\n'); + const manifest = join(work, 'Cargo.toml'); + writeFileSync(manifest, `[package] +name = "${packageMetadata.name}" +version = "${previousVersion}" +edition = "${packageMetadata.edition}" +repository = "${packageMetadata.repository}" +[workspace] +[[bin]] +name = "hypercmd-previous" +path = ${JSON.stringify(join(root, 'crates/hypercmd-cli/src/main.rs'))} +[[bin]] +name = "hypercmd-terminal" +path = ${JSON.stringify(join(root, 'tests/support/terminal-command.rs'))} +[dependencies] +${dependencies} +`); + await run('cargo', ['build', '--offline', '--manifest-path', manifest, + '--target-dir', join(root, 'target')]); + return join(root, 'target/debug/hypercmd-previous'); +} + +async function archive(version) { + const name = (await run('sh', [installer, '--archive', version])).stdout.trim(); + const directory = join(work, 'releases', `v${version}`); + const member = name.slice(0, -'.tar.gz'.length); + mkdirSync(join(directory, member), { recursive: true }); + copyFileSync(binary, join(directory, member, 'hypercmd')); + const path = join(directory, name); + await run('tar', ['-czf', path, '-C', directory, member]); + const checksum = createHash('sha256').update(readFileSync(path)).digest('hex'); + writeFileSync(`${path}.sha256`, `${checksum} ${name}\n`); + return { path, release: { tag_name: `v${version}`, draft: false, prerelease: false, + assets: [basename(installer), name, `${name}.sha256`].map(name => ({ name })) } }; +} + +try { + server.listen(0, '127.0.0.1'); + await once(server, 'listening'); + environment.HYPERCMD_RELEASE_URL = `http://127.0.0.1:${server.address().port}/latest`; + const metadata = JSON.parse((await run('cargo', + ['metadata', '--no-deps', '--format-version=1'])).stdout); + const packageMetadata = metadata.packages + .find(packageMetadata => packageMetadata.name === 'hypercmd-cli'); + const previous = await previousBinary(packageMetadata); + const current = await archive(packageMetadata.version); + const bootstrap = join(work, 'bootstrap'); + await run('sh', [installer, packageMetadata.version], { + ...environment, HYPERCMD_INSTALL: bootstrap, + }); + assert.deepEqual(readFileSync(join(bootstrap, 'bin/hypercmd')), readFileSync(binary)); + release = current.release; + mkdirSync(dirname(installed), { recursive: true }); + mkdirSync(join(environment.HYPERCMD_INSTALL, 'bin'), { recursive: true }); + const otherInstallation = join(environment.HYPERCMD_INSTALL, 'bin/hypercmd'); + writeFileSync(otherInstallation, 'another installation'); + copyFileSync(previous, installed); + const link = join(work, 'hypercmd'); + symlinkSync(installed, link); + await run(link, ['upgrade']); + assert.deepEqual(readFileSync(installed), readFileSync(binary)); + assert.equal(readFileSync(otherInstallation, 'utf8'), 'another installation'); + assert.deepEqual(readdirSync(dirname(installed)), ['hypercmd']); + + for (const version of [packageMetadata.version, previousVersion]) { + release = { ...current.release, tag_name: `v${version}`, assets: [] }; + const output = await run(installed, ['upgrade']); + assert.equal(output.stdout, `hypercmd ${packageMetadata.version} is already up to date.\n`); + assert.deepEqual(readFileSync(installed), readFileSync(binary)); + } + + const wrongVersion = await archive('99.0.0'); + const checksum = readFileSync(`${current.path}.sha256`); + const failures = [ + { release: { ...current.release, assets: [] }, message: 'still being published' }, + { release: { ...current.release, prerelease: true }, message: 'not stable' }, + { release: wrongVersion.release, message: 'wrong version' }, + { release: current.release, checksum: 'invalid\n', message: 'checksum mismatch' }, + ]; + for (const failure of failures) { + copyFileSync(previous, installed); + release = failure.release; + writeFileSync(`${current.path}.sha256`, failure.checksum ?? checksum); + const output = await run(installed, ['upgrade'], environment, 1); + assert(output.stderr.includes(failure.message), output.stderr); + assert.deepEqual(readFileSync(installed), readFileSync(previous)); + assert.deepEqual(readdirSync(dirname(installed)), ['hypercmd']); + } + + const cargoRoot = join(work, 'cargo-installation'); + await run('cargo', ['install', '--path', work, '--bin', 'hypercmd-previous', + '--root', cargoRoot, '--offline', '--debug', '--target-dir', join(root, 'target')]); + const cargoBinary = join(cargoRoot, 'bin/hypercmd-previous'); + release = wrongVersion.release; + const cargoFailure = await run(cargoBinary, ['upgrade'], { + ...environment, CARGO_HOME: join(work, 'empty-cargo-home'), CARGO_NET_OFFLINE: 'true', + }, 1); + assert.match(cargoFailure.stderr, /upgrade failed \(exit status: 101\)/); + assert.deepEqual(readFileSync(cargoBinary), readFileSync(previous)); + + release = current.release; + requests = 0; + const terminal = join(root, 'target/debug/hypercmd-terminal'); + const warning = `⚠️ New version available: ${previousVersion} → ${packageMetadata.version}. ` + + 'Run hypercmd upgrade'; + const checks = ['--offline', '--frozen'].map(mode => + ['check', mode, '--manifest-path', join(root, 'crates/hypercmd-cli/Cargo.toml')]); + // Compile before entering the PTY helper's short exit deadline. + await run(installed, checks[0]); + for (const args of [['--help'], ['--version'], ...checks]) { + assert.equal((await run(terminal, [installed, ...args])).stdout.includes(warning), false); + } + const continuousIntegration = await run(terminal, + [installed, 'profile'], { ...environment, CI: '1' }); + assert.equal(continuousIntegration.stdout.includes(warning), false); + assert.equal((await run(installed, ['profile'])).stderr, ''); + assert.equal(requests, 0); + for (let invocation = 0; invocation < 2; invocation += 1) { + const output = await run(terminal, [installed, 'profile']); + assert(output.stdout.replaceAll('\r', '').startsWith(`${warning}\n`), output.stdout); + assert.equal(requests, 1); + } + copyFileSync(binary, installed); + assert.equal((await run(terminal, [installed, 'profile'])).stdout.includes(warning), false); + assert.equal(requests, 1); + + copyFileSync(previous, installed); + responseStatus = 503; + const offline = { ...environment, XDG_CACHE_HOME: join(work, 'offline-cache') }; + for (let invocation = 0; invocation < 2; invocation += 1) { + const output = await run(terminal, [installed, 'profile'], offline); + assert.equal(output.stdout.includes(warning), false); + assert.equal(requests, 2); + } + console.log('CLI replacement, failed upgrades, ordering and cached terminal warnings passed.'); +} finally { + server.close(); + rmSync(work, { recursive: true, force: true }); +} diff --git a/tests/browser-consumer/Cargo.lock b/tests/browser-consumer/Cargo.lock index 603ea3a..45d136f 100644 --- a/tests/browser-consumer/Cargo.lock +++ b/tests/browser-consumer/Cargo.lock @@ -180,9 +180,9 @@ dependencies = [ [[package]] name = "fusor-async" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "804497a690960b93fe23366f41f968d923e60e9025eee19180e9d63f2a7d70d2" +checksum = "646fff2a46bb22563d2803c7bb2d47d606a63b4d1ae087a17e88535271ec5739" dependencies = [ "derive-where", "fusor-core", @@ -191,9 +191,9 @@ dependencies = [ [[package]] name = "fusor-build" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61e853f1efe0a7a43a69c1b0ba429a65e3fb2b059a9839522bea725452a325d5" +checksum = "9519b7630353b2f0d12255e4a94a102b0ab0d973623b138a5a6b4d8d8744d6b5" dependencies = [ "fusor-core", "fusor-islands", @@ -210,18 +210,18 @@ dependencies = [ [[package]] name = "fusor-components" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ff376904a2eadb6a540744719429734482d2e736a0773377d9853fe170613f5" +checksum = "b2fccd168a90d8d305d3c1cbcd5240cbf6c7642bd7e6d1cad82cd25be5f0a2d6" dependencies = [ "fusor-core", ] [[package]] name = "fusor-core" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36cc8392e17b5eea5f45606a51bb8736042bd19175f20fb63ee82fc1787561eb" +checksum = "99e9a5d9f8a49db0ed7132c1c8061c16797a97ec1fdfac621b25e39fa24d1c7c" dependencies = [ "fusor-macros", "js-sys", @@ -231,9 +231,9 @@ dependencies = [ [[package]] name = "fusor-islands" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09040f3dfaa95e41e54a4ba1005a88e017910b0eceee4e700c5f04be3c47ce22" +checksum = "74305bb3cb2e04df2c6ba06e13cbe536aca92046e61377eee4142e8dfd2eddd8" dependencies = [ "fusor-core", "serde", @@ -242,9 +242,9 @@ dependencies = [ [[package]] name = "fusor-macros" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebdbd0919aeab94a1589b0952a9711e7d46aab3123a0c2c02ba3b0683d814490" +checksum = "7116a1002c31d1027dd6da5844b8133b5d81c098c6720567c5cd8b8f8e5245d8" dependencies = [ "proc-macro2", "quote", @@ -253,9 +253,9 @@ dependencies = [ [[package]] name = "fusor-router" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1cbb73da8ceba9583442a661d65d9d1256ee2863a55ee1ec95f8e5d4b4507070" +checksum = "e86cf63dfe536faf9cb7b4d7ecfd0f3da3abaf005e9551889be82c4ea64982d9" dependencies = [ "form_urlencoded", "fusor-core", @@ -342,7 +342,7 @@ checksum = "428502d3ec1742c35e015871aef742bc4722a9acfcb616b8ff79b519922e1c36" [[package]] name = "hypercmd" -version = "0.1.1" +version = "0.1.2" dependencies = [ "fusor-async", "fusor-core", @@ -371,7 +371,7 @@ dependencies = [ [[package]] name = "hypercmd-build" -version = "0.1.1" +version = "0.1.2" dependencies = [ "fusor-build", "proc-macro2", @@ -383,7 +383,7 @@ dependencies = [ [[package]] name = "hypercmd-job-controls" -version = "0.1.1" +version = "0.1.2" dependencies = [ "fusor-build", "fusor-components", diff --git a/tests/browser-consumer/Cargo.toml b/tests/browser-consumer/Cargo.toml index 18732ba..72622e8 100644 --- a/tests/browser-consumer/Cargo.toml +++ b/tests/browser-consumer/Cargo.toml @@ -11,13 +11,13 @@ crate-type = ["cdylib", "rlib"] [dependencies] hypercmd-job-controls = { path = "../../examples/job-controls", features = ["terminal", "browser"] } -fusor = { package = "fusor-core", version = "=0.1.4", default-features = false, features = ["dom"] } -fusor-components = { version = "=0.1.4", default-features = false, features = ["browser"] } +fusor = { package = "fusor-core", version = "=0.1.5", default-features = false, features = ["dom"] } +fusor-components = { version = "=0.1.5", default-features = false, features = ["browser"] } wasm-bindgen = "=0.2.117" web-sys = { version = "=0.3.94", features = ["Window", "Document", "Element", "HtmlHeadElement"] } [build-dependencies] -fusor-build = { version = "=0.1.4" } +fusor-build = { version = "=0.1.5" } [package.metadata.fusor] entry = "web/index.html" diff --git a/tests/browser-consumer/build.rs b/tests/browser-consumer/build.rs index caf0236..94e5785 100644 --- a/tests/browser-consumer/build.rs +++ b/tests/browser-consumer/build.rs @@ -1,3 +1,3 @@ -fn main() -> Result<(), Box> { +fn main() -> Result<(), fusor_build::BuildError> { fusor_build::compile_app() } diff --git a/tests/browser-consumer/src/lib.rs b/tests/browser-consumer/src/lib.rs index 591de2a..a3e4161 100644 --- a/tests/browser-consumer/src/lib.rs +++ b/tests/browser-consumer/src/lib.rs @@ -35,7 +35,7 @@ impl App { clippy::too_many_lines, clippy::excessive_nesting, clippy::redundant_clone, - reason = "fusor-build 0.1.4's DOM codegen leaves these unsuppressed in generated mount code" + reason = "fusor-build 0.1.5's DOM codegen leaves these unsuppressed in generated mount code" )] mod dom { use super::App; diff --git a/tests/consumer/Cargo.lock b/tests/consumer/Cargo.lock index f9f765f..f58a2c9 100644 --- a/tests/consumer/Cargo.lock +++ b/tests/consumer/Cargo.lock @@ -180,9 +180,9 @@ dependencies = [ [[package]] name = "fusor-async" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "804497a690960b93fe23366f41f968d923e60e9025eee19180e9d63f2a7d70d2" +checksum = "646fff2a46bb22563d2803c7bb2d47d606a63b4d1ae087a17e88535271ec5739" dependencies = [ "derive-where", "fusor-core", @@ -191,9 +191,9 @@ dependencies = [ [[package]] name = "fusor-build" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61e853f1efe0a7a43a69c1b0ba429a65e3fb2b059a9839522bea725452a325d5" +checksum = "9519b7630353b2f0d12255e4a94a102b0ab0d973623b138a5a6b4d8d8744d6b5" dependencies = [ "fusor-core", "fusor-islands", @@ -210,27 +210,27 @@ dependencies = [ [[package]] name = "fusor-components" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ff376904a2eadb6a540744719429734482d2e736a0773377d9853fe170613f5" +checksum = "b2fccd168a90d8d305d3c1cbcd5240cbf6c7642bd7e6d1cad82cd25be5f0a2d6" dependencies = [ "fusor-core", ] [[package]] name = "fusor-core" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36cc8392e17b5eea5f45606a51bb8736042bd19175f20fb63ee82fc1787561eb" +checksum = "99e9a5d9f8a49db0ed7132c1c8061c16797a97ec1fdfac621b25e39fa24d1c7c" dependencies = [ "fusor-macros", ] [[package]] name = "fusor-islands" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09040f3dfaa95e41e54a4ba1005a88e017910b0eceee4e700c5f04be3c47ce22" +checksum = "74305bb3cb2e04df2c6ba06e13cbe536aca92046e61377eee4142e8dfd2eddd8" dependencies = [ "fusor-core", "serde", @@ -239,9 +239,9 @@ dependencies = [ [[package]] name = "fusor-macros" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebdbd0919aeab94a1589b0952a9711e7d46aab3123a0c2c02ba3b0683d814490" +checksum = "7116a1002c31d1027dd6da5844b8133b5d81c098c6720567c5cd8b8f8e5245d8" dependencies = [ "proc-macro2", "quote", @@ -250,9 +250,9 @@ dependencies = [ [[package]] name = "fusor-router" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1cbb73da8ceba9583442a661d65d9d1256ee2863a55ee1ec95f8e5d4b4507070" +checksum = "e86cf63dfe536faf9cb7b4d7ecfd0f3da3abaf005e9551889be82c4ea64982d9" dependencies = [ "form_urlencoded", "fusor-core", @@ -261,18 +261,18 @@ dependencies = [ [[package]] name = "fusor-std" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b92758fea275f6c2a972f92f011b28f113f29b982656a7cf31f464899268d9c" +checksum = "0cc9a2eec0f4da5126a900f509bfa2f507092817ff084876a154d3761608a398" dependencies = [ "fusor-core", ] [[package]] name = "fusor-test" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99f64fd86b203c7a0ea4ee44565695a2db649ab2b04ab812cd96f34a062377d8" +checksum = "a45bac1be3b65745acb2d2f5defa798ba142e63217ccee7931085d5eecd76762" dependencies = [ "fusor-async", "fusor-core", @@ -372,7 +372,7 @@ checksum = "428502d3ec1742c35e015871aef742bc4722a9acfcb616b8ff79b519922e1c36" [[package]] name = "hypercmd" -version = "0.1.1" +version = "0.1.2" dependencies = [ "fusor-async", "fusor-core", @@ -389,7 +389,7 @@ dependencies = [ [[package]] name = "hypercmd-build" -version = "0.1.1" +version = "0.1.2" dependencies = [ "fusor-build", "proc-macro2", diff --git a/tests/consumer/Cargo.toml b/tests/consumer/Cargo.toml index 65ae3d9..8b468bc 100644 --- a/tests/consumer/Cargo.toml +++ b/tests/consumer/Cargo.toml @@ -13,15 +13,15 @@ styles = ["ui/terminal.css"] [dependencies] hypercmd = { path = "../../crates/hypercmd", default-features = false } -fusor = { package = "fusor-core", version = "=0.1.4", default-features = false, features = ["derive"] } -fusor-components = { version = "=0.1.4", default-features = false } -fusor-router = { version = "=0.1.4", default-features = false } -fusor-async = { version = "=0.1.4", default-features = false } +fusor = { package = "fusor-core", version = "=0.1.5", default-features = false, features = ["derive"] } +fusor-components = { version = "=0.1.5", default-features = false } +fusor-router = { version = "=0.1.5", default-features = false } +fusor-async = { version = "=0.1.5", default-features = false } -fusor-std = { version = "=0.1.4", default-features = false, features = ["forms"] } +fusor-std = { version = "=0.1.5", default-features = false, features = ["forms"] } [dev-dependencies] -fusor-test = { version = "=0.1.4", default-features = false } +fusor-test = { version = "=0.1.5", default-features = false } [build-dependencies] hypercmd-build = { path = "../../crates/hypercmd-build" } diff --git a/tests/support/terminal-command.rs b/tests/support/terminal-command.rs new file mode 100644 index 0000000..0d5f811 --- /dev/null +++ b/tests/support/terminal-command.rs @@ -0,0 +1,16 @@ +pub mod pty; + +use portable_pty::{CommandBuilder, PtySize}; +use std::{env, io, io::Write}; + +fn main() -> Result<(), Box> { + let mut arguments = env::args_os().skip(1); + let executable = arguments.next().ok_or("expected a command to run")?; + let mut command = CommandBuilder::new(executable); + command.args(arguments); + let size = PtySize::default(); + let mut terminal = pty::Terminal::spawn(command, size.rows, size.cols); + terminal.wait_exit(); + io::stdout().write_all(&terminal.transcript)?; + Ok(()) +}