diff --git a/bin/build-npm-bin-packages b/bin/build-npm-bin-packages index 3b3d279f..b5a977b0 100755 --- a/bin/build-npm-bin-packages +++ b/bin/build-npm-bin-packages @@ -1,6 +1,6 @@ #!/usr/bin/env bash # Repackage release artifacts into npm packages: one data-only package per -# platform (blit-bin--[-musl]) plus the blit-bin launcher that +# platform (@blit-sh/bin--[-musl]) plus the @blit-sh/bin launcher that # depends on them as optionalDependencies. # # Usage: build-npm-bin-packages [version] @@ -92,8 +92,8 @@ JSON Prebuilt \`blit\` binary for $desc. -This is a platform-specific dependency of [\`blit-bin\`](https://www.npmjs.com/package/blit-bin); -install \`blit-bin\` instead. See . +This is a platform-specific dependency of [\`@blit-sh/bin\`](https://www.npmjs.com/package/@blit-sh/bin); +install \`@blit-sh/bin\` instead. See . MD pkg_names+=("$name") @@ -133,11 +133,11 @@ process_tarball() { case "$os" in linux) - write_platform_pkg "blit-bin-linux-$cpu" linux "$cpu" glibc blit "$bin" "Linux $arch (glibc)" ;; + write_platform_pkg "@blit-sh/bin-linux-$cpu" linux "$cpu" glibc blit "$bin" "Linux $arch (glibc)" ;; linux-musl) - write_platform_pkg "blit-bin-linux-$cpu-musl" linux "$cpu" musl blit "$bin" "Linux $arch (musl)" ;; + write_platform_pkg "@blit-sh/bin-linux-$cpu-musl" linux "$cpu" musl blit "$bin" "Linux $arch (musl)" ;; darwin) - write_platform_pkg "blit-bin-darwin-$cpu" darwin "$cpu" "" blit "$bin" "macOS $arch" ;; + write_platform_pkg "@blit-sh/bin-darwin-$cpu" darwin "$cpu" "" blit "$bin" "macOS $arch" ;; *) echo "error: unknown os '$os' in $f" >&2; exit 1 ;; esac rm -rf "$tmp" @@ -163,7 +163,7 @@ process_zip() { aarch64) cpu="arm64" ;; *) echo "error: unknown arch '$arch' in $f" >&2; exit 1 ;; esac - write_platform_pkg "blit-bin-win32-$cpu" win32 "$cpu" "" blit.exe "$bin" "Windows $arch" + write_platform_pkg "@blit-sh/bin-win32-$cpu" win32 "$cpu" "" blit.exe "$bin" "Windows $arch" rm -rf "$tmp" } @@ -190,9 +190,9 @@ fi # De-duplicate package names (glob fallbacks may match twice). mapfile -t pkg_names < <(printf '%s\n' "${pkg_names[@]}" | sort -u) -# --- Launcher package (blit-bin) --- -launcher_src="$repo_root/npm/blit-bin" -launcher_out="$out_dir/blit-bin" +# --- Launcher package (@blit-sh/bin) --- +launcher_src="$repo_root/npm/bin" +launcher_out="$out_dir/@blit-sh/bin" rm -rf "$launcher_out" mkdir -p "$launcher_out/bin" for f in index.js index.mjs index.d.ts resolve.js resolve.d.ts README.md; do @@ -209,14 +209,14 @@ done cat > "$launcher_out/package.json" < "$launcher_out/package.json" <=18" } } JSON -echo " generated blit-bin launcher (optionalDependencies: ${pkg_names[*]})" +echo " generated @blit-sh/bin launcher (optionalDependencies: ${pkg_names[*]})" # Emit a publish order manifest: platform packages first, launcher last. { for name in "${pkg_names[@]}"; do echo "$name"; done - echo "blit-bin" + echo "@blit-sh/bin" } > "$out_dir/.publish-order" echo "" diff --git a/bin/publish-npm-bin-packages b/bin/publish-npm-bin-packages index c44f6c2e..27e2d4d8 100755 --- a/bin/publish-npm-bin-packages +++ b/bin/publish-npm-bin-packages @@ -1,6 +1,6 @@ #!/usr/bin/env bash -# Publish the generated blit-bin npm packages (platform packages first, then -# the blit-bin launcher last so optionalDependencies resolve on install). +# Publish the generated @blit-sh/bin npm packages (platform packages first, then +# the @blit-sh/bin launcher last so optionalDependencies resolve on install). # # Usage: publish-npm-bin-packages [extra npm publish args...] # e.g. publish-npm-bin-packages dist/npm-bin --provenance --access public diff --git a/npm/blit-bin/README.md b/npm/bin/README.md similarity index 76% rename from npm/blit-bin/README.md rename to npm/bin/README.md index af44be2b..514436d2 100644 --- a/npm/blit-bin/README.md +++ b/npm/bin/README.md @@ -1,13 +1,13 @@ -# blit-bin +# @blit-sh/bin -The [blit](https://blit.sh) binary, distributed via npm. Installing `blit-bin` +The [blit](https://blit.sh) binary, distributed via npm. Installing `@blit-sh/bin` pulls in exactly one prebuilt package for your platform -(`blit-bin--[-musl]`) through optional dependencies — nothing else. +(`@blit-sh/bin--[-musl]`) through optional dependencies — nothing else. ## CLI ```sh -npm i -g blit-bin +npm i -g @blit-sh/bin blit open ``` @@ -20,7 +20,7 @@ actionable message if the matching prebuilt package was not installed. ### ESM ```js -import blit from "blit-bin"; +import blit from "@blit-sh/bin"; import { spawn } from "node:child_process"; spawn(blit, ["open"], { stdio: "inherit" }); @@ -29,7 +29,7 @@ spawn(blit, ["open"], { stdio: "inherit" }); ### CommonJS ```js -const blit = require("blit-bin"); +const blit = require("@blit-sh/bin"); const { spawn } = require("node:child_process"); spawn(blit, ["open"], { stdio: "inherit" }); @@ -37,12 +37,17 @@ spawn(blit, ["open"], { stdio: "inherit" }); ### Helpers -Lower-level resolution helpers are available on the `blit-bin/resolve` subpath +Lower-level resolution helpers are available on the `@blit-sh/bin/resolve` subpath (and as named exports of the main entry): ```js -import { binaryPath, binaryName, candidatePackages, isMusl } from "blit-bin"; -// or: import { binaryPath } from "blit-bin/resolve"; +import { + binaryPath, + binaryName, + candidatePackages, + isMusl, +} from "@blit-sh/bin"; +// or: import { binaryPath } from "@blit-sh/bin/resolve"; ``` | export | description | diff --git a/npm/blit-bin/bin/blit.js b/npm/bin/bin/blit.js similarity index 89% rename from npm/blit-bin/bin/blit.js rename to npm/bin/bin/blit.js index 44c705cd..3e00852b 100644 --- a/npm/blit-bin/bin/blit.js +++ b/npm/bin/bin/blit.js @@ -16,7 +16,7 @@ const result = spawnSync(bin, process.argv.slice(2), { stdio: "inherit" }); if (result.error) { process.stderr.write( - `blit-bin: failed to launch ${bin}: ${result.error.message}\n`, + `@blit-sh/bin: failed to launch ${bin}: ${result.error.message}\n`, ); process.exit(1); } diff --git a/npm/blit-bin/index.d.ts b/npm/bin/index.d.ts similarity index 95% rename from npm/blit-bin/index.d.ts rename to npm/bin/index.d.ts index c1fca808..ba0e9d9e 100644 --- a/npm/blit-bin/index.d.ts +++ b/npm/bin/index.d.ts @@ -4,7 +4,7 @@ * is installed. * * @example - * import blit from "blit-bin"; + * import blit from "@blit-sh/bin"; * import { spawn } from "node:child_process"; * spawn(blit, ["open"], { stdio: "inherit" }); */ diff --git a/npm/blit-bin/index.js b/npm/bin/index.js similarity index 75% rename from npm/blit-bin/index.js rename to npm/bin/index.js index 5fd08ff0..e9754d1a 100644 --- a/npm/blit-bin/index.js +++ b/npm/bin/index.js @@ -3,9 +3,9 @@ // Default (CommonJS) export: the absolute filesystem path to the prebuilt // `blit` executable for the current platform. // -// const blit = require("blit-bin"); +// const blit = require("@blit-sh/bin"); // require("child_process").spawn(blit, ["open"], { stdio: "inherit" }); // // Throws at require time with an actionable message if no matching prebuilt -// package is installed. Named helpers live on `blit-bin/resolve`. +// package is installed. Named helpers live on `@blit-sh/bin/resolve`. module.exports = require("./resolve.js").binaryPath(); diff --git a/npm/blit-bin/index.mjs b/npm/bin/index.mjs similarity index 93% rename from npm/blit-bin/index.mjs rename to npm/bin/index.mjs index 0f7ac6fd..0f721328 100644 --- a/npm/blit-bin/index.mjs +++ b/npm/bin/index.mjs @@ -1,7 +1,7 @@ // ESM entry point. Default export is the absolute path to the platform `blit` // binary; named exports expose the resolution helpers. // -// import blit from "blit-bin"; +// import blit from "@blit-sh/bin"; // import { spawn } from "node:child_process"; // spawn(blit, ["open"], { stdio: "inherit" }); import resolve from "./resolve.js"; diff --git a/npm/blit-bin/package.json b/npm/bin/package.json similarity index 95% rename from npm/blit-bin/package.json rename to npm/bin/package.json index 0523060d..a9068a34 100644 --- a/npm/blit-bin/package.json +++ b/npm/bin/package.json @@ -1,5 +1,5 @@ { - "name": "blit-bin", + "name": "@blit-sh/bin", "version": "0.0.0", "description": "Installs the prebuilt blit binary for your platform; default export is the binary path.", "keywords": [ @@ -15,7 +15,7 @@ "repository": { "type": "git", "url": "git+https://github.com/indent-com/blit.git", - "directory": "npm/blit-bin" + "directory": "npm/bin" }, "bugs": { "url": "https://github.com/indent-com/blit/issues" diff --git a/npm/blit-bin/resolve.d.ts b/npm/bin/resolve.d.ts similarity index 100% rename from npm/blit-bin/resolve.d.ts rename to npm/bin/resolve.d.ts diff --git a/npm/blit-bin/resolve.js b/npm/bin/resolve.js similarity index 84% rename from npm/blit-bin/resolve.js rename to npm/bin/resolve.js index f5b7a9ee..eb7def3a 100644 --- a/npm/blit-bin/resolve.js +++ b/npm/bin/resolve.js @@ -1,6 +1,6 @@ "use strict"; -// Platform binary resolution for blit-bin. Mirrors the release artifact matrix +// Platform binary resolution for @blit-sh/bin. Mirrors the release artifact matrix // (see bin/build-npm-bin-packages). Kept separate from the public entry points // (index.js / index.mjs) so the CLI and both module systems share one copy. @@ -10,10 +10,10 @@ const fs = require("fs"); function candidatePackages() { const platform = process.platform; const arch = process.arch; - if (platform === "win32") return [`blit-bin-win32-${arch}`]; - if (platform === "darwin") return [`blit-bin-darwin-${arch}`]; + if (platform === "win32") return [`@blit-sh/bin-win32-${arch}`]; + if (platform === "darwin") return [`@blit-sh/bin-darwin-${arch}`]; if (platform === "linux") { - const base = `blit-bin-linux-${arch}`; + const base = `@blit-sh/bin-linux-${arch}`; // Prefer the libc variant we detect, but fall back to the other. return isMusl() ? [`${base}-musl`, base] : [base, `${base}-musl`]; } @@ -59,7 +59,7 @@ function binaryPath() { } throw new Error( [ - `blit-bin: no prebuilt binary found for ${process.platform} ${process.arch}.`, + `@blit-sh/bin: no prebuilt binary found for ${process.platform} ${process.arch}.`, tried.length ? `Tried optional packages: ${tried.join(", ")}.` : "", "Supported: linux x64/arm64 (glibc & musl), darwin arm64, win32 x64.", "If your platform is supported, ensure optional dependencies were not",