mirror of
https://github.com/grafana/grafana.git
synced 2024-11-22 00:47:38 -06:00
8f06784449
* chore(d3-color): resolve all copies to 3.1.0 to fix vulnerability * chore(yarn): fix resolution version * chore(jest): compile d3-color from esm to cjs * chore(d3): bump d3 to latest, set jest config to transpile es modules * chore: bump visx packages to resolve d3-color to latest * chore(jest): add missing es modules to config * chore(storybook): prevent storybook config failure due to nested esm imports * chore(storybook): use a direct path to avoid es modules breaking config build * build(sass): use esbuild to generate sass theme vars for esm deps * chore: clean up swc dependencies * revert: remove debug console.log breaking tests
36 lines
1.5 KiB
TypeScript
36 lines
1.5 KiB
TypeScript
import { writeFile } from 'node:fs/promises';
|
|
import { resolve } from 'path';
|
|
|
|
import { createTheme } from '@grafana/data';
|
|
import { darkThemeVarsTemplate } from '@grafana/ui/src/themes/_variables.dark.scss.tmpl';
|
|
import { lightThemeVarsTemplate } from '@grafana/ui/src/themes/_variables.light.scss.tmpl';
|
|
import { commonThemeVarsTemplate } from '@grafana/ui/src/themes/_variables.scss.tmpl';
|
|
|
|
const darkThemeVariablesPath = resolve(__dirname, 'public', 'sass', '_variables.dark.generated.scss');
|
|
const lightThemeVariablesPath = resolve(__dirname, 'public', 'sass', '_variables.light.generated.scss');
|
|
const defaultThemeVariablesPath = resolve(__dirname, 'public', 'sass', '_variables.generated.scss');
|
|
|
|
async function writeVariablesFile(path: string, data: string) {
|
|
try {
|
|
await writeFile(path, data);
|
|
} catch (error) {
|
|
console.error('\nWriting SASS variable files failed', error);
|
|
process.exit(1);
|
|
}
|
|
}
|
|
|
|
async function generateSassVariableFiles() {
|
|
const darkTheme = createTheme();
|
|
const lightTheme = createTheme({ colors: { mode: 'light' } });
|
|
try {
|
|
await writeVariablesFile(darkThemeVariablesPath, darkThemeVarsTemplate(darkTheme));
|
|
await writeVariablesFile(lightThemeVariablesPath, lightThemeVarsTemplate(lightTheme));
|
|
await writeVariablesFile(defaultThemeVariablesPath, commonThemeVarsTemplate(darkTheme));
|
|
} catch (error) {
|
|
console.error('\nWriting SASS variable files failed', error);
|
|
process.exit(1);
|
|
}
|
|
}
|
|
|
|
generateSassVariableFiles();
|