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
32 changes: 32 additions & 0 deletions .github/scripts/extract-classnames.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
const fs = require("fs");
const path = require("path");

const rootDir = path.resolve(__dirname, "../../features");
const outputFile = path.resolve(__dirname, "../../class-names.json");

let collected = new Set();

function traverseDir(dir) {
const files = fs.readdirSync(dir);
for (const file of files) {
const fullPath = path.join(dir, file);
const stat = fs.statSync(fullPath);

if (stat.isDirectory()) {
traverseDir(fullPath);
} else if (stat.isFile() && file.endsWith(".js")) {
const content = fs.readFileSync(fullPath, "utf-8");
const regex = /className\(["'`](.*?)["'`]\)/g;
let match;
while ((match = regex.exec(content)) !== null) {
collected.add("ste-" + match[1].replaceAll(" ", "-"));
}
}
}
}

traverseDir(rootDir);

// Write results
fs.writeFileSync(outputFile, JSON.stringify([...collected], null, 2));
console.log(`✅ Extracted ${collected.size} class names to ${outputFile}`);
30 changes: 30 additions & 0 deletions .github/workflows/extract-classnames.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Extract Class Names

on:
push:
paths:
- "features/**.js"
workflow_dispatch:

jobs:
extract:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 20

- name: Run extraction script
run: node .github/scripts/extract-classnames.js

- name: Commit and push updated class-names.json
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add class-names.json
git commit -m "Update class-names.json" || echo "No changes"
git push
6 changes: 6 additions & 0 deletions api/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ function scratchClass(name) {
}
}

function className(name) {
return "ste-" + name.toLowerCase().replaceAll(" ", "-")
}

ScratchTools.modules.forEach(async function (script) {
var feature = await import(ScratchTools.dir + "/api/feature/index.js");
var shouldBeRun = true;
Expand All @@ -41,6 +45,7 @@ ScratchTools.modules.forEach(async function (script) {
fun.default({
feature: featureGenerated,
scratchClass,
className,
console: {
log: function (content) {
ste.console.log(content, script.feature.id);
Expand Down Expand Up @@ -78,6 +83,7 @@ ScratchTools.injectModule = async function (script) {
fun.default({
feature: featureGenerated,
scratchClass,
className,
console: {
log: function (content) {
ste.console.log(content, script.feature.id);
Expand Down
1 change: 1 addition & 0 deletions class-names.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]