Skip to content

Commit

Permalink
refactor to new biome
Browse files Browse the repository at this point in the history
  • Loading branch information
DexterStorey committed Oct 2, 2024
1 parent 1f4cdef commit 197bf7c
Show file tree
Hide file tree
Showing 44 changed files with 1,720 additions and 1,769 deletions.
4 changes: 0 additions & 4 deletions .eslintrc.js

This file was deleted.

1 change: 0 additions & 1 deletion .prettierrc.js

This file was deleted.

21 changes: 21 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"editor.defaultFormatter": "biomejs.biome",
"editor.formatOnSave": true,
"editor.formatOnType": true,
"[typescript]": {
"editor.defaultFormatter": "biomejs.biome"
},
"[typescriptreact]": {
"editor.defaultFormatter": "biomejs.biome"
},
"[json]": {
"editor.defaultFormatter": "biomejs.biome"
},
"editor.codeActionsOnSave": {
"quickfix.biome": "explicit",
"source.organizeImports.biome": "explicit"
},
"[prisma]": {
"editor.defaultFormatter": "Prisma.prisma"
}
}
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
- [2024-10-02] [refactor to new biome](https://github.com/RubricLab/ui/commit/8d2aeca6c0ae824b8bcf1f85a7bd1fecda84180e)
- [2024-10-02] [Again again](https://github.com/RubricLab/ui/commit/ad0f01623966ed33b238a56e1726d89e3e1ed029)
- [2024-10-02] [Bundle css](https://github.com/RubricLab/ui/commit/343655090d6f68bf065807a4552a655a5b660517)
- [2024-10-02] [Bundle index.ts](https://github.com/RubricLab/ui/commit/1b141ca0383cd61cd0d481a3008f3b122cdb3544)
Expand Down
143 changes: 70 additions & 73 deletions bin/commands/init.js
Original file line number Diff line number Diff line change
@@ -1,115 +1,112 @@
import { Command } from "commander";
import prompts from "prompts";
import { existsSync, promises as fs } from "node:fs";
import { resolve, dirname, relative } from "node:path";
import { fileURLToPath } from "node:url";
import chalk from "chalk";
import { Command } from 'commander'
import prompts from 'prompts'
import { existsSync, promises as fs } from 'node:fs'
import { resolve, dirname, relative } from 'node:path'
import { fileURLToPath } from 'node:url'
import chalk from 'chalk'

const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
const __filename = fileURLToPath(import.meta.url)
const __dirname = dirname(__filename)

export const init = new Command()
.name("init")
.description("Initialize required configuration files")
.name('init')
.description('Initialize required configuration files')
.action(async () => {
const responses = await prompts([
{
type: "toggle",
name: "typescript",
message: "Are you using TypeScript?",
type: 'toggle',
name: 'typescript',
message: 'Are you using TypeScript?',
initial: true,
active: "yes",
inactive: "no",
active: 'yes',
inactive: 'no'
},
{
type: "text",
name: "tw_config_path",
message: "Enter the path where your tailwind config file is located",
initial: (prev) =>
prev === true ? "./tailwind.config.ts" : "./tailwind.config.js",
type: 'text',
name: 'tw_config_path',
message: 'Enter the path where your tailwind config file is located',
initial: prev => (prev === true ? './tailwind.config.ts' : './tailwind.config.js')
},
{
type: "toggle",
name: "overwrite_tw_config",
message: "Do you want to overwrite your existing tailwind config?",
type: 'toggle',
name: 'overwrite_tw_config',
message: 'Do you want to overwrite your existing tailwind config?',
initial: false,
active: "yes",
inactive: "no",
active: 'yes',
inactive: 'no'
},
{
type: "text",
name: "styles_path",
message: "Enter the path where your styles file is located",
initial: "./app/globals.css",
},
]);
type: 'text',
name: 'styles_path',
message: 'Enter the path where your styles file is located',
initial: './app/globals.css'
}
])

await executeConfig(responses);
});
await executeConfig(responses)
})

