@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
@@ -1,23 +1,31 @@
1
+ import execa from "execa";
2
+ import { Cli } from "./cli.js";
3
+ import { git } from "./git.js";
4
+
1
5
  vi.mock("execa", () => {
2
- const execaMock = vi.fn();
3
- execaMock.sync = vi.fn();
6
+ const sync = vi.fn();
7
+ const execaMock = Object.assign(vi.fn(), { sync });
4
8
  return { default: execaMock };
5
9
  });
6
- const { default: execa } = await import("execa");
7
- const { git } = await import("./git.js");
8
- const { Cli } = await import("./cli.js");
9
- execa.sync.mockImplementation((...args) => {
10
+
11
+ type ExecaMock = {
12
+ sync: { mockImplementation(fn: (...args: unknown[]) => unknown): void };
13
+ mockReturnValue(v: unknown): void;
14
+ };
15
+
16
+ const execaMock = execa as unknown as ExecaMock;
17
+
18
+ execaMock.sync.mockImplementation((...args) => {
10
19
  return {
11
- stdout: `CMD: ${[].concat(...args.filter((arg) => typeof arg === "string" || Array.isArray(arg))).join(" ")}`
20
+ stdout: `CMD: ${([] as unknown[]).concat(...(args as (string | string[])[]).filter((arg) => typeof arg === "string" || Array.isArray(arg))).join(" ")}`
12
21
  };
13
22
  });
14
-
15
- execa.mockReturnValue({});
23
+ execaMock.mockReturnValue({});
16
24
 
17
25
  describe("GitCli", () => {
18
26
  beforeEach(() => {
19
- vi.spyOn(Cli, "getRaw").mockImplementation((...args) => {
20
- return `CMD: ${[].concat(...args.filter((arg) => typeof arg === "string" || Array.isArray(arg))).join(" ")}`;
27
+ vi.spyOn(Cli, "getRaw").mockImplementation((...args: unknown[]) => {
28
+ return `CMD: ${([] as unknown[]).concat(...(args as (string | string[])[]).filter((arg) => typeof arg === "string" || Array.isArray(arg))).join(" ")}`;
21
29
  });
22
30
  });
23
31
  describe("init", () => {
@@ -5,59 +5,59 @@ class GitCli extends Cli {
5
5
  super("git");
6
6
  }
7
7
 
8
- init(...args) {
8
+ init(...args: string[]) {
9
9
  return this.run("init", ...args);
10
10
  }
11
11
 
12
- add(...args) {
12
+ add(...args: string[]) {
13
13
  return this.run("add", ...args);
14
14
  }
15
15
 
16
- status(...args) {
16
+ status(...args: string[]) {
17
17
  return this.sync("status", ...args);
18
18
  }
19
19
 
20
- branch(...args) {
20
+ branch(...args: string[]) {
21
21
  return this.run("branch", ...args);
22
22
  }
23
23
 
24
- clean(...args) {
24
+ clean(...args: string[]) {
25
25
  return this.run("clean", ...args);
26
26
  }
27
27
 
28
- config(...args) {
28
+ config(...args: string[]) {
29
29
  return this.run("config", ...args).get();
30
30
  }
31
31
 
32
- checkout(...args) {
32
+ checkout(...args: string[]) {
33
33
  return this.run("checkout", ...args);
34
34
  }
35
35
 
36
- commit(...args) {
36
+ commit(...args: string[]) {
37
37
  return this.run("commit", ...args);
38
38
  }
39
39
 
40
- fetch(...args) {
40
+ fetch(...args: string[]) {
41
41
  return this.run("fetch", ...args);
42
42
  }
43
43
 
44
- prune(...args) {
44
+ prune(...args: string[]) {
45
45
  return this.run("prune", ...args);
46
46
  }
47
47
 
48
- merge(...args) {
48
+ merge(...args: string[]) {
49
49
  return this.sync("merge", ...args);
50
50
  }
51
51
 
52
- reset(...args) {
52
+ reset(...args: string[]) {
53
53
  return this.sync("reset", ...args);
54
54
  }
55
55
 
56
- remote(...args) {
56
+ remote(...args: string[]) {
57
57
  return this.run("remote", ...args);
58
58
  }
59
59
 
60
- rebase(...args) {
60
+ rebase(...args: string[]) {
61
61
  return this.run("rebase", ...args);
62
62
  }
63
63
 
@@ -73,20 +73,20 @@ class GitCli extends Cli {
73
73
  return this.get("log", "-1", "--pretty=%B");
74
74
  }
75
75
 
76
- push(...args) {
76
+ push(...args: string[]) {
77
77
  return this.run("push", ...args);
78
78
  }
79
79
 
80
- branchExists(branch, origin = "origin") {
81
- return this.branch("-a").getRaw().trim().includes(`remotes/${origin}/${branch}`);
80
+ branchExists(branch: string, origin = "origin") {
81
+ return this.run("branch", "-a").getRaw().trim().includes(`remotes/${origin}/${branch}`);
82
82
  }
83
83
 
84
- checkBranchRemoteStatus(branch, origin = "origin") {
84
+ checkBranchRemoteStatus(branch: string, origin = "origin") {
85
85
  return this.run("cherry", branch, `${origin}/${branch}`).get();
86
86
  }
87
87
 
88
- branches(...args) {
89
- return this.branch(...args)
88
+ branches(...args: string[]) {
89
+ return this.run("branch", ...args)
90
90
  .get()
91
91
  .split("\n")
92
92
  .map((branch) => branch.trim().replace("* ", ""))
@@ -94,11 +94,11 @@ class GitCli extends Cli {
94
94
  .filter((branch) => !String(branch).includes("/HEAD"));
95
95
  }
96
96
 
97
- show(branch) {
97
+ show(branch: string) {
98
98
  return this.run("show", '--format="%ci|%cr|%an"', branch, "--").getRaw().split("\n")[0].trim();
99
99
  }
100
100
 
101
- branchesInfos(...args) {
101
+ branchesInfos(...args: string[]) {
102
102
  return this.branches(...args)
103
103
  .map((branch) => {
104
104
  try {
@@ -113,8 +113,8 @@ class GitCli extends Cli {
113
113
  return undefined;
114
114
  }
115
115
  })
116
- .filter((b) => !!b)
117
- .sort((info1, info2) => info1.date < info2.date);
116
+ .filter((b): b is { branch: string; date: string; creation: string; author: string } => !!b)
117
+ .sort((info1, info2) => (info1.date < info2.date ? 1 : -1));
118
118
  }
119
119
  }
120
120
 
@@ -1,24 +1,31 @@
1
+ import execa from "execa";
2
+ import { lerna } from "./lerna.js";
3
+ import { Cli } from "./cli.js";
4
+
1
5
  vi.mock("execa", () => {
2
- const execaMock = vi.fn();
3
- execaMock.sync = vi.fn();
6
+ const sync = vi.fn();
7
+ const execaMock = Object.assign(vi.fn(), { sync });
4
8
  return { default: execaMock };
5
9
  });
6
- const { default: execa } = await import("execa");
7
- const { lerna } = await import("./lerna.js");
8
- const { Cli } = await import("./cli.js");
9
10
 
10
- execa.sync.mockImplementation((...args) => {
11
+ type ExecaMock = {
12
+ sync: { mockImplementation(fn: (...args: unknown[]) => unknown): void };
13
+ mockReturnValue(v: unknown): void;
14
+ };
15
+
16
+ const execaMock = execa as unknown as ExecaMock;
17
+
18
+ execaMock.sync.mockImplementation((...args) => {
11
19
  return {
12
- stdout: `CMD: ${[].concat(...args.filter((arg) => typeof arg === "string" || Array.isArray(arg))).join(" ")}`
20
+ stdout: `CMD: ${([] as unknown[]).concat(...(args as (string | string[])[]).filter((arg) => typeof arg === "string" || Array.isArray(arg))).join(" ")}`
13
21
  };
14
22
  });
15
-
16
- execa.mockReturnValue({});
23
+ execaMock.mockReturnValue({});
17
24
 
18
25
  describe("LernaCli", () => {
19
26
  beforeEach(() => {
20
- vi.spyOn(Cli, "getRaw").mockImplementation((...args) => {
21
- return `CMD: ${[].concat(...args.filter((arg) => typeof arg === "string" || Array.isArray(arg))).join(" ")}`;
27
+ vi.spyOn(Cli, "getRaw").mockImplementation((...args: unknown[]) => {
28
+ return `CMD: ${([] as unknown[]).concat(...(args as (string | string[])[]).filter((arg) => typeof arg === "string" || Array.isArray(arg))).join(" ")}`;
22
29
  });
23
30
  });
24
31
  describe("newVersion", () => {
@@ -5,19 +5,19 @@ class LernaCli extends Cli {
5
5
  super("lerna");
6
6
  }
7
7
 
8
- newVersion(version) {
8
+ newVersion(version: string) {
9
9
  return this.version(version, "--exact", "--yes", "--no-git-tag-version", "--no-push");
10
10
  }
11
11
 
12
- version(...args) {
12
+ version(...args: string[]) {
13
13
  return this.sync("version", ...args);
14
14
  }
15
15
 
16
- run(...args) {
16
+ run(...args: string[]) {
17
17
  return super.run("run", ...args);
18
18
  }
19
19
 
20
- install(...args) {
20
+ install(...args: string[]) {
21
21
  return super.run("install", ...args);
22
22
  }
23
23
  }
@@ -1,24 +1,31 @@
1
+ import execa from "execa";
2
+ import { npm } from "./npm.js";
3
+ import { Cli } from "./cli.js";
4
+
1
5
  vi.mock("execa", () => {
2
- const execaMock = vi.fn();
3
- execaMock.sync = vi.fn();
6
+ const sync = vi.fn();
7
+ const execaMock = Object.assign(vi.fn(), { sync });
4
8
  return { default: execaMock };
5
9
  });
6
10
 
7
- const { default: execa } = await import("execa");
8
- const { npm } = await import("./npm.js");
9
- const { Cli } = await import("./cli.js");
11
+ type ExecaMock = {
12
+ sync: { mockImplementation(fn: (...args: unknown[]) => unknown): void };
13
+ mockReturnValue(v: unknown): void;
14
+ };
15
+
16
+ const execaMock = execa as unknown as ExecaMock;
10
17
 
11
- execa.sync.mockImplementation((...args) => {
18
+ execaMock.sync.mockImplementation((...args) => {
12
19
  return {
13
- stdout: `CMD: ${[].concat(...args.filter((arg) => typeof arg === "string" || Array.isArray(arg))).join(" ")}`
20
+ stdout: `CMD: ${([] as unknown[]).concat(...(args as (string | string[])[]).filter((arg) => typeof arg === "string" || Array.isArray(arg))).join(" ")}`
14
21
  };
15
22
  });
16
- execa.mockReturnValue({});
23
+ execaMock.mockReturnValue({});
17
24
 
18
25
  describe("NpmCli", () => {
19
26
  beforeEach(() => {
20
- vi.spyOn(Cli, "getRaw").mockImplementation((...args) => {
21
- return `CMD: ${[].concat(...args.filter((arg) => typeof arg === "string" || Array.isArray(arg))).join(" ")}`;
27
+ vi.spyOn(Cli, "getRaw").mockImplementation((...args: unknown[]) => {
28
+ return `CMD: ${([] as unknown[]).concat(...(args as (string | string[])[]).filter((arg) => typeof arg === "string" || Array.isArray(arg))).join(" ")}`;
22
29
  });
23
30
  });
24
31
  describe("newVersion", () => {
@@ -5,19 +5,19 @@ class NpmCli extends Cli {
5
5
  super("npm");
6
6
  }
7
7
 
8
- newVersion(version) {
8
+ newVersion(version: string) {
9
9
  return this.version("--no-git-tag-version", version);
10
10
  }
11
11
 
12
- version(...args) {
12
+ version(...args: string[]) {
13
13
  return this.sync("version", ...args);
14
14
  }
15
15
 
16
- run(...args) {
16
+ run(...args: string[]) {
17
17
  return super.run("run", ...args);
18
18
  }
19
19
 
20
- install(...args) {
20
+ install(...args: string[]) {
21
21
  return super.run("install", ...args);
22
22
  }
23
23
 
@@ -1,24 +1,31 @@
1
+ import execa from "execa";
2
+ import { pnpm } from "./pnpm.js";
3
+ import { Cli } from "./cli.js";
4
+
1
5
  vi.mock("execa", () => {
2
- const execaMock = vi.fn();
3
- execaMock.sync = vi.fn();
6
+ const sync = vi.fn();
7
+ const execaMock = Object.assign(vi.fn(), { sync });
4
8
  return { default: execaMock };
5
9
  });
6
10
 
7
- const { default: execa } = await import("execa");
8
- const { pnpm } = await import("./pnpm.js");
9
- const { Cli } = await import("./cli.js");
11
+ type ExecaMock = {
12
+ sync: { mockImplementation(fn: (...args: unknown[]) => unknown): void };
13
+ mockReturnValue(v: unknown): void;
14
+ };
15
+
16
+ const execaMock = execa as unknown as ExecaMock;
10
17
 
11
- execa.sync.mockImplementation((...args) => {
18
+ execaMock.sync.mockImplementation((...args) => {
12
19
  return {
13
- stdout: `CMD: ${[].concat(...args.filter((arg) => typeof arg === "string" || Array.isArray(arg))).join(" ")}`
20
+ stdout: `CMD: ${([] as unknown[]).concat(...(args as (string | string[])[]).filter((arg) => typeof arg === "string" || Array.isArray(arg))).join(" ")}`
14
21
  };
15
22
  });
16
- execa.mockReturnValue({});
23
+ execaMock.mockReturnValue({});
17
24
 
18
25
  describe("PnpmCli", () => {
19
26
  beforeEach(() => {
20
- vi.spyOn(Cli, "getRaw").mockImplementation((...args) => {
21
- return `CMD: ${[].concat(...args.filter((arg) => typeof arg === "string" || Array.isArray(arg))).join(" ")}`;
27
+ vi.spyOn(Cli, "getRaw").mockImplementation((...args: unknown[]) => {
28
+ return `CMD: ${([] as unknown[]).concat(...(args as (string | string[])[]).filter((arg) => typeof arg === "string" || Array.isArray(arg))).join(" ")}`;
22
29
  });
23
30
  });
24
31
  describe("newVersion", () => {
@@ -5,20 +5,20 @@ class PnpmCli extends Cli {
5
5
  super("pnpm");
6
6
  }
7
7
 
8
- newVersion(version) {
8
+ newVersion(version: string) {
9
9
  // pnpm follows npm's version CLI semantics
10
10
  return this.version("--no-git-tag-version", version);
11
11
  }
12
12
 
13
- version(...args) {
13
+ version(...args: string[]) {
14
14
  return this.sync("version", ...args);
15
15
  }
16
16
 
17
- run(...args) {
17
+ run(...args: string[]) {
18
18
  return super.run("run", ...args);
19
19
  }
20
20
 
21
- install(...args) {
21
+ install(...args: string[]) {
22
22
  return super.run("install", ...args);
23
23
  }
24
24
 
@@ -1,26 +1,31 @@
1
- vi.mock("execa", () => {
2
- const execaMock = vi.fn();
3
- execaMock.sync = vi.fn();
1
+ import execa from "execa";
2
+ import { yarn } from "./yarn.js";
3
+ import { Cli } from "./cli.js";
4
4
 
5
+ vi.mock("execa", () => {
6
+ const sync = vi.fn();
7
+ const execaMock = Object.assign(vi.fn(), { sync });
5
8
  return { default: execaMock };
6
9
  });
7
10
 
8
- const { default: execa } = await import("execa");
9
- const { yarn } = await import("./yarn.js");
10
- const { Cli } = await import("./cli.js");
11
+ type ExecaMock = {
12
+ sync: { mockImplementation(fn: (...args: unknown[]) => unknown): void };
13
+ mockReturnValue(v: unknown): void;
14
+ };
11
15
 
12
- execa.sync.mockImplementation((...args) => {
16
+ const execaMock = execa as unknown as ExecaMock;
17
+
18
+ execaMock.sync.mockImplementation((...args) => {
13
19
  return {
14
- stdout: `CMD: ${[].concat(...args.filter((arg) => typeof arg === "string" || Array.isArray(arg))).join(" ")}`
20
+ stdout: `CMD: ${([] as unknown[]).concat(...(args as (string | string[])[]).filter((arg) => typeof arg === "string" || Array.isArray(arg))).join(" ")}`
15
21
  };
16
22
  });
17
-
18
- execa.mockReturnValue({});
23
+ execaMock.mockReturnValue({});
19
24
 
20
25
  describe("YarnCli", () => {
21
26
  beforeEach(() => {
22
- vi.spyOn(Cli, "getRaw").mockImplementation((...args) => {
23
- return `CMD: ${[].concat(...args.filter((arg) => typeof arg === "string" || Array.isArray(arg))).join(" ")}`;
27
+ vi.spyOn(Cli, "getRaw").mockImplementation((...args: unknown[]) => {
28
+ return `CMD: ${([] as unknown[]).concat(...(args as (string | string[])[]).filter((arg) => typeof arg === "string" || Array.isArray(arg))).join(" ")}`;
24
29
  });
25
30
  });
26
31
  describe("newVersion", () => {
@@ -5,19 +5,19 @@ class YarnCli extends Cli {
5
5
  super("yarn");
6
6
  }
7
7
 
8
- newVersion(version) {
8
+ newVersion(version: string) {
9
9
  return this.version("--no-git-tag-version", "--new-version", version);
10
10
  }
11
11
 
12
- version(...args) {
12
+ version(...args: string[]) {
13
13
  return this.sync("version", ...args);
14
14
  }
15
15
 
16
- run(...args) {
16
+ run(...args: string[]) {
17
17
  return super.run(...args);
18
18
  }
19
19
 
20
- install(...args) {
20
+ install(...args: string[]) {
21
21
  return super.run("install", ...args);
22
22
  }
23
23
 
@@ -0,0 +1,39 @@
1
+ import { git } from "./cli/git.js";
2
+
3
+ interface GitWorkspaceContext {
4
+ logger: { info: (...args: unknown[]) => void };
5
+ config: {
6
+ SCM_TOKEN?: string;
7
+ REPOSITORY_URL?: string;
8
+ ORIGIN?: string;
9
+ GIT_USER_NAME?: string;
10
+ GIT_USER_EMAIL?: string;
11
+ GIT_DISABLE_SSL?: string | boolean;
12
+ [key: string]: unknown;
13
+ };
14
+ }
15
+
16
+ export function configureGitWorkspace(context: GitWorkspaceContext) {
17
+ const {
18
+ logger,
19
+ config: { SCM_TOKEN, REPOSITORY_URL, ORIGIN, GIT_USER_NAME, GIT_USER_EMAIL, GIT_DISABLE_SSL }
20
+ } = context;
21
+
22
+ if (GIT_USER_NAME && GIT_USER_EMAIL) {
23
+ git.config("--global", "user.name", `"${GIT_USER_NAME}"`);
24
+ git.config("--global", "user.email", `"${GIT_USER_EMAIL}"`);
25
+ }
26
+
27
+ if (GIT_DISABLE_SSL) {
28
+ logger.info("Disable SSL verification");
29
+ git.config("--global", "http.sslVerify", "false");
30
+ }
31
+
32
+ if (SCM_TOKEN) {
33
+ const repository = (REPOSITORY_URL ?? "").replace("https://", "");
34
+
35
+ logger.info(`Configure remote repository ${repository}`);
36
+ git.remote("remove", ORIGIN ?? "origin").sync();
37
+ git.remote("add", ORIGIN ?? "origin", `https://${SCM_TOKEN}@${repository}`).sync();
38
+ }
39
+ }
@@ -50,7 +50,7 @@ export function getCI() {
50
50
  CI_ORIGIN: "origin-git",
51
51
  REF_COMMIT: GITHUB_SHA,
52
52
  IS_PULL_REQUEST: false,
53
- BRANCH_NAME: GITHUB_REF.replace("refs/heads/", "")
53
+ BRANCH_NAME: (GITHUB_REF as string).replace("refs/heads/", "")
54
54
  };
55
55
  }
56
56
 
@@ -75,6 +75,7 @@ export function getConfig() {
75
75
  const pkg = getPackageJson();
76
76
  const [owner, projectName] = pkg.name.replace(/^@/, "").split("/");
77
77
  const {
78
+ E2E_CMD,
78
79
  PROJECT_NAME,
79
80
  DOCKER_HUB_ID,
80
81
  DOCKER_HUB_PWD,
@@ -109,6 +110,7 @@ export function getConfig() {
109
110
 
110
111
  return {
111
112
  pkg,
113
+ E2E_CMD,
112
114
  PACKAGE_MANAGER: HAS_PNPM ? "pnpm" : HAS_BUN ? "bun" : HAS_YARN ? "yarn" : "npm",
113
115
  PROJECT_NAME: PROJECT_NAME || projectName,
114
116
  HAS_YARN,
@@ -1,3 +1,4 @@
1
+ // @ts-nocheck
1
2
  import fs from "fs";
2
3
 
3
4
  export function getPackageJson() {
@@ -1,3 +1,4 @@
1
+ // @ts-nocheck
1
2
  import { bun } from "./cli/bun.js";
2
3
  import { npm } from "./cli/npm.js";
3
4
  import { pnpm } from "./cli/pnpm.js";
@@ -1,3 +1,4 @@
1
+ // @ts-nocheck
1
2
  export async function getReleaseConfig() {
2
3
  try {
3
4
  return await import(`${process.cwd()}/release.config.mjs`);
@@ -1,3 +1,4 @@
1
+ // @ts-nocheck
1
2
  export * from "./cli/bun.js";
2
3
  export * from "./cli/cli.js";
3
4
  export * from "./cli/docker.js";
@@ -1,3 +1,4 @@
1
+ // @ts-nocheck
1
2
  vi.mock("listr", () => {
2
3
  return { default: vi.fn() };
3
4
  });
@@ -0,0 +1,67 @@
1
+ import chalk from "chalk";
2
+ import figures from "figures";
3
+ import inquirer from "inquirer";
4
+ import { Listr, type ListrTask } from "listr2";
5
+
6
+ import type { CmContext, CommandConstructor } from "./types.js";
7
+ import { getConfig } from "./get-config.js";
8
+ import { getReleaseConfig } from "./get-release-config.js";
9
+
10
+ function createTasksRunner(tasks: ListrTask[], ctx: CmContext): Promise<void> {
11
+ return new Listr(tasks, {
12
+ concurrent: false,
13
+ renderer: !ctx.verbose ? "default" : "verbose"
14
+ }).run(ctx);
15
+ }
16
+
17
+ export async function runCommand(
18
+ klass: CommandConstructor,
19
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
20
+ opts: Record<string, any>
21
+ ): Promise<void> {
22
+ try {
23
+ const config = getConfig();
24
+
25
+ let context = {
26
+ ...getReleaseConfig(),
27
+ ...config,
28
+ branch: { name: config.BRANCH_NAME as string },
29
+ config,
30
+ logger: console,
31
+ verbose: opts.verbose as number | undefined
32
+ } as unknown as CmContext;
33
+
34
+ const command = new klass();
35
+
36
+ if (command.mapContext) {
37
+ context = command.mapContext(opts as Record<string, unknown>, context);
38
+ }
39
+
40
+ if (command.prompt) {
41
+ context = {
42
+ ...context,
43
+ ...((await (inquirer as unknown as { prompt: (q: unknown) => Promise<Record<string, unknown>> }).prompt(
44
+ command.prompt(context)
45
+ )) as Record<string, unknown>)
46
+ };
47
+ }
48
+
49
+ command.verifyConditions?.(context);
50
+
51
+ const tasks = command.getTasks(context);
52
+
53
+ await createTasksRunner(tasks, context);
54
+
55
+ command.success?.(context);
56
+ } catch (er) {
57
+ console.error(chalk.red(figures.cross + " " + String(er)));
58
+ if (opts.verbose) {
59
+ console.error(String((er as Error).stack ?? "").replace(String(er), ""));
60
+ }
61
+ process.exit(-1);
62
+ }
63
+ }
64
+
65
+ process.on("unhandledRejection", () => {
66
+ // avoid extra promise rejection when using toObservable
67
+ });
@@ -0,0 +1,26 @@
1
+ import type { ListrTask } from "listr2";
2
+ import type { BaseContext, LastRelease, NextRelease } from "semantic-release";
3
+ import type { getConfig } from "./get-config";
4
+
5
+ export type CmContext<Extended = any> = BaseContext & {
6
+ config: ReturnType<typeof getConfig>;
7
+ branch: { name: string; type?: string };
8
+ nextRelease?: Partial<NextRelease>;
9
+ lastRelease?: Partial<LastRelease>;
10
+ verbose?: number;
11
+ output?: string[];
12
+ } & Extended;
13
+
14
+ export type SemanticContext = CmContext;
15
+
16
+ export interface ICommand {
17
+ mapContext?(opts: Record<string, unknown>, context: CmContext): CmContext;
18
+ prompt?(context: CmContext): Array<Record<string, unknown>>;
19
+ verifyConditions?(context: CmContext): void;
20
+ getTasks(context: CmContext): ListrTask[];
21
+ success?(context: CmContext): void;
22
+ }
23
+
24
+ export type CommandConstructor = new () => ICommand;
25
+
26
+ export type { ListrTask };
@@ -0,0 +1,4 @@
1
+ // Minimal @semantic-release/commit-analyzer type declarations
2
+ declare module "@semantic-release/commit-analyzer" {
3
+ export function analyzeCommits(pluginConfig: unknown, context: unknown): Promise<string | null>;
4
+ }
@@ -1,4 +1,8 @@
1
- import * as commands from "./commands/index.js";
1
+ import * as commands from "./commands";
2
+
3
+ declare global {
4
+ const __VERSION__: string;
5
+ }
2
6
 
3
7
  export * from "./commands/release.js";
4
8
  export * from "./common/index.js";