@repokit/core 1.3.7 → 1.5.0
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/dist/CommandParser.d.ts +6 -0
- package/dist/CommandParser.js +55 -0
- package/dist/ConfigurationParser.d.ts +5 -0
- package/dist/ConfigurationParser.js +36 -0
- package/dist/RepoKitCommand.d.ts +8 -0
- package/dist/RepoKitCommand.js +16 -0
- package/dist/RepoKitConfig.d.ts +17 -0
- package/dist/RepoKitConfig.js +22 -0
- package/dist/TSCompiler.d.ts +2 -0
- package/dist/TSCompiler.js +11 -0
- package/dist/commands/parse_commands.d.ts +1 -0
- package/dist/commands/parse_commands.js +6 -0
- package/dist/commands/parse_configuration.d.ts +1 -0
- package/dist/commands/parse_configuration.js +4 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +19 -0
- package/dist/types.d.ts +21 -0
- package/dist/types.js +2 -0
- package/externals/CommandParser.ts +5 -10
- package/externals/ConfigurationParser.ts +4 -3
- package/externals/TSCompiler.ts +8 -0
- package/externals/commands/parse_configuration.ts +1 -3
- package/installation/install.sh +6 -27
- package/internals/configuration/configuration.rs +1 -1
- package/internals/file_walker/walker.rs +1 -5
- package/internals/internal_commands/register_command.rs +1 -1
- package/internals/internal_commands/typescript_command.rs +3 -3
- package/internals/internal_filesystem/internal_filesystem.rs +3 -3
- package/package.json +24 -8
- package/externals/TaskPooler.ts +0 -31
- /package/externals/templates/{command_template.ts → command_template.txt} +0 -0
- /package/externals/templates/{configuration_template.ts → configuration_template.txt} +0 -0
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CommandParser = void 0;
|
|
4
|
+
const node_util_1 = require("node:util");
|
|
5
|
+
const node_path_1 = require("node:path");
|
|
6
|
+
const promises_1 = require("node:fs/promises");
|
|
7
|
+
const node_fs_1 = require("node:fs");
|
|
8
|
+
const TSCompiler_1 = require("./TSCompiler");
|
|
9
|
+
const RepoKitCommand_1 = require("./RepoKitCommand");
|
|
10
|
+
/* oxlint-disable typescript-eslint(no-misused-spread) */
|
|
11
|
+
class CommandParser extends TSCompiler_1.TSCompiler {
|
|
12
|
+
static async parse() {
|
|
13
|
+
const { paths, root } = this.parsePaths();
|
|
14
|
+
if (!root || !(0, node_fs_1.existsSync)(root) || !(await (0, promises_1.stat)(root)).isDirectory()) {
|
|
15
|
+
return console.log(JSON.stringify([]));
|
|
16
|
+
}
|
|
17
|
+
const pathList = paths.split(",").filter(Boolean);
|
|
18
|
+
const results = pathList.map(path => this.parseCommand((0, node_path_1.join)(root, path)));
|
|
19
|
+
console.log(JSON.stringify(results.flat()));
|
|
20
|
+
}
|
|
21
|
+
static parseCommand(path) {
|
|
22
|
+
const commands = [];
|
|
23
|
+
const declaredExports = require(path);
|
|
24
|
+
for (const key in declaredExports) {
|
|
25
|
+
if (declaredExports[key] instanceof RepoKitCommand_1.RepoKitCommand) {
|
|
26
|
+
commands.push({ ...declaredExports[key], location: path });
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return commands;
|
|
30
|
+
}
|
|
31
|
+
static parsePaths() {
|
|
32
|
+
try {
|
|
33
|
+
return (0, node_util_1.parseArgs)({
|
|
34
|
+
options: {
|
|
35
|
+
paths: {
|
|
36
|
+
default: "",
|
|
37
|
+
multiple: false,
|
|
38
|
+
short: "p",
|
|
39
|
+
type: "string",
|
|
40
|
+
},
|
|
41
|
+
root: {
|
|
42
|
+
default: "",
|
|
43
|
+
multiple: false,
|
|
44
|
+
short: "r",
|
|
45
|
+
type: "string",
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
}).values;
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
return { paths: "", root: "" };
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
exports.CommandParser = CommandParser;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ConfigurationParser = void 0;
|
|
4
|
+
const node_util_1 = require("node:util");
|
|
5
|
+
const node_path_1 = require("node:path");
|
|
6
|
+
const node_fs_1 = require("node:fs");
|
|
7
|
+
const TSCompiler_1 = require("./TSCompiler");
|
|
8
|
+
const RepoKitConfig_1 = require("./RepoKitConfig");
|
|
9
|
+
class ConfigurationParser extends TSCompiler_1.TSCompiler {
|
|
10
|
+
static parse() {
|
|
11
|
+
const root = this.parseRoot();
|
|
12
|
+
const path = (0, node_path_1.join)(root, "repokit.ts");
|
|
13
|
+
if (!(0, node_fs_1.existsSync)(path)) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
const config = require(path);
|
|
17
|
+
for (const key in config) {
|
|
18
|
+
if (config[key] instanceof RepoKitConfig_1.RepoKitConfig) {
|
|
19
|
+
return console.log(JSON.stringify(config[key].toScoped(path)));
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
static parseRoot() {
|
|
24
|
+
return (0, node_util_1.parseArgs)({
|
|
25
|
+
options: {
|
|
26
|
+
root: {
|
|
27
|
+
default: "",
|
|
28
|
+
multiple: false,
|
|
29
|
+
short: "r",
|
|
30
|
+
type: "string",
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
}).values.root;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
exports.ConfigurationParser = ConfigurationParser;
|
|
@@ -0,0 +1,8 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RepoKitCommand = void 0;
|
|
4
|
+
class RepoKitCommand {
|
|
5
|
+
name;
|
|
6
|
+
owner;
|
|
7
|
+
description;
|
|
8
|
+
commands;
|
|
9
|
+
constructor({ name, description, owner = "", commands = {}, }) {
|
|
10
|
+
this.name = name;
|
|
11
|
+
this.owner = owner;
|
|
12
|
+
this.commands = commands;
|
|
13
|
+
this.description = description;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
exports.RepoKitCommand = RepoKitCommand;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ICommand, IRepoKitConfig } from "./types";
|
|
2
|
+
import { RepoKitCommand } from "./RepoKitCommand";
|
|
3
|
+
export declare class RepoKitConfig implements Required<IRepoKitConfig> {
|
|
4
|
+
project: string;
|
|
5
|
+
thirdParty: RepoKitCommand[];
|
|
6
|
+
commands: Record<string, ICommand>;
|
|
7
|
+
constructor({ project, commands, thirdParty }: IRepoKitConfig);
|
|
8
|
+
toScoped(location: string): this & {
|
|
9
|
+
thirdParty: {
|
|
10
|
+
location: string;
|
|
11
|
+
name: string;
|
|
12
|
+
owner: string;
|
|
13
|
+
description: string;
|
|
14
|
+
commands: Record<string, ICommand>;
|
|
15
|
+
}[];
|
|
16
|
+
};
|
|
17
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RepoKitConfig = void 0;
|
|
4
|
+
const RepoKitCommand_1 = require("./RepoKitCommand");
|
|
5
|
+
/* eslint-disable typescript-eslint(no-misused-spread */
|
|
6
|
+
class RepoKitConfig {
|
|
7
|
+
project;
|
|
8
|
+
thirdParty;
|
|
9
|
+
commands;
|
|
10
|
+
constructor({ project, commands = {}, thirdParty = [] }) {
|
|
11
|
+
this.project = project;
|
|
12
|
+
this.commands = commands;
|
|
13
|
+
this.thirdParty = thirdParty.map(command => new RepoKitCommand_1.RepoKitCommand(command));
|
|
14
|
+
}
|
|
15
|
+
toScoped(location) {
|
|
16
|
+
return {
|
|
17
|
+
...this,
|
|
18
|
+
thirdParty: this.thirdParty.map(command => ({ ...command, location })),
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.RepoKitConfig = RepoKitConfig;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TSCompiler = void 0;
|
|
4
|
+
const ts_node_1 = require("ts-node");
|
|
5
|
+
class TSCompiler {
|
|
6
|
+
static {
|
|
7
|
+
const service = (0, ts_node_1.register)();
|
|
8
|
+
service.enabled(true);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
exports.TSCompiler = TSCompiler;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
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/types.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { RepoKitCommand } from "./RepoKitCommand";
|
|
2
|
+
export interface IRepoKitConfig {
|
|
3
|
+
project: string;
|
|
4
|
+
thirdParty?: RepoKitCommand[];
|
|
5
|
+
commands?: Record<string, ICommand>;
|
|
6
|
+
}
|
|
7
|
+
export interface IRepoKitCommand {
|
|
8
|
+
name: string;
|
|
9
|
+
owner?: string;
|
|
10
|
+
description: string;
|
|
11
|
+
commands: Record<string, ICommand>;
|
|
12
|
+
}
|
|
13
|
+
export interface ICommand {
|
|
14
|
+
command: string;
|
|
15
|
+
description: string;
|
|
16
|
+
args?: Record<string, string>;
|
|
17
|
+
}
|
|
18
|
+
export interface ILocatedCommand extends IRepoKitCommand {
|
|
19
|
+
location: string;
|
|
20
|
+
}
|
|
21
|
+
export type AsyncTask<T> = () => Promise<T>;
|
package/dist/types.js
ADDED
|
@@ -4,29 +4,24 @@ import { stat } from "node:fs/promises";
|
|
|
4
4
|
import { existsSync } from "node:fs";
|
|
5
5
|
|
|
6
6
|
import type { ILocatedCommand } from "./types";
|
|
7
|
-
import {
|
|
7
|
+
import { TSCompiler } from "./TSCompiler";
|
|
8
8
|
import { RepoKitCommand } from "./RepoKitCommand";
|
|
9
9
|
/* oxlint-disable typescript-eslint(no-misused-spread) */
|
|
10
10
|
|
|
11
|
-
export class CommandParser {
|
|
11
|
+
export class CommandParser extends TSCompiler {
|
|
12
12
|
public static async parse() {
|
|
13
13
|
const { paths, root } = this.parsePaths();
|
|
14
14
|
if (!root || !existsSync(root) || !(await stat(root)).isDirectory()) {
|
|
15
15
|
return console.log(JSON.stringify([]));
|
|
16
16
|
}
|
|
17
17
|
const pathList = paths.split(",").filter(Boolean);
|
|
18
|
-
const
|
|
19
|
-
const results = await Promise.all(
|
|
20
|
-
pathList.map(path =>
|
|
21
|
-
pool.enqueue(() => this.parseCommand(join(root, path))),
|
|
22
|
-
),
|
|
23
|
-
);
|
|
18
|
+
const results = pathList.map(path => this.parseCommand(join(root, path)));
|
|
24
19
|
console.log(JSON.stringify(results.flat()));
|
|
25
20
|
}
|
|
26
21
|
|
|
27
|
-
private static
|
|
22
|
+
private static parseCommand(path: string) {
|
|
28
23
|
const commands: ILocatedCommand[] = [];
|
|
29
|
-
const declaredExports =
|
|
24
|
+
const declaredExports = require(path);
|
|
30
25
|
for (const key in declaredExports) {
|
|
31
26
|
if (declaredExports[key] instanceof RepoKitCommand) {
|
|
32
27
|
commands.push({ ...declaredExports[key], location: path });
|
|
@@ -2,16 +2,17 @@ import { parseArgs } from "node:util";
|
|
|
2
2
|
import { join } from "node:path";
|
|
3
3
|
import { existsSync } from "node:fs";
|
|
4
4
|
|
|
5
|
+
import { TSCompiler } from "./TSCompiler";
|
|
5
6
|
import { RepoKitConfig } from "./RepoKitConfig";
|
|
6
7
|
|
|
7
|
-
export class ConfigurationParser {
|
|
8
|
-
public static
|
|
8
|
+
export class ConfigurationParser extends TSCompiler {
|
|
9
|
+
public static parse() {
|
|
9
10
|
const root = this.parseRoot();
|
|
10
11
|
const path = join(root, "repokit.ts");
|
|
11
12
|
if (!existsSync(path)) {
|
|
12
13
|
return;
|
|
13
14
|
}
|
|
14
|
-
const config =
|
|
15
|
+
const config = require(path);
|
|
15
16
|
for (const key in config) {
|
|
16
17
|
if (config[key] instanceof RepoKitConfig) {
|
|
17
18
|
return console.log(JSON.stringify(config[key].toScoped(path)));
|
package/installation/install.sh
CHANGED
|
@@ -1,20 +1,16 @@
|
|
|
1
1
|
|
|
2
2
|
CWD=$(pwd)
|
|
3
3
|
|
|
4
|
-
MODULE_DIRECTORY="node_modules"
|
|
5
|
-
|
|
6
|
-
if [[ "$CWD" != *"$MODULE_DIRECTORY"* ]]; then
|
|
7
|
-
yarn symlink;
|
|
8
|
-
exit 0;
|
|
9
|
-
fi
|
|
10
|
-
|
|
11
4
|
REPLACEMENT="/node_modules"
|
|
12
5
|
FALLBACK_ROOT="${CWD%${REPLACEMENT}*}"
|
|
13
6
|
|
|
14
|
-
SCRIPT_ORIGIN=$(pwd)
|
|
15
7
|
GIT_ROOT=$(git rev-parse --show-toplevel 2>/dev/null)
|
|
16
8
|
REPO_ROOT=${GIT_ROOT:-$FALLBACK_ROOT}
|
|
17
9
|
|
|
10
|
+
if [[ "$CWD" != *"$REPLACEMENT"* ]]; then
|
|
11
|
+
exit 0;
|
|
12
|
+
fi
|
|
13
|
+
|
|
18
14
|
|
|
19
15
|
cd $REPO_ROOT
|
|
20
16
|
|
|
@@ -29,28 +25,11 @@ else
|
|
|
29
25
|
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
|
|
30
26
|
fi
|
|
31
27
|
|
|
32
|
-
if npm list --depth=0 tsx; then
|
|
33
|
-
echo "Found tsx installation"
|
|
34
|
-
else
|
|
35
|
-
# Node Dependencies installation
|
|
36
|
-
if [ -f "${REPO_ROOT}/yarn.lock" ]; then
|
|
37
|
-
yarn global add tsx
|
|
38
|
-
elif [ -f "${REPO_ROOT}/pnpm-lock.yaml" ]; then
|
|
39
|
-
pnpm add -g tsx
|
|
40
|
-
elif [ -f "${REPO_ROOT}/package-lock.json" ]; then
|
|
41
|
-
npm i -g tsx
|
|
42
|
-
else
|
|
43
|
-
echo "No node.js package manager detected"
|
|
44
|
-
echo "Run npm init to create your node.js project"
|
|
45
|
-
fi
|
|
46
|
-
fi
|
|
47
|
-
|
|
48
|
-
|
|
49
28
|
echo "Installing Repokit CLI"
|
|
50
29
|
|
|
51
|
-
cd $
|
|
30
|
+
cd $CWD
|
|
52
31
|
|
|
53
|
-
echo "Compiling from $
|
|
32
|
+
echo "Compiling from $CWD"
|
|
54
33
|
|
|
55
34
|
. "$HOME/.cargo/env"
|
|
56
35
|
RUSTFLAGS="-Awarnings" cargo build --release
|
|
@@ -16,7 +16,7 @@ impl Configuration {
|
|
|
16
16
|
}
|
|
17
17
|
Configuration::welcome();
|
|
18
18
|
let mut source =
|
|
19
|
-
InternalFileSystem::new(root).resolve_template("configuration_template.
|
|
19
|
+
InternalFileSystem::new(root).resolve_template("configuration_template.txt");
|
|
20
20
|
let mut target = FileBuilder::create(path, |_| Logger::file_create_error());
|
|
21
21
|
FileBuilder::copy_to(&mut source, &mut target, |_| Logger::file_write_error());
|
|
22
22
|
Logger::info(
|
|
@@ -19,14 +19,10 @@ impl ParallelVisitor for TSFileVisitor {
|
|
|
19
19
|
let root_replacer = format!("{}/", self.root);
|
|
20
20
|
let repokit_import_matcher =
|
|
21
21
|
Regex::new(r#"(require\(|from[\s*]?)['"]@repokit/core["'][\)]?[;]?$"#).unwrap();
|
|
22
|
-
let template_matcher = Regex::new(r"externals\/templates\/[^\s]*?_template\.ts$").unwrap();
|
|
23
22
|
if let Ok(entry) = entry {
|
|
24
23
|
let path = entry.path();
|
|
25
24
|
let path_string = path.to_str().map_or("", |f| f);
|
|
26
|
-
if entry.file_type().is_some_and(|ft| ft.is_file())
|
|
27
|
-
&& path_string.ends_with(".ts")
|
|
28
|
-
&& !template_matcher.is_match(path_string)
|
|
29
|
-
{
|
|
25
|
+
if entry.file_type().is_some_and(|ft| ft.is_file()) && path_string.ends_with(".ts") {
|
|
30
26
|
let mut open_comment = false;
|
|
31
27
|
let file: File = FileBuilder::open(path_string, |_| Logger::open_file_error());
|
|
32
28
|
let reader: BufReader<File> = BufReader::new(file);
|
|
@@ -89,7 +89,7 @@ impl InternalExecutable for RegisterCommand {
|
|
|
89
89
|
Logger::info("Registering a new command");
|
|
90
90
|
let command_path = self.validate_path(args);
|
|
91
91
|
let mut source =
|
|
92
|
-
InternalFileSystem::new(&self.scope.root).resolve_template("command_template.
|
|
92
|
+
InternalFileSystem::new(&self.scope.root).resolve_template("command_template.txt");
|
|
93
93
|
let mut target = FileBuilder::create(&command_path, |_| Logger::file_create_error());
|
|
94
94
|
FileBuilder::copy_to(&mut source, &mut target, |_| Logger::file_write_error());
|
|
95
95
|
Logger::info("Creating command file");
|
|
@@ -23,7 +23,7 @@ impl TypescriptCommand {
|
|
|
23
23
|
|
|
24
24
|
pub fn parse_configuration(&self) -> RepoKitConfig {
|
|
25
25
|
let executable =
|
|
26
|
-
InternalFileSystem::new(&self.root).resolve_command("parse_configuration.
|
|
26
|
+
InternalFileSystem::new(&self.root).resolve_command("parse_configuration.js");
|
|
27
27
|
let stdout = self.execute(format!("{executable} --root {}", &self.root).as_str());
|
|
28
28
|
if stdout.is_empty() {
|
|
29
29
|
Configuration::create(&self.root);
|
|
@@ -34,7 +34,7 @@ impl TypescriptCommand {
|
|
|
34
34
|
|
|
35
35
|
pub fn parse_commands(&self, path_list: &MutexGuard<Vec<String>>) -> Vec<RepoKitCommand> {
|
|
36
36
|
let paths = path_list.join(",");
|
|
37
|
-
let executable = InternalFileSystem::new(&self.root).resolve_command("parse_commands.
|
|
37
|
+
let executable = InternalFileSystem::new(&self.root).resolve_command("parse_commands.js");
|
|
38
38
|
let stdout =
|
|
39
39
|
self.execute(format!("{executable} --paths {paths} --root {}", self.root).as_str());
|
|
40
40
|
let result: Result<Vec<RepoKitCommand>, serde_json::Error> = serde_json::from_str(&stdout);
|
|
@@ -52,7 +52,7 @@ impl TypescriptCommand {
|
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
fn execute(&self, args: &str) -> String {
|
|
55
|
-
Executor::exec(format!("
|
|
55
|
+
Executor::exec(format!("node {args}"), |cmd| {
|
|
56
56
|
cmd.current_dir(Path::new(&self.root))
|
|
57
57
|
})
|
|
58
58
|
}
|
|
@@ -56,15 +56,15 @@ impl InternalFileSystem {
|
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
fn commands_directory(&self) -> PathBuf {
|
|
59
|
-
self.absolute(format!("{}/commands", self.package_directory()).as_str())
|
|
59
|
+
self.absolute(format!("{}/dist/commands", self.package_directory()).as_str())
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
fn templates_directory(&self) -> PathBuf {
|
|
63
|
-
self.absolute(format!("{}/templates", self.package_directory()).as_str())
|
|
63
|
+
self.absolute(format!("{}/externals/templates", self.package_directory()).as_str())
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
fn package_directory(&self) -> String {
|
|
67
|
-
format!("./node_modules/{}
|
|
67
|
+
format!("./node_modules/{}", self.package_name())
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
fn package_name(&self) -> String {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@repokit/core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"description": "A knowledgebase for your repository - wrapped in a CLI",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cli",
|
|
@@ -15,31 +15,47 @@
|
|
|
15
15
|
"type": "git",
|
|
16
16
|
"url": "git+https://github.com/alexfigliolia/repokit.git"
|
|
17
17
|
},
|
|
18
|
-
"
|
|
18
|
+
"files": [
|
|
19
|
+
"media",
|
|
20
|
+
"dist",
|
|
21
|
+
"externals",
|
|
22
|
+
"internals",
|
|
23
|
+
"installation",
|
|
24
|
+
"Cargo.lock",
|
|
25
|
+
"Cargo.toml"
|
|
26
|
+
],
|
|
27
|
+
"main": "./dist/index.js",
|
|
28
|
+
"module": "./dist/index.js",
|
|
29
|
+
"types": "./dist/index.d.ts",
|
|
19
30
|
"publishConfig": {
|
|
20
31
|
"access": "public"
|
|
21
32
|
},
|
|
22
33
|
"scripts": {
|
|
23
34
|
"build:all": "yarn lint:ts && yarn lint:rust && yarn install:rust",
|
|
24
35
|
"build:rust": "cargo build --release",
|
|
36
|
+
"build:ts": "tsx devserver/run.ts",
|
|
37
|
+
"clean:ts": "tsx devserver/run.ts -c",
|
|
25
38
|
"grant:exec": "chmod -R +x ./installation",
|
|
26
39
|
"install:rust": "yarn build:rust && cargo install --path .",
|
|
27
40
|
"lint:rust": "cargo clippy --fix --allow-dirty",
|
|
28
41
|
"lint:ts": "yarn oxlint --type-aware --type-check --report-unused-disable-directives --fix && yarn oxfmt",
|
|
42
|
+
"package:ts": "yarn lint:ts && yarn lint:rust && yarn build:ts",
|
|
29
43
|
"postinstall": "yarn grant:exec && ./installation/install.sh",
|
|
30
44
|
"repokit": "yarn install:rust && repokit",
|
|
31
|
-
"run:dev": "yarn
|
|
32
|
-
"
|
|
45
|
+
"run:dev": "yarn build:ts && cargo run --package repokit --bin repokit",
|
|
46
|
+
"watch:ts": "tsx devserver/run.ts -w"
|
|
33
47
|
},
|
|
34
48
|
"dependencies": {
|
|
35
|
-
"@figliolia/event-emitter": "^1.
|
|
36
|
-
"
|
|
49
|
+
"@figliolia/event-emitter": "^1.2.0",
|
|
50
|
+
"ts-node": "^10.9.2"
|
|
37
51
|
},
|
|
38
52
|
"devDependencies": {
|
|
39
|
-
"@
|
|
40
|
-
"
|
|
53
|
+
"@figliolia/child-process": "^1.0.4",
|
|
54
|
+
"@types/node": "^25.3.0",
|
|
55
|
+
"oxfmt": "^0.34.0",
|
|
41
56
|
"oxlint": "^1.42.0",
|
|
42
57
|
"oxlint-tsgolint": "^0.14.0",
|
|
58
|
+
"tsx": "^4.21.0",
|
|
43
59
|
"typescript": "^5.9.3"
|
|
44
60
|
}
|
|
45
61
|
}
|
package/externals/TaskPooler.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { AutoIncrementingID } from "@figliolia/event-emitter";
|
|
2
|
-
|
|
3
|
-
import type { AsyncTask } from "./types";
|
|
4
|
-
|
|
5
|
-
export class TaskPooler<T> {
|
|
6
|
-
private readonly IDs = new AutoIncrementingID();
|
|
7
|
-
private readonly runningTasks = new Map<string, Promise<T>>();
|
|
8
|
-
constructor(public maxSize = 10) {}
|
|
9
|
-
|
|
10
|
-
public enqueue(task: AsyncTask<T>) {
|
|
11
|
-
return new Promise<T>(resolve => {
|
|
12
|
-
if (this.runningTasks.size < 10) {
|
|
13
|
-
return resolve(this.indexRunningTask(task));
|
|
14
|
-
}
|
|
15
|
-
resolve(this.indexBehindNextOpening(task));
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
private indexRunningTask(task: AsyncTask<T>) {
|
|
20
|
-
const ID = this.IDs.get();
|
|
21
|
-
const promise = task();
|
|
22
|
-
this.runningTasks.set(ID, promise);
|
|
23
|
-
void promise.finally(() => this.runningTasks.delete(ID));
|
|
24
|
-
return promise;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
private async indexBehindNextOpening(task: AsyncTask<T>) {
|
|
28
|
-
await Promise.race(this.runningTasks.values());
|
|
29
|
-
return this.indexRunningTask(task);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
File without changes
|
|
File without changes
|