async function executeConfig(responses) {
const fileEnc = "utf-8";
const overwriteTWConfig = responses.overwrite_tw_config;
const extension = responses.typescript ? "ts" : "js";
const configDir = resolve(__dirname, "../config");
const presetSourcePath = resolve(configDir, `rubric.preset.${extension}`);
const tailwindConfigSourcePath = resolve(
configDir,
`tailwind.config.${extension}`,
);
const stylesSourcePath = resolve(configDir, "globals.css");
const fileEnc = 'utf-8'
const overwriteTWConfig = responses.overwrite_tw_config
const extension = responses.typescript ? 'ts' : 'js'
const configDir = resolve(__dirname, '../config')
const presetSourcePath = resolve(configDir, `rubric.preset.${extension}`)
const tailwindConfigSourcePath = resolve(configDir, `tailwind.config.${extension}`)
const stylesSourcePath = resolve(configDir, 'globals.css')

const tailwindConfigDestinationPath = resolve(
process.cwd(),
responses.tw_config_path,
);
const tailwindConfigDestinationPath = resolve(process.cwd(), responses.tw_config_path)
const presetDestinationPath = resolve(
dirname(tailwindConfigDestinationPath),
`rubric.preset.${extension}`,
);
const stylesDestinationPath = resolve(process.cwd(), responses.styles_path);
`rubric.preset.${extension}`
)
const stylesDestinationPath = resolve(process.cwd(), responses.styles_path)

if (existsSync(presetSourcePath)) {
const presetConfig = await fs.readFile(presetSourcePath, fileEnc);
await fs.writeFile(presetDestinationPath, presetConfig, fileEnc);
const presetConfig = await fs.readFile(presetSourcePath, fileEnc)
await fs.writeFile(presetDestinationPath, presetConfig, fileEnc)
console.log(
`Preset file written to ${chalk.green(relative(process.cwd(), presetDestinationPath))}`,
);
`Preset file written to ${chalk.green(relative(process.cwd(), presetDestinationPath))}`
)
} else {
console.error(chalk.red("Preset file not found"));
console.error(chalk.red('Preset file not found'))
}

if (existsSync(stylesSourcePath)) {
try {
const [styleInsertion, userStyles] = await Promise.all([
fs.readFile(stylesSourcePath, fileEnc),
fs.readFile(stylesDestinationPath, fileEnc),
]);
const insertionPoint = "@tailwind utilities;";
const index = userStyles.indexOf(insertionPoint) + insertionPoint.length;
const updatedStyles = `${userStyles.slice(0, index)}\n\n${styleInsertion}${userStyles.slice(index)}`;
await fs.writeFile(stylesDestinationPath, updatedStyles, fileEnc);
fs.readFile(stylesDestinationPath, fileEnc)
])
const insertionPoint = '@tailwind utilities;'
const index = userStyles.indexOf(insertionPoint) + insertionPoint.length
const updatedStyles = `${userStyles.slice(0, index)}\n\n${styleInsertion}${userStyles.slice(index)}`
await fs.writeFile(stylesDestinationPath, updatedStyles, fileEnc)
console.log(
`Styles file written to ${chalk.green(relative(process.cwd(), stylesDestinationPath))}`,
);
`Styles file written to ${chalk.green(relative(process.cwd(), stylesDestinationPath))}`
)
} catch (error) {
console.error(
chalk.red(
"Failed to write to styles file. Ensure the path is correct and the file is writable.",
),
);
'Failed to write to styles file. Ensure the path is correct and the file is writable.'
)
)
}
}

