@walkeros/cli 4.4.0 → 4.5.0

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.js CHANGED
@@ -1280,6 +1280,127 @@ var init_structural_validators = __esm({
1280
1280
  }
1281
1281
  });
1282
1282
 
1283
+ // src/core/step-packages.ts
1284
+ import { packageNameToVariable } from "@walkeros/core";
1285
+ function getFlowSection(flow, section) {
1286
+ switch (section) {
1287
+ case "sources":
1288
+ return flow.sources;
1289
+ case "destinations":
1290
+ return flow.destinations;
1291
+ case "transformers":
1292
+ return flow.transformers;
1293
+ case "stores":
1294
+ return flow.stores;
1295
+ }
1296
+ }
1297
+ function parsePackageSpec(spec) {
1298
+ const at = spec.lastIndexOf("@");
1299
+ if (at <= 0) return { name: spec };
1300
+ const version = spec.slice(at + 1);
1301
+ return version ? { name: spec.slice(0, at), version } : { name: spec.slice(0, at) };
1302
+ }
1303
+ function detectStepPackages(flowSettings, section) {
1304
+ const packages = /* @__PURE__ */ new Set();
1305
+ const steps = getFlowSection(flowSettings, section);
1306
+ if (steps) {
1307
+ for (const [, stepConfig] of Object.entries(steps)) {
1308
+ if (typeof stepConfig !== "object" || stepConfig === null) continue;
1309
+ if (typeof stepConfig.package === "string") {
1310
+ packages.add(stepConfig.package);
1311
+ }
1312
+ }
1313
+ }
1314
+ return packages;
1315
+ }
1316
+ function collectAllStepPackages(flowSettings) {
1317
+ const allPackages = /* @__PURE__ */ new Set();
1318
+ const sections = [
1319
+ "sources",
1320
+ "destinations",
1321
+ "transformers",
1322
+ "stores"
1323
+ ];
1324
+ for (const section of sections) {
1325
+ for (const pkg of detectStepPackages(flowSettings, section)) {
1326
+ allPackages.add(pkg);
1327
+ }
1328
+ }
1329
+ return allPackages;
1330
+ }
1331
+ function applyStepPackages(flowSettings, packages, logger) {
1332
+ const stepPackages = collectAllStepPackages(flowSettings);
1333
+ const originalPins = /* @__PURE__ */ new Map();
1334
+ const inlineSeen = /* @__PURE__ */ new Map();
1335
+ const rewriteSteps = (from, to) => {
1336
+ for (const section of [
1337
+ "sources",
1338
+ "destinations",
1339
+ "transformers",
1340
+ "stores"
1341
+ ]) {
1342
+ const steps = getFlowSection(flowSettings, section);
1343
+ if (!steps) continue;
1344
+ for (const step of Object.values(steps)) {
1345
+ if (step.package === from) {
1346
+ step.package = to;
1347
+ }
1348
+ }
1349
+ }
1350
+ };
1351
+ for (const pkg of stepPackages) {
1352
+ const isLocalPath = pkg.startsWith(".") || pkg.startsWith("/");
1353
+ if (isLocalPath) {
1354
+ const varName = packageNameToVariable(pkg);
1355
+ if (!packages[varName]) {
1356
+ packages[varName] = {
1357
+ path: pkg
1358
+ };
1359
+ }
1360
+ rewriteSteps(pkg, varName);
1361
+ continue;
1362
+ }
1363
+ const { name, version } = parsePackageSpec(pkg);
1364
+ if (!originalPins.has(name)) {
1365
+ const entry = packages[name];
1366
+ originalPins.set(
1367
+ name,
1368
+ entry?.version !== void 0 || entry?.path !== void 0
1369
+ );
1370
+ }
1371
+ const hasBundlePin = originalPins.get(name) === true;
1372
+ if (name !== pkg) {
1373
+ rewriteSteps(pkg, name);
1374
+ }
1375
+ if (version && !hasBundlePin) {
1376
+ const seen = inlineSeen.get(name);
1377
+ if (seen !== void 0 && seen !== version) {
1378
+ throw new Error(
1379
+ `Conflicting inline versions for ${name}: "${seen}" and "${version}" are declared by different steps. Pin one version in config.bundle.packages.`
1380
+ );
1381
+ }
1382
+ inlineSeen.set(name, version);
1383
+ }
1384
+ const existing = packages[name];
1385
+ if (!existing) {
1386
+ packages[name] = version ? { version } : {};
1387
+ } else if (version && !existing.path) {
1388
+ if (!existing.version) {
1389
+ existing.version = version;
1390
+ } else if (existing.version !== version) {
1391
+ logger.warn(
1392
+ `Package ${name}: config.bundle.packages pins ${existing.version}; a step declares ${version} inline. Using the bundle pin.`
1393
+ );
1394
+ }
1395
+ }
1396
+ }
1397
+ }
1398
+ var init_step_packages = __esm({
1399
+ "src/core/step-packages.ts"() {
1400
+ "use strict";
1401
+ }
1402
+ });
1403
+
1283
1404
  // src/core/cache-utils.ts
1284
1405
  import { getHashServer } from "@walkeros/server-core";
