@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.
Files changed (209) hide show
  1. package/README.md +110 -294
  2. package/dist/bin/cm.mjs +9985 -1348
  3. package/dist/bin/cmrelease.mjs +3875 -1193
  4. package/dist/{cli-truncate-CXNquMRK.mjs → cli-truncate-Bi2MjGwF.mjs} +177 -6
  5. package/dist/cli-truncate-DMcpM5Q7.mjs +2 -0
  6. package/dist/cli-truncate-DMcpM5Q7.mjs.map +1 -0
  7. package/dist/{cli-truncate-BmHD4ngn.mjs → cli-truncate-DsW0mgI_.mjs} +177 -6
  8. package/dist/{common-CwPbT3So.mjs → common-BdfXquG0.mjs} +31 -36
  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.map +1 -1
  23. package/dist/{get-east-asian-width-eFfEkHwo.mjs → get-east-asian-width-wiVWCFXf.mjs} +4 -4
  24. package/dist/log-update-CLbF3iV6.mjs +6 -0
  25. package/dist/log-update-CLbF3iV6.mjs.map +1 -0
  26. package/dist/{log-update-B2GqeeDd.mjs → log-update-CTXRtajW.mjs} +185 -14
  27. package/dist/{log-update-BldA9lkm.mjs → log-update-Dy1vPMGY.mjs} +185 -14
  28. package/dist/npm-VM_GgazT.mjs +2 -0
  29. package/dist/npm-VM_GgazT.mjs.map +1 -0
  30. package/dist/{semver-D8gwMSFO.mjs → semver-DFjVbN1S.mjs} +2 -2
  31. package/dist/semver-DFjVbN1S.mjs.map +1 -0
  32. package/dist/source-CwLcYLzI.mjs +7 -0
  33. package/dist/source-CwLcYLzI.mjs.map +1 -0
  34. package/dist/{wrap-ansi-DsMb4WnZ.mjs → wrap-ansi-9ugahFCy.mjs} +2 -2
  35. package/dist/wrap-ansi-9ugahFCy.mjs.map +1 -0
  36. package/dist/{wrap-ansi-CWIezXNl.mjs → wrap-ansi-BRr0GA6g.mjs} +5 -5
  37. package/dist/{wrap-ansi-T0rz0Urp.mjs → wrap-ansi-Cupoo4Yg.mjs} +5 -5
  38. package/dist/wrap-ansi-dwgEjNWf.mjs +2 -0
  39. package/dist/write-package-cxki9d3K.mjs +8 -0
  40. package/dist/write-package-cxki9d3K.mjs.map +1 -0
  41. package/dist/write-packages-CxCAl_AG.mjs +10 -0
  42. package/dist/write-packages-CxCAl_AG.mjs.map +1 -0
  43. package/package.json +9 -41
  44. package/.oxfmtrc.json +0 -11
  45. package/.yarn/install-state.gz +0 -0
  46. package/.yarn/releases/yarn-4.18.0.cjs +0 -1000
  47. package/.yarnrc.yml +0 -10
  48. package/bin/cm-checkfeatures.ts +0 -10
  49. package/bin/cm-clean.ts +0 -10
  50. package/bin/cm-config.ts +0 -10
  51. package/bin/cm-deploy.ts +0 -10
  52. package/bin/cm-expedit.ts +0 -19
  53. package/bin/cm-fetch.ts +0 -10
  54. package/bin/cm-finish.ts +0 -10
  55. package/bin/cm-jira-releases.ts +0 -10
  56. package/bin/cm-merge.ts +0 -10
  57. package/bin/cm-publish.ts +0 -10
  58. package/bin/cm-pull.ts +0 -8
  59. package/bin/cm-push.ts +0 -10
  60. package/bin/cm-rebase.ts +0 -10
  61. package/bin/cm-release.ts +0 -5
  62. package/bin/cm-republish.ts +0 -10
  63. package/bin/cm-start.ts +0 -10
  64. package/bin/cm.ts +0 -40
  65. package/dist/cli-truncate-DbOyuy2e.mjs +0 -2
  66. package/dist/cli-truncate-DbOyuy2e.mjs.map +0 -1
  67. package/dist/common-CwPbT3So.mjs.map +0 -1
  68. package/dist/docker-clean-tags-Cd-E8IqJ.mjs +0 -2
  69. package/dist/docker-clean-tags-Cd-E8IqJ.mjs.map +0 -1
  70. package/dist/docker-publish-B0E0qYYB.mjs +0 -2
  71. package/dist/docker-publish-B0E0qYYB.mjs.map +0 -1
  72. package/dist/get-config-DoOyLztI.mjs +0 -41
  73. package/dist/get-config-DoOyLztI.mjs.map +0 -1
  74. package/dist/log-update-By8Z-mak.mjs +0 -6
  75. package/dist/log-update-By8Z-mak.mjs.map +0 -1
  76. package/dist/semver-D8gwMSFO.mjs.map +0 -1
  77. package/dist/src/index.mjs +0 -18
  78. package/dist/src/index.mjs.map +0 -1
  79. package/dist/src/semantic/core/analyze-commits.mjs +0 -2
  80. package/dist/src/semantic/core/analyze-commits.mjs.map +0 -1
  81. package/dist/src/semantic/core/conditional.mjs +0 -2
  82. package/dist/src/semantic/core/conditional.mjs.map +0 -1
  83. package/dist/src/semantic/core/exit.mjs +0 -2
  84. package/dist/src/semantic/core/exit.mjs.map +0 -1
  85. package/dist/src/semantic/core/prepare/bump-version.mjs +0 -48
  86. package/dist/src/semantic/core/prepare/bump-version.mjs.map +0 -1
  87. package/dist/src/semantic/core/prepare/commit.mjs +0 -2
  88. package/dist/src/semantic/core/prepare/commit.mjs.map +0 -1
  89. package/dist/src/semantic/core/prepare/release-info.mjs +0 -2
  90. package/dist/src/semantic/core/prepare/release-info.mjs.map +0 -1
  91. package/dist/src/semantic/core/run.mjs +0 -2
  92. package/dist/src/semantic/core/run.mjs.map +0 -1
  93. package/dist/src/semantic/core/sync-repository.mjs +0 -2
  94. package/dist/src/semantic/core/sync-repository.mjs.map +0 -1
  95. package/dist/src/semantic/core/verify-conditions.mjs +0 -2
  96. package/dist/src/semantic/core/verify-conditions.mjs.map +0 -1
  97. package/dist/src/semantic/core/verify-release.mjs +0 -2
  98. package/dist/src/semantic/core/verify-release.mjs.map +0 -1
  99. package/dist/src/semantic/docker/publish.mjs +0 -2
  100. package/dist/src/semantic/docker/publish.mjs.map +0 -1
  101. package/dist/src/semantic/docker/success.mjs +0 -2
  102. package/dist/src/semantic/docker/success.mjs.map +0 -1
  103. package/dist/strip-ansi-Aeu5cmZe.mjs +0 -174
  104. package/dist/strip-ansi-Cl0pRo-s.mjs +0 -2
  105. package/dist/strip-ansi-Cl0pRo-s.mjs.map +0 -1
  106. package/dist/wrap-ansi-BeIjar2W.mjs +0 -2
  107. package/dist/wrap-ansi-DsMb4WnZ.mjs.map +0 -1
  108. package/mise.toml +0 -2
  109. package/oxlint.json +0 -25
  110. package/release.config.mjs +0 -39
  111. package/src/commands/checkfeatures.ts +0 -39
  112. package/src/commands/clean.ts +0 -36
  113. package/src/commands/config.ts +0 -31
  114. package/src/commands/deploy.ts +0 -39
  115. package/src/commands/fetch.ts +0 -30
  116. package/src/commands/finish.ts +0 -50
  117. package/src/commands/index.ts +0 -13
  118. package/src/commands/jira-releases.ts +0 -97
  119. package/src/commands/merge.ts +0 -58
  120. package/src/commands/prompts/branches.ts +0 -46
  121. package/src/commands/pull.ts +0 -44
  122. package/src/commands/push.ts +0 -48
  123. package/src/commands/rebase.ts +0 -56
  124. package/src/commands/release.ts +0 -21
  125. package/src/commands/republish.ts +0 -34
  126. package/src/commands/start.ts +0 -123
  127. package/src/commands/tasks/merge-branch.ts +0 -80
  128. package/src/commands/tasks/push-branch.ts +0 -19
  129. package/src/commands/tasks/rebase-all-branches.ts +0 -37
  130. package/src/commands/tasks/refresh-repository.ts +0 -38
  131. package/src/commands/tasks/run-test.ts +0 -28
  132. package/src/commands/tasks/update-branch.ts +0 -49
  133. package/src/commands/tasks/update-dependencies.ts +0 -43
  134. package/src/commands/utils/check-install.ts +0 -31
  135. package/src/common/back/directus/directus-flow.test.ts +0 -63
  136. package/src/common/back/directus/directus-flow.ts +0 -48
  137. package/src/common/back/http/http-proxy.ts +0 -21
  138. package/src/common/back/http/http-request.spec.ts +0 -50
  139. package/src/common/back/http/http-request.ts +0 -74
  140. package/src/common/back/jira/get-sorted-releases.ts +0 -40
  141. package/src/common/back/jira/interfaces/JiraIIssue.d.ts +0 -100
  142. package/src/common/back/jira/jira-releases.ts +0 -47
  143. package/src/common/back/jira/jira-request.spec.ts +0 -59
  144. package/src/common/back/jira/jira-request.ts +0 -29
  145. package/src/common/back/jira/jira-search.spec.ts +0 -44
  146. package/src/common/back/jira/jira-search.ts +0 -17
  147. package/src/common/cli/bun.test.ts +0 -58
  148. package/src/common/cli/bun.ts +0 -33
  149. package/src/common/cli/cli.ts +0 -127
  150. package/src/common/cli/docker.test.ts +0 -141
  151. package/src/common/cli/docker.ts +0 -66
  152. package/src/common/cli/git.test.ts +0 -215
  153. package/src/common/cli/git.ts +0 -121
  154. package/src/common/cli/lerna.test.ts +0 -58
  155. package/src/common/cli/lerna.ts +0 -25
  156. package/src/common/cli/npm.test.ts +0 -58
  157. package/src/common/cli/npm.ts +0 -33
  158. package/src/common/cli/pnpm.test.ts +0 -58
  159. package/src/common/cli/pnpm.ts +0 -34
  160. package/src/common/cli/yarn.test.ts +0 -58
  161. package/src/common/cli/yarn.ts +0 -33
  162. package/src/common/configure-git-workspace.ts +0 -39
  163. package/src/common/get-config.ts +0 -159
  164. package/src/common/get-package-json.ts +0 -15
  165. package/src/common/get-package-manager.ts +0 -13
  166. package/src/common/get-release-config.ts +0 -9
  167. package/src/common/index.ts +0 -14
  168. package/src/common/run-command.test.ts +0 -66
  169. package/src/common/run-command.ts +0 -67
  170. package/src/common/types.ts +0 -26
  171. package/src/common/vendor.d.ts +0 -4
  172. package/src/index.ts +0 -14
  173. package/src/semantic/core/analyze-commits.ts +0 -21
  174. package/src/semantic/core/conditional.ts +0 -62
  175. package/src/semantic/core/exit.ts +0 -15
  176. package/src/semantic/core/prepare/bump-version.ts +0 -41
  177. package/src/semantic/core/prepare/commit.ts +0 -30
  178. package/src/semantic/core/prepare/release-info.ts +0 -6
  179. package/src/semantic/core/run.ts +0 -23
  180. package/src/semantic/core/sync-repository.ts +0 -55
  181. package/src/semantic/core/verify-conditions.ts +0 -41
  182. package/src/semantic/core/verify-release.ts +0 -10
  183. package/src/semantic/define-config.ts +0 -42
  184. package/src/semantic/docker/publish.ts +0 -6
  185. package/src/semantic/docker/success.ts +0 -10
  186. package/src/semantic/utils/__mock__/test1/package.json +0 -7
  187. package/src/semantic/utils/__mock__/test1/packages/a/package.json +0 -9
  188. package/src/semantic/utils/__mock__/test1/packages/b/package.json +0 -7
  189. package/src/semantic/utils/__mock__/test2/package.json +0 -4
  190. package/src/semantic/utils/__mock__/test2/packages/a/package.json +0 -7
  191. package/src/semantic/utils/__mock__/test2/packages/b/package.json +0 -5
  192. package/src/semantic/utils/bump-packages-version.test.ts +0 -76
  193. package/src/semantic/utils/bump-packages-version.ts +0 -53
  194. package/src/semantic/utils/calculate-snapshot-version.test.ts +0 -69
  195. package/src/semantic/utils/calculate-snapshot-version.ts +0 -17
  196. package/src/semantic/utils/display-package-info.ts +0 -12
  197. package/src/semantic/utils/display-release-info.ts +0 -13
  198. package/src/semantic/utils/docker-clean-tags.test.ts +0 -62
  199. package/src/semantic/utils/docker-clean-tags.ts +0 -58
  200. package/src/semantic/utils/docker-publish.test.ts +0 -45
  201. package/src/semantic/utils/docker-publish.ts +0 -24
  202. package/src/semantic/utils/log-section.ts +0 -9
  203. package/src/semantic/utils/release-rules.ts +0 -15
  204. package/src/semantic/utils/transform-writer.ts +0 -101
  205. package/src/workflow/index.ts +0 -42
  206. package/tsconfig.build.json +0 -29
  207. package/tsconfig.json +0 -30
  208. package/tsdown.config.ts +0 -63
  209. package/vitest.config.mts +0 -9
