Skip to content

Commit 53bae0a

Browse files
committed
refactor: centralize plugin definitions and improve dynamic plugin discovery validation
1 parent 3436793 commit 53bae0a

5 files changed

Lines changed: 38 additions & 30 deletions

File tree

packages/core-node/src/handlers/plugins.ts

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -202,24 +202,16 @@ export const registerPluginsHandlers = (context: PipelabContext) => {
202202
const packagesDir = context.getPackagesPath();
203203
const rawInstalled = await findInstalledPlugins(packagesDir);
204204

205-
const DEFAULT_PLUGIN_IDS = [
206-
"construct",
207-
"filesystem",
208-
"system",
209-
"steam",
210-
"itch",
211-
"electron",
212-
"discord",
213-
"poki",
214-
"nvpatch",
215-
"tauri",
216-
"minify",
217-
"netlify",
218-
];
205+
const { DEFAULT_PLUGIN_IDS, DEV_ONLY_PLUGIN_IDS } = await import("@pipelab/shared");
206+
const defaultPluginIds = [...DEFAULT_PLUGIN_IDS];
207+
208+
if (isDev) {
209+
defaultPluginIds.push(...DEV_ONLY_PLUGIN_IDS);
210+
}
219211

220212
const installed = rawInstalled
221213
.filter((item) => {
222-
const isDefault = DEFAULT_PLUGIN_IDS.some((id) => item.name === `@pipelab/plugin-${id}`);
214+
const isDefault = defaultPluginIds.some((id) => item.name === `@pipelab/plugin-${id}`);
223215
return !isDefault;
224216
})
225217
.map((item) => ({

packages/core-node/src/plugins-registry.ts

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,11 @@ export async function findInstalledPlugins(
172172
try {
173173
const content = await readFile(join(dir, "package.json"), "utf8");
174174
const pkg = JSON.parse(content);
175-
if (pkg.name && pkg.name !== "pnpm") {
175+
if (
176+
pkg.name &&
177+
pkg.name !== "pnpm" &&
178+
(pkg.pipelab || (pkg.keywords && pkg.keywords.includes("pipelab-plugin")))
179+
) {
176180
installed.push({
177181
name: pkg.name,
178182
version: pkg.version || "0.0.0",
@@ -222,20 +226,12 @@ export const builtInPlugins = async (options: { context: PipelabContext }): Prom
222226
const pluginsToLoad = new Map<string, string>(); // packageName -> version
223227

224228
// Load default/native plugins by default
225-
const defaultPlugins = [
226-
"@pipelab/plugin-construct",
227-
"@pipelab/plugin-filesystem",
228-
"@pipelab/plugin-system",
229-
"@pipelab/plugin-steam",
230-
"@pipelab/plugin-itch",
231-
"@pipelab/plugin-electron",
232-
"@pipelab/plugin-discord",
233-
"@pipelab/plugin-poki",
234-
"@pipelab/plugin-nvpatch",
235-
"@pipelab/plugin-tauri",
236-
"@pipelab/plugin-minify",
237-
"@pipelab/plugin-netlify",
238-
];
229+
const { DEFAULT_PLUGIN_IDS, DEV_ONLY_PLUGIN_IDS } = await import("@pipelab/shared");
230+
const defaultPlugins = [...DEFAULT_PLUGIN_IDS].map((id) => `@pipelab/plugin-${id}`);
231+
232+
if (isDev) {
233+
defaultPlugins.push(...DEV_ONLY_PLUGIN_IDS.map((id) => `@pipelab/plugin-${id}`));
234+
}
239235
for (const name of defaultPlugins) {
240236
pluginsToLoad.set(name, "latest");
241237
}

packages/shared/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ export * from "./ipc.types";
5050
export * from "./logger";
5151
export * from "./model";
5252
export * from "./plugins";
53+
export * from "./plugins-list";
5354
export * from "./plugins/definitions"; // <-- RE-ADDED
5455
export * from "./quickjs";
5556
export * from "./save-location";
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
export const DEFAULT_PLUGIN_IDS = [
2+
"construct",
3+
"filesystem",
4+
"system",
5+
"steam",
6+
"itch",
7+
"electron",
8+
"discord",
9+
"poki",
10+
"nvpatch",
11+
"netlify",
12+
];
13+
14+
export const DEV_ONLY_PLUGIN_IDS = [
15+
"tauri",
16+
"minify",
17+
];

plugins/plugin-construct/src/export-shared.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,8 @@ export const exportc3p = async <ACTION extends Action>(
215215
const pathsToCopy = [
216216
"https_editor.construct.net_0.indexeddb.blob",
217217
"https_editor.construct.net_0.indexeddb.leveldb",
218+
"https_preview.construct.net_0.indexeddb.leveldb",
219+
"https_account.construct.net_0.indexeddb.leveldb",
218220
];
219221

220222
for (const p of pathsToCopy) {

0 commit comments

Comments
 (0)