Skip to content

Commit

Permalink
feat: update scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
maotoumao committed Jun 1, 2024
1 parent 4402b0a commit c43c188
Show file tree
Hide file tree
Showing 20 changed files with 976 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
File renamed without changes
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
1 change: 1 addition & 0 deletions .publish/publish.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"publishName":"birds-of-a-feather-3f72ef18cc9a29f805e1dc8f6260d64d","packageName":"birds-of-a-feather","config":{"name":"飞鸟","preview":"@/imgs/preview.png","author":"猫头猫","iframe":{"app":"@/iframes/app.html"}}},{"publishName":"darkmode-32c031e1c795f39cbdb53b9674efd12a","packageName":"darkmode","config":{"name":"暗黑模式","preview":"#000","author":"猫头猫","description":"暗黑模式,好黑啊。"}},{"publishName":"fliqlo-4c902e5cc42a4ffeeae240c79df768e9","packageName":"fliqlo","config":{"name":"fliqlo","preview":"@/imgs/preview.png","description":"类似fliqlo的效果","author":"猫头猫","iframe":{"app":"@/iframes/app.html"}}},{"publishName":"night-star-08c37b62da7647b0f5ce542ffa8579ae","packageName":"night-star","config":{"name":"星夜","preview":"@/assets/night_sky_stars_linear_gradient_hd_8k_anime_style_8013dbdf-270b-4f00-b981-5745e056aae3.png","description":"背景图片","author":"猫头猫"}},{"publishName":"rainy-season-28907caafdae22596cc6f221b02b4778","packageName":"rainy-season","config":{"name":"雨季","preview":"@/imgs/preview.png","iframe":{"app":"@/iframes/app.html"},"author":"猫头猫"}},{"publishName":"sakura-34687ebc448460b868445b8677e0f2c1","packageName":"sakura","config":{"name":"樱花","preview":"@/imgs/preview.png","iframe":{"app":"@/iframes/app.html"},"author":"猫头猫"}}]
Binary file not shown.
Binary file not shown.
59 changes: 59 additions & 0 deletions .scripts/publish.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import { createWriteStream } from 'fs';
import fs from 'fs/promises';
import archiver from 'archiver';
import { rimraf } from 'rimraf';
import CryptoJS from 'crypto-js';

const exceptionFolders = ['node_modules'];

async function publish() {
await rimraf('./.publish/*', {
'glob': true
});

const validFolders = (await fs.readdir('.', {
'withFileTypes': true
})).filter(it => it.isDirectory() && !it.name.startsWith('.') && !exceptionFolders.includes(it.name)).sort((a, b) => a.name.localeCompare(b.name));
const themeConfigs = await Promise.all(validFolders.map(async folder => {
try {
const configFile = await fs.readFile(`./${folder.name}/config.json`);

const hash = CryptoJS.MD5(`./${folder.name}/config.json`).toString();

const archive = archiver('zip');
const outputName = `${folder.name}-${hash}`;
const outputPath = `./.publish/${outputName}.mftheme`
const output = createWriteStream(outputPath);
const promise = new Promise((resolve, reject) => {
archive.on('end', resolve);
archive.on('close', resolve);
archive.on('error', reject);
});


archive.pipe(output);
archive.directory(`./${folder.name}`, false);
archive.finalize();
await promise;

const config = JSON.parse(configFile);

return {
publishName: outputName,
packageName: folder.name,
config,
}

} catch(e) {
// ignore
console.log(2, e)
return null;
}
}))
await fs.writeFile('./.publish/publish.json', JSON.stringify(themeConfigs), 'utf-8');

console.log("Publish Done");

}

publish();
1 change: 1 addition & 0 deletions birds-of-a-feather/config.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "飞鸟",
"preview": "@/imgs/preview.png",
"author": "猫头猫",
"iframe": {
"app": "@/iframes/app.html"
}
Expand Down
1 change: 1 addition & 0 deletions darkmode/config.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"name": "暗黑模式",
"preview": "#000",
"author": "猫头猫",
"description": "暗黑模式,好黑啊。"
}
1 change: 1 addition & 0 deletions fliqlo/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "fliqlo",
"preview": "@/imgs/preview.png",
"description": "类似fliqlo的效果",
"author": "猫头猫",
"iframe": {
"app": "@/iframes/app.html"
}
Expand Down
Binary file removed image.png
Binary file not shown.
3 changes: 2 additions & 1 deletion night-star/config.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"name": "星夜",
"preview": "@/assets/night_sky_stars_linear_gradient_hd_8k_anime_style_8013dbdf-270b-4f00-b981-5745e056aae3.png",
"description": "背景图片"
"description": "背景图片",
"author": "猫头猫"
}
Loading

0 comments on commit c43c188

Please sign in to comment.