Skip to content
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

feat: store dir structure compatible with pnpm #166

Merged
merged 110 commits into from
Nov 2, 2023
Merged
Show file tree
Hide file tree
Changes from 81 commits
Commits
Show all changes
110 commits
Select commit Hold shift + click to select a range
54a81fd
feat: pacquet-store-dir
KSXGitHub Oct 29, 2023
13471c3
fix: file_path_by_hash_str
KSXGitHub Oct 30, 2023
30267c9
feat: serde
KSXGitHub Oct 30, 2023
b5ef876
feat: StoreDir::tmp
KSXGitHub Oct 30, 2023
a79c0a1
fix(cargo): path to a crate
KSXGitHub Oct 30, 2023
ddfeeb4
feat: impl From<PathBuf> for StoreDir
KSXGitHub Oct 30, 2023
b122d5c
test: StoreDir
KSXGitHub Oct 30, 2023
58c3837
feat: StoreDir::display
KSXGitHub Oct 30, 2023
68cfc31
feat: impl Eq for StoreDir
KSXGitHub Oct 30, 2023
6e4ed86
feat: StoreDir::file_path_by_content_address
KSXGitHub Oct 30, 2023
bb931d9
fix: borrow
KSXGitHub Oct 30, 2023
0ab7ff4
feat: use StoreDir
KSXGitHub Oct 30, 2023
c8526d0
feat: remove incomplete prune implementation
KSXGitHub Oct 30, 2023
1d716f2
fix: compile error
KSXGitHub Oct 30, 2023
e8c12fb
test(windows): fix
KSXGitHub Oct 30, 2023
90da00b
test(windows): fix
KSXGitHub Oct 30, 2023
6d43bce
refactor: remove unused items
KSXGitHub Oct 30, 2023
44c4f49
refactor: remove unnecessary `.to_path_buf()`
KSXGitHub Oct 30, 2023
185e4bf
test: file_path_by_content_address
KSXGitHub Oct 30, 2023
0c4e27c
refactor: StoreDir::new
KSXGitHub Oct 30, 2023
4e40463
refactor: combine `#[cfg(unix)]`
KSXGitHub Oct 30, 2023
deb1681
refactor: use sha2 directly
KSXGitHub Oct 30, 2023
c76724a
refactor: use `new_with_prefix`
KSXGitHub Oct 30, 2023
1ee7063
refactor: use `digest`
KSXGitHub Oct 30, 2023
5610e59
test: add back windows
KSXGitHub Oct 30, 2023
f1f4316
docs: add missing TODO
KSXGitHub Oct 30, 2023
b01abcd
refactor: pass suffix to write_sync
KSXGitHub Oct 30, 2023
4dfa84e
style: remove an empty line
KSXGitHub Oct 30, 2023
31148d3
feat: executable bits
KSXGitHub Oct 30, 2023
7b5d7bf
refactor: use early return
KSXGitHub Oct 30, 2023
dd430c6
feat: set executables as executable
KSXGitHub Oct 30, 2023
8d9eb49
fix: macos and windows
KSXGitHub Oct 30, 2023
3b6e68a
feat: index files
KSXGitHub Oct 31, 2023
871c8b6
fix: serde panics
KSXGitHub Oct 31, 2023
09c4222
docs: existing bugs
KSXGitHub Oct 31, 2023
9ea30e2
refactor: rename a function
KSXGitHub Oct 31, 2023
4fee0a3
refactor: StoreDir::file_path_by_hex_str
KSXGitHub Oct 31, 2023
8f98e73
fix: content address of the index files
KSXGitHub Oct 31, 2023
209e197
refactor: derive From for TaskError
KSXGitHub Oct 31, 2023
29e6901
refactor: move StoreDir to its own mod
KSXGitHub Oct 31, 2023
db673ef
refactor: move cafs into store-dir
KSXGitHub Oct 31, 2023
593dcdb
docs(store-dir): error type
KSXGitHub Oct 31, 2023
4c2141a
refactor: move TarballIndex into store-dir
KSXGitHub Oct 31, 2023
c7e8d9a
refactor: move a function to pacquet-fs
KSXGitHub Oct 31, 2023
b34a3f0
feat(fs): divide error variants into 2
KSXGitHub Oct 31, 2023
a77b775
refactor: rename
KSXGitHub Oct 31, 2023
e3821c1
refactor: correct categories
KSXGitHub Oct 31, 2023
1ef6d6f
refactor: remove unnecessary `pub(crate)`
KSXGitHub Oct 31, 2023
d9270f4
refactor: pass `executable` instead of `suffix`
KSXGitHub Oct 31, 2023
7d771db
refactor: remove FileSuffix and strum
KSXGitHub Oct 31, 2023
5f3050a
refactor: remove `Option` for `suffix`
KSXGitHub Oct 31, 2023
51c0672
refactor: rename a function
KSXGitHub Oct 31, 2023
fb18087
refactor: make_file_executable
KSXGitHub Oct 31, 2023
3ba5986
feat(fs): make_file_executable
KSXGitHub Oct 31, 2023
6782153
refactor: re-use make_file_executable
KSXGitHub Oct 31, 2023
b1c9e06
test: rename
KSXGitHub Oct 31, 2023
af24bd5
refactor: move some functions
KSXGitHub Oct 31, 2023
4bc61d0
fix: clippy on windows
KSXGitHub Oct 31, 2023
184cf13
test: tarball_index_file_path
KSXGitHub Oct 31, 2023
d31bd5e
fix: clippy on windows
KSXGitHub Oct 31, 2023
9a61217
chore(git): merge
KSXGitHub Oct 31, 2023
ac01df0
clippy: fix on windows
KSXGitHub Oct 31, 2023
8d46b55
chore(git): merge
KSXGitHub Oct 31, 2023
a757a85
fix: only make file executable when executable
KSXGitHub Oct 31, 2023
fa4562e
chore(git): merge from main
KSXGitHub Oct 31, 2023
2156131
feat: TarballIndexFileAttrs::checked_at
KSXGitHub Oct 31, 2023
d8c09da
test(cli): change dir to a sub dir
KSXGitHub Oct 31, 2023
0cae50e
feat: add .npmrc to every integration tests
KSXGitHub Oct 31, 2023
1c2e14a
refactor: remove unused, reuse available name
KSXGitHub Oct 31, 2023
bc55d2d
feat(test): create_npmrc parameter
KSXGitHub Oct 31, 2023
8166883
test: snapshot the store
KSXGitHub Oct 31, 2023
8fd6ec8
chore(git): merge
KSXGitHub Oct 31, 2023
ca61973
test(cli/install): correct snapshot
KSXGitHub Oct 31, 2023
bc80817
test: remove dirs from `get_all_files`
KSXGitHub Oct 31, 2023
b4c9edc
test(cli/install): exec files in the store
KSXGitHub Oct 31, 2023
b3f9d8c
test: remove dirs from `get_all_files`
KSXGitHub Oct 31, 2023
42b4a35
chore(git): merge
KSXGitHub Oct 31, 2023
e4e1773
style: use qualified
KSXGitHub Oct 31, 2023
00260a0
chore(git): merge
KSXGitHub Oct 31, 2023
791ac1e
chore(git): merge from main
KSXGitHub Oct 31, 2023
d91a355
docs: add a comment
KSXGitHub Oct 31, 2023
7966f5d
test(cli/install): snapshot all files
KSXGitHub Nov 1, 2023
aac7505
test(cli/install): snapshot last
KSXGitHub Nov 1, 2023
2750271
feat(config): default store dir to pnpm
KSXGitHub Nov 1, 2023
eea2459
perf: set mode at the same time as writing files
KSXGitHub Nov 1, 2023
50fb06d
refactor: clearer bit mask
KSXGitHub Nov 1, 2023
4f87522
refactor: rename TarballIndex -> PackageFilesIndex
KSXGitHub Nov 1, 2023
3883db0
refactor: rename some functions
KSXGitHub Nov 1, 2023
2d54d45
refactor: rename to PackageFileInfo
KSXGitHub Nov 1, 2023
3ab34b8
feat(tarball): don't panic on duplication
KSXGitHub Nov 1, 2023
7e0748d
docs: future tasks
KSXGitHub Nov 1, 2023
417e8dc
fix(docs): correct a link
KSXGitHub Nov 1, 2023
354b344
feat: only appends `-exec` when exec bits
KSXGitHub Nov 1, 2023
7014799
feat: set mode of all exec files to 755
KSXGitHub Nov 1, 2023
0980751
refactor: extract some expressions
KSXGitHub Nov 1, 2023
499ba6e
test: make sure executable modes are 755
KSXGitHub Nov 1, 2023
d31b6ae
refactor: rearrange code
KSXGitHub Nov 1, 2023
b847ecf
refactor: deduplicate
KSXGitHub Nov 1, 2023
c804271
refactor: remove unused constants
KSXGitHub Nov 1, 2023
14a3125
refactor: extract default npmrc
KSXGitHub Nov 1, 2023
ae2b85d
refactor: extract create_default_npmrc
KSXGitHub Nov 1, 2023
c265685
test: check against pnpm
KSXGitHub Nov 1, 2023
27f8a3f
ci: workaround
KSXGitHub Nov 1, 2023
9fb71f6
ci: fix codecov
KSXGitHub Nov 1, 2023
95741ef
test(windows): skip pnpm_compatibility
KSXGitHub Nov 1, 2023
0cd6cd5
chore(git): merge from main
KSXGitHub Nov 2, 2023
bbdfc2f
feat: support sha1 index files
KSXGitHub Nov 2, 2023
a3b0e4b
test(cli/install): index files
KSXGitHub Nov 2, 2023
3c505ba
test(cli/install): same index files as pnpm
KSXGitHub Nov 2, 2023
4d72247
docs: future plan
KSXGitHub Nov 2, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 30 additions & 19 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,14 @@ pacquet-package-manager = { path = "crates/package-manager" }
pacquet-lockfile = { path = "crates/lockfile" }
pacquet-npmrc = { path = "crates/npmrc" }
pacquet-executor = { path = "crates/executor" }
pacquet-cafs = { path = "crates/cafs" }
pacquet-diagnostics = { path = "crates/diagnostics" }
pacquet-store-dir = { path = "crates/store-dir" }

