@rrlab/biome-plugin 0.1.1 → 0.1.2-git-2238423.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
@@ -5,7 +5,6 @@ import { ShellService } from "@vlandoss/clibuddy";
5
5
  declare const TOOL_VERSIONS: {
6
6
  readonly "@biomejs/biome": {
7
7
  readonly install: "^2.0.0";
8
- readonly peer: ">=2.0.0";
9
8
  };
10
9
  };
11
10
  //#endregion
@@ -18,6 +17,8 @@ declare class BiomeService extends ToolService implements Formatter, Linter, Sta
18
17
  }
19
18
  declare function install(ctx: InstallContext): Promise<InstallResult>;
20
19
  declare function uninstall(ctx: UninstallContext): Promise<UninstallResult>;
21
- declare const biome: (options: void) => import("@rrlab/cli/plugin").Plugin;
20
+ declare const biome: (options?: {
21
+ only?: readonly ("lint" | "format" | "jsc")[] | undefined;
22
+ } | undefined) => import("@rrlab/cli/plugin").Plugin;
22
23
  //#endregion
23
24
  export { BiomeService, TOOL_VERSIONS, biome as default, install, uninstall };
package/dist/index.mjs CHANGED
@@ -1,13 +1,10 @@
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
7
- const TOOL_VERSIONS = { "@biomejs/biome": {
8
- install: "^2.0.0",
9
- peer: ">=2.0.0"
10
- } };
7
+ const TOOL_VERSIONS = { "@biomejs/biome": { install: "^2.0.0" } };
11
8
  //#endregion
12
9
  //#region src/index.ts
13
10
  const FROM = import.meta.url;
@@ -56,7 +53,11 @@ var BiomeService = class extends ToolService {
56
53
  }
57
54
  };
58
55
  async function install(ctx) {
59
- const scaffoldDecision = await decideScaffoldAction(ctx, await pathExists(path.join(ctx.appPkg.dirPath, BIOME_JSON)));
56
+ const scaffoldDecision = await decideScaffold(ctx, {
57
+ label: BIOME_JSON,
58
+ fileExists: await pathExists(path.join(ctx.appPkg.dirPath, BIOME_JSON)),
59
+ patchHint: `add ${BIOME_CONFIG_PKG} to extends, keep my other settings`
60
+ });
60
61
  if (scaffoldDecision === "skip") return { devDependencies: { "@biomejs/biome": TOOL_VERSIONS["@biomejs/biome"].install } };
61
62
  return {
62
63
  devDependencies: {
@@ -127,38 +128,6 @@ async function uninstall(ctx) {
127
128
  files
128
129
  };
129
130
  }
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
131
  async function pathExists(p) {
163
132
  try {
164
133
  await fs.access(p);
@@ -172,13 +141,8 @@ const biome = definePlugin(() => ({
172
141
  apiVersion: 1,
173
142
  install,
174
143
  uninstall,
175
- async setup({ shell }) {
144
+ capabilities: ({ shell }) => {
176
145
  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
146
  return {
183
147
  lint: svc,
184
148
  format: svc,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rrlab/biome-plugin",
3
- "version": "0.1.1",
3
+ "version": "0.1.2-git-2238423.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,13 @@
38
38
  },
39
39
  "peerDependencies": {
40
40
  "@biomejs/biome": ">=2.0.0",
41
- "@rrlab/cli": "0.0.3"
41
+ "@rrlab/cli": "0.0.4-git-2238423.0"
42
42
  },
43
43
  "devDependencies": {
44
- "@biomejs/biome": "2.4.4",
45
- "@rrlab/cli": "0.0.3",
44
+ "@biomejs/biome": "2.4.15",
45
+ "@types/semver": "^7.7.1",
46
+ "semver": "^7.8.1",
47
+ "@rrlab/cli": "0.0.4-git-2238423.0",
46
48
  "@rrlab/tsdown-config": "^0.1.0"
47
49
  },
48
50
  "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
 
@@ -1,3 +1,3 @@
1
1
  export const TOOL_VERSIONS = {
2
- "@biomejs/biome": { install: "^2.0.0", peer: ">=2.0.0" },
2
+ "@biomejs/biome": { install: "^2.0.0" },
3
3
  } as const;