@repokit/core 0.1.2 → 0.1.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/README.md +0 -4
- package/install.sh +17 -0
- package/package.json +8 -17
- package/workspaces/configuration/configuration.rs +1 -1
- package/workspaces/internal_commands/register_command.rs +1 -1
- package/workspaces/internal_commands/typescript_command.rs +7 -16
- package/workspaces/internal_filesystem/internal_filesystem.rs +10 -26
- package/workspaces/repokit/repokit.rs +1 -1
- package/dist/cjs/CommandParser.js +0 -69
- package/dist/cjs/ConfigurationParser.js +0 -46
- package/dist/cjs/RepoKitCommand.js +0 -12
- package/dist/cjs/RepoKitConfig.js +0 -10
- package/dist/cjs/TaskPooler.js +0 -42
- package/dist/cjs/commands/parse_commands.js +0 -15
- package/dist/cjs/commands/parse_configuration.js +0 -15
- package/dist/cjs/index.js +0 -19
- package/dist/cjs/package.json +0 -3
- package/dist/cjs/templates/command_template.js +0 -26
- package/dist/cjs/templates/configuration_template.js +0 -25
- package/dist/cjs/types.js +0 -2
- package/dist/mjs/CommandParser.js +0 -52
- package/dist/mjs/ConfigurationParser.js +0 -31
- package/dist/mjs/RepoKitCommand.js +0 -12
- package/dist/mjs/RepoKitConfig.js +0 -8
- package/dist/mjs/TaskPooler.js +0 -28
- package/dist/mjs/commands/parse_commands.js +0 -4
- package/dist/mjs/commands/parse_configuration.js +0 -4
- package/dist/mjs/index.js +0 -3
- package/dist/mjs/package.json +0 -4
- package/dist/mjs/templates/command_template.js +0 -23
- package/dist/mjs/templates/configuration_template.js +0 -22
- package/dist/mjs/types.js +0 -1
- package/dist/types/CommandParser.d.ts +0 -5
- package/dist/types/ConfigurationParser.d.ts +0 -4
- package/dist/types/RepoKitCommand.d.ts +0 -8
- package/dist/types/RepoKitConfig.d.ts +0 -6
- package/dist/types/TaskPooler.d.ts +0 -10
- package/dist/types/commands/parse_commands.d.ts +0 -1
- package/dist/types/commands/parse_configuration.d.ts +0 -1
- package/dist/types/index.d.ts +0 -3
- package/dist/types/templates/command_template.d.ts +0 -4
- package/dist/types/templates/configuration_template.d.ts +0 -5
- package/dist/types/types.d.ts +0 -18
package/README.md
CHANGED
|
@@ -61,10 +61,6 @@ export const RepoKit = new RepoKitConfig({
|
|
|
61
61
|
"yarn oxlint --type-aware --type-check --report-unused-disable-directives --fix && yarn oxfmt",
|
|
62
62
|
description: "Lints typescript files using oxc",
|
|
63
63
|
},
|
|
64
|
-
"build:ts": {
|
|
65
|
-
command: "yarn ts-packager -e src",
|
|
66
|
-
description: "Builds the typescript package",
|
|
67
|
-
},
|
|
68
64
|
},
|
|
69
65
|
});
|
|
70
66
|
```
|
package/install.sh
CHANGED
|
@@ -16,6 +16,23 @@ else
|
|
|
16
16
|
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
|
|
17
17
|
fi
|
|
18
18
|
|
|
19
|
+
if npm list --depth=0 tsx; then
|
|
20
|
+
echo "Found tsx installation"
|
|
21
|
+
else
|
|
22
|
+
# Node Dependencies installation
|
|
23
|
+
if [ -f "${REPO_ROOT}/yarn.lock" ]; then
|
|
24
|
+
yarn global add tsx
|
|
25
|
+
elif [ -f "${REPO_ROOT}/pnpm-lock.yaml" ]; then
|
|
26
|
+
pnpm add -g tsx
|
|
27
|
+
elif [ -f "${REPO_ROOT}/package-lock.json" ]; then
|
|
28
|
+
npm i -g tsx
|
|
29
|
+
else
|
|
30
|
+
echo "No node.js package manager detected"
|
|
31
|
+
echo "Run npm init to create your node.js project"
|
|
32
|
+
fi
|
|
33
|
+
fi
|
|
34
|
+
|
|
35
|
+
|
|
19
36
|
echo "Installing Repokit CLI"
|
|
20
37
|
|
|
21
38
|
cd "$SCRIPT_ORIGIN"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@repokit/core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "A knowledgebase for your repository - wrapped in a CLI",
|
|
5
5
|
"homepage": "https://github.com/alexfigliolia/repokit#readme",
|
|
6
6
|
"license": "MIT",
|
|
@@ -9,38 +9,29 @@
|
|
|
9
9
|
"type": "git",
|
|
10
10
|
"url": "git+https://github.com/alexfigliolia/repokit.git"
|
|
11
11
|
},
|
|
12
|
-
"main": "
|
|
13
|
-
"module": "dist/mjs/index.js",
|
|
14
|
-
"types": "dist/types/index.d.ts",
|
|
15
|
-
"exports": {
|
|
16
|
-
".": {
|
|
17
|
-
"types": "./dist/types/index.d.ts",
|
|
18
|
-
"import": "./dist/mjs/index.js",
|
|
19
|
-
"require": "./dist/cjs/index.js"
|
|
20
|
-
}
|
|
21
|
-
},
|
|
12
|
+
"main": "src/index.ts",
|
|
22
13
|
"publishConfig": {
|
|
23
14
|
"access": "public"
|
|
24
15
|
},
|
|
25
16
|
"scripts": {
|
|
26
|
-
"build:all": "yarn
|
|
17
|
+
"build:all": "yarn lint:ts && yarn lint:rust && yarn install:repokit",
|
|
27
18
|
"build:rust": "cargo build --release",
|
|
28
|
-
"build:ts": "yarn ts-packager -e src",
|
|
29
19
|
"install:repokit": "yarn build:rust && cargo install --path .",
|
|
30
20
|
"lint:rust": "cargo clippy --fix --allow-dirty",
|
|
31
21
|
"lint:ts": "yarn oxlint --type-aware --type-check --report-unused-disable-directives --fix && yarn oxfmt",
|
|
32
22
|
"postinstall": "chmod +x ./install.sh && ./install.sh",
|
|
33
|
-
"repokit": "yarn
|
|
23
|
+
"repokit": "yarn install:repokit && repokit",
|
|
34
24
|
"run:dev": "cargo run --package repokit --bin repokit"
|
|
35
25
|
},
|
|
36
|
-
"
|
|
26
|
+
"dependencies": {
|
|
37
27
|
"@figliolia/event-emitter": "^1.1.6",
|
|
38
|
-
"
|
|
28
|
+
"tsx": "^4.21.0"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
39
31
|
"@types/node": "^25.0.10",
|
|
40
32
|
"oxfmt": "^0.27.0",
|
|
41
33
|
"oxlint": "^1.42.0",
|
|
42
34
|
"oxlint-tsgolint": "^0.11.3",
|
|
43
|
-
"tsx": "^4.21.0",
|
|
44
35
|
"typescript": "^5.9.3"
|
|
45
36
|
}
|
|
46
37
|
}
|
|
@@ -12,7 +12,7 @@ impl Configuration {
|
|
|
12
12
|
return;
|
|
13
13
|
}
|
|
14
14
|
Configuration::welcome();
|
|
15
|
-
let template_path = InternalFileSystem::resolve_template("configuration_template");
|
|
15
|
+
let template_path = InternalFileSystem::resolve_template("configuration_template.ts");
|
|
16
16
|
let mut source = File::open(template_path).expect("Template");
|
|
17
17
|
let mut target = File::create(path_buf).expect("creating");
|
|
18
18
|
io::copy(&mut source, &mut target).expect("writing");
|
|
@@ -91,7 +91,7 @@ impl InternalExecutable for RegisterCommand {
|
|
|
91
91
|
fn run(&self, args: Vec<String>, _: &HashMap<String, Box<dyn InternalExecutable>>) {
|
|
92
92
|
Logger::info("Registering a new command");
|
|
93
93
|
let command_path = self.validate_path(args);
|
|
94
|
-
let template_path = InternalFileSystem::resolve_template("command_template");
|
|
94
|
+
let template_path = InternalFileSystem::resolve_template("command_template.ts");
|
|
95
95
|
let mut source = File::open(template_path).expect("Template");
|
|
96
96
|
let mut target = File::create(&command_path).expect("creating");
|
|
97
97
|
io::copy(&mut source, &mut target).expect("writing");
|
|
@@ -6,7 +6,6 @@ use crate::{
|
|
|
6
6
|
configuration::configuration::Configuration,
|
|
7
7
|
executor::executor::Executor,
|
|
8
8
|
internal_filesystem::internal_filesystem::InternalFileSystem,
|
|
9
|
-
logger::logger::Logger,
|
|
10
9
|
repokit::interfaces::{RepoKitCommand, RepoKitConfig},
|
|
11
10
|
};
|
|
12
11
|
|
|
@@ -20,9 +19,8 @@ impl TypescriptCommand {
|
|
|
20
19
|
}
|
|
21
20
|
|
|
22
21
|
pub fn parse_configuration(&self) -> RepoKitConfig {
|
|
23
|
-
let executable = InternalFileSystem::resolve_command("parse_configuration");
|
|
24
|
-
let stdout = self.
|
|
25
|
-
Logger::info(&stdout);
|
|
22
|
+
let executable = InternalFileSystem::resolve_command("parse_configuration.ts");
|
|
23
|
+
let stdout = self.execute(format!("{executable} --root {}", &self.root).as_str());
|
|
26
24
|
if stdout.is_empty() {
|
|
27
25
|
Configuration::create(&self.root);
|
|
28
26
|
}
|
|
@@ -33,22 +31,15 @@ impl TypescriptCommand {
|
|
|
33
31
|
|
|
34
32
|
pub fn parse_commands(&self, path_list: Vec<String>) -> Vec<RepoKitCommand> {
|
|
35
33
|
let paths = path_list.join(",");
|
|
36
|
-
let executable = InternalFileSystem::resolve_command("parse_commands");
|
|
37
|
-
let stdout =
|
|
38
|
-
|
|
39
|
-
format!("--paths {paths} --root {}", self.root).as_str(),
|
|
40
|
-
);
|
|
34
|
+
let executable = InternalFileSystem::resolve_command("parse_commands.ts");
|
|
35
|
+
let stdout =
|
|
36
|
+
self.execute(format!("{executable} --paths {paths} --root {}", self.root).as_str());
|
|
41
37
|
let commands: Vec<RepoKitCommand> = serde_json::from_str(&stdout).expect("parse");
|
|
42
38
|
commands
|
|
43
39
|
}
|
|
44
40
|
|
|
45
|
-
fn
|
|
46
|
-
|
|
47
|
-
"npx tsx"
|
|
48
|
-
} else {
|
|
49
|
-
"node"
|
|
50
|
-
};
|
|
51
|
-
Executor::exec(format!("{driver} {executable} {}", args), |cmd| {
|
|
41
|
+
fn execute(&self, args: &str) -> String {
|
|
42
|
+
Executor::exec(format!("npx tsx {args}"), |cmd| {
|
|
52
43
|
cmd.current_dir(Path::new(&self.root))
|
|
53
44
|
})
|
|
54
45
|
}
|
|
@@ -11,32 +11,23 @@ impl InternalFileSystem {
|
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
pub fn resolve_command(file_name: &str) -> String {
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
InternalFileSystem::path_buf_to_str(
|
|
15
|
+
InternalFileSystem::commands_directory().join(file_name),
|
|
16
|
+
)
|
|
16
17
|
}
|
|
17
18
|
|
|
18
19
|
pub fn resolve_template(file_name: &str) -> String {
|
|
19
|
-
|
|
20
|
-
|
|
20
|
+
InternalFileSystem::path_buf_to_str(
|
|
21
|
+
InternalFileSystem::templates_directory().join(file_name),
|
|
22
|
+
)
|
|
21
23
|
}
|
|
22
24
|
|
|
23
|
-
fn commands_directory() ->
|
|
24
|
-
InternalFileSystem::
|
|
25
|
+
fn commands_directory() -> PathBuf {
|
|
26
|
+
InternalFileSystem::absolute("./src/commands")
|
|
25
27
|
}
|
|
26
28
|
|
|
27
|
-
fn templates_directory() ->
|
|
28
|
-
InternalFileSystem::
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
fn source_internal(path: &str) -> (PathBuf, String) {
|
|
32
|
-
let src = InternalFileSystem::absolute(format!("./src/{path}").as_str());
|
|
33
|
-
if InternalFileSystem::is_in_node_modules(&src) {
|
|
34
|
-
return (
|
|
35
|
-
InternalFileSystem::absolute(format!("./dist/mjs/{path}").as_str()),
|
|
36
|
-
".js".to_string(),
|
|
37
|
-
);
|
|
38
|
-
}
|
|
39
|
-
(src, ".ts".to_string())
|
|
29
|
+
fn templates_directory() -> PathBuf {
|
|
30
|
+
InternalFileSystem::absolute("./src/templates")
|
|
40
31
|
}
|
|
41
32
|
|
|
42
33
|
fn path_buf_to_str(buffer: PathBuf) -> String {
|
|
@@ -45,11 +36,4 @@ impl InternalFileSystem {
|
|
|
45
36
|
.into_string()
|
|
46
37
|
.expect("Cannot construct path")
|
|
47
38
|
}
|
|
48
|
-
|
|
49
|
-
fn is_in_node_modules(path: &PathBuf) -> bool {
|
|
50
|
-
path.as_os_str()
|
|
51
|
-
.to_str()
|
|
52
|
-
.expect("blah")
|
|
53
|
-
.contains("node_modules")
|
|
54
|
-
}
|
|
55
39
|
}
|
|
@@ -57,7 +57,7 @@ impl RepoKit {
|
|
|
57
57
|
let script = interface.commands.get(sub_command).expect("exists");
|
|
58
58
|
let working_dir = Path::new(&interface.location).parent().expect("exists");
|
|
59
59
|
return Executor::with_stdio(
|
|
60
|
-
format!("{}{}", &script.command, &args[1..].join(" ")),
|
|
60
|
+
format!("{} {}", &script.command, &args[1..].join(" ")),
|
|
61
61
|
|cmd| cmd.current_dir(working_dir),
|
|
62
62
|
);
|
|
63
63
|
}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.CommandParser = void 0;
|
|
13
|
-
const node_util_1 = require("node:util");
|
|
14
|
-
const node_path_1 = require("node:path");
|
|
15
|
-
const promises_1 = require("node:fs/promises");
|
|
16
|
-
const node_fs_1 = require("node:fs");
|
|
17
|
-
const TaskPooler_1 = require("./TaskPooler");
|
|
18
|
-
const RepoKitCommand_1 = require("./RepoKitCommand");
|
|
19
|
-
/* oxlint-disable typescript-eslint(no-misused-spread) */
|
|
20
|
-
class CommandParser {
|
|
21
|
-
static parse() {
|
|
22
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
23
|
-
const { paths, root } = this.parsePaths();
|
|
24
|
-
if (!root || !(0, node_fs_1.existsSync)(root) || !(yield (0, promises_1.stat)(root)).isDirectory()) {
|
|
25
|
-
return console.log(JSON.stringify([]));
|
|
26
|
-
}
|
|
27
|
-
const pathList = paths.split(",").filter(Boolean);
|
|
28
|
-
const pool = new TaskPooler_1.TaskPooler();
|
|
29
|
-
const results = yield Promise.all(pathList.map(path => pool.enqueue(() => this.parseCommand((0, node_path_1.join)(root, path)))));
|
|
30
|
-
console.log(JSON.stringify(results.flat()));
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
static parseCommand(path) {
|
|
34
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
35
|
-
const commands = [];
|
|
36
|
-
const declaredExports = yield Promise.resolve(`${path}`).then(s => require(s));
|
|
37
|
-
for (const key in declaredExports) {
|
|
38
|
-
if (declaredExports[key] instanceof RepoKitCommand_1.RepoKitCommand) {
|
|
39
|
-
commands.push(Object.assign(Object.assign({}, declaredExports[key]), { location: path }));
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
return commands;
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
static parsePaths() {
|
|
46
|
-
try {
|
|
47
|
-
return (0, node_util_1.parseArgs)({
|
|
48
|
-
options: {
|
|
49
|
-
paths: {
|
|
50
|
-
default: "",
|
|
51
|
-
multiple: false,
|
|
52
|
-
short: "p",
|
|
53
|
-
type: "string",
|
|
54
|
-
},
|
|
55
|
-
root: {
|
|
56
|
-
default: "",
|
|
57
|
-
multiple: false,
|
|
58
|
-
short: "r",
|
|
59
|
-
type: "string",
|
|
60
|
-
},
|
|
61
|
-
},
|
|
62
|
-
}).values;
|
|
63
|
-
}
|
|
64
|
-
catch (_a) {
|
|
65
|
-
return { paths: "", root: "" };
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
exports.CommandParser = CommandParser;
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.ConfigurationParser = void 0;
|
|
13
|
-
const node_util_1 = require("node:util");
|
|
14
|
-
const node_path_1 = require("node:path");
|
|
15
|
-
const node_fs_1 = require("node:fs");
|
|
16
|
-
const RepoKitConfig_1 = require("./RepoKitConfig");
|
|
17
|
-
class ConfigurationParser {
|
|
18
|
-
static parse() {
|
|
19
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
20
|
-
const root = this.parseRoot();
|
|
21
|
-
const path = (0, node_path_1.join)(root, "repokit.ts");
|
|
22
|
-
if (!(0, node_fs_1.existsSync)(path)) {
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
const config = yield Promise.resolve(`${path}`).then(s => require(s));
|
|
26
|
-
for (const key in config) {
|
|
27
|
-
if (config[key] instanceof RepoKitConfig_1.RepoKitConfig) {
|
|
28
|
-
return console.log(JSON.stringify(config[key]));
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
static parseRoot() {
|
|
34
|
-
return (0, node_util_1.parseArgs)({
|
|
35
|
-
options: {
|
|
36
|
-
root: {
|
|
37
|
-
default: "",
|
|
38
|
-
multiple: false,
|
|
39
|
-
short: "r",
|
|
40
|
-
type: "string",
|
|
41
|
-
},
|
|
42
|
-
},
|
|
43
|
-
}).values.root;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
exports.ConfigurationParser = ConfigurationParser;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RepoKitCommand = void 0;
|
|
4
|
-
class RepoKitCommand {
|
|
5
|
-
constructor({ name, description, owner = "", commands = {}, }) {
|
|
6
|
-
this.name = name;
|
|
7
|
-
this.owner = owner;
|
|
8
|
-
this.commands = commands;
|
|
9
|
-
this.description = description;
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
exports.RepoKitCommand = RepoKitCommand;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RepoKitConfig = void 0;
|
|
4
|
-
class RepoKitConfig {
|
|
5
|
-
constructor({ project, commands = {} }) {
|
|
6
|
-
this.project = project;
|
|
7
|
-
this.commands = commands;
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
exports.RepoKitConfig = RepoKitConfig;
|
package/dist/cjs/TaskPooler.js
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.TaskPooler = void 0;
|
|
13
|
-
const event_emitter_1 = require("@figliolia/event-emitter");
|
|
14
|
-
class TaskPooler {
|
|
15
|
-
constructor(maxSize = 10) {
|
|
16
|
-
this.maxSize = maxSize;
|
|
17
|
-
this.IDs = new event_emitter_1.AutoIncrementingID();
|
|
18
|
-
this.runningTasks = new Map();
|
|
19
|
-
}
|
|
20
|
-
enqueue(task) {
|
|
21
|
-
return new Promise(resolve => {
|
|
22
|
-
if (this.runningTasks.size < 10) {
|
|
23
|
-
return resolve(this.indexRunningTask(task));
|
|
24
|
-
}
|
|
25
|
-
resolve(this.indexBehindNextOpening(task));
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
indexRunningTask(task) {
|
|
29
|
-
const ID = this.IDs.get();
|
|
30
|
-
const promise = task();
|
|
31
|
-
this.runningTasks.set(ID, promise);
|
|
32
|
-
void promise.finally(() => this.runningTasks.delete(ID));
|
|
33
|
-
return promise;
|
|
34
|
-
}
|
|
35
|
-
indexBehindNextOpening(task) {
|
|
36
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
37
|
-
yield Promise.race(this.runningTasks.values());
|
|
38
|
-
return this.indexRunningTask(task);
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
exports.TaskPooler = TaskPooler;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
const CommandParser_1 = require("../CommandParser");
|
|
13
|
-
void (() => __awaiter(void 0, void 0, void 0, function* () {
|
|
14
|
-
yield CommandParser_1.CommandParser.parse();
|
|
15
|
-
}))();
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
const ConfigurationParser_1 = require("../ConfigurationParser");
|
|
13
|
-
void (() => __awaiter(void 0, void 0, void 0, function* () {
|
|
14
|
-
yield ConfigurationParser_1.ConfigurationParser.parse();
|
|
15
|
-
}))();
|
package/dist/cjs/index.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./RepoKitConfig"), exports);
|
|
18
|
-
__exportStar(require("./RepoKitCommand"), exports);
|
|
19
|
-
__exportStar(require("./types"), exports);
|
package/dist/cjs/package.json
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Commands = void 0;
|
|
4
|
-
const core_1 = require("@repokit/core");
|
|
5
|
-
/**
|
|
6
|
-
* Please fill out this command file with your desired settings
|
|
7
|
-
*/
|
|
8
|
-
exports.Commands = new core_1.RepoKitCommand({
|
|
9
|
-
name: "<Your Package Name>",
|
|
10
|
-
owner: "<Optional Team or Individual>",
|
|
11
|
-
description: "<Your Package Description>",
|
|
12
|
-
commands: {
|
|
13
|
-
"<your-first-command>": {
|
|
14
|
-
command: "<insert shell command here>",
|
|
15
|
-
description: "A description for using your command",
|
|
16
|
-
},
|
|
17
|
-
"<your-second-command>": {
|
|
18
|
-
command: "<insert shell command here>",
|
|
19
|
-
description: "A description for using your command",
|
|
20
|
-
},
|
|
21
|
-
"<your-third-command>": {
|
|
22
|
-
command: "<insert shell command here>",
|
|
23
|
-
description: "A description for using your command",
|
|
24
|
-
},
|
|
25
|
-
},
|
|
26
|
-
});
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RepoKit = void 0;
|
|
4
|
-
const core_1 = require("@repokit/core");
|
|
5
|
-
/**
|
|
6
|
-
* Please fill out this config file with your desired
|
|
7
|
-
* repokit settings
|
|
8
|
-
*/
|
|
9
|
-
exports.RepoKit = new core_1.RepoKitConfig({
|
|
10
|
-
project: "Your Project Name",
|
|
11
|
-
commands: {
|
|
12
|
-
"<your-first-command>": {
|
|
13
|
-
command: "<insert shell command here>",
|
|
14
|
-
description: "A description for using your command",
|
|
15
|
-
},
|
|
16
|
-
"<your-second-command>": {
|
|
17
|
-
command: "<insert shell command here>",
|
|
18
|
-
description: "A description for using your command",
|
|
19
|
-
},
|
|
20
|
-
"<your-third-command>": {
|
|
21
|
-
command: "<insert shell command here>",
|
|
22
|
-
description: "A description for using your command",
|
|
23
|
-
},
|
|
24
|
-
},
|
|
25
|
-
});
|
package/dist/cjs/types.js
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { parseArgs } from "node:util";
|
|
2
|
-
import { join } from "node:path";
|
|
3
|
-
import { stat } from "node:fs/promises";
|
|
4
|
-
import { existsSync } from "node:fs";
|
|
5
|
-
import { TaskPooler } from "./TaskPooler.js";
|
|
6
|
-
import { RepoKitCommand } from "./RepoKitCommand.js";
|
|
7
|
-
/* oxlint-disable typescript-eslint(no-misused-spread) */
|
|
8
|
-
export class CommandParser {
|
|
9
|
-
static async parse() {
|
|
10
|
-
const { paths, root } = this.parsePaths();
|
|
11
|
-
if (!root || !existsSync(root) || !(await stat(root)).isDirectory()) {
|
|
12
|
-
return console.log(JSON.stringify([]));
|
|
13
|
-
}
|
|
14
|
-
const pathList = paths.split(",").filter(Boolean);
|
|
15
|
-
const pool = new TaskPooler();
|
|
16
|
-
const results = await Promise.all(pathList.map(path => pool.enqueue(() => this.parseCommand(join(root, path)))));
|
|
17
|
-
console.log(JSON.stringify(results.flat()));
|
|
18
|
-
}
|
|
19
|
-
static async parseCommand(path) {
|
|
20
|
-
const commands = [];
|
|
21
|
-
const declaredExports = await import(path);
|
|
22
|
-
for (const key in declaredExports) {
|
|
23
|
-
if (declaredExports[key] instanceof RepoKitCommand) {
|
|
24
|
-
commands.push({ ...declaredExports[key], location: path });
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
return commands;
|
|
28
|
-
}
|
|
29
|
-
static parsePaths() {
|
|
30
|
-
try {
|
|
31
|
-
return parseArgs({
|
|
32
|
-
options: {
|
|
33
|
-
paths: {
|
|
34
|
-
default: "",
|
|
35
|
-
multiple: false,
|
|
36
|
-
short: "p",
|
|
37
|
-
type: "string",
|
|
38
|
-
},
|
|
39
|
-
root: {
|
|
40
|
-
default: "",
|
|
41
|
-
multiple: false,
|
|
42
|
-
short: "r",
|
|
43
|
-
type: "string",
|
|
44
|
-
},
|
|
45
|
-
},
|
|
46
|
-
}).values;
|
|
47
|
-
}
|
|
48
|
-
catch {
|
|
49
|
-
return { paths: "", root: "" };
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { parseArgs } from "node:util";
|
|
2
|
-
import { join } from "node:path";
|
|
3
|
-
import { existsSync } from "node:fs";
|
|
4
|
-
import { RepoKitConfig } from "./RepoKitConfig.js";
|
|
5
|
-
export class ConfigurationParser {
|
|
6
|
-
static async parse() {
|
|
7
|
-
const root = this.parseRoot();
|
|
8
|
-
const path = join(root, "repokit.ts");
|
|
9
|
-
if (!existsSync(path)) {
|
|
10
|
-
return;
|
|
11
|
-
}
|
|
12
|
-
const config = await import(path);
|
|
13
|
-
for (const key in config) {
|
|
14
|
-
if (config[key] instanceof RepoKitConfig) {
|
|
15
|
-
return console.log(JSON.stringify(config[key]));
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
static parseRoot() {
|
|
20
|
-
return parseArgs({
|
|
21
|
-
options: {
|
|
22
|
-
root: {
|
|
23
|
-
default: "",
|
|
24
|
-
multiple: false,
|
|
25
|
-
short: "r",
|
|
26
|
-
type: "string",
|
|
27
|
-
},
|
|
28
|
-
},
|
|
29
|
-
}).values.root;
|
|
30
|
-
}
|
|
31
|
-
}
|
package/dist/mjs/TaskPooler.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { AutoIncrementingID } from "@figliolia/event-emitter";
|
|
2
|
-
export class TaskPooler {
|
|
3
|
-
maxSize;
|
|
4
|
-
IDs = new AutoIncrementingID();
|
|
5
|
-
runningTasks = new Map();
|
|
6
|
-
constructor(maxSize = 10) {
|
|
7
|
-
this.maxSize = maxSize;
|
|
8
|
-
}
|
|
9
|
-
enqueue(task) {
|
|
10
|
-
return new Promise(resolve => {
|
|
11
|
-
if (this.runningTasks.size < 10) {
|
|
12
|
-
return resolve(this.indexRunningTask(task));
|
|
13
|
-
}
|
|
14
|
-
resolve(this.indexBehindNextOpening(task));
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
indexRunningTask(task) {
|
|
18
|
-
const ID = this.IDs.get();
|
|
19
|
-
const promise = task();
|
|
20
|
-
this.runningTasks.set(ID, promise);
|
|
21
|
-
void promise.finally(() => this.runningTasks.delete(ID));
|
|
22
|
-
return promise;
|
|
23
|
-
}
|
|
24
|
-
async indexBehindNextOpening(task) {
|
|
25
|
-
await Promise.race(this.runningTasks.values());
|
|
26
|
-
return this.indexRunningTask(task);
|
|
27
|
-
}
|
|
28
|
-
}
|
package/dist/mjs/index.js
DELETED
package/dist/mjs/package.json
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { RepoKitCommand } from "@repokit/core";
|
|
2
|
-
/**
|
|
3
|
-
* Please fill out this command file with your desired settings
|
|
4
|
-
*/
|
|
5
|
-
export const Commands = new RepoKitCommand({
|
|
6
|
-
name: "<Your Package Name>",
|
|
7
|
-
owner: "<Optional Team or Individual>",
|
|
8
|
-
description: "<Your Package Description>",
|
|
9
|
-
commands: {
|
|
10
|
-
"<your-first-command>": {
|
|
11
|
-
command: "<insert shell command here>",
|
|
12
|
-
description: "A description for using your command",
|
|
13
|
-
},
|
|
14
|
-
"<your-second-command>": {
|
|
15
|
-
command: "<insert shell command here>",
|
|
16
|
-
description: "A description for using your command",
|
|
17
|
-
},
|
|
18
|
-
"<your-third-command>": {
|
|
19
|
-
command: "<insert shell command here>",
|
|
20
|
-
description: "A description for using your command",
|
|
21
|
-
},
|
|
22
|
-
},
|
|
23
|
-
});
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { RepoKitConfig } from "@repokit/core";
|
|
2
|
-
/**
|
|
3
|
-
* Please fill out this config file with your desired
|
|
4
|
-
* repokit settings
|
|
5
|
-
*/
|
|
6
|
-
export const RepoKit = new RepoKitConfig({
|
|
7
|
-
project: "Your Project Name",
|
|
8
|
-
commands: {
|
|
9
|
-
"<your-first-command>": {
|
|
10
|
-
command: "<insert shell command here>",
|
|
11
|
-
description: "A description for using your command",
|
|
12
|
-
},
|
|
13
|
-
"<your-second-command>": {
|
|
14
|
-
command: "<insert shell command here>",
|
|
15
|
-
description: "A description for using your command",
|
|
16
|
-
},
|
|
17
|
-
"<your-third-command>": {
|
|
18
|
-
command: "<insert shell command here>",
|
|
19
|
-
description: "A description for using your command",
|
|
20
|
-
},
|
|
21
|
-
},
|
|
22
|
-
});
|
package/dist/mjs/types.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { ICommand, IRepoKitCommand } from "./types";
|
|
2
|
-
export declare class RepoKitCommand {
|
|
3
|
-
name: string;
|
|
4
|
-
owner: string;
|
|
5
|
-
description: string;
|
|
6
|
-
commands: Record<string, ICommand>;
|
|
7
|
-
constructor({ name, description, owner, commands, }: IRepoKitCommand);
|
|
8
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { AsyncTask } from "./types";
|
|
2
|
-
export declare class TaskPooler<T> {
|
|
3
|
-
maxSize: number;
|
|
4
|
-
private readonly IDs;
|
|
5
|
-
private readonly runningTasks;
|
|
6
|
-
constructor(maxSize?: number);
|
|
7
|
-
enqueue(task: AsyncTask<T>): Promise<T>;
|
|
8
|
-
private indexRunningTask;
|
|
9
|
-
private indexBehindNextOpening;
|
|
10
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/types/index.d.ts
DELETED
package/dist/types/types.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
export interface IRepoKitConfig {
|
|
2
|
-
project: string;
|
|
3
|
-
commands?: Record<string, ICommand>;
|
|
4
|
-
}
|
|
5
|
-
export interface IRepoKitCommand {
|
|
6
|
-
name: string;
|
|
7
|
-
owner?: string;
|
|
8
|
-
description: string;
|
|
9
|
-
commands: Record<string, ICommand>;
|
|
10
|
-
}
|
|
11
|
-
export interface ICommand {
|
|
12
|
-
command: string;
|
|
13
|
-
description: string;
|
|
14
|
-
}
|
|
15
|
-
export interface ILocatedCommand extends IRepoKitCommand {
|
|
16
|
-
location: string;
|
|
17
|
-
}
|
|
18
|
-
export type AsyncTask<T> = () => Promise<T>;
|