@rrlab/cli 1.1.0 → 1.2.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.
Files changed (111) hide show
  1. package/README.md +10 -10
  2. package/bin +3 -5
  3. package/dist/cli.usage.kdl +26 -25
  4. package/dist/config.d.mts +1 -1
  5. package/dist/magic-string.es-BgIV5Mu3.mjs +1011 -0
  6. package/dist/plugin/__tests__/bin-probe.test.d.mts +1 -0
  7. package/dist/plugin/__tests__/bin-probe.test.mjs +64 -0
  8. package/dist/plugin/__tests__/decide-scaffold.test.d.mts +1 -0
  9. package/dist/plugin/__tests__/decide-scaffold.test.mjs +103 -0
  10. package/dist/plugin/__tests__/define-plugin.test.d.mts +1 -0
  11. package/dist/plugin/__tests__/define-plugin.test.mjs +130 -0
  12. package/dist/plugin/__tests__/pick-preset.test.d.mts +1 -0
  13. package/dist/plugin/__tests__/pick-preset.test.mjs +72 -0
  14. package/dist/plugin/__tests__/registry.test.d.mts +1 -0
  15. package/dist/plugin/__tests__/registry.test.mjs +104 -0
  16. package/dist/plugin/bin-probe.d.mts +4 -0
  17. package/dist/plugin/bin-probe.mjs +22 -0
  18. package/dist/plugin/decide-scaffold.d.mts +18 -0
  19. package/dist/plugin/decide-scaffold.mjs +36 -0
  20. package/dist/plugin/define-plugin.d.mts +17 -0
  21. package/dist/plugin/define-plugin.mjs +25 -0
  22. package/dist/plugin/directory.d.mts +47 -0
  23. package/dist/plugin/directory.mjs +45 -0
  24. package/dist/plugin/errors.d.mts +11 -0
  25. package/dist/plugin/errors.mjs +15 -0
  26. package/dist/plugin/index.d.mts +7 -0
  27. package/dist/plugin/index.mjs +50 -0
  28. package/dist/plugin/pick-preset.d.mts +13 -0
  29. package/dist/plugin/pick-preset.mjs +17 -0
  30. package/dist/plugin/registry.d.mts +19 -0
  31. package/dist/plugin/registry.mjs +2 -0
  32. package/dist/plugin/tool-service.d.mts +45 -0
  33. package/dist/plugin/tool-service.mjs +64 -0
  34. package/dist/plugin/types.d.mts +3 -0
  35. package/dist/plugin/types.mjs +1 -0
  36. package/dist/registry-BgqfKK5L.mjs +55 -0
  37. package/dist/run.mjs +969 -585
  38. package/dist/test.DNmyFkvJ-09ScyH13.mjs +13617 -0
  39. package/dist/tool-DKL6TauZ.d.mts +43 -0
  40. package/dist/{types-snfbujDH.d.mts → types-Iu4IyWof.d.mts} +11 -75
  41. package/package.json +6 -5
  42. package/src/actions/clean.ts +36 -0
  43. package/src/actions/config.ts +46 -0
  44. package/src/actions/doctor.ts +47 -0
  45. package/src/actions/format.ts +13 -0
  46. package/src/actions/jsc.ts +13 -0
  47. package/src/actions/lint.ts +13 -0
  48. package/src/actions/pack.ts +12 -0
  49. package/src/actions/plugins/add.ts +143 -0
  50. package/src/actions/plugins/list.ts +27 -0
  51. package/src/actions/plugins/remove.ts +110 -0
  52. package/src/actions/plugins/shared.ts +58 -0
  53. package/src/actions/run-tool.ts +23 -0
  54. package/src/actions/tsc.ts +65 -0
  55. package/src/errors/invalid-plugin-module.ts +6 -0
  56. package/src/errors/missing-plugin.ts +17 -0
  57. package/src/errors/plugin-api-version.ts +6 -0
  58. package/src/errors/unknown-plugin.ts +7 -0
  59. package/src/lib/plugin/define-plugin.ts +56 -0
  60. package/src/lib/plugin/directory.ts +30 -0
  61. package/src/lib/plugin/errors.ts +15 -0
  62. package/src/lib/{plugin.ts → plugin/index.ts} +8 -9
  63. package/src/lib/plugin/registry.ts +82 -0
  64. package/src/{plugin → lib/plugin}/tool-service.ts +10 -14
  65. package/src/{plugin → lib/plugin}/types.ts +10 -33
  66. package/src/program/base.ts +75 -0
  67. package/src/program/commands/check.ts +31 -62
  68. package/src/program/commands/clean.ts +12 -43
  69. package/src/program/commands/completion.ts +6 -4
  70. package/src/program/commands/config.ts +6 -11
  71. package/src/program/commands/doctor.ts +5 -54
  72. package/src/program/commands/format.ts +18 -25
  73. package/src/program/commands/jscheck.ts +18 -31
  74. package/src/program/commands/lint.ts +18 -26
  75. package/src/program/commands/pack.ts +18 -22
  76. package/src/program/commands/plugins.ts +17 -364
  77. package/src/program/commands/tscheck.ts +19 -77
  78. package/src/program/index.ts +20 -27
  79. package/src/program/root.ts +62 -0
  80. package/src/render/banner.ts +25 -0
  81. package/src/render/board.ts +41 -0
  82. package/src/render/footer.ts +31 -0
  83. package/src/render/labels.ts +28 -0
  84. package/src/render/lines.ts +100 -0
  85. package/src/render/plugin-view.ts +68 -0
  86. package/src/render/steps.ts +20 -0
  87. package/src/run.ts +2 -8
  88. package/src/services/config.ts +4 -0
  89. package/src/services/context.ts +84 -0
  90. package/src/services/file-ops.ts +79 -0
  91. package/src/services/json-edit.ts +1 -1
  92. package/src/services/plugin-meta.ts +63 -0
  93. package/src/services/plugin-services.ts +41 -0
  94. package/src/services/prompts.ts +1 -1
  95. package/src/services/static-checker.ts +46 -0
  96. package/src/types/config.ts +2 -1
  97. package/src/types/tool.ts +13 -26
  98. package/src/ui/theme.ts +5 -0
  99. package/dist/plugin.d.mts +0 -87
  100. package/dist/plugin.mjs +0 -214
  101. package/src/plugin/define-plugin.ts +0 -54
  102. package/src/plugin/registry.ts +0 -48
  103. package/src/program/board.ts +0 -86
  104. package/src/program/composed-jsc.ts +0 -43
  105. package/src/program/missing-plugin.ts +0 -18
  106. package/src/program/ui.ts +0 -59
  107. package/src/services/ctx.ts +0 -71
  108. package/src/services/plugins-registry.ts +0 -22
  109. /package/src/{plugin → lib/plugin}/bin-probe.ts +0 -0
  110. /package/src/{plugin → lib/plugin}/decide-scaffold.ts +0 -0
  111. /package/src/{plugin → lib/plugin}/pick-preset.ts +0 -0
