-
Notifications
You must be signed in to change notification settings - Fork 36
feat: add .npmrc file support
#18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
ddb74bb
feat: add `.npmrc` file support
anonrig ff0417d
fix: remove unused dependency from npmrc crate
anonrig 09a5043
feat: use pathbuf instead of string
anonrig 5a13b0f
feat: use config from npmrc
anonrig caf602c
fix: move npmrc to registry
anonrig a98f22a
test: add initial cli tests
anonrig 5ce6c02
feat: add support for npmrc registry field
anonrig 1714455
fix: revert current directory after test
anonrig File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| [package] | ||
| name = "pacquet_npmrc" | ||
| version = "0.0.1" | ||
| publish = false | ||
| authors.workspace = true | ||
| description.workspace = true | ||
| edition.workspace = true | ||
| homepage.workspace = true | ||
| keywords.workspace = true | ||
| license.workspace = true | ||
| repository.workspace = true | ||
|
|
||
| [dependencies] | ||
| home = { workspace = true } | ||
| serde = { workspace = true } | ||
| serde_ini = { workspace = true } | ||
| thiserror = { workspace = true } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| use std::{env, path::Path, str::FromStr}; | ||
|
|
||
| use serde::{de, Deserialize, Deserializer}; | ||
|
|
||
| // This needs to be implemented because serde doesn't support default = "true" as | ||
| // a valid option, and throws "failed to parse" error. | ||
| pub fn bool_true() -> bool { | ||
| true | ||
| } | ||
|
|
||
| pub fn default_hoist_pattern() -> Vec<String> { | ||
| vec!["*".to_string()] | ||
| } | ||
|
|
||
| pub fn default_public_hoist_pattern() -> Vec<String> { | ||
| vec!["*eslint*".to_string(), "*prettier*".to_string()] | ||
| } | ||
|
|
||
| /// If the $PACQUET_HOME env variable is set, then $PACQUET_HOME/store | ||
| /// If the $XDG_DATA_HOME env variable is set, then $XDG_DATA_HOME/pacquet/store | ||
| /// On Windows: ~/AppData/Local/pacquet/store | ||
| /// On macOS: ~/Library/pacquet/store | ||
| /// On Linux: ~/.local/share/pacquet/store | ||
| pub fn default_store_dir() -> String { | ||
| if let Ok(pacquet_home) = env::var("$PACQUET_HOME") { | ||
| return Path::new(&pacquet_home).join("store").as_path().display().to_string(); | ||
| } | ||
|
|
||
| if let Ok(xdg_data_home) = env::var("$XDG_DATA_HOME") { | ||
| return Path::new(&xdg_data_home).join("pacquet/store").as_path().display().to_string(); | ||
| } | ||
|
|
||
| // https://doc.rust-lang.org/std/env/consts/constant.OS.html | ||
| match env::consts::OS { | ||
| "linux" => "~/.local/share/pacquet/store".to_string(), | ||
| "macos" => "~/Library/pacquet/store".to_string(), | ||
| "windows" => "~/AppData/Local/pacquet/store".to_string(), | ||
| _ => panic!("unsupported operating system: {0}", env::consts::OS), | ||
| } | ||
| } | ||
|
|
||
| pub fn default_modules_dir() -> String { | ||
| "node_modules".to_string() | ||
| } | ||
|
|
||
| pub fn default_virtual_store_dir() -> String { | ||
| "node_modules/.pacquet".to_string() | ||
| } | ||
|
|
||
| pub fn default_registry() -> String { | ||
| "https://registry.npmjs.org/".to_string() | ||
| } | ||
|
|
||
| pub fn default_modules_cache_max_age() -> u64 { | ||
| 10080 | ||
| } | ||
|
|
||
| pub fn deserialize_bool<'de, D>(deserializer: D) -> Result<bool, D::Error> | ||
| where | ||
| D: Deserializer<'de>, | ||
| { | ||
| let s = String::deserialize(deserializer)?; | ||
| bool::from_str(&s).map_err(de::Error::custom) | ||
| } | ||
|
|
||
| pub fn deserialize_u64<'de, D>(deserializer: D) -> Result<u64, D::Error> | ||
| where | ||
| D: Deserializer<'de>, | ||
| { | ||
| let s = String::deserialize(deserializer)?; | ||
| u64::from_str(&s).map_err(de::Error::custom) | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.