From cf83886557946ac983e47300048f5b31c0667db1 Mon Sep 17 00:00:00 2001 From: "guillem.cordoba" Date: Tue, 12 Mar 2024 18:00:18 +0100 Subject: [PATCH] WIP --- .../Cargo.lock | 428 ++++++++++++++++++ .../Cargo.toml | 8 +- .../fixture/package.json | 17 + .../src/main.rs | 70 +++ .../sync-npm-dependencies-with-nix/Cargo.lock | 176 ------- .../src/main.rs | 26 -- flake.nix | 4 +- nix/fixture/flake.lock | 2 +- nix/fixture/flake.nix | 6 +- nix/fixture/package-lock.json | 5 +- nix/fixture/package.json | 17 +- nix/fixture/zome/package.json | 24 +- package-lock.json | 2 +- 13 files changed, 554 insertions(+), 231 deletions(-) create mode 100644 crates/replace-npm-dependencies-sources/Cargo.lock rename crates/{sync-npm-dependencies-with-nix => replace-npm-dependencies-sources}/Cargo.toml (51%) create mode 100644 crates/replace-npm-dependencies-sources/fixture/package.json create mode 100644 crates/replace-npm-dependencies-sources/src/main.rs delete mode 100644 crates/sync-npm-dependencies-with-nix/Cargo.lock delete mode 100644 crates/sync-npm-dependencies-with-nix/src/main.rs diff --git a/crates/replace-npm-dependencies-sources/Cargo.lock b/crates/replace-npm-dependencies-sources/Cargo.lock new file mode 100644 index 0000000..7061cc4 --- /dev/null +++ b/crates/replace-npm-dependencies-sources/Cargo.lock @@ -0,0 +1,428 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "aho-corasick" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" +dependencies = [ + "memchr", +] + +[[package]] +name = "anstream" +version = "0.6.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d96bd03f33fe50a863e394ee9718a706f988b9079b20c3784fb726e7678b62fb" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "utf8parse", +] + +[[package]] +name = "anstyle" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8901269c6307e8d93993578286ac0edf7f195079ffff5ebdeea6a59ffb7e36bc" + +[[package]] +name = "anstyle-parse" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c75ac65da39e5fe5ab759307499ddad880d724eed2f6ce5b5e8a26f4f387928c" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e28923312444cdd728e4738b3f9c9cac739500909bb3d3c94b43551b16517648" +dependencies = [ + "windows-sys", +] + +[[package]] +name = "anstyle-wincon" +version = "3.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1cd54b81ec8d6180e24654d0b371ad22fc3dd083b6ff8ba325b72e00c87660a7" +dependencies = [ + "anstyle", + "windows-sys", +] + +[[package]] +name = "anyhow" +version = "1.0.81" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0952808a6c2afd1aa8947271f3a60f1a6763c7b912d210184c5149b5cf147247" + +[[package]] +name = "bstr" +version = "1.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05efc5cfd9110c8416e471df0e96702d58690178e206e61b7173706673c93706" +dependencies = [ + "memchr", + "serde", +] + +[[package]] +name = "clap" +version = "4.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b230ab84b0ffdf890d5a10abdbc8b83ae1c4918275daea1ab8801f71536b2651" +dependencies = [ + "clap_builder", + "clap_derive", +] + +[[package]] +name = "clap_builder" +version = "4.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae129e2e766ae0ec03484e609954119f123cc1fe650337e155d03b022f24f7b4" +dependencies = [ + "anstream", + "anstyle", + "clap_lex", + "strsim", +] + +[[package]] +name = "clap_derive" +version = "4.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "307bc0538d5f0f83b8248db3087aa92fe504e4691294d0c96c0eabc33f47ba47" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "clap_lex" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "98cc8fbded0c607b7ba9dd60cd98df59af97e84d24e49c8557331cfc26d301ce" + +[[package]] +name = "colorchoice" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" + +[[package]] +name = "crossbeam-deque" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "613f8cc01fe9cf1a3eb3d7f488fd2fa8388403e97039e2f73692932e291a770d" +dependencies = [ + "crossbeam-epoch", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-epoch" +version = "0.9.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "248e3bacc7dc6baa3b21e405ee045c3047101a49145e7e9eca583ab4c2ca5345" + +[[package]] +name = "globset" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57da3b9b5b85bd66f31093f8c408b90a74431672542466497dcbdfdc02034be1" +dependencies = [ + "aho-corasick", + "bstr", + "log", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "heck" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" + +[[package]] +name = "ignore" +version = "0.4.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b46810df39e66e925525d6e38ce1e7f6e1d208f72dc39757880fcb66e2c58af1" +dependencies = [ + "crossbeam-deque", + "globset", + "log", + "memchr", + "regex-automata", + "same-file", + "walkdir", + "winapi-util", +] + +[[package]] +name = "itoa" +version = "1.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" + +[[package]] +name = "log" +version = "0.4.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" + +[[package]] +name = "memchr" +version = "2.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" + +[[package]] +name = "proc-macro2" +version = "1.0.79" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e835ff2298f5721608eb1a980ecaee1aef2c132bf95ecc026a11b7bf3c01c02e" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "regex-automata" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86b83b8b9847f9bf95ef68afb0b8e6cdb80f498442f5179a29fad448fcc1eaea" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" + +[[package]] +name = "replace-npm-dependencies-sources" +version = "0.1.0" +dependencies = [ + "anyhow", + "clap", + "ignore", + "serde", + "serde_json", +] + +[[package]] +name = "ryu" +version = "1.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e86697c916019a8588c99b5fac3cead74ec0b4b819707a682fd4d23fa0ce1ba1" + +[[package]] +name = "same-file" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "serde" +version = "1.0.197" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fb1c873e1b9b056a4dc4c0c198b24c3ffa059243875552b2bd0933b1aee4ce2" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.197" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.114" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c5f09b1bd632ef549eaa9f60a1f8de742bdbc698e6cee2095fc84dde5f549ae0" +dependencies = [ + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "strsim" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ee073c9e4cd00e28217186dbe12796d692868f432bf2e97ee73bed0c56dfa01" + +[[package]] +name = "syn" +version = "2.0.52" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b699d15b36d1f02c3e7c69f8ffef53de37aefae075d8488d4ba1a7788d574a07" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "unicode-ident" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" + +[[package]] +name = "utf8parse" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" + +[[package]] +name = "walkdir" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b" +dependencies = [ + "same-file", + "winapi-util", +] + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-util" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596" +dependencies = [ + "winapi", +] + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.52.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7dd37b7e5ab9018759f893a1952c9420d060016fc19a472b4bb20d1bdd694d1b" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bcf46cf4c365c6f2d1cc93ce535f2c8b244591df96ceee75d8e83deb70a9cac9" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da9f259dd3bcf6990b55bffd094c4f7235817ba4ceebde8e6d11cd0c5633b675" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b474d8268f99e0995f25b9f095bc7434632601028cf86590aea5c8a5cb7801d3" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1515e9a29e5bed743cb4415a9ecf5dfca648ce85ee42e15873c3cd8610ff8e02" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5eee091590e89cc02ad514ffe3ead9eb6b660aedca2183455434b93546371a03" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77ca79f2451b49fa9e2af39f0747fe999fcda4f5e241b2898624dca97a1f2177" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32b752e52a2da0ddfbdbcc6fceadfeede4c939ed16d13e648833a61dfb611ed8" diff --git a/crates/sync-npm-dependencies-with-nix/Cargo.toml b/crates/replace-npm-dependencies-sources/Cargo.toml similarity index 51% rename from crates/sync-npm-dependencies-with-nix/Cargo.toml rename to crates/replace-npm-dependencies-sources/Cargo.toml index aa2a950..579bc73 100644 --- a/crates/sync-npm-dependencies-with-nix/Cargo.toml +++ b/crates/replace-npm-dependencies-sources/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "sync-npm-dependencies-with-nix" +name = "replace-npm-dependencies-sources" version = "0.1.0" edition = "2021" @@ -7,5 +7,7 @@ edition = "2021" [dependencies] anyhow = "1.0.81" -parse-flake-lock = { git = "https://github.com/DeterminateSystems/flake-checker", branch = "main" } -walkdir = "2.5.0" +clap = {version ="4.5.2", features = ["derive"]} +ignore = "0.4" +serde_json = {version ="1", features = ["std"]} +serde = "1" diff --git a/crates/replace-npm-dependencies-sources/fixture/package.json b/crates/replace-npm-dependencies-sources/fixture/package.json new file mode 100644 index 0000000..aed5c20 --- /dev/null +++ b/crates/replace-npm-dependencies-sources/fixture/package.json @@ -0,0 +1,17 @@ +{ + "author": "", + "dependencies": { + "@holochain-open-dev/profiles": "2221" + }, + "description": "", + "keywords": [], + "license": "ISC", + "main": "index.js", + "name": "zome", + "scripts": { + "build": "", + "start": "node index.js" + }, + "type": "module", + "version": "1.0.0" +} \ No newline at end of file diff --git a/crates/replace-npm-dependencies-sources/src/main.rs b/crates/replace-npm-dependencies-sources/src/main.rs new file mode 100644 index 0000000..75193a9 --- /dev/null +++ b/crates/replace-npm-dependencies-sources/src/main.rs @@ -0,0 +1,70 @@ +use anyhow::Result; +use ignore::Walk; +use serde_json::Value; +use std::{collections::HashMap, fs::File, io::BufReader, process::Command}; + +use clap::Parser; + +#[derive(Parser)] +#[command(version, about, long_about = None)] +struct Cli { + /// List of dependencies to replace, in the form = + dependencies_to_replace: Vec, +} + +fn parse_args() -> Result> { + let cli = Cli::parse(); + + let mut deps: HashMap = HashMap::new(); + + for dep in cli.dependencies_to_replace { + let split: Vec<&str> = dep.split('=').into_iter().collect(); + deps.insert(split[0].to_string(), split[1].to_string()); + } + + Ok(deps) +} + +fn main() -> Result<()> { + let deps_to_replace = parse_args()?; + + let mut replaced_some_dep = false; + + for entry in Walk::new(".").into_iter().filter_map(|e| e.ok()) { + let f_name = entry.file_name().to_string_lossy(); + + if f_name == "package.json" { + let file = File::open(entry.path())?; + let reader = BufReader::new(file); + let mut package_json_contents: Value = serde_json::from_reader(reader)?; + + if let Some(Value::Object(deps)) = package_json_contents.get_mut("dependencies") { + for (dep_to_replace, new_source) in &deps_to_replace { + if let Some(found_dep) = deps.get_mut(dep_to_replace) { + match &found_dep { + Value::String(old_source) if old_source.eq(new_source) => {} + _ => { + *found_dep = Value::String(new_source.clone()); + println!( + "{:?}: setting dependency \"{dep_to_replace}\" to \"{new_source}\"", + entry.path() + ); + replaced_some_dep = true; + } + } + } + } + } + + let st = serde_json::to_string_pretty(&package_json_contents)?; + + std::fs::write(entry.path(), st)?; + } + } + + if replaced_some_dep { + Command::new("npm").arg("install").output()?; + } + + Ok(()) +} diff --git a/crates/sync-npm-dependencies-with-nix/Cargo.lock b/crates/sync-npm-dependencies-with-nix/Cargo.lock deleted file mode 100644 index 049c1ab..0000000 --- a/crates/sync-npm-dependencies-with-nix/Cargo.lock +++ /dev/null @@ -1,176 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 3 - -[[package]] -name = "anyhow" -version = "1.0.81" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0952808a6c2afd1aa8947271f3a60f1a6763c7b912d210184c5149b5cf147247" - -[[package]] -name = "itoa" -version = "1.0.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" - -[[package]] -name = "parse-flake-lock" -version = "0.1.0" -source = "git+https://github.com/DeterminateSystems/flake-checker?branch=main#267211ab35fdd1792cdfcfcf9f98901d89971f99" -dependencies = [ - "serde", - "serde_json", - "thiserror", -] - -[[package]] -name = "proc-macro2" -version = "1.0.79" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e835ff2298f5721608eb1a980ecaee1aef2c132bf95ecc026a11b7bf3c01c02e" -dependencies = [ - "unicode-ident", -] - -[[package]] -name = "quote" -version = "1.0.35" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" -dependencies = [ - "proc-macro2", -] - -[[package]] -name = "ryu" -version = "1.0.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e86697c916019a8588c99b5fac3cead74ec0b4b819707a682fd4d23fa0ce1ba1" - -[[package]] -name = "same-file" -version = "1.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" -dependencies = [ - "winapi-util", -] - -[[package]] -name = "serde" -version = "1.0.197" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fb1c873e1b9b056a4dc4c0c198b24c3ffa059243875552b2bd0933b1aee4ce2" -dependencies = [ - "serde_derive", -] - -[[package]] -name = "serde_derive" -version = "1.0.197" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "serde_json" -version = "1.0.114" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5f09b1bd632ef549eaa9f60a1f8de742bdbc698e6cee2095fc84dde5f549ae0" -dependencies = [ - "itoa", - "ryu", - "serde", -] - -[[package]] -name = "syn" -version = "2.0.52" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b699d15b36d1f02c3e7c69f8ffef53de37aefae075d8488d4ba1a7788d574a07" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "sync-npm-dependencies-with-nix" -version = "0.1.0" -dependencies = [ - "anyhow", - "parse-flake-lock", - "walkdir", -] - -[[package]] -name = "thiserror" -version = "1.0.58" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03468839009160513471e86a034bb2c5c0e4baae3b43f79ffc55c4a5427b3297" -dependencies = [ - "thiserror-impl", -] - -[[package]] -name = "thiserror-impl" -version = "1.0.58" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c61f3ba182994efc43764a46c018c347bc492c79f024e705f46567b418f6d4f7" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "unicode-ident" -version = "1.0.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" - -[[package]] -name = "walkdir" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b" -dependencies = [ - "same-file", - "winapi-util", -] - -[[package]] -name = "winapi" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" -dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", -] - -[[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" - -[[package]] -name = "winapi-util" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596" -dependencies = [ - "winapi", -] - -[[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" diff --git a/crates/sync-npm-dependencies-with-nix/src/main.rs b/crates/sync-npm-dependencies-with-nix/src/main.rs deleted file mode 100644 index 8c69663..0000000 --- a/crates/sync-npm-dependencies-with-nix/src/main.rs +++ /dev/null @@ -1,26 +0,0 @@ -use anyhow::Result; -use std::path::Path; - -use parse_flake_lock::{FlakeLock, FlakeLockParseError}; - -use walkdir::WalkDir; - -fn main() -> Result<()> { - for entry in WalkDir::new(".").into_iter().filter_map(|e| e.ok()) { - let f_name = entry.file_name().to_string_lossy(); - - if f_name == "package.json" { - println!("{}", f_name); - } - } - - Ok(()) -} - -// fn main() -> Result<(), FlakeLockParseError> { -// let flake_lock = FlakeLock::new(Path::new("flake.lock"))?; - -// println!("asdf {flake_lock:?}"); - -// Ok(()) -// } diff --git a/flake.nix b/flake.nix index 687126e..a737e16 100644 --- a/flake.nix +++ b/flake.nix @@ -147,11 +147,11 @@ ]; }; - packages.sync-npm-dependencies-with-nix = + packages.replace-npm-dependencies-sources = let craneLib = inputs.crane.lib.${system}; - cratePath = ./crates/sync-npm-dependencies-with-nix; + cratePath = ./crates/replace-npm-dependencies-sources; cargoToml = builtins.fromTOML (builtins.readFile "${cratePath}/Cargo.toml"); crate = cargoToml.package.name; diff --git a/nix/fixture/flake.lock b/nix/fixture/flake.lock index 8ce87c0..3a82a9c 100644 --- a/nix/fixture/flake.lock +++ b/nix/fixture/flake.lock @@ -1790,7 +1790,7 @@ }, "locked": { "lastModified": 0, - "narHash": "sha256-109s5Jy6JbqhsNvk8LfrNpAtNXDGN+K1LjIIwIwULsM=", + "narHash": "sha256-lELJg+tX2na9fQby6ogHS3Pt3Rpb3cd96LzHAhSXRuM=", "path": "../..", "type": "path" }, diff --git a/nix/fixture/flake.nix b/nix/fixture/flake.nix index ea9378d..d8948f0 100644 --- a/nix/fixture/flake.nix +++ b/nix/fixture/flake.nix @@ -63,14 +63,14 @@ # more packages go here cargo-nextest ] ++ [ - inputs'.hcUtils.packages.sync-npm-dependencies-with-nix + inputs'.hcUtils.packages.replace-npm-dependencies-sources ]; shellHook = '' - sync-npm-dependencies-with-nix ${builtins.trace (builtins.toString (builtins.map (p: "${p.meta.packageName}=${p.outPath}/lib") (builtins.attrValues (allNpmPackages {inherit inputs' self';})))) "hey"} + replace-npm-dependencies-sources ${builtins.toString (builtins.map (p: "${p.meta.packageName}=${p.outPath}/lib") (builtins.attrValues (allNpmPackages {inherit inputs' self';})))} ''; }; - + # packages.i = inputs'.profiles.packages.profiles_ui; }; }; } diff --git a/nix/fixture/package-lock.json b/nix/fixture/package-lock.json index 895a100..dee95dc 100644 --- a/nix/fixture/package-lock.json +++ b/nix/fixture/package-lock.json @@ -10,7 +10,10 @@ "license": "ISC", "workspaces": [ "./zome/" - ] + ], + "dependencies": { + "zome": "^1.0.0" + } }, "../../../../../../../../nix/store/hqsw2yppsm6gr4jdrqmxlrdm48j1397c--holochain-open-dev-profiles-0.0.0/lib": {}, "node_modules/@holochain-open-dev/profiles": { diff --git a/nix/fixture/package.json b/nix/fixture/package.json index 4429609..3b8ec81 100644 --- a/nix/fixture/package.json +++ b/nix/fixture/package.json @@ -1,9 +1,14 @@ { - "name": "fixture", - "version": "1.0.0", + "author": "", + "dependencies": { + "zome": "/nix/store/3l4n96ahxi1jd59srny1vyn59x7qxx75-zome/lib" + }, "description": "", - "workspaces": ["./zome/"], "keywords": [], - "author": "", - "license": "ISC" -} + "license": "ISC", + "name": "fixture", + "version": "1.0.0", + "workspaces": [ + "./zome/" + ] +} \ No newline at end of file diff --git a/nix/fixture/zome/package.json b/nix/fixture/zome/package.json index 19998e8..a9ee473 100644 --- a/nix/fixture/zome/package.json +++ b/nix/fixture/zome/package.json @@ -1,17 +1,17 @@ { - "name": "zome", - "version": "1.0.0", - "description": "", - "main": "index.js", - "type": "module", - "scripts": { - "start": "node index.js", - "build": "" - }, + "author": "", "dependencies": { "@holochain-open-dev/profiles": "file:/nix/store/hqsw2yppsm6gr4jdrqmxlrdm48j1397c--holochain-open-dev-profiles-0.0.0/lib" }, + "description": "", "keywords": [], - "author": "", - "license": "ISC" -} + "license": "ISC", + "main": "index.js", + "name": "zome", + "scripts": { + "build": "", + "start": "node index.js" + }, + "type": "module", + "version": "1.0.0" +} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 7a9c7eb..cc61581 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9885,7 +9885,7 @@ }, "packages/stores": { "name": "@holochain-open-dev/stores", - "version": "0.8.10", + "version": "0.8.11", "dependencies": { "@alenaksu/json-viewer": "^2.0.1", "@holochain-open-dev/utils": "^0.16.5",