Skip to content

Commit 86ca016

Browse files
committed
Some changes
1 parent 8f9fb4c commit 86ca016

2 files changed

Lines changed: 18 additions & 4 deletions

File tree

.github/scripts/extract-classnames.js

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,27 @@ function traverseDir(dir) {
1919
const regex = /className\(["'`](.*?)["'`]\)/g;
2020
let match;
2121
while ((match = regex.exec(content)) !== null) {
22-
collected.add("ste-" + match[1].replaceAll(" ", "-"));
22+
collected.add({
23+
className: "ste-" + match[1].replaceAll(" ", "-"),
24+
features: [
25+
dir.split("/features/")[1].split("/")[0].replaceAll(".js", ""),
26+
],
27+
});
2328
}
2429
}
2530
}
2631
}
2732

2833
traverseDir(rootDir);
2934

30-
// Write results
31-
fs.writeFileSync(outputFile, JSON.stringify([...collected], null, 2));
32-
console.log(`✅ Extracted ${collected.size} class names to ${outputFile}`);
35+
const mergedFeatures = Object.values(
36+
[...collected].reduce((acc, item) => {
37+
if (!acc[item.className]) {
38+
acc[item.className] = { className: item.className, features: new Set() };
39+
}
40+
item.features.forEach(f => acc[item.className].features.add(f));
41+
return acc;
42+
}, {})
43+
).map(obj => ({ className: obj.className, features: [...obj.features] }));
44+
45+
fs.writeFileSync(outputFile, JSON.stringify(mergedFeatures, null, 2));

.github/workflows/extract-classnames.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ on:
88

99
jobs:
1010
extract:
11+
if: github.repository == 'STForScratch/ScratchTools'
1112
runs-on: ubuntu-latest
1213

1314
steps:

0 commit comments

Comments
 (0)