@pipelab/plugin-itch 1.0.0-beta.13 → 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
@@ -1,12 +1,12 @@
1
1
  import { a as __require, i as __reExport, n as __esmMin, o as __toESM, r as __exportAll, t as __commonJSMin } from "./chunk-kImr3pkf.mjs";
2
2
  import path, { delimiter, dirname, join } from "node:path";
3
- import { access, chmod, mkdir, mkdtemp, realpath, rm } from "node:fs/promises";
3
+ import { access, chmod, mkdir, rm } from "node:fs/promises";
4
4
  import { appendFileSync, constants, createReadStream, createWriteStream, existsSync, readFileSync, readdirSync, statSync, writeFileSync } from "node:fs";
5
5
  import { hostname } from "os";
6
6
  import { normalize } from "path";
7
7
  import { formatWithOptions, types } from "util";
8
8
  import { fileURLToPath } from "node:url";
9
- import { constants as constants$1, tmpdir } from "node:os";
9
+ import { constants as constants$1 } from "node:os";
10
10
  import http from "node:http";
11
11
  import { webcrypto } from "node:crypto";
12
12
  import { ChildProcess, execFile, spawn, spawnSync } from "node:child_process";
@@ -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,
@@ -45282,35 +45395,6 @@ const createPathParam = (value, definition) => {
45282
45395
  };
45283
45396
  };
45284
45397
  //#endregion
45285
- //#region ../../packages/shared/src/save-location.ts
45286
- const SaveLocationInternalValidator = object({
45287
- id: string(),
45288
- project: string(),
45289
- lastModified: string(),
45290
- type: literal("internal"),
45291
- configName: string()
45292
- });
45293
- const SaveLocationValidator = union([
45294
- object({
45295
- id: string(),
45296
- project: string(),
45297
- path: string(),
45298
- lastModified: string(),
45299
- type: literal("external"),
45300
- summary: object({
45301
- plugins: array(string()),
45302
- name: string(),
45303
- description: string()
45304
- })
45305
- }),
45306
- SaveLocationInternalValidator,
45307
- object({
45308
- id: string(),
45309
- project: string(),
45310
- type: literal("pipelab-cloud")
45311
- })
45312
- ]);
45313
- //#endregion
45314
45398
  //#region ../../packages/shared/src/websocket.types.ts
