Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ jobs:

- run: npm install
- run: npm run build
- run: npm run check:theme-dependencies
- working-directory: core
run: |
npm run bundle
npm run bundle:min

- run: npm run coverage
- run: npm run doc
- run: npm run doc
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"⬆️⬆️⬆️⬆️⬆️ package ⬆️⬆️⬆️⬆️⬆️": "▲▲▲▲▲ package ▲▲▲▲▲",
"test": "lerna exec \"tsbb test --no-watchman\" --scope @uiw/react-codemirror",
"coverage": "lerna exec \"tsbb test --coverage --bail --no-watchman\" --scope @uiw/react-codemirror --scope @uiw/codemirror-extensions-langs",
"check:theme-dependencies": "node themes/_scripts/check-runtime-dependencies.cjs",
"prepare": "husky",
"version": "lerna version --exact --force-publish --no-push --no-git-tag-version",
"prettier": "prettier --write '**/*.{js,jsx,tsx,ts,less,json}'",
Expand Down
74 changes: 74 additions & 0 deletions themes/_scripts/check-runtime-dependencies.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
const fs = require('node:fs');
const path = require('node:path');

const themesDir = path.resolve(__dirname, '..');

function packageName(specifier) {
if (specifier.startsWith('@')) {
return specifier.split('/').slice(0, 2).join('/');
}
return specifier.split('/')[0];
}

