@repokit/core 1.0.3 → 1.0.4
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/Cargo.lock
CHANGED
|
@@ -265,6 +265,7 @@ dependencies = [
|
|
|
265
265
|
"serde",
|
|
266
266
|
"serde_json",
|
|
267
267
|
"tokio",
|
|
268
|
+
"tokio-thread-pool",
|
|
268
269
|
]
|
|
269
270
|
|
|
270
271
|
[[package]]
|
|
@@ -336,6 +337,15 @@ dependencies = [
|
|
|
336
337
|
"pin-project-lite",
|
|
337
338
|
]
|
|
338
339
|
|
|
340
|
+
[[package]]
|
|
341
|
+
name = "tokio-thread-pool"
|
|
342
|
+
version = "1.0.0"
|
|
343
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
344
|
+
checksum = "d94c3392b98a14acc18fa639cb48e94355ed7aaae4a45164e394d6c4da39c9ec"
|
|
345
|
+
dependencies = [
|
|
346
|
+
"tokio",
|
|
347
|
+
]
|
|
348
|
+
|
|
339
349
|
[[package]]
|
|
340
350
|
name = "unicode-ident"
|
|
341
351
|
version = "1.0.22"
|
package/Cargo.toml
CHANGED
|
@@ -13,9 +13,10 @@ serde_json = "1.0"
|
|
|
13
13
|
colored = "3"
|
|
14
14
|
lexopt = "0.3.1"
|
|
15
15
|
normalize-path = "0.2.1"
|
|
16
|
-
tokio = { version = "1.49.0", features = ["rt-multi-thread"] }
|
|
17
16
|
futures = "0.3.31"
|
|
18
17
|
jwalk = "0.8.1"
|
|
19
18
|
alphanumeric-sort = "1.5.5"
|
|
19
|
+
tokio-thread-pool = "1.0.0"
|
|
20
|
+
tokio = "1.49.0"
|
|
20
21
|
|
|
21
22
|
|
|
@@ -4,11 +4,12 @@ use std::{
|
|
|
4
4
|
path::Path,
|
|
5
5
|
};
|
|
6
6
|
|
|
7
|
+
use futures::{TryStreamExt, stream::FuturesUnordered};
|
|
7
8
|
use jwalk::WalkDir;
|
|
9
|
+
use tokio_thread_pool::ThreadPool;
|
|
8
10
|
|
|
9
11
|
use crate::{
|
|
10
|
-
|
|
11
|
-
repokit::interfaces::RepoKitCommand,
|
|
12
|
+
internal_commands::typescript_command::TypescriptCommand, repokit::interfaces::RepoKitCommand,
|
|
12
13
|
};
|
|
13
14
|
|
|
14
15
|
pub struct ExternalCommands {
|
|
@@ -21,8 +22,8 @@ impl ExternalCommands {
|
|
|
21
22
|
}
|
|
22
23
|
|
|
23
24
|
pub async fn find_all(&self) -> Vec<RepoKitCommand> {
|
|
24
|
-
let mut
|
|
25
|
-
let mut pool = ThreadPool::new(None, None);
|
|
25
|
+
let mut futures = FuturesUnordered::new();
|
|
26
|
+
let mut pool = ThreadPool::new(None, None, None);
|
|
26
27
|
for entry in WalkDir::new(&self.root).into_iter().filter_map(|e| {
|
|
27
28
|
if e.is_err() {
|
|
28
29
|
return None;
|
|
@@ -43,16 +44,23 @@ impl ExternalCommands {
|
|
|
43
44
|
}
|
|
44
45
|
}) {
|
|
45
46
|
let path = entry.path();
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
futures.push(pool.spawn(move || {
|
|
48
|
+
if ExternalCommands::read(&path) {
|
|
49
|
+
return Some(path.clone());
|
|
50
|
+
}
|
|
51
|
+
None
|
|
52
|
+
}));
|
|
53
|
+
}
|
|
54
|
+
let mut paths: Vec<String> = Vec::new();
|
|
55
|
+
while let Ok(Some(buffer)) = futures.try_next().await {
|
|
56
|
+
if let Some(path) = buffer {
|
|
49
57
|
paths.push(
|
|
50
|
-
(
|
|
58
|
+
(path)
|
|
51
59
|
.into_os_string()
|
|
52
60
|
.into_string()
|
|
53
61
|
.expect("stringify")
|
|
54
62
|
.replace(&self.root, ""),
|
|
55
|
-
)
|
|
63
|
+
)
|
|
56
64
|
}
|
|
57
65
|
}
|
|
58
66
|
pool.pool.shutdown_background();
|
package/internals/main.rs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@repokit/core",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "A knowledgebase for your repository - wrapped in a CLI",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cli",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"scripts": {
|
|
23
23
|
"build:all": "yarn lint:ts && yarn lint:rust && yarn install:repokit",
|
|
24
24
|
"build:rust": "cargo build --release",
|
|
25
|
-
"install:
|
|
25
|
+
"install:rust": "yarn build:rust && cargo install --path .",
|
|
26
26
|
"lint:rust": "cargo clippy --fix --allow-dirty",
|
|
27
27
|
"lint:ts": "yarn oxlint --type-aware --type-check --report-unused-disable-directives --fix && yarn oxfmt",
|
|
28
28
|
"postinstall": "chmod +x ./install.sh && ./install.sh",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
pub mod thread_pool;
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
use tokio::{
|
|
2
|
-
runtime::{self, Runtime},
|
|
3
|
-
task::JoinHandle,
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
pub struct ThreadPool {
|
|
7
|
-
pub pool: Runtime,
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
impl ThreadPool {
|
|
11
|
-
pub fn new(threads_override: Option<usize>, pool_override: Option<Runtime>) -> ThreadPool {
|
|
12
|
-
let pool = pool_override.unwrap_or(ThreadPool::create_pool(threads_override));
|
|
13
|
-
ThreadPool { pool }
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
pub fn spawn<T: Send + 'static, F: (Fn() -> T) + 'static + Send>(
|
|
17
|
-
&mut self,
|
|
18
|
-
task: F,
|
|
19
|
-
) -> JoinHandle<T> {
|
|
20
|
-
self.pool.spawn(async move { task() })
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
fn create_pool(threads: Option<usize>) -> Runtime {
|
|
24
|
-
let mut pool = runtime::Builder::new_multi_thread();
|
|
25
|
-
pool.enable_all();
|
|
26
|
-
match threads {
|
|
27
|
-
Some(size) => pool.worker_threads(size),
|
|
28
|
-
None => &pool,
|
|
29
|
-
};
|
|
30
|
-
pool.build().unwrap()
|
|
31
|
-
}
|
|
32
|
-
}
|