-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
976 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
{ | ||
"name": "暗黑模式", | ||
"preview": "#000", | ||
"author": "猫头猫", | ||
"description": "暗黑模式,好黑啊。" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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": "猫头猫" | ||
} |
Oops, something went wrong.