Files
codewhale/npm/codewhale/scripts/artifacts.js
T
Hunter Bown 23daefbe24 feat(npm): publish as codewhale; keep deepseek-tui as deprecation shim
Rename the npm wrapper directory and package from `deepseek-tui` to
`codewhale`. Move under `npm/codewhale/`:
  - `package.json` renamed (name, bin, internal field) — keeps a
    `deepseekBinaryVersion` fallback so old metadata still works.
  - Bin entry points renamed to `bin/codewhale.js` and
    `bin/codewhale-tui.js`; they spawn the corresponding canonical
    binaries via the wrapper.
  - `scripts/artifacts.js` switches to the canonical asset-name matrix
    (`codewhale-*`, `codewhale-tui-*`) and `codewhale-artifacts-sha256.txt`.
  - `scripts/run.js` exports `runCodewhale` and `runCodewhaleTui`; the
    legacy `runDeepseek` exports are gone since nothing else inside the
    package depended on them.
  - `scripts/install.js`, `verify-release-assets.js`, `preflight-glibc.js`
    update brand-mention strings + User-Agent headers. Env vars
    (`DEEPSEEK_TUI_*`, `DEEPSEEK_*`) are explicitly anti-scope and are
    left in place.
  - Tests retargeted at the canonical asset names; all 19 still pass.
  - README rewritten with the new install command and a deprecation
    note about the old package.

Create a one-release deprecation shim at `npm/deepseek-tui/`:
  - `package.json` with no `bin`, just a postinstall script that
    prints a clear message telling the user to install `codewhale`
    instead.
  - `README.md` with the same migration note.
  - Will be removed in v0.9.0 (or whenever Hunter retires the shims).

Release-side scripts in `scripts/release/` follow the rename:
  - `prepare-local-release-assets.js` now requires `npm/codewhale/...`
    and copies the canonical `codewhale*` binaries.
  - `npm-wrapper-smoke.js` smokes the renamed package.
  - `check-versions.sh` reads `npm/codewhale/package.json` for the
    primary check and additionally pins the legacy shim package to
    the same version.
  - `check-published.sh` queries `codewhale@<version>` (with
    `codewhaleBinaryVersion` lookup that falls back to the legacy
    `deepseekBinaryVersion` field).
  - `.github/workflows/auto-tag.yml` watches both `npm/codewhale/` and
    `npm/deepseek-tui/` package.json for auto-tag triggers.

Verified:
  - `npm test` inside `npm/codewhale/` passes 19/19.
  - `npm install --dry-run --ignore-scripts` succeeds for both
    `npm/codewhale/` and `npm/deepseek-tui/`.
  - `scripts/release/check-versions.sh` reports OK.
  - Rust gates re-run: `cargo check`, `cargo fmt --check`,
    `cargo clippy -- -D warnings`, all clean.

No `npm publish` is run from this change — Hunter publishes manually
when the rebrand is ready to ship.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-23 11:11:53 -05:00

127 lines
3.7 KiB
JavaScript

const path = require("path");
const os = require("os");
const CHECKSUM_MANIFEST = "codewhale-artifacts-sha256.txt";
const ASSET_MATRIX = {
linux: {
x64: ["codewhale-linux-x64", "codewhale-tui-linux-x64"],
arm64: ["codewhale-linux-arm64", "codewhale-tui-linux-arm64"],
},
darwin: {
x64: ["codewhale-macos-x64", "codewhale-tui-macos-x64"],
arm64: ["codewhale-macos-arm64", "codewhale-tui-macos-arm64"],
},
win32: {
x64: ["codewhale-windows-x64.exe", "codewhale-tui-windows-x64.exe"],
},
};
// HarmonyPC (openharmony) is an x86_64 Linux-compatible environment; map it to
// the linux binary family so npm install succeeds without a separate build target.
const PLATFORM_ALIASES = {
openharmony: "linux",
};
function detectBinaryNames() {
const rawPlatform = os.platform();
const platform = PLATFORM_ALIASES[rawPlatform] || rawPlatform;
const arch = os.arch();
const defaults = ASSET_MATRIX[platform];
if (!defaults) {
const supported = Object.keys(ASSET_MATRIX).map(p => `'${p}'`).join(', ');
throw new Error(
`Unsupported platform: ${rawPlatform}. Supported platforms: ${supported}.\n\n` +
unsupportedBuildHint(),
);
}
const pair = defaults[arch];
if (!pair) {
const supported = Object.keys(defaults).map(a => `'${a}'`).join(', ');
throw new Error(
`Unsupported architecture: ${arch} on platform ${platform}. ` +
`Supported architectures: ${supported}.\n\n` +
unsupportedBuildHint(),
);
}
return {
platform,
arch,
codewhale: pair[0],
tui: pair[1],
};
}
function unsupportedBuildHint() {
return [
"No prebuilt binary is available for this platform/architecture combo.",
"You can still run codewhale by building from source with Cargo:",
"",
" # Requires Rust 1.88+ (https://rustup.rs)",
" cargo install codewhale-cli --locked # provides `codewhale`",
" cargo install codewhale-tui --locked # provides `codewhale-tui`",
"",
"Or build from a checkout:",
"",
" git clone https://github.com/Hmbown/DeepSeek-TUI.git",
" cd DeepSeek-TUI",
" cargo install --path crates/cli --locked",
" cargo install --path crates/tui --locked",
"",
"See https://github.com/Hmbown/DeepSeek-TUI/blob/main/docs/INSTALL.md",
"for cross-compilation, mirror, and Linux ARM64 specifics.",
].join("\n");
}
function executableName(base, platform) {
return platform === "win32" ? `${base}.exe` : base;
}
function releaseBaseUrl(version, repo = "Hmbown/DeepSeek-TUI") {
const override =
process.env.DEEPSEEK_TUI_RELEASE_BASE_URL || process.env.DEEPSEEK_RELEASE_BASE_URL;
if (override) {
const trimmed = String(override).trim();
return trimmed.endsWith("/") ? trimmed : `${trimmed}/`;
}
return `https://github.com/${repo}/releases/download/v${version}/`;
}
function releaseAssetUrl(baseName, version, repo = "Hmbown/DeepSeek-TUI") {
return new URL(baseName, releaseBaseUrl(version, repo)).toString();
}
function checksumManifestUrl(version, repo = "Hmbown/DeepSeek-TUI") {
return releaseAssetUrl(CHECKSUM_MANIFEST, version, repo);
}
function releaseBinaryDirectory() {
return path.join(__dirname, "..", "bin", "downloads");
}
function allAssetNames() {
const names = [];
for (const platformAssets of Object.values(ASSET_MATRIX)) {
for (const pair of Object.values(platformAssets)) {
names.push(pair[0], pair[1]);
}
}
return Array.from(new Set(names));
}
function allReleaseAssetNames() {
return [...allAssetNames(), CHECKSUM_MANIFEST];
}
module.exports = {
allAssetNames,
allReleaseAssetNames,
CHECKSUM_MANIFEST,
checksumManifestUrl,
detectBinaryNames,
executableName,
releaseAssetUrl,
releaseBaseUrl,
releaseBinaryDirectory,
};