1285
1406
  import semver from "semver";
@@ -1318,7 +1439,7 @@ var init_cache_utils = __esm({
1318
1439
  }
1319
1440
  });
1320
1441
 
1321
- // src/commands/bundle/package-manager.ts
1442
+ // src/core/package-manager.ts
1322
1443
  import pacote from "pacote";
1323
1444
  import path8 from "path";
1324
1445
  import fs7 from "fs-extra";
@@ -1867,9 +1988,9 @@ Each package must use the same version across all declarations. Please update yo
1867
1988
  }
1868
1989
  var PACOTE_OPTS, PACOTE_RETRY_ATTEMPTS, PACOTE_PER_ATTEMPT_TIMEOUT_MS, PACOTE_MAX_TOTAL_MS, MIN_ATTEMPT_BUDGET_MS, BASE_BACKOFF_MS, JITTER, PERMANENT_ERROR_CODES, SOURCE_PRIORITY;
1869
1990
  var init_package_manager = __esm({
1870
- "src/commands/bundle/package-manager.ts"() {
1991
+ "src/core/package-manager.ts"() {
1871
1992
  "use strict";
1872
- init_core();
1993
+ init_local_packages();
1873
1994
  init_cache_utils();
1874
1995
  init_tmp();
1875
1996
  PACOTE_OPTS = {
@@ -2188,7 +2309,7 @@ import { builtinModules } from "module";
2188
2309
  import path12 from "path";
2189
2310
  import fs11 from "fs-extra";
2190
2311
  import {
2191
- packageNameToVariable,
2312
+ packageNameToVariable as packageNameToVariable2,
2192
2313
  ENV_MARKER_PREFIX,
2193
2314
  SECRET_MARKER_PREFIX as SECRET_MARKER_PREFIX2,
2194
2315
  isPathStepEntry,
@@ -2198,18 +2319,6 @@ import { getHashServer as getHashServer3 } from "@walkeros/server-core";
2198
2319
  function isInlineCode2(code) {
2199
2320
  return code !== null && typeof code === "object" && !Array.isArray(code) && "push" in code;
2200
2321
  }
2201
- function getFlowSection(flow, section) {
2202
- switch (section) {
2203
- case "sources":
2204
- return flow.sources;
2205
- case "destinations":
2206
- return flow.destinations;
2207
- case "transformers":
2208
- return flow.transformers;
2209
- case "stores":
2210
- return flow.stores;
2211
- }
2212
- }
2213
2322
  function hasCodeReference2(code) {
2214
2323
  return isInlineCode2(code) || typeof code === "string";
2215
2324
  }
@@ -2674,19 +2783,6 @@ function createEsbuildOptions(buildOptions, entryPath, outputPath, tempDir, pack
2674
2783
  baseOptions.target = resolveTarget(buildOptions);
2675
2784
  return baseOptions;
2676
2785
  }
2677
- function detectStepPackages(flowSettings, section) {
2678
- const packages = /* @__PURE__ */ new Set();
2679
- const steps = getFlowSection(flowSettings, section);
2680
- if (steps) {
2681
- for (const [, stepConfig] of Object.entries(steps)) {
2682
- if (typeof stepConfig !== "object" || stepConfig === null) continue;
2683
- if (typeof stepConfig.package === "string") {
2684
- packages.add(stepConfig.package);
2685
- }
2686
- }
2687
- }
2688
- return packages;
2689
- }
2690
2786
  function getNodeExternals() {
2691
2787
  const externals = [];
2692
2788
  for (const mod of builtinModules) {
@@ -2746,84 +2842,6 @@ async function runNftServerPath(outputPath, flowSettings, buildOptions, tempDir,
2746
2842
  `nft-trace: copied ${result.copied} file(s); wrote ${sidecarPath}`
2747
2843
  );
2748
2844
  }
2749
- function collectAllStepPackages(flowSettings) {
2750
- const allPackages = /* @__PURE__ */ new Set();
2751
- const sections = [
2752
- "sources",
2753
- "destinations",
2754
- "transformers",
2755
- "stores"
2756
- ];
2757
- for (const section of sections) {
2758
- for (const pkg of detectStepPackages(flowSettings, section)) {
2759
- allPackages.add(pkg);
2760
- }
2761
- }
2762
- return allPackages;
2763
- }
2764
- function applyStepPackages(flowSettings, packages, logger) {
2765
- const stepPackages = collectAllStepPackages(flowSettings);
2766
- const originalVersions = /* @__PURE__ */ new Map();
2767
- const inlineSeen = /* @__PURE__ */ new Map();
2768
- const rewriteSteps = (from, to) => {
2769
- for (const section of [
2770
- "sources",
2771
- "destinations",
2772
- "transformers",
2773
- "stores"
2774
- ]) {
2775
- const steps = getFlowSection(flowSettings, section);
2776
- if (!steps) continue;
2777
- for (const step of Object.values(steps)) {
2778
- if (step.package === from) {
2779
- step.package = to;
2780
- }
2781
- }
2782
- }
2783
- };
2784
- for (const pkg of stepPackages) {
2785
- const isLocalPath = pkg.startsWith(".") || pkg.startsWith("/");
2786
- if (isLocalPath) {
2787
- const varName = packageNameToVariable(pkg);
2788
- if (!packages[varName]) {
2789
- packages[varName] = {
2790
- path: pkg
2791
- };
2792
- }
2793
- rewriteSteps(pkg, varName);
2794
- continue;
2795
- }
2796
- const { name, version } = parsePackageSpec(pkg);
2797
- if (!originalVersions.has(name)) {
2798
- originalVersions.set(name, packages[name]?.version);
2799
- }
2800
- const bundlePinnedVersion = originalVersions.get(name);
2801
- if (name !== pkg) {
2802
- rewriteSteps(pkg, name);
2803
- }
2804
- if (version && !bundlePinnedVersion) {
2805
- const seen = inlineSeen.get(name);
2806
- if (seen !== void 0 && seen !== version) {
2807
- throw new Error(
2808
- `Conflicting inline versions for ${name}: "${seen}" and "${version}" are declared by different steps. Pin one version in config.bundle.packages.`
2809
- );
2810
- }
2811
- inlineSeen.set(name, version);
2812
- }
2813
- const existing = packages[name];
2814
- if (!existing) {
2815
- packages[name] = version ? { version } : {};
2816
- } else if (version) {
2817
- if (!existing.version) {
2818
- existing.version = version;
2819
- } else if (existing.version !== version) {
2820
- logger.warn(
2821
- `Package ${name}: config.bundle.packages pins ${existing.version}; a step declares ${version} inline. Using the bundle pin.`
2822
- );
2823
- }
2824
- }
2825
- }
2826
- }
2827
2845
  function detectNamedImports(flowSettings) {
2828
2846
  const namedImports = /* @__PURE__ */ new Map();
2829
2847
  const addNamed = (pkg, importName) => {
@@ -2857,7 +2875,7 @@ async function generateImportStatements(packages, destinationPackages, sourcePac
2857
2875
  const hasNamed = namedImports.has(packageName);
2858
2876
  const namedImportsToGenerate = [];
2859
2877
  if (isUsedByDestOrSource && !hasNamed) {
2860
- const varName = packageNameToVariable(packageName);
2878
+ const varName = packageNameToVariable2(packageName);
2861
2879
  importStatements.push(`import ${varName} from '${packageName}';`);
2862
2880
  }
2863
2881
  if (hasNamed) {
@@ -2912,12 +2930,6 @@ async function computeDevPackages(usedPackages, packagePaths) {
2912
2930
  }
2913
2931
  return devPackages;
2914
2932
  }
2915
- function parsePackageSpec(spec) {
2916
- const at = spec.lastIndexOf("@");
2917
- if (at <= 0) return { name: spec };
2918
- const version = spec.slice(at + 1);
2919
- return version ? { name: spec.slice(0, at), version } : { name: spec.slice(0, at) };
2920
- }
2921
2933
  function packageSpecName(spec) {
2922
2934
  return parsePackageSpec(spec).name;
2923
2935
  }
@@ -3068,7 +3080,7 @@ function buildSplitConfigObject(flowSettings, namedImports) {
3068
3080
  if (typeof step.import === "string" && step.package) {
3069
3081
  return step.import;
3070
3082
  }
3071
- return packageNameToVariable(step.package);
3083
+ return packageNameToVariable2(step.package);
3072
3084
  }
3073
3085
  function getStepProps(step) {
3074
3086
  const props = {};
@@ -3528,6 +3540,7 @@ var init_bundler = __esm({
3528
3540
  init_config_classifier();
3529
3541
  init_structural_validators();
3530
3542
  init_structural_validators();
3543
+ init_step_packages();
3531
3544
  init_package_manager();
3532
3545
  init_nft_trace();
3533
3546
  init_assert_consumer_deps();
@@ -8249,7 +8262,7 @@ function validateMapping(input) {
8249
8262
  // src/commands/validate/validators/entry.ts
8250
8263
  import Ajv from "ajv";
8251
8264
  import { fetchPackageSchema } from "@walkeros/core";
8252
- var CLIENT_HEADER = "walkeros-cli/4.4.0";
8265
+ var CLIENT_HEADER = "walkeros-cli/4.5.0";
8253
8266
  var SECTIONS = ["destinations", "sources", "transformers"];
8254
8267
  function resolveEntry(path20, flowConfig) {
8255
8268
  const flows = flowConfig.flows;
@@ -8815,7 +8828,7 @@ init_config_file();
8815
8828
  import { createHash } from "crypto";
8816
8829
  import semver4 from "semver";
8817
8830
  var bakedContractVersion = true ? "4.3.0" : PLACEHOLDER;
8818
- var bakedContractHash = true ? "921ca196fc71f3bf88bb0104338240438eb9411b274641d35c82b1462b4865b5" : "";
8831
+ var bakedContractHash = true ? "78d9f32be512ebb51e8c6c262aab05dd4eda28a84269fc53ff87b88e41940e6d" : "";
8819
8832
  function isRecord3(value) {
8820
8833
  return value !== null && typeof value === "object" && !Array.isArray(value);
8821
8834
  }