Skip to content

Commit 330906e

Browse files
committed
fix: Fix CI
1 parent 1a1a86d commit 330906e

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ jobs:
3535
- name: Discover submodules
3636
id: discover-submodules
3737
run: |
38+
sudo node ./scripts/generate-metadata.js
3839
sudo node ./scripts/discover-submodules.js > submodules.json
3940
cat submodules.json
4041

scripts/generate-metadata.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
const { execSync } = require('child_process');
2+
const path = require('path');
3+
const fs = require('fs');
4+
const GetPluginName = (pluginDir) => {
5+
const jsonPath = path.join(pluginDir, 'plugin.json');
6+
try {
7+
if (fs.existsSync(jsonPath)) {
8+
const pluginJson = JSON.parse(fs.readFileSync(jsonPath));
9+
return pluginJson.name;
10+
}
11+
}
12+
catch (error) {
13+
return null;
14+
}
15+
}
16+
const ParsePlugin = (pluginsDir, submodule) => {
17+
const submodulePath = path.join(pluginsDir, submodule);
18+
const pluginName = execSync(`git -C ${submodulePath} rev-list --max-parents=0 HEAD`, { encoding: 'utf-8' }).trim();
19+
if (fs.existsSync(path.join(submodulePath, '.git'))) {
20+
try {
21+
return { id: pluginName, commitId: execSync(`git -C ${submodulePath} rev-parse HEAD`, { encoding: 'utf-8' }).trim() };
22+
}
23+
catch (error) {
24+
return { id: pluginName, commitId: null };
25+
}
26+
}
27+
else {
28+
return { id: pluginName, commitId: null };
29+
}
30+
}
31+
const pluginsDir = path.resolve(process.cwd(), 'plugins');
32+
let pluginIds = [];
33+
if (fs.existsSync(pluginsDir)) {
34+
fs.readdirSync(pluginsDir).forEach(submodule => { pluginIds.push(ParsePlugin(pluginsDir, submodule)); });
35+
}
36+
// write JSON to metadata.json
37+
fs.writeFileSync(path.resolve(process.cwd(), 'metadata.json'), JSON.stringify(pluginIds, null, 4));

0 commit comments

Comments
 (0)