Skip to content

Commit

Permalink
feat: update version to v1
Browse files Browse the repository at this point in the history
  • Loading branch information
arvinxx committed Aug 18, 2023
1 parent 2cc971f commit aa04ad6
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 34 deletions.
37 changes: 37 additions & 0 deletions .github/scripts/buildIndex.mjs
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",
});
3 changes: 3 additions & 0 deletions meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"version": 1
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"index.json"
],
"scripts": {
"build": "node ./scripts/buildIndex.mjs"
"build": "node .github/scripts/buildIndex.mjs"
},
"publishConfig": {
"access": "public",
Expand Down
33 changes: 0 additions & 33 deletions scripts/buildIndex.mjs

This file was deleted.

0 comments on commit aa04ad6

Please sign in to comment.