diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c6625bc..e7666cb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,7 +11,10 @@ env: jobs: build-test-lint: - runs-on: ubuntu-latest + strategy: + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v4 @@ -21,5 +24,38 @@ jobs: with: components: clippy, rustfmt + - name: Install Node.js for end-to-end tests + uses: actions/setup-node@v4 + with: + node-version: 22 + - name: Run make (build, test, lint) + if: runner.os != 'Windows' run: make + + - name: Build, test and lint + if: runner.os == 'Windows' + run: | + cargo fmt --all --check + cargo clippy --workspace --all-targets -- -D warnings + cargo test --workspace + + registry-tests: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Install Rust toolchain + uses: dtolnay/rust-toolchain@stable + + - name: Install Node.js for real-world tests + uses: actions/setup-node@v4 + with: + node-version: 22 + + - name: Run tests that need registry.npmjs.org + run: cargo test -p resolver -- --ignored + + - name: Run real-world scenarios + run: make real-world diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9957289..e5cee97 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -19,6 +19,20 @@ jobs: target: x86_64-unknown-linux-gnu artifact_name: craft asset_name: craft-linux-amd64 + - os: ubuntu-24.04-arm + target: aarch64-unknown-linux-gnu + artifact_name: craft + asset_name: craft-linux-arm64 + - os: ubuntu-latest + target: x86_64-unknown-linux-musl + artifact_name: craft + asset_name: craft-linux-amd64-musl + musl: true + - os: ubuntu-24.04-arm + target: aarch64-unknown-linux-musl + artifact_name: craft + asset_name: craft-linux-arm64-musl + musl: true - os: macos-latest target: x86_64-apple-darwin artifact_name: craft @@ -41,16 +55,29 @@ jobs: with: targets: ${{ matrix.target }} + - name: Install musl tools + if: matrix.musl + run: sudo apt-get update && sudo apt-get install -y musl-tools + - name: Build release binary run: cargo build --release --target ${{ matrix.target }} -p craft + env: + CRAFT_RELEASE_VERSION: ${{ github.ref_name }} - - name: Rename binary + - name: Rename binary and write its checksum shell: bash run: | cp target/${{ matrix.target }}/release/${{ matrix.artifact_name }} ${{ matrix.asset_name }} + if command -v sha256sum >/dev/null; then + sha256sum ${{ matrix.asset_name }} > ${{ matrix.asset_name }}.sha256 + else + shasum -a 256 ${{ matrix.asset_name }} > ${{ matrix.asset_name }}.sha256 + fi - name: Upload binary to release uses: softprops/action-gh-release@v1 if: startsWith(github.ref, 'refs/tags/') with: - files: ${{ matrix.asset_name }} + files: | + ${{ matrix.asset_name }} + ${{ matrix.asset_name }}.sha256 diff --git a/.gitignore b/.gitignore index f9fc130..572fc8b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ /target node_modules -.DS_Store \ No newline at end of file +.DS_Store +/craft.lock diff --git a/Cargo.lock b/Cargo.lock index b59e84c..dbf839b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -9,9 +9,13 @@ dependencies = [ "anyhow", "contract", "debug", + "fsutil", + "lockfile", "package", "pipeline", "process", + "progress", + "resolver", "serde_json", "tempfile", "tokio", @@ -32,6 +36,21 @@ dependencies = [ "memchr", ] +[[package]] +name = "alloc-no-stdlib" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2fb6cfd47bf496ff64095c20eaba0c201404ee38714d4142fcfa1dc334fcc7a" + +[[package]] +name = "alloc-stdlib" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b5c1865780388bfa186411ab5f247819487fc4864c6e9c3106611fa347586e1" +dependencies = [ + "alloc-no-stdlib", +] + [[package]] name = "anstream" version = "0.6.21" @@ -88,6 +107,33 @@ version = "1.0.100" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a23eb6b1614318a8071c9b2521f36b424b2c83db5eb3a0fead4a6c0809af6e61" +[[package]] +name = "assert_cmd" +version = "2.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2aa3a22042e45de04255c7bf3626e239f450200fd0493c1e382263544b20aea6" +dependencies = [ + "anstyle", + "bstr", + "libc", + "predicates", + "predicates-core", + "predicates-tree", + "wait-timeout", +] + +[[package]] +name = "async-compression" +version = "0.4.51" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d5755640120b24961f8231e05892e4a4f7e0d04e8aeca161508c9c397946970" +dependencies = [ + "compression-codecs", + "compression-core", + "pin-project-lite", + "tokio", +] + [[package]] name = "async-recursion" version = "1.1.1" @@ -96,29 +142,32 @@ checksum = "3b43422f69d8ff38f95f1b2bb76517c91589a924d1559a0e935d7c8ce0274c11" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.110", ] [[package]] -name = "base64" -version = "0.21.7" +name = "atomic-waker" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" +checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" [[package]] -name = "bincode" -version = "1.3.3" +name = "autocfg" +version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad" -dependencies = [ - "serde", -] +checksum = "f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53" [[package]] -name = "bitflags" -version = "1.3.2" +name = "base64" +version = "0.22.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" + +[[package]] +name = "base64" +version = "0.23.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +checksum = "ac07cdecf99051d9a5238b80f35af32cdeba5b336e55d957b318b50137e18da5" [[package]] name = "bitflags" @@ -126,6 +175,47 @@ version = "2.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "812e12b5285cc515a9c72a5c1d3b6d46a19dac5acfef5265968c166106e31dd3" +[[package]] +name = "block-buffer" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +dependencies = [ + "generic-array", +] + +[[package]] +name = "brotli" +version = "9.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8b851b75c23ca7873623d612fe49bd1989aeb03d08fb9432187eb253d3d4c6b" +dependencies = [ + "alloc-no-stdlib", + "alloc-stdlib", + "brotli-decompressor", +] + +[[package]] +name = "brotli-decompressor" +version = "6.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "941cd9bd4ddab83cb46fa5a2d428f1c857b24ac78cb876cf7beb710840934bd7" +dependencies = [ + "alloc-no-stdlib", + "alloc-stdlib", +] + +[[package]] +name = "bstr" +version = "1.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6bb31b46c14244e20ee9984b11bf5c992b91fb6939fea616e3512c8baecdbe5f" +dependencies = [ + "memchr", + "regex-automata", + "serde_core", +] + [[package]] name = "bumpalo" version = "3.19.0" @@ -160,6 +250,12 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" +[[package]] +name = "cfg_aliases" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724" + [[package]] name = "clap" version = "4.5.53" @@ -191,7 +287,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn", + "syn 2.0.110", ] [[package]] @@ -205,6 +301,7 @@ name = "cli" version = "0.1.0" dependencies = [ "clap", + "contract", ] [[package]] @@ -213,6 +310,24 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b05b61dc5112cbb17e4b6cd61790d9845d13888356391624cbe7e41efeac1e75" +[[package]] +name = "compression-codecs" +version = "0.4.46" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cae36683101b2899f48bd31f8db9839437356188e3b1ff23096e73dab09ba8fe" +dependencies = [ + "brotli", + "compression-core", + "flate2", + "memchr", +] + +[[package]] +name = "compression-core" +version = "0.4.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ebdda89edc534bf8d5dd2857562633b6495557e5846552ade994b99ed13c36a" + [[package]] name = "console" version = "0.16.1" @@ -231,7 +346,10 @@ name = "contract" version = "0.1.0" dependencies = [ "anyhow", - "thiserror", + "base64 0.22.1", + "progress", + "tempfile", + "thiserror 1.0.69", ] [[package]] @@ -250,14 +368,31 @@ version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" +[[package]] +name = "cpufeatures" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280" +dependencies = [ + "libc", +] + [[package]] name = "craft" version = "0.1.0" dependencies = [ + "anyhow", + "assert_cmd", "cli", "contract", "debug", + "fsutil", "manager", + "predicates", + "progress", + "serde_json", + "tempfile", + "testkit", "tokio", ] @@ -270,15 +405,46 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "crypto-common" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78c8292055d1c1df0cce5d180393dc8cce0abec0a7102adb6c7b1eef6016d60a" +dependencies = [ + "generic-array", + "typenum", +] + [[package]] name = "debug" version = "0.1.0" dependencies = [ - "contract", "tracing", "tracing-subscriber", ] +[[package]] +name = "deranged" +version = "0.5.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e9de72ce2ad1f90dc62fa25f0f430ef85eb4b0d8fa0be4f30373bc40a21d28e" + +[[package]] +name = "difflib" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6184e33543162437515c2e2b48714794e37845ec9851711914eec9d308f6ebe8" + +[[package]] +name = "digest" +version = "0.10.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" +dependencies = [ + "block-buffer", + "crypto-common", +] + [[package]] name = "displaydoc" version = "0.2.5" @@ -287,7 +453,7 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.110", ] [[package]] @@ -356,25 +522,19 @@ dependencies = [ ] [[package]] -name = "fnv" -version = "1.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" - -[[package]] -name = "foreign-types" -version = "0.3.2" +name = "float-cmp" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" +checksum = "b09cf3155332e944990140d967ff5eceb70df778b34f77d8075db46e4704e6d8" dependencies = [ - "foreign-types-shared", + "num-traits", ] [[package]] -name = "foreign-types-shared" -version = "0.1.1" +name = "fnv" +version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] name = "form_urlencoded" @@ -385,6 +545,16 @@ dependencies = [ "percent-encoding", ] +[[package]] +name = "fsutil" +version = "0.1.0" +dependencies = [ + "junction", + "reflink-copy", + "tempfile", + "tokio", +] + [[package]] name = "futures" version = "0.3.31" @@ -441,7 +611,7 @@ checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.110", ] [[package]] @@ -474,6 +644,29 @@ dependencies = [ "slab", ] +[[package]] +name = "generic-array" +version = "0.14.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "getrandom" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff2abc00be7fca6ebc474524697ae276ad847ad0a6b3faa4bcb027e9a4614ad0" +dependencies = [ + "cfg-if", + "js-sys", + "libc", + "wasi", + "wasm-bindgen", +] + [[package]] name = "getrandom" version = "0.3.4" @@ -481,22 +674,24 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "899def5c37c4fd7b2664648c28120ecec138e4d395b459e5ca34f9cce2dd77fd" dependencies = [ "cfg-if", + "js-sys", "libc", "r-efi", "wasip2", + "wasm-bindgen", ] [[package]] name = "h2" -version = "0.3.27" +version = "0.4.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0beca50380b1fc32983fc1cb4587bfa4bb9e78fc259aad4a0032d2080309222d" +checksum = "7d29020232d6aa3fb1daca64c1127cf662cf97f254ae16c18c05b8ab635fc118" dependencies = [ + "atomic-waker", "bytes", "fnv", "futures-core", "futures-sink", - "futures-util", "http", "indexmap", "slab", @@ -519,23 +714,34 @@ checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" [[package]] name = "http" -version = "0.2.12" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "601cbb57e577e2f5ef5be8e7b83f0f63994f25aa94d673e54a92d5c516d101f1" +checksum = "918d3568bebf352712bc2ef3d46a8bcf1a75b373be6539de198e9105cbbf9ce0" dependencies = [ "bytes", - "fnv", "itoa", ] [[package]] name = "http-body" -version = "0.4.6" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca2a8f2913ee65f60facd6a5905613afaa448497a0230cc41ce022d93290bc2c" +dependencies = [ + "bytes", + "http", +] + +[[package]] +name = "http-body-util" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2" +checksum = "23169fe34a5fbcdd3f3862e78fb9b6fccd5f02a6dc6f732547005d45631ce71c" dependencies = [ "bytes", + "futures-core", "http", + "http-body", "pin-project-lite", ] @@ -545,47 +751,67 @@ version = "1.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6dbf3de79e51f3d586ab4cb9d5c3e2c14aa28ed23d180cf89b4df0454a69cc87" -[[package]] -name = "httpdate" -version = "1.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" - [[package]] name = "hyper" -version = "0.14.32" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41dfc780fdec9373c01bae43289ea34c972e40ee3c9f6b3c8801a35f35586ce7" +checksum = "2c3e324da4c95177d6291d4c8730197c0d1822f8a9766814a4a44fa5ab797c9c" dependencies = [ + "atomic-waker", "bytes", "futures-channel", "futures-core", - "futures-util", "h2", "http", "http-body", "httparse", - "httpdate", "itoa", "pin-project-lite", - "socket2 0.5.10", + "smallvec", "tokio", - "tower-service", - "tracing", "want", ] [[package]] -name = "hyper-tls" -version = "0.5.0" +name = "hyper-rustls" +version = "0.27.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dfa8e654703247911e29c23fbeaa261834bd9bb74efba2f9acddc37bfb127f53" +dependencies = [ + "http", + "hyper", + "hyper-util", + "rustls", + "tokio", + "tokio-rustls", + "tower-service", + "webpki-roots", +] + +[[package]] +name = "hyper-util" +version = "0.1.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" +checksum = "ddc03d96684f9226b8a787cdb71488417b53ab5ea8fdb1dac946cb9431cc8bff" dependencies = [ + "base64 0.23.1", "bytes", + "futures-channel", + "futures-util", + "http", + "http-body", + "httparse", "hyper", - "native-tls", + "ipnet", + "libc", + "percent-encoding", + "pin-project-lite", + "socket2", + "system-configuration", "tokio", - "tokio-native-tls", + "tower-service", + "tracing", + "windows-registry", ] [[package]] @@ -741,6 +967,16 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "junction" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8cfc352a66ba903c23239ef51e809508b6fc2b0f90e3476ac7a9ff47e863ae95" +dependencies = [ + "scopeguard", + "windows-sys 0.61.2", +] + [[package]] name = "lazy_static" version = "1.5.0" @@ -759,7 +995,7 @@ version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "416f7e718bdb06000964960ffa43b4335ad4012ae8b99060261aa4a8088d5ccb" dependencies = [ - "bitflags 2.10.0", + "bitflags", "libc", "redox_syscall", ] @@ -789,10 +1025,12 @@ dependencies = [ name = "lockfile" version = "0.1.0" dependencies = [ - "bincode", + "anyhow", "contract", + "fsutil", "serde", "serde_json", + "tempfile", "tokio", ] @@ -802,6 +1040,12 @@ version = "0.4.28" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "34080505efa8e45a4b816c349525ebe327ceaa8559756f0356cba97ef3bf7432" +[[package]] +name = "lru-slab" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "112b39cec0b298b6c1999fee3e31427f74f676e4cb9879ed1a121b43661a4154" + [[package]] name = "manager" version = "0.1.0" @@ -811,6 +1055,8 @@ dependencies = [ "contract", "debug", "package", + "serde_json", + "tempfile", "tokio", ] @@ -848,7 +1094,7 @@ checksum = "db5b29714e950dbb20d5e6f74f9dcec4edbcc1067bb7f8ed198c097b8c1a818b" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.110", ] [[package]] @@ -884,30 +1130,21 @@ dependencies = [ "windows-sys 0.61.2", ] -[[package]] -name = "native-tls" -version = "0.2.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87de3442987e9dbec73158d5c715e7ad9072fda936bb03d19d7fa10e00520f0e" -dependencies = [ - "libc", - "log", - "openssl", - "openssl-probe", - "openssl-sys", - "schannel", - "security-framework", - "security-framework-sys", - "tempfile", -] - [[package]] name = "network" version = "0.1.0" dependencies = [ + "anyhow", + "base64 0.22.1", + "bytes", "contract", + "debug", "reqwest", "serde", + "serde_json", + "sha1", + "sha2", + "tempfile", "tokio", ] @@ -921,7 +1158,7 @@ dependencies = [ "miette", "nom", "serde", - "thiserror", + "thiserror 1.0.69", ] [[package]] @@ -934,6 +1171,12 @@ dependencies = [ "minimal-lexical", ] +[[package]] +name = "normalize-line-endings" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61807f77802ff30975e01f4f071c8ba10c022052f98b3294119f3e615d13e5be" + [[package]] name = "nu-ansi-term" version = "0.50.3" @@ -944,69 +1187,43 @@ dependencies = [ ] [[package]] -name = "once_cell" -version = "1.21.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" - -[[package]] -name = "once_cell_polyfill" -version = "1.70.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "384b8ab6d37215f3c5301a95a4accb5d64aa607f1fcb26a11b5303878451b4fe" - -[[package]] -name = "openssl" -version = "0.10.75" +name = "num-conv" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08838db121398ad17ab8531ce9de97b244589089e290a384c900cb9ff7434328" -dependencies = [ - "bitflags 2.10.0", - "cfg-if", - "foreign-types", - "libc", - "once_cell", - "openssl-macros", - "openssl-sys", -] +checksum = "521739c6d2bac4aa25192232afe6841231376b2b26d4d9fae5ecf8ca5772e441" [[package]] -name = "openssl-macros" -version = "0.1.1" +name = "num-traits" +version = "0.2.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" dependencies = [ - "proc-macro2", - "quote", - "syn", + "autocfg", ] [[package]] -name = "openssl-probe" -version = "0.1.6" +name = "once_cell" +version = "1.21.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d05e27ee213611ffe7d6348b942e8f942b37114c00cc03cec254295a4a17852e" +checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" [[package]] -name = "openssl-sys" -version = "0.9.111" +name = "once_cell_polyfill" +version = "1.70.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82cab2d520aa75e3c58898289429321eb788c3106963d0dc886ec7a5f4adc321" -dependencies = [ - "cc", - "libc", - "pkg-config", - "vcpkg", -] +checksum = "384b8ab6d37215f3c5301a95a4accb5d64aa607f1fcb26a11b5303878451b4fe" [[package]] name = "package" version = "0.1.0" dependencies = [ + "anyhow", "contract", - "semver", + "fsutil", + "node-semver", "serde", "serde_json", + "tempfile", "tokio", ] @@ -1033,6 +1250,16 @@ dependencies = [ "windows-link", ] +[[package]] +name = "pem" +version = "3.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d30c53c26bc5b31a98cd02d20f25a7c8567146caf63ed593a9d87b2775291be" +dependencies = [ + "base64 0.22.1", + "serde_core", +] + [[package]] name = "percent-encoding" version = "2.3.2" @@ -1055,27 +1282,26 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" name = "pipeline" version = "0.1.0" dependencies = [ + "anyhow", "async-recursion", "contract", "debug", + "fsutil", "futures", + "lockfile", "node-semver", "package", + "process", "resolver", + "serde_json", "tarball", "tempfile", "tokio", ] [[package]] -name = "pkg-config" -version = "0.3.32" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7edddbd0b52d732b21ad9a5fab5c704c14cd949e5e9a1ec5929a24fded1b904c" - -[[package]] -name = "portable-atomic" -version = "1.11.1" +name = "portable-atomic" +version = "1.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f84267b20a16ea918e43c6a88433c2d54fa145c92a811b5b047ccbe153674483" @@ -1088,6 +1314,51 @@ dependencies = [ "zerovec", ] +[[package]] +name = "powerfmt" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a6394b9e965e73d0a289ee54f589087e2c676aedf60885baf52c76b771e4958" + +[[package]] +name = "ppv-lite86" +version = "0.2.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9" +dependencies = [ + "zerocopy", +] + +[[package]] +name = "predicates" +version = "3.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ada8f2932f28a27ee7b70dd6c1c39ea0675c55a36879ab92f3a715eaa1e63cfe" +dependencies = [ + "anstyle", + "difflib", + "float-cmp", + "normalize-line-endings", + "predicates-core", + "regex", +] + +[[package]] +name = "predicates-core" +version = "1.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cad38746f3166b4031b1a0d39ad9f954dd291e7854fcc0eed52ee41a0b50d144" + +[[package]] +name = "predicates-tree" +version = "1.0.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0de1b847b39c8131db0467e9df1ff60e6d0562ab8e9a16e568ad0fdb372e2f2" +dependencies = [ + "predicates-core", + "termtree", +] + [[package]] name = "proc-macro2" version = "1.0.103" @@ -1103,6 +1374,7 @@ version = "0.1.0" dependencies = [ "anyhow", "contract", + "tempfile", "tokio", ] @@ -1111,7 +1383,61 @@ name = "progress" version = "0.1.0" dependencies = [ "indicatif", +] + +[[package]] +name = "quinn" +version = "0.11.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e20a958963c291dc322d98411f541009df2ced7b5a4f2bd52337638cfccf20" +dependencies = [ + "bytes", + "cfg_aliases", + "pin-project-lite", + "quinn-proto", + "quinn-udp", + "rustc-hash", + "rustls", + "socket2", + "thiserror 2.0.21", "tokio", + "tracing", + "web-time", +] + +[[package]] +name = "quinn-proto" +version = "0.11.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "434b42fec591c96ef50e21e886936e66d3cc3f737104fdb9b737c40ffb94c098" +dependencies = [ + "bytes", + "getrandom 0.3.4", + "lru-slab", + "rand", + "ring", + "rustc-hash", + "rustls", + "rustls-pki-types", + "slab", + "thiserror 2.0.21", + "tinyvec", + "tracing", + "web-time", +] + +[[package]] +name = "quinn-udp" +version = "0.5.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "addec6a0dcad8a8d96a771f815f0eaf55f9d1805756410b39f5fa81332574cbd" +dependencies = [ + "cfg_aliases", + "libc", + "once_cell", + "socket2", + "tracing", + "windows-sys 0.60.2", ] [[package]] @@ -1129,13 +1455,79 @@ version = "5.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f" +[[package]] +name = "rand" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6db2770f06117d490610c7488547d543617b21bfa07796d7a12f6f1bd53850d1" +dependencies = [ + "rand_chacha", + "rand_core", +] + +[[package]] +name = "rand_chacha" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76afc826de14238e6e8c374ddcc1fa19e374fd8dd986b0d2af0d02377261d83c" +dependencies = [ + "getrandom 0.3.4", +] + +[[package]] +name = "rcgen" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75e669e5202259b5314d1ea5397316ad400819437857b90861765f24c4cf80a2" +dependencies = [ + "pem", + "ring", + "rustls-pki-types", + "time", + "yasna", +] + [[package]] name = "redox_syscall" version = "0.5.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed2bf2547551a7053d6fdfafda3f938979645c44812fbfcda098faae3f1a362d" dependencies = [ - "bitflags 2.10.0", + "bitflags", +] + +[[package]] +name = "reflink-copy" +version = "0.1.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9dd7ab4af0363d5ccfd2838d782a28196cf32a5cc2e4fe3c5dc83f2be588b8b" +dependencies = [ + "cfg-if", + "libc", + "rustix", + "windows", +] + +[[package]] +name = "regex" +version = "1.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e10754a14b9137dd7b1e3e5b0493cc9171fdd105e0ab477f51b72e7f3ac0e276" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", ] [[package]] @@ -1157,42 +1549,43 @@ checksum = "7a2d987857b319362043e95f5353c0535c1f58eec5336fdfcf626430af7def58" [[package]] name = "reqwest" -version = "0.11.27" +version = "0.12.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd67538700a17451e7cba03ac727fb961abb7607553461627b97de0b89cf4a62" +checksum = "eddd3ca559203180a307f12d114c268abf583f59b03cb906fd0b3ff8646c1147" dependencies = [ - "base64", + "base64 0.22.1", "bytes", "encoding_rs", "futures-core", - "futures-util", "h2", "http", "http-body", + "http-body-util", "hyper", - "hyper-tls", - "ipnet", + "hyper-rustls", + "hyper-util", "js-sys", "log", "mime", - "native-tls", - "once_cell", "percent-encoding", "pin-project-lite", - "rustls-pemfile", + "quinn", + "rustls", + "rustls-pki-types", "serde", "serde_json", "serde_urlencoded", "sync_wrapper", - "system-configuration", "tokio", - "tokio-native-tls", + "tokio-rustls", + "tower", + "tower-http", "tower-service", "url", "wasm-bindgen", "wasm-bindgen-futures", "web-sys", - "winreg", + "webpki-roots", ] [[package]] @@ -1202,19 +1595,46 @@ dependencies = [ "anyhow", "contract", "debug", + "fsutil", + "lockfile", "network", "node-semver", "package", + "serde", + "serde_json", + "sha2", + "tarball", + "tempfile", "tokio", ] +[[package]] +name = "ring" +version = "0.17.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4689e6c2294d81e88dc6261c768b63bc4fcdb852be6d1352498b114f61383b7" +dependencies = [ + "cc", + "cfg-if", + "getrandom 0.2.17", + "libc", + "untrusted", + "windows-sys 0.52.0", +] + +[[package]] +name = "rustc-hash" +version = "2.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94300abf3f1ae2e2b8ffb7b58043de3d399c73fa6f4b73826402a5c457614dbe" + [[package]] name = "rustix" version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cd15f8a2c5551a84d56efdc1cd049089e409ac19a3072d5037a17fd70719ff3e" dependencies = [ - "bitflags 2.10.0", + "bitflags", "errno", "libc", "linux-raw-sys", @@ -1222,12 +1642,38 @@ dependencies = [ ] [[package]] -name = "rustls-pemfile" -version = "1.0.4" +name = "rustls" +version = "0.23.46" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48e13bd8c0e9365c43cfa5c9e8f9ad49d3c8444926c9aac819e0e4dc503c8fdf" +dependencies = [ + "once_cell", + "ring", + "rustls-pki-types", + "rustls-webpki", + "subtle", + "zeroize", +] + +[[package]] +name = "rustls-pki-types" +version = "1.15.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f4925028c7eb5d1fcdaf196971378ed9d2c1c4efc7dc5d011256f76c99c0a96" +dependencies = [ + "web-time", + "zeroize", +] + +[[package]] +name = "rustls-webpki" +version = "0.103.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c74cae0a4cf6ccbbf5f359f08efdf8ee7e1dc532573bf0db71968cb56b1448c" +checksum = "4443b1b6d39d7c663139942cc4558262562d2c84123bb6282ef177009ca8b281" dependencies = [ - "base64", + "ring", + "rustls-pki-types", + "untrusted", ] [[package]] @@ -1242,50 +1688,12 @@ version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f" -[[package]] -name = "schannel" -version = "0.1.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "891d81b926048e76efe18581bf793546b4c0eaf8448d72be8de2bbee5fd166e1" -dependencies = [ - "windows-sys 0.61.2", -] - [[package]] name = "scopeguard" version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" -[[package]] -name = "security-framework" -version = "2.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "897b2245f0b511c87893af39b033e5ca9cce68824c4d7e7630b5a1d339658d02" -dependencies = [ - "bitflags 2.10.0", - "core-foundation", - "core-foundation-sys", - "libc", - "security-framework-sys", -] - -[[package]] -name = "security-framework-sys" -version = "2.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc1f0cbffaac4852523ce30d8bd3c5cdc873501d96ff467ca09b6767bb8cd5c0" -dependencies = [ - "core-foundation-sys", - "libc", -] - -[[package]] -name = "semver" -version = "1.0.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d767eb0aabc880b29956c35734170f26ed551a859dbd361d140cdbeca61ab1e2" - [[package]] name = "serde" version = "1.0.228" @@ -1313,7 +1721,7 @@ checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.110", ] [[package]] @@ -1322,6 +1730,7 @@ version = "1.0.145" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "402a6f66d8c709116cf22f558eab210f5a50187f702eb4d7e5ef38d9a7f1c79c" dependencies = [ + "indexmap", "itoa", "memchr", "ryu", @@ -1341,6 +1750,28 @@ dependencies = [ "serde", ] +[[package]] +name = "sha1" +version = "0.10.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a978451301f4db1d02937a4ab3ccce137717b81826e79b7d49ffe3244a13c3b8" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + +[[package]] +name = "sha2" +version = "0.10.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + [[package]] name = "sharded-slab" version = "0.1.7" @@ -1383,16 +1814,6 @@ version = "1.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03" -[[package]] -name = "socket2" -version = "0.5.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e22376abed350d73dd1cd119b57ffccad95b4e585a7cda43e286245ce23c0678" -dependencies = [ - "libc", - "windows-sys 0.52.0", -] - [[package]] name = "socket2" version = "0.6.1" @@ -1415,6 +1836,12 @@ version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" +[[package]] +name = "subtle" +version = "2.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" + [[package]] name = "syn" version = "2.0.110" @@ -1426,11 +1853,25 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "syn" +version = "3.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d78c8dee4c7bf0e14673097256fed6142ce9d3b85a408189d07482442145823b" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + [[package]] name = "sync_wrapper" -version = "0.1.2" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" +checksum = "0bf256ce5efdfa370213c1dabab5935a12e49f2c58d15e9eac2870d3b4f27263" +dependencies = [ + "futures-core", +] [[package]] name = "synstructure" @@ -1440,25 +1881,25 @@ checksum = "728a70f3dbaf5bab7f0c4b1ac8d7ae5ea60a4b5549c8a5914361c99147a709d2" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.110", ] [[package]] name = "system-configuration" -version = "0.5.1" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7" +checksum = "a13f3d0daba03132c0aa9767f98351b3488edc2c100cda2d2ec2b04f3d8d3c8b" dependencies = [ - "bitflags 1.3.2", + "bitflags", "core-foundation", "system-configuration-sys", ] [[package]] name = "system-configuration-sys" -version = "0.5.0" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a75fb188eb626b924683e3b95e3a48e63551fcfb51949de2f06a9d91dbee93c9" +checksum = "8e1d1b10ced5ca923a1fcb8d03e96b8d3268065d724548c0211415ff6ac6bac4" dependencies = [ "core-foundation-sys", "libc", @@ -1479,6 +1920,7 @@ dependencies = [ name = "tarball" version = "0.1.0" dependencies = [ + "anyhow", "contract", "flate2", "tar", @@ -1493,19 +1935,47 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2d31c77bdf42a745371d260a26ca7163f1e0924b64afa0b688e61b5a9fa02f16" dependencies = [ "fastrand", - "getrandom", + "getrandom 0.3.4", "once_cell", "rustix", "windows-sys 0.61.2", ] +[[package]] +name = "termtree" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f50febec83f5ee1df3015341d8bd429f2d1cc62bcba7ea2076759d315084683" + +[[package]] +name = "testkit" +version = "0.1.0" +dependencies = [ + "base64 0.22.1", + "flate2", + "rcgen", + "rustls", + "serde_json", + "sha2", + "tar", +] + [[package]] name = "thiserror" version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" dependencies = [ - "thiserror-impl", + "thiserror-impl 1.0.69", +] + +[[package]] +name = "thiserror" +version = "2.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09e52cb86a36cede5cb101bf8908837b3e4c6e5e59fe7fd85c23fb56200d189e" +dependencies = [ + "thiserror-impl 2.0.21", ] [[package]] @@ -1516,7 +1986,18 @@ checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.110", +] + +[[package]] +name = "thiserror-impl" +version = "2.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe5197923287db20a58125f0bc85c062f7f2c892de97b18c356f9efb14b28524" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.9", ] [[package]] @@ -1528,6 +2009,25 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "time" +version = "0.3.55" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cdb87b95ec50ddfa440816d227a17b2ccbdda963a316a727fda0fc4334f7d134" +dependencies = [ + "deranged", + "num-conv", + "powerfmt", + "serde_core", + "time-core", +] + +[[package]] +name = "time-core" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e1c906769ad99c88eaa54e728060edef082f8e358ff32030cb7c7d315e81109" + [[package]] name = "tinystr" version = "0.8.2" @@ -1538,6 +2038,21 @@ dependencies = [ "zerovec", ] +[[package]] +name = "tinyvec" +version = "1.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e61e67053d25a4e82c844e8424039d9745781b3fc4f32b8d55ed50f5f667ef3" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" + [[package]] name = "tokio" version = "1.48.0" @@ -1550,7 +2065,7 @@ dependencies = [ "parking_lot", "pin-project-lite", "signal-hook-registry", - "socket2 0.6.1", + "socket2", "tokio-macros", "windows-sys 0.61.2", ] @@ -1563,16 +2078,16 @@ checksum = "af407857209536a95c8e56f8231ef2c2e2aff839b22e07a1ffcbc617e9db9fa5" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.110", ] [[package]] -name = "tokio-native-tls" -version = "0.3.1" +name = "tokio-rustls" +version = "0.26.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2" +checksum = "c9cc2678c2cdd569ef8215e2afd7954ada2ae20b4fdd2c5fe6139a3b02d105db" dependencies = [ - "native-tls", + "rustls", "tokio", ] @@ -1589,6 +2104,50 @@ dependencies = [ "tokio", ] +[[package]] +name = "tower" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebe5ef63511595f1344e2d5cfa636d973292adc0eec1f0ad45fae9f0851ab1d4" +dependencies = [ + "futures-core", + "futures-util", + "pin-project-lite", + "sync_wrapper", + "tokio", + "tower-layer", + "tower-service", +] + +[[package]] +name = "tower-http" +version = "0.6.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4cfcf7e2740e6fc6d4d688b4ef00650406bb94adf4731e43c096c3a19fe40840" +dependencies = [ + "async-compression", + "bitflags", + "bytes", + "futures-core", + "futures-util", + "http", + "http-body", + "http-body-util", + "pin-project-lite", + "tokio", + "tokio-util", + "tower", + "tower-layer", + "tower-service", + "url", +] + +[[package]] +name = "tower-layer" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "121c2a6cda46980bb0fcd1647ffaf6cd3fc79a013de288782836f6df9c48780e" + [[package]] name = "tower-service" version = "0.3.3" @@ -1614,7 +2173,7 @@ checksum = "81383ab64e72a7a8b8e13130c49e3dab29def6d0c7d76a03087b3cf71c5c6903" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.110", ] [[package]] @@ -1662,6 +2221,12 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" +[[package]] +name = "typenum" +version = "1.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6f5e870be6c3b371b77fe0ee0bafb859fa4964b4404c27de1d380043c4dda20" + [[package]] name = "unicode-ident" version = "1.0.22" @@ -1686,6 +2251,12 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "81e544489bf3d8ef66c953931f56617f423cd4b5494be343d9b9d3dda037b9a3" +[[package]] +name = "untrusted" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" + [[package]] name = "url" version = "2.5.7" @@ -1717,16 +2288,25 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ba73ea9cf16a25df0c8caa16c51acb937d5712a8429db78a3ee29d5dcacd3a65" [[package]] -name = "vcpkg" -version = "0.2.15" +name = "version_check" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" + +[[package]] +name = "wait-timeout" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ac3b126d3914f9849036f826e054cbabdc8519970b8998ddaf3b5bd3c65f11" +dependencies = [ + "libc", +] [[package]] name = "want" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e" +checksum = "ec4cdd0dd910afe868b7ef477227d8d538b46b3075031afee8a9f2acb0a2ed0b" dependencies = [ "try-lock", ] @@ -1791,7 +2371,7 @@ dependencies = [ "bumpalo", "proc-macro2", "quote", - "syn", + "syn 2.0.110", "wasm-bindgen-shared", ] @@ -1824,6 +2404,82 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "webpki-roots" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f5f280bbb2b287bc8e7de7e3852945a0ff50d1bbcb5ed42b6c7a568c546df171" +dependencies = [ + "rustls-pki-types", +] + +[[package]] +name = "windows" +version = "0.62.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "527fadee13e0c05939a6a05d5bd6eec6cd2e3dbd648b9f8e447c6518133d8580" +dependencies = [ + "windows-collections", + "windows-core", + "windows-future", + "windows-numerics", +] + +[[package]] +name = "windows-collections" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23b2d95af1a8a14a3c7367e1ed4fc9c20e0a26e79551b1454d72583c97cc6610" +dependencies = [ + "windows-core", +] + +[[package]] +name = "windows-core" +version = "0.62.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8e83a14d34d0623b51dce9581199302a221863196a1dde71a7663a4c2be9deb" +dependencies = [ + "windows-implement", + "windows-interface", + "windows-link", + "windows-result", + "windows-strings", +] + +[[package]] +name = "windows-future" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1d6f90251fe18a279739e78025bd6ddc52a7e22f921070ccdc67dde84c605cb" +dependencies = [ + "windows-core", + "windows-link", + "windows-threading", +] + +[[package]] +name = "windows-implement" +version = "0.60.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "053e2e040ab57b9dc951b72c264860db7eb3b0200ba345b4e4c3b14f67855ddf" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.110", +] + +[[package]] +name = "windows-interface" +version = "0.59.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f316c4a2570ba26bbec722032c4099d8c8bc095efccdc15688708623367e358" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.110", +] + [[package]] name = "windows-link" version = "0.2.1" @@ -1831,12 +2487,42 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" [[package]] -name = "windows-sys" -version = "0.48.0" +name = "windows-numerics" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e2e40844ac143cdb44aead537bbf727de9b044e107a0f1220392177d15b0f26" +dependencies = [ + "windows-core", + "windows-link", +] + +[[package]] +name = "windows-registry" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02752bf7fbdcce7f2a27a742f798510f3e5ad88dbe84871e5168e2120c3d5720" +dependencies = [ + "windows-link", + "windows-result", + "windows-strings", +] + +[[package]] +name = "windows-result" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7781fa89eaf60850ac3d2da7af8e5242a5ea78d1a11c49bf2910bb5a73853eb5" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-strings" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +checksum = "7837d08f69c77cf6b07689544538e017c1bfcf57e34b4c0ff58e6c2cd3b37091" dependencies = [ - "windows-targets 0.48.5", + "windows-link", ] [[package]] @@ -1866,21 +2552,6 @@ dependencies = [ "windows-link", ] -[[package]] -name = "windows-targets" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" -dependencies = [ - "windows_aarch64_gnullvm 0.48.5", - "windows_aarch64_msvc 0.48.5", - "windows_i686_gnu 0.48.5", - "windows_i686_msvc 0.48.5", - "windows_x86_64_gnu 0.48.5", - "windows_x86_64_gnullvm 0.48.5", - "windows_x86_64_msvc 0.48.5", -] - [[package]] name = "windows-targets" version = "0.52.6" @@ -1915,10 +2586,13 @@ dependencies = [ ] [[package]] -name = "windows_aarch64_gnullvm" -version = "0.48.5" +name = "windows-threading" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" +checksum = "3949bd5b99cafdf1c7ca86b43ca564028dfe27d66958f2470940f73d86d75b37" +dependencies = [ + "windows-link", +] [[package]] name = "windows_aarch64_gnullvm" @@ -1932,12 +2606,6 @@ version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a9d8416fa8b42f5c947f8482c43e7d89e73a173cead56d044f6a56104a6d1b53" -[[package]] -name = "windows_aarch64_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" - [[package]] name = "windows_aarch64_msvc" version = "0.52.6" @@ -1950,12 +2618,6 @@ version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b9d782e804c2f632e395708e99a94275910eb9100b2114651e04744e9b125006" -[[package]] -name = "windows_i686_gnu" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" - [[package]] name = "windows_i686_gnu" version = "0.52.6" @@ -1980,12 +2642,6 @@ version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fa7359d10048f68ab8b09fa71c3daccfb0e9b559aed648a8f95469c27057180c" -[[package]] -name = "windows_i686_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" - [[package]] name = "windows_i686_msvc" version = "0.52.6" @@ -1998,12 +2654,6 @@ version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e7ac75179f18232fe9c285163565a57ef8d3c89254a30685b57d83a38d326c2" -[[package]] -name = "windows_x86_64_gnu" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" - [[package]] name = "windows_x86_64_gnu" version = "0.52.6" @@ -2016,12 +2666,6 @@ version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c3842cdd74a865a8066ab39c8a7a473c0778a3f29370b5fd6b4b9aa7df4a499" -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" - [[package]] name = "windows_x86_64_gnullvm" version = "0.52.6" @@ -2034,12 +2678,6 @@ version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0ffa179e2d07eee8ad8f57493436566c7cc30ac536a3379fdf008f47f6bb7ae1" -[[package]] -name = "windows_x86_64_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" - [[package]] name = "windows_x86_64_msvc" version = "0.52.6" @@ -2052,16 +2690,6 @@ version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d6bbff5f0aada427a1e5a6da5f1f98158182f26556f345ac9e04d36d0ebed650" -[[package]] -name = "winreg" -version = "0.50.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "524e57b2c537c0f9b1e69f1965311ec12182b4122e45035b1508cd24d2adadb1" -dependencies = [ - "cfg-if", - "windows-sys 0.48.0", -] - [[package]] name = "wit-bindgen" version = "0.46.0" @@ -2084,6 +2712,15 @@ dependencies = [ "rustix", ] +[[package]] +name = "yasna" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e17bb3549cc1321ae1296b9cdc2698e2b6cb1992adfa19a8c72e5b7a738f44cd" +dependencies = [ + "time", +] + [[package]] name = "yoke" version = "0.8.1" @@ -2103,10 +2740,30 @@ checksum = "b659052874eb698efe5b9e8cf382204678a0086ebf46982b79d6ca3182927e5d" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.110", "synstructure", ] +[[package]] +name = "zerocopy" +version = "0.8.48" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eed437bf9d6692032087e337407a86f04cd8d6a16a37199ed57949d415bd68e9" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.8.48" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70e3cd084b1788766f53af483dd21f93881ff30d7320490ec3ef7526d203bad4" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.110", +] + [[package]] name = "zerofrom" version = "0.1.6" @@ -2124,10 +2781,16 @@ checksum = "d71e5d6e06ab090c67b5e44993ec16b72dcbaabc526db883a360057678b48502" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.110", "synstructure", ] +[[package]] +name = "zeroize" +version = "1.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e13084392c5e4bc371903e2935a5eaeed24905a7511356b883835e18a78f6879" + [[package]] name = "zerotrie" version = "0.2.3" @@ -2158,5 +2821,5 @@ checksum = "eadce39539ca5cb3985590102671f2567e659fca9666581ad3411d59207951f3" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.110", ] diff --git a/Cargo.toml b/Cargo.toml index 7ba181a..9332b26 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,8 +14,11 @@ members = [ "crates/network", "crates/tarball", "crates/process", + "crates/fsutil", + "crates/testkit", ] resolver = "2" [workspace.lints.clippy] unwrap_used = "deny" +expect_used = "deny" diff --git a/Makefile b/Makefile index 465aa81..fe6a811 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: build test lint craft +.PHONY: build test lint fmt craft real-world all: build test lint @@ -9,7 +9,14 @@ test: cargo test lint: - cargo clippy --workspace -- -D warnings + cargo fmt --all --check + cargo clippy --workspace --all-targets -- -D warnings + +fmt: + cargo fmt --all + +real-world: + cargo test -p craft --test real_world -- --ignored craft: cargo run -p craft -- $(filter-out $@,$(MAKECMDGOALS)) diff --git a/README.md b/README.md index bd4f459..f847d3e 100644 --- a/README.md +++ b/README.md @@ -8,32 +8,33 @@ ![Release](https://github.com/craftpkg/craft/actions/workflows/release.yml/badge.svg) ![License](https://img.shields.io/badge/license-MIT-blue.svg) -**Craft** is a blazing fast, Rust-based package manager designed for modern web development. It focuses on speed, reliability, and a delightful developer experience. +**Craft** is a fast, strict package manager for Node.js, written in Rust. It installs from the npm registry (or any npm-compatible one) into a pnpm-style `node_modules`, keeps a deterministic `craft.lock`, and runs dependency install scripts only for packages you trust. ## ✨ Features -- πŸš€ **Blazing Fast**: Written in Rust for maximum performance. -- ⚑ **Parallel Downloads**: Resolves and downloads packages concurrently. -- πŸ”’ **Reliable Locking**: Deterministic installs with `package-lock.json` support (coming soon). -- πŸ“¦ **Efficient Caching**: Global cache to save disk space and bandwidth. -- πŸ› οΈ **Developer Friendly**: Intuitive CLI with helpful error messages. -- πŸ—οΈ **Multi-Platform**: Native binaries for Linux, macOS (Intel & Apple Silicon), and Windows. +- πŸš€ **Fast**: parallel resolution and downloads, packuments cached on disk and revalidated with ETags, files cloned (copy-on-write) from a global store. An unchanged project installs in milliseconds. +- πŸ”’ **Deterministic**: `craft.lock` records every resolved version, tarball and integrity; `craft install --frozen-lockfile` (the default in CI) installs exactly that. +- πŸ“¦ **Strict, isolated layout**: every package sees only the dependencies it declares, each project has its own `node_modules/.craft`, and the global store is never modified after extraction. +- 🧩 **npm-compatible**: semver ranges, dist-tags, `npm:` aliases, git and tarball URLs, `file:` and `link:` dependencies, peer and optional dependencies, `os`/`cpu`/`libc` platform packages, `.npmrc` registries and auth. +- πŸ›‘οΈ **Safe by default**: tarballs are verified against their integrity hash, and dependencies' install scripts run only when listed in `trustedDependencies`. ## πŸš€ Installation -### One-line Install (Recommended) +### One-line install ```bash curl -fsSL https://raw.githubusercontent.com/craftpkg/craft/main/install.sh | bash ``` -### From Binary +The script downloads the binary for your platform (a static build on musl/Alpine), verifies its SHA-256 checksum, and installs it to `/usr/local/bin` when writable or `~/.local/bin` otherwise β€” no `sudo`. Set `CRAFT_INSTALL_DIR` to choose the directory and `CRAFT_VERSION` to pin a release. -Download the latest release for your platform from the [Releases](https://github.com/craftpkg/craft/releases) page. +### From a release -### From Source +Download a binary and its `.sha256` from the [Releases](https://github.com/craftpkg/craft/releases) page: Linux (x64 and arm64, glibc and musl), macOS (Intel and Apple Silicon) and Windows (x64). -Ensure you have [Rust](https://www.rust-lang.org/tools/install) installed. +On Windows, directory links are junctions and bins get `.cmd`, `.ps1` and sh shims like npm's, so neither administrator rights nor Developer Mode are needed; scripts run through `cmd`. + +### From source ```bash git clone https://github.com/craftpkg/craft.git @@ -43,74 +44,72 @@ cargo install --path apps/craft ## πŸ“– Usage -### Initialize a Project - -Currently, Craft works with existing `package.json` files. Support for `craft init` is coming soon! - -### Install Dependencies - -Install all dependencies listed in your `package.json`: - -```bash -craft install -``` - -### Add Packages - -Add a package to your dependencies: - ```bash -craft add react +craft init # create a package.json +craft install # install everything in package.json (alias: craft i) +craft add react react-dom # add dependencies +craft add -D typescript # …to devDependencies (-E exact, -O optional, -P peer) +craft remove react # remove dependencies (aliases: rm, uninstall, un) +craft update [pkg…] # update within the ranges in package.json; --latest to move ranges +craft outdated # show what has newer versions +craft list --depth 1 # show the dependency tree (alias: ls) +craft why ms # show why a package is installed +craft run build # run a script, with its pre/post scripts (craft run lists them) +craft start / craft test # shortcuts for craft run start / test +craft tsc --noEmit # run a dependency's bin directly +craft exec eslint . # run a dependency's bin, never a script +craft dlx create-vite my-app # run a package without adding it (alias: craft x) +craft trust esbuild # allow a dependency's install scripts, then install +craft ci # clean, frozen install for CI +craft cache clean --force # remove the global store and metadata cache ``` -Add multiple packages: - -```bash -craft add react react-dom -``` +Global flags: `--offline` (never touch the network), `--prefer-offline` (use cached metadata without revalidating), `--silent`, `--debug`. `craft -v` prints the version. Every command has `--help`. -Add a development dependency: +## 🧠 How it works -```bash -craft add typescript -D -``` +- **Global store** β€” each package is extracted once into `~/.craft/store/v1/@-/` after its integrity is verified, and never written to afterwards. +- **Per-project virtual store** β€” every package lives in `node_modules/.craft/@/node_modules/`, imported from the store by clone, hardlink or copy (whichever the filesystem supports), with its dependencies linked beside it. Your `node_modules/` entries are links into `.craft`. Packages that `require` something they never declared still find it through `node_modules/.craft/node_modules`, while your own code only sees what `package.json` lists. +- **Peer dependencies** resolve to what the parent provides; a package used with different peers gets one copy per peer set (`ui@1.0.0_react@18.3.1`). +- **`craft.lock`** is sorted JSON meant to be committed. With it, installs make no registry metadata requests at all; `craft add`, `craft remove` and `craft update` keep it up to date. Anything removed from `package.json` is pruned from `node_modules` on the next install. -### Remove Packages +## πŸ›‘οΈ Install scripts -Remove a package from your dependencies: +Dependencies' `preinstall` / `install` / `postinstall` scripts (and implicit `node-gyp` builds) run only for packages listed in `package.json`: -```bash -craft remove react +```json +{ + "trustedDependencies": ["bcrypt", "esbuild"] +} ``` -### Run Scripts - -Run a script defined in your `package.json`: +Craft lists every package whose scripts it skipped; `craft trust ` adds it and builds it. Your project's own lifecycle scripts always run, and `--ignore-scripts` turns all of them off. -```bash -craft run build -``` +## βš™οΈ Configuration -Shortcuts for common scripts: +Craft reads `.npmrc` from your home directory and the project, plus `npm_config_*` variables: -```bash -craft start # Equivalent to: craft run start -craft test # Equivalent to: craft run test +```ini +registry=https://registry.npmjs.org/ +@acme:registry=https://npm.pkg.github.com +//npm.pkg.github.com/:_authToken=${GITHUB_TOKEN} +https-proxy=http://proxy.internal:8080 +fetch-retries=3 +network-concurrency=16 ``` -### Manage Cache - -Clean the global package cache: - -```bash -craft cache clean --force -``` +Supported keys: `registry`, `@scope:registry`, `//host/:_authToken`, `_auth`, `username` + `_password`, `https-proxy`, `proxy`, `noproxy`, `strict-ssl`, `cafile`, `fetch-retries`, `network-concurrency`, `offline`, `prefer-offline`. Credentials are only ever sent to the host they're configured for. HTTPS uses craft's bundled root certificates; point `cafile` at your CA's certificate to use a private registry or a TLS-inspecting proxy. -> **Note**: The `--force` flag is required for confirmation. Without it, the command will show a warning message. +| Environment variable | Purpose | +| --- | --- | +| `CRAFT_HOME` | Where the store and caches live (default `~/.craft`) | +| `CRAFT_REGISTRY` | Override the default registry | +| `CRAFT_OS` / `CRAFT_CPU` / `CRAFT_LIBC` | Install platform packages for another platform (e.g. building a Linux image on a Mac) | +| `CI` | When set, installs require an up-to-date `craft.lock` | ## 🀝 Contributing -Contributions are welcome! Please feel free to submit a Pull Request. +Contributions are welcome! `make` runs formatting, lints and the full test suite against a local mock registry (the end-to-end tests need Node.js on `PATH`). `make real-world` runs scenarios with real packages against registry.npmjs.org and GitHub, and `docker/windows/test.sh` cross-compiles the tests for Windows and runs them under Wine. 1. Fork the repository 2. Create your feature branch (`git checkout -b feature/amazing-feature`) diff --git a/REMAINING.md b/REMAINING.md new file mode 100644 index 0000000..284c403 --- /dev/null +++ b/REMAINING.md @@ -0,0 +1,752 @@ +# Craft β€” Remaining Work + +Status of the Rust package manager as of **2026-10-24**, and the ordered list of work needed to finalize it. +Work through tasks top to bottom: each phase unblocks the next. Tick a task's box when it is merged. + +**Known-bug tests:** every open bug that has a scenario is an `#[ignore = "fixed by : …"]` end-to-end test in +`apps/craft/tests/e2e/`. `cargo test -p craft --test e2e -- --ignored` lists what's still broken; when a task +lands, delete the `#[ignore]` on its tests. + +**Real-world tests:** `make real-world` runs `apps/craft/tests/real_world/` (ignored by default, and in CI's +`registry-tests` job) against registry.npmjs.org, JSR and GitHub with pinned real packages: an Express server, React SSR +with Redux and React Query sharing one React, a `craft dlx create-vite` project that installs and builds, TypeScript and +Prettier through bins and scripts, esbuild / SWC / Lightning CSS platform binaries, a trusted `bcrypt` build, foreign +platform installs, git / tarball / JSR / `file:` / `link:` sources, aliases, outdated / update / list / why / remove, +offline and frozen installs, and dlx. Projects share one craft home per run, so the store is exercised concurrently. + +Legend: **P0** broken installs / crashes Β· **P1** wrong behaviour Β· **P2** performance, DX, hygiene Β· +βœ… reproduced against the real binary Β· πŸ“– found by code reading + +--- + +## Current state + +Works today: + +- `craft install` / `craft add` / `craft remove` / `craft run` / `craft cache clean --force` +- Parallel resolution + download from `registry.npmjs.org`, global tarball cache in `~/.craft/packages` +- Happy-path projects install and run (`express`, `lodash`, `openai`, `axios`, `typescript`, `eslint`) +- `craft ` dispatches to `node_modules/.bin` (`craft tsc --version` works) +- `cargo build` and `cargo test` green (62 tests) + +Broken or missing, in short: non-semver specs panic, peer deps and aliases don't link, `@types/*` links dangle, +the global cache is mutated per project (races), no lockfile, no integrity checks, no optional/platform deps, +no lifecycle scripts, `craft run` doesn't put `.bin` on `PATH`. + +--- + +## Progress tracker + +| ID | Task | Pri | Status | +|---|---|---|---| +| **Phase 0 β€” Foundations** | | | | +| 0.1 | Explicit `Context` (cwd + `CRAFT_HOME`) instead of process-global env/cwd | P2 | [x] | +| 0.2 | Test isolation: no real installs or env mutation in unit tests | P2 | [x] | +| 0.3 | Mock registry + end-to-end test harness | P2 | [x] | +| 0.4 | Lint/CI hygiene (`clippy --all-targets`, fmt, workspace lints, dead code) | P2 | [x] | +| **Phase 1 β€” Correctness fixes (current layout)** | | | | +| 1.1 | Dependency spec classification β€” no more panics | P0 | [x] | +| 1.2 | `InstallPipe` returns a resolution graph, not a flat list | P0 | [x] | +| 1.3 | npm alias linking (root + transitive) | P0 | [x] | +| 1.4 | Tarball root-directory stripping | P0 | [x] | +| 1.5 | HTTP status checks + friendly registry errors | P0 | [x] | +| 1.6 | Atomic download and extraction | P0 | [x] | +| 1.7 | Integrity verification (`dist.integrity` / `shasum`) | P0 | [x] | +| 1.8 | Symlink-safe filesystem helpers (dangling links) | P0 | [x] | +| 1.9 | `craft add` fixes | P1 | [x] | +| 1.10 | Preserve `package.json` formatting and key order | P1 | [x] | +| 1.11 | `craft remove` fixes | P1 | [x] | +| 1.12 | `craft run` fixes (PATH, exit code, quoting, pre/post, env) | P1 | [x] | +| 1.13 | Git / tarball-URL / `file:` / `link:` dependencies | P1 | [x] | +| 1.14 | Bin linking edge cases | P1 | [x] | +| **Phase 2 β€” Store & layout redesign** | | | | +| 2.1 | Global content-addressed store (read-only) | P0 | [x] | +| 2.2 | Per-project virtual store `node_modules/.craft` | P0 | [x] | +| 2.3 | Peer dependency resolution | P0 | [x] | +| 2.4 | Bins inside the virtual store | P1 | [x] | +| 2.5 | Prune extraneous packages | P1 | [x] | +| **Phase 3 β€” Lockfile** | | | | +| 3.1 | Lockfile format (text, deterministic) | P0 | [x] | +| 3.2 | Write lockfile after install/add/remove | P0 | [x] | +| 3.3 | Install from lockfile (skip resolution) | P0 | [x] | +| 3.4 | `--frozen-lockfile` / `craft ci` | P1 | [x] | +| **Phase 4 β€” Platform packages & lifecycle scripts** | | | | +| 4.1 | `optionalDependencies` | P0 | [x] | +| 4.2 | `os` / `cpu` / `libc` filtering | P0 | [x] | +| 4.3 | Lifecycle scripts with an allowlist | P0 | [x] | +| **Phase 5 β€” Network & performance** | | | | +| 5.1 | Abbreviated packuments | P2 | [-] deferred | +| 5.2 | Memoize packument fetches per package name | P2 | [x] | +| 5.3 | Global concurrency limits | P2 | [x] | +| 5.4 | Timeouts, retries, User-Agent | P2 | [x] | +| 5.5 | Streaming downloads (hash while writing) | P2 | [x] | +| 5.6 | Metadata disk cache (ETag / 304) | P2 | [x] | +| 5.7 | Registry configuration (`.npmrc`, scopes, auth) | P1 | [x] | +| **Phase 6 β€” CLI & UX** | | | | +| 6.1 | Progress output and install summary | P2 | [x] | +| 6.2 | Error reporting (no panics, contextual messages) | P2 | [x] | +| 6.3 | Missing commands and flags | P2 | [x] | +| 6.4 | Windows support (shims, junctions) | P2 | [x] | +| 6.5 | Release & docs accuracy | P2 | [x] | +| **Phase 7 β€” Later** | | | | +| 7.x | Workspaces, `package-lock.json` import, overrides, `dlx`, global installs | β€” | [ ] | + +--- + +## Phase 0 β€” Foundations + +Do these first: every later fix needs a fast, offline, isolated way to prove it works. + +### 0.1 Explicit `Context` instead of process-global state Β· P2 πŸ“– β€” βœ” done + +> Done: `contract::Context { cwd, craft_home, verbose }` built in `main` via `Context::from_env`; `Actor::with(context, payload)`; `InstallPipe`/`LinkerPipe`/`Resolver` take the context or cache dir; `CRAFT_HOME` override; missing home is an error, not a panic; `set_verbose`/`CRAFT_VERBOSE` and `RemoveActorPayload::working_dir` removed. + +**Problem** +- `contract::get_package_cache_dir()` reads `HOME` and `expect`s it (`crates/contract/src/constants.rs:11`) β€” panics without `HOME`. +- Every actor/pipe calls `std::env::current_dir()` itself, so tests must `set_current_dir` / `set_var("HOME")`, which is process-global and races between parallel tests (`linker_pipe.rs:335-338`, `install_actor.rs:48`). +- `CraftManager::set_verbose` sets `CRAFT_VERBOSE` via `unsafe set_var`, but nothing ever reads it. + +**Fix** +- Add a `Context { cwd: PathBuf, home: PathBuf /* ~/.craft */, verbose: bool }` in `contract`, built once in `main`. +- `home` resolves from `CRAFT_HOME`, then `dirs::home_dir()/.craft`; return an error, not a panic. +- Pass `&Context` (or `Arc`) into actors and pipes; remove all `current_dir()` / `get_package_cache_dir()` calls below `main`. +- Delete `set_verbose` / `CRAFT_VERBOSE` or read it in `debug::init`. + +**Done when** +- `grep -rn "current_dir()\|set_var\|get_package_cache_dir" crates/` only hits `main` and `Context::from_env`. +- Tests construct a `Context` pointing at a `tempdir` β€” no global mutation. + +### 0.2 Test isolation Β· P2 βœ… β€” βœ” done + +> Done: manager tests rewritten as offline dispatch tests (start/run scripts, install without package.json, remove, cache clean) in a tempdir `Context`; 6 live-registry resolver tests are `#[ignore]`d and run in a separate `registry-tests` CI job via `--ignored`. Verified: `cargo test` passes with all HTTP(S) routed to a dead proxy, and leaves `git status` and `~/.craft` untouched. The ignored tests get offline equivalents once the mock registry (0.3) exists. + +**Problem** +- `crates/manager/src/manager.rs:99-115` runs a real `craft add react` against the crate dir β€” every `cargo test` creates `crates/manager/node_modules` and writes to the real `~/.craft`. +- `test_handle_start_command` tries to run a real `start` script. +- Resolver tests (`npm.rs`, `resolver.rs`) require network access and the live registry state. + +**Fix** +- Replace manager tests with dispatch tests that don't execute actors (or run them against a `Context` in a tempdir + mock registry from 0.3). +- Mark live-registry tests `#[ignore]` (run in a nightly CI job with `--ignored`), and cover the same logic via the mock registry. + +**Done when** `cargo test` works offline and leaves `git status` and `~/.craft` untouched. + +### 0.3 Mock registry + end-to-end harness Β· P2 β€” βœ” done + +> Done: `CRAFT_REGISTRY` / `Context::with_registry` make the registry configurable. `crates/testkit` provides `MockRegistry` (a `tiny_http` server on `127.0.0.1` serving packuments, tarballs and npm-style 404s, recording request paths) and `PackageFixture` (builds tarballs in memory with real `sha512` integrity, configurable root dir, bins, peer/optional deps; its default `index.js` requires its dependencies so `require()` proves the subtree resolves). `apps/craft/tests/e2e/` runs the real binary per test in a tempdir project + craft home: 20 passing scenarios and 23 `#[ignore]`d known-bug scenarios, each confirmed to fail today for the documented reason. CI installs Node 22 for these tests. + +**Fix** +- Make the registry base URL configurable (`Context.registry`, default `https://registry.npmjs.org`) β€” also needed by 5.7. +- Add a test-support crate (or `tests/common`) that: + - serves packuments + tarballs from fixtures with `httpmock`/`wiremock` (or a tiny `axum` server); + - builds fixture tarballs on the fly (`tar` + `flate2`, like `crates/tarball/src/gzip.rs` tests do), with configurable root dir name (`package/`, `node/`, …). +- E2E tests run the `craft` binary via `assert_cmd` in a tempdir with `CRAFT_HOME` and the mock registry URL, then assert with `node -e "require(...)"` where Node is available. + +**Fixture scenarios to add now** (each later task turns its scenario green): +peer deps, root alias, transitive alias, `@types`-style tarball root, dist-tag spec, `file:` spec, +dangling symlink in `node_modules`, failing script exit code, scoped package with string `bin`, +404 package, corrupt tarball / wrong integrity, optional platform dep. + +### 0.4 Lint / CI hygiene Β· P2 βœ… β€” βœ” done + +> Done: `make lint` runs `cargo fmt --check` + `clippy --workspace --all-targets -D warnings`; `clippy.toml` sets `allow-unwrap-in-tests`; `process`/`tarball` moved to edition 2024 with workspace lints; template `add()`, `InstallPackage::satisfies` and the `semver` dependency removed; the verbose log filter covers every workspace crate (actor logs were previously dropped); `Cli::normalize` returns a new `cli::Action` enum so the manager only sees `Add`/`Remove`/`Run`/`Cache`/`Install`; CI runs `make` on Ubuntu and macOS. +> +> Deferred: denying `clippy::expect_used` outside tests waits for 1.1 (most remaining `expect`s are the panics 1.1 removes); `windows-latest` joins the CI matrix in 6.4, since bins and directory links don't work on Windows yet. + +**Problem** +- `cargo clippy --all-targets` fails: 14 `unwrap_used` errors in `crates/actor/src/{install_actor,remove_package_actor}.rs` tests. CI passes only because the Makefile lints without `--all-targets`. +- `crates/process` and `crates/tarball` use edition 2021 and don't opt into `[lints] workspace = true`. +- Dead code: `crates/tarball/src/lib.rs` template `add()` fn; `InstallPackage::satisfies` (`install_package.rs:58`) is unused and uses Cargo semver, not npm semver; `crates/lockfile` and `crates/progress` are not depended on by anything (keep β€” used in Phase 3 / 6.1). +- `debug::init` filter (`crates/debug/src/debug.rs:11`) omits `actor`, `network`, `tarball`, `process`, `lockfile`. +- `manager.rs` handles `Start`, `Test`, `External` again after `Cli::normalize` already rewrote them β€” unreachable branches. + +**Fix** +- Makefile `lint`: `cargo clippy --workspace --all-targets -- -D warnings` + `cargo fmt --check`. +- Allow `unwrap`/`expect` in tests via `#![cfg_attr(test, allow(clippy::unwrap_used))]` or switch tests to `-> Result<()>` with `?`. +- Edition 2024 + workspace lints everywhere; consider also denying `clippy::expect_used` outside tests (would have caught 1.1). +- Remove the dead code listed above; make `normalize()` return a smaller enum so the manager can't see un-normalized variants. +- CI matrix: `ubuntu-latest`, `macos-latest`, `windows-latest`. + +--- + +## Phase 1 β€” Correctness fixes (current layout) + +Targeted fixes that don't need the store redesign. Some code (linker) will be rewritten in Phase 2; +keep fixes there minimal and put the logic in reusable helpers so it carries over. + +### 1.1 Dependency spec classification β€” no more panics Β· P0 βœ… β€” βœ” done + +> Done: `package::DependencySpec` (`Registry`/`Alias`/`Git`/`Tarball`/`File`/`Link`/`Workspace`) with `VersionRequirement` (`Exact`/`Range`/`Tag`) parses every `package.json` spec and `craft add` literal; `""`/`*` mean any version, invalid specs and unsupported kinds return `SpecError` instead of panicking. `select_version` follows npm: a tag's version, else `latest` when it satisfies the range, else the highest satisfying stable version. `from_literal` splits at the first `@` after a scope (aliases like `sw@npm:string-width@^4` now parse) and keeps git URLs/paths whole. The broken `GitResolver` and `InstallPackage::is_git` were removed. Root packages are now linked to the exact artifact they resolved to (see 1.2). `clippy::expect_used` is denied outside tests; `testkit` and the e2e crate allow it. 4 known-bug e2e tests now pass. + +**Problem** β€” `crates/resolver/src/npm.rs:38` does `Range::parse(req_version).expect(..)`. Any spec that isn't a semver range panics (exit 101): + +``` +$ craft add ms@latest +thread 'main' panicked at crates/resolver/src/npm.rs:38:57: +should not panic: SemverError { input: "latest", ... NoValidRanges } +``` + +Reproduced for `latest`, `file:../a`, `github:lodash/lodash`, `https://…/ms-2.1.3.tgz`, `workspace:*`. +`linker_pipe.rs:61,137,144` also `expect` on `Version::parse` (panics for git artifacts with version `"git"`). +`is_git()` checks the package **name** (`install_package.rs:79`), but in `package.json` git URLs live in the **version** field. + +**Fix** β€” replace `DependencySpec { package_name, version }` with an enum parsed once from `(name, spec)`: + +```rust +pub enum DependencySpec { + Range { name: String, range: Range }, // "^1.2.3", "1.x || >=3", "", "*" + Tag { name: String, tag: String }, // "latest", "next", "beta" + Version { name: String, version: Version }, // "1.2.3" (fast path) + Alias { alias: String, target: Box }, // "npm:pkg@^1" + Git { name: String, url: String, committish: Option }, // git+https, git+ssh, github:, gitlab:, bitbucket:, "user/repo" + Tarball { name: String, url: String }, // http(s)://…/*.tgz + File { name: String, path: PathBuf }, // file: + Link { name: String, path: PathBuf }, // link: + Workspace { name: String, range: String }, // workspace: +} +``` + +- Empty string and `*` β†’ any range. Invalid input β†’ `Err` with the package name and spec in the message. +- `InstallPackage::from_literal` (`craft add pkg@spec`) parses through the same function. +- Dist-tag resolution: look up `dist-tags[tag]`. +- Range resolution should match npm: prefer `dist-tags.latest` when it satisfies the range, else highest satisfying non-prerelease. +- Until 1.13 / Phase 7, `Git`/`Tarball`/`File`/`Link`/`Workspace` return a clear `unsupported dependency type` error β€” never a panic. +- Replace every `expect("should not panic")` in `npm.rs` and `linker_pipe.rs` with fallible code (skip unparsable registry versions with a `debug::warning!`). +- Then deny `clippy::expect_used` outside tests in the workspace lints (deferred from 0.4). + +**Done when** the spec table above is unit-tested; the E2E dist-tag fixture installs; no `expect` remains in `resolver`/`pipeline` non-test code. + +### 1.2 `InstallPipe` returns a resolution graph Β· P0 πŸ“– β€” βœ” done + +**Problem** β€” `InstallPipe::run` returns a deduplicated `Vec` (`install_pipe.rs:149-165`). The linker then **re-guesses** which artifact each dependency edge meant by name + "highest satisfying version" (`linker_pipe.rs:46-64`, `125-148`). Every alias, multi-version and "which version did the root resolve to" bug comes from this lost information. + +> Done: `resolver::graph` defines `ResolutionGraph { roots, nodes }`, `ResolvedNode { artifact, dependencies }` and `Edge { name, spec, target, kind }` keyed by `NodeId` (`name@version`, `BTreeMap` for deterministic order). `InstallPipe::resolve_package` returns the `NodeId` each request resolved to and records edges as it recurses; each version is downloaded and walked once (claimed-node set), and cycles resolve without waiting on themselves. `LinkerPipe` links exactly the graph's edges and no longer depends on `node-semver`. `craft add` reads root edges from the graph. + +**Fix** +- Return a graph: + +```rust +pub struct ResolutionGraph { + pub nodes: HashMap, // NodeId = "name@version" + pub roots: Vec, // from package.json +} +pub struct ResolvedNode { artifact: ResolvedArtifact, deps: Vec } +pub struct Edge { link_name: String /* alias-aware */, spec: String, target: NodeId, kind: DepKind /* Prod|Dev|Optional|Peer */ } +``` + +- Each `resolve_package` call returns its `NodeId`; record the edge from the parent at that point. +- Linker consumes edges directly: no `Range::parse` in the linker at all. +- This graph is what the lockfile (Phase 3) serializes. + +**Done when** `LinkerPipe` has no version matching logic and links exactly the edges it's given. + +### 1.3 npm alias linking Β· P0 βœ… β€” βœ” done + +> Done with 1.2: every link is created at `node_modules/`, so root and transitive aliases resolve under Node, and `craft add sw@npm:string-width@^4.2.0` saves `"sw": "npm:string-width@^4.2.3"`. Verified against the real registry with `@isaacs/cliui` (`string-width-cjs`). + +**Problem** β€” aliases resolve but never link. `artifact_map` is keyed by real name, lookups use the alias name (`linker_pipe.rs:46`, `117`), and the destination uses `artifact.name` (`linker_pipe.rs:168`). + +``` +"sw": "npm:string-width@^4.2.0" β†’ node_modules/ is empty, exit 0 +"@isaacs/cliui": "8.0.2" β†’ Error: Cannot find module 'string-width-cjs' +``` + +**Fix** β€” with 1.2 in place, link at `node_modules/` β†’ target node. Same for transitive edges. +`craft add sw@npm:string-width@^4` must save `"sw": "npm:string-width@^4.x.y"`. + +**Done when** both fixtures above `require()` successfully. + +### 1.4 Tarball root-directory stripping Β· P0 βœ… β€” βœ” done + +> Done: `tarball::gzip::unzip` strips whatever root folder entries sit under and extracts into `Context::package_dir` (`/-/package`), the one path the install and linker pipes share. Entries with `..`, absolute paths or a non-folder root are rejected (`TarballError::UnsafePath`); symlinks and hardlinks are skipped, as npm does. Files and dirs get default permissions, with the execute bit kept for files that had one. The `-/package` layout stays until the store redesign (2.1). Caches extracted with the old code under a non-`package/` root are re-extracted, since their `package/` dir is missing. + +**Problem** β€” the linker assumes the archive root is `package/` (`linker_pipe.rs:33`, `163`). `@types/*` tarballs use `node/`, some older packages use other names: + +``` +node_modules/@types/node -> ~/.craft/packages/@types/node-22.20.5/package (does not exist) +``` + +**Fix** β€” in `tarball::gzip::unzip`, strip the first path component of every entry (iterate `archive.entries()`, rewrite path, `entry.unpack_in`-style safety checks for `..` and absolute paths). Extract to `/@/` directly so the linker never guesses a subdirectory. +Also normalize permissions (some tarballs have `0o000` dirs) β€” files `0o644`, dirs and bins `0o755`. + +**Done when** the `@types`-style fixture links to a dir containing `index.d.ts`. + +### 1.5 HTTP status checks + friendly registry errors Β· P0 βœ… β€” βœ” done + +> Done: `Network::fetch` / `download` turn non-2xx responses into `NetworkError::Status { url, status }` before reading the body, so error pages are never parsed or written to the cache. `NpmResolver` maps 404 β†’ `RegistryError::PackageNotFound`, 401/403 β†’ `RegistryError::AccessDenied` (credentials hint); anything else keeps its cause under "failed to fetch {name} from {registry}". `InstallPipe` threads the resolved ancestry through recursion and wraps resolve/fetch failures once, at the failing request: `failed to install ghost@^1.0.0 (required by express@4.21.2 > body-parser@1.20.3)`. Retrying 429/5xx is left to 5.4. + +**Problem** +- `Network::fetch` and `Network::download` (`crates/network/src/network.rs:21-37`) never check `response.status()`. A 404/500 body is saved as a `.tgz`, or parsed as a packument. +- Unknown package error today: + +``` +Caused by: missing field `name` at line 1 column 21 +``` + +**Fix** +- `response.error_for_status()`; map 404 β†’ `PipelineError::PackageNotFound { name }`, 401/403 β†’ auth error hint, 429/5xx β†’ retryable (5.4). +- Error messages name the package and the spec that requested it, plus the parent chain if transitive (`express > body-parser > foo`). + +### 1.6 Atomic download and extraction Β· P0 πŸ“– β€” βœ” done + +> Done: `Network::download` writes to a `NamedTempFile` beside the target and renames it into place; `tarball::gzip::unzip` extracts into a `.extract-*` staging dir beside `package/` and renames it, keeping the other copy if another process got there first. A failed extraction removes its staging dir. `InstallPipe::fetch` checks for the extracted package before downloading, so a missing `.tgz` no longer triggers a re-download. Verified by `kill -9` at several points of a 71-package real-registry install (2–69 packages extracted): every re-run succeeded. Not done: a completion marker β€” dirs half-extracted by craft builds older than this are still trusted (`craft cache clean` clears them). Concurrent installs still race while linking into the shared cache (1.8 / 2.2), integrity before rename is 1.7. + +**Problem** +- `Resolver::download` treats `file_path.exists()` as "cached" (`crates/resolver/src/resolver.rs:67`). `Network::download` creates the final file then writes into it β€” a killed process leaves a truncated `.tgz` that is reused forever. +- Same for extraction: `if !unzip_dir.exists() { unzip(..) }` (`install_pipe.rs:88`) β€” half-extracted dirs are reused forever. +- Locks are in-process only (`download_locks`, `unzip_locks`), so two `craft` processes race. + +**Fix** +- Download to `.tmp--`, verify integrity (1.7), then `rename` into place (atomic on the same filesystem). +- Extract into `.tmp-`, then `rename`; if the rename fails because the target now exists, another process won β€” delete the temp dir and continue. +- Optional: a marker file (`.craft-complete`) written last, and treat dirs without it as absent. + +**Done when** killing `craft` mid-install and re-running produces a working install; two concurrent installs never error. + +### 1.7 Integrity verification Β· P0 πŸ“– β€” βœ” done + +> Done: `PackageDist` reads `integrity` and `shasum`; `network::Integrity` parses SRI (`sha512`/`sha384`/`sha256`/`sha1`, strongest listed algorithm wins, `?options` and unknown algorithms ignored) or falls back to the sha1 `shasum`, and is stored on `ResolvedArtifact` for the lockfile. `Network::download` verifies before the atomic rename, so a mismatch (`IntegrityError::Mismatch`, both hashes in the message) leaves nothing in the cache. A cached `.tgz` is re-verified before reuse and downloaded again if it no longer matches. Hashing still buffers the whole body; streaming is 5.5. Also fixed: the e2e suite stalled for 90s in about half the runs, because tiny_http's thread pool loses wakeups while threads sit on keep-alive connections; `MockRegistry` now uses a std `TcpListener` that answers one request per connection. + +**Problem** β€” `PackageDist` only has `tarball` (`crates/package/src/npm.rs:58-60`); `dist.integrity` / `dist.shasum` are ignored. Nothing stops a corrupted or tampered tarball from being installed. + +**Fix** +- Add `integrity: Option` and `shasum: Option` to `PackageDist`. +- Verify SRI (`sha512-`, also accept `sha256`/`sha1`) using `ssri` or `sha2` + `base64`; fall back to `shasum` (sha1 hex). Hash while streaming (5.5). +- Mismatch β†’ delete the temp file, error `IntegrityMismatch { name, version, expected, actual }`. +- Store integrity on `ResolvedArtifact` (needed by the lockfile). + +**Done when** the corrupt-tarball fixture fails with an integrity error and leaves nothing in the cache. + +### 1.8 Symlink-safe filesystem helpers Β· P0 βœ… β€” βœ” done + +> Done: new `fsutil` crate. `remove_entry` removes a file, tree or symlink (dangling included) without following it. `force_symlink_dir` / `force_symlink_file` create the link under a unique staging name and rename it over the destination, so stale entries, dangling links and concurrent writers never surface as `EEXIST`. `ensure_dir` replaces anything in the way of a directory (a dangling `.bin` or `@scope` link, a stray file). `relative_target` gives `.bin` links npm-style targets (`../typescript/bin/tsc`); package links stay absolute because they point into `~/.craft`. The linker and `craft remove` use them everywhere. The concurrent-install e2e scenario now passes (25/25 runs), so it is no longer ignored; the cross-project interference it stood for remains a 2.2 concern. + +**Problem** β€” `Path::exists()` follows symlinks, so a dangling link looks absent; the next `symlink()` fails with `EEXIST`, and `remove` skips it. + +``` +$ ln -s /nonexistent node_modules/express && craft install +Error: File exists (os error 17) +$ craft remove lodash # lodash is a dangling link β†’ left in place, exit 0 +``` + +Occurrences: `linker_pipe.rs:79`, `176`, `236`; `remove_package_actor.rs:32`. + +**Fix** β€” one helper module (e.g. `crates/fsutil` or inside `pipeline`): + +```rust +async fn remove_entry(path: &Path) -> io::Result<()> // symlink_metadata: file/symlink β†’ remove_file, dir β†’ remove_dir_all, NotFound β†’ Ok +async fn force_symlink_dir(target: &Path, link: &Path) -> io::Result<()> // remove_entry + symlink, retry once on EEXIST +``` + +Use relative symlink targets where possible (relocatable `node_modules`). Use it everywhere links are created or removed. + +### 1.9 `craft add` fixes Β· P1 βœ… β€” βœ” done + +> Done: `craft add` reads `package.json` before resolving anything, so a missing one fails with no registry traffic. Saved specs follow npm: `^` for tags, ranges and exact versions, the exact version with the new `-E/--exact`, and `npm:@…` for aliases (from the graph's root edges since 1.2). Adding with or without `-D` moves an existing entry out of the other section. Left for later: suggesting `craft init` (6.3), saving git/file specs verbatim (1.13), and installing all dependencies so the lockfile stays consistent (Phase 3). + +**Problems** (`crates/actor/src/add_package_actor.rs`) +- ~~`craft add react@18` installs but does not update `package.json`~~ (fixed in 1.1). +- ~~When several versions of a name are resolved, `find` picks an arbitrary one~~ (fixed in 1.1). +- ~~`package.json` is read **after** installing (line 37); with no `package.json`, all work is done then it fails.~~ +- Only the added packages are installed/linked β€” existing deps aren't verified, and once the lockfile exists it must be updated too. + +**Fix** +- Read `package.json` first; error early if missing (suggest `craft init`, 6.3). +- Save rules (match npm): tag or range spec β†’ `^`; exact version spec β†’ `^` unless `-E/--exact`; alias β†’ `npm:@^`; git/file β†’ the original spec. +- If the package already exists in the other section (`dependencies` vs `devDependencies`), move it. +- After Phase 3: run a full install (all deps) so the lockfile stays consistent. + +### 1.10 Preserve `package.json` formatting Β· P1 βœ… β€” βœ” done + +> Done: `package::ProjectManifest` edits `package.json` as an order-preserving `serde_json` map (`preserve_order` enabled) and writes back the detected indent (spaces or tabs, 2 by default for minified files), CRLF line endings and trailing newline; a BOM is dropped. New entries go in at their alphabetical position, updated ones keep theirs, and a section emptied by removal is deleted. `craft add` and `craft remove` both use it, and `remove` only writes when something changed. Verified byte-identical add β†’ remove round trips on this repo's `package.json` and a tab/CRLF file against the real registry. The typed `PackageJson` remains for reading. + +**Problem** β€” writes go through the typed `PackageJson` struct with a `HashMap` `other` field (`crates/package/src/npm.rs:28-29`) and `serde_json` without `preserve_order`. Result: top-level keys reorder between runs (`private`/`type` swapped in testing), indentation is forced to 2 spaces, trailing newline is dropped β†’ noisy git diffs. + +**Fix** +- Enable `serde_json`'s `preserve_order` feature. +- Edit `package.json` as a `serde_json::Value` (only touching `dependencies`/`devDependencies`/…), not by re-serializing the typed struct. +- Detect indentation (tab / N spaces) and the trailing newline from the original file and reproduce them. +- New dependency maps are sorted alphabetically (npm behaviour); existing ones keep order with the new key inserted sorted. +- Keep the typed `PackageJson` for reading registry manifests only. + +**Done when** `add` then `remove` of the same package produces a byte-identical `package.json`. + +### 1.11 `craft remove` fixes Β· P1 βœ… β€” βœ” done + +> Done: `craft remove` deletes every `.bin` link whose target (resolved lexically, relative or absolute) lies inside the removed package, so other packages' bins stay. A package listed in neither dependency section prints `warning: is not a dependency of this project` to stderr and leaves `package.json` untouched. Dangling links (1.8) and write-only-when-changed (1.10) were already done. Left for later: pruning orphaned transitive deps (2.5) and updating the lockfile (Phase 3). + +**Problems** (`crates/actor/src/remove_package_actor.rs`) +- Dangling symlinks not removed (1.8). +- The package's bins in `node_modules/.bin` are left behind. +- `package.json` is rewritten even when nothing changed; a package not in `package.json` gives no user-facing message. +- Orphaned transitive deps are not pruned (fixed properly by 2.5). + +**Fix** β€” use 1.8 helpers; remove bins whose link target is inside the removed package; only write when changed (1.10); warn ` is not a dependency`; update lockfile (Phase 3). + +### 1.12 `craft run` fixes Β· P1 βœ… β€” βœ” done + +> Done: scripts run with every ancestor's `node_modules/.bin` in front of `PATH`, `INIT_CWD`, `npm_lifecycle_event`/`_script`, `npm_package_name`/`_version`/`_json` and `npm_config_user_agent=craft/ `. `pre`/`post` run around the script, stopping at the first failure, and only the main script gets the arguments, each shell-quoted. Without a matching script, `craft ` / `craft run ` spawns the nearest `node_modules/.bin/` directly with an argv array, and works without a `package.json`. Otherwise it fails with `script "" not found; available scripts: …` β€” the raw-shell fallback is gone (`craft exec`, 6.3). A failing script exits craft with its own code (128 + signal when killed) and one `error: exited with code N` line. craft ignores SIGINT while the child runs, so Ctrl-C reaches the script through the terminal's process group and craft exits with the script's code. Not done: adding the `node` binary's directory to `PATH`, and Windows `cmd` quoting beyond the basics (6.4). + +**Problems** (`crates/actor/src/run_script_actor.rs`, `crates/process/src/process.rs`) + +| Problem | Repro | Location | +|---|---|---| +| `node_modules/.bin` not on `PATH` | `"ver": "semver 1.2.3"` β†’ `sh: semver: command not found` | `process.rs:43-67` | +| Exit code replaced by 1 | `"fail": "exit 3"` β†’ craft exits 1 with `Error: Command failed with status: exit status: 3` | `process.rs:63` + `main.rs` | +| Args joined unquoted into `sh -c` | `craft run show 'a; echo INJECTED'` runs `echo INJECTED` | `run_script_actor.rs:57-60` | +| `pre