-
-
Notifications
You must be signed in to change notification settings - Fork 101
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
4 changed files
with
41 additions
and
34 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,37 @@ | ||
import {readdirSync, writeFileSync, readFileSync} from "node:fs"; | ||
import {join, dirname} from "node:path"; | ||
import {fileURLToPath} from "node:url"; | ||
|
||
const __filename = fileURLToPath(import.meta.url); | ||
const __dirname = dirname(__filename); | ||
|
||
const root = join(__dirname, "../.."); | ||
const pluginsDir = join(root, "./plugins"); | ||
|
||
|
||
const plugins = readdirSync(pluginsDir, {withFileTypes: true}); | ||
|
||
const meta = JSON.parse(readFileSync(join(root, 'meta.json'), {encoding: "utf8"})); | ||
|
||
const pluginsIndex = { | ||
...meta, | ||
plugins: [], | ||
}; | ||
|
||
const list = []; | ||
plugins.forEach((file) => { | ||
if (file.isFile()) { | ||
const data = readFileSync(join(pluginsDir, file.name), {encoding: "utf8"}); | ||
// 校验 | ||
const plugin = JSON.parse(data); | ||
|
||
// 校验 | ||
list.push(plugin); | ||
} | ||
}); | ||
|
||
pluginsIndex.plugins = list.sort((a, b) => new Date(b.createAt) - new Date(a.createAt)); | ||
|
||
writeFileSync(join(root, "./index.json"), JSON.stringify(pluginsIndex, null, 2), { | ||
encoding: "utf8", | ||
}); |
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,3 @@ | ||
{ | ||
"version": 1 | ||
} |
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 was deleted.
Oops, something went wrong.