mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Chore: Bump d3-color to 3.1.0 (#61609)
* 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
This commit is contained in:
@@ -1,41 +1,35 @@
|
||||
import * as fs from 'fs';
|
||||
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 = __dirname + '/../../public/sass/_variables.dark.generated.scss';
|
||||
const lightThemeVariablesPath = __dirname + '/../../public/sass/_variables.light.generated.scss';
|
||||
const defaultThemeVariablesPath = __dirname + '/../../public/sass/_variables.generated.scss';
|
||||
|
||||
const writeVariablesFile = async (path: string, data: string) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
fs.writeFile(path, data, (e) => {
|
||||
if (e) {
|
||||
reject(e);
|
||||
} else {
|
||||
resolve(data);
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
const generateSassVariableFiles = async () => {
|
||||
const darkTheme = createTheme();
|
||||
const lightTheme = createTheme({ colors: { mode: 'light' } });
|
||||
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 Promise.all([
|
||||
writeVariablesFile(darkThemeVariablesPath, darkThemeVarsTemplate(darkTheme)),
|
||||
writeVariablesFile(lightThemeVariablesPath, lightThemeVarsTemplate(lightTheme)),
|
||||
writeVariablesFile(defaultThemeVariablesPath, commonThemeVarsTemplate(darkTheme)),
|
||||
]);
|
||||
console.log('\nSASS variable files generated');
|
||||
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();
|
||||
|
@@ -5,6 +5,6 @@
|
||||
"extends": "../../tsconfig.json",
|
||||
"ts-node": {
|
||||
"transpileOnly": true,
|
||||
"transpiler": "ts-node/transpilers/swc-experimental"
|
||||
"swc": true
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user