Skip to content

Commit

Permalink
chore: remove bun from tailwind script
Browse files Browse the repository at this point in the history
  • Loading branch information
ematipico committed Feb 1, 2025
1 parent 3c11251 commit dff45a4
Show file tree
Hide file tree
Showing 6 changed files with 98 additions and 37 deletions.
4 changes: 3 additions & 1 deletion justfile
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,10 @@ gen-formatter:
cargo run -p xtask_codegen -- formatter

# Generates the Tailwind CSS preset for utility class sorting (requires Bun)
[working-directory: 'packages/tailwindcss-config-analyzer']
gen-tw:
bun packages/tailwindcss-config-analyzer/src/generate-tailwind-preset.ts
pnpm build
pnpm execute

# Generates the code of the grammars available in Biome
gen-grammar *args='':
Expand Down
8 changes: 6 additions & 2 deletions packages/tailwindcss-config-analyzer/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tailwindcss-config-analyzer",
"version": "1.0.0",
"version": "0.0.0",
"description": "Tools to introspect Tailwind CSS configurations for integration with Biome",
"private": true,
"license": "MIT OR Apache-2.0",
Expand All @@ -9,8 +9,12 @@
"dependencies": {
"tailwindcss": "^3.4.17"
},
"scripts": {
"build": "tsc",
"execute": "node dist/generate-tailwind-preset.js"
},
"devDependencies": {
"@types/bun": "1.2.0",
"@types/node": "^22.13.0",
"read-package-up": "11.0.0",
"typescript": "5.7.3"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
// run this script: $ just gen-tw
// requires Bun installed globally: bun.sh

import path from "node:path";
import { fileURLToPath } from "node:url";
import { readPackageUp } from "read-package-up";
import { introspectTailwindConfig } from "./introspect.js";
import { type SortConfig, sortConfigFromSpec } from "./sort-config.js";
import fs from "node:fs"

const ROOT_PACKAGE_NAME = "@biomejs/monorepo";
const OUTPUT_PATH =
"crates/biome_js_analyze/src/semantic_analyzers/nursery/use_sorted_classes/tailwind_preset.rs";
const OUTPUT_PATH = "crates/biome_js_analyze/src/lint/nursery/use_sorted_classes/tailwind_preset.rs";

const EXCLUDED_LAYERS = ["defaults", "base"];
const LAYER_ORDER = ["components", "utilities"];
Expand Down Expand Up @@ -106,7 +105,7 @@ async function generateTailwindPreset() {
const file = generateFile(sortConfig);
const rootPath = await findRoot();
const outputPath = path.join(rootPath, OUTPUT_PATH);
await Bun.write(outputPath, file);
await fs.promises.writeFile(outputPath, file);
}

await generateTailwindPreset();
4 changes: 3 additions & 1 deletion packages/tailwindcss-config-analyzer/src/introspect.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import type { Config } from "tailwindcss";
import { createContext } from "tailwindcss/lib/lib/setupContextUtils";
// @ts-ignore
import pkg from "tailwindcss/lib/lib/setupContextUtils.js";
import resolveConfig from "tailwindcss/resolveConfig.js";
import type { TailwindContext } from "./types.js";

const { createContext } = pkg;
const DEFAULT_CONFIG: Config = { content: [] };

function createContextFromConfig(config: Partial<Config>) {
Expand Down
6 changes: 4 additions & 2 deletions packages/tailwindcss-config-analyzer/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"compilerOptions": {
"lib": [
"ESNext"
"ESNext",
"dom"
],
"module": "NodeNext",
"target": "esnext",
Expand All @@ -14,7 +15,8 @@
"jsx": "react-jsx",
"allowSyntheticDefaultImports": true,
"forceConsistentCasingInFileNames": true,
"allowJs": true
"allowJs": true,
"outDir": "dist",
},
"include": [
"src/**/*"
Expand Down
106 changes: 79 additions & 27 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit dff45a4

Please sign in to comment.