@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,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) {
9
- // pnpm follows npm's version CLI semantics
10
- return this.version("--no-git-tag-version", version);
11
- }
12
-
13
- version(...args) {
14
- return this.sync("version", ...args);
15
- }
16
-
17
- run(...args) {
18
- return super.run("run", ...args);
19
- }
20
-
21
- install(...args) {
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();
@@ -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 { pnpm } = await import("./pnpm.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("PnpmCli", () => {
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 = pnpm.newVersion("1.0.0");
27
-
28
- expect(result.stdout).toEqual("CMD: pnpm version --no-git-tag-version 1.0.0");
29
- });
30
- });
31
- describe("run", () => {
32
- it('should run "run" cmd', async () => {
33
- await pnpm.run("run-arg");
34
-
35
- expect(execa).toHaveBeenCalledWith("pnpm", ["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 pnpm.install("install-arg");
44
-
45
- expect(execa).toHaveBeenCalledWith("pnpm", ["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 YarnCli extends Cli {
4
- constructor() {
5
- super("yarn");
6
- }
7
-
8
- newVersion(version) {
9
- return this.version("--no-git-tag-version", "--new-version", version);
10
- }
11
-
12
- version(...args) {
13
- return this.sync("version", ...args);
14
- }
15
-
16
- run(...args) {
17
- return super.run(...args);
18
- }
19
-
20
- install(...args) {
21
- return super.run("install", ...args);
22
- }
23
-
24
- /**
25
- * Reinstall dependencies without yarn.lock mutation
26
- * @returns {Promise<unknown>}
27
- */
28
- restore() {
29
- return super.run("install", "--immutable");
30
- }
31
- }
32
-
33
- export const yarn = new YarnCli();
@@ -1,53 +0,0 @@
1
- vi.mock("execa", () => {
2
- const execaMock = vi.fn();
3
- execaMock.sync = vi.fn();
4
-
5
- return { default: execaMock };
6
- });
7
-
8
- const { default: execa } = await import("execa");
9
- const { yarn } = await import("./yarn.js");
10
- const { Cli } = await import("./cli.js");
11
-
12
- execa.sync.mockImplementation((...args) => {
13
- return {
14
- stdout: `CMD: ${[].concat(...args.filter((arg) => typeof arg === "string" || Array.isArray(arg))).join(" ")}`
15
- };
16
- });
17
-
18
- execa.mockReturnValue({});
19
-
20
- describe("YarnCli", () => {
21
- beforeEach(() => {
22
- vi.spyOn(Cli, "getRaw").mockImplementation((...args) => {
23
- return `CMD: ${[].concat(...args.filter((arg) => typeof arg === "string" || Array.isArray(arg))).join(" ")}`;
24
- });
25
- });
26
- describe("newVersion", () => {
27
- it("should run newVersion cmd", () => {
28
- const result = yarn.newVersion("1.0.0");
29
-
30
- expect(result.stdout).toEqual("CMD: yarn version --no-git-tag-version --new-version 1.0.0");
31
- });
32
- });
33
- describe("run", () => {
34
- it('should run "run" cmd', async () => {
35
- await yarn.run("run-arg");
36
-
37
- expect(execa).toHaveBeenCalledWith("yarn", ["run-arg"], {
38
- cwd: process.cwd(),
39
- stdio: "inherit"
40
- });
41
- });
42
- });
43
- describe("install", () => {
44
- it('should run "install" cmd', async () => {
45
- await yarn.install("install-arg");
46
-
47
- expect(execa).toHaveBeenCalledWith("yarn", ["install", "install-arg"], {
48
- cwd: process.cwd(),
49
- stdio: "inherit"
50
- });
51
- });
52
- });
53
- });
@@ -1,26 +0,0 @@
1
- import { git } from "./cli/git.js";
2
-
3
- export function configureGitWorkspace(context) {
4
- const {
5
- logger,
6
- config: { SCM_TOKEN, REPOSITORY_URL, ORIGIN, GIT_USER_NAME, GIT_USER_EMAIL, GIT_DISABLE_SSL }
7
- } = context;
8
-
9
- if (GIT_USER_NAME && GIT_USER_EMAIL) {
10
- git.config("--global", "user.name", `"${GIT_USER_NAME}"`);
11
- git.config("--global", "user.email", `"${GIT_USER_EMAIL}"`);
12
- }
13
-
14
- if (GIT_DISABLE_SSL) {
15
- logger.info("Disable SSL verification");
16
- git.config("--global", "http.sslVerify", "false");
17
- }
18
-
19
- if (SCM_TOKEN) {
20
- const repository = REPOSITORY_URL.replace("https://", "");
21
-
22
- logger.info(`Configure remote repository ${repository}`);
23
- git.remote("remove", ORIGIN).sync();
24
- git.remote("add", ORIGIN, `https://${SCM_TOKEN}@${repository}`).sync();
25
- }
26
- }
@@ -1,157 +0,0 @@
1
- import fs from "node:fs";
2
- import { join } from "node:path";
3
-
4
- import hasYarn from "has-yarn";
5
- import get from "lodash/get.js";
6
-
7
- import { git } from "./cli/git.js";
8
- import { getPackageJson } from "./get-package-json.js";
9
-
10
- export function getCI() {
11
- const { env } = process;
12
- const { GIT_USER_NAME, GIT_USER_EMAIL } = env;
13
- if (env.CI) {
14
- if (env.GITLAB_CI) {
15
- const { CI_BUILD_ID, CI_JOB_ID, CI_COMMIT_SHA, CI_COMMIT_BRANCH } = env;
16
-
17
- return {
18
- CI_NAME: "GitLab CI",
19
- USER: GIT_USER_NAME || "GitLab CI",
20
- EMAIL: GIT_USER_EMAIL || "gitlab@gitlab.com",
21
- BUILD_NUMBER: CI_BUILD_ID || CI_JOB_ID,
22
- CI_ORIGIN: "origin-git",
23
- REF_COMMIT: CI_COMMIT_SHA,
24
- IS_PULL_REQUEST: false,
25
- BRANCH_NAME: CI_COMMIT_BRANCH
26
- };
27
- }
28
-
29
- if (env.CIRCLECI) {
30
- const { CIRCLE_BUILD_NUM, CIRCLE_SHA1, CIRCLE_PULL_REQUEST, CIRCLE_BRANCH } = env;
31
- return {
32
- CI_NAME: "Circle CI",
33
- USER: GIT_USER_NAME || "Circle CI",
34
- EMAIL: GIT_USER_EMAIL || "circle@circleci.com",
35
- BUILD_NUMBER: CIRCLE_BUILD_NUM,
36
- CI_ORIGIN: "origin-git",
37
- REF_COMMIT: CIRCLE_SHA1,
38
- IS_PULL_REQUEST: CIRCLE_PULL_REQUEST && CIRCLE_PULL_REQUEST !== "false",
39
- BRANCH_NAME: CIRCLE_BRANCH
40
- };
41
- }
42
-
43
- if (env.GITHUB_ACTION) {
44
- const { GITHUB_ACTION, GITHUB_SHA, GITHUB_REF, GITHUB_ACTOR } = env;
45
- return {
46
- CI_NAME: "Github CI",
47
- USER: GIT_USER_NAME || GITHUB_ACTOR || "Github CI",
48
- EMAIL: GIT_USER_EMAIL || "action@github.com",
49
- BUILD_NUMBER: GITHUB_ACTION,
50
- CI_ORIGIN: "origin-git",
51
- REF_COMMIT: GITHUB_SHA,
52
- IS_PULL_REQUEST: false,
53
- BRANCH_NAME: GITHUB_REF.replace("refs/heads/", "")
54
- };
55
- }
56
-
57
- return {
58
- NAME: "Unsupported CI",
59
- BUILD_NUMBER: "",
60
- CI_ORIGIN: "origin-git",
61
- IS_PULL_REQUEST: false,
62
- BRANCH_NAME: git.getBranchName()
63
- };
64
- }
65
- // / local
66
- return {
67
- NAME: "LOCAL",
68
- BUILD_NUMBER: "1",
69
- CI_ORIGIN: "origin-git",
70
- BRANCH_NAME: git.getBranchName()
71
- };
72
- }
73
-
74
- export function getConfig() {
75
- const pkg = getPackageJson();
76
- const [owner, projectName] = pkg.name.replace(/^@/, "").split("/");
77
- const {
78
- PROJECT_NAME,
79
- DOCKER_HUB_ID,
80
- DOCKER_HUB_PWD,
81
- REF_COMMIT,
82
- GH_TOKEN,
83
- SCM_TOKEN,
84
- REPOSITORY_URL,
85
- GIT_DISABLE_SSL,
86
- GIT_USER_NAME,
87
- GIT_USER_EMAIL,
88
- GITLAB_USER_EMAIL,
89
- GITLAB_USER_NAME,
90
- GIT_FETCH_MAX_DEPTH,
91
- JIRA_API,
92
- JIRA_EMAIL,
93
- JIRA_TOKEN,
94
- DIRECTUS_URL,
95
- DIRECTUS_FLOW_ID,
96
- DIRECTUS_ACCESS_TOKEN,
97
- HTTPS_PROXY
98
- } = process.env;
99
-
100
- const HAS_YARN = hasYarn();
101
- const HAS_PNPM = fs.existsSync(join(process.cwd(), "pnpm-lock.yaml"));
102
- const HAS_BUN = fs.existsSync(join(process.cwd(), "bun.lock")) || fs.existsSync(join(process.cwd(), "bun.lockb"));
103
- const IS_YARN_BERRY = HAS_YARN ? fs.existsSync(join(process.cwd(), ".yamlrc.yml")) : false;
104
- let BUMP_METHOD = get(pkg, "flow.bumpMethod", "default");
105
-
106
- if ((IS_YARN_BERRY || HAS_PNPM || HAS_BUN) && ["native", "default"].includes(BUMP_METHOD)) {
107
- BUMP_METHOD = "cmflow";
108
- }
109
-
110
- return {
111
- pkg,
112
- PACKAGE_MANAGER: HAS_PNPM ? "pnpm" : HAS_BUN ? "bun" : HAS_YARN ? "yarn" : "npm",
113
- PROJECT_NAME: PROJECT_NAME || projectName,
114
- HAS_YARN,
115
- HAS_PNPM,
116
- HAS_BUN,
117
- IS_YARN_BERRY,
118
- HAS_LERNA: (pkg.dependencies && pkg.dependencies.lerna) || (pkg.devDependencies && pkg.devDependencies.lerna),
119
- CI_SKIP: "[ci skip]",
120
- RELEASE_CANDIDATE_TAG: "[MEP]",
121
- ORIGIN: "origin",
122
- get PRODUCTION_BRANCH() {
123
- return get(pkg, "flow.branch.production") || process.env.PRODUCTION_BRANCH || "production";
124
- },
125
- get DEVELOP_BRANCH() {
126
- return get(pkg, "flow.branch.develop") || process.env.DEVELOP_BRANCH || "master";
127
- },
128
- get OWNER() {
129
- return process.env.OWNER || owner;
130
- },
131
- get DOCKER_REPOSITORY() {
132
- const { DOCKER_REPOSITORY, OWNER, PROJECT_NAME } = process.env;
133
- return DOCKER_REPOSITORY || `${OWNER || owner}/${PROJECT_NAME || projectName}`;
134
- },
135
- DOCKER_HUB_ID,
136
- DOCKER_HUB_PWD,
137
- REF_COMMIT,
138
- GH_TOKEN,
139
- SCM_TOKEN: GH_TOKEN || SCM_TOKEN,
140
- REPOSITORY_URL: get(pkg, "repository.url", get(pkg, "repository", REPOSITORY_URL)),
141
- GIT_USER_NAME: GIT_USER_NAME || GITLAB_USER_NAME,
142
- GIT_USER_EMAIL: GIT_USER_EMAIL || GITLAB_USER_EMAIL,
143
- GIT_FETCH_MAX_DEPTH,
144
- GIT_DISABLE_SSL,
145
- BUMP_METHOD,
146
- JIRA_API,
147
- JIRA_EMAIL,
148
- JIRA_TOKEN,
149
- HTTPS_PROXY,
150
- DIRECTUS_URL,
151
- DIRECTUS_FLOW_ID,
152
- DIRECTUS_ACCESS_TOKEN,
153
- CAN_TRIGGER_WORKFLOW: DIRECTUS_ACCESS_TOKEN && DIRECTUS_FLOW_ID && DIRECTUS_URL,
154
- WORKSPACES: pkg.workspaces || [],
155
- ...getCI()
156
- };
157
- }
@@ -1,14 +0,0 @@
1
- import fs from "fs";
2
-
3
- export function getPackageJson() {
4
- try {
5
- const content = fs.readFileSync(`${process.cwd()}/package.json`, { encoding: "utf8" });
6
-
7
- return JSON.parse(content);
8
- } catch (error) {
9
- console.error("Error while loading package.json", error);
10
- return {
11
- name: "@clubmed/root"
12
- };
13
- }
14
- }
@@ -1,12 +0,0 @@
1
- import { bun } from "./cli/bun.js";
2
- import { npm } from "./cli/npm.js";
3
- import { pnpm } from "./cli/pnpm.js";
4
- import { yarn } from "./cli/yarn.js";
5
-
6
- export function getPackageManager(pkgManager) {
7
- if (pkgManager === "bun") {
8
- return bun;
9
- }
10
-
11
- return pkgManager === "yarn" ? yarn : pkgManager === "pnpm" ? pnpm : npm;
12
- }
@@ -1,8 +0,0 @@
1
- export async function getReleaseConfig() {
2
- try {
3
- return await import(`${process.cwd()}/release.config.mjs`);
4
- } catch (er) {
5
- console.log("Error while loading release.config.mjs", er);
6
- return {};
7
- }
8
- }
@@ -1,13 +0,0 @@
1
- export * from "./cli/bun.js";
2
- export * from "./cli/cli.js";
3
- export * from "./cli/docker.js";
4
- export * from "./cli/git.js";
5
- export * from "./cli/lerna.js";
6
- export * from "./cli/npm.js";
7
- export * from "./cli/pnpm.js";
8
- export * from "./cli/yarn.js";
9
- export * from "./configure-git-workspace.js";
10
- export * from "./get-config.js";
11
- export * from "./get-package-json.js";
12
- export * from "./get-package-manager.js";
13
- export * from "./run-command.js";
@@ -1,64 +0,0 @@
1
- import chalk from "chalk";
2
- import figures from "figures";
3
- import inquirer from "inquirer";
4
- import Listr from "listr";
5
-
6
- import { getConfig } from "./get-config.js";
7
- import { getReleaseConfig } from "./get-release-config.js";
8
-
9
- function createTasksRunner(tasks, ctx) {
10
- return new Listr(tasks, {
11
- concurrent: false,
12
- renderer: !ctx.verbose ? "default" : "verbose"
13
- }).run(ctx);
14
- }
15
-
16
- export async function runCommand(klass, commander) {
17
- try {
18
- const config = getConfig();
19
- let context = {
20
- ...getReleaseConfig(),
21
- ...config,
22
- branch: { name: config.BRANCH_NAME },
23
- config,
24
- logger: console,
25
- verbose: commander.verbose
26
- };
27
-
28
- const command = new klass();
29
-
30
- // Map context from commander and current context
31
- if (command.mapContext) {
32
- context = command.mapContext(commander, context);
33
- }
34
-
35
- // show prompts
36
- if (command.prompt) {
37
- context = {
38
- ...context,
39
- ...(await inquirer.prompt(command.prompt(context)))
40
- };
41
- }
42
-
43
- // Verify conditions
44
- command.verifyConditions && command.verifyConditions(context);
45
-
46
- // Get tasks
47
- const tasks = command.getTasks(context);
48
-
49
- // Run tasks
50
- await createTasksRunner(tasks, context);
51
-
52
- command.success && command.success(context);
53
- } catch (er) {
54
- console.error(chalk.red(figures.cross + " " + String(er)));
55
- if (commander.verbose) {
56
- console.error(String(er.stack).replace(String(er), ""));
57
- }
58
- process.exit(-1);
59
- }
60
- }
61
-
62
- process.on("unhandledRejection", () => {
63
- // avoid extra promise rejection when using toObservable
64
- });
@@ -1,65 +0,0 @@
1
- vi.mock("listr", () => {
2
- return { default: vi.fn() };
3
- });
4
-
5
- const { default: Listr } = await import("listr");
6
- const { runCommand } = await import("./run-command.js");
7
-
8
- describe("runCommand", () => {
9
- beforeEach(() => {
10
- Listr.mockReturnValue({
11
- run() {}
12
- });
13
- });
14
- it("should call runCommand", async () => {
15
- class Cmd {
16
- mapContext(ctx) {
17
- return {
18
- ...ctx,
19
- test: true
20
- };
21
- }
22
-
23
- getTasks() {
24
- return [];
25
- }
26
- }
27
-
28
- vi.spyOn(Cmd.prototype, "mapContext");
29
- vi.spyOn(Cmd.prototype, "getTasks");
30
-
31
- await runCommand(Cmd, {
32
- prop: "1"
33
- });
34
-
35
- expect(Cmd.prototype.mapContext).toHaveBeenCalledWith({ prop: "1" }, expect.any(Object));
36
- expect(Cmd.prototype.getTasks).toHaveBeenCalledWith({
37
- prop: "1",
38
- test: true
39
- });
40
- });
41
- it("should call runCommand and catch error", async () => {
42
- class Cmd {
43
- mapContext(ctx) {
44
- return {
45
- ...ctx,
46
- test: true
47
- };
48
- }
49
-
50
- getTasks() {
51
- throw new Error("Error");
52
- }
53
- }
54
-
55
- vi.spyOn(console, "error").mockReturnValue(undefined);
56
- vi.spyOn(process, "exit").mockImplementation(() => {});
57
-
58
- await runCommand(Cmd, {
59
- prop: "1"
60
- });
61
-
62
- expect(console.error).toHaveBeenCalled();
63
- expect(process.exit).toHaveBeenCalledWith(-1);
64
- });
65
- });
package/src/index.js DELETED
@@ -1,10 +0,0 @@
1
- import * as commands from "./commands/index.js";
2
-
3
- export * from "./commands/release.js";
4
- export * from "./common/index.js";
5
- export * from "./semantic/define-config.js";
6
- export * from "./semantic/utils/release-rules.js";
7
- export * from "./semantic/utils/transform-writer.js";
8
- export * from "./workflow/index.js";
9
-
10
- export { commands };
@@ -1,17 +0,0 @@
1
- import * as commitAnalyzerPlugins from "@semantic-release/commit-analyzer";
2
-
3
- import { calculateSnapshotVersion } from "../utils/calculate-snapshot-version.js";
4
-
5
- export async function analyzeCommits(pluginConfig, context) {
6
- if (context.branch && context.branch.type !== "prerelease") {
7
- return commitAnalyzerPlugins.analyzeCommits(pluginConfig, context);
8
- }
9
-
10
- const analyzedCommits = await commitAnalyzerPlugins.analyzeCommits(pluginConfig, context);
11
- context.nextRelease = context.nextRelease || {};
12
- context.nextRelease.type = analyzedCommits;
13
- context.nextRelease.version = calculateSnapshotVersion(context);
14
- context.lastRelease.version = null;
15
-
16
- return "patch";
17
- }
@@ -1,55 +0,0 @@
1
- import { getConfig } from "../../common/index.js";
2
-
3
- export function prepare(pluginConfig, context) {
4
- return runAll("prepare", pluginConfig, context, context.branch?.type === "release");
5
- }
6
-
7
- export function success(pluginConfig, context) {
8
- return runAll("success", pluginConfig, context, context.branch?.type === "release");
9
- }
10
-
11
- export function publish(pluginConfig, context) {
12
- return runAll("publish", pluginConfig, context, context.branch?.type === "release");
13
- }
14
-
15
- export function generateNotes(pluginConfig, context) {
16
- return runAll("generateNotes", pluginConfig, context, context.branch?.type === "release");
17
- }
18
-
19
- export function fail(pluginConfig, context) {
20
- return runAll("fail", pluginConfig, context, context.branch?.type === "release");
21
- }
22
-
23
- async function runAll(step, pluginConfig, context, defaultCondition) {
24
- context.config = getConfig();
25
-
26
- const condition = pluginConfig.when !== undefined ? pluginConfig.when(context) : defaultCondition;
27
-
28
- if (!condition) {
29
- context.logger.info(`Skip step "${step}" of plugin(s) "${pluginConfig.run}"`);
30
- return;
31
- }
32
-
33
- if (pluginConfig.run) {
34
- const tasks = [].concat(pluginConfig.run);
35
-
36
- for (const task of tasks) {
37
- if (typeof task === "string") {
38
- const mod = await import(task);
39
- const taskFunction = mod[step];
40
-
41
- if (taskFunction) {
42
- context.logger.log(` Start conditional step "${step}" of plugin "${task}"`);
43
-
44
- try {
45
- await taskFunction(pluginConfig, context);
46
- context.logger.success(` Completed conditional step "${step}" of plugin "${task}"`);
47
- } catch (er) {
48
- context.logger.error(` Fail conditional step "${step}" of plugin "${task}"`);
49
- throw er;
50
- }
51
- }
52
- }
53
- }
54
- }
55
- }
@@ -1,14 +0,0 @@
1
- import { getConfig } from "../../common/index.js";
2
-
3
- export default async function exit(pluginConfig, context) {
4
- context.config = getConfig();
5
- const condition = pluginConfig.when !== undefined ? pluginConfig.when(context) : true;
6
-
7
- if (condition) {
8
- // avoid next semantic-release steps when is a prerelease or release branch with SKIP_GITHUB_PUBLISH
9
- context.logger.success("Skip next semantic-release steps");
10
- process.exit(0);
11
- } else {
12
- context.logger.success("Continue next semantic-release steps");
13
- }
14
- }
@@ -1,38 +0,0 @@
1
- import { getConfig, getPackageManager, lerna } from "../../../common/index.js";
2
- import { bumpPackagesVersion } from "../../utils/bump-packages-version.js";
3
-
4
- export async function prepare(_, context) {
5
- context.config = getConfig();
6
- const {
7
- config: { PACKAGE_MANAGER, HAS_LERNA, BUMP_METHOD, WORKSPACES },
8
- logger
9
- } = context;
10
- const versionPackageManager = PACKAGE_MANAGER === "yarn" ? "npm" : PACKAGE_MANAGER;
11
-
12
- logger.info(`Start bump version for all packages using method: ${BUMP_METHOD}`);
13
-
14
- switch (BUMP_METHOD) {
15
- case "native":
16
- logger.info("Using package manager");
17
- getPackageManager(PACKAGE_MANAGER).newVersion(context.nextRelease.version);
18
- break;
19
- case "lerna":
20
- if (HAS_LERNA) {
21
- await lerna.newVersion(context.nextRelease.version);
22
- }
23
- break;
24
- case "cmflow":
25
- await bumpPackagesVersion(context.nextRelease.version, WORKSPACES);
26
- await getPackageManager(PACKAGE_MANAGER).install();
27
- break;
28
- case "native:lerna":
29
- default:
30
- getPackageManager(versionPackageManager).newVersion(context.nextRelease.version);
31
-
32
- if (HAS_LERNA) {
33
- await lerna.newVersion(context.nextRelease.version);
34
- }
35
- }
36
-
37
- logger.info("Bump version finished with success...");
38
- }