packaging: move rg manifest out of npm bin

This commit is contained in:
Michael Bolin
2026-05-21 08:20:03 -07:00
parent 298e5cfce1
commit 6fb492a1b1
8 changed files with 46 additions and 13 deletions

View File

@@ -1,79 +0,0 @@
#!/usr/bin/env dotslash
{
"name": "rg",
"platforms": {
"macos-aarch64": {
"size": 1777930,
"hash": "sha256",
"digest": "378e973289176ca0c6054054ee7f631a065874a352bf43f0fa60ef079b6ba715",
"format": "tar.gz",
"path": "ripgrep-15.1.0-aarch64-apple-darwin/rg",
"providers": [
{
"url": "https://github.com/BurntSushi/ripgrep/releases/download/15.1.0/ripgrep-15.1.0-aarch64-apple-darwin.tar.gz"
}
]
},
"linux-aarch64": {
"size": 1869959,
"hash": "sha256",
"digest": "2b661c6ef508e902f388e9098d9c4c5aca72c87b55922d94abdba830b4dc885e",
"format": "tar.gz",
"path": "ripgrep-15.1.0-aarch64-unknown-linux-gnu/rg",
"providers": [
{
"url": "https://github.com/BurntSushi/ripgrep/releases/download/15.1.0/ripgrep-15.1.0-aarch64-unknown-linux-gnu.tar.gz"
}
]
},
"macos-x86_64": {
"size": 1894127,
"hash": "sha256",
"digest": "64811cb24e77cac3057d6c40b63ac9becf9082eedd54ca411b475b755d334882",
"format": "tar.gz",
"path": "ripgrep-15.1.0-x86_64-apple-darwin/rg",
"providers": [
{
"url": "https://github.com/BurntSushi/ripgrep/releases/download/15.1.0/ripgrep-15.1.0-x86_64-apple-darwin.tar.gz"
}
]
},
"linux-x86_64": {
"size": 2263077,
"hash": "sha256",
"digest": "1c9297be4a084eea7ecaedf93eb03d058d6faae29bbc57ecdaf5063921491599",
"format": "tar.gz",
"path": "ripgrep-15.1.0-x86_64-unknown-linux-musl/rg",
"providers": [
{
"url": "https://github.com/BurntSushi/ripgrep/releases/download/15.1.0/ripgrep-15.1.0-x86_64-unknown-linux-musl.tar.gz"
}
]
},
"windows-x86_64": {
"size": 1810687,
"hash": "sha256",
"digest": "124510b94b6baa3380d051fdf4650eaa80a302c876d611e9dba0b2e18d87493a",
"format": "zip",
"path": "ripgrep-15.1.0-x86_64-pc-windows-msvc/rg.exe",
"providers": [
{
"url": "https://github.com/BurntSushi/ripgrep/releases/download/15.1.0/ripgrep-15.1.0-x86_64-pc-windows-msvc.zip"
}
]
},
"windows-aarch64": {
"size": 1675460,
"hash": "sha256",
"digest": "00d931fb5237c9696ca49308818edb76d8eb6fc132761cb2a1bd616b2df02f8e",
"format": "zip",
"path": "ripgrep-15.1.0-aarch64-pc-windows-msvc/rg.exe",
"providers": [
{
"url": "https://github.com/BurntSushi/ripgrep/releases/download/15.1.0/ripgrep-15.1.0-aarch64-pc-windows-msvc.zip"
}
]
}
}
}

View File

@@ -11,7 +11,7 @@
"node": ">=16"
},
"files": [
"bin",
"bin/codex.js",
"vendor"
],
"repository": {

View File

@@ -255,9 +255,6 @@ def stage_sources(staging_dir: Path, version: str, package: str) -> None:
bin_dir = staging_dir / "bin"
bin_dir.mkdir(parents=True, exist_ok=True)
shutil.copy2(CODEX_CLI_ROOT / "bin" / "codex.js", bin_dir / "codex.js")
rg_manifest = CODEX_CLI_ROOT / "bin" / "rg"
if rg_manifest.exists():
shutil.copy2(rg_manifest, bin_dir / "rg")
readme_src = REPO_ROOT / "README.md"
if readme_src.exists():
@@ -316,7 +313,7 @@ def stage_sources(staging_dir: Path, version: str, package: str) -> None:
package_json["version"] = version
if package == "codex":
package_json["files"] = ["bin"]
package_json["files"] = ["bin/codex.js"]
package_json["optionalDependencies"] = {
CODEX_PLATFORM_PACKAGES[platform_package]["npm_name"]: (
f"npm:{CODEX_NPM_NAME}@"

View File

@@ -20,9 +20,10 @@ from urllib.request import urlopen
SCRIPT_DIR = Path(__file__).resolve().parent
CODEX_CLI_ROOT = SCRIPT_DIR.parent
REPO_ROOT = CODEX_CLI_ROOT.parent
DEFAULT_WORKFLOW_URL = "https://github.com/openai/codex/actions/runs/26131514935" # rust-v0.132.0
VENDOR_DIR_NAME = "vendor"
RG_MANIFEST = CODEX_CLI_ROOT / "bin" / "rg"
RG_MANIFEST = REPO_ROOT / "scripts" / "codex_package" / "rg"
BINARY_TARGETS = (
"x86_64-unknown-linux-musl",
"aarch64-unknown-linux-musl",

View File

@@ -0,0 +1,35 @@
#!/usr/bin/env python3
import importlib.util
import json
from pathlib import Path
import tempfile
import unittest
BUILD_SCRIPT = Path(__file__).resolve().parent / "build_npm_package.py"
SPEC = importlib.util.spec_from_file_location("codex_build_npm_package", BUILD_SCRIPT)
if SPEC is None or SPEC.loader is None:
raise RuntimeError(f"Unable to load module from {BUILD_SCRIPT}")
build_npm_package = importlib.util.module_from_spec(SPEC)
SPEC.loader.exec_module(build_npm_package)
class StageSourcesTest(unittest.TestCase):
def test_codex_meta_package_omits_ripgrep_manifest(self) -> None:
with tempfile.TemporaryDirectory() as temp_dir:
staging_dir = Path(temp_dir)
build_npm_package.stage_sources(staging_dir, "0.1.0", "codex")
with open(staging_dir / "package.json", encoding="utf-8") as fh:
package_json = json.load(fh)
self.assertTrue((staging_dir / "bin" / "codex.js").is_file())
self.assertFalse((staging_dir / "bin" / "rg").exists())
self.assertEqual(package_json["files"], ["bin/codex.js"])
if __name__ == "__main__":
unittest.main()