@package-pal/core 0.0.13 → 0.0.14

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.
Files changed (33) hide show
  1. package/index.d.ts +4 -0
  2. package/index.d.ts.map +1 -1
  3. package/index.js +315 -96
  4. package/index.js.map +13 -12
  5. package/lib/configuration/functions/get-ignore-globs.d.ts +7 -0
  6. package/lib/configuration/functions/get-ignore-globs.d.ts.map +1 -0
  7. package/lib/configuration/functions/load-config.d.ts.map +1 -1
  8. package/lib/configuration/functions/parse-config.d.ts +14 -0
  9. package/lib/configuration/functions/parse-config.d.ts.map +1 -1
  10. package/lib/configuration/schemas/config.d.ts +21 -0
  11. package/lib/configuration/schemas/config.d.ts.map +1 -1
  12. package/lib/configuration/types/activated-config.d.ts +1 -0
  13. package/lib/configuration/types/activated-config.d.ts.map +1 -1
  14. package/lib/configuration/types/bump-package-callback-props.d.ts +42 -0
  15. package/lib/configuration/types/bump-package-callback-props.d.ts.map +1 -0
  16. package/lib/configuration/types/bump-packages-ready-callback-props.d.ts +14 -0
  17. package/lib/configuration/types/bump-packages-ready-callback-props.d.ts.map +1 -0
  18. package/lib/configuration/types/config.d.ts +16 -0
  19. package/lib/configuration/types/config.d.ts.map +1 -1
  20. package/lib/configuration/types/packages-ready-callback-props.d.ts +11 -0
  21. package/lib/configuration/types/packages-ready-callback-props.d.ts.map +1 -1
  22. package/lib/configuration/types/process-package-callback-props.d.ts +18 -0
  23. package/lib/configuration/types/process-package-callback-props.d.ts.map +1 -1
  24. package/lib/graph/functions/dfs-traverse-graph.d.ts +4 -1
  25. package/lib/graph/functions/dfs-traverse-graph.d.ts.map +1 -1
  26. package/lib/package/functions/bump-package-version.d.ts.map +1 -1
  27. package/lib/package/functions/scan-glob-pattern-paths.d.ts.map +1 -1
  28. package/lib/types/bump-package-version-options.d.ts +1 -0
  29. package/lib/types/bump-package-version-options.d.ts.map +1 -1
  30. package/lib/types/bump-version-type.d.ts +4 -4
  31. package/lib/watch/functions/filter-files-modified-since.d.ts.map +1 -1
  32. package/lib/watch/functions/watch-package-changes.d.ts.map +1 -1
  33. package/package.json +2 -2
package/index.d.ts CHANGED
@@ -7,7 +7,11 @@ export type * from './lib/types/watch-packages-options.ts';
7
7
  export * from './lib/types/bump-version-type.ts';
8
8
  export type * from './lib/configuration/types/logger.ts';
9
9
  export type { Config, SchemaLogLevel as LogLevel, } from './lib/configuration/types/config.ts';
10
+ export type * from './lib/configuration/types/subprocess-callback.ts';
11
+ export type * from './lib/configuration/types/bump-package-callback-props.ts';
12
+ export type * from './lib/configuration/types/bump-packages-ready-callback-props.ts';
10
13
  export type * from './lib/configuration/types/process-package-callback-props.ts';
14
+ export type * from './lib/configuration/types/packages-ready-callback-props.ts';
11
15
  export type * from './lib/graph/types/package-graph.ts';
12
16
  export type * from './lib/graph/types/package-graphs.ts';
13
17
  export type * from './lib/graph/types/package-node.ts';
package/index.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../packages/core/src/index.ts"],"names":[],"mappings":"AAAA,mBAAmB,yCAAyC,CAAC;AAC7D,mBAAmB,0CAA0C,CAAC;AAC9D,mBAAmB,0CAA0C,CAAC;AAC9D,mBAAmB,8DAA8D,CAAC;AAClF,mBAAmB,6CAA6C,CAAC;AACjE,mBAAmB,uCAAuC,CAAC;AAC3D,cAAc,kCAAkC,CAAC;AAEjD,mBAAmB,qCAAqC,CAAC;AACzD,YAAY,EACX,MAAM,EAAE,cAAc,IAAI,QAAQ,GAClC,MAAM,qCAAqC,CAAC;AAC7C,mBAAmB,6DAA6D,CAAC;AAEjF,mBAAmB,oCAAoC,CAAC;AACxD,mBAAmB,qCAAqC,CAAC;AACzD,mBAAmB,mCAAmC,CAAC;AACvD,mBAAmB,oCAAoC,CAAC;AAExD,mBAAmB,qCAAqC,CAAC;AACzD,cAAc,wCAAwC,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,+CAA+C,CAAC;AACjF,OAAO,EAAE,gBAAgB,EAAE,MAAM,6CAA6C,CAAC;AAE/E,mBAAmB,sCAAsC,CAAC;AAE1D,cAAc,cAAc,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../packages/core/src/index.ts"],"names":[],"mappings":"AAAA,mBAAmB,yCAAyC,CAAC;AAC7D,mBAAmB,0CAA0C,CAAC;AAC9D,mBAAmB,0CAA0C,CAAC;AAC9D,mBAAmB,8DAA8D,CAAC;AAClF,mBAAmB,6CAA6C,CAAC;AACjE,mBAAmB,uCAAuC,CAAC;AAC3D,cAAc,kCAAkC,CAAC;AAEjD,mBAAmB,qCAAqC,CAAC;AACzD,YAAY,EACX,MAAM,EAAE,cAAc,IAAI,QAAQ,GAClC,MAAM,qCAAqC,CAAC;AAC7C,mBAAmB,kDAAkD,CAAC;AACtE,mBAAmB,0DAA0D,CAAC;AAC9E,mBAAmB,iEAAiE,CAAC;AACrF,mBAAmB,6DAA6D,CAAC;AACjF,mBAAmB,4DAA4D,CAAC;AAEhF,mBAAmB,oCAAoC,CAAC;AACxD,mBAAmB,qCAAqC,CAAC;AACzD,mBAAmB,mCAAmC,CAAC;AACvD,mBAAmB,oCAAoC,CAAC;AAExD,mBAAmB,qCAAqC,CAAC;AACzD,cAAc,wCAAwC,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,+CAA+C,CAAC;AACjF,OAAO,EAAE,gBAAgB,EAAE,MAAM,6CAA6C,CAAC;AAE/E,mBAAmB,sCAAsC,CAAC;AAE1D,cAAc,cAAc,CAAC"}
package/index.js CHANGED
@@ -1,12 +1,12 @@
1
1
  // @bun
