@cmflow/cli 3.3.0 → 3.4.0-alpha.3

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 (165) hide show
  1. package/README.md +102 -298
  2. package/dist/bin/cm.mjs +83622 -0
  3. package/dist/bin/cmrelease.mjs +75079 -0
  4. package/dist/cli-truncate-Bi2MjGwF.mjs +323 -0
  5. package/dist/cli-truncate-DMcpM5Q7.mjs +2 -0
  6. package/dist/cli-truncate-DMcpM5Q7.mjs.map +1 -0
  7. package/dist/cli-truncate-DsW0mgI_.mjs +323 -0
  8. package/dist/common-BdfXquG0.mjs +61 -0
  9. package/dist/common-BdfXquG0.mjs.map +1 -0
  10. package/dist/compile-packages-BB08_q2B.mjs +2 -0
  11. package/dist/compile-packages-BB08_q2B.mjs.map +1 -0
  12. package/dist/docker-Cc30aRzl.mjs +34 -0
  13. package/dist/docker-Cc30aRzl.mjs.map +1 -0
  14. package/dist/docker-clean-tags-EvFdWykP.mjs +2 -0
  15. package/dist/docker-clean-tags-EvFdWykP.mjs.map +1 -0
  16. package/dist/docker-publish-CG0aN9se.mjs +2 -0
  17. package/dist/docker-publish-CG0aN9se.mjs.map +1 -0
  18. package/dist/find-packages-611B-66T.mjs +42 -0
  19. package/dist/find-packages-611B-66T.mjs.map +1 -0
  20. package/dist/get-config-8ivgd1KC.mjs +9 -0
  21. package/dist/get-config-8ivgd1KC.mjs.map +1 -0
  22. package/dist/get-east-asian-width-Tfn8qoqd.mjs +2 -0
  23. package/dist/get-east-asian-width-Tfn8qoqd.mjs.map +1 -0
  24. package/dist/get-east-asian-width-wiVWCFXf.mjs +682 -0
  25. package/dist/log-update-CLbF3iV6.mjs +6 -0
  26. package/dist/log-update-CLbF3iV6.mjs.map +1 -0
  27. package/dist/log-update-CTXRtajW.mjs +668 -0
  28. package/dist/log-update-Dy1vPMGY.mjs +668 -0
  29. package/dist/npm-VM_GgazT.mjs +2 -0
  30. package/dist/npm-VM_GgazT.mjs.map +1 -0
  31. package/dist/rolldown-runtime-B4iAMlE-.mjs +35 -0
  32. package/dist/semver-DFjVbN1S.mjs +2 -0
  33. package/dist/semver-DFjVbN1S.mjs.map +1 -0
  34. package/dist/source-CwLcYLzI.mjs +7 -0
  35. package/dist/source-CwLcYLzI.mjs.map +1 -0
  36. package/dist/wrap-ansi-9ugahFCy.mjs +9 -0
  37. package/dist/wrap-ansi-9ugahFCy.mjs.map +1 -0
  38. package/dist/wrap-ansi-BRr0GA6g.mjs +330 -0
  39. package/dist/wrap-ansi-Cupoo4Yg.mjs +330 -0
  40. package/dist/wrap-ansi-dwgEjNWf.mjs +2 -0
  41. package/dist/write-package-cxki9d3K.mjs +8 -0
  42. package/dist/write-package-cxki9d3K.mjs.map +1 -0
  43. package/dist/write-packages-CxCAl_AG.mjs +10 -0
  44. package/dist/write-packages-CxCAl_AG.mjs.map +1 -0
  45. package/package.json +40 -63
  46. package/tsdown.config.ts +54 -0
  47. package/.oxfmtrc.json +0 -11
  48. package/.yarn/install-state.gz +0 -0
  49. package/.yarn/releases/yarn-4.7.0.cjs +0 -935
  50. package/.yarnrc.yml +0 -3
  51. package/bin/checkfeatures.js +0 -13
  52. package/bin/cm-clean.js +0 -8
  53. package/bin/cm-config.js +0 -15
  54. package/bin/cm-deploy.js +0 -8
  55. package/bin/cm-expedit.js +0 -19
  56. package/bin/cm-fetch.js +0 -12
  57. package/bin/cm-finish.js +0 -14
  58. package/bin/cm-jira-releases.js +0 -16
  59. package/bin/cm-merge.js +0 -12
  60. package/bin/cm-publish.js +0 -15
  61. package/bin/cm-push.js +0 -15
  62. package/bin/cm-rebase.js +0 -15
  63. package/bin/cm-republish.js +0 -12
  64. package/bin/cm-start.js +0 -21
  65. package/bin/cm.js +0 -27
  66. package/bin/cmpull.js +0 -22
  67. package/bin/cmrelease.js +0 -5
  68. package/mise.toml +0 -2
  69. package/oxlint.json +0 -25
  70. package/release.config.mjs +0 -39
  71. package/src/commands/checkfeatures.js +0 -20
  72. package/src/commands/clean.js +0 -29
  73. package/src/commands/config.js +0 -23
  74. package/src/commands/deploy.js +0 -34
  75. package/src/commands/fetch.js +0 -18
  76. package/src/commands/finish.js +0 -43
  77. package/src/commands/index.js +0 -12
  78. package/src/commands/jira-releases.js +0 -62
  79. package/src/commands/merge.js +0 -41
  80. package/src/commands/prompts/branches.js +0 -38
  81. package/src/commands/pull.js +0 -30
  82. package/src/commands/push.js +0 -23
  83. package/src/commands/rebase.js +0 -35
  84. package/src/commands/release.js +0 -21
  85. package/src/commands/republish.js +0 -21
  86. package/src/commands/start.js +0 -109
  87. package/src/commands/tasks/merge-branch.js +0 -65
  88. package/src/commands/tasks/push-branch.js +0 -10
  89. package/src/commands/tasks/rebase-all-branches.js +0 -29
  90. package/src/commands/tasks/refresh-repository.js +0 -34
  91. package/src/commands/tasks/run-test.js +0 -21
  92. package/src/commands/tasks/update-branch.js +0 -43
  93. package/src/commands/tasks/update-dependencies.js +0 -42
  94. package/src/commands/utils/check-install.js +0 -31
  95. package/src/common/back/directus/directus-flow.js +0 -40
  96. package/src/common/back/directus/directus-flow.test.js +0 -62
  97. package/src/common/back/http/http-proxy.js +0 -15
  98. package/src/common/back/http/http-request.js +0 -77
  99. package/src/common/back/http/http-request.spec.js +0 -49
  100. package/src/common/back/jira/get-sorted-releases.js +0 -40
  101. package/src/common/back/jira/interfaces/JiraIIssue.d.ts +0 -100
  102. package/src/common/back/jira/jira-releases.js +0 -36
  103. package/src/common/back/jira/jira-request.js +0 -21
  104. package/src/common/back/jira/jira-request.spec.js +0 -59
  105. package/src/common/back/jira/jira-search.js +0 -17
  106. package/src/common/back/jira/jira-search.spec.js +0 -44
  107. package/src/common/cli/bun.js +0 -33
  108. package/src/common/cli/bun.test.js +0 -51
  109. package/src/common/cli/cli.js +0 -110
  110. package/src/common/cli/docker.js +0 -66
  111. package/src/common/cli/docker.test.js +0 -133
  112. package/src/common/cli/git.js +0 -121
  113. package/src/common/cli/git.test.js +0 -207
  114. package/src/common/cli/lerna.js +0 -25
  115. package/src/common/cli/lerna.test.js +0 -51
  116. package/src/common/cli/npm.js +0 -33
  117. package/src/common/cli/npm.test.js +0 -51
  118. package/src/common/cli/pnpm.js +0 -34
  119. package/src/common/cli/pnpm.test.js +0 -51
  120. package/src/common/cli/yarn.js +0 -33
  121. package/src/common/cli/yarn.test.js +0 -53
  122. package/src/common/configure-git-workspace.js +0 -26
  123. package/src/common/get-config.js +0 -157
  124. package/src/common/get-package-json.js +0 -14
  125. package/src/common/get-package-manager.js +0 -12
  126. package/src/common/get-release-config.js +0 -8
  127. package/src/common/index.js +0 -13
  128. package/src/common/run-command.js +0 -64
  129. package/src/common/run-command.test.js +0 -65
  130. package/src/index.js +0 -10
  131. package/src/semantic/core/analyze-commits.js +0 -17
  132. package/src/semantic/core/conditional.js +0 -55
  133. package/src/semantic/core/exit.js +0 -14
  134. package/src/semantic/core/prepare/bump-version.js +0 -38
  135. package/src/semantic/core/prepare/commit.js +0 -29
  136. package/src/semantic/core/prepare/release-info.js +0 -5
  137. package/src/semantic/core/run.js +0 -22
  138. package/src/semantic/core/sync-repository.js +0 -52
  139. package/src/semantic/core/verify-conditions.js +0 -40
  140. package/src/semantic/core/verify-release.js +0 -9
  141. package/src/semantic/define-config.js +0 -42
  142. package/src/semantic/docker/publish.js +0 -5
  143. package/src/semantic/docker/success.js +0 -9
  144. package/src/semantic/utils/__mock__/test1/package.json +0 -7
  145. package/src/semantic/utils/__mock__/test1/packages/a/package.json +0 -9
  146. package/src/semantic/utils/__mock__/test1/packages/b/package.json +0 -7
  147. package/src/semantic/utils/__mock__/test2/package.json +0 -4
  148. package/src/semantic/utils/__mock__/test2/packages/a/package.json +0 -7
  149. package/src/semantic/utils/__mock__/test2/packages/b/package.json +0 -5
  150. package/src/semantic/utils/bump-packages-version.js +0 -52
  151. package/src/semantic/utils/bump-packages-version.test.js +0 -75
  152. package/src/semantic/utils/calculate-snapshot-version.js +0 -15
  153. package/src/semantic/utils/calculate-snapshot-version.test.js +0 -67
  154. package/src/semantic/utils/display-package-info.js +0 -11
  155. package/src/semantic/utils/display-release-info.js +0 -12
  156. package/src/semantic/utils/docker-clean-tags.js +0 -51
  157. package/src/semantic/utils/docker-clean-tags.test.js +0 -61
  158. package/src/semantic/utils/docker-publish.js +0 -23
  159. package/src/semantic/utils/docker-publish.test.js +0 -44
  160. package/src/semantic/utils/log-section.js +0 -5
  161. package/src/semantic/utils/release-rules.js +0 -15
  162. package/src/semantic/utils/transform-writer.js +0 -77
  163. package/src/workflow/index.js +0 -42
  164. package/tsconfig.json +0 -37
  165. package/vitest.config.mts +0 -10
