@anysphere/file-service 0.0.0-ba159ee7 → 0.0.0-bc85c93a

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.d.ts CHANGED
@@ -5,6 +5,7 @@
5
5
 
6
6
  export class MerkleClient {
7
7
  constructor(absoluteRootDirectory: string)
8
+ isTooBig(maxFiles: number, gitIgnoredFiles: Array<string>, isGitRepo: boolean): Promise<boolean>
8
9
  init(gitIgnoredFiles: Array<string>, isGitRepo: boolean): Promise<void>
9
10
  computeMerkleTree(gitIgnoredFiles: Array<string>, isGitRepo: boolean): Promise<void>
10
11
  updateFile(filePath: string): Promise<void>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anysphere/file-service",
3
- "version": "0.0.0-ba159ee7",
3
+ "version": "0.0.0-bc85c93a",
4
4
  "main": "index.js",
5
5
  "types": "index.d.ts",
6
6
  "napi": {
@@ -36,12 +36,12 @@
36
36
  "version": "napi version"
37
37
  },
38
38
  "optionalDependencies": {
39
- "@anysphere/file-service-win32-x64-msvc": "0.0.0-ba159ee7",
40
- "@anysphere/file-service-darwin-x64": "0.0.0-ba159ee7",
41
- "@anysphere/file-service-linux-x64-gnu": "0.0.0-ba159ee7",
42
- "@anysphere/file-service-darwin-arm64": "0.0.0-ba159ee7",
43
- "@anysphere/file-service-win32-arm64-msvc": "0.0.0-ba159ee7",
44
- "@anysphere/file-service-darwin-universal": "0.0.0-ba159ee7",
45
- "@anysphere/file-service-linux-arm64-gnu": "0.0.0-ba159ee7"
39
+ "@anysphere/file-service-win32-x64-msvc": "0.0.0-bc85c93a",
40
+ "@anysphere/file-service-darwin-x64": "0.0.0-bc85c93a",
41
+ "@anysphere/file-service-linux-x64-gnu": "0.0.0-bc85c93a",
42
+ "@anysphere/file-service-darwin-arm64": "0.0.0-bc85c93a",
43
+ "@anysphere/file-service-win32-arm64-msvc": "0.0.0-bc85c93a",
44
+ "@anysphere/file-service-darwin-universal": "0.0.0-bc85c93a",
45
+ "@anysphere/file-service-linux-arm64-gnu": "0.0.0-bc85c93a"
46
46
  }
47
47
  }
@@ -0,0 +1,21 @@
1
+ echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
2
+ VERSION="0.0.0-$(git rev-parse --short HEAD)"
3
+ echo "Checking npm view works"
4
+
5
+ NPM_VIEW_HELP=$(npm view --help 2>/dev/null)
6
+ if [ $? -eq 0 ]; then
7
+ echo "npm view --help command executed successfully"
8
+ else
9
+ echo "npm view --help command failed"
10
+ exit 1
11
+ fi
12
+
13
+ echo "checking if version $VERSION already exists"
14
+ EXISTS=$(npm view @anysphere/file-service@$VERSION version 2>/dev/null)
15
+ if [ -z "$EXISTS" ]; then
16
+ echo "Publishing version $VERSION"
17
+ yarn version --no-git-tag-version --new-version $VERSION
18
+ npm publish --access public --tag next --scope @anysphere
19
+ else
20
+ echo "Version $VERSION already exists. Skipping publish."
21
+ fi
package/src/file_utils.rs CHANGED
@@ -45,86 +45,17 @@ pub fn is_good_file(file_path: &Path) -> Result<(), Error> {
45
45
  }
46
46
 
