@repokit/core 0.0.9 → 0.1.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.
@@ -16,6 +16,7 @@ const promises_1 = require("node:fs/promises");
16
16
  const node_fs_1 = require("node:fs");
17
17
  const TaskPooler_1 = require("./TaskPooler");
18
18
  const RepoKitCommand_1 = require("./RepoKitCommand");
19
+ /* oxlint-disable typescript-eslint(no-misused-spread) */
19
20
  class CommandParser {
20
21
  static parse() {
21
22
  return __awaiter(this, void 0, void 0, function* () {
@@ -35,7 +36,7 @@ class CommandParser {
35
36
  const declaredExports = yield Promise.resolve(`${path}`).then(s => require(s));
36
37
  for (const key in declaredExports) {
37
38
  if (declaredExports[key] instanceof RepoKitCommand_1.RepoKitCommand) {
38
- commands.push(Object.assign(Object.assign({}, declaredExports[key].toJSON()), { location: path }));
39
+ commands.push(Object.assign(Object.assign({}, declaredExports[key]), { location: path }));
39
40
  }
40
41
  }
41
42
  return commands;
@@ -8,9 +8,5 @@ class RepoKitCommand {
8
8
  this.commands = commands;
9
9
  this.description = description;
10
10
  }
11
- toJSON() {
12
- const { name, owner, commands, description } = this;
13
- return { name, owner, commands, description };
14
- }
15
11
  }
16
12
  exports.RepoKitCommand = RepoKitCommand;
@@ -4,6 +4,7 @@ import { stat } from "node:fs/promises";
4
4
  import { existsSync } from "node:fs";
5
5
  import { TaskPooler } from "./TaskPooler.js";
6
6
  import { RepoKitCommand } from "./RepoKitCommand.js";
7
+ /* oxlint-disable typescript-eslint(no-misused-spread) */
7
8
  export class CommandParser {
8
9
  static async parse() {
9
10
  const { paths, root } = this.parsePaths();
@@ -20,7 +21,7 @@ export class CommandParser {
20
21
  const declaredExports = await import(path);
21
22
  for (const key in declaredExports) {
22
23
  if (declaredExports[key] instanceof RepoKitCommand) {
23
- commands.push({ ...declaredExports[key].toJSON(), location: path });
24
+ commands.push({ ...declaredExports[key], location: path });
24
25
  }
25
26
  }
26
27
  return commands;
@@ -9,8 +9,4 @@ export class RepoKitCommand {
9
9
  this.commands = commands;
10
10
  this.description = description;
11
11
  }
12
- toJSON() {
13
- const { name, owner, commands, description } = this;
14
- return { name, owner, commands, description };
15
- }
16
12
  }
@@ -5,10 +5,4 @@ export declare class RepoKitCommand {
5
5
  description: string;
6
6
  commands: Record<string, ICommand>;
7
7
  constructor({ name, description, owner, commands, }: IRepoKitCommand);
8
- toJSON(): {
9
- name: string;
10
- owner: string;
11
- commands: Record<string, ICommand>;
12
- description: string;
13
- };
14
8
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@repokit/core",
3
- "version": "0.0.9",
3
+ "version": "0.1.0",
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",
@@ -23,11 +23,12 @@
23
23
  "access": "public"
24
24
  },
25
25
  "scripts": {
26
- "build:all": "yarn build:ts && yarn lint:all && yarn install:repokit",
26
+ "build:all": "yarn build:ts && yarn lint:ts && yarn lint:rust && yarn install:repokit",
27
27
  "build:rust": "cargo build --release",
28
28
  "build:ts": "yarn ts-packager -e src",
29
29
  "install:repokit": "yarn build:rust && cargo install --path .",
30
- "lint:all": "repokit format:rust && repokit lint:ts",
30
+ "lint:rust": "cargo clippy --fix --allow-dirty",
31
+ "lint:ts": "yarn oxlint --type-aware --type-check --report-unused-disable-directives --fix && yarn oxfmt",
31
32
  "postinstall": "chmod +x ./install.sh && ./install.sh",
32
33
  "repokit": "yarn build:ts && yarn install:repokit && repokit",
33
34
  "run:dev": "cargo run --package repokit --bin repokit"
@@ -6,6 +6,7 @@ import { existsSync } from "node:fs";
6
6
  import type { ILocatedCommand } from "./types";
7
7
  import { TaskPooler } from "./TaskPooler";
8
8
  import { RepoKitCommand } from "./RepoKitCommand";
9
+ /* oxlint-disable typescript-eslint(no-misused-spread) */
9
10
 
10
11
  export class CommandParser {
11
12
  public static async parse() {
@@ -28,7 +29,7 @@ export class CommandParser {
28
29
  const declaredExports = await import(path);
29
30
  for (const key in declaredExports) {
30
31
  if (declaredExports[key] instanceof RepoKitCommand) {
31
- commands.push({ ...declaredExports[key].toJSON(), location: path });
32
+ commands.push({ ...declaredExports[key], location: path });
32
33
  }
33
34
  }
34
35
  return commands;
@@ -16,9 +16,4 @@ export class RepoKitCommand {
16
16
  this.commands = commands;
17
17
  this.description = description;
18
18
  }
19
-
20
- public toJSON() {
21
- const { name, owner, commands, description } = this;
22
- return { name, owner, commands, description };
23
- }
24
19
  }
@@ -11,26 +11,44 @@ impl InternalFileSystem {
11
11
  }
12
12
 
13
13
  pub fn commands_directory() -> PathBuf {
14
- InternalFileSystem::absolute("./src/commands")
14
+ InternalFileSystem::source_internal("commands")
15
15
  }
16
16
 
17
17
  pub fn templates_directory() -> PathBuf {
18
- InternalFileSystem::absolute("./src/templates")
18
+ InternalFileSystem::source_internal("templates")
19
19
  }
20
20
 
21
21
  pub fn resolve_command(file_name: &str) -> String {
22
- InternalFileSystem::commands_directory()
23
- .join(file_name)
24
- .into_os_string()
25
- .into_string()
26
- .expect("Cannot construct path")
22
+ InternalFileSystem::path_buf_to_str(
23
+ InternalFileSystem::commands_directory().join(file_name),
24
+ )
27
25
  }
28
26
 
29
27
  pub fn resolve_template(file_name: &str) -> String {
30
- InternalFileSystem::templates_directory()
31
- .join(file_name)
28
+ InternalFileSystem::path_buf_to_str(
29
+ InternalFileSystem::templates_directory().join(file_name),
30
+ )
31
+ }
32
+
33
+ fn source_internal(path: &str) -> PathBuf {
34
+ let src = InternalFileSystem::absolute(format!("./src/{path}").as_str());
35
+ if InternalFileSystem::is_in_node_modules(&src) {
36
+ return InternalFileSystem::absolute(format!("./dist/{path}").as_str());
37
+ }
38
+ src
39
+ }
40
+
41
+ fn path_buf_to_str(buffer: PathBuf) -> String {
42
+ buffer
32
43
  .into_os_string()
33
44
  .into_string()
34
45
  .expect("Cannot construct path")
35
46
  }
47
+
48
+ fn is_in_node_modules(path: &PathBuf) -> bool {
49
+ path.as_os_str()
50
+ .to_str()
51
+ .expect("blah")
52
+ .contains("node_modules")
53
+ }
36
54
  }