45315
45399
  var WebSocketError = class extends Error {
45316
45400
  constructor(message, code, requestId) {
@@ -45327,20 +45411,6 @@ object({
45327
45411
  version: literal("1.0.0"),
45328
45412
  data: optional(record(string(), SaveLocationValidator), {})
45329
45413
  });
45330
- const FileRepoProjectValidatorV2$1 = object({
45331
- id: string(),
45332
- name: string(),
45333
- description: string()
45334
- });
45335
- object({
45336
- version: literal("2.0.0"),
45337
- projects: array(FileRepoProjectValidatorV2$1),
45338
- pipelines: optional(array(SaveLocationValidator), [])
45339
- });
45340
- object({
45341
- version: literal("1.0.0"),
45342
- data: optional(record(string(), SaveLocationValidator), {})
45343
- });
45344
45414
  const FileRepoProjectValidatorV2 = object({
45345
45415
  id: string(),
45346
45416
  name: string(),
@@ -45360,9 +45430,13 @@ var init_esm_shims = __esmMin((() => {
45360
45430
  __dirname = /* @__PURE__ */ getDirname();
45361
45431
  }));
45362
45432
  //#endregion
45363
- //#region ../../packages/core-node/src/context.ts
45433
+ //#region ../../packages/constants/src/index.ts
45364
45434
  init_esm_shims();
45365
- const _dirname = typeof __dirname !== "undefined" ? __dirname : typeof import.meta !== "undefined" && import.meta.url ? dirname(fileURLToPath(import.meta.url)) : process.cwd();
45435
+ const websocketPort = 33753;
45436
+ //#endregion
45437
+ //#region ../../packages/core-node/src/context.ts
45438
+ const metaUrl = typeof import.meta !== "undefined" ? import.meta.url : void 0;
45439
+ const _dirname = typeof __dirname !== "undefined" ? __dirname : metaUrl ? dirname(fileURLToPath(metaUrl)) : process.cwd();
45366
45440
  const isDev = process.env.NODE_ENV === "development";
45367
45441
  /**
45368
45442
  * Finds the monorepo root by looking for pnpm-workspace.yaml.
@@ -48934,9 +49008,6 @@ const useAPI = () => {
48934
49008
  };
48935
49009
  };
48936
49010
  //#endregion
48937
- //#region ../../packages/constants/src/index.ts
48938
- const websocketPort = 33753;
48939
- //#endregion
48940
49011
  //#region ../../packages/core-node/src/websocket-server.ts
48941
49012
  var WebSocketServer = class {
48942
49013
  wss = null;
@@ -100881,11 +100952,11 @@ var require_cp = /* @__PURE__ */ __commonJSMin(((exports, module) => {
100881
100952
  var require_with_temp_dir = /* @__PURE__ */ __commonJSMin(((exports, module) => {
100882
100953
  const { join: join$5, sep: sep$1 } = __require("path");
100883
100954
  const getOptions = require_get_options();
100884
- const { mkdir: mkdir$4, mkdtemp: mkdtemp$1, rm: rm$5 } = __require("fs/promises");
100955
+ const { mkdir: mkdir$4, mkdtemp, rm: rm$5 } = __require("fs/promises");
100885
100956
  const withTempDir = async (root, fn, opts) => {
100886
100957
  const options = getOptions(opts, { copy: ["tmpPrefix"] });
100887
100958
  await mkdir$4(root, { recursive: true });
100888
- const target = await mkdtemp$1(join$5(`${root}${sep$1}`, options.tmpPrefix || ""));
100959
+ const target = await mkdtemp(join$5(`${root}${sep$1}`, options.tmpPrefix || ""));
100889
100960
  let err;
100890
100961
  let result;
100891
100962
  try {
@@ -110484,9 +110555,9 @@ var require_protected = /* @__PURE__ */ __commonJSMin(((exports, module) => {
110484
110555
  //#region ../../node_modules/pacote/lib/util/cache-dir.js
110485
110556
  var require_cache_dir = /* @__PURE__ */ __commonJSMin(((exports, module) => {
110486
110557
  const { resolve: resolve$6 } = __require("node:path");
110487
- const { tmpdir: tmpdir$1, homedir } = __require("node:os");
110558
+ const { tmpdir, homedir } = __require("node:os");
110488
110559
  module.exports = (fakePlatform = false) => {
110489
- const temp = tmpdir$1();
110560
+ const temp = tmpdir();
110490
110561
  const uidOrPid = process.getuid ? process.getuid() : process.pid;
110491
110562
  const home = homedir() || resolve$6(temp, "npm-" + uidOrPid);
110492
110563
  const platform = fakePlatform || process.platform;
@@ -150559,7 +150630,7 @@ var require_error = /* @__PURE__ */ __commonJSMin(((exports, module) => {
150559
150630
  const { promisify: promisify$1 } = __require("util");
150560
150631
  const path$1 = __require("path");
150561
150632
  const { createHash } = __require("crypto");
150562
- const { realpath: realpath$1, lstat, createReadStream: createReadStream$1, readdir } = __require("fs");
150633
+ const { realpath, lstat, createReadStream: createReadStream$1, readdir } = __require("fs");
150563
150634
  const url = __require("url");
150564
150635
  const slasher = require_glob_slash();
150565
150636
  const minimatch = require_minimatch();
@@ -150882,7 +150953,7 @@ var require_error = /* @__PURE__ */ __commonJSMin(((exports, module) => {
150882
150953
  };
150883
150954
  const getHandlers = (methods) => Object.assign({
150884
150955
  lstat: promisify$1(lstat),
150885
- realpath: promisify$1(realpath$1),
150956
+ realpath: promisify$1(realpath),
150886
150957
  createReadStream: createReadStream$1,
150887
150958
  readdir: promisify$1(readdir),
150888
150959
  sendError
@@ -151037,15 +151108,6 @@ if (isDev && projectRoot) {
151037
151108
  //#region ../plugin-core/src/pipelab.ts
151038
151109
  const createActionRunner = (runner) => runner;
151039
151110
  //#endregion
151040
- //#region ../plugin-core/src/fs-utils.ts
151041
- const generateTempFolder = async (base) => {
151042
- const targetBase = base || tmpdir();
151043
- await mkdir(targetBase, { recursive: true });
151044
- const realPath = await realpath(targetBase);
151045
- console.log("join", join(realPath, "pipelab-"));
151046
- return await mkdtemp(join(realPath, "pipelab-"));
151047
- };
151048
- //#endregion
151049
151111
  //#region ../plugin-core/src/archive-utils.ts
151050
151112
  /**
151051
151113
  * Extracts a .zip archive.
@@ -151088,12 +151150,12 @@ async function extractZip(archivePath, destinationDir) {
151088
151150
  //#region src/ensure.ts
151089
151151
  /**
151090
151152
  * Installs itch.io butler CLI if not already present.
151091
- * @param thirdpartyDir The directory where third-party tools are stored.
151153
+ * @param context The PipelabContext instance.
151092
151154
  * @param version The version of butler to install.
151093
151155
  * @returns A Promise that resolves to the path of the butler executable.
151094
151156
  */
151095
- const ensureButler = async (thirdpartyDir, version = "LATEST") => {
151096
- const butlerDir = join(thirdpartyDir, "butler", version);
151157
+ const ensureButler = async (context, version = "LATEST") => {
151158
+ const butlerDir = join(context.getThirdPartyPath(), "butler", version);
151097
151159
  const isWindows = process.platform === "win32";
151098
151160
  const finalButlerPath = join(butlerDir, isWindows ? "butler.exe" : "butler");
151099
151161
  try {
@@ -151112,7 +151174,7 @@ const ensureButler = async (thirdpartyDir, version = "LATEST") => {
151112
151174
  if (localArch === "x64" || localArch === "arm64") butlerName += "amd64";
151113
151175
  else throw new Error(`Unsupported architecture for butler: ${localArch}`);
151114
151176
  const downloadUrl = `https://broth.itch.zone/butler/${butlerName}/${version}/archive/default`;
151115
- const tempDir = await generateTempFolder(join(thirdpartyDir, ".tmp"));
151177
+ const tempDir = await context.createTempFolder("butler-setup-");
151116
151178
  const archivePath = join(tempDir, "butler.zip");
151117
151179
  console.log(`Downloading butler from ${downloadUrl}...`);
151118
151180
  await downloadFile(downloadUrl, archivePath);
@@ -151128,75 +151190,86 @@ const ensureButler = async (thirdpartyDir, version = "LATEST") => {
151128
151190
  };
151129
151191
  //#endregion
151130
151192
  //#region src/index.ts
151131
- var src_default = createNodeDefinition({ nodes: [{
151132
- node: createAction({
151133
- id: "itch-upload",
151134
- name: "Upload to Itch.io",
151135
- description: "",
151136
- icon: "",
151137
- displayString: "`Upload ${fmt.param(params['input-folder'], 'primary', 'No path selected')} to ${fmt.param(params['user'], 'primary', 'No project')}/${fmt.param(params['project'], 'primary', 'No project')}:${fmt.param(params['channel'], 'primary', 'No channel')}`",
151138
- meta: {},
151139
- params: {
151140
- "input-folder": createPathParam("", {
151141
- required: true,
151142
- label: "Folder to Upload",
151143
- control: {
151144
- type: "path",
151145
- options: { properties: ["openDirectory"] }
151146
- }
151147
- }),
151148
- user: createStringParam("", {
151149
- required: true,
151150
- label: "User"
151151
- }),
151152
- project: createStringParam("", {
151153
- required: true,
151154
- label: "Project"
151155
- }),
151156
- channel: createStringParam("", {
151157
- required: true,
151158
- label: "Channel"
151159
- }),
151160
- "api-key": createStringParam("", {
151161
- required: true,
151162
- label: "API key"
151163
- })
151164
- },
151165
- outputs: {}
151166
- }),
151167
- runner: createActionRunner(async ({ log, inputs, cwd, abortSignal, paths }) => {
151168
- const { node, thirdparty } = paths;
151169
- const butlerPath = await ensureButler(thirdparty);
151170
- log("Uploading to itch");
151171
- await runWithLiveLogs(butlerPath, [
151172
- "push",
151173
- inputs["input-folder"],
151174
- `${inputs.user}/${inputs.project}:${inputs.channel}`,
151175
- "--json"
151176
- ], {
151177
- env: {
151178
- ...process.env,
151179
- PATH: `${dirname(node)}${delimiter}${process.env.PATH}`,
151180
- BUTLER_API_KEY: inputs["api-key"]
151193
+ var src_default = createNodeDefinition({
151194
+ nodes: [{
151195
+ node: createAction({
151196
+ id: "itch-upload",
151197
+ name: "Upload to Itch.io",
151198
+ description: "",
151199
+ icon: "",
151200
+ displayString: "`Upload ${fmt.param(params['input-folder'], 'primary', 'No path selected')} to ${fmt.param(params['user'], 'primary', 'No project')}/${fmt.param(params['project'], 'primary', 'No project')}:${fmt.param(params['channel'], 'primary', 'No channel')}`",
151201
+ meta: {},
151202
+ params: {
151203
+ "input-folder": createPathParam("", {
151204
+ required: true,
151205
+ label: "Folder to Upload",
151206
+ control: {
151207
+ type: "path",
151208
+ options: { properties: ["openDirectory"] }
151209
+ }
151210
+ }),
151211
+ user: createStringParam("", {
151212
+ required: true,
151213
+ label: "User"
151214
+ }),
151215
+ project: createStringParam("", {
151216
+ required: true,
151217
+ label: "Project"
151218
+ }),
151219
+ channel: createStringParam("", {
151220
+ required: true,
151221
+ label: "Channel"
151222
+ }),
151223
+ "api-key": createStringParam("", {
151224
+ required: true,
151225
+ label: "API key"
151226
+ })
151181
151227
  },
151182
- cancelSignal: abortSignal
151183
- }, log, { onStdout(data, subprocess) {
151184
- const jsons = data.trim().split("\n");
151185
- for (const jsonData of jsons) {
151186
- const json = JSON.parse(jsonData);
151187
- switch (json.type) {
151188
- case "log":
151189
- log(json.message);
151190
- break;
151191
- case "progress":
151192
- log(`${json.progress}% - ETA: ${json.eta}s`);
151193
- break;
151228
+ outputs: {}
151229
+ }),
151230
+ runner: createActionRunner(async ({ log, inputs, cwd, abortSignal, context }) => {
151231
+ const node = context.getNodePath();
151232
+ const butlerPath = await ensureButler(context);
151233
+ log("Uploading to itch");
151234
+ await runWithLiveLogs(butlerPath, [
151235
+ "push",
151236
+ inputs["input-folder"],
151237
+ `${inputs.user}/${inputs.project}:${inputs.channel}`,
151238
+ "--json"
151239
+ ], {
151240
+ env: {
151241
+ ...process.env,
151242
+ PATH: `${dirname(node)}${delimiter}${process.env.PATH}`,
151243
+ BUTLER_API_KEY: inputs["api-key"]
151244
+ },
151245
+ cancelSignal: abortSignal
151246
+ }, log, { onStdout(data, subprocess) {
151247
+ const jsons = data.trim().split("\n");
151248
+ for (const jsonData of jsons) {
151249
+ const json = JSON.parse(jsonData);
151250
+ switch (json.type) {
151251
+ case "log":
151252
+ log(json.message);
151253
+ break;
151254
+ case "progress":
151255
+ log(`${json.progress}% - ETA: ${json.eta}s`);
151256
+ break;
151257
+ }
151194
151258
  }
151195
- }
151196
- } });
151197
- log("Uploaded to itch");
151198
- })
151199
- }] });
151259
+ } });
151260
+ log("Uploaded to itch");
151261
+ })
151262
+ }],
151263
+ integrations: [{
151264
+ name: "Itch Butler Account",
151265
+ fields: [{
151266
+ key: "apiKey",
151267
+ label: "Butler API Key",
151268
+ type: "password",
151269
+ placeholder: "butler API key"
151270
+ }]
151271
+ }]
151272
+ });
151200
151273
  //#endregion
151201
151274
  export { src_default as default };
151202
151275