47
47
  let bad_extensions = vec![
48
- "lock",
49
- "bak",
50
- "tmp",
51
- "bin",
52
- "exe",
53
- "dll",
54
- "so",
55
- "lockb",
56
- "qwoff",
57
- "isl",
58
- "csv",
59
- "pdf",
60
- // add ms word, excel, powerpoint, etc.
61
- "doc",
62
- "docx",
63
- "xls",
64
- "xlsx",
65
- "ppt",
66
- "pptx",
67
- "odt",
68
- "ods",
69
- "odp",
70
- "odg",
71
- "odf",
72
- "sxw",
73
- "sxc",
74
- "sxi",
75
- "sxd",
76
- "sdc",
77
- // add images
78
- "jpg",
79
- "jpeg",
80
- "png",
81
- "gif",
82
- "bmp",
83
- "tif",
84
- // add audio
85
- "mp3",
86
- "wav",
87
- "wma",
88
- "ogg",
89
- "flac",
90
- "aac",
91
- // add video
92
- "mp4",
93
- "mov",
94
- "wmv",
95
- "flv",
96
- "avi",
97
- // add archives
98
- "zip",
99
- "tar",
100
- "gz",
101
- "7z",
102
- "rar",
103
- "tgz",
104
- "dmg",
105
- "iso",
106
- "cue",
107
- "mdf",
108
- "mds",
109
- "vcd",
110
- "toast",
111
- "img",
112
- "apk",
113
- "msi",
114
- "cab",
115
- "tar.gz",
116
- "tar.xz",
117
- "tar.bz2",
118
- "tar.lzma",
119
- "tar.Z",
120
- "tar.sz",
121
- "lzma",
122
- // add fonts
123
- "ttf",
124
- "otf",
125
- "woff",
126
- "woff2",
127
- "eot",
48
+ "lock", "bak", "tmp", "bin", "exe", "dll", "so", "lockb", "qwoff", "isl",
49
+ "csv", "pdf", // add ms word, excel, powerpoint, etc.
50
+ "doc", "docx", "xls", "xlsx", "ppt", "pptx", "odt", "ods", "odp", "odg",
51
+ "odf", "sxw", "sxc", "sxi", "sxd", "sdc", // add images
52
+ "jpg", "jpeg", "png", "gif", "bmp", "tif", // add audio
53
+ "mp3", "wav", "wma", "ogg", "flac", "aac", // add video
54
+ "mp4", "mov", "wmv", "flv", "avi", // add archives
55
+ "zip", "tar", "gz", "7z", "rar", "tgz", "dmg", "iso", "cue", "mdf", "mds",
56
+ "vcd", "toast", "img", "apk", "msi", "cab", "tar.gz", "tar.xz", "tar.bz2",
57
+ "tar.lzma", "tar.Z", "tar.sz", "lzma", // add fonts
58
+ "ttf", "otf", "woff", "woff2", "eot", "webp", "vsix",
128
59
  ];
129
60
  match bad_extensions.contains(&extension) {
130
61
  true => {
package/src/lib.rs CHANGED
@@ -44,6 +44,57 @@ impl MerkleClient {
44
44
  }
45
45
  }
46
46
 
47
+ #[napi]
48
+ pub async fn is_too_big(
49
+ &self,
50
+ max_files: i32,
51
+ git_ignored_files: Vec<String>,
52
+ is_git_repo: bool,
53
+ ) -> bool {
54
+ let git_ignored_set =
55
+ HashSet::<String>::from_iter(git_ignored_files.into_iter());
56
+ let mut num_files = 0;
57
+ let mut dirs_to_check = vec![self.absolute_root_directory.clone()];
58
+
59
+ while let Some(dir) = dirs_to_check.pop() {
60
+ info!("dir: {:?}", dir);
61
+ let mut entries = match tokio::fs::read_dir(&dir).await {
62
+ Ok(entries) => entries,
63
+ Err(_) => continue,
64
+ };
65
+ if num_files > max_files {
66
+ return true;
67
+ }
68
+
69
+ while let Some(entry) = entries.next_entry().await.unwrap_or(None) {
70
+ let path = entry.path();
71
+ info!("entry: {:?}", path);
72
+ let path_str = match path.to_str() {
73
+ Some(path_str) => path_str.to_string(),
74
+ None => continue,
75
+ };
76
+
77
+ if git_ignored_set.contains(&path_str) {
78
+ continue;
79
+ }
80
+
81
+ match entry.file_type().await {
82
+ Ok(file_type) => {
83
+ if file_type.is_dir() {
84
+ dirs_to_check.push(path_str);
85
+ }
86
+
87
+ if file_type.is_file() {
88
+ num_files += 1;
89
+ }
90
+ }
91
+ Err(_) => continue,
92
+ }
93
+ }
94
+ }
95
+ num_files > max_files
96
+ }
97
+
47
98
  #[napi]
48
99
  pub async unsafe fn init(
49
100
  &mut self,
@@ -295,9 +295,14 @@ impl MerkleTree {
295
295
  if file_node.is_none() {
296
296
  return Err(anyhow::anyhow!("Could not find directory the in tree!"));
297
297
  }
298
+ let absolute_path = if absolute_path.ends_with(std::path::MAIN_SEPARATOR) {
299
+ absolute_path.to_string()
300
+ } else {
301
+ format!("{}{}", absolute_path, std::path::MAIN_SEPARATOR)
302
+ };
298
303
 
299
304
  for (file_path, f) in &self.files {
300
- if !file_path.contains(absolute_path) {
305
+ if !file_path.contains(absolute_path.as_str()) {
301
306
  continue;
302
307
  }
303
308