@@ -1,30 +0,0 @@
1
- import type { Command } from "commander";
2
- import type { CmContext, ListrTask, ICommand } from "../common/types.js";
3
- import { runCommand } from "../common/run-command.js";
4
- import { refreshRepository } from "./tasks/refresh-repository.js";
5
-
6
- interface FetchOpts {
7
- verbose?: number;
8
- }
9
-
10
- export class Fetch implements ICommand {
11
- mapContext(_opts: FetchOpts, context: CmContext): CmContext {
12
- return { ...context, output: [] };
13
- }
14
-
15
- getTasks(context: CmContext): ListrTask[] {
16
- return [refreshRepository(context)];
17
- }
18
-
19
- success(context: CmContext): void {
20
- const output = (context.output ?? []) as string[];
21
- console.log(output.filter((l) => !l.match("Fetching")).join("\n"));
22
- }
23
- }
24
-
25
- export default (program: Command): void =>
26
- void program
27
- .command("fetch")
28
- .description("Download objects and refs from repository (--all and --prune)")
29
- .option("-v, --verbose", "Enable verbose log", (v, t: number) => t + 1, 0)
30
- .action((opts: FetchOpts) => runCommand(Fetch, opts));
@@ -1,50 +0,0 @@
1
- import type { Command } from "commander";
2
- import chalk from "chalk";
3
- import figures from "figures";
4
- import type { ListrTask } from "listr2";
5
-
6
- import type { CmContext, ICommand } from "../common/types.js";
7
- import { git } from "../common/cli/git.js";
8
- import { runCommand } from "../common/run-command.js";
9
- import { Rebase, type RebaseOpts } from "./rebase.js";
10
- import { pushBranch } from "./tasks/push-branch.js";
11
-
12
- export class Finish extends Rebase implements ICommand {
13
- mapContext(commander: RebaseOpts, context: CmContext): CmContext {
14
- return { ...super.mapContext(commander, context), checkStatus: true, force: true };
15
- }
16
-
17
- verifyConditions(context: CmContext): void {
18
- if (context.featureBranch === context.fromBranch) {
19
- console.error(chalk.red(`${figures.cross} ${context.fromBranch as string} cannot be finished`));
20
- process.exit(1);
21
- }
22
- }
23
-
24
- getTasks(context: CmContext): ListrTask[] {
25
- return [
26
- ...super.getTasks(context),
27
- {
28
- title: `Add ${context.RELEASE_CANDIDATE_TAG as string} on last commit`,
29
- task() {
30
- const message = `${git.getLastCommitMsg()} ${context.config.RELEASE_CANDIDATE_TAG}`;
31
- return git.commit("--amend", "-m", message).toObservable();
32
- }
33
- },
34
- pushBranch(context)
35
- ];
36
- }
37
-
38
- success(context: CmContext): void {
39
- console.log(chalk.green(figures.tick), "Branch", chalk.green(context.featureBranch as string), "is finished");
40
- }
41
- }
42
-
43
- export default (program: Command): void =>
44
- void program
45
- .command("finish")
46
- .description("Rebase the branch, add [MEP] tag on latest commit and push it")
47
- .option("-t, --unit-test", "Run unit test", (v, t: number) => t + 1, 0)
48
- .option("-c, --cucumber", "Run cucumber", (v, t: number) => t + 1, 0)
49
- .option("-v, --verbose", "Enable verbose log", (v, t: number) => t + 1, 0)
50
- .action((opts: RebaseOpts) => runCommand(Finish, opts));
@@ -1,13 +0,0 @@
1
- export * from "./checkfeatures.js";
2
- export * from "./clean.js";
3
- export * from "./config.js";
4
- export * from "./deploy.js";
5
- export * from "./fetch.js";
6
- export * from "./finish.js";
7
- export * from "./jira-releases.js";
8
- export * from "./merge.js";
9
- export * from "./pull.js";
10
- export * from "./push.js";
11
- export * from "./rebase.js";
12
- export * from "./republish.js";
13
- export * from "./start.js";
@@ -1,97 +0,0 @@
1
- import chalk from "chalk";
2
- import type { Command } from "commander";
3
- import figures from "figures";
4
- import type { ListrTask } from "listr2";
5
- import moment from "moment";
6
- import { triggerDirectusFlow } from "../common/back/directus/directus-flow.js";
7
- import { getSortedReleases } from "../common/back/jira/get-sorted-releases.js";
8
- import { updateJiraRelease } from "../common/back/jira/jira-releases.js";
9
- import { getConfig } from "../common/index.js";
10
- import { runCommand } from "../common/run-command.js";
11
-
12
- import type { CmContext, ICommand } from "../common/types.js";
13
-
14
- interface JiraReleasesOpts {
15
- component?: string;
16
- projectId?: string;
17
- update?: number;
18
- verbose?: number;
19
- tag?: string;
20
- }
21
- export interface JiraRelease {
22
- id: string;
23
- name: string;
24
- released: boolean;
25
- releaseDate?: string;
26
- version: string;
27
- [key: string]: unknown;
28
- }
29
-
30
- interface JiraReleasesContext extends CmContext {
31
- projectId?: string;
32
- component?: string;
33
- tag?: string;
34
- update?: number;
35
- releases?: JiraRelease[];
36
- }
37
-
38
- export class JiraReleases implements ICommand {
39
- mapContext(commander: JiraReleasesOpts, context: CmContext): JiraReleasesContext {
40
- return {
41
- ...context,
42
- projectId: commander.projectId,
43
- update: commander.update,
44
- component: commander.component,
45
- tag: commander.tag?.replace(/^version-/, "").replace(/^v/, "")
46
- };
47
- }
48
-
49
- getTasks(context: JiraReleasesContext): ListrTask[] {
50
- if (!context.tag) {
51
- console.log(chalk.red(figures.cross), "Missing tag version. Skipping release notes generation");
52
- return [];
53
- }
54
-
55
- return [
56
- {
57
- title: `List all releases under ${context.tag} for ${context.component} component and ${context.projectId} project`,
58
- task: async () => {
59
- context.releases = (await getSortedReleases(context.projectId ?? "", context.component ?? "", context.tag ?? ""))
60
- .filter(Boolean)
61
- .filter((release) => release.released === false) as JiraRelease[];
62
- }
63
- },
64
- {
65
- title: `Update ${context.tag} on ${context.component} component`,
66
- skip: () => !context.update || (context.releases?.length ?? 0) === 0,
67
- task: async () => {
68
- for (const release of context.releases ?? []) {
69
- release.released = true;
70
- release.releaseDate = moment().format("YYYY-MM-DD");
71
- await updateJiraRelease(release);
72
- }
73
- }
74
- },
75
- {
76
- title: "Trigger CMS API Workflow",
77
- skip: () => !(getConfig() as Record<string, unknown>).CAN_TRIGGER_WORKFLOW || (context.releases?.length ?? 0) === 0,
78
- task: () =>
79
- triggerDirectusFlow(
80
- context.projectId ?? "",
81
- (context.releases ?? []).map(({ version }) => version)
82
- )
83
- }
84
- ];
85
- }
86
- }
87
-
88
- export default (program: Command): void =>
89
- void program
90
- .command("jira-releases")
91
- .description("Check jira releases status from given status")
92
- .option("-c, --component <component>", "Jira component filter")
93
- .option("--project-id <projectId>", "Jira projectId filter")
94
- .option("-u, --update", "Update jira releases status if necessary", (v, t: number) => t + 1, 0)
95
- .option("-v, --verbose", "Enable verbose log", (v, t: number) => t + 1, 0)
96
- .option("-t, --tag <tag>", "The tag version you want to check or update")
97
- .action((opts: JiraReleasesOpts) => runCommand(JiraReleases, opts));
@@ -1,58 +0,0 @@
1
- import type { Command } from "commander";
2
- import chalk from "chalk";
3
- import figures from "figures";
4
- import type { ListrTask } from "listr2";
5
-
6
- import type { CmContext, ICommand } from "../common/types.js";
7
- import { git } from "../common/cli/git.js";
8
- import { runCommand } from "../common/run-command.js";
9
- import { mergeBranch } from "./tasks/merge-branch.js";
10
-
11
- interface MergeOpts {
12
- verbose?: number;
13
- }
14
-
15
- export class Merge implements ICommand {
16
- private lastCommitMessage = "";
17
-
18
- getTasks(context: CmContext): ListrTask[] {
19
- const { RELEASE_CANDIDATE_TAG } = context;
20
- this.lastCommitMessage = git.getLastCommitMsg() as string;
21
- if (this.lastCommitMessage.includes(RELEASE_CANDIDATE_TAG as string)) {
22
- return [mergeBranch(context as unknown as Parameters<typeof mergeBranch>[0])];
23
- }
24
- return [];
25
- }
26
-
27
- success(context: CmContext): void {
28
- const { RELEASE_CANDIDATE_TAG } = context;
29
- if (this.lastCommitMessage.includes(RELEASE_CANDIDATE_TAG as string)) {
30
- context.logger.info(
31
- chalk.green(figures.tick),
32
- "Branch",
33
- chalk.green(context.BRANCH_NAME as string),
34
- `merged into ${context.PRODUCTION_BRANCH as string}`
35
- );
36
- } else {
37
- context.logger.info(
38
- chalk.green(figures.tick),
39
- "Merge branch",
40
- chalk.green(context.BRANCH_NAME as string),
41
- `into ${context.PRODUCTION_BRANCH as string} not required`
42
- );
43
- context.logger.info(
44
- chalk.green(figures.tick),
45
- "Last commit message:",
46
- chalk.green(this.lastCommitMessage),
47
- `does not contain ${RELEASE_CANDIDATE_TAG as string}`
48
- );
49
- }
50
- }
51
- }
52
-
53
- export default (program: Command): void =>
54
- void program
55
- .command("merge")
56
- .description("Merge current branch into PRODUCTION_BRANCH")
57
- .option("-v, --verbose", "Enable verbose log", (v, t: number) => t + 1, 0)
58
- .action((opts: MergeOpts) => runCommand(Merge, opts));
@@ -1,46 +0,0 @@
1
- import inquirer from "inquirer";
2
-
3
- import { git } from "../../common/index.js";
4
-
5
- function toRemote(branch: string, origin: string) {
6
- branch = branch.replace(`${origin}/`, "");
7
- return `${origin}/${branch}`;
8
- }
9
-
10
- interface BranchesContext {
11
- fromBranch?: string;
12
- origin: string;
13
- PRODUCTION_BRANCH: string;
14
- DEVELOP_BRANCH: string;
15
- message?: string;
16
- }
17
-
18
- export function branches({ fromBranch, origin, PRODUCTION_BRANCH, DEVELOP_BRANCH, message = "Start your branch from:" }: BranchesContext) {
19
- const currentBranch = git.getBranchName();
20
- const originDevelop = `${origin}/${DEVELOP_BRANCH}`;
21
- const originProduction = `${origin}/${PRODUCTION_BRANCH}`;
22
-
23
- let startFromBranches: (string | inquirer.Separator)[] = [originProduction];
24
-
25
- if (startFromBranches.indexOf(toRemote(currentBranch, origin)) === -1 && git.branchExists(currentBranch, origin)) {
26
- startFromBranches = startFromBranches.concat(toRemote(currentBranch, origin));
27
- }
28
-
29
- const remoteBranches = git
30
- .branchesInfos("-r")
31
- .map((info) => info.branch)
32
- .filter((name) => !startFromBranches.includes(name) && ![originDevelop, originProduction].includes(name));
33
-
34
- if (remoteBranches.length) {
35
- startFromBranches = startFromBranches.concat([new inquirer.Separator(), ...remoteBranches]);
36
- }
37
-
38
- return {
39
- type: "list",
40
- name: "fromBranch",
41
- message,
42
- default: startFromBranches.indexOf(fromBranch || originProduction),
43
- choices: startFromBranches,
44
- when: !fromBranch || currentBranch !== DEVELOP_BRANCH
45
- };
46
- }
@@ -1,44 +0,0 @@
1
- import type { Command } from "commander";
2
- import type { ListrTask } from "listr2";
3
-
4
- import type { CmContext, ICommand } from "../common/types.js";
5
- import { git } from "../common/index.js";
6
- import { runCommand } from "../common/run-command.js";
7
-
8
- interface PullOpts {
9
- branch: string;
10
- verbose?: number;
11
- }
12
-
13
- export class Pull implements ICommand {
14
- mapContext(options: Record<string, unknown>, context: CmContext): CmContext {
15
- return { ...context, targetBranch: options["branch"] as string };
16
- }
17
-
18
- getTasks(context: CmContext): ListrTask[] {
19
- const { targetBranch } = context;
20
- return [
21
- { title: "Git fetch", task: () => git.fetch("--all", "--prune", "--tags") },
22
- {
23
- title: `Delete local branch ${targetBranch as string}`,
24
- task: () => (git.branch("-D", targetBranch as string) as Promise<unknown>).catch(() => {})
25
- },
26
- {
27
- title: `Checkout origin/${targetBranch as string}`,
28
- task: () => git.checkout(`origin/${targetBranch as string}`, "--track")
29
- }
30
- ];
31
- }
32
-
33
- success(context: CmContext): void {
34
- console.log(`BRANCH ${context.targetBranch as string} RETRIEVE DONE`);
35
- }
36
- }
37
-
38
- export default (program: Command): void =>
39
- void program
40
- .command("pull")
41
- .description("Pull a branch from origin")
42
- .argument("<branch>", "Branch name to pull")
43
- .option("-v, --verbose", "Enable verbose log", (v, t: number) => t + 1, 0)
44
- .action((branch: string, opts: Omit<PullOpts, "branch">) => runCommand(Pull, { ...opts, branch }));
@@ -1,48 +0,0 @@
1
- import type { Command } from "commander";
2
- import chalk from "chalk";
3
- import figures from "figures";
4
- import type { ListrTask } from "listr2";
5
-
6
- import type { CmContext, ICommand } from "../common/types.js";
7
- import { runCommand } from "../common/run-command.js";
8
- import { Rebase, type RebaseOpts } from "./rebase.js";
9
- import { pushBranch } from "./tasks/push-branch.js";
10
-
11
- export class Push extends Rebase implements ICommand {
12
- mapContext(commander: RebaseOpts, context: CmContext): CmContext {
13
- return {
14
- ...super.mapContext(commander, context),
15
- force: !!commander.force,
16
- checkStatus: true
17
- };
18
- }
19
-
20
- getTasks(context: CmContext): ListrTask[] {
21
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
22
- return [...super.getTasks(context), pushBranch(context as any)];
23
- }
24
-
25
- success(context: CmContext): void {
26
- console.log(chalk.green(figures.tick), "Branch", chalk.green(context.featureBranch as string), "rebased and pushed.");
27
- }
28
- }
29
-
30
- export default (program: Command): void =>
31
- void program
32
- .command("push")
33
- .description("Rebase the current branch from production and push all commits")
34
- .option("-t, --unit-test", "Run unit test", (v, t: number) => t + 1, 0)
35
- .option("-c, --cucumber", "Run cucumber", (v, t: number) => t + 1, 0)
36
- .option("-f, --force", "Force push", (v, t: number) => t + 1, 0)
37
- .option("-v, --verbose", "Enable verbose log", (v, t: number) => t + 1, 0)
38
- .action((opts: RebaseOpts) => runCommand(Push, opts));
39
-
40
- export const publish = (program: Command): void =>
41
- void program
42
- .command("publish")
43
- .description("Alias of push: rebase and push current branch")
44
- .option("-t, --unit-test", "Run unit test", (v, t: number) => t + 1, 0)
45
- .option("-c, --cucumber", "Run cucumber", (v, t: number) => t + 1, 0)
46
- .option("-f, --force", "Force push", (v, t: number) => t + 1, 0)
47
- .option("-v, --verbose", "Enable verbose log", (v, t: number) => t + 1, 0)
48
- .action((opts: RebaseOpts) => runCommand(Push, opts));
@@ -1,56 +0,0 @@
1
- import chalk from "chalk";
2
- import type { Command } from "commander";
3
- import figures from "figures";
4
- import type { ListrTask } from "listr2";
5
- import { git } from "../common/cli/git.js";
6
- import { runCommand } from "../common/run-command.js";
7
-
8
- import type { CmContext, ICommand } from "../common/types.js";
9
- import { Fetch } from "./fetch.js";
10
- import { runTest } from "./tasks/run-test.js";
11
- import { updateBranch } from "./tasks/update-branch.js";
12
- import { updateDependencies } from "./tasks/update-dependencies.js";
13
-
14
- export interface RebaseOpts {
15
- unitTest?: number;
16
- cucumber?: number;
17
- force?: number;
18
- verbose?: number;
19
- }
20
-
21
- export class Rebase extends Fetch implements ICommand {
22
- mapContext(commander: RebaseOpts, context: CmContext): CmContext {
23
- return {
24
- ...context,
25
- origin: context.ORIGIN,
26
- featureBranch: git.getBranchName(),
27
- fromBranch: context.PRODUCTION_BRANCH,
28
- checkStatus: commander.force === undefined ? true : !!commander.force,
29
- rebase: true,
30
- skipTest: !commander.cucumber && !commander.unitTest,
31
- skipUnit: !commander.unitTest,
32
- skipE2E: context.HAS_E2E ? !commander.cucumber : true
33
- };
34
- }
35
-
36
- getTasks(context: CmContext): ListrTask[] {
37
- return [...super.getTasks(context), updateBranch(context), updateDependencies(context), ...runTest(context)];
38
- }
39
-
40
- success(context: CmContext): void {
41
- console.log(
42
- chalk.green(figures.tick),
43
- `Branch ${chalk.green(context.featureBranch as string)} rebased from ${chalk.green(context.fromBranch as string)} HEAD`
44
- );
45
- }
46
- }
47
-
48
- export default (program: Command): void =>
49
- void program
50
- .command("rebase")
51
- .description("Rebase the current branch from production")
52
- .option("-t, --unit-test", "Run unit test", (v, t: number) => t + 1, 0)
53
- .option("-c, --cucumber", "Run cucumber", (v, t: number) => t + 1, 0)
54
- .option("-f, --force", "Force push", (v, t: number) => t + 1, 0)
55
- .option("-v, --verbose", "Enable verbose log", (v, t: number) => t + 1, 0)
56
- .action((opts: RebaseOpts) => runCommand(Rebase, opts));
@@ -1,21 +0,0 @@
1
- import semantic_release from "semantic-release";
2
-
3
- delete process.env.CIRCLE_PR_NUMBER;
4
- delete process.env.CIRCLE_PULL_REQUEST;
5
- delete process.env.CI_PULL_REQUEST;
6
-
7
- export function release(options = {}) {
8
- semantic_release({
9
- dryRun: process.argv.includes("--dry-run"),
10
- ci: false,
11
- noCi: true,
12
- ...options
13
- })
14
- .then(() => {
15
- process.exitCode = 0;
16
- })
17
- .catch((err) => {
18
- console.log("Error while releasing", err);
19
- process.exitCode = 1;
20
- });
21
- }
@@ -1,34 +0,0 @@
1
- import type { Command } from "commander";
2
- import chalk from "chalk";
3
- import figures from "figures";
4
- import type { ListrTask } from "listr2";
5
-
6
- import type { CmContext, ICommand } from "../common/types.js";
7
- import { runCommand } from "../common/run-command.js";
8
- import { Fetch } from "./fetch.js";
9
- import { rebaseAllBranches } from "./tasks/rebase-all-branches.js";
10
-
11
- interface RepublishOpts {
12
- verbose?: number;
13
- }
14
-
15
- export class Republish extends Fetch implements ICommand {
16
- mapContext(commander: RepublishOpts, context: CmContext): CmContext {
17
- return { ...super.mapContext(commander, context) };
18
- }
19
-
20
- getTasks(context: CmContext): ListrTask[] {
21
- return [...super.getTasks(context), rebaseAllBranches(context as unknown as Parameters<typeof rebaseAllBranches>[0])];
22
- }
23
-
24
- success(): void {
25
- console.log(chalk.green(figures.tick), "All branches rebased and pushed.");
26
- }
27
- }
28
-
29
- export default (program: Command): void =>
30
- void program
31
- .command("republish")
32
- .description("Rebase all branches from production")
33
- .option("-v, --verbose", "Enable verbose log", (v, t: number) => t + 1, 0)
34
- .action((opts: RepublishOpts) => runCommand(Republish, opts));
@@ -1,123 +0,0 @@
1
- import chalk from "chalk";
2
- import type { Command } from "commander";
3
- import figures from "figures";
4
- import type { ListrTask } from "listr2";
5
- import { git } from "../common/cli/git.js";
6
- import { runCommand } from "../common/run-command.js";
7
-
8
- import type { CmContext, ICommand } from "../common/types.js";
9
- import { WORKFLOW_CONFIGURATION } from "../workflow/index.js";
10
- import { Fetch } from "./fetch.js";
11
- import { branches } from "./prompts/branches.js";
12
- import { updateDependencies } from "./tasks/update-dependencies.js";
13
-
14
- interface StartOpts {
15
- jiraId?: string;
16
- branchName?: string;
17
- verbose?: number;
18
- }
19
-
20
- type StartContext = CmContext<{
21
- jiraId?: string;
22
- branchName?: string;
23
- type?: string;
24
- featureBranch?: string;
25
- fromBranch?: string;
26
- origin?: string;
27
- }>;
28
-
29
- function sanitize(name: string): string {
30
- return name
31
- .replace(/[/\\_|. ]/gi, "-")
32
- .split("-")
33
- .filter(Boolean)
34
- .join("-");
35
- }
36
-
37
- export class Start extends Fetch implements ICommand {
38
- mapContext(options: StartOpts, context: CmContext): StartContext {
39
- const branchName = options.branchName ?? "";
40
- const cfg = WORKFLOW_CONFIGURATION as Array<{ type: string }>;
41
- const type = cfg.map(({ type }) => type).find((t) => branchName.startsWith(`${t}-`));
42
- const jiraId = options.jiraId ?? (branchName.startsWith("CMAB-") ? `CMAB-${branchName.split("-")[1]}` : undefined);
43
- const resolvedBranchName = branchName.startsWith("CMAB-") ? branchName.split("-").slice(2).join("-") : branchName;
44
-
45
- return {
46
- ...context,
47
- origin: context.ORIGIN as string,
48
- jiraId,
49
- branchName: resolvedBranchName,
50
- type
51
- };
52
- }
53
-
54
- prompt(context: StartContext): Array<Record<string, unknown>> {
55
- return [
56
- {
57
- type: "input",
58
- name: "jiraId",
59
- message: "What is the Jira ID? (leave blank to skip)",
60
- default: context.jiraId,
61
- when: !context.jiraId
62
- },
63
- {
64
- type: "list",
65
- name: "type",
66
- message: "Choose the type of your branch:",
67
- choices: ["fix", "feat", "chore", "docs", "tech"],
68
- default: context.type,
69
- when: !context.type && !context.jiraId
70
- },
71
- {
72
- type: "input",
73
- name: "branchName",
74
- message: "What is the branch name?",
75
- validate(branch: string) {
76
- if (!branch.length) return "Branch name is required";
77
- if (git.branchExists(branch, context.origin as string)) return `${branch} already exists`;
78
- return true;
79
- },
80
- when: !context.branchName
81
- },
82
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
83
- branches(context as any)
84
- ];
85
- }
86
-
87
- getTasks(context: StartContext): ListrTask[] {
88
- context.branchName = sanitize(context.branchName ?? "");
89
- context.featureBranch = context.jiraId
90
- ? `${context.jiraId}-${context.branchName}`
91
- : context.branchName.includes((context.type ?? "") + "-")
92
- ? context.branchName
93
- : `${context.type}-${context.branchName}`;
94
- context.fromBranch = context.fromBranch ?? context.config.PRODUCTION_BRANCH;
95
-
96
- return [
97
- ...super.getTasks(context),
98
- {
99
- title: `Create branch from ${chalk.green(context.fromBranch)}`,
100
- task: () => git.checkout("--no-track", "-b", context.featureBranch!, context.fromBranch!).toObservable()
101
- },
102
- updateDependencies(context)
103
- ];
104
- }
105
-
106
- success(context: StartContext): void {
107
- console.log(
108
- chalk.green(figures.tick),
109
- `New branch ${chalk.green(context.featureBranch!)} created from ${chalk.green(context.fromBranch!)} HEAD`
110
- );
111
- }
112
- }
113
-
114
- export default (program: Command): void =>
115
- void program
116
- .command("start")
117
- .description("Create a new branch from the latest commit of production branch")
118
- .argument("[jiraId]", "Jira ticket ID")
119
- .argument("[branchName]", "Branch name")
120
- .option("-v, --verbose", "Enable verbose log", (v, t: number) => t + 1, 0)
121
- .action((jiraId: string | undefined, branchName: string | undefined, opts: { verbose?: number }) =>
122
- runCommand(Start, { jiraId, branchName, verbose: opts.verbose })
123
- );