@pipelab/core-node 1.0.1-beta.29 → 1.0.1-beta.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pipelab/core-node",
3
- "version": "1.0.1-beta.29",
3
+ "version": "1.0.1-beta.31",
4
4
  "private": false,
5
5
  "description": "The Pipelab automation engine for Node.js",
6
6
  "license": "FSL-1.1-MIT",
@@ -39,8 +39,8 @@
39
39
  "type-fest": "4.39.0",
40
40
  "ws": "8.18.3",
41
41
  "yauzl": "2.10.0",
42
- "@pipelab/constants": "1.0.1-beta.25",
43
- "@pipelab/shared": "2.0.1-beta.26"
42
+ "@pipelab/constants": "1.0.1-beta.27",
43
+ "@pipelab/shared": "2.0.1-beta.28"
44
44
  },
45
45
  "devDependencies": {
46
46
  "@types/adm-zip": "0.5.7",
@@ -53,7 +53,7 @@
53
53
  "@types/yauzl": "2.10.3",
54
54
  "tsdown": "0.21.2",
55
55
  "typescript": "^5.0.0",
56
- "@pipelab/tsconfig": "1.0.1-beta.25"
56
+ "@pipelab/tsconfig": "1.0.1-beta.27"
57
57
  },
58
58
  "scripts": {
59
59
  "build": "tsdown",
@@ -20,39 +20,41 @@ const DEFAULT_PLUGIN_IDS = [
20
20
  "netlify",
21
21
  ];
22
22
 
23
- export const builtInPlugins = async (options: { context: PipelabContext }) => {
24
- console.log("[Plugins] Finalizing default plugins list...");
25
- const promises = DEFAULT_PLUGIN_IDS.map(async (id) => {
26
- try {
27
- const packageName = `@pipelab/plugin-${id}`;
28
- // console.log(`[Plugins] [${id}] Attempting to resolve...`);
23
+ export const loadPipelabPlugin = async (id: string, options: { context: PipelabContext }) => {
24
+ try {
25
+ const packageName = `@pipelab/plugin-${id}`;
26
+ const { packageDir, entryPoint } = await fetchPipelabPlugin(packageName, "latest", {
27
+ context: options.context,
28
+ installDeps: true,
29
+ });
29
30
 
30
- const { packageDir, entryPoint } = await fetchPipelabPlugin(packageName, "latest", {
31
- context: options.context,
32
- });
33
-
34
- console.log(`[Plugins] [${id}] Attempting to import from: ${entryPoint}`);
35
- if (!existsSync(entryPoint)) {
36
- console.error(`[Plugins] [${id}] CRITICAL: Plugin entry point not found at ${entryPoint}`);
37
- // Optionally list files in the directory to see what's there
38
- try {
39
- const files = await readdir(packageDir, { recursive: true });
40
- console.log(`[Plugins] [${id}] Directory contents:`, files);
41
- } catch (e) {}
42
- }
31
+ console.log(`[Plugins] [${id}] Attempting to import from: ${entryPoint}`);
32
+ if (!existsSync(entryPoint)) {
33
+ console.error(`[Plugins] [${id}] CRITICAL: Plugin entry point not found at ${entryPoint}`);
34
+ try {
35
+ const files = await readdir(packageDir, { recursive: true });
36
+ console.log(`[Plugins] [${id}] Directory contents:`, files);
37
+ } catch (e) { }
38
+ }
43
39
 
44
- const pluginModule = await import(pathToFileURL(entryPoint).href);
45
- console.log(`[Plugins] [${id}] Successfully loaded from: ${packageDir}`);
46
- return pluginModule.default;
47
- } catch (e: any) {
48
- console.error(`[Plugins] [${id}] CRITICAL: Failed to load:`, e);
49
- if (e.code === "ERR_MODULE_NOT_FOUND") {
50
- console.error(
51
- `[Plugins] [${id}] This usually means a dependency is missing in the plugin's node_modules.`,
52
- );
53
- }
54
- return null;
40
+ const pluginModule = await import(pathToFileURL(entryPoint).href);
41
+ console.log(`[Plugins] [${id}] Successfully loaded from: ${packageDir}`);
42
+ return pluginModule.default;
43
+ } catch (e: any) {
44
+ console.error(`[Plugins] [${id}] CRITICAL: Failed to load:`, e);
45
+ if (e.code === "ERR_MODULE_NOT_FOUND") {
46
+ console.error(
47
+ `[Plugins] [${id}] This usually means a dependency is missing in the plugin's node_modules.`,
48
+ );
55
49
  }
50
+ return null;
51
+ }
52
+ };
53
+
54
+ export const builtInPlugins = async (options: { context: PipelabContext }) => {
55
+ console.log("[Plugins] Finalizing default plugins list...");
56
+ const promises = DEFAULT_PLUGIN_IDS.map(async (id) => {
57
+ return loadPipelabPlugin(id, options);
56
58
  });
57
59
 
58
60
  const plugins = await Promise.all(promises);
@@ -190,18 +190,18 @@ export async function ensurePNPM(version = "10.12.0", options: { context: Pipela
190
190
  async function installDependencies(packageDir: string, packageName: string, options: FetchOptions) {
191
191
  const nodeModulesPath = join(packageDir, "node_modules");
192
192
 
193
- // Check if node_modules already exists and has content
194
193
  if (existsSync(nodeModulesPath)) {
195
194
  try {
196
195
  const files = await readdir(nodeModulesPath);
197
- if (files.length > 0) return;
198
- console.warn(`[Fetcher] ${packageName}: node_modules exists but is empty. Re-installing...`);
196
+ if (files.length === 0) {
197
+ console.warn(`[Fetcher] ${packageName}: node_modules exists but is empty. Re-installing...`);
198
+ }
199
199
  } catch (e) {
200
200
  // Continue to install if readdir fails
201
201
  }
202
202
  }
203
203
 
204
- console.log(`[Fetcher] ${packageName}: Installing dependencies...`);
204
+ console.log(`[Fetcher] ${packageName}: Ensuring dependencies are installed...`);
205
205
  try {
206
206
  const { all } = await runPnpm(packageDir, {
207
207
  signal: options.signal,
package/src/utils.ts CHANGED
@@ -15,7 +15,8 @@ import type { BuildHistoryEntry } from "@pipelab/shared";
15
15
  import type { Variable } from "@pipelab/shared";
16
16
 
17
17
  import { ensure, generateTempFolder, extractTarGz, extractZip, zipFolder } from "./utils/fs-extras";
18
- import { fetchPipelabAsset, fetchPipelabPlugin } from "./utils/remote";
18
+ import { fetchPipelabAsset } from "./utils/remote";
19
+ import { loadPipelabPlugin } from "./plugins-registry";
19
20
  import { setupConfigFile } from "./config";
20
21
  import { AppConfig } from "@pipelab/shared";
21
22
 
@@ -139,19 +140,13 @@ export const executeGraphWithHistory = async ({
139
140
  const isRegistered = registeredPlugins.value.some((p) => p.id === pluginId);
140
141
  if (!isRegistered) {
141
142
  logger().info(`[Runner] Plugin "${pluginId}" not found, attempting to load...`);
142
- try {
143
- const packageName = `@pipelab/plugin-${pluginId}`;
144
-
145
- const { packageDir, entryPoint } = await fetchPipelabPlugin(packageName, "latest", {
146
- context: ctx,
147
- });
148
- const pluginModule = await import(pathToFileURL(entryPoint).href);
149
- const pluginDefinition = pluginModule.default;
143
+ const pluginDefinition = await loadPipelabPlugin(pluginId, { context: ctx });
150
144
 
145
+ if (pluginDefinition) {
151
146
  registerPlugins([pluginDefinition]);
152
147
  logger().info(`[Runner] Plugin "${pluginId}" loaded and registered successfully`);
153
- } catch (e) {
154
- logger().error(`[Runner] Failed to load or register plugin "${pluginId}":`, e);
148
+ } else {
149
+ logger().error(`[Runner] Failed to load or register plugin "${pluginId}"`);
155
150
  }
156
151
  }
157
152
  }