@rrlab/biome-plugin 0.1.1-git-85e8cd0.0 → 0.1.2-git-c5c6e0f.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/index.d.mts CHANGED
@@ -18,6 +18,8 @@ declare class BiomeService extends ToolService implements Formatter, Linter, Sta
18
18
  }
19
19
  declare function install(ctx: InstallContext): Promise<InstallResult>;
20
20
  declare function uninstall(ctx: UninstallContext): Promise<UninstallResult>;
21
- declare const biome: (options: void) => import("@rrlab/cli/plugin").Plugin;
21
+ declare const biome: (options?: {
22
+ only?: readonly ("lint" | "format" | "jsc")[] | undefined;
23
+ } | undefined) => import("@rrlab/cli/plugin").Plugin;
22
24
  //#endregion
23
25
  export { BiomeService, TOOL_VERSIONS, biome as default, install, uninstall };
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import fs from "node:fs/promises";
2
2
  import path from "node:path";
3
- import { ToolService, definePlugin } from "@rrlab/cli/plugin";
3
+ import { ToolService, decideScaffold, definePlugin } from "@rrlab/cli/plugin";
4
4
  import { colorize, isCI } from "@vlandoss/clibuddy";
5
5
  import { parse } from "comment-json";
6
6
  //#region src/tool-versions.ts
@@ -56,7 +56,11 @@ var BiomeService = class extends ToolService {
56
56
  }
57
57
  };