# Dependencies
async-recursion = { version = "1.0.5" }
clap = { version = "4", features = ["derive", "string"] }
command-extra = { version = "1.0.0" }
base64 = { version = "0.21.5" }
dashmap = { version = "5.5.3" }
derive_more = { version = "1.0.0-beta.3", features = ["full"] }
dunce = { version = "1.0.4" }
Expand All @@ -49,6 +50,7 @@ serde = { version = "1.0.188", features = ["derive"] }
serde_ini = { version = "0.2.0" }
serde_json = { version = "1.0.107", features = ["preserve_order"] }
serde_yaml = { version = "0.9.1" }
sha2 = { version = "0.10.8" }
split-first-char = { version = "0.0.0" }
ssri = { version = "9.0.0" }
strum = { version = "0.25.0", features = ["derive"] }
Expand Down
20 changes: 0 additions & 20 deletions crates/cafs/Cargo.toml

This file was deleted.

97 changes: 0 additions & 97 deletions crates/cafs/src/lib.rs

This file was deleted.

1 change: 0 additions & 1 deletion crates/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ name = "pacquet"
path = "src/bin/main.rs"

[dependencies]
pacquet-cafs = { workspace = true }
pacquet-executor = { workspace = true }
pacquet-fs = { workspace = true }
pacquet-lockfile = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion crates/cli/src/cli_args/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
panic!("Not implemented")
}
StoreCommand::Prune => {
pacquet_cafs::prune_sync(&config().store_dir).wrap_err("pruning store")?;
config().store_dir.prune().wrap_err("pruning store")?;

Check warning on line 32 in crates/cli/src/cli_args/store.rs

View check run for this annotation

Codecov / codecov/patch

crates/cli/src/cli_args/store.rs#L32

Added line #L32 was not covered by tests
}
StoreCommand::Path => {
println!("{}", config().store_dir.display());
Expand Down
45 changes: 45 additions & 0 deletions crates/cli/tests/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use pacquet_testing_utils::{
bin::pacquet_with_temp_cwd,
fs::{get_all_files, get_all_folders, is_symlink_or_junction},
};
use pipe_trait::Pipe;
use std::fs;

#[test]
Expand Down Expand Up @@ -46,3 +47,47 @@ fn should_install_dependencies() {

drop(root); // cleanup
}

#[test]
fn should_install_exec_files() {
let (command, root, workspace) = pacquet_with_temp_cwd(true);

eprintln!("Creating package.json...");
let manifest_path = workspace.join("package.json");
let package_json_content = serde_json::json!({
"dependencies": {
"pretty-exec": "0.3.10",
},
});
fs::write(&manifest_path, package_json_content.to_string()).expect("write to package.json");

eprintln!("Executing command...");
command.with_arg("install").assert().success();

eprintln!("Listing all files in the store...");
let store_files = root.path().join("pacquet-store").pipe_as_ref(get_all_files);
let (exec_files, non_exec_files): (Vec<_>, Vec<_>) =
store_files.iter().partition(|path| path.ends_with("-exec"));

eprintln!("Snapshot");
insta::assert_debug_snapshot!(exec_files);

#[cfg(unix)]
{
use pacquet_testing_utils::fs::is_path_executable;
use pretty_assertions::assert_eq;

eprintln!("All files that end with '-exec' are executable, others not");
assert_eq!(
store_files.iter().partition(|name| {
root.path().join("pacquet-store").join(name).pipe_as_ref(is_path_executable)
}),
(exec_files, non_exec_files),
);
}

#[cfg(windows)]
let _ = non_exec_files; // suppress clippy complaint on windows

drop(root); // cleanup
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
source: crates/cli/tests/install.rs
assertion_line: 45
assertion_line: 46
expression: "(workspace_folders, store_files)"
---
(
Expand All @@ -21,20 +21,23 @@ expression: "(workspace_folders, store_files)"
"node_modules/is-odd",
],
[
"01/d306b80f4b1678c655f3b0685db1f7a741fc746d251c00e925298ab89630a3167bde8c7d8d779b72770c41f9f302bb1e3f312672ce7aa8e6c156c319eeeada",
"17/54b7271ca0e30dc7d775986711a2b61b298200c12f867bde6f7e19d56047c9ab77a93304520fa1a31b0c3a4e6fb6b310f89dd8cb4d95a5c662807ef733f85f",
"1a/5c01a1321e71a1c263fb83878cbba2686f71f571b42c2d40d93858bf1f4c6ff7f625125a68932c243e75ead4a9d2f18d9b22b3fe55c39fe6605a42b2e70620",
"37/8eb16c230fce354ef7e72722ee708cbefea9a481aa597b06fefc12f665ab60176cbf04d6bc159be42ccdbc51764d71516f86bb28a01b0e60c76a2753f1cf44",
"40/fe18b2c1f241075b732727110323f3e29f9d6c8765ff0222bccfa34784caa8abcd18ffbd4bbfab979e5478ace273a74ed3a0a22f0261334fa7c59e032edbde",
"54/7bcd683e2f9f7b0c2790c637b9231539947be923479534592d91886a56d6262fdc1d8ced24ac2cc3adfda139fe399dc7502d382c7afc536e3057a7cf11e6c0",
"55/dcbc7fff1ac1c4755f4cbf24ba21e0dcae062c802d3db937d2b6182f4554dd85d14529a0c9688eac825a345b63ab8b2e5d7699e2be07178df5bb8a072235eb",
"58/01e592e94aa4076c179180956f33f8262fa7157a06bfe636a6854bd3b9b2ddf44780ffa1405642ad8ece2ed6514e19a28178cbecdcf5608a3be710bbf3c0d4",
"60/ab54849d6cfd7b05076c3bc4d9baffe1f800f4d5e2d67c39c521a7a3d93b347ce5a8e45397102e40e2103652c543c8e7bb161c15d0a6e34ec1a9d11c168d2a",
"88/1f101d2f1886fc5f9ac5c8d25e5540908e140031169ea41a4a9941cf95fe2711c1292c1995609c6f174b3815cc0dcc6cd2a10339a348d39fe75bc77b53ba9e",
"9f/cbe5dc86bc33bdb4f125559e767c3aaad94c7c4b21b80b694d9b0158ee0f10ee53b127c2bf05db9768afdaf1fb6778fd08a19412fb3c1adad655863e6c351d",
"ca/65df16eb450ab63f90f107a8cc9ac82da9635408e813a6f6d3e13cfba78917b31b66652479ebba54b612566600b2ab1bc16b82d082c5f87803961a8e9e3931",
"e5/c2514d2b0d3d6bedad24fdd75c55e780211cf0692c21f401201c2d7dfa990ad00188bd68b30c826aaa2a72ecad12a74bc03430384f933b1751035dd1b18ca2",
"f7/02180f4465a777127ad6a211306dd564993c17f7d3d9401604df4bc657d8d888902de632a4cf55b551ddfb9f84ba8a900788773f03c77836143ef94e182c7c",
"ff/d3f3fed65d7b489216916772c6180b5c1714ddde16e7e2c99ff5f8a4214bb8f884a0c1d06a1b1a8a4b0d6252ad85b533b1626f0dd8d474f2283f6cdfd69f6c",
"v3/files/01/d306b80f4b1678c655f3b0685db1f7a741fc746d251c00e925298ab89630a3167bde8c7d8d779b72770c41f9f302bb1e3f312672ce7aa8e6c156c319eeeada",
"v3/files/09/0a6758fac3c263f5f923075d986d2ed26ff74ca2c957e5b86b17e62342564ae142d5374d01ec5163c6f7091d93d2e0779c8da4083d8d0128f7408169781630-index.json",
"v3/files/17/54b7271ca0e30dc7d775986711a2b61b298200c12f867bde6f7e19d56047c9ab77a93304520fa1a31b0c3a4e6fb6b310f89dd8cb4d95a5c662807ef733f85f",
"v3/files/1a/5c01a1321e71a1c263fb83878cbba2686f71f571b42c2d40d93858bf1f4c6ff7f625125a68932c243e75ead4a9d2f18d9b22b3fe55c39fe6605a42b2e70620",
"v3/files/37/8eb16c230fce354ef7e72722ee708cbefea9a481aa597b06fefc12f665ab60176cbf04d6bc159be42ccdbc51764d71516f86bb28a01b0e60c76a2753f1cf44",
"v3/files/40/fe18b2c1f241075b732727110323f3e29f9d6c8765ff0222bccfa34784caa8abcd18ffbd4bbfab979e5478ace273a74ed3a0a22f0261334fa7c59e032edbde",
"v3/files/54/7bcd683e2f9f7b0c2790c637b9231539947be923479534592d91886a56d6262fdc1d8ced24ac2cc3adfda139fe399dc7502d382c7afc536e3057a7cf11e6c0",
"v3/files/55/dcbc7fff1ac1c4755f4cbf24ba21e0dcae062c802d3db937d2b6182f4554dd85d14529a0c9688eac825a345b63ab8b2e5d7699e2be07178df5bb8a072235eb",
"v3/files/58/01e592e94aa4076c179180956f33f8262fa7157a06bfe636a6854bd3b9b2ddf44780ffa1405642ad8ece2ed6514e19a28178cbecdcf5608a3be710bbf3c0d4",
"v3/files/58/a80a5a0e5e531bd1646c16f05bdf6da1fb0174a1d9c2fede3e5f306cd4302c56049ddd5776bb5b3f32d9ffee4347b707a5a6a1d0f7a12e788d343d1d54c822-index.json",
"v3/files/5a/ed551de20b04af0a016254022499417f781a6384e39460ebfe77f1f2b08a5a14bb6d4a9dc1246063eaa1bda8499e66513ef7bcb1ab1d08cac3728c3f07c3ce-index.json",
"v3/files/60/ab54849d6cfd7b05076c3bc4d9baffe1f800f4d5e2d67c39c521a7a3d93b347ce5a8e45397102e40e2103652c543c8e7bb161c15d0a6e34ec1a9d11c168d2a",
"v3/files/88/1f101d2f1886fc5f9ac5c8d25e5540908e140031169ea41a4a9941cf95fe2711c1292c1995609c6f174b3815cc0dcc6cd2a10339a348d39fe75bc77b53ba9e",
"v3/files/9f/cbe5dc86bc33bdb4f125559e767c3aaad94c7c4b21b80b694d9b0158ee0f10ee53b127c2bf05db9768afdaf1fb6778fd08a19412fb3c1adad655863e6c351d",
"v3/files/ca/65df16eb450ab63f90f107a8cc9ac82da9635408e813a6f6d3e13cfba78917b31b66652479ebba54b612566600b2ab1bc16b82d082c5f87803961a8e9e3931",
"v3/files/e5/c2514d2b0d3d6bedad24fdd75c55e780211cf0692c21f401201c2d7dfa990ad00188bd68b30c826aaa2a72ecad12a74bc03430384f933b1751035dd1b18ca2",
"v3/files/f7/02180f4465a777127ad6a211306dd564993c17f7d3d9401604df4bc657d8d888902de632a4cf55b551ddfb9f84ba8a900788773f03c77836143ef94e182c7c",
"v3/files/ff/d3f3fed65d7b489216916772c6180b5c1714ddde16e7e2c99ff5f8a4214bb8f884a0c1d06a1b1a8a4b0d6252ad85b533b1626f0dd8d474f2283f6cdfd69f6c",
],
)
Loading