@cmflow/cli 3.2.1 → 3.4.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (221) hide show
  1. package/{.prettierrc → .oxfmtrc.json} +2 -1
  2. package/.yarn/install-state.gz +0 -0
  3. package/.yarn/releases/yarn-4.18.0.cjs +1000 -0
  4. package/.yarnrc.yml +8 -1
  5. package/README.md +66 -72
  6. package/bin/cm-checkfeatures.ts +10 -0
  7. package/bin/cm-clean.ts +10 -0
  8. package/bin/cm-config.ts +10 -0
  9. package/bin/cm-deploy.ts +10 -0
  10. package/bin/cm-expedit.ts +19 -0
  11. package/bin/cm-fetch.ts +10 -0
  12. package/bin/cm-finish.ts +10 -0
  13. package/bin/cm-jira-releases.ts +10 -0
  14. package/bin/cm-merge.ts +10 -0
  15. package/bin/cm-publish.ts +10 -0
  16. package/bin/cm-pull.ts +8 -0
  17. package/bin/cm-push.ts +10 -0
  18. package/bin/cm-rebase.ts +10 -0
  19. package/bin/{cmrelease.js → cm-release.ts} +0 -0
  20. package/bin/cm-republish.ts +10 -0
  21. package/bin/cm-start.ts +10 -0
  22. package/bin/cm.ts +40 -0
  23. package/dist/bin/cm.mjs +74985 -0
  24. package/dist/bin/cmrelease.mjs +72397 -0
  25. package/dist/cli-truncate-BmHD4ngn.mjs +152 -0
  26. package/dist/cli-truncate-CXNquMRK.mjs +152 -0
  27. package/dist/cli-truncate-DbOyuy2e.mjs +2 -0
  28. package/dist/cli-truncate-DbOyuy2e.mjs.map +1 -0
  29. package/dist/common-CwPbT3So.mjs +66 -0
  30. package/dist/common-CwPbT3So.mjs.map +1 -0
  31. package/dist/docker-clean-tags-Cd-E8IqJ.mjs +2 -0
  32. package/dist/docker-clean-tags-Cd-E8IqJ.mjs.map +1 -0
  33. package/dist/docker-publish-B0E0qYYB.mjs +2 -0
  34. package/dist/docker-publish-B0E0qYYB.mjs.map +1 -0
  35. package/dist/get-config-DoOyLztI.mjs +41 -0
  36. package/dist/get-config-DoOyLztI.mjs.map +1 -0
  37. package/dist/get-east-asian-width-Tfn8qoqd.mjs +2 -0
  38. package/dist/get-east-asian-width-Tfn8qoqd.mjs.map +1 -0
  39. package/dist/get-east-asian-width-eFfEkHwo.mjs +682 -0
  40. package/dist/log-update-B2GqeeDd.mjs +497 -0
  41. package/dist/log-update-BldA9lkm.mjs +497 -0
  42. package/dist/log-update-By8Z-mak.mjs +6 -0
  43. package/dist/log-update-By8Z-mak.mjs.map +1 -0
  44. package/dist/rolldown-runtime-B4iAMlE-.mjs +35 -0
  45. package/dist/semver-D8gwMSFO.mjs +2 -0
  46. package/dist/semver-D8gwMSFO.mjs.map +1 -0
  47. package/dist/src/index.mjs +18 -0
  48. package/dist/src/index.mjs.map +1 -0
  49. package/dist/src/semantic/core/analyze-commits.mjs +2 -0
  50. package/dist/src/semantic/core/analyze-commits.mjs.map +1 -0
  51. package/dist/src/semantic/core/conditional.mjs +2 -0
  52. package/dist/src/semantic/core/conditional.mjs.map +1 -0
  53. package/dist/src/semantic/core/exit.mjs +2 -0
  54. package/dist/src/semantic/core/exit.mjs.map +1 -0
  55. package/dist/src/semantic/core/prepare/bump-version.mjs +48 -0
  56. package/dist/src/semantic/core/prepare/bump-version.mjs.map +1 -0
  57. package/dist/src/semantic/core/prepare/commit.mjs +2 -0
  58. package/dist/src/semantic/core/prepare/commit.mjs.map +1 -0
  59. package/dist/src/semantic/core/prepare/release-info.mjs +2 -0
  60. package/dist/src/semantic/core/prepare/release-info.mjs.map +1 -0
  61. package/dist/src/semantic/core/run.mjs +2 -0
  62. package/dist/src/semantic/core/run.mjs.map +1 -0
  63. package/dist/src/semantic/core/sync-repository.mjs +2 -0
  64. package/dist/src/semantic/core/sync-repository.mjs.map +1 -0
  65. package/dist/src/semantic/core/verify-conditions.mjs +2 -0
  66. package/dist/src/semantic/core/verify-conditions.mjs.map +1 -0
  67. package/dist/src/semantic/core/verify-release.mjs +2 -0
  68. package/dist/src/semantic/core/verify-release.mjs.map +1 -0
  69. package/dist/src/semantic/docker/publish.mjs +2 -0
  70. package/dist/src/semantic/docker/publish.mjs.map +1 -0
  71. package/dist/src/semantic/docker/success.mjs +2 -0
  72. package/dist/src/semantic/docker/success.mjs.map +1 -0
  73. package/dist/strip-ansi-Aeu5cmZe.mjs +174 -0
  74. package/dist/strip-ansi-Cl0pRo-s.mjs +2 -0
  75. package/dist/strip-ansi-Cl0pRo-s.mjs.map +1 -0
  76. package/dist/wrap-ansi-BeIjar2W.mjs +2 -0
  77. package/dist/wrap-ansi-CWIezXNl.mjs +330 -0
  78. package/dist/wrap-ansi-DsMb4WnZ.mjs +9 -0
  79. package/dist/wrap-ansi-DsMb4WnZ.mjs.map +1 -0
  80. package/dist/wrap-ansi-T0rz0Urp.mjs +330 -0
  81. package/mise.toml +2 -0
  82. package/oxlint.json +25 -0
  83. package/package.json +65 -62
  84. package/release.config.mjs +6 -6
  85. package/src/commands/checkfeatures.ts +39 -0
  86. package/src/commands/clean.ts +36 -0
  87. package/src/commands/config.ts +31 -0
  88. package/src/commands/deploy.ts +39 -0
  89. package/src/commands/fetch.ts +30 -0
  90. package/src/commands/finish.ts +50 -0
  91. package/src/commands/{index.js → index.ts} +3 -0
  92. package/src/commands/jira-releases.ts +97 -0
  93. package/src/commands/merge.ts +58 -0
  94. package/src/commands/prompts/{branches.js → branches.ts} +13 -5
  95. package/src/commands/pull.ts +44 -0
  96. package/src/commands/push.ts +48 -0
  97. package/src/commands/rebase.ts +56 -0
  98. package/src/commands/republish.ts +34 -0
  99. package/src/commands/start.ts +123 -0
  100. package/src/commands/tasks/{merge-branch.js → merge-branch.ts} +18 -3
  101. package/src/commands/tasks/push-branch.ts +19 -0
  102. package/src/commands/tasks/{rebase-all-branches.js → rebase-all-branches.ts} +10 -2
  103. package/src/commands/tasks/{refresh-repository.js → refresh-repository.ts} +8 -4
  104. package/src/commands/tasks/run-test.ts +28 -0
  105. package/src/commands/tasks/{update-branch.js → update-branch.ts} +15 -9
  106. package/src/commands/tasks/{update-dependencies.js → update-dependencies.ts} +4 -3
  107. package/src/common/back/directus/{directus-flow.test.js → directus-flow.test.ts} +1 -0
  108. package/src/common/back/directus/{directus-flow.js → directus-flow.ts} +10 -2
  109. package/src/common/back/http/{http-proxy.js → http-proxy.ts} +7 -1
  110. package/src/common/back/http/{http-request.spec.js → http-request.spec.ts} +8 -7
  111. package/src/common/back/http/{http-request.js → http-request.ts} +16 -19
  112. package/src/common/back/jira/{get-sorted-releases.js → get-sorted-releases.ts} +2 -2
  113. package/src/common/back/jira/interfaces/JiraIIssue.d.ts +3 -3
  114. package/src/common/back/jira/{jira-releases.js → jira-releases.ts} +14 -3
  115. package/src/common/back/jira/{jira-request.js → jira-request.ts} +9 -1
  116. package/src/common/back/jira/{jira-search.js → jira-search.ts} +2 -2
  117. package/src/common/cli/{bun.test.js → bun.test.ts} +17 -10
  118. package/src/common/cli/{bun.js → bun.ts} +4 -4
  119. package/src/common/cli/cli.ts +127 -0
  120. package/src/common/cli/{docker.test.js → docker.test.ts} +22 -14
  121. package/src/common/cli/{docker.js → docker.ts} +6 -6
  122. package/src/common/cli/{git.test.js → git.test.ts} +19 -11
  123. package/src/common/cli/{git.js → git.ts} +24 -24
  124. package/src/common/cli/{lerna.test.js → lerna.test.ts} +18 -11
  125. package/src/common/cli/{lerna.js → lerna.ts} +4 -4
  126. package/src/common/cli/{npm.test.js → npm.test.ts} +17 -10
  127. package/src/common/cli/{npm.js → npm.ts} +4 -4
  128. package/src/common/cli/{pnpm.test.js → pnpm.test.ts} +17 -10
  129. package/src/common/cli/{pnpm.js → pnpm.ts} +4 -4
  130. package/src/common/cli/{yarn.test.js → yarn.test.ts} +17 -12
  131. package/src/common/cli/{yarn.js → yarn.ts} +4 -4
  132. package/src/common/configure-git-workspace.ts +39 -0
  133. package/src/common/{get-config.js → get-config.ts} +3 -1
  134. package/src/common/{get-package-json.js → get-package-json.ts} +1 -0
  135. package/src/common/{get-package-manager.js → get-package-manager.ts} +1 -0
  136. package/src/common/{get-release-config.js → get-release-config.ts} +1 -0
  137. package/src/common/{index.js → index.ts} +1 -0
  138. package/src/common/{run-command.test.js → run-command.test.ts} +1 -0
  139. package/src/common/run-command.ts +67 -0
  140. package/src/common/types.ts +26 -0
  141. package/src/common/vendor.d.ts +4 -0
  142. package/src/{index.js → index.ts} +5 -1
  143. package/src/semantic/core/{analyze-commits.js → analyze-commits.ts} +7 -3
  144. package/src/semantic/core/{conditional.js → conditional.ts} +16 -9
  145. package/src/semantic/core/{exit.js → exit.ts} +3 -2
  146. package/src/semantic/core/prepare/{bump-version.js → bump-version.ts} +11 -8
  147. package/src/semantic/core/prepare/{commit.js → commit.ts} +3 -2
  148. package/src/semantic/core/prepare/release-info.ts +6 -0
  149. package/src/semantic/core/{run.js → run.ts} +3 -2
  150. package/src/semantic/core/sync-repository.ts +55 -0
  151. package/src/semantic/core/{verify-conditions.js → verify-conditions.ts} +4 -3
  152. package/src/semantic/core/{verify-release.js → verify-release.ts} +2 -1
  153. package/src/semantic/docker/publish.ts +6 -0
  154. package/src/semantic/docker/{success.js → success.ts} +2 -1
  155. package/src/semantic/utils/__mock__/test1/package.json +7 -1
  156. package/src/semantic/utils/__mock__/test1/packages/a/package.json +9 -1
  157. package/src/semantic/utils/__mock__/test1/packages/b/package.json +7 -1
  158. package/src/semantic/utils/{bump-packages-version.test.js → bump-packages-version.test.ts} +1 -0
  159. package/src/semantic/utils/{bump-packages-version.js → bump-packages-version.ts} +12 -11
  160. package/src/semantic/utils/{calculate-snapshot-version.test.js → calculate-snapshot-version.test.ts} +10 -8
  161. package/src/semantic/utils/calculate-snapshot-version.ts +17 -0
  162. package/src/semantic/utils/display-package-info.ts +12 -0
  163. package/src/semantic/utils/display-release-info.ts +13 -0
  164. package/src/semantic/utils/{docker-clean-tags.test.js → docker-clean-tags.test.ts} +1 -0
  165. package/src/semantic/utils/{docker-clean-tags.js → docker-clean-tags.ts} +11 -4
  166. package/src/semantic/utils/{docker-publish.test.js → docker-publish.test.ts} +1 -0
  167. package/src/semantic/utils/{docker-publish.js → docker-publish.ts} +4 -3
  168. package/src/semantic/utils/{log-section.js → log-section.ts} +5 -1
  169. package/src/semantic/utils/{transform-writer.js → transform-writer.ts} +37 -13
  170. package/tsconfig.build.json +29 -0
  171. package/tsconfig.json +8 -32
  172. package/tsdown.config.ts +63 -0
  173. package/vitest.config.mts +4 -5
  174. package/.prettierignore +0 -5
  175. package/.yarn/releases/yarn-4.7.0.cjs +0 -935
  176. package/bin/checkfeatures.sh +0 -5
  177. package/bin/cm-clean.js +0 -8
  178. package/bin/cm-config.js +0 -15
  179. package/bin/cm-deploy.js +0 -8
  180. package/bin/cm-fetch.js +0 -12
  181. package/bin/cm-finish.js +0 -14
  182. package/bin/cm-jira-releases.js +0 -16
  183. package/bin/cm-merge.js +0 -12
  184. package/bin/cm-publish.js +0 -15
  185. package/bin/cm-push.js +0 -15
  186. package/bin/cm-rebase.js +0 -15
  187. package/bin/cm-republish.js +0 -12
  188. package/bin/cm-start.js +0 -21
  189. package/bin/cm.js +0 -27
  190. package/bin/cmexpedit.sh +0 -9
  191. package/bin/cmpull.sh +0 -7
  192. package/eslint.config.mjs +0 -67
  193. package/src/commands/clean.js +0 -29
  194. package/src/commands/config.js +0 -23
  195. package/src/commands/deploy.js +0 -34
  196. package/src/commands/fetch.js +0 -18
  197. package/src/commands/finish.js +0 -43
  198. package/src/commands/jira-releases.js +0 -62
  199. package/src/commands/merge.js +0 -41
  200. package/src/commands/push.js +0 -23
  201. package/src/commands/rebase.js +0 -35
  202. package/src/commands/republish.js +0 -21
  203. package/src/commands/start.js +0 -109
  204. package/src/commands/tasks/push-branch.js +0 -10
  205. package/src/commands/tasks/run-test.js +0 -21
  206. package/src/common/cli/cli.js +0 -110
  207. package/src/common/configure-git-workspace.js +0 -26
  208. package/src/common/run-command.js +0 -64
  209. package/src/semantic/core/prepare/release-info.js +0 -5
  210. package/src/semantic/core/sync-repository.js +0 -52
  211. package/src/semantic/docker/publish.js +0 -5
  212. package/src/semantic/utils/calculate-snapshot-version.js +0 -15
  213. package/src/semantic/utils/display-package-info.js +0 -11
  214. package/src/semantic/utils/display-release-info.js +0 -12
  215. /package/src/commands/{release.js → release.ts} +0 -0
  216. /package/src/commands/utils/{check-install.js → check-install.ts} +0 -0
  217. /package/src/common/back/jira/{jira-request.spec.js → jira-request.spec.ts} +0 -0
  218. /package/src/common/back/jira/{jira-search.spec.js → jira-search.spec.ts} +0 -0
  219. /package/src/semantic/{define-config.js → define-config.ts} +0 -0
  220. /package/src/semantic/utils/{release-rules.js → release-rules.ts} +0 -0
  221. /package/src/workflow/{index.js → index.ts} +0 -0
