From 7c10237694f369607c7534ee95d858b669d45e7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CKenzo-Wada=E2=80=9D?= Date: Tue, 12 Mar 2024 01:52:59 +0900 Subject: [PATCH 1/5] feat: add biome --- boilerplates/biome/files/$package.json.ts | 20 ++++ boilerplates/biome/files/biome.json | 18 ++++ boilerplates/biome/package.json | 30 ++++++ boilerplates/biome/tsconfig.json | 5 + packages/core/src/utils/package.ts | 5 +- packages/tests/tests/FRAMEWORK+biome.spec.ts | 11 ++ pnpm-lock.yaml | 104 +++++++++++++++++++ 7 files changed, 192 insertions(+), 1 deletion(-) create mode 100644 boilerplates/biome/files/$package.json.ts create mode 100644 boilerplates/biome/files/biome.json create mode 100644 boilerplates/biome/package.json create mode 100644 boilerplates/biome/tsconfig.json create mode 100644 packages/tests/tests/FRAMEWORK+biome.spec.ts diff --git a/boilerplates/biome/files/$package.json.ts b/boilerplates/biome/files/$package.json.ts new file mode 100644 index 000000000..b5f24bdca --- /dev/null +++ b/boilerplates/biome/files/$package.json.ts @@ -0,0 +1,20 @@ +import { addDependency, loadAsJson, setScripts, type TransformerProps } from "@batijs/core"; + +export default async function getPackageJson(props: TransformerProps) { + const packageJson = await loadAsJson(props); + + setScripts(packageJson, { + lint: { + value: "biome lint --apply ./", + precedence: 0 + }, + format: { + value: "biome format --write ./", + precedence: 0 + } + }); + + return addDependency(packageJson, await import("../package.json", { assert: { type: "json" } }), { + devDependencies: ["@biomejs/biome"], + }); +} diff --git a/boilerplates/biome/files/biome.json b/boilerplates/biome/files/biome.json new file mode 100644 index 000000000..3393a5548 --- /dev/null +++ b/boilerplates/biome/files/biome.json @@ -0,0 +1,18 @@ +{ + "$schema": "https://biomejs.dev/schemas/1.6.0/schema.json", + "organizeImports": { + "enabled": false + }, + "linter": { + "enabled": true, + "rules": { + "recommended": true + } + }, + "files": { + "ignore": [ + "./dist/**", + "./node_modules/**" + ] + } +} diff --git a/boilerplates/biome/package.json b/boilerplates/biome/package.json new file mode 100644 index 000000000..1fe5650b3 --- /dev/null +++ b/boilerplates/biome/package.json @@ -0,0 +1,30 @@ +{ + "name": "@batijs/biome", + "private": true, + "version": "0.0.1", + "description": "", + "type": "module", + "scripts": { + "check-types": "tsc --noEmit", + "build": "bati-compile-boilerplate" + }, + "keywords": [], + "author": "", + "license": "MIT", + "devDependencies": { + "@batijs/compile": "workspace:*", + "@biomejs/biome": "^1.6.0", + "@types/node": "^18.19.14" + }, + "dependencies": { + "@batijs/core": "workspace:*" + }, + "files": [ + "dist/" + ], + "bati": { + "if": { + "flag": "biome" + } + } +} diff --git a/boilerplates/biome/tsconfig.json b/boilerplates/biome/tsconfig.json new file mode 100644 index 000000000..8f625f855 --- /dev/null +++ b/boilerplates/biome/tsconfig.json @@ -0,0 +1,5 @@ +{ + "extends": [ + "../tsconfig.base.json" + ] +} \ No newline at end of file diff --git a/packages/core/src/utils/package.ts b/packages/core/src/utils/package.ts index 8c1d63a35..b69f44478 100644 --- a/packages/core/src/utils/package.ts +++ b/packages/core/src/utils/package.ts @@ -12,6 +12,7 @@ export interface PackageJsonScripts { build?: string; preview?: string; lint?: string; + format?: string; }; } @@ -26,6 +27,7 @@ export interface PackageJsonScriptOptions { build?: PackageJsonScriptOption; preview?: PackageJsonScriptOption; lint?: PackageJsonScriptOption; + format?: PackageJsonScriptOption; } function* deps(obj: PackageJsonDeps) { @@ -82,6 +84,7 @@ const previousScripts: Required = { build: { precedence: -Infinity }, preview: { precedence: -Infinity }, lint: { precedence: -Infinity }, + format: { precedence: -Infinity }, }; function warnScript(key: string, old: string, nnew: string) { @@ -98,7 +101,7 @@ function warnScript(key: string, old: string, nnew: string) { } export function setScripts(packageJson: T, scripts: PackageJsonScriptOptions) { - const keys = ["dev", "build", "preview", "lint"] as const; + const keys = ["dev", "build", "preview", "lint", "format"] as const; for (const key of keys) { const prev = previousScripts[key]!; diff --git a/packages/tests/tests/FRAMEWORK+biome.spec.ts b/packages/tests/tests/FRAMEWORK+biome.spec.ts new file mode 100644 index 000000000..47f06aa6e --- /dev/null +++ b/packages/tests/tests/FRAMEWORK+biome.spec.ts @@ -0,0 +1,11 @@ +import { describeBati } from "@batijs/tests-utils"; + +export const matrix = [["solid", "react", "vue"], "biome"]; + +await describeBati(({ test, expect, fetch }) => { + test("home", async () => { + const res = await fetch("/"); + expect(res.status).toBe(200); + expect(await res.text()).not.toContain('{"is404":true}'); + }); +}); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a4e9766ea..3cf4a2e96 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -48,6 +48,22 @@ importers: specifier: ^5.3.3 version: 5.3.3 + boilerplates/biome: + dependencies: + '@batijs/core': + specifier: workspace:* + version: link:../../packages/core + devDependencies: + '@batijs/compile': + specifier: workspace:* + version: link:../../packages/compile + '@biomejs/biome': + specifier: ^1.6.0 + version: 1.6.0 + '@types/node': + specifier: ^18.19.14 + version: 18.19.14 + boilerplates/compiled: dependencies: '@batijs/core': @@ -1619,6 +1635,94 @@ packages: to-fast-properties: 2.0.0 dev: true + /@biomejs/biome@1.6.0: + resolution: {integrity: sha512-hvP8K1+CV8qc9eNdXtPwzScVxFSHB448CPKSqX6+8IW8G7bbhBVKGC80BowExJN5+vu+kzsj4xkWa780MAOlJw==} + engines: {node: '>=14.*'} + hasBin: true + requiresBuild: true + optionalDependencies: + '@biomejs/cli-darwin-arm64': 1.6.0 + '@biomejs/cli-darwin-x64': 1.6.0 + '@biomejs/cli-linux-arm64': 1.6.0 + '@biomejs/cli-linux-arm64-musl': 1.6.0 + '@biomejs/cli-linux-x64': 1.6.0 + '@biomejs/cli-linux-x64-musl': 1.6.0 + '@biomejs/cli-win32-arm64': 1.6.0 + '@biomejs/cli-win32-x64': 1.6.0 + dev: true + + /@biomejs/cli-darwin-arm64@1.6.0: + resolution: {integrity: sha512-K1Fjqye5pt+Ua+seC7V/2bFjfnqOaEOcQbBQSiiefB/VPNOb6lA5NFIfJ1PskTA3JrMXE1k7iqKQn56qrKFS6A==} + engines: {node: '>=14.*'} + cpu: [arm64] + os: [darwin] + requiresBuild: true + dev: true + optional: true + + /@biomejs/cli-darwin-x64@1.6.0: + resolution: {integrity: sha512-CjEALu6vN9RbcfhaBDoj481mesUIsUjxgQn+/kiMCea+Paypqslhez1I7OwRBJnkzz+Pa+PXdABd7S30eyy6+Q==} + engines: {node: '>=14.*'} + cpu: [x64] + os: [darwin] + requiresBuild: true + dev: true + optional: true + + /@biomejs/cli-linux-arm64-musl@1.6.0: + resolution: {integrity: sha512-prww6AUuJ+IO/GziN3WjtGM/DNOVuPFxqWrK97wKTZygEDdA+o1qHUN2HeCkSyk084xnzbMSbls5xscAKAn43A==} + engines: {node: '>=14.*'} + cpu: [arm64] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /@biomejs/cli-linux-arm64@1.6.0: + resolution: {integrity: sha512-32LVrC7dAgQT39YZ0ieO/VzzpAflozs9mW5K0oKNef7S4ocCdk89E98eXApxOdei0JTf3vfseDCl1AUIp6MwJw==} + engines: {node: '>=14.*'} + cpu: [arm64] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /@biomejs/cli-linux-x64-musl@1.6.0: + resolution: {integrity: sha512-NwitWeUKCy8G/rr+rgHPYirnrsOjJEJBWODdaRzweeFNcJjvO6de6AmNdSJzsewzLEaxjOWyoXU03MdzbGz/6Q==} + engines: {node: '>=14.*'} + cpu: [x64] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /@biomejs/cli-linux-x64@1.6.0: + resolution: {integrity: sha512-b6mWu9Cu4w5B3K46wq9SlxKEZEEL6II/6HFNAuZ4YL8mOeQ0FTMU+wNMJFKkmkSE2zvim3xwW3PknmbLKbe3Mg==} + engines: {node: '>=14.*'} + cpu: [x64] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /@biomejs/cli-win32-arm64@1.6.0: + resolution: {integrity: sha512-DlNOL6mG+76iZS1gL/UiuMme7jnt+auzo2+u0aUq6UXYsb75juchwlnVLy2UV5CQjVBRB8+RM+KVoXRZ8NlBjQ==} + engines: {node: '>=14.*'} + cpu: [arm64] + os: [win32] + requiresBuild: true + dev: true + optional: true + + /@biomejs/cli-win32-x64@1.6.0: + resolution: {integrity: sha512-sXBcXIOGuG8/XcHqmnkhLIs0oy6Dp+TkH4Alr4WH/P8mNsp5GcStI/ZwbEiEoxA0P3Fi+oUppQ6srxaY2rSCHg==} + engines: {node: '>=14.*'} + cpu: [x64] + os: [win32] + requiresBuild: true + dev: true + optional: true + /@brillout/import@0.2.3: resolution: {integrity: sha512-1T8WlD75eeFSMrptGy8jiLHmfHgMmSjWvLOIUvHmSVZt+6k0eQqYUoK4KbmE4T9pVLIfxvZSOm2D68VEqKRHRw==} dev: true From e11d97b17d7a86b5a526e892e17a52960b175314 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CKenzo-Wada=E2=80=9D?= Date: Tue, 12 Mar 2024 01:58:54 +0900 Subject: [PATCH 2/5] feat: remove disabled of biome --- packages/features/src/features.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/features/src/features.ts b/packages/features/src/features.ts index cabdec3a3..ef06b8e7c 100644 --- a/packages/features/src/features.ts +++ b/packages/features/src/features.ts @@ -393,7 +393,6 @@ export const features = [ "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0nMS4wJyBlbmNvZGluZz0nVVRGLTgnPz48IURPQ1RZUEUgc3ZnIFBVQkxJQyAnLS8vVzNDLy9EVEQgU1ZHIDEuMS8vRU4nICdodHRwOi8vd3d3LnczLm9yZy9HcmFwaGljcy9TVkcvMS4xL0RURC9zdmcxMS5kdGQnPjxzdmcgeG1sbnM9J2h0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnJyB2ZXJzaW9uPScxLjEnIHdpZHRoPSc0OHB4JyBoZWlnaHQ9JzQ4cHgnIHN0eWxlPSdzaGFwZS1yZW5kZXJpbmc6Z2VvbWV0cmljUHJlY2lzaW9uOyB0ZXh0LXJlbmRlcmluZzpnZW9tZXRyaWN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Ljk3NTEsNDEuMDA4NiAzMy4zMDg0LDQxLjUwODYgMzEuNSw0MS41IFonLz48L2c+PGc+PHBhdGggc3R5bGU9J29wYWNpdHk6MC42ODInIGZpbGw9JyM5MjhlMzYnIGQ9J00gMjguNSwxNC41IEMgMjkuMTIzOSwxNC45MTY5IDI5LjQ1NzMsMTUuNTgzNiAyOS41LDE2LjVDIDI5LjI1MjgsMTcuNzEzMyAyOC41ODYyLDE4LjM4IDI3LjUsMTguNUMgMjguMjM0MSwxNy4yOTIxIDI4LjU2NzQsMTUuOTU4NyAyOC41LDE0LjUgWicvPjwvZz48Zz48cGF0aCBzdHlsZT0nb3BhY2l0eTowLjc1OCcgZmlsbD0nI2M0YTMyMycgZD0nTSAyMy41LDMzLjUgQyAyMy41LDM2LjE2NjcgMjMuNSwzOC44MzMzIDIzLjUsNDEuNUMgMjYuMTY2Nyw0MS41IDI4LjgzMzMsNDEuNSAzMS41LDQxLjVDIDI4LjcxMzEsNDIuNDc2NyAyNS43MTMxLDQyLjgxIDIyLjUsNDIuNUMgMjIuMTksMzkuMjg2OSAyMi41MjMzLDM2LjI4NjkgMjMuNSwzMy41IFonLz48L2c+PC9zdmc+Cg==", url: "https://biomejs.dev", spectrum: "bleeding_edge", - disabled: true, }, // Error tracking From 0027018e78f13dab6822f33cc71ec7b8f2084d24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CKenzo-Wada=E2=80=9D?= Date: Tue, 12 Mar 2024 02:00:29 +0900 Subject: [PATCH 3/5] add blank line --- boilerplates/biome/tsconfig.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/boilerplates/biome/tsconfig.json b/boilerplates/biome/tsconfig.json index 8f625f855..d797ad3bc 100644 --- a/boilerplates/biome/tsconfig.json +++ b/boilerplates/biome/tsconfig.json @@ -2,4 +2,4 @@ "extends": [ "../tsconfig.base.json" ] -} \ No newline at end of file +} From 22f10264f1602f310ea6c92728e280c748326da5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CKenzo-Wada=E2=80=9D?= Date: Wed, 3 Apr 2024 22:07:41 +0900 Subject: [PATCH 4/5] add check --aply --- boilerplates/biome/files/$package.json.ts | 4 ++++ packages/core/src/utils/package.ts | 5 ++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/boilerplates/biome/files/$package.json.ts b/boilerplates/biome/files/$package.json.ts index b5f24bdca..5b1395dd6 100644 --- a/boilerplates/biome/files/$package.json.ts +++ b/boilerplates/biome/files/$package.json.ts @@ -11,6 +11,10 @@ export default async function getPackageJson(props: TransformerProps) { format: { value: "biome format --write ./", precedence: 0 + }, + check: { + value: 'biome check --apply-unsafe ./src', + precedence: 0 } }); diff --git a/packages/core/src/utils/package.ts b/packages/core/src/utils/package.ts index a131163d4..a28949bb8 100644 --- a/packages/core/src/utils/package.ts +++ b/packages/core/src/utils/package.ts @@ -13,6 +13,7 @@ export interface PackageJsonScripts { preview?: string; lint?: string; format?: string; + check?: string; }; } @@ -28,6 +29,7 @@ export interface PackageJsonScriptOptions { preview?: PackageJsonScriptOption; lint?: PackageJsonScriptOption; format?: PackageJsonScriptOption; + check?: PackageJsonScriptOption; } function* deps(obj: PackageJsonDeps) { @@ -85,6 +87,7 @@ const previousScripts: Required = { preview: { precedence: -Infinity }, lint: { precedence: -Infinity }, format: { precedence: -Infinity }, + check: { precedence: -Infinity }, }; function warnScript(key: string, old: string, nnew: string) { @@ -101,7 +104,7 @@ function warnScript(key: string, old: string, nnew: string) { } export function setScripts(packageJson: T, scripts: PackageJsonScriptOptions) { - const keys = ["dev", "build", "preview", "lint", "format"] as const; + const keys = ["dev", "build", "preview", "lint", "format", "check"] as const; for (const key of keys) { const prev = previousScripts[key]!; From 87ce3c968e7a879bbbbb815618d200ccc3e07fba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CKenzo-Wada=E2=80=9D?= Date: Wed, 3 Apr 2024 22:20:04 +0900 Subject: [PATCH 5/5] fix linter --- boilerplates/biome/files/$package.json.ts | 6 +----- packages/core/src/utils/package.ts | 5 +---- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/boilerplates/biome/files/$package.json.ts b/boilerplates/biome/files/$package.json.ts index 5b1395dd6..46edb2235 100644 --- a/boilerplates/biome/files/$package.json.ts +++ b/boilerplates/biome/files/$package.json.ts @@ -5,17 +5,13 @@ export default async function getPackageJson(props: TransformerProps) { setScripts(packageJson, { lint: { - value: "biome lint --apply ./", + value: "biome check --apply-unsafe ./", precedence: 0 }, format: { value: "biome format --write ./", precedence: 0 }, - check: { - value: 'biome check --apply-unsafe ./src', - precedence: 0 - } }); return addDependency(packageJson, await import("../package.json", { assert: { type: "json" } }), { diff --git a/packages/core/src/utils/package.ts b/packages/core/src/utils/package.ts index a28949bb8..a131163d4 100644 --- a/packages/core/src/utils/package.ts +++ b/packages/core/src/utils/package.ts @@ -13,7 +13,6 @@ export interface PackageJsonScripts { preview?: string; lint?: string; format?: string; - check?: string; }; } @@ -29,7 +28,6 @@ export interface PackageJsonScriptOptions { preview?: PackageJsonScriptOption; lint?: PackageJsonScriptOption; format?: PackageJsonScriptOption; - check?: PackageJsonScriptOption; } function* deps(obj: PackageJsonDeps) { @@ -87,7 +85,6 @@ const previousScripts: Required = { preview: { precedence: -Infinity }, lint: { precedence: -Infinity }, format: { precedence: -Infinity }, - check: { precedence: -Infinity }, }; function warnScript(key: string, old: string, nnew: string) { @@ -104,7 +101,7 @@ function warnScript(key: string, old: string, nnew: string) { } export function setScripts(packageJson: T, scripts: PackageJsonScriptOptions) { - const keys = ["dev", "build", "preview", "lint", "format", "check"] as const; + const keys = ["dev", "build", "preview", "lint", "format"] as const; for (const key of keys) { const prev = previousScripts[key]!;