@cmflow/cli 3.4.0-alpha.1 → 3.4.0-alpha.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +110 -294
- package/dist/bin/cm.mjs +9985 -1348
- package/dist/bin/cmrelease.mjs +3875 -1193
- package/dist/{cli-truncate-CXNquMRK.mjs → cli-truncate-Bi2MjGwF.mjs} +177 -6
- package/dist/cli-truncate-DMcpM5Q7.mjs +2 -0
- package/dist/cli-truncate-DMcpM5Q7.mjs.map +1 -0
- package/dist/{cli-truncate-BmHD4ngn.mjs → cli-truncate-DsW0mgI_.mjs} +177 -6
- package/dist/{common-CwPbT3So.mjs → common-BdfXquG0.mjs} +31 -36
- package/dist/common-BdfXquG0.mjs.map +1 -0
- package/dist/compile-packages-BB08_q2B.mjs +2 -0
- package/dist/compile-packages-BB08_q2B.mjs.map +1 -0
- package/dist/docker-Cc30aRzl.mjs +34 -0
- package/dist/docker-Cc30aRzl.mjs.map +1 -0
- package/dist/docker-clean-tags-EvFdWykP.mjs +2 -0
- package/dist/docker-clean-tags-EvFdWykP.mjs.map +1 -0
- package/dist/docker-publish-CG0aN9se.mjs +2 -0
- package/dist/docker-publish-CG0aN9se.mjs.map +1 -0
- package/dist/find-packages-611B-66T.mjs +42 -0
- package/dist/find-packages-611B-66T.mjs.map +1 -0
- package/dist/get-config-8ivgd1KC.mjs +9 -0
- package/dist/get-config-8ivgd1KC.mjs.map +1 -0
- package/dist/get-east-asian-width-Tfn8qoqd.mjs.map +1 -1
- package/dist/{get-east-asian-width-eFfEkHwo.mjs → get-east-asian-width-wiVWCFXf.mjs} +4 -4
- package/dist/log-update-CLbF3iV6.mjs +6 -0
- package/dist/log-update-CLbF3iV6.mjs.map +1 -0
- package/dist/{log-update-B2GqeeDd.mjs → log-update-CTXRtajW.mjs} +185 -14
- package/dist/{log-update-BldA9lkm.mjs → log-update-Dy1vPMGY.mjs} +185 -14
- package/dist/npm-VM_GgazT.mjs +2 -0
- package/dist/npm-VM_GgazT.mjs.map +1 -0
- package/dist/{semver-D8gwMSFO.mjs → semver-DFjVbN1S.mjs} +2 -2
- package/dist/semver-DFjVbN1S.mjs.map +1 -0
- package/dist/source-CwLcYLzI.mjs +7 -0
- package/dist/source-CwLcYLzI.mjs.map +1 -0
- package/dist/{wrap-ansi-DsMb4WnZ.mjs → wrap-ansi-9ugahFCy.mjs} +2 -2
- package/dist/wrap-ansi-9ugahFCy.mjs.map +1 -0
- package/dist/{wrap-ansi-CWIezXNl.mjs → wrap-ansi-BRr0GA6g.mjs} +5 -5
- package/dist/{wrap-ansi-T0rz0Urp.mjs → wrap-ansi-Cupoo4Yg.mjs} +5 -5
- package/dist/wrap-ansi-dwgEjNWf.mjs +2 -0
- package/dist/write-package-cxki9d3K.mjs +8 -0
- package/dist/write-package-cxki9d3K.mjs.map +1 -0
- package/dist/write-packages-CxCAl_AG.mjs +10 -0
- package/dist/write-packages-CxCAl_AG.mjs.map +1 -0
- package/package.json +9 -41
- package/.oxfmtrc.json +0 -11
- package/.yarn/install-state.gz +0 -0
- package/.yarn/releases/yarn-4.18.0.cjs +0 -1000
- package/.yarnrc.yml +0 -10
- package/bin/cm-checkfeatures.ts +0 -10
- package/bin/cm-clean.ts +0 -10
- package/bin/cm-config.ts +0 -10
- package/bin/cm-deploy.ts +0 -10
- package/bin/cm-expedit.ts +0 -19
- package/bin/cm-fetch.ts +0 -10
- package/bin/cm-finish.ts +0 -10
- package/bin/cm-jira-releases.ts +0 -10
- package/bin/cm-merge.ts +0 -10
- package/bin/cm-publish.ts +0 -10
- package/bin/cm-pull.ts +0 -8
- package/bin/cm-push.ts +0 -10
- package/bin/cm-rebase.ts +0 -10
- package/bin/cm-release.ts +0 -5
- package/bin/cm-republish.ts +0 -10
- package/bin/cm-start.ts +0 -10
- package/bin/cm.ts +0 -40
- package/dist/cli-truncate-DbOyuy2e.mjs +0 -2
- package/dist/cli-truncate-DbOyuy2e.mjs.map +0 -1
- package/dist/common-CwPbT3So.mjs.map +0 -1
- package/dist/docker-clean-tags-Cd-E8IqJ.mjs +0 -2
- package/dist/docker-clean-tags-Cd-E8IqJ.mjs.map +0 -1
- package/dist/docker-publish-B0E0qYYB.mjs +0 -2
- package/dist/docker-publish-B0E0qYYB.mjs.map +0 -1
- package/dist/get-config-DoOyLztI.mjs +0 -41
- package/dist/get-config-DoOyLztI.mjs.map +0 -1
- package/dist/log-update-By8Z-mak.mjs +0 -6
- package/dist/log-update-By8Z-mak.mjs.map +0 -1
- package/dist/semver-D8gwMSFO.mjs.map +0 -1
- package/dist/src/index.mjs +0 -18
- package/dist/src/index.mjs.map +0 -1
- package/dist/src/semantic/core/analyze-commits.mjs +0 -2
- package/dist/src/semantic/core/analyze-commits.mjs.map +0 -1
- package/dist/src/semantic/core/conditional.mjs +0 -2
- package/dist/src/semantic/core/conditional.mjs.map +0 -1
- package/dist/src/semantic/core/exit.mjs +0 -2
- package/dist/src/semantic/core/exit.mjs.map +0 -1
- package/dist/src/semantic/core/prepare/bump-version.mjs +0 -48
- package/dist/src/semantic/core/prepare/bump-version.mjs.map +0 -1
- package/dist/src/semantic/core/prepare/commit.mjs +0 -2
- package/dist/src/semantic/core/prepare/commit.mjs.map +0 -1
- package/dist/src/semantic/core/prepare/release-info.mjs +0 -2
- package/dist/src/semantic/core/prepare/release-info.mjs.map +0 -1
- package/dist/src/semantic/core/run.mjs +0 -2
- package/dist/src/semantic/core/run.mjs.map +0 -1
- package/dist/src/semantic/core/sync-repository.mjs +0 -2
- package/dist/src/semantic/core/sync-repository.mjs.map +0 -1
- package/dist/src/semantic/core/verify-conditions.mjs +0 -2
- package/dist/src/semantic/core/verify-conditions.mjs.map +0 -1
- package/dist/src/semantic/core/verify-release.mjs +0 -2
- package/dist/src/semantic/core/verify-release.mjs.map +0 -1
- package/dist/src/semantic/docker/publish.mjs +0 -2
- package/dist/src/semantic/docker/publish.mjs.map +0 -1
- package/dist/src/semantic/docker/success.mjs +0 -2
- package/dist/src/semantic/docker/success.mjs.map +0 -1
- package/dist/strip-ansi-Aeu5cmZe.mjs +0 -174
- package/dist/strip-ansi-Cl0pRo-s.mjs +0 -2
- package/dist/strip-ansi-Cl0pRo-s.mjs.map +0 -1
- package/dist/wrap-ansi-BeIjar2W.mjs +0 -2
- package/dist/wrap-ansi-DsMb4WnZ.mjs.map +0 -1
- package/mise.toml +0 -2
- package/oxlint.json +0 -25
- package/release.config.mjs +0 -39
- package/src/commands/checkfeatures.ts +0 -39
- package/src/commands/clean.ts +0 -36
- package/src/commands/config.ts +0 -31
- package/src/commands/deploy.ts +0 -39
- package/src/commands/fetch.ts +0 -30
- package/src/commands/finish.ts +0 -50
- package/src/commands/index.ts +0 -13
- package/src/commands/jira-releases.ts +0 -97
- package/src/commands/merge.ts +0 -58
- package/src/commands/prompts/branches.ts +0 -46
- package/src/commands/pull.ts +0 -44
- package/src/commands/push.ts +0 -48
- package/src/commands/rebase.ts +0 -56
- package/src/commands/release.ts +0 -21
- package/src/commands/republish.ts +0 -34
- package/src/commands/start.ts +0 -123
- package/src/commands/tasks/merge-branch.ts +0 -80
- package/src/commands/tasks/push-branch.ts +0 -19
- package/src/commands/tasks/rebase-all-branches.ts +0 -37
- package/src/commands/tasks/refresh-repository.ts +0 -38
- package/src/commands/tasks/run-test.ts +0 -28
- package/src/commands/tasks/update-branch.ts +0 -49
- package/src/commands/tasks/update-dependencies.ts +0 -43
- package/src/commands/utils/check-install.ts +0 -31
- package/src/common/back/directus/directus-flow.test.ts +0 -63
- package/src/common/back/directus/directus-flow.ts +0 -48
- package/src/common/back/http/http-proxy.ts +0 -21
- package/src/common/back/http/http-request.spec.ts +0 -50
- package/src/common/back/http/http-request.ts +0 -74
- package/src/common/back/jira/get-sorted-releases.ts +0 -40
- package/src/common/back/jira/interfaces/JiraIIssue.d.ts +0 -100
- package/src/common/back/jira/jira-releases.ts +0 -47
- package/src/common/back/jira/jira-request.spec.ts +0 -59
- package/src/common/back/jira/jira-request.ts +0 -29
- package/src/common/back/jira/jira-search.spec.ts +0 -44
- package/src/common/back/jira/jira-search.ts +0 -17
- package/src/common/cli/bun.test.ts +0 -58
- package/src/common/cli/bun.ts +0 -33
- package/src/common/cli/cli.ts +0 -127
- package/src/common/cli/docker.test.ts +0 -141
- package/src/common/cli/docker.ts +0 -66
- package/src/common/cli/git.test.ts +0 -215
- package/src/common/cli/git.ts +0 -121
- package/src/common/cli/lerna.test.ts +0 -58
- package/src/common/cli/lerna.ts +0 -25
- package/src/common/cli/npm.test.ts +0 -58
- package/src/common/cli/npm.ts +0 -33
- package/src/common/cli/pnpm.test.ts +0 -58
- package/src/common/cli/pnpm.ts +0 -34
- package/src/common/cli/yarn.test.ts +0 -58
- package/src/common/cli/yarn.ts +0 -33
- package/src/common/configure-git-workspace.ts +0 -39
- package/src/common/get-config.ts +0 -159
- package/src/common/get-package-json.ts +0 -15
- package/src/common/get-package-manager.ts +0 -13
- package/src/common/get-release-config.ts +0 -9
- package/src/common/index.ts +0 -14
- package/src/common/run-command.test.ts +0 -66
- package/src/common/run-command.ts +0 -67
- package/src/common/types.ts +0 -26
- package/src/common/vendor.d.ts +0 -4
- package/src/index.ts +0 -14
- package/src/semantic/core/analyze-commits.ts +0 -21
- package/src/semantic/core/conditional.ts +0 -62
- package/src/semantic/core/exit.ts +0 -15
- package/src/semantic/core/prepare/bump-version.ts +0 -41
- package/src/semantic/core/prepare/commit.ts +0 -30
- package/src/semantic/core/prepare/release-info.ts +0 -6
- package/src/semantic/core/run.ts +0 -23
- package/src/semantic/core/sync-repository.ts +0 -55
- package/src/semantic/core/verify-conditions.ts +0 -41
- package/src/semantic/core/verify-release.ts +0 -10
- package/src/semantic/define-config.ts +0 -42
- package/src/semantic/docker/publish.ts +0 -6
- package/src/semantic/docker/success.ts +0 -10
- package/src/semantic/utils/__mock__/test1/package.json +0 -7
- package/src/semantic/utils/__mock__/test1/packages/a/package.json +0 -9
- package/src/semantic/utils/__mock__/test1/packages/b/package.json +0 -7
- package/src/semantic/utils/__mock__/test2/package.json +0 -4
- package/src/semantic/utils/__mock__/test2/packages/a/package.json +0 -7
- package/src/semantic/utils/__mock__/test2/packages/b/package.json +0 -5
- package/src/semantic/utils/bump-packages-version.test.ts +0 -76
- package/src/semantic/utils/bump-packages-version.ts +0 -53
- package/src/semantic/utils/calculate-snapshot-version.test.ts +0 -69
- package/src/semantic/utils/calculate-snapshot-version.ts +0 -17
- package/src/semantic/utils/display-package-info.ts +0 -12
- package/src/semantic/utils/display-release-info.ts +0 -13
- package/src/semantic/utils/docker-clean-tags.test.ts +0 -62
- package/src/semantic/utils/docker-clean-tags.ts +0 -58
- package/src/semantic/utils/docker-publish.test.ts +0 -45
- package/src/semantic/utils/docker-publish.ts +0 -24
- package/src/semantic/utils/log-section.ts +0 -9
- package/src/semantic/utils/release-rules.ts +0 -15
- package/src/semantic/utils/transform-writer.ts +0 -101
- package/src/workflow/index.ts +0 -42
- package/tsconfig.build.json +0 -29
- package/tsconfig.json +0 -30
- package/tsdown.config.ts +0 -63
- package/vitest.config.mts +0 -9
package/src/common/cli/docker.ts
DELETED
|
@@ -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: string[]) {
|
|
11
|
-
return this.get("tag", ...args);
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
login(...args: string[]) {
|
|
15
|
-
return this.sync("login", ...args);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
push(...args: string[]) {
|
|
19
|
-
return this.run("push", ...args);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
async getToken(username: string, password: string) {
|
|
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 }: { token: string; repository: string }) {
|
|
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: string, { token, repository }: { token: string; repository: string }) {
|
|
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,215 +0,0 @@
|
|
|
1
|
-
import execa from "execa";
|
|
2
|
-
import { Cli } from "./cli.js";
|
|
3
|
-
import { git } from "./git.js";
|
|
4
|
-
|
|
5
|
-
vi.mock("execa", () => {
|
|
6
|
-
const sync = vi.fn();
|
|
7
|
-
const execaMock = Object.assign(vi.fn(), { sync });
|
|
8
|
-
return { default: execaMock };
|
|
9
|
-
});
|
|
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) => {
|
|
19
|
-
return {
|
|
20
|
-
stdout: `CMD: ${([] as unknown[]).concat(...(args as (string | string[])[]).filter((arg) => typeof arg === "string" || Array.isArray(arg))).join(" ")}`
|
|
21
|
-
};
|
|
22
|
-
});
|
|
23
|
-
execaMock.mockReturnValue({});
|
|
24
|
-
|
|
25
|
-
describe("GitCli", () => {
|
|
26
|
-
beforeEach(() => {
|
|
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(" ")}`;
|
|
29
|
-
});
|
|
30
|
-
});
|
|
31
|
-
describe("init", () => {
|
|
32
|
-
it("should run init cmd", () => {
|
|
33
|
-
const result = git.init("init-arg").sync();
|
|
34
|
-
|
|
35
|
-
expect(result.stdout).toEqual("CMD: git init init-arg");
|
|
36
|
-
expect(execa.sync).toHaveBeenCalledWith("git", ["init", "init-arg"], {
|
|
37
|
-
cwd: process.cwd(),
|
|
38
|
-
stdio: "inherit"
|
|
39
|
-
});
|
|
40
|
-
});
|
|
41
|
-
});
|
|
42
|
-
describe("add", () => {
|
|
43
|
-
it("should run add cmd", () => {
|
|
44
|
-
const result = git.add("add-arg").sync();
|
|
45
|
-
|
|
46
|
-
expect(result.stdout).toEqual("CMD: git add add-arg");
|
|
47
|
-
expect(execa.sync).toHaveBeenCalledWith("git", ["add", "add-arg"], {
|
|
48
|
-
cwd: process.cwd(),
|
|
49
|
-
stdio: "inherit"
|
|
50
|
-
});
|
|
51
|
-
});
|
|
52
|
-
});
|
|
53
|
-
describe("branch", () => {
|
|
54
|
-
it("should run branch cmd", () => {
|
|
55
|
-
const result = git.branch("branch-arg").sync();
|
|
56
|
-
|
|
57
|
-
expect(result.stdout).toEqual("CMD: git branch branch-arg");
|
|
58
|
-
expect(execa.sync).toHaveBeenCalledWith("git", ["branch", "branch-arg"], {
|
|
59
|
-
cwd: process.cwd(),
|
|
60
|
-
stdio: "inherit"
|
|
61
|
-
});
|
|
62
|
-
});
|
|
63
|
-
});
|
|
64
|
-
describe("clean", () => {
|
|
65
|
-
it("should run branch cmd", () => {
|
|
66
|
-
const result = git.clean("clean-arg").sync();
|
|
67
|
-
|
|
68
|
-
expect(result.stdout).toEqual("CMD: git clean clean-arg");
|
|
69
|
-
expect(execa.sync).toHaveBeenCalledWith("git", ["clean", "clean-arg"], {
|
|
70
|
-
cwd: process.cwd(),
|
|
71
|
-
stdio: "inherit"
|
|
72
|
-
});
|
|
73
|
-
});
|
|
74
|
-
});
|
|
75
|
-
describe("config", () => {
|
|
76
|
-
it("should run config cmd", () => {
|
|
77
|
-
const result = git.config("config-arg");
|
|
78
|
-
|
|
79
|
-
expect(result).toEqual("CMD: git config config-arg");
|
|
80
|
-
expect(Cli.getRaw).toHaveBeenCalledWith("git", ["config", "config-arg"], {
|
|
81
|
-
cwd: process.cwd()
|
|
82
|
-
});
|
|
83
|
-
});
|
|
84
|
-
});
|
|
85
|
-
describe("checkout", () => {
|
|
86
|
-
it("should run checkout cmd", () => {
|
|
87
|
-
const result = git.checkout("checkout-arg").sync();
|
|
88
|
-
|
|
89
|
-
expect(result.stdout).toEqual("CMD: git checkout checkout-arg");
|
|
90
|
-
expect(execa.sync).toHaveBeenCalledWith("git", ["checkout", "checkout-arg"], {
|
|
91
|
-
cwd: process.cwd(),
|
|
92
|
-
stdio: "inherit"
|
|
93
|
-
});
|
|
94
|
-
});
|
|
95
|
-
});
|
|
96
|
-
describe("commit", () => {
|
|
97
|
-
it("should run commit cmd", () => {
|
|
98
|
-
const result = git.commit("commit-arg").sync();
|
|
99
|
-
|
|
100
|
-
expect(result.stdout).toEqual("CMD: git commit commit-arg");
|
|
101
|
-
expect(execa.sync).toHaveBeenCalledWith("git", ["commit", "commit-arg"], {
|
|
102
|
-
cwd: process.cwd(),
|
|
103
|
-
stdio: "inherit"
|
|
104
|
-
});
|
|
105
|
-
});
|
|
106
|
-
});
|
|
107
|
-
describe("fetch", () => {
|
|
108
|
-
it("should run fetch cmd", () => {
|
|
109
|
-
const result = git.fetch("fetch-arg").sync();
|
|
110
|
-
|
|
111
|
-
expect(result.stdout).toEqual("CMD: git fetch fetch-arg");
|
|
112
|
-
expect(execa.sync).toHaveBeenCalledWith("git", ["fetch", "fetch-arg"], {
|
|
113
|
-
cwd: process.cwd(),
|
|
114
|
-
stdio: "inherit"
|
|
115
|
-
});
|
|
116
|
-
});
|
|
117
|
-
});
|
|
118
|
-
describe("prune", () => {
|
|
119
|
-
it("should run fetch cmd", () => {
|
|
120
|
-
const result = git.prune("prune-arg").sync();
|
|
121
|
-
|
|
122
|
-
expect(result.stdout).toEqual("CMD: git prune prune-arg");
|
|
123
|
-
expect(execa.sync).toHaveBeenCalledWith("git", ["prune", "prune-arg"], {
|
|
124
|
-
cwd: process.cwd(),
|
|
125
|
-
stdio: "inherit"
|
|
126
|
-
});
|
|
127
|
-
});
|
|
128
|
-
});
|
|
129
|
-
describe("merge", () => {
|
|
130
|
-
it("should run fetch cmd", () => {
|
|
131
|
-
const result = git.merge("merge-arg");
|
|
132
|
-
|
|
133
|
-
expect(result.stdout).toEqual("CMD: git merge merge-arg");
|
|
134
|
-
expect(execa.sync).toHaveBeenCalledWith("git", ["merge", "merge-arg"], {
|
|
135
|
-
cwd: process.cwd(),
|
|
136
|
-
stdio: "inherit"
|
|
137
|
-
});
|
|
138
|
-
});
|
|
139
|
-
});
|
|
140
|
-
describe("reset", () => {
|
|
141
|
-
it("should run reset cmd", () => {
|
|
142
|
-
const result = git.reset("reset-arg");
|
|
143
|
-
|
|
144
|
-
expect(result.stdout).toEqual("CMD: git reset reset-arg");
|
|
145
|
-
expect(execa.sync).toHaveBeenCalledWith("git", ["reset", "reset-arg"], {
|
|
146
|
-
cwd: process.cwd(),
|
|
147
|
-
stdio: "inherit"
|
|
148
|
-
});
|
|
149
|
-
});
|
|
150
|
-
});
|
|
151
|
-
describe("remote", () => {
|
|
152
|
-
it("should run remote cmd", () => {
|
|
153
|
-
const result = git.remote("remote-arg").sync();
|
|
154
|
-
|
|
155
|
-
expect(result.stdout).toEqual("CMD: git remote remote-arg");
|
|
156
|
-
expect(execa.sync).toHaveBeenCalledWith("git", ["remote", "remote-arg"], {
|
|
157
|
-
cwd: process.cwd(),
|
|
158
|
-
stdio: "inherit"
|
|
159
|
-
});
|
|
160
|
-
});
|
|
161
|
-
});
|
|
162
|
-
describe("rebase", () => {
|
|
163
|
-
it("should run rebase cmd", () => {
|
|
164
|
-
const result = git.rebase("rebase-arg").sync();
|
|
165
|
-
|
|
166
|
-
expect(result.stdout).toEqual("CMD: git rebase rebase-arg");
|
|
167
|
-
expect(execa.sync).toHaveBeenCalledWith("git", ["rebase", "rebase-arg"], {
|
|
168
|
-
cwd: process.cwd(),
|
|
169
|
-
stdio: "inherit"
|
|
170
|
-
});
|
|
171
|
-
});
|
|
172
|
-
});
|
|
173
|
-
describe("status", () => {
|
|
174
|
-
it("should run status cmd", () => {
|
|
175
|
-
const result = git.status("status-arg");
|
|
176
|
-
|
|
177
|
-
expect(result.stdout).toEqual("CMD: git status status-arg");
|
|
178
|
-
expect(execa.sync).toHaveBeenCalledWith("git", ["status", "status-arg"], {
|
|
179
|
-
cwd: process.cwd(),
|
|
180
|
-
stdio: "inherit"
|
|
181
|
-
});
|
|
182
|
-
});
|
|
183
|
-
});
|
|
184
|
-
describe("getCommitTag", () => {
|
|
185
|
-
it("should run revParse cmd", () => {
|
|
186
|
-
const result = git.getCommitTag("ref");
|
|
187
|
-
|
|
188
|
-
expect(result).toEqual("CMD: git rev-parse --short ref");
|
|
189
|
-
});
|
|
190
|
-
});
|
|
191
|
-
describe("getBranchName", () => {
|
|
192
|
-
it("should run revParse cmd", () => {
|
|
193
|
-
const result = git.getBranchName("ref");
|
|
194
|
-
|
|
195
|
-
expect(result).toEqual("CMD: git rev-parse --abbrev-ref ref");
|
|
196
|
-
});
|
|
197
|
-
});
|
|
198
|
-
describe("getLastCommitMsg", () => {
|
|
199
|
-
it("should run revParse cmd", () => {
|
|
200
|
-
const result = git.getLastCommitMsg();
|
|
201
|
-
|
|
202
|
-
expect(result).toEqual("CMD: git log -1 --pretty=%B");
|
|
203
|
-
});
|
|
204
|
-
});
|
|
205
|
-
describe("push", () => {
|
|
206
|
-
it("should run push cmd", async () => {
|
|
207
|
-
await git.push("push-arg");
|
|
208
|
-
|
|
209
|
-
expect(execa).toHaveBeenCalledWith("git", ["push", "push-arg"], {
|
|
210
|
-
cwd: process.cwd(),
|
|
211
|
-
stdio: "inherit"
|
|
212
|
-
});
|
|
213
|
-
});
|
|
214
|
-
});
|
|
215
|
-
});
|
package/src/common/cli/git.ts
DELETED
|
@@ -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: string[]) {
|
|
9
|
-
return this.run("init", ...args);
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
add(...args: string[]) {
|
|
13
|
-
return this.run("add", ...args);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
status(...args: string[]) {
|
|
17
|
-
return this.sync("status", ...args);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
branch(...args: string[]) {
|
|
21
|
-
return this.run("branch", ...args);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
clean(...args: string[]) {
|
|
25
|
-
return this.run("clean", ...args);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
config(...args: string[]) {
|
|
29
|
-
return this.run("config", ...args).get();
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
checkout(...args: string[]) {
|
|
33
|
-
return this.run("checkout", ...args);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
commit(...args: string[]) {
|
|
37
|
-
return this.run("commit", ...args);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
fetch(...args: string[]) {
|
|
41
|
-
return this.run("fetch", ...args);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
prune(...args: string[]) {
|
|
45
|
-
return this.run("prune", ...args);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
merge(...args: string[]) {
|
|
49
|
-
return this.sync("merge", ...args);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
reset(...args: string[]) {
|
|
53
|
-
return this.sync("reset", ...args);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
remote(...args: string[]) {
|
|
57
|
-
return this.run("remote", ...args);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
rebase(...args: string[]) {
|
|
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: string[]) {
|
|
77
|
-
return this.run("push", ...args);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
branchExists(branch: string, origin = "origin") {
|
|
81
|
-
return this.run("branch", "-a").getRaw().trim().includes(`remotes/${origin}/${branch}`);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
checkBranchRemoteStatus(branch: string, origin = "origin") {
|
|
85
|
-
return this.run("cherry", branch, `${origin}/${branch}`).get();
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
branches(...args: string[]) {
|
|
89
|
-
return this.run("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: string) {
|
|
98
|
-
return this.run("show", '--format="%ci|%cr|%an"', branch, "--").getRaw().split("\n")[0].trim();
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
branchesInfos(...args: string[]) {
|
|
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 is { branch: string; date: string; creation: string; author: string } => !!b)
|
|
117
|
-
.sort((info1, info2) => (info1.date < info2.date ? 1 : -1));
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
export const git = new GitCli();
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import execa from "execa";
|
|
2
|
-
import { lerna } from "./lerna.js";
|
|
3
|
-
import { Cli } from "./cli.js";
|
|
4
|
-
|
|
5
|
-
vi.mock("execa", () => {
|
|
6
|
-
const sync = vi.fn();
|
|
7
|
-
const execaMock = Object.assign(vi.fn(), { sync });
|
|
8
|
-
return { default: execaMock };
|
|
9
|
-
});
|
|
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) => {
|
|
19
|
-
return {
|
|
20
|
-
stdout: `CMD: ${([] as unknown[]).concat(...(args as (string | string[])[]).filter((arg) => typeof arg === "string" || Array.isArray(arg))).join(" ")}`
|
|
21
|
-
};
|
|
22
|
-
});
|
|
23
|
-
execaMock.mockReturnValue({});
|
|
24
|
-
|
|
25
|
-
describe("LernaCli", () => {
|
|
26
|
-
beforeEach(() => {
|
|
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(" ")}`;
|
|
29
|
-
});
|
|
30
|
-
});
|
|
31
|
-
describe("newVersion", () => {
|
|
32
|
-
it("should run add cmd", () => {
|
|
33
|
-
const result = lerna.newVersion("1.0.0");
|
|
34
|
-
|
|
35
|
-
expect(result.stdout).toEqual("CMD: lerna version 1.0.0 --exact --yes --no-git-tag-version --no-push");
|
|
36
|
-
});
|
|
37
|
-
});
|
|
38
|
-
describe("run", () => {
|
|
39
|
-
it('should run "run" cmd', async () => {
|
|
40
|
-
await lerna.run("run-arg");
|
|
41
|
-
|
|
42
|
-
expect(execa).toHaveBeenCalledWith("lerna", ["run", "run-arg"], {
|
|
43
|
-
cwd: process.cwd(),
|
|
44
|
-
stdio: "inherit"
|
|
45
|
-
});
|
|
46
|
-
});
|
|
47
|
-
});
|
|
48
|
-
describe("install", () => {
|
|
49
|
-
it('should run "install" cmd', async () => {
|
|
50
|
-
await lerna.install("install-arg");
|
|
51
|
-
|
|
52
|
-
expect(execa).toHaveBeenCalledWith("lerna", ["install", "install-arg"], {
|
|
53
|
-
cwd: process.cwd(),
|
|
54
|
-
stdio: "inherit"
|
|
55
|
-
});
|
|
56
|
-
});
|
|
57
|
-
});
|
|
58
|
-
});
|
package/src/common/cli/lerna.ts
DELETED
|
@@ -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: string) {
|
|
9
|
-
return this.version(version, "--exact", "--yes", "--no-git-tag-version", "--no-push");
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
version(...args: string[]) {
|
|
13
|
-
return this.sync("version", ...args);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
run(...args: string[]) {
|
|
17
|
-
return super.run("run", ...args);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
install(...args: string[]) {
|
|
21
|
-
return super.run("install", ...args);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export const lerna = new LernaCli();
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import execa from "execa";
|
|
2
|
-
import { npm } from "./npm.js";
|
|
3
|
-
import { Cli } from "./cli.js";
|
|
4
|
-
|
|
5
|
-
vi.mock("execa", () => {
|
|
6
|
-
const sync = vi.fn();
|
|
7
|
-
const execaMock = Object.assign(vi.fn(), { sync });
|
|
8
|
-
return { default: execaMock };
|
|
9
|
-
});
|
|
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) => {
|
|
19
|
-
return {
|
|
20
|
-
stdout: `CMD: ${([] as unknown[]).concat(...(args as (string | string[])[]).filter((arg) => typeof arg === "string" || Array.isArray(arg))).join(" ")}`
|
|
21
|
-
};
|
|
22
|
-
});
|
|
23
|
-
execaMock.mockReturnValue({});
|
|
24
|
-
|
|
25
|
-
describe("NpmCli", () => {
|
|
26
|
-
beforeEach(() => {
|
|
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(" ")}`;
|
|
29
|
-
});
|
|
30
|
-
});
|
|
31
|
-
describe("newVersion", () => {
|
|
32
|
-
it("should run newVersion cmd", () => {
|
|
33
|
-
const result = npm.newVersion("1.0.0");
|
|
34
|
-
|
|
35
|
-
expect(result.stdout).toEqual("CMD: npm version --no-git-tag-version 1.0.0");
|
|
36
|
-
});
|
|
37
|
-
});
|
|
38
|
-
describe("run", () => {
|
|
39
|
-
it('should run "run" cmd', async () => {
|
|
40
|
-
await npm.run("run-arg");
|
|
41
|
-
|
|
42
|
-
expect(execa).toHaveBeenCalledWith("npm", ["run", "run-arg"], {
|
|
43
|
-
cwd: process.cwd(),
|
|
44
|
-
stdio: "inherit"
|
|
45
|
-
});
|
|
46
|
-
});
|
|
47
|
-
});
|
|
48
|
-
describe("install", () => {
|
|
49
|
-
it('should run "install" cmd', async () => {
|
|
50
|
-
await npm.install("install-arg");
|
|
51
|
-
|
|
52
|
-
expect(execa).toHaveBeenCalledWith("npm", ["install", "install-arg"], {
|
|
53
|
-
cwd: process.cwd(),
|
|
54
|
-
stdio: "inherit"
|
|
55
|
-
});
|
|
56
|
-
});
|
|
57
|
-
});
|
|
58
|
-
});
|
package/src/common/cli/npm.ts
DELETED
|
@@ -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: string) {
|
|
9
|
-
return this.version("--no-git-tag-version", version);
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
version(...args: string[]) {
|
|
13
|
-
return this.sync("version", ...args);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
run(...args: string[]) {
|
|
17
|
-
return super.run("run", ...args);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
install(...args: string[]) {
|
|
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,58 +0,0 @@
|
|
|
1
|
-
import execa from "execa";
|
|
2
|
-
import { pnpm } from "./pnpm.js";
|
|
3
|
-
import { Cli } from "./cli.js";
|
|
4
|
-
|
|
5
|
-
vi.mock("execa", () => {
|
|
6
|
-
const sync = vi.fn();
|
|
7
|
-
const execaMock = Object.assign(vi.fn(), { sync });
|
|
8
|
-
return { default: execaMock };
|
|
9
|
-
});
|
|
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) => {
|
|
19
|
-
return {
|
|
20
|
-
stdout: `CMD: ${([] as unknown[]).concat(...(args as (string | string[])[]).filter((arg) => typeof arg === "string" || Array.isArray(arg))).join(" ")}`
|
|
21
|
-
};
|
|
22
|
-
});
|
|
23
|
-
execaMock.mockReturnValue({});
|
|
24
|
-
|
|
25
|
-
describe("PnpmCli", () => {
|
|
26
|
-
beforeEach(() => {
|
|
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(" ")}`;
|
|
29
|
-
});
|
|
30
|
-
});
|
|
31
|
-
describe("newVersion", () => {
|
|
32
|
-
it("should run newVersion cmd", () => {
|
|
33
|
-
const result = pnpm.newVersion("1.0.0");
|
|
34
|
-
|
|
35
|
-
expect(result.stdout).toEqual("CMD: pnpm version --no-git-tag-version 1.0.0");
|
|
36
|
-
});
|
|
37
|
-
});
|
|
38
|
-
describe("run", () => {
|
|
39
|
-
it('should run "run" cmd', async () => {
|
|
40
|
-
await pnpm.run("run-arg");
|
|
41
|
-
|
|
42
|
-
expect(execa).toHaveBeenCalledWith("pnpm", ["run", "run-arg"], {
|
|
43
|
-
cwd: process.cwd(),
|
|
44
|
-
stdio: "inherit"
|
|
45
|
-
});
|
|
46
|
-
});
|
|
47
|
-
});
|
|
48
|
-
describe("install", () => {
|
|
49
|
-
it('should run "install" cmd', async () => {
|
|
50
|
-
await pnpm.install("install-arg");
|
|
51
|
-
|
|
52
|
-
expect(execa).toHaveBeenCalledWith("pnpm", ["install", "install-arg"], {
|
|
53
|
-
cwd: process.cwd(),
|
|
54
|
-
stdio: "inherit"
|
|
55
|
-
});
|
|
56
|
-
});
|
|
57
|
-
});
|
|
58
|
-
});
|
package/src/common/cli/pnpm.ts
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { Cli } from "./cli.js";
|
|
2
|
-
|
|
3
|
-
class PnpmCli extends Cli {
|
|
4
|
-
constructor() {
|
|
5
|
-
super("pnpm");
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
newVersion(version: string) {
|
|
9
|
-
// pnpm follows npm's version CLI semantics
|
|
10
|
-
return this.version("--no-git-tag-version", version);
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
version(...args: string[]) {
|
|
14
|
-
return this.sync("version", ...args);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
run(...args: string[]) {
|
|
18
|
-
return super.run("run", ...args);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
install(...args: string[]) {
|
|
22
|
-
return super.run("install", ...args);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Reinstall dependencies without pnpm-lock.yaml mutation
|
|
27
|
-
* @returns {Promise<unknown>}
|
|
28
|
-
*/
|
|
29
|
-
restore() {
|
|
30
|
-
return super.run("install", "--frozen-lockfile");
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export const pnpm = new PnpmCli();
|