if (!overwriteTWConfig) {
const presetPrompt = `${chalk.green("+")} ${chalk.dim("presets: [")}${chalk.blue(`require("./rubric.preset.${extension}")`)}${chalk.dim("],")}`;
const contentPrompt = `${chalk.green("+")} ${chalk.dim("content: [")}${chalk.blue(`"./node_modules/rubricui/dist/**/*.{js,jsx,ts,tsx}"`)}${chalk.dim("],")}`;
console.log(`\nManual changes required to ${chalk.bold(`tailwind.config.${extension}`)}:\n${presetPrompt}\n${contentPrompt}`);
const presetPrompt = `${chalk.green('+')} ${chalk.dim('presets: [')}${chalk.blue(`require("./rubric.preset.${extension}")`)}${chalk.dim('],')}`
const contentPrompt = `${chalk.green('+')} ${chalk.dim('content: [')}${chalk.blue(`"./node_modules/rubricui/dist/**/*.{js,jsx,ts,tsx}"`)}${chalk.dim('],')}`
console.log(
`\nManual changes required to ${chalk.bold(`tailwind.config.${extension}`)}:\n${presetPrompt}\n${contentPrompt}`
)
} else if (existsSync(tailwindConfigSourcePath)) {
const tailwindConfig = await fs.readFile(tailwindConfigSourcePath, fileEnc);
await fs.writeFile(tailwindConfigDestinationPath, tailwindConfig, fileEnc);
console.log(`Tailwind config file written to ${chalk.green(relative(process.cwd(), tailwindConfigDestinationPath))}`);
const tailwindConfig = await fs.readFile(tailwindConfigSourcePath, fileEnc)
await fs.writeFile(tailwindConfigDestinationPath, tailwindConfig, fileEnc)
console.log(
`Tailwind config file written to ${chalk.green(relative(process.cwd(), tailwindConfigDestinationPath))}`
)
} else {
console.error(chalk.red("Tailwind config file not found"));
console.error(chalk.red('Tailwind config file not found'))
}
}
32 changes: 16 additions & 16 deletions bin/config/globals.css
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
@layer base {
:root {
--rubricui-primary: 252 252 252;
--rubricui-contrast: 5 5 5;
}
:root {
--rubricui-primary: 252 252 252;
--rubricui-contrast: 5 5 5;
}

.dark {
--rubricui-primary: 5 5 5;
--rubricui-contrast: 252 252 252;
}
.dark {
--rubricui-primary: 5 5 5;
--rubricui-contrast: 252 252 252;
}
}

@layer base {
body {
@apply bg-rubricui-primary text-rubricui-contrast;
font-feature-settings: "rlig" 1, "calt" 1;
}
button:hover {
text-shadow: 0px 0px 10px rgb(var(--rubricui-primary));
}
}
body {
@apply bg-rubricui-primary text-rubricui-contrast;
font-feature-settings: "rlig" 1, "calt" 1;
}
button:hover {
text-shadow: 0px 0px 10px rgb(var(--rubricui-primary));
}
}
51 changes: 25 additions & 26 deletions bin/config/rubric.preset.js
Original file line number Diff line number Diff line change
@@ -1,40 +1,39 @@
const rubricConfig = {
content: ["./node_modules/rubricui/dist/**/*.{js,jsx,ts,tsx}"],
content: ['./node_modules/rubricui/dist/**/*.{js,jsx,ts,tsx}'],
theme: {
extend: {
colors: {
"rubricui-primary": "rgb(var(--rubricui-primary) / <alpha-value>)",
"rubricui-contrast": "rgb(var(--rubricui-contrast) / <alpha-value>)",
'rubricui-primary': 'rgb(var(--rubricui-primary) / <alpha-value>)',
'rubricui-contrast': 'rgb(var(--rubricui-contrast) / <alpha-value>)'
},
transitionDuration: {
"rubricui-duration": "300ms",
'rubricui-duration': '300ms'
},
keyframes: {
"rubricui-loading-rotate": {
"0%": { transform: "rotate(0deg)" },
"25%": { transform: "rotate(90deg)" },
"50%": { transform: "rotate(180deg)" },
"75%": { transform: "rotate(270deg)" },
"100%": { transform: "rotate(360deg)" },
'rubricui-loading-rotate': {
'0%': { transform: 'rotate(0deg)' },
'25%': { transform: 'rotate(90deg)' },
'50%': { transform: 'rotate(180deg)' },
'75%': { transform: 'rotate(270deg)' },
'100%': { transform: 'rotate(360deg)' }
},
"accordion-down": {
from: { height: "0" },
to: { height: "var(--radix-accordion-content-height)" },
},
"accordion-up": {
from: { height: "var(--radix-accordion-content-height)" },
to: { height: "0" },
'accordion-down': {
from: { height: '0' },
to: { height: 'var(--radix-accordion-content-height)' }
},
'accordion-up': {
from: { height: 'var(--radix-accordion-content-height)' },
to: { height: '0' }
}
},
animation: {
"rubricui-loading-rotate":
"rubricui-loading-rotate 1s steps(1) infinite",
"accordion-down": "accordion-down 0.2s ease-out",
"accordion-up": "accordion-up 0.2s ease-out",
},
},
'rubricui-loading-rotate': 'rubricui-loading-rotate 1s steps(1) infinite',
'accordion-down': 'accordion-down 0.2s ease-out',
'accordion-up': 'accordion-up 0.2s ease-out'
}
}
},
plugins: [require("tailwindcss-animate"), require("@tailwindcss/typography")],
};
plugins: [require('tailwindcss-animate'), require('@tailwindcss/typography')]
}

