Skip to content

Commit

Permalink
add package to check script and fix issues
Browse files Browse the repository at this point in the history
  • Loading branch information
DaniGuardiola committed Feb 29, 2024
1 parent 5ee6bc9 commit c1389b4
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 22 deletions.
24 changes: 12 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
{
"name": "@biomejs/monorepo",
"private": true,
"version": "0.0.0",
"scripts": {
"check:apply": "cargo biome-cli-dev check --apply-unsafe editors website packages/@biomejs/js-api",
"check": "cargo biome-cli-dev check editors website packages/@biomejs/js-api",
"ci": "cargo biome-cli-dev ci editors website packages/@biomejs/js-api"
"name": "@biomejs/monorepo",
"private": true,
"version": "0.0.0",
"scripts": {
"check:apply": "cargo biome-cli-dev check --apply-unsafe editors website packages/@biomejs/js-api packages/tailwindcss-config-analyzer",
"check": "cargo biome-cli-dev check editors website packages/@biomejs/js-api packages/tailwindcss-config-analyzer",
"ci": "cargo biome-cli-dev ci editors website packages/@biomejs/js-api packages/tailwindcss-config-analyzer"
},
"keywords": [],
"author": "",
"devDependencies": {
"keywords": [],
"author": "",
"devDependencies": {
"shared": "file:./shared",
"@changesets/cli": "^2.26.2"
}
"@changesets/cli": "^2.26.2"
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// run this script: $ just gen-tw
// requires Bun installed globally: bun.sh

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

const ROOT_PACKAGE_NAME = "@biomejs/monorepo";
const OUTPUT_PATH =
Expand All @@ -22,14 +22,18 @@ use super::sort_config::UtilityLayer;
`;

function generateLayer({ layer, classes }: SortConfig["utilities"][number]) {
const header = `const ${layer.toUpperCase()}_LAYER_CLASSES: [&str; ${classes.length}] = [`;
const header = `const ${layer.toUpperCase()}_LAYER_CLASSES: [&str; ${
classes.length
}] = [`;

// try single line
const singleLine = `${header}${classes.map((c) => `"${c}"`).join(", ")}];`;
if (singleLine.length < LINE_LIMIT) return `${singleLine}\n`;

// if single line is too long, do multi-line
return `${header}\n${classes.map((c) => `${INDENT}"${c}"`).join(",\n")},\n];\n`;
return `${header}\n${classes
.map((c) => `${INDENT}"${c}"`)
.join(",\n")},\n];\n`;
}

function generateLayerArray(layers: SortConfig["utilities"]) {
Expand Down
4 changes: 2 additions & 2 deletions packages/tailwindcss-config-analyzer/src/introspect.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import resolveConfig from "tailwindcss/resolveConfig.js";
import { createContext } from "tailwindcss/lib/lib/setupContextUtils";
import type { Config } from "tailwindcss";
import { createContext } from "tailwindcss/lib/lib/setupContextUtils";
import resolveConfig from "tailwindcss/resolveConfig.js";
import type { TailwindContext } from "./types.js";

const DEFAULT_CONFIG: Config = { content: [] };
Expand Down
6 changes: 3 additions & 3 deletions packages/tailwindcss-config-analyzer/src/sort-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export type SortConfig = {
}>;
};

function compareBigInt(a: BigInt, b: BigInt) {
function compareBigInt(a: bigint, b: bigint) {
if (a < b) return -1;
if (a > b) return 1;
return 0;
Expand All @@ -29,11 +29,11 @@ export function sortConfigFromSpec(
{ layerOrder }: { layerOrder: Array<string> },
): SortConfig {
const utilitiesByLayer = new Map<string, Set<UtilitySpec>>();
spec.utilities.forEach((utilitySpec) => {
for (const utilitySpec of spec.utilities) {
const layer = utilitiesByLayer.get(utilitySpec.layer) ?? new Set();
layer.add(utilitySpec);
utilitiesByLayer.set(utilitySpec.layer, layer);
});
}
const layerIndexes = new Map(
layerOrder.map((layer, index) => [layer, index]),
);
Expand Down

0 comments on commit c1389b4

Please sign in to comment.