Skip to content

Commit f647d1b

Browse files
committed
updated yml file
1 parent df3f315 commit f647d1b

1 file changed

Lines changed: 26 additions & 7 deletions

File tree

.github/workflows/tag.yml

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
- name: Setup Node
2525
uses: actions/setup-node@v4
2626
with:
27-
node-version: 20
27+
node-version: 22
2828

2929
- name: Install dependencies
3030
run: npm install terser clean-css
@@ -45,29 +45,28 @@ jobs:
4545
const files = fs.readdirSync(".").filter(f => {
4646
if (fs.statSync(f).isDirectory()) return false;
4747
if (f.startsWith(".")) return false;
48-
if (f.includes(".min.")) return false;
49-
if (["README.md", "LICENSE"].includes(f)) return false;
50-
if (f.endsWith(".html")) return false;
5148
return true;
5249
});
5350
51+
// detect main file (framework or component)
5452
const mainFile =
5553
files.find(f => f === "ccm.js") ||
5654
files.find(f => /^ccm\.[a-z0-9_]+\.mjs$/.test(f));
5755
5856
for (const file of files) {
5957
6058
const ext = file.split(".").pop();
59+
6160
if (!["js", "mjs", "css"].includes(ext)) continue;
6261
6362
let content = fs.readFileSync(file, "utf-8");
6463
65-
// Replace local paths
64+
// replace local paths
6665
content = content.replaceAll("././", BASE_URL);
6766
6867
let outputName = file;
6968
70-
// Version main file
69+
// rename main file with version
7170
if (file === mainFile) {
7271
if (file.endsWith(".mjs")) {
7372
outputName = file.replace(".mjs", `-${VERSION}.mjs`);
@@ -76,7 +75,7 @@ jobs:
7675
}
7776
}
7877
79-
// JS / MJS minify
78+
// JS / MJS minify + source map
8079
if (ext === "js" || ext === "mjs") {
8180
const result = await minify(content, {
8281
sourceMap: {
@@ -99,6 +98,26 @@ jobs:
9998
fs.writeFileSync(minName, minified);
10099
}
101100
}
101+
102+
// 🔥 CLEANUP: keep ONLY .min.* and .map
103+
const all = fs.readdirSync(".");
104+
105+
for (const file of all) {
106+
107+
if (file.startsWith(".")) {
108+
fs.rmSync(file, { recursive: true, force: true });
109+
continue;
110+
}
111+
112+
const ext = file.split(".").pop();
113+
const isMin = file.includes(".min.");
114+
const isMap = ext === "map";
115+
116+
if (!isMin && !isMap) {
117+
fs.rmSync(file, { recursive: true, force: true });
118+
}
119+
}
120+
102121
EOF
103122
env:
104123
VERSION: ${{ github.event.inputs.version }}

0 commit comments

Comments
 (0)