Skip to content

Commit f17c772

Browse files
authored
chore: bump shiki deps and add theme generator (#37)
1 parent 56ca217 commit f17c772

4 files changed

Lines changed: 151 additions & 54 deletions

File tree

src-js-bundle/shiki/package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,17 @@
66
"scripts": {
77
"dev": "vite",
88
"build": "vite build",
9+
"generate-config": "node ./scripts/generate-config.js",
910
"preview": "vite preview"
1011
},
1112
"devDependencies": {
12-
"vite": "npm:rolldown-vite@7.3.0"
13+
"js-yaml": "^4.1.1",
14+
"vite": "npm:rolldown-vite@7.3.1"
1315
},
1416
"overrides": {
15-
"vite": "npm:rolldown-vite@7.3.0"
17+
"vite": "npm:rolldown-vite@7.3.1"
1618
},
1719
"dependencies": {
18-
"shiki": "^3.20.0"
20+
"shiki": "^3.22.0"
1921
}
2022
}

src-js-bundle/shiki/pnpm-lock.yaml

Lines changed: 55 additions & 39 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import { readFileSync, writeFileSync } from "node:fs";
2+
import yaml from "js-yaml";
3+
import { bundledThemesInfo } from "shiki/bundle/full";
4+
5+
/* thanks to https://github.com/halo-sigs/plugin-shiki/blob/main/scripts/generate-themes-for-settings-file.mjs */
6+
7+
const THEME_FIELD_NAMES = ["lightTheme", "darkTheme", "theme"];
8+
const settingsFilePath = new URL(
9+
"../../../src/main/resources/extensions/settings.yaml",
10+
import.meta.url,
11+
);
12+
13+
try {
14+
const settingsFileContent = readFileSync(settingsFilePath, "utf8");
15+
const settings = yaml.load(settingsFileContent);
16+
17+
if (!settings?.spec?.forms) {
18+
console.warn("No forms found in settings.yaml");
19+
process.exit(0);
20+
}
21+
22+
const themeOptions = bundledThemesInfo.map((theme) => ({
23+
label: `${theme.displayName}${theme.type})`,
24+
value: theme.id,
25+
}));
26+
27+
let updatedCount = 0;
28+
settings.spec.forms.forEach((form) => {
29+
if (form.group!== "shiki") {
30+
return;
31+
}
32+
form.formSchema?.forEach((field) => {
33+
if (THEME_FIELD_NAMES.includes(field.name)) {
34+
field.options = themeOptions;
35+
updatedCount++;
36+
}
37+
});
38+
});
39+
40+
const updatedYaml = yaml.dump(settings, {
41+
indent: 2,
42+
lineWidth: -1,
43+
noRefs: true,
44+
quotingType: '"',
45+
forceQuotes: false,
46+
flowLevel: -1,
47+
sortKeys: false,
48+
});
49+
50+
writeFileSync(settingsFilePath, updatedYaml, "utf8");
51+
console.log(`✓ Updated ${updatedCount} theme fields in settings.yaml`);
52+
} catch (error) {
53+
console.error("Error updating settings.yaml:", error.message);
54+
process.exit(1);
55+
}

0 commit comments

Comments
 (0)