@@ -1,109 +0,0 @@
1
- import chalk from "chalk";
2
- import figures from "figures";
3
-
4
- import { git } from "../common/cli/git.js";
5
- import { WORKFLOW_CONFIGURATION } from "../workflow/index.js";
6
- import { Fetch } from "./fetch.js";
7
- import { branches } from "./prompts/branches.js";
8
- import { updateDependencies } from "./tasks/update-dependencies.js";
9
-
10
- function sanitize(name) {
11
- return name
12
- .replace(/[/\\_|. ]/gi, "-")
13
- .split("-")
14
- .filter(Boolean)
15
- .join("-");
16
- }
17
-
18
- export class Start extends Fetch {
19
- mapContext(options, context) {
20
- options.branchName = options.branchName || "";
21
- const type = WORKFLOW_CONFIGURATION.map(({ type }) => type).find((t) => options.branchName.startsWith(`${t}-`));
22
-
23
- if (!options.branchName && options.jiraId) {
24
- options.branchName = options.jiraId;
25
- }
26
-
27
- if (options.branchName.startsWith("CMAB-")) {
28
- const [, key, ...rest] = options.branchName.split("-");
29
- options.jiraId = `CMAB-${key}`;
30
- options.branchName = rest.join("-");
31
- }
32
-
33
- return {
34
- ...context,
35
- origin: context.ORIGIN,
36
- jiraId: options.jiraId,
37
- branchName: options.branchName,
38
- type
39
- };
40
- }
41
-
42
- prompt(context) {
43
- return [
44
- {
45
- type: "input",
46
- name: "jiraId",
47
- message: "What is the Jira ID ? (leave blank to skip)",
48
- default: context.jiraId,
49
- when: !context.jiraId
50
- },
51
- {
52
- type: "list",
53
- name: "type",
54
- message: "Choose the type of your branch:",
55
- choices: ["fix", "feat", "chore", "docs", "tech"],
56
- default: context.type,
57
- when: !context.type && !context.jiraId
58
- },
59
- {
60
- type: "input",
61
- name: "branchName",
62
- message: "What is the branch name ?",
63
- validate(branch) {
64
- if (!branch.length) {
65
- return "Branch name is required";
66
- }
67
-
68
- if (git.branchExists(branch, context.origin)) {
69
- return `${branch} already exists`;
70
- }
71
-
72
- return true;
73
- },
74
-
75
- when: !context.branchName
76
- },
77
-
78
- branches(context)
79
- ];
80
- }
81
-
82
- getTasks(context) {
83
- context.branchName = sanitize(context.branchName);
84
-
85
- context.featureBranch = context.jiraId
86
- ? `${context.jiraId}-${context.branchName}`
87
- : context.branchName.includes(context.type + "-")
88
- ? context.branchName
89
- : `${context.type}-${context.branchName}`;
90
-
91
- context.fromBranch = context.fromBranch || context.PRODUCTION_BRANCH;
92
-
93
- return [
94
- ...super.getTasks(context),
95
- {
96
- title: `Create branch from ${chalk.green(context.fromBranch)}`,
97
- task: () => git.checkout("--no-track", "-b", context.featureBranch, context.fromBranch).toObservable()
98
- },
99
- updateDependencies(context)
100
- ];
101
- }
102
-
103
- success(context) {
104
- console.log(
105
- chalk.green(figures.tick),
106
- `New branch ${chalk.green(context.featureBranch)} created from ${chalk.green(context.fromBranch)} HEAD`
107
- );
108
- }
109
- }
@@ -1,10 +0,0 @@
1
- import { git } from "../../common/cli/git.js";
2
-
3
- export function pushBranch({ origin = "origin", featureBranch, upstream = true, noVerify = true }) {
4
- return {
5
- title: `Push ${featureBranch}`,
6
- task: () => {
7
- return git.push(...[upstream ? "-u" : "", "-f", origin, featureBranch, noVerify ? "--no-verify" : ""].filter(Boolean)).toObservable();
8
- }
9
- };
10
- }
@@ -1,21 +0,0 @@
1
- import { getPackageManager, git } from "../../common/index.js";
2
-
3
- export const runTest = ({ E2E_CMD, PACKAGE_MANAGER, skipTest, skipUnit, skipE2E }) => {
4
- return [
5
- {
6
- title: "Unit test",
7
- skip: () => skipTest || skipUnit,
8
- task: () => getPackageManager(PACKAGE_MANAGER).run("test")
9
- },
10
- {
11
- title: "E2E test",
12
- skip: () => skipTest || skipE2E,
13
- task: () => getPackageManager(PACKAGE_MANAGER).run(E2E_CMD || "test_e2e")
14
- },
15
- {
16
- title: "Reset changes",
17
- skip: () => skipTest,
18
- task: () => git.reset("--hard") // reset files updated unit test
19
- }
20
- ];
21
- };
@@ -1,110 +0,0 @@
1
- import "any-observable/register/rxjs-all.js";
2
-
3
- import { spawnSync } from "child_process";
4
- import execa from "execa";
5
- import { filter, fromEvent, map, merge, takeUntil } from "rxjs";
6
- export class Cli {
7
- constructor(cmd) {
8
- this.cmd = cmd;
9
- }
10
-
11
- sync(...args) {
12
- return Cli.run(this.cmd, args).sync();
13
- }
14
-
15
- run(...args) {
16
- return Cli.run(this.cmd, args);
17
- }
18
-
19
- get(...args) {
20
- return Cli.run(this.cmd, args).get();
21
- }
22
-
23
- static run(cmd, args = [], options = {}) {
24
- const run = (opt = {}) => {
25
- return execa(cmd, args, {
26
- cwd: process.cwd(),
27
- ...opt,
28
- ...options
29
- });
30
- };
31
-
32
- let isPromise = true;
33
-
34
- const promise = new Promise((resolve, reject) => {
35
- setTimeout(async () => {
36
- if (isPromise) {
37
- try {
38
- const result = await run({
39
- stdio: "inherit"
40
- });
41
-
42
- resolve(result);
43
- } catch (err) {
44
- reject(err);
45
- }
46
- } else {
47
- resolve();
48
- }
49
- }, 10);
50
- });
51
-
52
- promise.toObservable = (opt) => {
53
- isPromise = false;
54
- const cp = run(opt);
55
- const end$ = fromEvent(cp, "close");
56
- const stdout$ = fromEvent(cp.stdout, "data").pipe(
57
- takeUntil(end$),
58
- map((data) => data.toString())
59
- );
60
- const stderr$ = fromEvent(cp.stderr, "data").pipe(
61
- takeUntil(end$),
62
- map((data) => data.toString())
63
- );
64
-
65
- return merge(stdout$, stderr$).pipe(filter(Boolean));
66
- };
67
-
68
- promise.toStream = (opt) => {
69
- isPromise = false;
70
-
71
- return run(opt);
72
- };
73
-
74
- promise.cwd = (cwd) => {
75
- options.cwd = cwd;
76
- return promise;
77
- };
78
-
79
- promise.sync = (opt) => {
80
- isPromise = false;
81
- return execa.sync(cmd, args, {
82
- cwd: process.cwd(),
83
- stdio: "inherit",
84
- ...options,
85
- ...opt
86
- });
87
- };
88
-
89
- promise.getRaw = (opt) => {
90
- isPromise = false;
91
- return Cli.getRaw(cmd, args, {
92
- cwd: process.cwd(),
93
- ...options,
94
- ...opt
95
- });
96
- };
97
-
98
- promise.get = promise.getRaw;
99
-
100
- return promise;
101
- }
102
-
103
- static getRaw(cmd, args, options) {
104
- return spawnSync(cmd, args, options)
105
- .output.filter((o) => !!o)
106
- .map((o) => o.toString())
107
- .join("\n")
108
- .trim();
109
- }
110
- }
@@ -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,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,5 +0,0 @@
1
- import { writeFile } from "node:fs/promises";
2
-
3
- export function prepare(pluginConfig, context) {
4
- return writeFile(pluginConfig.path, context.branch.name, { encoding: "utf-8" });
5
- }
@@ -1,52 +0,0 @@
1
- import { getConfig, git } from "../../common/index.js";
2
-
3
- export default async function syncRepository(pluginConfig, context) {
4
- context.config = getConfig();
5
-
6
- const {
7
- logger,
8
- config: { PRODUCTION_BRANCH, ORIGIN, DEVELOP_BRANCH }
9
- } = context;
10
-
11
- logger.info("Prepare release");
12
-
13
- async function asyncCatchError(fn) {
14
- try {
15
- return await fn();
16
- } catch (er) {
17
- context.logger.error(String(er), er.stack);
18
- }
19
- }
20
-
21
- await asyncCatchError(() => git.fetch());
22
-
23
- const candidateBranches =
24
- pluginConfig.includes ||
25
- context.options.branches?.map((branch) => {
26
- return branch.name || branch;
27
- });
28
-
29
- logger.info(`Candidate branches to sync: ${candidateBranches.join(", ")}`);
30
-
31
- if (candidateBranches.includes(context.branch.name)) {
32
- logger.info(`Push ${context.branch.name}`);
33
-
34
- await asyncCatchError(() => {
35
- logger.info(`git push --quiet --set-upstream ${ORIGIN} ${context.branch.name}`);
36
-
37
- return git.push("--quiet", "--set-upstream", ORIGIN, context.branch.name);
38
- });
39
- } else {
40
- logger.info(`Skip push for ${context.branch.name}`);
41
- }
42
-
43
- if (PRODUCTION_BRANCH !== DEVELOP_BRANCH) {
44
- logger.info(`Sync ${DEVELOP_BRANCH} with ${PRODUCTION_BRANCH}`);
45
- logger.info(`git push -f ${ORIGIN} ${PRODUCTION_BRANCH}:refs/heads/${DEVELOP_BRANCH}`);
46
-
47
- await asyncCatchError(async () => {
48
- await git.push("-f", ORIGIN, `${PRODUCTION_BRANCH}:refs/heads/${DEVELOP_BRANCH}`);
49
- logger.success(`${ORIGIN}/${DEVELOP_BRANCH} branch correctly updated`);
50
- });
51
- }
52
- }
@@ -1,5 +0,0 @@
1
- import { dockerPublish } from "../utils/docker-publish.js";
2
-
3
- export async function publish(pluginConfig, context) {
4
- await dockerPublish(context);
5
- }
@@ -1,15 +0,0 @@
1
- import semver from "semver";
2
-
3
- import { getConfig, git } from "../../common/index.js";
4
-
5
- export function calculateSnapshotVersion(context) {
6
- context.config = getConfig();
7
- const {
8
- nextRelease: { type },
9
- lastRelease,
10
- config: { REF_COMMIT }
11
- } = context;
12
- const { major, minor, patch } = semver.parse(lastRelease.version);
13
-
14
- return `${semver.inc(`${major}.${minor}.${patch}`, type)}-beta${git.getCommitTag(REF_COMMIT)}`;
15
- }
@@ -1,11 +0,0 @@
1
- import { logSection } from "./log-section.js";
2
-
3
- export function displayPackageInfo(context) {
4
- logSection("Package Info", context);
5
- context.logger.info("Name : " + context.config.PROJECT_NAME);
6
- context.logger.info("Version : " + context.lastRelease.version);
7
- context.logger.info("Repository : " + context.config.REPOSITORY_URL);
8
- context.logger.info("Branch : " + context.branch.name);
9
- context.logger.info("Tag : " + context.lastRelease.gitTag);
10
- context.logger.info("GitHead : " + context.lastRelease.gitHead);
11
- }
@@ -1,12 +0,0 @@
1
- import { logSection } from "./log-section.js";
2
-
3
- export function displayReleaseInfo(context) {
4
- logSection("Release Info", context);
5
- context.logger.info("Branch : " + context.branch.name);
6
- context.logger.info("Build N° : " + context.config.BUILD_NUMBER);
7
- context.logger.info("Version : " + context.nextRelease.version);
8
- context.logger.info("Tag : " + context.nextRelease.gitTag);
9
- context.logger.info("GitHead : " + context.nextRelease.gitHead);
10
- context.logger.info("Type : " + context.nextRelease.type);
11
- context.logger.info("Channel : " + context.nextRelease.channel);
12
- }
File without changes
File without changes