@repokit/core 1.6.1 → 1.7.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.
@@ -2,6 +2,7 @@ import { TSCompiler } from "./TSCompiler.mjs";
2
2
  import { RepoKitCommand } from "./RepoKitCommand.mjs";
3
3
  import { ConcurrencyPool } from "./ConcurrencyPool.mjs";
4
4
  import { parseArgs } from "node:util";
5
+ import { join } from "node:path";
5
6
  import { stat } from "node:fs/promises";
6
7
  import { existsSync } from "node:fs";
7
8
 
@@ -14,12 +15,12 @@ var CommandParser = class {
14
15
  this.compiler = new TSCompiler(root, "parse_commands");
15
16
  const pool = new ConcurrencyPool();
16
17
  const pathList = paths.split(",").filter(Boolean);
17
- const commands = await Promise.all(pathList.map((path) => pool.enqueue(() => this.parseCommand(path))));
18
+ const commands = await Promise.all(pathList.map((path) => pool.enqueue(() => this.parseCommand(root, path))));
18
19
  console.log(JSON.stringify(commands.flat()));
19
20
  }
20
- static async parseCommand(path) {
21
+ static async parseCommand(root, path) {
21
22
  const commands = [];
22
- const declaredExports = await this.compiler?.compile?.(path);
23
+ const declaredExports = await this.compiler?.compile?.(join(root, path));
23
24
  for (const key in declaredExports) if (declaredExports[key] instanceof RepoKitCommand) commands.push({
24
25
  ...declaredExports[key],
25
26
  location: path
@@ -1,8 +1,8 @@
1
1
  import { TSCompiler } from "./TSCompiler.mjs";
2
2
  import { RepoKitConfig } from "./RepoKitConfig.mjs";
3
3
  import { parseArgs } from "node:util";
4
- import { existsSync } from "node:fs";
5
4
  import { join } from "node:path";
5
+ import { existsSync } from "node:fs";
6
6
 
7
7
  //#region externals/ConfigurationParser.ts
8
8
  var ConfigurationParser = class extends TSCompiler {
@@ -1,5 +1,5 @@
1
- import { readFile, rm, writeFile } from "node:fs/promises";
2
1
  import { basename, resolve } from "node:path";
2
+ import { readFile, rm, writeFile } from "node:fs/promises";
3
3
  import { transform } from "@swc/core";
4
4
 
5
5
  //#region externals/TSCompiler.ts
@@ -1,5 +1,5 @@
1
1
  //#region externals/templates/command_template.txt
2
- var command_template_default = "import { RepoKitCommand } from \"@repokit/core\";\n\n/**\n * Please fill out this command file with your desired settings\n */\nexport const Commands = new RepoKitCommand({\n name: \"<Your Package Name>\",\n owner: \"<Optional Team or Individual>\",\n description: \"<Your Package Description>\",\n commands: {\n \"<your-first-command>\": {\n command: \"<insert shell command here>\",\n description: \"A description for using your command\",\n },\n \"<your-second-command>\": {\n command: \"<insert shell command here>\",\n description: \"A description for using your command\",\n },\n \"<your-third-command>\": {\n command: \"<insert shell command here>\",\n description: \"A description for using your command\",\n },\n },\n});\n";
2
+ var command_template_default = "import { RepoKitCommand } from \"@repokit/core\";\n\n/**\n * Please fill out this command file with your desired settings\n */\nexport const Commands = new RepoKitCommand({\n name: \"<Your Package Name>\",\n owner: \"<Optional Team or Individual>\",\n description: \"<Your Package Description>\",\n commands: {\n \"<your-first-command>\": {\n command: \"<insert shell command here>\",\n description: \"A description for your command\",\n },\n \"<your-second-command>\": {\n command: \"<insert shell command here>\",\n description: \"A description for your command\",\n },\n \"<your-third-command>\": {\n command: \"<insert shell command here>\",\n description: \"A description for your command\",\n },\n },\n});\n";
3
3
 
4
4
  //#endregion
5
5
  export { command_template_default as default };
@@ -1,5 +1,5 @@
1
1
  //#region externals/templates/configuration_template.txt
2
- var configuration_template_default = "import { RepoKitConfig } from \"@repokit/core\";\n\n/**\n * Please fill out this config file with your desired\n * repokit settings\n */\nexport const RepoKit = new RepoKitConfig({\n project: \"Your Project Name\",\n commands: {\n \"<your-first-command>\": {\n command: \"<insert shell command here>\",\n description: \"A description for using your command\",\n },\n \"<your-second-command>\": {\n command: \"<insert shell command here>\",\n description: \"A description for using your command\",\n },\n \"<your-third-command>\": {\n command: \"<insert shell command here>\",\n description: \"A description for using your command\",\n },\n },\n});\n";
2
+ var configuration_template_default = "import { RepoKitConfig } from \"@repokit/core\";\n\n/**\n * Please fill out this config file with your desired\n * repokit settings\n */\nexport const RepoKit = new RepoKitConfig({\n project: \"Your Project Name\",\n commands: {\n \"<your-first-command>\": {\n command: \"<insert shell command here>\",\n description: \"A description for your command\",\n },\n \"<your-second-command>\": {\n command: \"<insert shell command here>\",\n description: \"A description for your command\",\n },\n \"<your-third-command>\": {\n command: \"<insert shell command here>\",\n description: \"A description for your command\",\n },\n },\n});\n";
3
3
 
4
4
  //#endregion
5
5
  export { configuration_template_default as default };
@@ -1,4 +1,5 @@
1
1
  import { parseArgs } from "node:util";
2
+ import { join } from "node:path";
2
3
  import { stat } from "node:fs/promises";
3
4
  import { existsSync } from "node:fs";
4
5
 
@@ -20,14 +21,14 @@ export class CommandParser {
20
21
  const pool = new ConcurrencyPool<ILocatedCommand[]>();
21
22
  const pathList = paths.split(",").filter(Boolean);
22
23
  const commands = await Promise.all(
23
- pathList.map(path => pool.enqueue(() => this.parseCommand(path))),
24
+ pathList.map(path => pool.enqueue(() => this.parseCommand(root, path))),
24
25
  );
25
26
  console.log(JSON.stringify(commands.flat()));
26
27
  }
27
28
 
28
- private static async parseCommand(path: string) {
29
+ private static async parseCommand(root: string, path: string) {
29
30
  const commands: ILocatedCommand[] = [];
30
- const declaredExports = await this.compiler?.compile?.(path);
31
+ const declaredExports = await this.compiler?.compile?.(join(root, path));
31
32
  for (const key in declaredExports) {
32
33
  if (declaredExports[key] instanceof RepoKitCommand) {
33
34
  commands.push({ ...declaredExports[key], location: path });
@@ -10,15 +10,15 @@ export const Commands = new RepoKitCommand({
10
10
  commands: {
11
11
  "<your-first-command>": {
12
12
  command: "<insert shell command here>",
13
- description: "A description for using your command",
13
+ description: "A description for your command",
14
14
  },
15
15
  "<your-second-command>": {
16
16
  command: "<insert shell command here>",
17
- description: "A description for using your command",
17
+ description: "A description for your command",
18
18
  },
19
19
  "<your-third-command>": {
20
20
  command: "<insert shell command here>",
21
- description: "A description for using your command",
21
+ description: "A description for your command",
22
22
  },
23
23
  },
24
24
  });
@@ -9,15 +9,15 @@ export const RepoKit = new RepoKitConfig({
9
9
  commands: {
10
10
  "<your-first-command>": {
11
11
  command: "<insert shell command here>",
12
- description: "A description for using your command",
12
+ description: "A description for your command",
13
13
  },
14
14
  "<your-second-command>": {
15
15
  command: "<insert shell command here>",
16
- description: "A description for using your command",
16
+ description: "A description for your command",
17
17
  },
18
18
  "<your-third-command>": {
19
19
  command: "<insert shell command here>",
20
- description: "A description for using your command",
20
+ description: "A description for your command",
21
21
  },
22
22
  },
23
23
  });
@@ -38,7 +38,16 @@ impl TypescriptCommand {
38
38
  self.execute(format!("{executable} --paths {paths} --root {}", self.root).as_str());
39
39
  let result: Result<Vec<RepoKitCommand>, serde_json::Error> = serde_json::from_str(&stdout);
40
40
  match result {
41
- Ok(commands) => commands,
41
+ Ok(mut commands) => {
42
+ for command in commands.iter_mut() {
43
+ let relative_location = &command.location;
44
+ command.location = Path::join(Path::new(&self.root), relative_location)
45
+ .to_str()
46
+ .expect("str")
47
+ .to_string()
48
+ }
49
+ commands
50
+ }
42
51
  Err(_) => {
43
52
  Logger::info("There was an error parsing one of your commands");
44
53
  Logger::info(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@repokit/core",
3
- "version": "1.6.1",
3
+ "version": "1.7.0",
4
4
  "description": "A knowledgebase for your repository - wrapped in a CLI",
5
5
  "keywords": [
6
6
  "cli",