@cmflow/cli 3.3.0 → 3.4.0-alpha.1

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 (212) hide show
  1. package/.yarn/install-state.gz +0 -0
  2. package/.yarn/releases/yarn-4.18.0.cjs +1000 -0
  3. package/.yarnrc.yml +8 -1
  4. package/bin/cm-checkfeatures.ts +10 -0
  5. package/bin/cm-clean.ts +10 -0
  6. package/bin/cm-config.ts +10 -0
  7. package/bin/cm-deploy.ts +10 -0
  8. package/bin/{cm-expedit.js → cm-expedit.ts} +4 -4
  9. package/bin/cm-fetch.ts +10 -0
  10. package/bin/cm-finish.ts +10 -0
  11. package/bin/cm-jira-releases.ts +10 -0
  12. package/bin/cm-merge.ts +10 -0
  13. package/bin/cm-publish.ts +10 -0
  14. package/bin/cm-pull.ts +8 -0
  15. package/bin/cm-push.ts +10 -0
  16. package/bin/cm-rebase.ts +10 -0
  17. package/bin/{cmrelease.js → cm-release.ts} +0 -0
  18. package/bin/cm-republish.ts +10 -0
  19. package/bin/cm-start.ts +10 -0
  20. package/bin/cm.ts +40 -0
  21. package/dist/bin/cm.mjs +74985 -0
  22. package/dist/bin/cmrelease.mjs +72397 -0
  23. package/dist/cli-truncate-BmHD4ngn.mjs +152 -0
  24. package/dist/cli-truncate-CXNquMRK.mjs +152 -0
  25. package/dist/cli-truncate-DbOyuy2e.mjs +2 -0
  26. package/dist/cli-truncate-DbOyuy2e.mjs.map +1 -0
  27. package/dist/common-CwPbT3So.mjs +66 -0
  28. package/dist/common-CwPbT3So.mjs.map +1 -0
  29. package/dist/docker-clean-tags-Cd-E8IqJ.mjs +2 -0
  30. package/dist/docker-clean-tags-Cd-E8IqJ.mjs.map +1 -0
  31. package/dist/docker-publish-B0E0qYYB.mjs +2 -0
  32. package/dist/docker-publish-B0E0qYYB.mjs.map +1 -0
  33. package/dist/get-config-DoOyLztI.mjs +41 -0
  34. package/dist/get-config-DoOyLztI.mjs.map +1 -0
  35. package/dist/get-east-asian-width-Tfn8qoqd.mjs +2 -0
  36. package/dist/get-east-asian-width-Tfn8qoqd.mjs.map +1 -0
  37. package/dist/get-east-asian-width-eFfEkHwo.mjs +682 -0
  38. package/dist/log-update-B2GqeeDd.mjs +497 -0
  39. package/dist/log-update-BldA9lkm.mjs +497 -0
  40. package/dist/log-update-By8Z-mak.mjs +6 -0
  41. package/dist/log-update-By8Z-mak.mjs.map +1 -0
  42. package/dist/rolldown-runtime-B4iAMlE-.mjs +35 -0
  43. package/dist/semver-D8gwMSFO.mjs +2 -0
  44. package/dist/semver-D8gwMSFO.mjs.map +1 -0
  45. package/dist/src/index.mjs +18 -0
  46. package/dist/src/index.mjs.map +1 -0
  47. package/dist/src/semantic/core/analyze-commits.mjs +2 -0
  48. package/dist/src/semantic/core/analyze-commits.mjs.map +1 -0
  49. package/dist/src/semantic/core/conditional.mjs +2 -0
  50. package/dist/src/semantic/core/conditional.mjs.map +1 -0
  51. package/dist/src/semantic/core/exit.mjs +2 -0
  52. package/dist/src/semantic/core/exit.mjs.map +1 -0
  53. package/dist/src/semantic/core/prepare/bump-version.mjs +48 -0
  54. package/dist/src/semantic/core/prepare/bump-version.mjs.map +1 -0
  55. package/dist/src/semantic/core/prepare/commit.mjs +2 -0
  56. package/dist/src/semantic/core/prepare/commit.mjs.map +1 -0
  57. package/dist/src/semantic/core/prepare/release-info.mjs +2 -0
  58. package/dist/src/semantic/core/prepare/release-info.mjs.map +1 -0
  59. package/dist/src/semantic/core/run.mjs +2 -0
  60. package/dist/src/semantic/core/run.mjs.map +1 -0
  61. package/dist/src/semantic/core/sync-repository.mjs +2 -0
  62. package/dist/src/semantic/core/sync-repository.mjs.map +1 -0
  63. package/dist/src/semantic/core/verify-conditions.mjs +2 -0
  64. package/dist/src/semantic/core/verify-conditions.mjs.map +1 -0
  65. package/dist/src/semantic/core/verify-release.mjs +2 -0
  66. package/dist/src/semantic/core/verify-release.mjs.map +1 -0
  67. package/dist/src/semantic/docker/publish.mjs +2 -0
  68. package/dist/src/semantic/docker/publish.mjs.map +1 -0
  69. package/dist/src/semantic/docker/success.mjs +2 -0
  70. package/dist/src/semantic/docker/success.mjs.map +1 -0
  71. package/dist/strip-ansi-Aeu5cmZe.mjs +174 -0
  72. package/dist/strip-ansi-Cl0pRo-s.mjs +2 -0
  73. package/dist/strip-ansi-Cl0pRo-s.mjs.map +1 -0
  74. package/dist/wrap-ansi-BeIjar2W.mjs +2 -0
  75. package/dist/wrap-ansi-CWIezXNl.mjs +330 -0
  76. package/dist/wrap-ansi-DsMb4WnZ.mjs +9 -0
  77. package/dist/wrap-ansi-DsMb4WnZ.mjs.map +1 -0
  78. package/dist/wrap-ansi-T0rz0Urp.mjs +330 -0
  79. package/package.json +47 -38
  80. package/release.config.mjs +6 -6
  81. package/src/commands/checkfeatures.ts +39 -0
  82. package/src/commands/clean.ts +36 -0
  83. package/src/commands/config.ts +31 -0
  84. package/src/commands/deploy.ts +39 -0
  85. package/src/commands/fetch.ts +30 -0
  86. package/src/commands/finish.ts +50 -0
  87. package/src/commands/{index.js → index.ts} +1 -0
  88. package/src/commands/jira-releases.ts +97 -0
  89. package/src/commands/merge.ts +58 -0
  90. package/src/commands/prompts/{branches.js → branches.ts} +13 -5
  91. package/src/commands/pull.ts +44 -0
  92. package/src/commands/push.ts +48 -0
  93. package/src/commands/rebase.ts +56 -0
  94. package/src/commands/republish.ts +34 -0
  95. package/src/commands/start.ts +123 -0
  96. package/src/commands/tasks/{merge-branch.js → merge-branch.ts} +18 -3
  97. package/src/commands/tasks/push-branch.ts +19 -0
  98. package/src/commands/tasks/{rebase-all-branches.js → rebase-all-branches.ts} +10 -2
  99. package/src/commands/tasks/{refresh-repository.js → refresh-repository.ts} +8 -4
  100. package/src/commands/tasks/run-test.ts +28 -0
  101. package/src/commands/tasks/{update-branch.js → update-branch.ts} +15 -9
  102. package/src/commands/tasks/{update-dependencies.js → update-dependencies.ts} +4 -3
  103. package/src/common/back/directus/{directus-flow.test.js → directus-flow.test.ts} +1 -0
  104. package/src/common/back/directus/{directus-flow.js → directus-flow.ts} +10 -2
  105. package/src/common/back/http/{http-proxy.js → http-proxy.ts} +7 -1
  106. package/src/common/back/http/{http-request.spec.js → http-request.spec.ts} +8 -7
  107. package/src/common/back/http/{http-request.js → http-request.ts} +16 -19
  108. package/src/common/back/jira/{get-sorted-releases.js → get-sorted-releases.ts} +2 -2
  109. package/src/common/back/jira/{jira-releases.js → jira-releases.ts} +14 -3
  110. package/src/common/back/jira/{jira-request.js → jira-request.ts} +9 -1
  111. package/src/common/back/jira/{jira-search.js → jira-search.ts} +2 -2
  112. package/src/common/cli/{bun.test.js → bun.test.ts} +17 -10
  113. package/src/common/cli/{bun.js → bun.ts} +4 -4
  114. package/src/common/cli/cli.ts +127 -0
  115. package/src/common/cli/{docker.test.js → docker.test.ts} +22 -14
  116. package/src/common/cli/{docker.js → docker.ts} +6 -6
  117. package/src/common/cli/{git.test.js → git.test.ts} +19 -11
  118. package/src/common/cli/{git.js → git.ts} +24 -24
  119. package/src/common/cli/{lerna.test.js → lerna.test.ts} +18 -11
  120. package/src/common/cli/{lerna.js → lerna.ts} +4 -4
  121. package/src/common/cli/{npm.test.js → npm.test.ts} +17 -10
  122. package/src/common/cli/{npm.js → npm.ts} +4 -4
  123. package/src/common/cli/{pnpm.test.js → pnpm.test.ts} +17 -10
  124. package/src/common/cli/{pnpm.js → pnpm.ts} +4 -4
  125. package/src/common/cli/{yarn.test.js → yarn.test.ts} +17 -12
  126. package/src/common/cli/{yarn.js → yarn.ts} +4 -4
  127. package/src/common/configure-git-workspace.ts +39 -0
  128. package/src/common/{get-config.js → get-config.ts} +3 -1
  129. package/src/common/{get-package-json.js → get-package-json.ts} +1 -0
  130. package/src/common/{get-package-manager.js → get-package-manager.ts} +1 -0
  131. package/src/common/{get-release-config.js → get-release-config.ts} +1 -0
  132. package/src/common/{index.js → index.ts} +1 -0
  133. package/src/common/{run-command.test.js → run-command.test.ts} +1 -0
  134. package/src/common/run-command.ts +67 -0
  135. package/src/common/types.ts +26 -0
  136. package/src/common/vendor.d.ts +4 -0
  137. package/src/{index.js → index.ts} +5 -1
  138. package/src/semantic/core/{analyze-commits.js → analyze-commits.ts} +7 -3
  139. package/src/semantic/core/{conditional.js → conditional.ts} +16 -9
  140. package/src/semantic/core/{exit.js → exit.ts} +3 -2
  141. package/src/semantic/core/prepare/{bump-version.js → bump-version.ts} +11 -8
  142. package/src/semantic/core/prepare/{commit.js → commit.ts} +3 -2
  143. package/src/semantic/core/prepare/release-info.ts +6 -0
  144. package/src/semantic/core/{run.js → run.ts} +3 -2
  145. package/src/semantic/core/sync-repository.ts +55 -0
  146. package/src/semantic/core/{verify-conditions.js → verify-conditions.ts} +4 -3
  147. package/src/semantic/core/{verify-release.js → verify-release.ts} +2 -1
  148. package/src/semantic/docker/publish.ts +6 -0
  149. package/src/semantic/docker/{success.js → success.ts} +2 -1
  150. package/src/semantic/utils/{bump-packages-version.test.js → bump-packages-version.test.ts} +1 -0
  151. package/src/semantic/utils/{bump-packages-version.js → bump-packages-version.ts} +12 -11
  152. package/src/semantic/utils/{calculate-snapshot-version.test.js → calculate-snapshot-version.test.ts} +10 -8
  153. package/src/semantic/utils/calculate-snapshot-version.ts +17 -0
  154. package/src/semantic/utils/display-package-info.ts +12 -0
  155. package/src/semantic/utils/display-release-info.ts +13 -0
  156. package/src/semantic/utils/{docker-clean-tags.test.js → docker-clean-tags.test.ts} +1 -0
  157. package/src/semantic/utils/{docker-clean-tags.js → docker-clean-tags.ts} +11 -4
  158. package/src/semantic/utils/{docker-publish.test.js → docker-publish.test.ts} +1 -0
  159. package/src/semantic/utils/{docker-publish.js → docker-publish.ts} +4 -3
  160. package/src/semantic/utils/{log-section.js → log-section.ts} +5 -1
  161. package/src/semantic/utils/{transform-writer.js → transform-writer.ts} +37 -13
  162. package/tsconfig.build.json +29 -0
  163. package/tsconfig.json +8 -15
  164. package/tsdown.config.ts +63 -0
  165. package/vitest.config.mts +2 -3
  166. package/.yarn/releases/yarn-4.7.0.cjs +0 -935
  167. package/bin/checkfeatures.js +0 -13
  168. package/bin/cm-clean.js +0 -8
  169. package/bin/cm-config.js +0 -15
  170. package/bin/cm-deploy.js +0 -8
  171. package/bin/cm-fetch.js +0 -12
  172. package/bin/cm-finish.js +0 -14
  173. package/bin/cm-jira-releases.js +0 -16
  174. package/bin/cm-merge.js +0 -12
  175. package/bin/cm-publish.js +0 -15
  176. package/bin/cm-push.js +0 -15
  177. package/bin/cm-rebase.js +0 -15
  178. package/bin/cm-republish.js +0 -12
  179. package/bin/cm-start.js +0 -21
  180. package/bin/cm.js +0 -27
  181. package/bin/cmpull.js +0 -22
  182. package/src/commands/checkfeatures.js +0 -20
  183. package/src/commands/clean.js +0 -29
  184. package/src/commands/config.js +0 -23
  185. package/src/commands/deploy.js +0 -34
  186. package/src/commands/fetch.js +0 -18
  187. package/src/commands/finish.js +0 -43
  188. package/src/commands/jira-releases.js +0 -62
  189. package/src/commands/merge.js +0 -41
  190. package/src/commands/pull.js +0 -30
  191. package/src/commands/push.js +0 -23
  192. package/src/commands/rebase.js +0 -35
  193. package/src/commands/republish.js +0 -21
  194. package/src/commands/start.js +0 -109
  195. package/src/commands/tasks/push-branch.js +0 -10
  196. package/src/commands/tasks/run-test.js +0 -21
  197. package/src/common/cli/cli.js +0 -110
  198. package/src/common/configure-git-workspace.js +0 -26
  199. package/src/common/run-command.js +0 -64
  200. package/src/semantic/core/prepare/release-info.js +0 -5
  201. package/src/semantic/core/sync-repository.js +0 -52
  202. package/src/semantic/docker/publish.js +0 -5
  203. package/src/semantic/utils/calculate-snapshot-version.js +0 -15
  204. package/src/semantic/utils/display-package-info.js +0 -11
  205. package/src/semantic/utils/display-release-info.js +0 -12
  206. /package/src/commands/{release.js → release.ts} +0 -0
  207. /package/src/commands/utils/{check-install.js → check-install.ts} +0 -0
  208. /package/src/common/back/jira/{jira-request.spec.js → jira-request.spec.ts} +0 -0
  209. /package/src/common/back/jira/{jira-search.spec.js → jira-search.spec.ts} +0 -0
  210. /package/src/semantic/{define-config.js → define-config.ts} +0 -0
  211. /package/src/semantic/utils/{release-rules.js → release-rules.ts} +0 -0
  212. /package/src/workflow/{index.js → index.ts} +0 -0