function runtimeImports(source) {
const imports = new Set();
const patterns = [
/\bimport\s+(?:[^'";]+?\s+from\s+)?['"]([^'"]+)['"]/g,
/\bexport\s+[^'";]+?\s+from\s+['"]([^'"]+)['"]/g,
/\b(?:import|require)\s*\(\s*['"]([^'"]+)['"]\s*\)/g,
];

for (const pattern of patterns) {
for (const match of source.matchAll(pattern)) {
if (!match[1].startsWith('.') && !path.isAbsolute(match[1])) {
imports.add(match[1]);
}
}
}
return imports;
}

function javascriptFiles(directory) {
if (!fs.existsSync(directory)) return [];
return fs.readdirSync(directory, { withFileTypes: true }).flatMap((entry) => {
const entryPath = path.join(directory, entry.name);
if (entry.isDirectory()) return javascriptFiles(entryPath);
return entry.isFile() && entry.name.endsWith('.js') ? [entryPath] : [];
});
}

const failures = [];
for (const entry of fs.readdirSync(themesDir, { withFileTypes: true })) {
if (!entry.isDirectory() || entry.name.startsWith('_')) continue;

const packageDir = path.join(themesDir, entry.name);
const manifestPath = path.join(packageDir, 'package.json');
const manifest = JSON.parse(fs.readFileSync(manifestPath, 'utf8'));
const declared = new Set([
...Object.keys(manifest.dependencies || {}),
...Object.keys(manifest.optionalDependencies || {}),
...Object.keys(manifest.peerDependencies || {}),
]);
const outputFiles = [
...javascriptFiles(path.join(packageDir, 'esm')),
...javascriptFiles(path.join(packageDir, 'cjs')),
];

for (const file of outputFiles) {
const source = fs.readFileSync(file, 'utf8');
for (const specifier of runtimeImports(source)) {
const dependency = packageName(specifier);
if (!declared.has(dependency)) {
failures.push(`${entry.name}: ${path.relative(packageDir, file)} imports ${specifier}`);
}
}
}
}

if (failures.length > 0) {
console.error('Undeclared runtime dependencies found:');
for (const failure of failures) console.error(`- ${failure}`);
process.exitCode = 1;
} else {
console.log('All built theme runtime imports are declared.');
}
2 changes: 2 additions & 0 deletions themes/abcdef/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
"cjs"
],
"dependencies": {
"@babel/runtime": "^7.18.6",
"@lezer/highlight": "^1.0.0",
"@uiw/codemirror-themes": "4.25.11"
},
"keywords": [
Expand Down
2 changes: 2 additions & 0 deletions themes/abyss/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
"cjs"
],
"dependencies": {
"@babel/runtime": "^7.18.6",
"@lezer/highlight": "^1.0.0",
"@uiw/codemirror-themes": "4.25.11"
},
"keywords": [
Expand Down
2 changes: 2 additions & 0 deletions themes/androidstudio/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
"cjs"
],
"dependencies": {
"@babel/runtime": "^7.18.6",
"@lezer/highlight": "^1.0.0",
"@uiw/codemirror-themes": "4.25.11"
},
"keywords": [
Expand Down
2 changes: 2 additions & 0 deletions themes/andromeda/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
"cjs"
],
"dependencies": {
"@babel/runtime": "^7.18.6",
"@lezer/highlight": "^1.0.0",
"@uiw/codemirror-themes": "4.25.11"
},
"keywords": [
Expand Down
2 changes: 2 additions & 0 deletions themes/atomone/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
"cjs"
],
"dependencies": {
"@babel/runtime": "^7.18.6",
"@lezer/highlight": "^1.0.0",
"@uiw/codemirror-themes": "4.25.11"
},
"keywords": [
Expand Down
2 changes: 2 additions & 0 deletions themes/aura/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
"cjs"
],
"dependencies": {
"@babel/runtime": "^7.18.6",
"@lezer/highlight": "^1.0.0",
"@uiw/codemirror-themes": "4.25.11"
},
"keywords": [
Expand Down
2 changes: 2 additions & 0 deletions themes/basic/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
"cjs"
],
"dependencies": {
"@babel/runtime": "^7.18.6",
"@lezer/highlight": "^1.0.0",
"@uiw/codemirror-themes": "4.25.11"
},
"keywords": [
Expand Down
2 changes: 2 additions & 0 deletions themes/bbedit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
"cjs"
],
"dependencies": {
"@babel/runtime": "^7.18.6",
"@lezer/highlight": "^1.0.0",
"@uiw/codemirror-themes": "4.25.11"
},
"keywords": [
Expand Down
2 changes: 2 additions & 0 deletions themes/bespin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
"cjs"
],
"dependencies": {
"@babel/runtime": "^7.18.6",
"@lezer/highlight": "^1.0.0",
"@uiw/codemirror-themes": "4.25.11"
},
"keywords": [
Expand Down
1 change: 1 addition & 0 deletions themes/console/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"cjs"
],
"dependencies": {
"@babel/runtime": "^7.18.6",
"@uiw/codemirror-themes": "4.25.11"
},
"keywords": [
Expand Down
2 changes: 2 additions & 0 deletions themes/copilot/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
"cjs"
],
"dependencies": {
"@babel/runtime": "^7.18.6",
"@lezer/highlight": "^1.0.0",
"@uiw/codemirror-themes": "4.25.11"
},
"keywords": [
Expand Down
2 changes: 2 additions & 0 deletions themes/darcula/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
"cjs"
],
"dependencies": {
"@babel/runtime": "^7.18.6",
"@lezer/highlight": "^1.0.0",
"@uiw/codemirror-themes": "4.25.11"
},
"keywords": [
Expand Down
2 changes: 2 additions & 0 deletions themes/dracula/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
"cjs"
],
"dependencies": {
"@babel/runtime": "^7.18.6",
"@lezer/highlight": "^1.0.0",
"@uiw/codemirror-themes": "4.25.11"
},
"keywords": [
Expand Down
2 changes: 2 additions & 0 deletions themes/duotone/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
"cjs"
],
"dependencies": {
"@babel/runtime": "^7.18.6",
"@lezer/highlight": "^1.0.0",
"@uiw/codemirror-themes": "4.25.11"
},
"keywords": [
Expand Down
2 changes: 2 additions & 0 deletions themes/eclipse/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
"cjs"
],
"dependencies": {
"@babel/runtime": "^7.18.6",
"@lezer/highlight": "^1.0.0",
"@uiw/codemirror-themes": "4.25.11"
},
"keywords": [
Expand Down
2 changes: 2 additions & 0 deletions themes/github/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
"cjs"
],
"dependencies": {
"@babel/runtime": "^7.18.6",
"@lezer/highlight": "^1.0.0",
"@uiw/codemirror-themes": "4.25.11"
},
"keywords": [
Expand Down
2 changes: 2 additions & 0 deletions themes/gruvbox/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
"cjs"
],
"dependencies": {
"@babel/runtime": "^7.18.6",
"@lezer/highlight": "^1.0.0",
"@uiw/codemirror-themes": "4.25.11"
},
"keywords": [
Expand Down
2 changes: 2 additions & 0 deletions themes/kimbie/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
"cjs"
],
"dependencies": {
"@babel/runtime": "^7.18.6",
"@lezer/highlight": "^1.0.0",
"@uiw/codemirror-themes": "4.25.11"
},
"keywords": [
Expand Down
2 changes: 2 additions & 0 deletions themes/material/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
"cjs"
],
"dependencies": {
"@babel/runtime": "^7.18.6",
"@lezer/highlight": "^1.0.0",
"@uiw/codemirror-themes": "4.25.11"
},
"keywords": [
Expand Down
2 changes: 2 additions & 0 deletions themes/monokai-dimmed/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
"cjs"
],
"dependencies": {
"@babel/runtime": "^7.18.6",
"@lezer/highlight": "^1.0.0",
"@uiw/codemirror-themes": "4.25.11"
},
"keywords": [
Expand Down
2 changes: 2 additions & 0 deletions themes/monokai/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
"cjs"
],
"dependencies": {
"@babel/runtime": "^7.18.6",
"@lezer/highlight": "^1.0.0",
"@uiw/codemirror-themes": "4.25.11"
},
"keywords": [
Expand Down
2 changes: 2 additions & 0 deletions themes/noctis-lilac/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
"cjs"
],
"dependencies": {
"@babel/runtime": "^7.18.6",
"@lezer/highlight": "^1.0.0",
"@uiw/codemirror-themes": "4.25.11"
},
"keywords": [
Expand Down
2 changes: 2 additions & 0 deletions themes/nord/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
"cjs"
],
"dependencies": {
"@babel/runtime": "^7.18.6",
"@lezer/highlight": "^1.0.0",
"@uiw/codemirror-themes": "4.25.11"
},
"keywords": [
Expand Down
2 changes: 2 additions & 0 deletions themes/okaidia/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
"cjs"
],
"dependencies": {
"@babel/runtime": "^7.18.6",
"@lezer/highlight": "^1.0.0",
"@uiw/codemirror-themes": "4.25.11"
},
"keywords": [
Expand Down
2 changes: 2 additions & 0 deletions themes/quietlight/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
"cjs"
],
"dependencies": {
"@babel/runtime": "^7.18.6",
"@lezer/highlight": "^1.0.0",
"@uiw/codemirror-themes": "4.25.11"
},
"keywords": [
Expand Down
2 changes: 2 additions & 0 deletions themes/red/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
"cjs"
],
"dependencies": {
"@babel/runtime": "^7.18.6",
"@lezer/highlight": "^1.0.0",
"@uiw/codemirror-themes": "4.25.11"
},
"keywords": [
Expand Down
2 changes: 2 additions & 0 deletions themes/solarized/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
"cjs"
],
"dependencies": {
"@babel/runtime": "^7.18.6",
"@lezer/highlight": "^1.0.0",
"@uiw/codemirror-themes": "4.25.11"
},
"keywords": [
Expand Down
2 changes: 2 additions & 0 deletions themes/sublime/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
"cjs"
],
"dependencies": {
"@babel/runtime": "^7.18.6",
"@lezer/highlight": "^1.0.0",
"@uiw/codemirror-themes": "4.25.11"
},
"keywords": [
Expand Down
2 changes: 2 additions & 0 deletions themes/tokyo-night-day/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
"cjs"
],
"dependencies": {
"@babel/runtime": "^7.18.6",
"@lezer/highlight": "^1.0.0",
"@uiw/codemirror-themes": "4.25.11"
},
"keywords": [
Expand Down
2 changes: 2 additions & 0 deletions themes/tokyo-night-storm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
"cjs"
],
"dependencies": {
"@babel/runtime": "^7.18.6",
"@lezer/highlight": "^1.0.0",
"@uiw/codemirror-themes": "4.25.11"
},
"keywords": [
Expand Down
2 changes: 2 additions & 0 deletions themes/tokyo-night/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
"cjs"
],
"dependencies": {
"@babel/runtime": "^7.18.6",
"@lezer/highlight": "^1.0.0",
"@uiw/codemirror-themes": "4.25.11"
},
"keywords": [
Expand Down
2 changes: 2 additions & 0 deletions themes/tomorrow-night-blue/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
"cjs"
],
"dependencies": {
"@babel/runtime": "^7.18.6",
"@lezer/highlight": "^1.0.0",
"@uiw/codemirror-themes": "4.25.11"
},
"keywords": [
Expand Down
2 changes: 2 additions & 0 deletions themes/vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
"cjs"
],
"dependencies": {
"@babel/runtime": "^7.18.6",
"@lezer/highlight": "^1.0.0",
"@uiw/codemirror-themes": "4.25.11"
},
"keywords": [
Expand Down
Loading
Loading