diff options
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/build/common.mjs | 5 | ||||
-rw-r--r-- | scripts/generatePluginList.ts | 20 |
2 files changed, 18 insertions, 7 deletions
diff --git a/scripts/build/common.mjs b/scripts/build/common.mjs index 24518fa..a6b170a 100644 --- a/scripts/build/common.mjs +++ b/scripts/build/common.mjs @@ -64,7 +64,7 @@ export const globPlugins = kind => ({ }); build.onLoad({ filter, namespace: "import-plugins" }, async () => { - const pluginDirs = ["plugins", "userplugins"]; + const pluginDirs = ["plugins/_api", "plugins/_core", "plugins", "userplugins"]; let code = ""; let plugins = "\n"; let i = 0; @@ -72,8 +72,9 @@ export const globPlugins = kind => ({ if (!existsSync(`./src/${dir}`)) continue; const files = await readdir(`./src/${dir}`); for (const file of files) { - if (file.startsWith(".")) continue; + if (file.startsWith("_") || file.startsWith(".")) continue; if (file === "index.ts") continue; + const fileBits = file.split("."); if (fileBits.length > 2 && ["ts", "tsx"].includes(fileBits.at(-1))) { const mod = fileBits.at(-2); diff --git a/scripts/generatePluginList.ts b/scripts/generatePluginList.ts index 87c32ab..70dc142 100644 --- a/scripts/generatePluginList.ts +++ b/scripts/generatePluginList.ts @@ -171,8 +171,8 @@ async function parseFile(fileName: string) { throw fail("no default export called 'definePlugin' found"); } -async function getEntryPoint(dirent: Dirent) { - const base = join("./src/plugins", dirent.name); +async function getEntryPoint(dir: string, dirent: Dirent) { + const base = join(dir, dirent.name); if (!dirent.isDirectory()) return base; for (const name of ["index.ts", "index.tsx"]) { @@ -186,13 +186,23 @@ async function getEntryPoint(dirent: Dirent) { throw new Error(`${dirent.name}: Couldn't find entry point`); } +function isPluginFile({ name }: { name: string; }) { + if (name === "index.ts") return false; + return !name.startsWith("_") && !name.startsWith("."); +} + (async () => { parseDevs(); - const plugins = readdirSync("./src/plugins", { withFileTypes: true }).filter(d => d.name !== "index.ts"); - const promises = plugins.map(async dirent => parseFile(await getEntryPoint(dirent))); + const plugins = ["src/plugins", "src/plugins/_core"].flatMap(dir => + readdirSync(dir, { withFileTypes: true }) + .filter(isPluginFile) + .map(async dirent => + parseFile(await getEntryPoint(dir, dirent)) + ) + ); - const data = JSON.stringify(await Promise.all(promises)); + const data = JSON.stringify(await Promise.all(plugins)); if (process.argv.length > 2) { writeFileSync(process.argv[2], data); |