@@ -0,0 +1,497 @@
1
+ import { n as ansiStyles, t as stripAnsi } from "./strip-ansi-Aeu5cmZe.mjs";
2
+ import { n as isFullWidth, r as isWide } from "./get-east-asian-width-eFfEkHwo.mjs";
3
+ import wrapAnsi from "./wrap-ansi-T0rz0Urp.mjs";
4
+ import process$1 from "node:process";
5
+ import os from "node:os";
6
+ //#region node_modules/environment/index.js
7
+ const isBrowser = globalThis.window?.document !== void 0;
8
+ globalThis.process?.versions?.node;
9
+ globalThis.process?.versions?.bun;
10
+ globalThis.Deno?.version?.deno;
11
+ globalThis.process?.versions?.electron;
12
+ globalThis.navigator?.userAgent?.includes("jsdom");
13
+ typeof WorkerGlobalScope !== "undefined" && globalThis instanceof WorkerGlobalScope;
14
+ typeof DedicatedWorkerGlobalScope !== "undefined" && globalThis instanceof DedicatedWorkerGlobalScope;
15
+ typeof SharedWorkerGlobalScope !== "undefined" && globalThis instanceof SharedWorkerGlobalScope;
16
+ typeof ServiceWorkerGlobalScope !== "undefined" && globalThis instanceof ServiceWorkerGlobalScope;
17
+ const platform = globalThis.navigator?.userAgentData?.platform;
18
+ platform === "macOS" || globalThis.navigator?.platform === "MacIntel" || globalThis.navigator?.userAgent?.includes(" Mac ") === true || globalThis.process?.platform;
19
+ platform === "Windows" || globalThis.navigator?.platform === "Win32" || globalThis.process?.platform;
20
+ platform === "Linux" || globalThis.navigator?.platform?.startsWith("Linux") === true || globalThis.navigator?.userAgent?.includes(" Linux ") === true || globalThis.process?.platform;
21
+ platform === "iOS" || globalThis.navigator?.platform === "MacIntel" && globalThis.navigator?.maxTouchPoints > 1 || /iPad|iPhone|iPod/.test(globalThis.navigator?.platform);
22
+ platform === "Android" || globalThis.navigator?.platform === "Android" || globalThis.navigator?.userAgent?.includes(" Android ") === true || globalThis.process?.platform;
23
+ //#endregion
24
+ //#region node_modules/listr2/node_modules/ansi-escapes/base.js
25
+ const ESC = "\x1B[";
26
+ !isBrowser && process$1.env.TERM_PROGRAM;
27
+ const isWindows = !isBrowser && process$1.platform === "win32";
28
+ !isBrowser && (process$1.env.TERM?.startsWith("screen") || process$1.env.TERM?.startsWith("tmux") || process$1.env.TMUX);
29
+ isBrowser || process$1.cwd;
30
+ const cursorUp = (count = 1) => ESC + count + "A";
31
+ const eraseLines = (count) => {
32
+ let clear = "";
33
+ for (let i = 0; i < count; i++) clear += eraseLine + (i < count - 1 ? cursorUp() : "");
34
+ if (count) clear += "\x1B[G";
35
+ return clear;
36
+ };
37
+ const eraseLine = "\x1B[2K";
38
+ const isOldWindows = () => {
39
+ if (isBrowser || !isWindows) return false;
40
+ const parts = os.release().split(".");
41
+ const major = Number(parts[0]);
42
+ const build = Number(parts[2] ?? 0);
43
+ if (major < 10) return true;
44
+ if (major === 10 && build < 10586) return true;
45
+ return false;
46
+ };
47
+ isOldWindows();
48
+ //#endregion
49
+ //#region node_modules/mimic-function/index.js
50
+ const copyProperty = (to, from, property, ignoreNonConfigurable) => {
51
+ if (property === "length" || property === "prototype") return;
52
+ if (property === "arguments" || property === "caller") return;
53
+ const toDescriptor = Object.getOwnPropertyDescriptor(to, property);
54
+ const fromDescriptor = Object.getOwnPropertyDescriptor(from, property);
55
+ if (!canCopyProperty(toDescriptor, fromDescriptor) && ignoreNonConfigurable) return;
56
+ Object.defineProperty(to, property, fromDescriptor);
57
+ };
58
+ const canCopyProperty = function(toDescriptor, fromDescriptor) {
59
+ return toDescriptor === void 0 || toDescriptor.configurable || toDescriptor.writable === fromDescriptor.writable && toDescriptor.enumerable === fromDescriptor.enumerable && toDescriptor.configurable === fromDescriptor.configurable && (toDescriptor.writable || toDescriptor.value === fromDescriptor.value);
60
+ };
61
+ const changePrototype = (to, from) => {
62
+ const fromPrototype = Object.getPrototypeOf(from);
63
+ if (fromPrototype === Object.getPrototypeOf(to)) return;
64
+ Object.setPrototypeOf(to, fromPrototype);
65
+ };
66
+ const wrappedToString = (withName, fromBody) => `/* Wrapped ${withName}*/\n${fromBody}`;
67
+ const toStringDescriptor = Object.getOwnPropertyDescriptor(Function.prototype, "toString");
68
+ const toStringName = Object.getOwnPropertyDescriptor(Function.prototype.toString, "name");
69
+ const changeToString = (to, from, name) => {
70
+ const withName = name === "" ? "" : `with ${name.trim()}() `;
71
+ const newToString = wrappedToString.bind(null, withName, from.toString());
72
+ Object.defineProperty(newToString, "name", toStringName);
73
+ const { writable, enumerable, configurable } = toStringDescriptor;
74
+ Object.defineProperty(to, "toString", {
75
+ value: newToString,
76
+ writable,
77
+ enumerable,
78
+ configurable
79
+ });
80
+ };
81
+ function mimicFunction(to, from, { ignoreNonConfigurable = false } = {}) {
82
+ const { name } = to;
83
+ for (const property of Reflect.ownKeys(from)) copyProperty(to, from, property, ignoreNonConfigurable);
84
+ changePrototype(to, from);
85
+ changeToString(to, from, name);
86
+ return to;
87
+ }
88
+ //#endregion
89
+ //#region node_modules/listr2/node_modules/onetime/index.js
90
+ const calledFunctions = /* @__PURE__ */ new WeakMap();
91
+ const onetime = (function_, options = {}) => {
92
+ if (typeof function_ !== "function") throw new TypeError("Expected a function");
93
+ let returnValue;
94
+ let callCount = 0;
95
+ const functionName = function_.displayName || function_.name || "<anonymous>";
96
+ const onetime = function(...arguments_) {
97
+ calledFunctions.set(onetime, ++callCount);
98
+ if (callCount === 1) {
99
+ returnValue = function_.apply(this, arguments_);
100
+ function_ = void 0;
101
+ } else if (options.throw === true) throw new Error(`Function \`${functionName}\` can only be called once`);
102
+ return returnValue;
103
+ };
104
+ mimicFunction(onetime, function_);
105
+ calledFunctions.set(onetime, callCount);
106
+ return onetime;
107
+ };
108
+ onetime.callCount = (function_) => {
109
+ if (!calledFunctions.has(function_)) throw new Error(`The given function \`${function_.name}\` is not wrapped by the \`onetime\` package`);
110
+ return calledFunctions.get(function_);
111
+ };
112
+ //#endregion
113
+ //#region node_modules/signal-exit/dist/mjs/signals.js
114
+ /**
115
+ * This is not the set of all possible signals.
116
+ *
117
+ * It IS, however, the set of all signals that trigger
118
+ * an exit on either Linux or BSD systems. Linux is a
119
+ * superset of the signal names supported on BSD, and
120
+ * the unknown signals just fail to register, so we can
121
+ * catch that easily enough.
122
+ *
123
+ * Windows signals are a different set, since there are
124
+ * signals that terminate Windows processes, but don't
125
+ * terminate (or don't even exist) on Posix systems.
126
+ *
127
+ * Don't bother with SIGKILL. It's uncatchable, which
128
+ * means that we can't fire any callbacks anyway.
129
+ *
130
+ * If a user does happen to register a handler on a non-
131
+ * fatal signal like SIGWINCH or something, and then
132
+ * exit, it'll end up firing `process.emit('exit')`, so
133
+ * the handler will be fired anyway.
134
+ *
135
+ * SIGBUS, SIGFPE, SIGSEGV and SIGILL, when not raised
136
+ * artificially, inherently leave the process in a
137
+ * state from which it is not safe to try and enter JS
138
+ * listeners.
139
+ */
140
+ const signals = [];
141
+ signals.push("SIGHUP", "SIGINT", "SIGTERM");
142
+ if (process.platform !== "win32") signals.push("SIGALRM", "SIGABRT", "SIGVTALRM", "SIGXCPU", "SIGXFSZ", "SIGUSR2", "SIGTRAP", "SIGSYS", "SIGQUIT", "SIGIOT");
143
+ if (process.platform === "linux") signals.push("SIGIO", "SIGPOLL", "SIGPWR", "SIGSTKFLT");
144
+ //#endregion
145
+ //#region node_modules/signal-exit/dist/mjs/index.js
146
+ const processOk = (process) => !!process && typeof process === "object" && typeof process.removeListener === "function" && typeof process.emit === "function" && typeof process.reallyExit === "function" && typeof process.listeners === "function" && typeof process.kill === "function" && typeof process.pid === "number" && typeof process.on === "function";
147
+ const kExitEmitter = Symbol.for("signal-exit emitter");
148
+ const global = globalThis;
149
+ const ObjectDefineProperty = Object.defineProperty.bind(Object);
150
+ var Emitter = class {
151
+ emitted = {
152
+ afterExit: false,
153
+ exit: false
154
+ };
155
+ listeners = {
156
+ afterExit: [],
157
+ exit: []
158
+ };
159
+ count = 0;
160
+ id = Math.random();
161
+ constructor() {
162
+ if (global[kExitEmitter]) return global[kExitEmitter];
163
+ ObjectDefineProperty(global, kExitEmitter, {
164
+ value: this,
165
+ writable: false,
166
+ enumerable: false,
167
+ configurable: false
168
+ });
169
+ }
170
+ on(ev, fn) {
171
+ this.listeners[ev].push(fn);
172
+ }
173
+ removeListener(ev, fn) {
174
+ const list = this.listeners[ev];
175
+ const i = list.indexOf(fn);
176
+ /* c8 ignore start */
177
+ if (i === -1) return;
178
+ /* c8 ignore stop */
179
+ if (i === 0 && list.length === 1) list.length = 0;
180
+ else list.splice(i, 1);
181
+ }
182
+ emit(ev, code, signal) {
183
+ if (this.emitted[ev]) return false;
184
+ this.emitted[ev] = true;
185
+ let ret = false;
186
+ for (const fn of this.listeners[ev]) ret = fn(code, signal) === true || ret;
187
+ if (ev === "exit") ret = this.emit("afterExit", code, signal) || ret;
188
+ return ret;
189
+ }
190
+ };
191
+ var SignalExitBase = class {};
192
+ const signalExitWrap = (handler) => {
193
+ return {
194
+ onExit(cb, opts) {
195
+ return handler.onExit(cb, opts);
196
+ },
197
+ load() {
198
+ return handler.load();
199
+ },
200
+ unload() {
201
+ return handler.unload();
202
+ }
203
+ };
204
+ };
205
+ var SignalExitFallback = class extends SignalExitBase {
206
+ onExit() {
207
+ return () => {};
208
+ }
209
+ load() {}
210
+ unload() {}
211
+ };
212
+ var SignalExit = class extends SignalExitBase {
213
+ /* c8 ignore start */
214
+ #hupSig = process$2.platform === "win32" ? "SIGINT" : "SIGHUP";
215
+ /* c8 ignore stop */
216
+ #emitter = new Emitter();
217
+ #process;
218
+ #originalProcessEmit;
219
+ #originalProcessReallyExit;
220
+ #sigListeners = {};
221
+ #loaded = false;
222
+ constructor(process) {
223
+ super();
224
+ this.#process = process;
225
+ this.#sigListeners = {};
226
+ for (const sig of signals) this.#sigListeners[sig] = () => {
227
+ const listeners = this.#process.listeners(sig);
228
+ let { count } = this.#emitter;
229
+ /* c8 ignore start */
230
+ const p = process;
231
+ if (typeof p.__signal_exit_emitter__ === "object" && typeof p.__signal_exit_emitter__.count === "number") count += p.__signal_exit_emitter__.count;
232
+ /* c8 ignore stop */
233
+ if (listeners.length === count) {
234
+ this.unload();
235
+ const ret = this.#emitter.emit("exit", null, sig);
236
+ /* c8 ignore start */
237
+ const s = sig === "SIGHUP" ? this.#hupSig : sig;
238
+ if (!ret) process.kill(process.pid, s);
239
+ }
240
+ };
241
+ this.#originalProcessReallyExit = process.reallyExit;
242
+ this.#originalProcessEmit = process.emit;
243
+ }
244
+ onExit(cb, opts) {
245
+ /* c8 ignore start */
246
+ if (!processOk(this.#process)) return () => {};
247
+ /* c8 ignore stop */
248
+ if (this.#loaded === false) this.load();
249
+ const ev = opts?.alwaysLast ? "afterExit" : "exit";
250
+ this.#emitter.on(ev, cb);
251
+ return () => {
252
+ this.#emitter.removeListener(ev, cb);
253
+ if (this.#emitter.listeners["exit"].length === 0 && this.#emitter.listeners["afterExit"].length === 0) this.unload();
254
+ };
255
+ }
256
+ load() {
257
+ if (this.#loaded) return;
258
+ this.#loaded = true;
259
+ this.#emitter.count += 1;
260
+ for (const sig of signals) try {
261
+ const fn = this.#sigListeners[sig];
262
+ if (fn) this.#process.on(sig, fn);
263
+ } catch (_) {}
264
+ this.#process.emit = (ev, ...a) => {
265
+ return this.#processEmit(ev, ...a);
266
+ };
267
+ this.#process.reallyExit = (code) => {
268
+ return this.#processReallyExit(code);
269
+ };
270
+ }
271
+ unload() {
272
+ if (!this.#loaded) return;
273
+ this.#loaded = false;
274
+ signals.forEach((sig) => {
275
+ const listener = this.#sigListeners[sig];
276
+ /* c8 ignore start */
277
+ if (!listener) throw new Error("Listener not defined for signal: " + sig);
278
+ /* c8 ignore stop */
279
+ try {
280
+ this.#process.removeListener(sig, listener);
281
+ } catch (_) {}
282
+ /* c8 ignore stop */
283
+ });
284
+ this.#process.emit = this.#originalProcessEmit;
285
+ this.#process.reallyExit = this.#originalProcessReallyExit;
286
+ this.#emitter.count -= 1;
287
+ }
288
+ #processReallyExit(code) {
289
+ /* c8 ignore start */
290
+ if (!processOk(this.#process)) return 0;
291
+ this.#process.exitCode = code || 0;
292
+ /* c8 ignore stop */
293
+ this.#emitter.emit("exit", this.#process.exitCode, null);
294
+ return this.#originalProcessReallyExit.call(this.#process, this.#process.exitCode);
295
+ }
296
+ #processEmit(ev, ...args) {
297
+ const og = this.#originalProcessEmit;
298
+ if (ev === "exit" && processOk(this.#process)) {
299
+ if (typeof args[0] === "number") this.#process.exitCode = args[0];
300
+ /* c8 ignore start */
301
+ const ret = og.call(this.#process, ev, ...args);
302
+ /* c8 ignore start */
303
+ this.#emitter.emit("exit", this.#process.exitCode, null);
304
+ /* c8 ignore stop */
305
+ return ret;
306
+ } else return og.call(this.#process, ev, ...args);
307
+ }
308
+ };
309
+ const process$2 = globalThis.process;
310
+ const { onExit, load, unload } = signalExitWrap(processOk(process$2) ? new SignalExit(process$2) : new SignalExitFallback());
311
+ //#endregion
312
+ //#region node_modules/listr2/node_modules/restore-cursor/index.js
313
+ const terminal = process$1.stderr.isTTY ? process$1.stderr : process$1.stdout.isTTY ? process$1.stdout : void 0;
314
+ const restoreCursor = terminal ? onetime(() => {
315
+ onExit(() => {
316
+ terminal.write("\x1B[?25h");
317
+ }, { alwaysLast: true });
318
+ }) : () => {};
319
+ //#endregion
320
+ //#region node_modules/listr2/node_modules/cli-cursor/index.js
321
+ let isHidden = false;
322
+ const cliCursor = {};
323
+ cliCursor.show = (writableStream = process$1.stderr) => {
324
+ if (!writableStream.isTTY) return;
325
+ isHidden = false;
326
+ writableStream.write("\x1B[?25h");
327
+ };
328
+ cliCursor.hide = (writableStream = process$1.stderr) => {
329
+ if (!writableStream.isTTY) return;
330
+ restoreCursor();
331
+ isHidden = true;
332
+ writableStream.write("\x1B[?25l");
333
+ };
334
+ cliCursor.toggle = (force, writableStream) => {
335
+ if (force !== void 0) isHidden = force;
336
+ if (isHidden) cliCursor.show(writableStream);
337
+ else cliCursor.hide(writableStream);
338
+ };
339
+ //#endregion
340
+ //#region node_modules/listr2/node_modules/log-update/node_modules/is-fullwidth-code-point/index.js
341
+ function isFullwidthCodePoint(codePoint) {
342
+ if (!Number.isInteger(codePoint)) return false;
343
+ return isFullWidth(codePoint) || isWide(codePoint);
344
+ }
345
+ //#endregion
346
+ //#region node_modules/listr2/node_modules/log-update/node_modules/slice-ansi/index.js
347
+ const ESCAPES = /* @__PURE__ */ new Set([27, 155]);
348
+ const CODE_POINT_0 = "0".codePointAt(0);
349
+ const CODE_POINT_9 = "9".codePointAt(0);
350
+ const MAX_ANSI_SEQUENCE_LENGTH = 19;
351
+ const endCodesSet = /* @__PURE__ */ new Set();
352
+ const endCodesMap = /* @__PURE__ */ new Map();
353
+ for (const [start, end] of ansiStyles.codes) {
354
+ endCodesSet.add(ansiStyles.color.ansi(end));
355
+ endCodesMap.set(ansiStyles.color.ansi(start), ansiStyles.color.ansi(end));
356
+ }
357
+ function getEndCode(code) {
358
+ if (endCodesSet.has(code)) return code;
359
+ if (endCodesMap.has(code)) return endCodesMap.get(code);
360
+ code = code.slice(2);
361
+ if (code.includes(";")) code = code[0] + "0";
362
+ const returnValue = ansiStyles.codes.get(Number.parseInt(code, 10));
363
+ if (returnValue) return ansiStyles.color.ansi(returnValue);
364
+ return ansiStyles.reset.open;
365
+ }
366
+ function findNumberIndex(string) {
367
+ for (let index = 0; index < string.length; index++) {
368
+ const codePoint = string.codePointAt(index);
369
+ if (codePoint >= CODE_POINT_0 && codePoint <= CODE_POINT_9) return index;
370
+ }
371
+ return -1;
372
+ }
373
+ function parseAnsiCode(string, offset) {
374
+ string = string.slice(offset, offset + MAX_ANSI_SEQUENCE_LENGTH);
375
+ const startIndex = findNumberIndex(string);
376
+ if (startIndex !== -1) {
377
+ let endIndex = string.indexOf("m", startIndex);
378
+ if (endIndex === -1) endIndex = string.length;
379
+ return string.slice(0, endIndex + 1);
380
+ }
381
+ }
382
+ function tokenize(string, endCharacter = Number.POSITIVE_INFINITY) {
383
+ const returnValue = [];
384
+ let index = 0;
385
+ let visibleCount = 0;
386
+ while (index < string.length) {
387
+ const codePoint = string.codePointAt(index);
388
+ if (ESCAPES.has(codePoint)) {
389
+ const code = parseAnsiCode(string, index);
390
+ if (code) {
391
+ returnValue.push({
392
+ type: "ansi",
393
+ code,
394
+ endCode: getEndCode(code)
395
+ });
396
+ index += code.length;
397
+ continue;
398
+ }
399
+ }
400
+ const isFullWidth = isFullwidthCodePoint(codePoint);
401
+ const character = String.fromCodePoint(codePoint);
402
+ returnValue.push({
403
+ type: "character",
404
+ value: character,
405
+ isFullWidth
406
+ });
407
+ index += character.length;
408
+ visibleCount += isFullWidth ? 2 : character.length;
409
+ if (visibleCount >= endCharacter) break;
410
+ }
411
+ return returnValue;
412
+ }
413
+ function reduceAnsiCodes(codes) {
414
+ let returnValue = [];
415
+ for (const code of codes) if (code.code === ansiStyles.reset.open) returnValue = [];
416
+ else if (endCodesSet.has(code.code)) returnValue = returnValue.filter((returnValueCode) => returnValueCode.endCode !== code.code);
417
+ else {
418
+ returnValue = returnValue.filter((returnValueCode) => returnValueCode.endCode !== code.endCode);
419
+ returnValue.push(code);
420
+ }
421
+ return returnValue;
422
+ }
423
+ function undoAnsiCodes(codes) {
424
+ return reduceAnsiCodes(codes).map(({ endCode }) => endCode).reverse().join("");
425
+ }
426
+ function sliceAnsi(string, start, end) {
427
+ const tokens = tokenize(string, end);
428
+ let activeCodes = [];
429
+ let position = 0;
430
+ let returnValue = "";
431
+ let include = false;
432
+ for (const token of tokens) {
433
+ if (end !== void 0 && position >= end) break;
434
+ if (token.type === "ansi") {
435
+ activeCodes.push(token);
436
+ if (include) returnValue += token.code;
437
+ } else {
438
+ if (!include && position >= start) {
439
+ include = true;
440
+ activeCodes = reduceAnsiCodes(activeCodes);
441
+ returnValue = activeCodes.map(({ code }) => code).join("");
442
+ }
443
+ if (include) returnValue += token.value;
444
+ position += token.isFullWidth ? 2 : token.value.length;
445
+ }
446
+ }
447
+ returnValue += undoAnsiCodes(activeCodes);
448
+ return returnValue;
449
+ }
450
+ //#endregion
451
+ //#region node_modules/listr2/node_modules/log-update/index.js
452
+ const defaultTerminalHeight = 24;
453
+ const getWidth = ({ columns = 80 }) => columns;
454
+ const fitToTerminalHeight = (stream, text) => {
455
+ const terminalHeight = stream.rows ?? defaultTerminalHeight;
456
+ const lines = text.split("\n");
457
+ const toRemove = Math.max(0, lines.length - terminalHeight);
458
+ return toRemove ? sliceAnsi(text, stripAnsi(lines.slice(0, toRemove).join("\n")).length + 1) : text;
459
+ };
460
+ function createLogUpdate(stream, { showCursor = false } = {}) {
461
+ let previousLineCount = 0;
462
+ let previousWidth = getWidth(stream);
463
+ let previousOutput = "";
464
+ const reset = () => {
465
+ previousOutput = "";
466
+ previousWidth = getWidth(stream);
467
+ previousLineCount = 0;
468
+ };
469
+ const render = (...arguments_) => {
470
+ if (!showCursor) cliCursor.hide();
471
+ let output = fitToTerminalHeight(stream, arguments_.join(" ") + "\n");
472
+ const width = getWidth(stream);
473
+ if (output === previousOutput && previousWidth === width) return;
474
+ previousOutput = output;
475
+ previousWidth = width;
476
+ output = wrapAnsi(output, width, {
477
+ trim: false,
478
+ hard: true,
479
+ wordWrap: false
480
+ });
481
+ stream.write(eraseLines(previousLineCount) + output);
482
+ previousLineCount = output.split("\n").length;
483
+ };
484
+ render.clear = () => {
485
+ stream.write(eraseLines(previousLineCount));
486
+ reset();
487
+ };
488
+ render.done = () => {
489
+ reset();
490
+ if (!showCursor) cliCursor.show();
491
+ };
492
+ return render;
493
+ }
494
+ createLogUpdate(process$1.stdout);
495
+ createLogUpdate(process$1.stderr);
496
+ //#endregion
497
+ export { createLogUpdate };