@pipelab/plugin-netlify 1.0.0-beta.14 → 1.0.0-beta.15

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/dist/index.mjs CHANGED
@@ -4,11 +4,11 @@ import { normalize } from "path";
4
4
  import { formatWithOptions, types } from "util";
5
5
  import path, { basename, delimiter, dirname, join } from "node:path";
6
6
  import { fileURLToPath } from "node:url";
7
- import { constants, tmpdir } from "node:os";
7
+ import { constants } from "node:os";
8
8
  import { appendFileSync, createReadStream, createWriteStream, existsSync, readFileSync, readdirSync, statSync, writeFileSync } from "node:fs";
9
+ import { chmod, cp, mkdir, readFile, readdir, rename, rm, writeFile } from "node:fs/promises";
9
10
  import http from "node:http";
10
11
  import { webcrypto } from "node:crypto";
11
- import { chmod, cp, mkdir, mkdtemp, readFile, readdir, realpath, rename, rm, writeFile } from "node:fs/promises";
12
12
  import { ChildProcess, execFile, spawn, spawnSync } from "node:child_process";
13
13
  import { StringDecoder } from "node:string_decoder";
14
14
  import { aborted, callbackify, debuglog, inspect, promisify, stripVTControlCharacters } from "node:util";
@@ -1595,6 +1595,56 @@ function literal(literal_, message) {
1595
1595
  }
1596
1596
  };
1597
1597
  }
1598
+ function looseObject(entries, message) {
1599
+ return {
1600
+ kind: "schema",
1601
+ type: "loose_object",
1602
+ reference: looseObject,
1603
+ expects: "Object",
1604
+ async: false,
1605
+ entries,
1606
+ message,
1607
+ _run(dataset, config2) {
1608
+ const input = dataset.value;
1609
+ if (input && typeof input === "object") {
1610
+ dataset.typed = true;
1611
+ dataset.value = {};
1612
+ for (const key in this.entries) {
1613
+ const value2 = input[key];
1614
+ const valueDataset = this.entries[key]._run({
1615
+ typed: false,
1616
+ value: value2
1617
+ }, config2);
1618
+ if (valueDataset.issues) {
1619
+ const pathItem = {
1620
+ type: "object",
1621
+ origin: "value",
1622
+ input,
1623
+ key,
1624
+ value: value2
1625
+ };
1626
+ for (const issue of valueDataset.issues) {
1627
+ if (issue.path) issue.path.unshift(pathItem);
1628
+ else issue.path = [pathItem];
1629
+ dataset.issues?.push(issue);
1630
+ }
1631
+ if (!dataset.issues) dataset.issues = valueDataset.issues;
1632
+ if (config2.abortEarly) {
1633
+ dataset.typed = false;
1634
+ break;
1635
+ }
1636
+ }
1637
+ if (!valueDataset.typed) dataset.typed = false;
1638
+ if (valueDataset.value !== void 0 || key in input) dataset.value[key] = valueDataset.value;
1639
+ }
1640
+ if (!dataset.issues || !config2.abortEarly) {
1641
+ for (const key in input) if (_isValidObjectKey(input, key) && !(key in this.entries)) dataset.value[key] = input[key];
1642
+ }
1643
+ } else _addIssue(this, "type", dataset, config2);
1644
+ return dataset;
1645
+ }
1646
+ };
1647
+ }
1598
1648
  function number(message) {
1599
1649
  return {
1600
1650
  kind: "schema",
@@ -2132,6 +2182,18 @@ settingsMigratorInternal.createMigrations({
2132
2182
  })
2133
2183
  ]
2134
2184
  });
2185
+ const connectionsMigratorInternal = createMigrator();
2186
+ const defaultConnections = connectionsMigratorInternal.createDefault({
2187
+ version: "1.0.0",
2188
+ connections: []
2189
+ });
2190
+ connectionsMigratorInternal.createMigrations({
2191
+ defaultValue: defaultConnections,
2192
+ migrations: [createMigration({
2193
+ version: "1.0.0",
2194
+ up: finalVersion
2195
+ })]
2196
+ });
2135
2197
  const fileRepoMigratorInternal = createMigrator();
