@repokit/core 1.7.1 → 1.9.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.mts +3 -2
- package/dist/CommandParser.mjs +8 -13
- package/dist/ConfigurationParser.d.mts +1 -1
- package/dist/ConfigurationParser.mjs +5 -6
- package/dist/TSCompiler.d.mts +3 -5
- package/dist/TSCompiler.mjs +23 -15
- package/dist/_virtual/_rolldown/runtime.mjs +5 -0
- package/dist/commands/parse_configuration.mjs +1 -3
- package/externals/CommandParser.ts +9 -17
- package/externals/ConcurrencyPool.ts +1 -2
- package/externals/ConfigurationParser.ts +5 -7
- package/externals/RepoKitConfig.ts +1 -1
- package/externals/TSCompiler.ts +26 -21
- package/externals/commands/parse_configuration.ts +2 -2
- package/externals/index.ts +1 -1
- package/installation/install.sh +0 -1
- package/package.json +12 -4
package/dist/CommandParser.d.mts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { TSCompiler } from "./TSCompiler.mjs";
|
|
2
|
+
|
|
1
3
|
//#region externals/CommandParser.d.ts
|
|
2
|
-
declare class CommandParser {
|
|
3
|
-
private static compiler?;
|
|
4
|
+
declare class CommandParser extends TSCompiler {
|
|
4
5
|
static parse(): Promise<void>;
|
|
5
6
|
private static parseCommand;
|
|
6
7
|
private static parsePaths;
|
package/dist/CommandParser.mjs
CHANGED
|
@@ -1,25 +1,20 @@
|
|
|
1
|
-
import { TSCompiler } from "./TSCompiler.mjs";
|
|
2
1
|
import { RepoKitCommand } from "./RepoKitCommand.mjs";
|
|
3
|
-
import {
|
|
4
|
-
import { parseArgs } from "node:util";
|
|
5
|
-
import { join } from "node:path";
|
|
6
|
-
import { stat } from "node:fs/promises";
|
|
2
|
+
import { TSCompiler } from "./TSCompiler.mjs";
|
|
7
3
|
import { existsSync } from "node:fs";
|
|
4
|
+
import { stat } from "node:fs/promises";
|
|
5
|
+
import { join } from "node:path";
|
|
6
|
+
import { parseArgs } from "node:util";
|
|
8
7
|
//#region externals/CommandParser.ts
|
|
9
|
-
var CommandParser = class {
|
|
10
|
-
static compiler;
|
|
8
|
+
var CommandParser = class extends TSCompiler {
|
|
11
9
|
static async parse() {
|
|
12
10
|
const { paths, root } = this.parsePaths();
|
|
13
11
|
if (!root || !existsSync(root) || !(await stat(root)).isDirectory()) return console.log(JSON.stringify([]));
|
|
14
|
-
|
|
15
|
-
const pool = new ConcurrencyPool();
|
|
16
|
-
const pathList = paths.split(",").filter(Boolean);
|
|
17
|
-
const commands = await Promise.all(pathList.map((path) => pool.enqueue(() => this.parseCommand(root, path))));
|
|
12
|
+
const commands = paths.split(",").filter(Boolean).map((path) => this.parseCommand(join(root, path)));
|
|
18
13
|
console.log(JSON.stringify(commands.flat()));
|
|
19
14
|
}
|
|
20
|
-
static
|
|
15
|
+
static parseCommand(path) {
|
|
21
16
|
const commands = [];
|
|
22
|
-
const declaredExports =
|
|
17
|
+
const declaredExports = super.compile(path);
|
|
23
18
|
for (const key in declaredExports) if (declaredExports[key] instanceof RepoKitCommand) commands.push({
|
|
24
19
|
...declaredExports[key],
|
|
25
20
|
location: path
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import { TSCompiler } from "./TSCompiler.mjs";
|
|
2
2
|
import { RepoKitConfig } from "./RepoKitConfig.mjs";
|
|
3
|
-
import { parseArgs } from "node:util";
|
|
4
|
-
import { join } from "node:path";
|
|
5
3
|
import { existsSync } from "node:fs";
|
|
4
|
+
import { join } from "node:path";
|
|
5
|
+
import { parseArgs } from "node:util";
|
|
6
6
|
//#region externals/ConfigurationParser.ts
|
|
7
7
|
var ConfigurationParser = class extends TSCompiler {
|
|
8
|
-
static
|
|
9
|
-
const
|
|
10
|
-
const path = join(root, "repokit.ts");
|
|
8
|
+
static parse() {
|
|
9
|
+
const path = join(this.parseRoot(), "repokit.ts");
|
|
11
10
|
if (!existsSync(path)) return;
|
|
12
|
-
const config =
|
|
11
|
+
const config = super.compile(path);
|
|
13
12
|
for (const key in config) if (config[key] instanceof RepoKitConfig) return console.log(JSON.stringify(config[key].toScoped(path)));
|
|
14
13
|
}
|
|
15
14
|
static parseRoot() {
|
package/dist/TSCompiler.d.mts
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
//#region externals/TSCompiler.d.ts
|
|
2
2
|
declare class TSCompiler {
|
|
3
|
-
readonly
|
|
4
|
-
|
|
5
|
-
private static
|
|
6
|
-
constructor(root: string, command: string);
|
|
7
|
-
compile(path: string): Promise<any>;
|
|
3
|
+
private static readonly compilerOptions;
|
|
4
|
+
static compile<T extends Record<string, unknown>>(path: string): T;
|
|
5
|
+
private static import;
|
|
8
6
|
}
|
|
9
7
|
//#endregion
|
|
10
8
|
export { TSCompiler };
|
package/dist/TSCompiler.mjs
CHANGED
|
@@ -1,20 +1,28 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { transform } from "@swc/core";
|
|
1
|
+
import { __require } from "./_virtual/_rolldown/runtime.mjs";
|
|
2
|
+
import { register } from "ts-node";
|
|
4
3
|
//#region externals/TSCompiler.ts
|
|
5
|
-
var TSCompiler = class
|
|
6
|
-
static
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
var TSCompiler = class {
|
|
5
|
+
static compilerOptions = {
|
|
6
|
+
swc: true,
|
|
7
|
+
typeCheck: false,
|
|
8
|
+
transpileOnly: true,
|
|
9
|
+
compilerOptions: {
|
|
10
|
+
noEmit: true,
|
|
11
|
+
module: "commonjs",
|
|
12
|
+
isolatedModules: false
|
|
13
|
+
},
|
|
14
|
+
moduleTypes: { "**": "cjs" }
|
|
15
|
+
};
|
|
16
|
+
static compile(path) {
|
|
17
|
+
const compiler = register(this.compilerOptions);
|
|
18
|
+
compiler.enabled(true);
|
|
19
|
+
const result = this.import(path);
|
|
20
|
+
compiler.enabled(false);
|
|
21
|
+
return result;
|
|
10
22
|
}
|
|
11
|
-
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
await writeFile(target, result.code);
|
|
15
|
-
const config = await import(target);
|
|
16
|
-
await rm(target, { force: true });
|
|
17
|
-
return config;
|
|
23
|
+
static import(filePath) {
|
|
24
|
+
const _module = __require(filePath);
|
|
25
|
+
return _module?.__esModule ? _module : { default: _module };
|
|
18
26
|
}
|
|
19
27
|
};
|
|
20
28
|
//#endregion
|
|
@@ -1,34 +1,26 @@
|
|
|
1
|
-
import { parseArgs } from "node:util";
|
|
2
|
-
import { join } from "node:path";
|
|
3
|
-
import { stat } from "node:fs/promises";
|
|
4
1
|
import { existsSync } from "node:fs";
|
|
5
|
-
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
2
|
+
import { stat } from "node:fs/promises";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import { parseArgs } from "node:util";
|
|
8
5
|
import { RepoKitCommand } from "./RepoKitCommand";
|
|
9
|
-
import {
|
|
6
|
+
import { TSCompiler } from "./TSCompiler";
|
|
7
|
+
import type { ILocatedCommand } from "./types";
|
|
10
8
|
/* oxlint-disable typescript-eslint(no-misused-spread) */
|
|
11
9
|
|
|
12
|
-
export class CommandParser {
|
|
13
|
-
private static compiler?: TSCompiler;
|
|
14
|
-
|
|
10
|
+
export class CommandParser extends TSCompiler {
|
|
15
11
|
public static async parse() {
|
|
16
12
|
const { paths, root } = this.parsePaths();
|
|
17
13
|
if (!root || !existsSync(root) || !(await stat(root)).isDirectory()) {
|
|
18
14
|
return console.log(JSON.stringify([]));
|
|
19
15
|
}
|
|
20
|
-
this.compiler = new TSCompiler(root, "parse_commands");
|
|
21
|
-
const pool = new ConcurrencyPool<ILocatedCommand[]>();
|
|
22
16
|
const pathList = paths.split(",").filter(Boolean);
|
|
23
|
-
const commands =
|
|
24
|
-
pathList.map(path => pool.enqueue(() => this.parseCommand(root, path))),
|
|
25
|
-
);
|
|
17
|
+
const commands = pathList.map(path => this.parseCommand(join(root, path)));
|
|
26
18
|
console.log(JSON.stringify(commands.flat()));
|
|
27
19
|
}
|
|
28
20
|
|
|
29
|
-
private static
|
|
21
|
+
private static parseCommand(path: string) {
|
|
30
22
|
const commands: ILocatedCommand[] = [];
|
|
31
|
-
const declaredExports =
|
|
23
|
+
const declaredExports = super.compile(path);
|
|
32
24
|
for (const key in declaredExports) {
|
|
33
25
|
if (declaredExports[key] instanceof RepoKitCommand) {
|
|
34
26
|
commands.push({ ...declaredExports[key], location: path });
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { AutoIncrementingID } from "@figliolia/event-emitter";
|
|
2
|
-
|
|
3
2
|
import type { AsyncTask } from "./types";
|
|
4
3
|
|
|
5
4
|
export class ConcurrencyPool<T> {
|
|
6
5
|
private readonly IDs = new AutoIncrementingID();
|
|
7
6
|
private readonly activeTasks = new Map<string, Promise<T>>();
|
|
8
|
-
constructor(public readonly maxConcurrency
|
|
7
|
+
constructor(public readonly maxConcurrency = 10) {}
|
|
9
8
|
|
|
10
9
|
public async enqueue(task: AsyncTask<T>) {
|
|
11
10
|
if (this.activeTasks.size === this.maxConcurrency) {
|
|
@@ -1,19 +1,17 @@
|
|
|
1
|
-
import { parseArgs } from "node:util";
|
|
2
|
-
import { join } from "node:path";
|
|
3
1
|
import { existsSync } from "node:fs";
|
|
4
|
-
|
|
5
|
-
import {
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { parseArgs } from "node:util";
|
|
6
4
|
import { RepoKitConfig } from "./RepoKitConfig";
|
|
5
|
+
import { TSCompiler } from "./TSCompiler";
|
|
7
6
|
|
|
8
7
|
export class ConfigurationParser extends TSCompiler {
|
|
9
|
-
public static
|
|
8
|
+
public static parse() {
|
|
10
9
|
const root = this.parseRoot();
|
|
11
10
|
const path = join(root, "repokit.ts");
|
|
12
11
|
if (!existsSync(path)) {
|
|
13
12
|
return;
|
|
14
13
|
}
|
|
15
|
-
const
|
|
16
|
-
const config = await compiler.compile(path);
|
|
14
|
+
const config = super.compile(path);
|
|
17
15
|
for (const key in config) {
|
|
18
16
|
if (config[key] instanceof RepoKitConfig) {
|
|
19
17
|
return console.log(JSON.stringify(config[key].toScoped(path)));
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ICommand, IRepoKitConfig } from "./types";
|
|
2
1
|
import { RepoKitCommand } from "./RepoKitCommand";
|
|
2
|
+
import type { ICommand, IRepoKitConfig } from "./types";
|
|
3
3
|
/* eslint-disable typescript-eslint(no-misused-spread */
|
|
4
4
|
|
|
5
5
|
export class RepoKitConfig implements Required<IRepoKitConfig> {
|
package/externals/TSCompiler.ts
CHANGED
|
@@ -1,26 +1,31 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
import { transform } from "@swc/core";
|
|
1
|
+
import type { RegisterOptions } from "ts-node";
|
|
2
|
+
import { register } from "ts-node";
|
|
5
3
|
|
|
6
4
|
export class TSCompiler {
|
|
7
|
-
private static readonly
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
5
|
+
private static readonly compilerOptions: RegisterOptions = {
|
|
6
|
+
swc: true,
|
|
7
|
+
typeCheck: false,
|
|
8
|
+
transpileOnly: true,
|
|
9
|
+
compilerOptions: {
|
|
10
|
+
noEmit: true,
|
|
11
|
+
module: "commonjs",
|
|
12
|
+
isolatedModules: false,
|
|
13
|
+
},
|
|
14
|
+
moduleTypes: {
|
|
15
|
+
"**": "cjs",
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
public static compile<T extends Record<string, unknown>>(path: string) {
|
|
20
|
+
const compiler = register(this.compilerOptions);
|
|
21
|
+
compiler.enabled(true);
|
|
22
|
+
const result = this.import(path) as T;
|
|
23
|
+
compiler.enabled(false);
|
|
24
|
+
return result;
|
|
25
|
+
}
|
|
12
26
|
|
|
13
|
-
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
module: {
|
|
17
|
-
type: "es6",
|
|
18
|
-
},
|
|
19
|
-
});
|
|
20
|
-
const target = `${resolve(path, "../")}/${basename(path)}${TSCompiler.TMP_FILE_NAME}`;
|
|
21
|
-
await writeFile(target, result.code);
|
|
22
|
-
const config = await import(target);
|
|
23
|
-
await rm(target, { force: true });
|
|
24
|
-
return config;
|
|
27
|
+
private static import(filePath: string) {
|
|
28
|
+
const _module = require(filePath);
|
|
29
|
+
return _module?.__esModule ? _module : { default: _module };
|
|
25
30
|
}
|
|
26
31
|
}
|
package/externals/index.ts
CHANGED
package/installation/install.sh
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@repokit/core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.9.0",
|
|
4
4
|
"description": "A knowledgebase for your repository - wrapped in a CLI",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cli",
|
|
@@ -47,14 +47,22 @@
|
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
49
|
"@figliolia/event-emitter": "^1.2.0",
|
|
50
|
-
"@swc/core": "^1.15.18"
|
|
50
|
+
"@swc/core": "^1.15.18",
|
|
51
|
+
"ts-node": "^10.9.2"
|
|
51
52
|
},
|
|
52
53
|
"devDependencies": {
|
|
53
54
|
"@figliolia/child-process": "^1.0.4",
|
|
54
55
|
"@types/node": "^25.3.0",
|
|
55
|
-
"
|
|
56
|
+
"@typescript-eslint/eslint-plugin": "^8.57.1",
|
|
57
|
+
"@typescript-eslint/parser": "^8.57.1",
|
|
58
|
+
"eslint": "^10.0.3",
|
|
59
|
+
"eslint-import-resolver-typescript": "^4.4.4",
|
|
60
|
+
"eslint-plugin-import": "^2.32.0",
|
|
61
|
+
"eslint-plugin-simple-import-sort": "^12.1.1",
|
|
62
|
+
"eslint-plugin-unused-imports": "^4.4.1",
|
|
63
|
+
"oxfmt": "^0.41.0",
|
|
56
64
|
"oxlint": "^1.42.0",
|
|
57
|
-
"oxlint-tsgolint": "^0.
|
|
65
|
+
"oxlint-tsgolint": "^0.17.0",
|
|
58
66
|
"tsdown": "^0.21.0",
|
|
59
67
|
"tsx": "^4.21.0",
|
|
60
68
|
"typescript": "^5.9.3"
|