@@ -1,71 +0,0 @@
1
- import fs from "node:fs";
2
- import { createPkg, createShellService, cwd, type Pkg, type ShellService } from "@vlandoss/clibuddy";
3
- import { PluginRegistry } from "#src/plugin/registry.ts";
4
- import type { PluginContext } from "#src/plugin/types.ts";
5
- import type { ExportedConfig } from "#src/types/config.ts";
6
- import { ConfigService } from "./config.ts";
7
- import { logger } from "./logger.ts";
8
-
9
- export type Context = {
10
- binPkg: Pkg;
11
- appPkg: Pkg;
12
- shell: ShellService;
13
- config: ExportedConfig;
14
- registry: PluginRegistry;
15
- };
16
-
17
- export async function createContext(binDir: string): Promise<Context> {
18
- const debug = logger.subdebug("create-context");
19
-
20
- const binPath = fs.realpathSync(binDir);
21
-
22
- debug("bin path:", binPath);
23
- debug("process cwd:", process.cwd());
24
-
25
- const [appPkg, binPkg] = await Promise.all([createPkg(cwd), createPkg(binPath)]);
26
-
27
- if (!binPkg) {
28
- throw new Error("Could not find bin package.json");
29
- }
30
-
31
- if (!appPkg) {
32
- throw new Error("Could not find app package.json");
33
- }
34
-
35
- debug("app pkg info: %O", appPkg.info());
36
- debug("bin pkg info: %O", binPkg.info());
37
-
38
- const shell = createShellService();
39
-
40
- debug("shell service options: %O", shell.options);
41
-
42
- const configService = new ConfigService();
43
- const config = await configService.load();
44
-
45
- const registry = new PluginRegistry();
46
- const pluginContext: PluginContext = {
47
- shell,
48
- logger,
49
- appPkg,
50
- binPkg,
51
- cwd,
52
- };
53
-
54
- for (const plugin of config.config.plugins ?? []) {
55
- const got = plugin.apiVersion as number;
56
- if (got !== 1) {
57
- throw new Error(`Plugin '${plugin.name}' targets apiVersion ${got}, but this kernel supports only apiVersion 1.`);
58
- }
59
- debug("registering plugin: %s", plugin.name);
60
- const capabilities = await plugin.capabilities(pluginContext);
61
- registry.register(plugin, capabilities);
62
- }
63
-
64
- return {
65
- appPkg,
66
- binPkg,
67
- shell,
68
- config,
69
- registry,
70
- };
71
- }
@@ -1,22 +0,0 @@
1
- /**
2
- * Map from short aliases the user types (`rr plugins add ts`) to the
3
- * full npm package name and the canonical local binding the plugin file
4
- * is imported as inside `run-run.config.{ts,mts}`.
5
- *
6
- * Third-party plugins use their full package name; the binding is derived
7
- * by stripping a `@scope/<tool>-plugin` (or `@scope/<tool>-run-run-plugin`)
8
- * suffix and using the tool segment.
9
- */
10
- export const OFFICIAL_PLUGINS = {
11
- ts: { pkg: "@rrlab/ts-plugin", exportName: "ts" },
12
- eslint: { pkg: "@rrlab/eslint-plugin", exportName: "eslint" },
13
- biome: { pkg: "@rrlab/biome-plugin", exportName: "biome" },
14
- oxc: { pkg: "@rrlab/oxc-plugin", exportName: "oxc" },
15
- tsdown: { pkg: "@rrlab/tsdown-plugin", exportName: "tsdown" },
16
- } as const;
17
-
18
- export type OfficialAlias = keyof typeof OFFICIAL_PLUGINS;
19
-
20
- export function officialAliases(): readonly OfficialAlias[] {
21
- return Object.keys(OFFICIAL_PLUGINS) as OfficialAlias[];
22
- }
File without changes
File without changes
File without changes