Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions bin/build-npm-bin-packages
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
# Repackage release artifacts into npm packages: one data-only package per
# platform (blit-bin-<os>-<cpu>[-musl]) plus the blit-bin launcher that
# platform (@blit-sh/bin-<os>-<cpu>[-musl]) plus the @blit-sh/bin launcher that
# depends on them as optionalDependencies.
#
# Usage: build-npm-bin-packages <artifacts-dir> <out-dir> [version]
Expand Down Expand Up @@ -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 <https://blit.sh>.
This is a platform-specific dependency of [\`@blit-sh/bin\`](https://www.npmjs.com/package/@blit-sh/bin);
install \`@blit-sh/bin\` instead. See <https://blit.sh>.
MD

pkg_names+=("$name")
Expand Down Expand Up @@ -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"
Expand All @@ -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"
}

Expand All @@ -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
Expand All @@ -209,14 +209,14 @@ done

cat > "$launcher_out/package.json" <<JSON
{
"name": "blit-bin",
"name": "@blit-sh/bin",
"version": "$version",
"description": "Installs the prebuilt blit binary for your platform; default export is the binary path.",
"keywords": ["blit", "terminal", "multiplexer", "wayland", "cli"],
"homepage": "$HOMEPAGE",
"license": "$LICENSE",
"author": "$AUTHOR",
"repository": { "type": "git", "url": "$REPO_URL", "directory": "npm/blit-bin" },
"repository": { "type": "git", "url": "$REPO_URL", "directory": "npm/bin" },
"bugs": { "url": "$BUGS_URL" },
"bin": { "blit": "bin/blit.js" },
"type": "commonjs",
Expand All @@ -241,12 +241,12 @@ cat > "$launcher_out/package.json" <<JSON
"engines": { "node": ">=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 ""
Expand Down
4 changes: 2 additions & 2 deletions bin/publish-npm-bin-packages
Original file line number Diff line number Diff line change
@@ -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 <packages-dir> [extra npm publish args...]
# e.g. publish-npm-bin-packages dist/npm-bin --provenance --access public
Expand Down
23 changes: 14 additions & 9 deletions npm/blit-bin/README.md → npm/bin/README.md
Original file line number Diff line number Diff line change
@@ -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-<os>-<cpu>[-musl]`) through optional dependencies — nothing else.
(`@blit-sh/bin-<os>-<cpu>[-musl]`) through optional dependencies — nothing else.

## CLI

```sh
npm i -g blit-bin
npm i -g @blit-sh/bin
blit open
```

Expand All @@ -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" });
Expand All @@ -29,20 +29,25 @@ 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" });
```

### 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 |
Expand Down
2 changes: 1 addition & 1 deletion npm/blit-bin/bin/blit.js → npm/bin/bin/blit.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion npm/blit-bin/index.d.ts → npm/bin/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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" });
*/
Expand Down
4 changes: 2 additions & 2 deletions npm/blit-bin/index.js → npm/bin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
2 changes: 1 addition & 1 deletion npm/blit-bin/index.mjs → npm/bin/index.mjs
Original file line number Diff line number Diff line change
@@ -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";
Expand Down
4 changes: 2 additions & 2 deletions npm/blit-bin/package.json → npm/bin/package.json
Original file line number Diff line number Diff line change
@@ -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": [
Expand All @@ -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"
Expand Down
File renamed without changes.
10 changes: 5 additions & 5 deletions npm/blit-bin/resolve.js → npm/bin/resolve.js
Original file line number Diff line number Diff line change
@@ -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.

Expand All @@ -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`];
}
Expand Down Expand Up @@ -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",
Expand Down
Loading