2
2
  // packages/core/src/lib/types/bump-version-type.ts
3
3
  var BumpVersionType = {
4
- Major: "major",
5
- Minor: "minor",
6
4
  Patch: "patch",
7
- Premajor: "premajor",
8
- Preminor: "preminor",
5
+ Minor: "minor",
6
+ Major: "major",
9
7
  Prepatch: "prepatch",
8
+ Preminor: "preminor",
9
+ Premajor: "premajor",
10
10
  Prerelease: "prerelease"
11
11
  };
12
12
  // packages/core/src/lib/package/types/package-adapter.ts
@@ -95,6 +95,18 @@ var Config = z3.object({
95
95
  preId: z3.optional(z3.string()),
96
96
  exact: z3.optional(z3.boolean())
97
97
  })),
98
+ bump: z3.optional(zLooseObjectWithoutIndexSignature({
99
+ ignore: z3.optional(z3.union([z3.string(), z3.array(z3.string())])),
100
+ hooks: z3.optional(z3.object({
101
+ onBeforeProcessPackage: z3.optional(zLooseFunction()),
102
+ onProcessPackage: z3.optional(zLooseFunction()),
103
+ onAfterProcessPackage: z3.optional(zLooseFunction()),
104
+ onBeforePackagesReady: z3.optional(zLooseFunction()),
105
+ onPackagesReady: z3.optional(zLooseFunction()),
106
+ onAfterPackagesReady: z3.optional(zLooseFunction())
107
+ })),
108
+ subprocess: z3.optional(z3.object({ concurrency: z3.nullish(z3.number()) }))
109
+ })),
98
110
  watch: z3.optional(zLooseObjectWithoutIndexSignature({
99
111
  debounceMs: z3.optional(z3.number()),
100
112
  ignore: z3.optional(z3.union([z3.string(), z3.array(z3.string())])),
@@ -221,6 +233,18 @@ var defaultConfig = {
221
233
  preId: "",
222
234
  exact: false
223
235
  },
236
+ bump: {
237
+ ignore: "",
238
+ hooks: {
239
+ onBeforeProcessPackage: noOp2,
240
+ onProcessPackage: noOp2,
241
+ onAfterProcessPackage: noOp2,
242
+ onBeforePackagesReady: noOp2,
243
+ onPackagesReady: noOp2,
244
+ onAfterPackagesReady: noOp2
245
+ },
246
+ subprocess: { concurrency: null }
247
+ },
224
248
  watch: {
225
249
  debounceMs: 500,
226
250
  ignore: "",
@@ -388,7 +412,7 @@ import { assertDefined as assertDefined5 } from "@package-pal/util";
388
412
 
389
413
  // packages/core/src/lib/graph/functions/dfs-traverse-graph.ts
390
414
  import { assertDefined as assertDefined4 } from "@package-pal/util";
391
- var dfsTraverseGraph = function* (graph, traverseFromPackages) {
415
+ var dfsTraverseGraph = function* (graph, traverseFromPackages, options) {
392
416
  const visited = new Set;
393
417
  const stack = Array.isArray(traverseFromPackages) ? traverseFromPackages.slice() : [traverseFromPackages];
394
418
  while (stack.length) {
@@ -404,6 +428,9 @@ var dfsTraverseGraph = function* (graph, traverseFromPackages) {
404
428
  yield node.packageData;
405
429
  for (const dep of node.pointsToPackages) {
406
430
  if (!visited.has(dep)) {
431
+ if (options?.shouldTraverse && !options.shouldTraverse(dep)) {
432
+ continue;
433
+ }
407
434
  stack.push(dep);
408
435
  }
409
436
  }
@@ -572,87 +599,25 @@ var generateTopologicalSortedGroups = (packageGraph, logger) => {
572
599
  };
573
600
 
574
601
  // packages/core/src/lib/package/functions/bump-package-version.ts
575
- import { styleText as styleText5 } from "util";
602
+ import { dirname as dirname4 } from "path";
603
+ import { styleText as styleText6 } from "util";
576
604
  import {
577
605
  isDefined as isDefined2,
606
+ normalisePath,
578
607
  runAsync
579
608
  } from "@package-pal/util";
580
609
  import { inc } from "semver";
581
- var dependentWriteConcurrency = 20;
582
- var bumpPackageVersion = async (options) => {
583
- const exact = isDefined2(options.exact) ? options.exact : options.config.version.exact;
584
- const preId = isDefined2(options.preId) ? options.preId : options.config.version.preId;
585
- const {
586
- packageName,
587
- type,
588
- packageGraphs,
589
- adapter,
590
- config: { logger }
591
- } = options;
592
- logger.debug(styleText5("dim", `Bumping package '${packageName}'...`));
593
- const packageNode = packageGraphs.dependencies.get(packageName);
594
- if (!packageNode) {
595
- throw new Error(`Package '${packageName}' not found.`);
596
- }
597
- const currentVersion = packageNode.packageData.version ?? "1.0.0";
598
- const bumpedVersion = inc(currentVersion, type, undefined, preId);
599
- if (!bumpedVersion) {
600
- throw new Error(`Package '${packageName}' version '${currentVersion}' is invalid.`);
601
- }
602
- logger.info(`Updating '${packageName}' version: ${currentVersion} \u2192 ${bumpedVersion}.`);
603
- await adapter.bumpOwnVersion(packageNode.packageData, bumpedVersion, logger);
604
- const dependentWriteTasks = [];
605
- for (const dependent of dfsTraverseGraph(packageGraphs.dependents, packageName)) {
606
- dependentWriteTasks.push(async () => {
607
- const updated = await adapter.bumpDependencyVersion(dependent, packageName, bumpedVersion, exact, logger);
608
- if (updated) {
609
- logger.debug(styleText5("dim", `Updated dependency '${packageName}' in '${dependent.name}'.`));
610
- }
611
- });
612
- }
613
- await runAsync(dependentWriteTasks, dependentWriteConcurrency);
614
- };
615
610
 
616
- // packages/core/src/lib/package/functions/load-packages.ts
617
- import { styleText as styleText6 } from "util";
618
- import { normalisePath } from "@package-pal/util";
619
- var loadPackages = async (rootDir, packagePatterns, adapter, logger) => {
620
- let resolvedPatterns = packagePatterns;
621
- if (packagePatterns.length === 1 && packagePatterns[0] === "packages/*") {
622
- resolvedPatterns = adapter.defaultPatterns;
623
- }
624
- const patternContent = resolvedPatterns.map((pattern) => `'${pattern}'`).join(", ");
625
- logger.debug(styleText6("dim", `Loading packages matching pattern/s ${patternContent}...${rootDir ? ` from ${rootDir}` : ""}`));
626
- const packages = [];
627
- const seenByName = new Map;
628
- for await (const packageData of adapter.scanPackages(Array.from(new Set(resolvedPatterns)), logger, rootDir)) {
629
- const normalizedPath = normalisePath(packageData.path);
630
- const existingPath = seenByName.get(packageData.name);
631
- if (existingPath === normalizedPath) {
632
- continue;
633
- }
634
- if (existingPath) {
635
- const duplicatePaths = existingPath.localeCompare(normalizedPath) <= 0 ? [existingPath, normalizedPath] : [normalizedPath, existingPath];
636
- throw new Error(`Duplicate package name '${packageData.name}' found in multiple manifests: '${duplicatePaths[0]}' and '${duplicatePaths[1]}'.`);
637
- }
638
- seenByName.set(packageData.name, normalizedPath);
639
- packages.push(packageData);
640
- }
641
- if (!packages.length) {
642
- throw new Error(`No packages found for pattern/s ${patternContent}.`);
643
- }
644
- return packages.sort((a, b) => a.name.localeCompare(b.name) || normalisePath(a.path).localeCompare(normalisePath(b.path)));
611
+ // packages/core/src/lib/configuration/functions/get-ignore-globs.ts
612
+ var {Glob } = globalThis.Bun;
613
+ var getIgnoreGlobs = (ignore) => {
614
+ const patterns = Array.isArray(ignore) ? ignore : [ignore];
615
+ const filtered = patterns.filter((pattern) => pattern.length > 0);
616
+ return filtered.length === 0 ? undefined : filtered.map((pattern) => new Glob(pattern));
645
617
  };
646
618
 
647
- // packages/core/src/lib/package/functions/run-for-each-package.ts
648
- import { dirname as dirname4 } from "path";
649
- import {
650
- assertDefined as assertDefined8,
651
- runAsync as runAsync2
652
- } from "@package-pal/util";
653
-
654
619
  // packages/core/src/lib/process/functions/run-subprocess.ts
655
- import { styleText as styleText7 } from "util";
620
+ import { styleText as styleText5 } from "util";
656
621
 
657
622
  // packages/core/src/lib/process/types/exit-state.ts
658
623
  var ExitState = {
@@ -948,7 +913,7 @@ var cancelCodes = new Set([
948
913
  ]);
949
914
  var runSubprocess = async (opts) => {
950
915
  if (opts.signal?.aborted) {
951
- opts.logger?.debug(styleText7("dim", `Skipped '${opts.debugName}' subprocess command; signal already cancelled.`));
916
+ opts.logger?.debug(styleText5("dim", `Skipped '${opts.debugName}' subprocess command; signal already cancelled.`));
952
917
  return ExitState.Cancelled;
953
918
  }
954
919
  const {
@@ -975,11 +940,11 @@ var runSubprocess = async (opts) => {
975
940
  const [readStdout, readStderr] = [{
976
941
  source: subprocess.stdout,
977
942
  type: StdType.Out,
978
- writer: getLineBufferedWriter(styleText7("dim", `[O-${pid}]`.padEnd(minPrefixLen, " ")))
943
+ writer: getLineBufferedWriter(styleText5("dim", `[O-${pid}]`.padEnd(minPrefixLen, " ")))
979
944
  }, {
980
945
  source: subprocess.stderr,
981
946
  type: StdType.Err,
982
- writer: getLineBufferedWriter(styleText7("yellow", styleText7("dim", `[E-${pid}]`.padEnd(minPrefixLen, " "))), undefined, process.stderr.write.bind(process.stderr))
947
+ writer: getLineBufferedWriter(styleText5("yellow", styleText5("dim", `[E-${pid}]`.padEnd(minPrefixLen, " "))), undefined, process.stderr.write.bind(process.stderr))
983
948
  }].map(async ({
984
949
  source,
985
950
  type,
@@ -998,7 +963,7 @@ var runSubprocess = async (opts) => {
998
963
  writer.flush();
999
964
  });
1000
965
  const executedCommand = commands.join(" ");
1001
- opts.logger?.debug(styleText7("dim", `Started '${opts.debugName}' subprocess command '${opts.shellCommand}' (${executedCommand}) with PID ${pid}.`));
966
+ opts.logger?.debug(styleText5("dim", `Started '${opts.debugName}' subprocess command '${opts.shellCommand}' (${executedCommand}) with PID ${pid}.`));
1002
967
  const [
1003
968
  ,
1004
969
  ,
@@ -1008,21 +973,267 @@ var runSubprocess = async (opts) => {
1008
973
  readStderr,
1009
974
  subprocess.exited.then((exitCode) => {
1010
975
  if (cancelCodes.has(exitCode)) {
1011
- opts.logger?.debug(styleText7("dim", `Cancelled '${opts.debugName}' subprocess command; PID ${pid} exited.`));
976
+ opts.logger?.debug(styleText5("dim", `Cancelled '${opts.debugName}' subprocess command; PID ${pid} exited.`));
1012
977
  return ExitState.Cancelled;
1013
978
  }
1014
979
  if (exitCode !== 0) {
1015
- opts.logger?.error(styleText7("red", `'${opts.debugName}' command '${opts.shellCommand}' (${executedCommand}) with PID ${pid} failed with exit code ${exitCode.toString()}.`));
980
+ opts.logger?.error(styleText5("red", `'${opts.debugName}' command '${opts.shellCommand}' (${executedCommand}) with PID ${pid} failed with exit code ${exitCode.toString()}.`));
1016
981
  return ExitState.Errored;
1017
982
  }
1018
- opts.logger?.debug(styleText7("dim", `Completed '${opts.debugName}' subprocess command; PID ${pid} exited.`));
983
+ opts.logger?.debug(styleText5("dim", `Completed '${opts.debugName}' subprocess command; PID ${pid} exited.`));
1019
984
  return ExitState.Completed;
1020
985
  })
1021
986
  ]);
1022
987
  return exitState;
1023
988
  };
1024
989
 
990
+ // packages/core/src/lib/package/functions/bump-package-version.ts
991
+ var dependentWriteConcurrency = 20;
992
+ var runBumpHookCommand = async (debugName, shellCommand, options) => {
993
+ if (!shellCommand) {
994
+ return;
995
+ }
996
+ const exitState = await runSubprocess({
997
+ ...options,
998
+ debugName,
999
+ shellCommand
1000
+ });
1001
+ if (exitState === ExitState.Errored) {
1002
+ throw new Error(`Bump hook '${debugName}' failed.`);
1003
+ }
1004
+ };
1005
+ var toShellCommand = (value) => {
1006
+ return typeof value === "string" ? value : undefined;
1007
+ };
1008
+ var isIgnoredPackage = (packageData, ignoreGlobs) => {
1009
+ const normalisedPath = normalisePath(packageData.path);
1010
+ const normalisedDir = normalisePath(packageData.dir);
1011
+ return ignoreGlobs.some((glob) => glob.match(normalisedPath) || glob.match(normalisedDir));
1012
+ };
1013
+ var getBumpHookProps = (bumpGroups) => {
1014
+ return {
1015
+ totalBumps: new Map(bumpGroups.flat().map((bump) => [bump.name, bump])),
1016
+ totalBumpOrder: bumpGroups.map((group) => group.map((bump) => bump.name))
1017
+ };
1018
+ };
1019
+ var runBumpPackageHooks = async (bumpConfig, bumpGroup, allBumpGroups, logger) => {
1020
+ const {
1021
+ totalBumps,
1022
+ totalBumpOrder
1023
+ } = getBumpHookProps(allBumpGroups);
1024
+ await runAsync(bumpGroup.map((bump) => async () => {
1025
+ const props = {
1026
+ ...bump,
1027
+ totalBumps,
1028
+ totalBumpOrder
1029
+ };
1030
+ const cwd2 = dirname4(bump.path);
1031
+ const env2 = {
1032
+ PP_PACKAGE_NAME: bump.name,
1033
+ PP_PACKAGE_DIR: bump.dir,
1034
+ PP_PACKAGE_PATH: bump.path,
1035
+ PP_PACKAGE_VERSION: bump.version,
1036
+ PP_PACKAGE_PREVIOUS_VERSION: bump.previousVersion,
1037
+ PP_PACKAGE_BUMP_TYPE: bump.type
1038
+ };
1039
+ await runBumpHookCommand(`before bump ${bump.name}`, toShellCommand(await bumpConfig.hooks.onBeforeProcessPackage(props)), {
1040
+ cwd: cwd2,
1041
+ env: env2,
1042
+ logger
1043
+ });
1044
+ await runBumpHookCommand(`bump ${bump.name}`, toShellCommand(await bumpConfig.hooks.onProcessPackage(props)), {
1045
+ cwd: cwd2,
1046
+ env: env2,
1047
+ logger
1048
+ });
1049
+ await runBumpHookCommand(`after bump ${bump.name}`, toShellCommand(await bumpConfig.hooks.onAfterProcessPackage(props)), {
1050
+ cwd: cwd2,
1051
+ env: env2,
1052
+ logger
1053
+ });
1054
+ }), bumpConfig.subprocess.concurrency);
1055
+ };
1056
+ var runBumpReadyHooks = async (bumpConfig, bumpGroups, logger) => {
1057
+ const {
1058
+ totalBumps,
1059
+ totalBumpOrder
1060
+ } = getBumpHookProps(bumpGroups);
1061
+ const readyProps = {
1062
+ totalBumps,
1063
+ totalBumpOrder
1064
+ };
1065
+ await runBumpHookCommand("before bump packages ready", toShellCommand(await bumpConfig.hooks.onBeforePackagesReady(readyProps)), { logger });
1066
+ await runBumpHookCommand("bump packages ready", toShellCommand(await bumpConfig.hooks.onPackagesReady(readyProps)), { logger });
1067
+ await runBumpHookCommand("after bump packages ready", toShellCommand(await bumpConfig.hooks.onAfterPackagesReady(readyProps)), { logger });
1068
+ };
1069
+ var createBumpPackage = (packageName, options) => ({
1070
+ name: packageName,
1071
+ dir: options.dir,
1072
+ path: options.path,
1073
+ previousVersion: options.previousVersion,
1074
+ version: options.version,
1075
+ type: options.type,
1076
+ isSourcePackage: options.isSourcePackage
1077
+ });
1078
+ var bumpPackageVersion = async (options) => {
1079
+ const exact = isDefined2(options.exact) ? options.exact : options.config.version.exact;
1080
+ const preId = isDefined2(options.preId) ? options.preId : options.config.version.preId;
1081
+ const {
1082
+ packageName,
1083
+ type,
1084
+ cascade,
1085
+ packageGraphs,
1086
+ adapter,
1087
+ config: {
1088
+ bump,
1089
+ logger
1090
+ }
1091
+ } = options;
1092
+ logger.debug(styleText6("dim", `Bumping package '${packageName}'...`));
1093
+ const packageNode = packageGraphs.dependencies.get(packageName);
1094
+ if (!packageNode) {
1095
+ throw new Error(`Package '${packageName}' not found.`);
1096
+ }
1097
+ const ignoreGlobs = getIgnoreGlobs(bump.ignore);
1098
+ const ignoredPackageNames = !ignoreGlobs ? new Set : new Set(Array.from(packageGraphs.dependencies.values()).filter((node) => isIgnoredPackage(node.packageData, ignoreGlobs)).map((node) => node.packageData.name));
1099
+ if (ignoredPackageNames.has(packageName)) {
1100
+ throw new Error(`Package '${packageName}' matches bump.ignore and cannot be bumped.`);
1101
+ }
1102
+ const traversed = Array.from(dfsTraverseGraph(packageGraphs.dependents, packageName, { shouldTraverse: (name) => {
1103
+ if (ignoredPackageNames.has(name)) {
1104
+ logger.debug(styleText6("dim", `Ignoring bump cascade through '${name}' (matched bump.ignore).`));
1105
+ return false;
1106
+ }
1107
+ return true;
1108
+ } }));
1109
+ const packageNamesToBump = new Set(traversed.map((pkg) => pkg.name));
1110
+ const dependentsToBump = traversed.filter((pkg) => pkg.name !== packageName);
1111
+ const bumpGroups = [];
1112
+ if (cascade) {
1113
+ const sortedGroupsObj = generateTopologicalSortedGroups(packageGraphs.dependencies, logger);
1114
+ const packagesToProcessInOrder = sortedGroupsObj.groups.map((group) => group.filter((name) => packageNamesToBump.has(name))).filter((group) => group.length > 0);
1115
+ const circularPackagesToProcess = sortedGroupsObj.circular.filter((name) => packageNamesToBump.has(name));
1116
+ if (circularPackagesToProcess.length > 0) {
1117
+ packagesToProcessInOrder.push(circularPackagesToProcess);
1118
+ }
1119
+ for (const packageGroup of packagesToProcessInOrder) {
1120
+ const groupBumps = [];
1121
+ for (const currentPackageName of packageGroup) {
1122
+ const node = packageGraphs.dependencies.get(currentPackageName);
1123
+ if (!node) {
1124
+ continue;
1125
+ }
1126
+ const currentVersion = node.packageData.version ?? "1.0.0";
1127
+ const bumpType = currentPackageName === packageName ? type : cascade;
1128
+ const nextVersion = inc(currentVersion, bumpType, undefined, preId);
1129
+ if (!nextVersion) {
1130
+ throw new Error(`Package '${currentPackageName}' version '${currentVersion}' is invalid.`);
1131
+ }
1132
+ groupBumps.push(createBumpPackage(currentPackageName, {
1133
+ dir: node.packageData.dir,
1134
+ path: node.packageData.path,
1135
+ previousVersion: currentVersion,
1136
+ version: nextVersion,
1137
+ type: bumpType,
1138
+ isSourcePackage: currentPackageName === packageName
1139
+ }));
1140
+ }
1141
+ if (groupBumps.length > 0) {
1142
+ bumpGroups.push(groupBumps);
1143
+ }
1144
+ }
1145
+ const bumpedVersionsMap = new Map;
1146
+ for (const groupBumps of bumpGroups) {
1147
+ const groupBumpedVersionsMap = new Map(groupBumps.map((bumpPackage) => [bumpPackage.name, bumpPackage.version]));
1148
+ for (const [currentPackageName, nextVersion] of groupBumpedVersionsMap) {
1149
+ bumpedVersionsMap.set(currentPackageName, nextVersion);
1150
+ }
1151
+ await runAsync(groupBumps.map((bumpPackage) => async () => {
1152
+ const node = packageGraphs.dependencies.get(bumpPackage.name);
1153
+ if (!node) {
1154
+ return;
1155
+ }
1156
+ for (const depName of node.packageData.localDependencies ?? []) {
1157
+ const newlyBumpedVersion = bumpedVersionsMap.get(depName);
1158
+ if (newlyBumpedVersion) {
1159
+ await adapter.bumpDependencyVersion(node.packageData, depName, newlyBumpedVersion, exact, logger);
1160
+ }
1161
+ }
1162
+ logger.debug(styleText6("dim", `Bumping '${bumpPackage.name}' (${bumpPackage.type}): ${bumpPackage.previousVersion} \u2192 ${bumpPackage.version}`));
1163
+ await adapter.bumpOwnVersion(node.packageData, bumpPackage.version, logger);
1164
+ node.packageData.version = bumpPackage.version;
1165
+ }), dependentWriteConcurrency);
1166
+ await runBumpPackageHooks(bump, groupBumps, bumpGroups, logger);
1167
+ }
1168
+ } else {
1169
+ const currentVersion = packageNode.packageData.version ?? "1.0.0";
1170
+ const bumpedVersion = inc(currentVersion, type, undefined, preId);
1171
+ if (!bumpedVersion) {
1172
+ throw new Error(`Package '${packageName}' version '${currentVersion}' is invalid.`);
1173
+ }
1174
+ const sourceBump = createBumpPackage(packageName, {
1175
+ dir: packageNode.packageData.dir,
1176
+ path: packageNode.packageData.path,
1177
+ previousVersion: currentVersion,
1178
+ version: bumpedVersion,
1179
+ type,
1180
+ isSourcePackage: true
1181
+ });
1182
+ bumpGroups.push([sourceBump]);
1183
+ logger.debug(styleText6("dim", `Bumping '${packageName}' (${type}): ${currentVersion} \u2192 ${bumpedVersion}`));
1184
+ await adapter.bumpOwnVersion(packageNode.packageData, bumpedVersion, logger);
1185
+ const dependentWriteTasks = [];
1186
+ for (const dependent of dependentsToBump) {
1187
+ dependentWriteTasks.push(async () => {
1188
+ const updated = await adapter.bumpDependencyVersion(dependent, packageName, bumpedVersion, exact, logger);
1189
+ if (updated) {
1190
+ logger.debug(styleText6("dim", `Updated dependency '${packageName}' in '${dependent.name}'.`));
1191
+ }
1192
+ });
1193
+ }
1194
+ await runAsync(dependentWriteTasks, dependentWriteConcurrency);
1195
+ await runBumpPackageHooks(bump, [sourceBump], bumpGroups, logger);
1196
+ }
1197
+ await runBumpReadyHooks(bump, bumpGroups, logger);
1198
+ };
1199
+
1200
+ // packages/core/src/lib/package/functions/load-packages.ts
1201
+ import { styleText as styleText7 } from "util";
1202
+ import { normalisePath as normalisePath2 } from "@package-pal/util";
1203
+ var loadPackages = async (rootDir, packagePatterns, adapter, logger) => {
1204
+ let resolvedPatterns = packagePatterns;
1205
+ if (packagePatterns.length === 1 && packagePatterns[0] === "packages/*") {
1206
+ resolvedPatterns = adapter.defaultPatterns;
1207
+ }
1208
+ const patternContent = resolvedPatterns.map((pattern) => `'${pattern}'`).join(", ");
1209
+ logger.debug(styleText7("dim", `Loading packages matching pattern/s ${patternContent}...${rootDir ? ` from ${rootDir}` : ""}`));
1210
+ const packages = [];
1211
+ const seenByName = new Map;
1212
+ for await (const packageData of adapter.scanPackages(Array.from(new Set(resolvedPatterns)), logger, rootDir)) {
1213
+ const normalizedPath = normalisePath2(packageData.path);
1214
+ const existingPath = seenByName.get(packageData.name);
1215
+ if (existingPath === normalizedPath) {
1216
+ continue;
1217
+ }
1218
+ if (existingPath) {
1219
+ const duplicatePaths = existingPath.localeCompare(normalizedPath) <= 0 ? [existingPath, normalizedPath] : [normalizedPath, existingPath];
1220
+ throw new Error(`Duplicate package name '${packageData.name}' found in multiple manifests: '${duplicatePaths[0]}' and '${duplicatePaths[1]}'.`);
1221
+ }
1222
+ seenByName.set(packageData.name, normalizedPath);
1223
+ packages.push(packageData);
1224
+ }
1225
+ if (!packages.length) {
1226
+ throw new Error(`No packages found for pattern/s ${patternContent}.`);
1227
+ }
1228
+ return packages.sort((a, b) => a.name.localeCompare(b.name) || normalisePath2(a.path).localeCompare(normalisePath2(b.path)));
1229
+ };
1230
+
1025
1231
  // packages/core/src/lib/package/functions/run-for-each-package.ts
1232
+ import { dirname as dirname5 } from "path";
1233
+ import {
1234
+ assertDefined as assertDefined8,
1235
+ runAsync as runAsync2
1236
+ } from "@package-pal/util";
1026
1237
  var runForEachPackage = async (packageGraphs, packageOrder, getCommand, logger, topological = true, concurrency) => {
1027
1238
  const controller = new AbortController;
1028
1239
  let processPackageOrder = packageOrder.circular.length > 0 ? packageOrder.groups.concat([packageOrder.circular]) : packageOrder.groups;
@@ -1036,7 +1247,7 @@ var runForEachPackage = async (packageGraphs, packageOrder, getCommand, logger,
1036
1247
  name: packageName,
1037
1248
  dir: packageNode.packageData.dir
1038
1249
  };
1039
- const processPackageCwd = dirname4(packageNode.packageData.path);
1250
+ const processPackageCwd = dirname5(packageNode.packageData.path);
1040
1251
  const shellCommand = await getCommand(processPackageProps);
1041
1252
  if (!shellCommand) {
1042
1253
  return;
@@ -1065,7 +1276,7 @@ import {
1065
1276
  watch
1066
1277
  } from "fs";
1067
1278
  import {
1068
- dirname as dirname6,
1279
+ dirname as dirname7,
1069
1280
  join as join3
1070
1281
  } from "path";
1071
1282
  import { styleText as styleText9 } from "util";
@@ -1074,10 +1285,9 @@ import {
1074
1285
  getDeferredPromise,
1075
1286
  getStringMatcher,
1076
1287
  isDefined as isDefined4,
1077
- normalisePath as normalisePath2,
1288
+ normalisePath as normalisePath3,
1078
1289
  runAsync as runAsync4
1079
1290
  } from "@package-pal/util";
1080
- var {Glob } = globalThis.Bun;
1081
1291
 
1082
1292
  // packages/core/src/lib/graph/functions/merge-graphs.ts
1083
1293
  var mergeGraphs = (a, b) => {
@@ -1145,6 +1355,7 @@ var dedupeSharedPaths = (paths, by) => {
1145
1355
  // packages/core/src/lib/watch/functions/filter-files-modified-since.ts
1146
1356
  import { stat } from "fs/promises";
1147
1357
  import { runAsync as runAsync3 } from "@package-pal/util";
1358
+ var fileStatConcurrency = 20;
1148
1359
  var filterFilesModifiedSince = async (paths, sinceMs) => {
1149
1360
  const tasks = paths.map((path) => async () => {
1150
1361
  try {
@@ -1155,7 +1366,7 @@ var filterFilesModifiedSince = async (paths, sinceMs) => {
1155
1366
  return path;
1156
1367
  }
1157
1368
  });
1158
- const results = await runAsync3(tasks, 20);
1369
+ const results = await runAsync3(tasks, fileStatConcurrency);
1159
1370
  return results.filter((path) => path !== null);
1160
1371
  };
1161
1372
 
@@ -1306,7 +1517,7 @@ var getChangeLogic = (packageGraphs, packageChanges, lastProcessedSubgraph, conf
1306
1517
  // packages/core/src/lib/watch/functions/normalise-watched-file-path.ts
1307
1518
  import {
1308
1519
  basename as basename3,
1309
- dirname as dirname5,
1520
+ dirname as dirname6,
1310
1521
  join as join2
1311
1522
  } from "path";
1312
1523
  var removeTrailing = [
@@ -1320,7 +1531,7 @@ var removeTrailing = [
1320
1531
  ".swn"
1321
1532
  ];
1322
1533
  var normaliseWatchedFilePath = (filePath) => {
1323
- const dir = dirname5(filePath);
1534
+ const dir = dirname6(filePath);
1324
1535
  let base = basename3(filePath);
1325
1536
  const baseLower = base.toLowerCase();
1326
1537
  for (const trailing of removeTrailing) {
@@ -1369,13 +1580,18 @@ var onProcessPackage = async (packageGraphs, packageChanges, watchConfig, determ
1369
1580
  totalProcessOrder: changedPackageProcessOrder,
1370
1581
  signal: controller.signal
1371
1582
  };
1372
- const processPackageCwd = dirname6(packageNode.packageData.path);
1583
+ const processPackageCwd = dirname7(packageNode.packageData.path);
1584
+ const processPackageEnv = {
1585
+ PP_PACKAGE_NAME: packageName,
1586
+ PP_PACKAGE_DIR: processPackageProps.dir
1587
+ };
1373
1588
  const beforeProcessPackageShellCommand = await watchConfig.hooks.onBeforeProcessPackage(processPackageProps);
1374
1589
  if (beforeProcessPackageShellCommand) {
1375
1590
  await runSubprocess({
1376
1591
  debugName: `before process ${packageName}`,
1377
1592
  shellCommand: beforeProcessPackageShellCommand,
1378
1593
  cwd: processPackageCwd,
1594
+ env: processPackageEnv,
1379
1595
  signal: controller.signal,
1380
1596
  logger
1381
1597
  });
@@ -1396,6 +1612,7 @@ var onProcessPackage = async (packageGraphs, packageChanges, watchConfig, determ
1396
1612
  debugName: `process ${packageName}`,
1397
1613
  shellCommand: processPackageShellCommand,
1398
1614
  cwd: processPackageCwd,
1615
+ env: processPackageEnv,
1399
1616
  signal: controller.signal,
1400
1617
  logger,
1401
1618
  onStdChunk: (chunk) => {
@@ -1421,6 +1638,7 @@ var onProcessPackage = async (packageGraphs, packageChanges, watchConfig, determ
1421
1638
  debugName: `after process ${packageName}`,
1422
1639
  shellCommand: processPackageErrorCommand,
1423
1640
  cwd: processPackageCwd,
1641
+ env: processPackageEnv,
1424
1642
  signal: controller.signal,
1425
1643
  logger
1426
1644
  });
@@ -1445,6 +1663,7 @@ var onProcessPackage = async (packageGraphs, packageChanges, watchConfig, determ
1445
1663
  debugName: `after process ${packageName}`,
1446
1664
  shellCommand: afterProcessPackageShellCommand,
1447
1665
  cwd: processPackageCwd,
1666
+ env: processPackageEnv,
1448
1667
  signal: controller.signal,
1449
1668
  logger
1450
1669
  });
@@ -1495,7 +1714,7 @@ var watchPackageChanges = (packageData, packageGraphs, watchConfig, rootDir, log
1495
1714
  let debounceTimeout;
1496
1715
  let startedDebounceMs;
1497
1716
  let controller;
1498
- const ignoreGlobs = watchConfig.ignore ? (Array.isArray(watchConfig.ignore) ? watchConfig.ignore : [watchConfig.ignore]).map((pattern) => new Glob(pattern)) : undefined;
1717
+ const ignoreGlobs = watchConfig.ignore ? getIgnoreGlobs(watchConfig.ignore) : undefined;
1499
1718
  const changedPackagePaths = new Map;
1500
1719
  const useController = (reset) => {
1501
1720
  if (controller && (reset || controller.signal.aborted)) {
@@ -1518,7 +1737,7 @@ var watchPackageChanges = (packageData, packageGraphs, watchConfig, rootDir, log
1518
1737
  startedDebounceMs = Date.now();
1519
1738
  }
1520
1739
  if (packageName && watchPath && filePath) {
1521
- const changedPath = normalisePath2(join3(watchPath, normaliseWatchedFilePath(filePath)));
1740
+ const changedPath = normalisePath3(join3(watchPath, normaliseWatchedFilePath(filePath)));
1522
1741
  if (ignoreGlobs?.some((glob) => glob.match(changedPath))) {
1523
1742
  logger.debug(styleText9("dim", `Ignoring change '${changedPath}' (matched ignore pattern).`));
1524
1743
  return;
@@ -1561,7 +1780,7 @@ var watchPackageChanges = (packageData, packageGraphs, watchConfig, rootDir, log
1561
1780
  name,
1562
1781
  path
1563
1782
  }) => {
1564
- const watchPath = dirname6(path);
1783
+ const watchPath = dirname7(path);
1565
1784
  return watch(watchPath, { recursive: true }, (event, filePath) => {
1566
1785
  onWatchEvent({
1567
1786
  watchPath,
@@ -1655,5 +1874,5 @@ export {
1655
1874
  BumpVersionType
1656
1875
  };
1657
1876
 
1658
- //# debugId=9A67423F575E08A064756E2164756E21
1877
+ //# debugId=D8A98DEC7186B6BF64756E2164756E21
1659
1878
  //# sourceMappingURL=index.js.map