@pipelab/plugin-core 1.0.1-beta.15 → 1.0.1-beta.19
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/CHANGELOG.md +32 -0
- package/dist/index.cjs +64 -109
- package/dist/index.d.cts +39 -78
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +39 -78
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +21 -105
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -5
- package/src/pipelab.ts +62 -79
- package/src/utils.ts +17 -167
package/dist/index.mjs
CHANGED
|
@@ -2,13 +2,11 @@ import { o as debugLog, t as QuickJSEmscriptenModuleError } from "./chunk-JTKJZQ
|
|
|
2
2
|
import { hostname } from "os";
|
|
3
3
|
import { normalize } from "path";
|
|
4
4
|
import { formatWithOptions, types } from "util";
|
|
5
|
-
import {
|
|
6
|
-
import { dirname, join } from "node:path";
|
|
5
|
+
import { PipelabContext, downloadFile, fetchPackage, fetchPipelabAsset, fetchPipelabCli, fetchPipelabPlugin, runPnpm, runWithLiveLogs } from "@pipelab/core-node";
|
|
7
6
|
import { access, mkdir, mkdtemp, realpath, writeFile } from "node:fs/promises";
|
|
8
|
-
import {
|
|
9
|
-
import { pipeline } from "node:stream/promises";
|
|
10
|
-
import pacote from "pacote";
|
|
7
|
+
import { dirname, join } from "node:path";
|
|
11
8
|
import { tmpdir } from "node:os";
|
|
9
|
+
import { createWriteStream } from "node:fs";
|
|
12
10
|
import tar from "tar";
|
|
13
11
|
import yauzl from "yauzl";
|
|
14
12
|
import archiver from "archiver";
|
|
@@ -2376,7 +2374,12 @@ const AppSettingsValidatorV7 = object({
|
|
|
2376
2374
|
id: string(),
|
|
2377
2375
|
name: string(),
|
|
2378
2376
|
url: string()
|
|
2379
|
-
}))
|
|
2377
|
+
})),
|
|
2378
|
+
buildHistory: object({ retentionPolicy: object({
|
|
2379
|
+
enabled: boolean(),
|
|
2380
|
+
maxEntries: number(),
|
|
2381
|
+
maxAge: number()
|
|
2382
|
+
}) })
|
|
2380
2383
|
});
|
|
2381
2384
|
const AppSettingsValidator = AppSettingsValidatorV7;
|
|
2382
2385
|
//#endregion
|
|
@@ -64287,113 +64290,16 @@ const createPlugin = (plugin) => {
|
|
|
64287
64290
|
return plugin;
|
|
64288
64291
|
};
|
|
64289
64292
|
//#endregion
|
|
64290
|
-
//#region src/custom-errors.ts
|
|
64291
|
-
var ExternalCommandError = class ExternalCommandError extends Error {
|
|
64292
|
-
code;
|
|
64293
|
-
constructor(message, code) {
|
|
64294
|
-
super(message);
|
|
64295
|
-
this.code = code;
|
|
64296
|
-
Object.setPrototypeOf(this, ExternalCommandError.prototype);
|
|
64297
|
-
}
|
|
64298
|
-
};
|
|
64299
|
-
//#endregion
|
|
64300
64293
|
//#region src/utils.ts
|
|
64301
64294
|
const fileExists = async (path) => {
|
|
64302
64295
|
try {
|
|
64296
|
+
const { access } = await import("node:fs/promises");
|
|
64303
64297
|
await access(path);
|
|
64304
64298
|
return true;
|
|
64305
64299
|
} catch {
|
|
64306
64300
|
return false;
|
|
64307
64301
|
}
|
|
64308
64302
|
};
|
|
64309
|
-
const runWithLiveLogs = async (command, args, execaOptions, log, hooks, abortSignal) => {
|
|
64310
|
-
console.log("command: ", command, args.join(" "));
|
|
64311
|
-
const subprocess = execa(command, args, {
|
|
64312
|
-
...execaOptions,
|
|
64313
|
-
stdout: "pipe",
|
|
64314
|
-
stderr: "pipe",
|
|
64315
|
-
stdin: "pipe",
|
|
64316
|
-
env: {
|
|
64317
|
-
...process.env,
|
|
64318
|
-
...execaOptions.env,
|
|
64319
|
-
TERM: "xterm-256color",
|
|
64320
|
-
FORCE_STDERR_LOGGING: "1"
|
|
64321
|
-
},
|
|
64322
|
-
cancelSignal: abortSignal
|
|
64323
|
-
});
|
|
64324
|
-
hooks?.onCreated?.(subprocess);
|
|
64325
|
-
subprocess.stdout?.on("data", (data) => {
|
|
64326
|
-
hooks?.onStdout?.(data.toString(), subprocess);
|
|
64327
|
-
});
|
|
64328
|
-
subprocess.stderr?.on("data", (data) => {
|
|
64329
|
-
hooks?.onStderr?.(data.toString(), subprocess);
|
|
64330
|
-
});
|
|
64331
|
-
try {
|
|
64332
|
-
const { exitCode } = await subprocess;
|
|
64333
|
-
hooks?.onExit?.(exitCode ?? 0);
|
|
64334
|
-
} catch (error) {
|
|
64335
|
-
const code = error.exitCode ?? 1;
|
|
64336
|
-
hooks?.onExit?.(code);
|
|
64337
|
-
throw new ExternalCommandError(error.message, code);
|
|
64338
|
-
}
|
|
64339
|
-
};
|
|
64340
|
-
/**
|
|
64341
|
-
* Downloads a file from a given URL to a specified local path with progress tracking.
|
|
64342
|
-
*
|
|
64343
|
-
* @param url - The URL of the file to download.
|
|
64344
|
-
* @param localPath - The local file path to save the downloaded file.
|
|
64345
|
-
* @returns A promise that resolves when the file is downloaded.
|
|
64346
|
-
*/
|
|
64347
|
-
const downloadFile = async (url, localPath, hooks, abortSignal) => {
|
|
64348
|
-
const response = await fetch(url, { signal: abortSignal });
|
|
64349
|
-
if (!response.ok) throw new Error(`Failed to fetch file: ${response.statusText}`);
|
|
64350
|
-
const contentLength = response.headers.get("content-length");
|
|
64351
|
-
if (!contentLength) throw new Error("Content-Length header is missing");
|
|
64352
|
-
const totalSize = parseInt(contentLength, 10);
|
|
64353
|
-
let downloadedSize = 0;
|
|
64354
|
-
const fileStream = createWriteStream(localPath);
|
|
64355
|
-
const progressStream = new TransformStream({ transform(chunk, controller) {
|
|
64356
|
-
downloadedSize += chunk.length;
|
|
64357
|
-
const progress = downloadedSize / totalSize * 100;
|
|
64358
|
-
if (hooks?.onProgress) hooks.onProgress({
|
|
64359
|
-
progress,
|
|
64360
|
-
downloadedSize
|
|
64361
|
-
});
|
|
64362
|
-
controller.enqueue(chunk);
|
|
64363
|
-
} });
|
|
64364
|
-
const readable = response.body?.pipeThrough(progressStream);
|
|
64365
|
-
if (!readable) throw new Error("Failed to create a readable stream");
|
|
64366
|
-
await pipeline(readable, fileStream);
|
|
64367
|
-
};
|
|
64368
|
-
/**
|
|
64369
|
-
* Installs an NPM package from the npm registry as a tarball if not already present.
|
|
64370
|
-
* @param thirdpartyDir The directory where third-party tools are stored.
|
|
64371
|
-
* @param name The name of the package (e.g., 'pnpm' or '@poki/cli').
|
|
64372
|
-
* @param version The version of the package.
|
|
64373
|
-
* @param options (Optional) configuration for dependency installation.
|
|
64374
|
-
* @returns A Promise that resolves to the path of the extracted package (the 'package' subfolder).
|
|
64375
|
-
*/
|
|
64376
|
-
const ensureNPMPackage = async (thirdpartyDir, name, version, options) => {
|
|
64377
|
-
const packageDir = join(thirdpartyDir, name, version);
|
|
64378
|
-
const finalPath = join(packageDir, "package");
|
|
64379
|
-
if (await fileExists(finalPath)) return finalPath;
|
|
64380
|
-
console.log(`NPM package ${name}@${version} not found at ${finalPath}, installing...`);
|
|
64381
|
-
console.log(`Extracting ${name}@${version} to ${finalPath}...`);
|
|
64382
|
-
await mkdir(packageDir, { recursive: true });
|
|
64383
|
-
await pacote.extract(`${name}@${version}`, finalPath);
|
|
64384
|
-
if (options?.installDeps && options.pnpmPath) {
|
|
64385
|
-
console.log(`Installing dependencies for ${name}@${version} using pnpm at ${options.pnpmPath}...`);
|
|
64386
|
-
await execa(options.nodePath || process.execPath, [
|
|
64387
|
-
options.pnpmPath,
|
|
64388
|
-
"install",
|
|
64389
|
-
"--prod"
|
|
64390
|
-
], {
|
|
64391
|
-
cwd: finalPath,
|
|
64392
|
-
stdio: "inherit"
|
|
64393
|
-
});
|
|
64394
|
-
}
|
|
64395
|
-
return finalPath;
|
|
64396
|
-
};
|
|
64397
64303
|
//#endregion
|
|
64398
64304
|
//#region src/fs-utils.ts
|
|
64399
64305
|
const ensure = async (filesPath, defaultContent = "{}") => {
|
|
@@ -64486,6 +64392,16 @@ const zipFolder = async (from, to, log) => {
|
|
|
64486
64392
|
});
|
|
64487
64393
|
};
|
|
64488
64394
|
//#endregion
|
|
64395
|
+
//#region src/custom-errors.ts
|
|
64396
|
+
var ExternalCommandError = class ExternalCommandError extends Error {
|
|
64397
|
+
code;
|
|
64398
|
+
constructor(message, code) {
|
|
64399
|
+
super(message);
|
|
64400
|
+
this.code = code;
|
|
64401
|
+
Object.setPrototypeOf(this, ExternalCommandError.prototype);
|
|
64402
|
+
}
|
|
64403
|
+
};
|
|
64404
|
+
//#endregion
|
|
64489
64405
|
//#region src/node-utils.ts
|
|
64490
64406
|
const fileExists$1 = async (path) => {
|
|
64491
64407
|
try {
|
|
@@ -64515,6 +64431,6 @@ const detectRuntime = async (appFolder) => {
|
|
|
64515
64431
|
return detectedRuntime;
|
|
64516
64432
|
};
|
|
64517
64433
|
//#endregion
|
|
64518
|
-
export { AppSettingsValidator, AppSettingsValidatorV1, AppSettingsValidatorV2, AppSettingsValidatorV3, AppSettingsValidatorV4, AppSettingsValidatorV5, AppSettingsValidatorV6, AppSettingsValidatorV7, BenefitNotFoundError, EditorParamValidatorV3, ExternalCommandError, OriginValidator, src_default as RELEASE_SYNC, SaveLocationExternalValidator, SaveLocationInternalValidator, SaveLocationPipelabCloudValidator, SaveLocationValidator, SavedFileDefaultValidator, SavedFileSimpleValidator, SavedFileValidator, SavedFileValidatorV1, SavedFileValidatorV2, SavedFileValidatorV3, SavedFileValidatorV4, ShellChannels, SubscriptionExpiredError, SubscriptionRequiredError, UnauthorizedError, VariableValidatorV1, WebSocketConnectionError, WebSocketError, WebSocketTimeoutError, appSettingsMigrator, configRegistry, createAction, createActionRunner, createArray, createBooleanParam, createColorPicker, createCondition, createConditionRunner, createDefinition, createEvent, createEventRunner, createExpression, createExpressionRunner, createLoop, createLoopRunner, createNetlifySiteParam, createNodeDefinition, createNumberParam, createPasswordParam, createPathParam, createPlugin, createQuickJs, createQuickJsFromVariant, createRawParam, createStringParam, createSubscriptionError, createVersionSchema, de_DE_default as de_DE, defaultAppSettings, defaultFileRepo, detectRuntime, downloadFile, en_US_default as en_US, ensure,
|
|
64434
|
+
export { AppSettingsValidator, AppSettingsValidatorV1, AppSettingsValidatorV2, AppSettingsValidatorV3, AppSettingsValidatorV4, AppSettingsValidatorV5, AppSettingsValidatorV6, AppSettingsValidatorV7, BenefitNotFoundError, EditorParamValidatorV3, ExternalCommandError, OriginValidator, PipelabContext, src_default as RELEASE_SYNC, SaveLocationExternalValidator, SaveLocationInternalValidator, SaveLocationPipelabCloudValidator, SaveLocationValidator, SavedFileDefaultValidator, SavedFileSimpleValidator, SavedFileValidator, SavedFileValidatorV1, SavedFileValidatorV2, SavedFileValidatorV3, SavedFileValidatorV4, ShellChannels, SubscriptionExpiredError, SubscriptionRequiredError, UnauthorizedError, VariableValidatorV1, WebSocketConnectionError, WebSocketError, WebSocketTimeoutError, appSettingsMigrator, configRegistry, createAction, createActionRunner, createArray, createBooleanParam, createColorPicker, createCondition, createConditionRunner, createDefinition, createEvent, createEventRunner, createExpression, createExpressionRunner, createLoop, createLoopRunner, createNetlifySiteParam, createNodeDefinition, createNumberParam, createPasswordParam, createPathParam, createPlugin, createQuickJs, createQuickJsFromVariant, createRawParam, createStringParam, createSubscriptionError, createVersionSchema, de_DE_default as de_DE, defaultAppSettings, defaultFileRepo, detectRuntime, downloadFile, en_US_default as en_US, ensure, es_ES_default as es_ES, extractTarGz, extractZip, fetchPackage, fetchPipelabAsset, fetchPipelabCli, fetchPipelabPlugin, fileExists, fileRepoMigrations, fmt, foo, fr_FR_default as fr_FR, generateTempFolder, getSubscriptionErrorMessage, isRenderer, isRequired, isSubscriptionError, isSupabaseAvailable, isWebSocketErrorMessage, isWebSocketRequestMessage, isWebSocketResponseMessage, makeResolvedParams, newVariant, processGraph, pt_BR_default as pt_BR, runPnpm, runWithLiveLogs, savedFileMigrator, schema, sleep, supabase, useLogger, usePlugins, variableToFormattedVariable, zh_CN_default as zh_CN, zipFolder };
|
|
64519
64435
|
|
|
64520
64436
|
//# sourceMappingURL=index.mjs.map
|