export default rubricConfig;
export default rubricConfig
53 changes: 26 additions & 27 deletions bin/config/rubric.preset.ts
Original file line number Diff line number Diff line change
@@ -1,42 +1,41 @@
import type { Config } from "tailwindcss";
import type { Config } from 'tailwindcss'

const rubricConfig = {
content: ["./node_modules/rubricui/dist/**/*.{js,jsx,ts,tsx}"],
content: ['./node_modules/rubricui/dist/**/*.{js,jsx,ts,tsx}'],
theme: {
extend: {
colors: {
"rubricui-primary": "rgb(var(--rubricui-primary) / <alpha-value>)",
"rubricui-contrast": "rgb(var(--rubricui-contrast) / <alpha-value>)",
'rubricui-primary': 'rgb(var(--rubricui-primary) / <alpha-value>)',
'rubricui-contrast': 'rgb(var(--rubricui-contrast) / <alpha-value>)'
},
transitionDuration: {
"rubricui-duration": "300ms",
'rubricui-duration': '300ms'
},
keyframes: {
"rubricui-loading-rotate": {
"0%": { transform: "rotate(0deg)" },
"25%": { transform: "rotate(90deg)" },
"50%": { transform: "rotate(180deg)" },
"75%": { transform: "rotate(270deg)" },
"100%": { transform: "rotate(360deg)" },
'rubricui-loading-rotate': {
'0%': { transform: 'rotate(0deg)' },
'25%': { transform: 'rotate(90deg)' },
'50%': { transform: 'rotate(180deg)' },
'75%': { transform: 'rotate(270deg)' },
'100%': { transform: 'rotate(360deg)' }
},
"accordion-down": {
from: { height: "0" },
to: { height: "var(--radix-accordion-content-height)" },
},
"accordion-up": {
from: { height: "var(--radix-accordion-content-height)" },
to: { height: "0" },
'accordion-down': {
from: { height: '0' },
to: { height: 'var(--radix-accordion-content-height)' }
},
'accordion-up': {
from: { height: 'var(--radix-accordion-content-height)' },
to: { height: '0' }
}
},
animation: {
"rubricui-loading-rotate":
"rubricui-loading-rotate 1s steps(1) infinite",
"accordion-down": "accordion-down 0.2s ease-out",
"accordion-up": "accordion-up 0.2s ease-out",
},
},
'rubricui-loading-rotate': 'rubricui-loading-rotate 1s steps(1) infinite',
'accordion-down': 'accordion-down 0.2s ease-out',
'accordion-up': 'accordion-up 0.2s ease-out'
}
}
},
plugins: [require("tailwindcss-animate"), require("@tailwindcss/typography")],
} satisfies Config;
plugins: [require('tailwindcss-animate'), require('@tailwindcss/typography')]
} satisfies Config

export default rubricConfig;
export default rubricConfig
Loading

0 comments on commit 197bf7c

Please sign in to comment.