58
58
  async function install(ctx) {
59
- const scaffoldDecision = await decideScaffoldAction(ctx, await pathExists(path.join(ctx.appPkg.dirPath, BIOME_JSON)));
59
+ const scaffoldDecision = await decideScaffold(ctx, {
60
+ label: BIOME_JSON,
61
+ fileExists: await pathExists(path.join(ctx.appPkg.dirPath, BIOME_JSON)),
62
+ patchHint: `add ${BIOME_CONFIG_PKG} to extends, keep my other settings`
63
+ });
60
64
  if (scaffoldDecision === "skip") return { devDependencies: { "@biomejs/biome": TOOL_VERSIONS["@biomejs/biome"].install } };
61
65
  return {
62
66
  devDependencies: {
@@ -127,38 +131,6 @@ async function uninstall(ctx) {
127
131
  files
128
132
  };
129
133
  }
130
- async function decideScaffoldAction(ctx, fileExists) {
131
- if (!fileExists) {
132
- if (ctx.flags.yes || ctx.flags.nonInteractive) return "create";
133
- const choice = await ctx.prompts.confirm({
134
- message: `Scaffold ${BIOME_JSON} with the @rrlab/biome-config preset?`,
135
- initialValue: true
136
- });
137
- if (ctx.prompts.isCancel(choice)) throw new Error("Cancelled by user.");
138
- return choice ? "create" : "skip";
139
- }
140
- if (ctx.flags.yes || ctx.flags.nonInteractive) return "patch";
141
- const choice = await ctx.prompts.select({
142
- message: `${BIOME_JSON} already exists. What do you want to do?`,
143
- options: [
144
- {
145
- value: "patch",
146
- label: "Patch — add @rrlab/biome-config to extends, keep my other settings"
147
- },
148
- {
149
- value: "skip",
150
- label: "Skip — leave it alone"
151
- },
152
- {
153
- value: "overwrite",
154
- label: "Overwrite — replace with a fresh scaffold"
155
- }
156
- ],
157
- initialValue: "patch"
158
- });
159
- if (ctx.prompts.isCancel(choice)) throw new Error("Cancelled by user.");
160
- return choice;
161
- }
162
134
  async function pathExists(p) {
163
135
  try {
164
136
  await fs.access(p);
@@ -172,13 +144,8 @@ const biome = definePlugin(() => ({
172
144
  apiVersion: 1,
173
145
  install,
174
146
  uninstall,
175
- async setup({ shell }) {
147
+ capabilities: ({ shell }) => {
176
148
  const svc = new BiomeService(shell);
177
- try {
178
- await svc.getBinDir();
179
- } catch (_err) {
180
- throw new Error("@rrlab/biome-plugin requires @biomejs/biome to be installed in the host project. Run: rr plugins add biome (or: pnpm add -D @biomejs/biome)");
181
- }
182
149
  return {
183
150
  lint: svc,
184
151
  format: svc,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rrlab/biome-plugin",
3
- "version": "0.1.1-git-85e8cd0.0",
3
+ "version": "0.1.2-git-c5c6e0f.0",
4
4
  "description": "Biome plugin for @rrlab/cli — provides lint, format, and jsc capabilities.",
5
5
  "homepage": "https://github.com/variableland/dx/tree/main/run-run/biome-plugin#readme",
6
6
  "bugs": {
@@ -38,11 +38,11 @@
38
38
  },
39
39
  "peerDependencies": {
40
40
  "@biomejs/biome": ">=2.0.0",
41
- "@rrlab/cli": "0.0.3-git-85e8cd0.0"
41
+ "@rrlab/cli": "0.0.4-git-c5c6e0f.0"
42
42
  },
43
43
  "devDependencies": {
44
44
  "@biomejs/biome": "2.4.4",
45
- "@rrlab/cli": "0.0.3-git-85e8cd0.0",
45
+ "@rrlab/cli": "0.0.4-git-c5c6e0f.0",
46
46
  "@rrlab/tsdown-config": "^0.1.0"
47
47
  },
48
48
  "scripts": {
package/src/index.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import fs from "node:fs/promises";
2
2
  import path from "node:path";
3
3
  import {
4
+ decideScaffold,
4
5
  definePlugin,
5
6
  type FileOp,
6
7
  type FormatOptions,
@@ -59,7 +60,11 @@ export class BiomeService extends ToolService implements Formatter, Linter, Stat
59
60
  export async function install(ctx: InstallContext): Promise<InstallResult> {
60
61
  const biomeJsonPath = path.join(ctx.appPkg.dirPath, BIOME_JSON);
61
62
  const fileExists = await pathExists(biomeJsonPath);
62
- const scaffoldDecision = await decideScaffoldAction(ctx, fileExists);
63
+ const scaffoldDecision = await decideScaffold(ctx, {
64
+ label: BIOME_JSON,
65
+ fileExists,
66
+ patchHint: `add ${BIOME_CONFIG_PKG} to extends, keep my other settings`,
67
+ });
63
68
 
64
69
  if (scaffoldDecision === "skip") {
65
70
  return { devDependencies: { "@biomejs/biome": TOOL_VERSIONS["@biomejs/biome"].install } };
@@ -126,37 +131,6 @@ export async function uninstall(ctx: UninstallContext): Promise<UninstallResult>
126
131
  return { removeDependencies, files };
127
132
  }
128
133
 
129
- type ExistingFileAction = "skip" | "patch" | "overwrite";
130
-
131
- async function decideScaffoldAction(
132
- ctx: InstallContext,
133
- fileExists: boolean,
134
- ): Promise<"create" | "patch" | "overwrite" | "skip"> {
135
- if (!fileExists) {
136
- if (ctx.flags.yes || ctx.flags.nonInteractive) return "create";
137
- const choice = await ctx.prompts.confirm({
138
- message: `Scaffold ${BIOME_JSON} with the @rrlab/biome-config preset?`,
139
- initialValue: true,
140
- });
141
- if (ctx.prompts.isCancel(choice)) throw new Error("Cancelled by user.");
142
- return choice ? "create" : "skip";
143
- }
144
-
145
- if (ctx.flags.yes || ctx.flags.nonInteractive) return "patch";
146
-
147
- const choice = await ctx.prompts.select<ExistingFileAction>({
148
- message: `${BIOME_JSON} already exists. What do you want to do?`,
149
- options: [
150
- { value: "patch", label: "Patch — add @rrlab/biome-config to extends, keep my other settings" },
151
- { value: "skip", label: "Skip — leave it alone" },
152
- { value: "overwrite", label: "Overwrite — replace with a fresh scaffold" },
153
- ],
154
- initialValue: "patch",
155
- });
156
- if (ctx.prompts.isCancel(choice)) throw new Error("Cancelled by user.");
157
- return choice;
158
- }
159
-
160
134
  async function pathExists(p: string): Promise<boolean> {
161
135
  try {
162
136
  await fs.access(p);
@@ -166,26 +140,14 @@ async function pathExists(p: string): Promise<boolean> {
166
140
  }
167
141
  }
168
142
 
169
- const biome = definePlugin<void>(() => ({
143
+ const biome = definePlugin(() => ({
170
144
  name: "biome",
171
145
  apiVersion: 1,
172
146
  install,
173
147
  uninstall,
174
- async setup({ shell }) {
148
+ capabilities: ({ shell }) => {
175
149
  const svc = new BiomeService(shell);
176
- try {
177
- await svc.getBinDir();
178
- } catch (_err) {
179
- throw new Error(
180
- "@rrlab/biome-plugin requires @biomejs/biome to be installed in the host project. " +
181
- "Run: rr plugins add biome (or: pnpm add -D @biomejs/biome)",
182
- );
183
- }
184
- return {
185
- lint: svc,
186
- format: svc,
187
- jsc: svc,
188
- };
150
+ return { lint: svc, format: svc, jsc: svc };
189
151
  },
190
152
  }));
191
153