@@ -1,66 +0,0 @@
1
- import axios from "axios";
2
-
3
- import { Cli } from "./cli.js";
4
-
5
- class DockerCli extends Cli {
6
- constructor() {
7
- super("docker");
8
- }
9
-
10
- tag(...args) {
11
- return this.get("tag", ...args);
12
- }
13
-
14
- login(...args) {
15
- return this.sync("login", ...args);
16
- }
17
-
18
- push(...args) {
19
- return this.run("push", ...args);
20
- }
21
-
22
- async getToken(username, password) {
23
- const {
24
- data: { token }
25
- } = await axios({
26
- method: "POST",
27
- url: "https://hub.docker.com/v2/users/login/",
28
- headers: {
29
- Accept: "application/json",
30
- "Content-Type": "application/json"
31
- },
32
- data: {
33
- username,
34
- password
35
- }
36
- });
37
-
38
- return token;
39
- }
40
-
41
- async getTags({ token, repository }) {
42
- const { data } = await axios({
43
- method: "GET",
44
- url: `https://hub.docker.com/v2/repositories/${repository}/tags/?page=1&page_size=500`,
45
- headers: {
46
- Accept: "application/json",
47
- Authorization: `JWT ${token}`
48
- }
49
- });
50
-
51
- return data.results;
52
- }
53
-
54
- async deleteTag(tag, { token, repository }) {
55
- await axios({
56
- method: "DELETE",
57
- url: `https://hub.docker.com/v2/repositories/${repository}/tags/${tag}/`,
58
- headers: {
59
- Accept: "application/json",
60
- Authorization: `JWT ${token}`
61
- }
62
- });
63
- }
64
- }
65
-
66
- export const docker = new DockerCli();
@@ -1,133 +0,0 @@
1
- vi.mock("axios", () => {
2
- return { default: vi.fn() };
3
- });
4
- vi.mock("execa", () => {
5
- const execaMock = vi.fn();
6
- execaMock.sync = vi.fn();
7
- return { default: execaMock };
8
- });
9
- const { default: execa } = await import("execa");
10
- const { default: axios } = await import("axios");
11
- const { docker } = await import("./docker.js");
12
- const { Cli } = await import("./cli.js");
13
-
14
- execa.mockReturnValue({});
15
-
16
- execa.sync.mockImplementation((...args) => {
17
- return {
18
- stdout: `CMD: ${[].concat(...args.filter((arg) => typeof arg === "string" || Array.isArray(arg))).join(" ")}`
19
- };
20
- });
21
-
22
- describe("DockerCli", () => {
23
- beforeEach(() => {
24
- vi.spyOn(Cli, "getRaw").mockImplementation((...args) => {
25
- return `CMD: ${[].concat(...args.filter((arg) => typeof arg === "string" || Array.isArray(arg))).join(" ")}`;
26
- });
27
- });
28
- describe("tag", () => {
29
- it("should run tag cmd", () => {
30
- const result = docker.tag("tag-arg", "image");
31
-
32
- expect(result).toEqual("CMD: docker tag tag-arg image");
33
- expect(Cli.getRaw).toHaveBeenCalledWith("docker", ["tag", "tag-arg", "image"], {
34
- cwd: process.cwd()
35
- });
36
- });
37
- });
38
- describe("login", () => {
39
- it("should run login cmd", () => {
40
- const result = docker.login("login-arg");
41
-
42
- expect(result.stdout).toEqual("CMD: docker login login-arg");
43
- expect(execa.sync).toHaveBeenCalledWith("docker", ["login", "login-arg"], {
44
- cwd: process.cwd(),
45
- stdio: "inherit"
46
- });
47
- });
48
- });
49
- describe("push", () => {
50
- it("should run push cmd", async () => {
51
- await docker.push("push-arg");
52
-
53
- expect(execa).toHaveBeenCalledWith("docker", ["push", "push-arg"], {
54
- cwd: process.cwd(),
55
- stdio: "inherit"
56
- });
57
- });
58
- });
59
- describe("getToken", () => {
60
- beforeEach(() => {
61
- axios.mockReturnValue({ data: { token: "token" } });
62
- });
63
- it("should get token", async () => {
64
- const token = await docker.getToken("username", "password");
65
-
66
- expect(axios).toHaveBeenCalledWith({
67
- method: "POST",
68
- url: "https://hub.docker.com/v2/users/login/",
69
- headers: {
70
- Accept: "application/json",
71
- "Content-Type": "application/json"
72
- },
73
- data: {
74
- password: "password",
75
- username: "username"
76
- }
77
- });
78
- expect(token).toEqual("token");
79
- });
80
- });
81
- describe("getTags", () => {
82
- beforeEach(() => {
83
- axios.mockReturnValue({
84
- data: {
85
- results: [
86
- {
87
- name: "branch-1",
88
- last_updated: new Date("2020-06-01")
89
- }
90
- ]
91
- }
92
- });
93
- });
94
- it("should get token", async () => {
95
- const tags = await docker.getTags({
96
- token: "token",
97
- repository: "owner"
98
- });
99
-
100
- expect(tags).toEqual([
101
- {
102
- name: "branch-1",
103
- last_updated: new Date("2020-06-01")
104
- }
105
- ]);
106
- expect(axios).toHaveBeenCalledWith({
107
- method: "GET",
108
- url: "https://hub.docker.com/v2/repositories/owner/tags/?page=1&page_size=500",
109
- headers: {
110
- Accept: "application/json",
111
- Authorization: "JWT token"
112
- }
113
- });
114
- });
115
- });
116
- describe("deleteTag", () => {
117
- it("should run delete Tag", async () => {
118
- await docker.deleteTag("my-tag", {
119
- token: "token",
120
- repository: "owner"
121
- });
122
-
123
- expect(axios).toHaveBeenCalledWith({
124
- headers: {
125
- Accept: "application/json",
126
- Authorization: "JWT token"
127
- },
128
- method: "DELETE",
129
- url: "https://hub.docker.com/v2/repositories/owner/tags/my-tag/"
130
- });
131
- });
132
- });
133
- });
@@ -1,121 +0,0 @@
1
- import { Cli } from "./cli.js";
2
-
3
- class GitCli extends Cli {
4
- constructor() {
5
- super("git");
6
- }
7
-
8
- init(...args) {
9
- return this.run("init", ...args);
10
- }
11
-
12
- add(...args) {
13
- return this.run("add", ...args);
14
- }
15
-
16
- status(...args) {
17
- return this.sync("status", ...args);
18
- }
19
-
20
- branch(...args) {
21
- return this.run("branch", ...args);
22
- }
23
-
24
- clean(...args) {
25
- return this.run("clean", ...args);
26
- }
27
-
28
- config(...args) {
29
- return this.run("config", ...args).get();
30
- }
31
-
32
- checkout(...args) {
33
- return this.run("checkout", ...args);
34
- }
35
-
36
- commit(...args) {
37
- return this.run("commit", ...args);
38
- }
39
-
40
- fetch(...args) {
41
- return this.run("fetch", ...args);
42
- }
43
-
44
- prune(...args) {
45
- return this.run("prune", ...args);
46
- }
47
-
48
- merge(...args) {
49
- return this.sync("merge", ...args);
50
- }
51
-
52
- reset(...args) {
53
- return this.sync("reset", ...args);
54
- }
55
-
56
- remote(...args) {
57
- return this.run("remote", ...args);
58
- }
59
-
60
- rebase(...args) {
61
- return this.run("rebase", ...args);
62
- }
63
-
64
- getCommitTag(ref = "HEAD") {
65
- return this.get("rev-parse", "--short", ref);
66
- }
67
-
68
- getBranchName(ref = "HEAD") {
69
- return this.get("rev-parse", "--abbrev-ref", ref);
70
- }
71
-
72
- getLastCommitMsg() {
73
- return this.get("log", "-1", "--pretty=%B");
74
- }
75
-
76
- push(...args) {
77
- return this.run("push", ...args);
78
- }
79
-
80
- branchExists(branch, origin = "origin") {
81
- return this.branch("-a").getRaw().trim().includes(`remotes/${origin}/${branch}`);
82
- }
83
-
84
- checkBranchRemoteStatus(branch, origin = "origin") {
85
- return this.run("cherry", branch, `${origin}/${branch}`).get();
86
- }
87
-
88
- branches(...args) {
89
- return this.branch(...args)
90
- .get()
91
- .split("\n")
92
- .map((branch) => branch.trim().replace("* ", ""))
93
- .filter((branch) => !!branch)
94
- .filter((branch) => !String(branch).includes("/HEAD"));
95
- }
96
-
97
- show(branch) {
98
- return this.run("show", '--format="%ci|%cr|%an"', branch, "--").getRaw().split("\n")[0].trim();
99
- }
100
-
101
- branchesInfos(...args) {
102
- return this.branches(...args)
103
- .map((branch) => {
104
- try {
105
- const [date, creation, author] = this.show(branch).split("|");
106
- return {
107
- branch,
108
- date,
109
- creation,
110
- author
111
- };
112
- } catch {
113
- return undefined;
114
- }
115
- })
116
- .filter((b) => !!b)
117
- .sort((info1, info2) => info1.date < info2.date);
118
- }
119
- }
120
-
121
- export const git = new GitCli();
@@ -1,207 +0,0 @@
1
- vi.mock("execa", () => {
2
- const execaMock = vi.fn();
3
- execaMock.sync = vi.fn();
4
- return { default: execaMock };
5
- });
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
- return {
11
- stdout: `CMD: ${[].concat(...args.filter((arg) => typeof arg === "string" || Array.isArray(arg))).join(" ")}`
12
- };
13
- });
14
-
15
- execa.mockReturnValue({});
16
-
17
- describe("GitCli", () => {
18
- beforeEach(() => {
19
- vi.spyOn(Cli, "getRaw").mockImplementation((...args) => {
20
- return `CMD: ${[].concat(...args.filter((arg) => typeof arg === "string" || Array.isArray(arg))).join(" ")}`;
21
- });
22
- });
23
- describe("init", () => {
24
- it("should run init cmd", () => {
25
- const result = git.init("init-arg").sync();
26
-
27
- expect(result.stdout).toEqual("CMD: git init init-arg");
28
- expect(execa.sync).toHaveBeenCalledWith("git", ["init", "init-arg"], {
29
- cwd: process.cwd(),
30
- stdio: "inherit"
31
- });
32
- });
33
- });
34
- describe("add", () => {
35
- it("should run add cmd", () => {
36
- const result = git.add("add-arg").sync();
37
-
38
- expect(result.stdout).toEqual("CMD: git add add-arg");
39
- expect(execa.sync).toHaveBeenCalledWith("git", ["add", "add-arg"], {
40
- cwd: process.cwd(),
41
- stdio: "inherit"
42
- });
43
- });
44
- });
45
- describe("branch", () => {
46
- it("should run branch cmd", () => {
47
- const result = git.branch("branch-arg").sync();
48
-
49
- expect(result.stdout).toEqual("CMD: git branch branch-arg");
50
- expect(execa.sync).toHaveBeenCalledWith("git", ["branch", "branch-arg"], {
51
- cwd: process.cwd(),
52
- stdio: "inherit"
53
- });
54
- });
55
- });
56
- describe("clean", () => {
57
- it("should run branch cmd", () => {
58
- const result = git.clean("clean-arg").sync();
59
-
60
- expect(result.stdout).toEqual("CMD: git clean clean-arg");
61
- expect(execa.sync).toHaveBeenCalledWith("git", ["clean", "clean-arg"], {
62
- cwd: process.cwd(),
63
- stdio: "inherit"
64
- });
65
- });
66
- });
67
- describe("config", () => {
68
- it("should run config cmd", () => {
69
- const result = git.config("config-arg");
70
-
71
- expect(result).toEqual("CMD: git config config-arg");
72
- expect(Cli.getRaw).toHaveBeenCalledWith("git", ["config", "config-arg"], {
73
- cwd: process.cwd()
74
- });
75
- });
76
- });
77
- describe("checkout", () => {
78
- it("should run checkout cmd", () => {
79
- const result = git.checkout("checkout-arg").sync();
80
-
81
- expect(result.stdout).toEqual("CMD: git checkout checkout-arg");
82
- expect(execa.sync).toHaveBeenCalledWith("git", ["checkout", "checkout-arg"], {
83
- cwd: process.cwd(),
84
- stdio: "inherit"
85
- });
86
- });
87
- });
88
- describe("commit", () => {
89
- it("should run commit cmd", () => {
90
- const result = git.commit("commit-arg").sync();
91
-
92
- expect(result.stdout).toEqual("CMD: git commit commit-arg");
93
- expect(execa.sync).toHaveBeenCalledWith("git", ["commit", "commit-arg"], {
94
- cwd: process.cwd(),
95
- stdio: "inherit"
96
- });
97
- });
98
- });
99
- describe("fetch", () => {
100
- it("should run fetch cmd", () => {
101
- const result = git.fetch("fetch-arg").sync();
102
-
103
- expect(result.stdout).toEqual("CMD: git fetch fetch-arg");
104
- expect(execa.sync).toHaveBeenCalledWith("git", ["fetch", "fetch-arg"], {
105
- cwd: process.cwd(),
106
- stdio: "inherit"
107
- });
108
- });
109
- });
110
- describe("prune", () => {
111
- it("should run fetch cmd", () => {
112
- const result = git.prune("prune-arg").sync();
113
-
114
- expect(result.stdout).toEqual("CMD: git prune prune-arg");
115
- expect(execa.sync).toHaveBeenCalledWith("git", ["prune", "prune-arg"], {
116
- cwd: process.cwd(),
117
- stdio: "inherit"
118
- });
119
- });
120
- });
121
- describe("merge", () => {
122
- it("should run fetch cmd", () => {
123
- const result = git.merge("merge-arg");
124
-
125
- expect(result.stdout).toEqual("CMD: git merge merge-arg");
126
- expect(execa.sync).toHaveBeenCalledWith("git", ["merge", "merge-arg"], {
127
- cwd: process.cwd(),
128
- stdio: "inherit"
129
- });
130
- });
131
- });
132
- describe("reset", () => {
133
- it("should run reset cmd", () => {
134
- const result = git.reset("reset-arg");
135
-
136
- expect(result.stdout).toEqual("CMD: git reset reset-arg");
137
- expect(execa.sync).toHaveBeenCalledWith("git", ["reset", "reset-arg"], {
138
- cwd: process.cwd(),
139
- stdio: "inherit"
140
- });
141
- });
142
- });
143
- describe("remote", () => {
144
- it("should run remote cmd", () => {
145
- const result = git.remote("remote-arg").sync();
146
-
147
- expect(result.stdout).toEqual("CMD: git remote remote-arg");
148
- expect(execa.sync).toHaveBeenCalledWith("git", ["remote", "remote-arg"], {
149
- cwd: process.cwd(),
150
- stdio: "inherit"
151
- });
152
- });
153
- });
154
- describe("rebase", () => {
155
- it("should run rebase cmd", () => {
156
- const result = git.rebase("rebase-arg").sync();
157
-
158
- expect(result.stdout).toEqual("CMD: git rebase rebase-arg");
159
- expect(execa.sync).toHaveBeenCalledWith("git", ["rebase", "rebase-arg"], {
160
- cwd: process.cwd(),
161
- stdio: "inherit"
162
- });
163
- });
164
- });
165
- describe("status", () => {
166
- it("should run status cmd", () => {
167
- const result = git.status("status-arg");
168
-
169
- expect(result.stdout).toEqual("CMD: git status status-arg");
170
- expect(execa.sync).toHaveBeenCalledWith("git", ["status", "status-arg"], {
171
- cwd: process.cwd(),
172
- stdio: "inherit"
173
- });
174
- });
175
- });
176
- describe("getCommitTag", () => {
177
- it("should run revParse cmd", () => {
178
- const result = git.getCommitTag("ref");
179
-
180
- expect(result).toEqual("CMD: git rev-parse --short ref");
181
- });
182
- });
183
- describe("getBranchName", () => {
184
- it("should run revParse cmd", () => {
185
- const result = git.getBranchName("ref");
186
-
187
- expect(result).toEqual("CMD: git rev-parse --abbrev-ref ref");
188
- });
189
- });
190
- describe("getLastCommitMsg", () => {
191
- it("should run revParse cmd", () => {
192
- const result = git.getLastCommitMsg();
193
-
194
- expect(result).toEqual("CMD: git log -1 --pretty=%B");
195
- });
196
- });
197
- describe("push", () => {
198
- it("should run push cmd", async () => {
199
- await git.push("push-arg");
200
-
201
- expect(execa).toHaveBeenCalledWith("git", ["push", "push-arg"], {
202
- cwd: process.cwd(),
203
- stdio: "inherit"
204
- });
205
- });
206
- });
207
- });
@@ -1,25 +0,0 @@
1
- import { Cli } from "./cli.js";
2
-
3
- class LernaCli extends Cli {
4
- constructor() {
5
- super("lerna");
6
- }
7
-
8
- newVersion(version) {
9
- return this.version(version, "--exact", "--yes", "--no-git-tag-version", "--no-push");
10
- }
11
-
12
- version(...args) {
13
- return this.sync("version", ...args);
14
- }
15
-
16
- run(...args) {
17
- return super.run("run", ...args);
18
- }
19
-
20
- install(...args) {
21
- return super.run("install", ...args);
22
- }
23
- }
24
-
25
- export const lerna = new LernaCli();
@@ -1,51 +0,0 @@
1
- vi.mock("execa", () => {
2
- const execaMock = vi.fn();
3
- execaMock.sync = vi.fn();
4
- return { default: execaMock };
5
- });
6
- const { default: execa } = await import("execa");
7
- const { lerna } = await import("./lerna.js");
8
- const { Cli } = await import("./cli.js");
9
-
10
- execa.sync.mockImplementation((...args) => {
11
- return {
12
- stdout: `CMD: ${[].concat(...args.filter((arg) => typeof arg === "string" || Array.isArray(arg))).join(" ")}`
13
- };
14
- });
15
-
16
- execa.mockReturnValue({});
17
-
18
- describe("LernaCli", () => {
19
- beforeEach(() => {
20
- vi.spyOn(Cli, "getRaw").mockImplementation((...args) => {
21
- return `CMD: ${[].concat(...args.filter((arg) => typeof arg === "string" || Array.isArray(arg))).join(" ")}`;
22
- });
23
- });
24
- describe("newVersion", () => {
25
- it("should run add cmd", () => {
26
- const result = lerna.newVersion("1.0.0");
27
-
28
- expect(result.stdout).toEqual("CMD: lerna version 1.0.0 --exact --yes --no-git-tag-version --no-push");
29
- });
30
- });
31
- describe("run", () => {
32
- it('should run "run" cmd', async () => {
33
- await lerna.run("run-arg");
34
-
35
- expect(execa).toHaveBeenCalledWith("lerna", ["run", "run-arg"], {
36
- cwd: process.cwd(),
37
- stdio: "inherit"
38
- });
39
- });
40
- });
41
- describe("install", () => {
42
- it('should run "install" cmd', async () => {
43
- await lerna.install("install-arg");
44
-
45
- expect(execa).toHaveBeenCalledWith("lerna", ["install", "install-arg"], {
46
- cwd: process.cwd(),
47
- stdio: "inherit"
48
- });
49
- });
50
- });
51
- });
@@ -1,33 +0,0 @@
1
- import { Cli } from "./cli.js";
2
-
3
- class NpmCli extends Cli {
4
- constructor() {
5
- super("npm");
6
- }
7
-
8
- newVersion(version) {
9
- return this.version("--no-git-tag-version", version);
10
- }
11
-
12
- version(...args) {
13
- return this.sync("version", ...args);
14
- }
15
-
16
- run(...args) {
17
- return super.run("run", ...args);
18
- }
19
-
20
- install(...args) {
21
- return super.run("install", ...args);
22
- }
23
-
24
- /**
25
- * Reinstall dependencies without package-lock mutation
26
- * @returns {Promise<unknown>}
27
- */
28
- restore() {
29
- return super.run("ci");
30
- }
31
- }
32
-
33
- export const npm = new NpmCli();
@@ -1,51 +0,0 @@
1
- vi.mock("execa", () => {
2
- const execaMock = vi.fn();
3
- execaMock.sync = vi.fn();
4
- return { default: execaMock };
5
- });
6
-
7
- const { default: execa } = await import("execa");
8
- const { npm } = await import("./npm.js");
9
- const { Cli } = await import("./cli.js");
10
-
11
- execa.sync.mockImplementation((...args) => {
12
- return {
13
- stdout: `CMD: ${[].concat(...args.filter((arg) => typeof arg === "string" || Array.isArray(arg))).join(" ")}`
14
- };
15
- });
16
- execa.mockReturnValue({});
17
-
18
- describe("NpmCli", () => {
19
- beforeEach(() => {
20
- vi.spyOn(Cli, "getRaw").mockImplementation((...args) => {
21
- return `CMD: ${[].concat(...args.filter((arg) => typeof arg === "string" || Array.isArray(arg))).join(" ")}`;
22
- });
23
- });
24
- describe("newVersion", () => {
25
- it("should run newVersion cmd", () => {
26
- const result = npm.newVersion("1.0.0");
27
-
28
- expect(result.stdout).toEqual("CMD: npm version --no-git-tag-version 1.0.0");
29
- });
30
- });
31
- describe("run", () => {
32
- it('should run "run" cmd', async () => {
33
- await npm.run("run-arg");
34
-
35
- expect(execa).toHaveBeenCalledWith("npm", ["run", "run-arg"], {
36
- cwd: process.cwd(),
37
- stdio: "inherit"
38
- });
39
- });
40
- });
41
- describe("install", () => {
42
- it('should run "install" cmd', async () => {
43
- await npm.install("install-arg");
44
-
45
- expect(execa).toHaveBeenCalledWith("npm", ["install", "install-arg"], {
46
- cwd: process.cwd(),
47
- stdio: "inherit"
48
- });
49
- });
50
- });
51
- });