2136
2198
  const defaultFileRepo = fileRepoMigratorInternal.createDefault({
2137
2199
  version: "2.0.0",
@@ -2293,11 +2355,51 @@ const LEGACY_ID_MAP = {
2293
2355
  };
2294
2356
  const getStrictPluginId = (pluginId) => {
2295
2357
  if (!pluginId) return pluginId;
2296
- if (LEGACY_ID_MAP[pluginId]) return LEGACY_ID_MAP[pluginId];
2297
- if (pluginId.startsWith("@") || pluginId.includes("/") || pluginId.startsWith("pipelab-plugin-")) return pluginId;
2298
- const prefixed = `@pipelab/plugin-${pluginId}`;
2299
- return LEGACY_ID_MAP[prefixed] || prefixed;
2358
+ return LEGACY_ID_MAP[pluginId] || pluginId;
2300
2359
  };
2360
+ //#endregion
2361
+ //#region ../../packages/shared/src/save-location.ts
2362
+ const SaveLocationInternalValidator = object({
2363
+ id: string(),
2364
+ project: string(),
2365
+ lastModified: string(),
2366
+ type: literal("internal"),
2367
+ configName: string()
2368
+ });
2369
+ const SaveLocationValidator = union([
2370
+ object({
2371
+ id: string(),
2372
+ project: string(),
2373
+ path: string(),
2374
+ lastModified: string(),
2375
+ type: literal("external"),
2376
+ summary: object({
2377
+ plugins: array(string()),
2378
+ name: string(),
2379
+ description: string()
2380
+ })
2381
+ }),
2382
+ SaveLocationInternalValidator,
2383
+ object({
2384
+ id: string(),
2385
+ project: string(),
2386
+ type: literal("pipelab-cloud")
2387
+ })
2388
+ ]);
2389
+ object({
2390
+ version: literal("1.0.0"),
2391
+ data: optional(record(string(), SaveLocationValidator), {})
2392
+ });
2393
+ const FileRepoProjectValidatorV2$1 = object({
2394
+ id: string(),
2395
+ name: string(),
2396
+ description: string()
2397
+ });
2398
+ object({
2399
+ version: literal("2.0.0"),
2400
+ projects: array(FileRepoProjectValidatorV2$1),
2401
+ pipelines: optional(array(SaveLocationValidator), [])
2402
+ });
2301
2403
  object({
2302
2404
  cacheFolder: string(),
2303
2405
  theme: union([literal("light"), literal("dark")]),
@@ -2449,6 +2551,17 @@ object({
2449
2551
  })),
2450
2552
  isInternalMigrationBannerClosed: optional(boolean(), false)
2451
2553
  });
2554
+ const ConnectionValidator = looseObject({
2555
+ id: string(),
2556
+ pluginName: string(),
2557
+ name: string(),
2558
+ createdAt: string(),
2559
+ isDefault: boolean()
2560
+ });
2561
+ object({
2562
+ version: literal("1.0.0"),
2563
+ connections: array(ConnectionValidator)
2564
+ });
2452
2565
  //#endregion
2453
2566
  //#region ../../node_modules/tslog/dist/esm/prettyLogStyles.js
2454
2567
  const prettyLogStyles = {
@@ -2969,7 +3082,7 @@ const useLogger = () => {
2969
3082
  const OriginValidator = object({
2970
3083
  pluginId: string(),
2971
3084
  nodeId: string(),
2972
- version: pipe(optional(string()), description("Pinned version of the plugin for this block. Falls back to \"latest\" when absent."))
3085
+ version: optional(pipe(string(), description("Pinned version of the plugin for this block. Falls back to \"latest\" when absent.")))
2973
3086
  });
2974
3087
  const BlockActionValidatorV1 = object({
2975
3088
  type: literal("action"),
@@ -2982,7 +3095,7 @@ const EditorParamValidatorV3 = union([literal("simple"), literal("editor")]);
2982
3095
  const BlockActionValidatorV3 = object({
2983
3096
  type: literal("action"),
2984
3097
  uid: string(),
2985
- name: pipe(optional(string()), description("A custom name provided by the user")),
3098
+ name: optional(pipe(string(), description("A custom name provided by the user"))),
2986
3099
  disabled: optional(boolean()),
2987
3100
  params: record(string(), object({
2988
3101
  editor: EditorParamValidatorV3,
@@ -45296,35 +45409,6 @@ const createNetlifySiteParam = (value, tokenKey, definition) => {
45296
45409
  };
45297
45410
  };
45298
45411
  //#endregion
45299
- //#region ../../packages/shared/src/save-location.ts
45300
- const SaveLocationInternalValidator = object({
45301
- id: string(),
45302
- project: string(),
45303
- lastModified: string(),
45304
- type: literal("internal"),
45305
- configName: string()
45306
- });
45307
- const SaveLocationValidator = union([
45308
- object({
45309
- id: string(),
45310
- project: string(),
45311
- path: string(),
45312
- lastModified: string(),
45313
- type: literal("external"),
45314
- summary: object({
45315
- plugins: array(string()),
45316
- name: string(),
45317
- description: string()
45318
- })
45319
- }),
45320
- SaveLocationInternalValidator,
45321
- object({
45322
- id: string(),
45323
- project: string(),
45324
- type: literal("pipelab-cloud")
45325
- })
45326
- ]);
45327
- //#endregion
45328
45412
  //#region ../../packages/shared/src/websocket.types.ts
45329
45413
  var WebSocketError = class extends Error {
45330
45414
  constructor(message, code, requestId) {
@@ -45341,20 +45425,6 @@ object({
45341
45425
  version: literal("1.0.0"),
45342
45426
  data: optional(record(string(), SaveLocationValidator), {})
45343
45427
  });
45344
- const FileRepoProjectValidatorV2$1 = object({
45345
- id: string(),
45346
- name: string(),
45347
- description: string()
45348
- });
45349
- object({
45350
- version: literal("2.0.0"),
45351
- projects: array(FileRepoProjectValidatorV2$1),
45352
- pipelines: optional(array(SaveLocationValidator), [])
45353
- });
45354
- object({
45355
- version: literal("1.0.0"),
45356
- data: optional(record(string(), SaveLocationValidator), {})
45357
- });
45358
45428
  const FileRepoProjectValidatorV2 = object({
45359
45429
  id: string(),
45360
45430
  name: string(),
@@ -45374,9 +45444,15 @@ var init_esm_shims = __esmMin((() => {
45374
45444
  __dirname = /* @__PURE__ */ getDirname();
45375
45445
  }));
45376
45446
  //#endregion
45377
- //#region ../../packages/core-node/src/context.ts
45447
+ //#region ../../packages/constants/src/index.ts
45378
45448
  init_esm_shims();
45379
- const _dirname = typeof __dirname !== "undefined" ? __dirname : typeof import.meta !== "undefined" && import.meta.url ? dirname(fileURLToPath(import.meta.url)) : process.cwd();
45449
+ const websocketPort = 33753;
45450
+ const DEFAULT_NODE_VERSION = "24.14.1";
45451
+ const DEFAULT_PNPM_VERSION = "10.12.0";
45452
+ //#endregion
45453
+ //#region ../../packages/core-node/src/context.ts
45454
+ const metaUrl = typeof import.meta !== "undefined" ? import.meta.url : void 0;
45455
+ const _dirname = typeof __dirname !== "undefined" ? __dirname : metaUrl ? dirname(fileURLToPath(metaUrl)) : process.cwd();
45380
45456
  const isDev = process.env.NODE_ENV === "development";
45381
45457
  /**
45382
45458
  * Finds the monorepo root by looking for pnpm-workspace.yaml.
@@ -48948,9 +49024,6 @@ const useAPI = () => {
48948
49024
  };
48949
49025
  };
48950
49026
  //#endregion
48951
- //#region ../../packages/constants/src/index.ts
48952
- const websocketPort = 33753;
48953
- //#endregion
48954
49027
  //#region ../../packages/core-node/src/websocket-server.ts
48955
49028
  var WebSocketServer = class {
48956
49029
  wss = null;
@@ -89355,14 +89428,6 @@ var import_tar = /* @__PURE__ */ __toESM(require_tar$1(), 1);
89355
89428
  var import_yauzl = /* @__PURE__ */ __toESM(require_yauzl(), 1);
89356
89429
  require_archiver();
89357
89430
  /**
89358
- * Generates a unique temporary folder.
89359
- */
89360
- const generateTempFolder = async (base) => {
89361
- const targetBase = base || tmpdir();
89362
- await mkdir(targetBase, { recursive: true });
89363
- return await mkdtemp(join(await realpath(targetBase), "pipelab-"));
89364
- };
89365
- /**
89366
89431
  * Extracts a .tar.gz archive.
89367
89432
  */
89368
89433
  async function extractTarGz(archivePath, destinationDir) {
@@ -100913,11 +100978,11 @@ var require_cp = /* @__PURE__ */ __commonJSMin(((exports, module) => {
100913
100978
  var require_with_temp_dir = /* @__PURE__ */ __commonJSMin(((exports, module) => {
100914
100979
  const { join: join$5, sep: sep$1 } = __require("path");
100915
100980
  const getOptions = require_get_options();
100916
- const { mkdir: mkdir$4, mkdtemp: mkdtemp$1, rm: rm$5 } = __require("fs/promises");
100981
+ const { mkdir: mkdir$4, mkdtemp, rm: rm$5 } = __require("fs/promises");
100917
100982
  const withTempDir = async (root, fn, opts) => {
100918
100983
  const options = getOptions(opts, { copy: ["tmpPrefix"] });
100919
100984
  await mkdir$4(root, { recursive: true });
100920
- const target = await mkdtemp$1(join$5(`${root}${sep$1}`, options.tmpPrefix || ""));
100985
+ const target = await mkdtemp(join$5(`${root}${sep$1}`, options.tmpPrefix || ""));
100921
100986
  let err;
100922
100987
  let result;
100923
100988
  try {
@@ -110516,9 +110581,9 @@ var require_protected = /* @__PURE__ */ __commonJSMin(((exports, module) => {
110516
110581
  //#region ../../node_modules/pacote/lib/util/cache-dir.js
110517
110582
  var require_cache_dir = /* @__PURE__ */ __commonJSMin(((exports, module) => {
110518
110583
  const { resolve: resolve$6 } = __require("node:path");
110519
- const { tmpdir: tmpdir$1, homedir } = __require("node:os");
110584
+ const { tmpdir, homedir } = __require("node:os");
110520
110585
  module.exports = (fakePlatform = false) => {
110521
- const temp = tmpdir$1();
110586
+ const temp = tmpdir();
110522
110587
  const uidOrPid = process.getuid ? process.getuid() : process.pid;
110523
110588
  const home = homedir() || resolve$6(temp, "npm-" + uidOrPid);
110524
110589
  const platform = fakePlatform || process.platform;
@@ -150591,7 +150656,7 @@ var require_error = /* @__PURE__ */ __commonJSMin(((exports, module) => {
150591
150656
  const { promisify: promisify$1 } = __require("util");
150592
150657
  const path$1 = __require("path");
150593
150658
  const { createHash } = __require("crypto");
150594
- const { realpath: realpath$1, lstat, createReadStream: createReadStream$1, readdir: readdir$1 } = __require("fs");
150659
+ const { realpath, lstat, createReadStream: createReadStream$1, readdir: readdir$1 } = __require("fs");
150595
150660
  const url = __require("url");
150596
150661
  const slasher = require_glob_slash();
150597
150662
  const minimatch = require_minimatch();
@@ -150914,7 +150979,7 @@ var require_error = /* @__PURE__ */ __commonJSMin(((exports, module) => {
150914
150979
  };
150915
150980
  const getHandlers = (methods) => Object.assign({
150916
150981
  lstat: promisify$1(lstat),
150917
- realpath: promisify$1(realpath$1),
150982
+ realpath: promisify$1(realpath),
150918
150983
  createReadStream: createReadStream$1,
150919
150984
  readdir: promisify$1(readdir$1),
150920
150985
  sendError
@@ -151053,8 +151118,6 @@ const sendStartupProgress = (message) => {
151053
151118
  };
151054
151119
  //#endregion
151055
151120
  //#region ../../packages/core-node/src/utils/remote.ts
151056
- const DEFAULT_NODE_VERSION = "24.14.1";
151057
- const DEFAULT_PNPM_VERSION = "10.12.0";
151058
151121
  function isPackageComplete(packageDir) {
151059
151122
  return existsSync(join(packageDir, "package.json"));
151060
151123
  }
@@ -151246,7 +151309,7 @@ async function ensureNodeJS(context, version = DEFAULT_NODE_VERSION) {
151246
151309
  const extension = isWindows ? "zip" : "tar.gz";
151247
151310
  const fileName = `node-v${version}-${platform === "osx" ? "darwin" : platform}-${arch}.${extension}`;
151248
151311
  const downloadUrl = `https://nodejs.org/dist/v${version}/${fileName}`;
151249
- const tempDir = await generateTempFolder(tmpdir());
151312
+ const tempDir = await context.createTempFolder("node-download-");
151250
151313
  const archivePath = join(tempDir, fileName);
151251
151314
  sendStartupProgress(`Downloading Node.js v${version}...`);
151252
151315
  console.log(`Downloading Node.js from ${downloadUrl}...`);
@@ -151568,72 +151631,83 @@ const uploadToNetlifyRunner = createActionRunner(async ({ log, inputs, cwd, abor
151568
151631
  });
151569
151632
  //#endregion
151570
151633
  //#region src/index.ts
151571
- var src_default = createNodeDefinition({ nodes: [{
151572
- node: createAction({
151573
- id: "netlify-build",
151574
- name: "Build Netlify site",
151575
- description: "",
151576
- icon: "",
151577
- displayString: "`Build ${fmt.param(params['input-folder'], 'primary', 'No path selected')}`",
151578
- meta: {},
151579
- params: {
151580
- "input-folder": createPathParam("", {
151581
- required: true,
151582
- label: "Path to the folder to upload to netlify",
151583
- control: {
151584
- type: "path",
151585
- options: { properties: ["openDirectory"] }
151586
- }
151587
- }),
151588
- token: createStringParam("", {
151589
- required: true,
151590
- label: "Token"
151591
- })
151592
- },
151593
- outputs: {}
151594
- }),
151595
- runner: createActionRunner(async ({ log, inputs, cwd, abortSignal, paths }) => {
151596
- log("Building netlify site");
151597
- const { node } = paths;
151598
- const buildDir = join(cwd, "build");
151599
- const inputFolder = inputs["input-folder"];
151600
- if (!await fileExists(join(inputFolder, "package.json"))) throw new Error("No package.json found in input folder");
151601
- await cp(inputs["input-folder"], buildDir, { recursive: true });
151602
- const netlifyDir = join(buildDir, ".netlify");
151603
- const netlifyState = join(netlifyDir, "state.json");
151604
- await mkdir(netlifyDir, { recursive: true });
151605
- await writeFile(netlifyState, `{ "siteId": "${inputs.site}" }`, "utf-8");
151606
- const { all: buildOut } = await runPnpm(buildDir, {
151607
- args: [
151608
- "--package",
151609
- "netlify-cli",
151610
- "dlx",
151611
- "netlify",
151612
- "build"
151613
- ],
151614
- extraEnv: { NETLIFY_AUTH_TOKEN: inputs.token },
151615
- signal: abortSignal
151616
- });
151617
- if (buildOut) log(buildOut);
151618
- const { all: deployOut } = await runPnpm(buildDir, {
151619
- args: [
151620
- "--package",
151621
- "netlify-cli",
151622
- "dlx",
151623
- "netlify",
151624
- "deploy",
151625
- "--prod"
151626
- ],
151627
- extraEnv: { NETLIFY_AUTH_TOKEN: inputs.token },
151628
- signal: abortSignal
151629
- });
151630
- if (deployOut) log(deployOut);
151631
- log("Uploaded to netlify");
151632
- })
151633
- }, {
151634
- node: uploadToNetlify,
151635
- runner: uploadToNetlifyRunner
151636
- }] });
151634
+ var src_default = createNodeDefinition({
151635
+ nodes: [{
151636
+ node: createAction({
151637
+ id: "netlify-build",
151638
+ name: "Build Netlify site",
151639
+ description: "",
151640
+ icon: "",
151641
+ displayString: "`Build ${fmt.param(params['input-folder'], 'primary', 'No path selected')}`",
151642
+ meta: {},
151643
+ params: {
151644
+ "input-folder": createPathParam("", {
151645
+ required: true,
151646
+ label: "Path to the folder to upload to netlify",
151647
+ control: {
151648
+ type: "path",
151649
+ options: { properties: ["openDirectory"] }
151650
+ }
151651
+ }),
151652
+ token: createStringParam("", {
151653
+ required: true,
151654
+ label: "Token"
151655
+ })
151656
+ },
151657
+ outputs: {}
151658
+ }),
151659
+ runner: createActionRunner(async ({ log, inputs, cwd, abortSignal, paths }) => {
151660
+ log("Building netlify site");
151661
+ const { node } = paths;
151662
+ const buildDir = join(cwd, "build");
151663
+ const inputFolder = inputs["input-folder"];
151664
+ if (!await fileExists(join(inputFolder, "package.json"))) throw new Error("No package.json found in input folder");
151665
+ await cp(inputs["input-folder"], buildDir, { recursive: true });
151666
+ const netlifyDir = join(buildDir, ".netlify");
151667
+ const netlifyState = join(netlifyDir, "state.json");
151668
+ await mkdir(netlifyDir, { recursive: true });
151669
+ await writeFile(netlifyState, `{ "siteId": "${inputs.site}" }`, "utf-8");
151670
+ const { all: buildOut } = await runPnpm(buildDir, {
151671
+ args: [
151672
+ "--package",
151673
+ "netlify-cli",
151674
+ "dlx",
151675
+ "netlify",
151676
+ "build"
151677
+ ],
151678
+ extraEnv: { NETLIFY_AUTH_TOKEN: inputs.token },
151679
+ signal: abortSignal
151680
+ });
151681
+ if (buildOut) log(buildOut);
151682
+ const { all: deployOut } = await runPnpm(buildDir, {
151683
+ args: [
151684
+ "--package",
151685
+ "netlify-cli",
151686
+ "dlx",
151687
+ "netlify",
151688
+ "deploy",
151689
+ "--prod"
151690
+ ],
151691
+ extraEnv: { NETLIFY_AUTH_TOKEN: inputs.token },
151692
+ signal: abortSignal
151693
+ });
151694
+ if (deployOut) log(deployOut);
151695
+ log("Uploaded to netlify");
151696
+ })
151697
+ }, {
151698
+ node: uploadToNetlify,
151699
+ runner: uploadToNetlifyRunner
151700
+ }],
151701
+ integrations: [{
151702
+ name: "Netlify Account",
151703
+ fields: [{
151704
+ key: "apiKey",
151705
+ label: "Personal Access Token",
151706
+ type: "password",
151707
+ placeholder: "netlify API token"
151708
+ }]
151709
+ }]
151710
+ });
151637
151711
  //#endregion
151638
151712
  export { src_default as default };
151639
151713