@cmflow/cli 1.0.16 → 1.1.1-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 (124) hide show
  1. package/.prettierignore +5 -0
  2. package/.prettierrc +10 -0
  3. package/README.md +106 -32
  4. package/bin/cm-changelog.js +20 -12
  5. package/bin/cm-clean.js +4 -7
  6. package/bin/cm-config.js +8 -8
  7. package/bin/cm-deploy.js +4 -8
  8. package/bin/cm-fetch.js +7 -7
  9. package/bin/cm-finish.js +9 -9
  10. package/bin/cm-merge.js +7 -7
  11. package/bin/cm-publish.js +10 -10
  12. package/bin/cm-push.js +10 -10
  13. package/bin/cm-rebase.js +10 -10
  14. package/bin/cm-republish.js +7 -7
  15. package/bin/cm-start.js +10 -10
  16. package/bin/cm.js +20 -20
  17. package/bin/cmrelease.js +2 -2
  18. package/eslint.config.mjs +67 -0
  19. package/package.json +27 -21
  20. package/release.config.mjs +49 -19
  21. package/src/commands/changelog.js +23 -23
  22. package/src/commands/clean.js +13 -13
  23. package/src/commands/config.js +8 -8
  24. package/src/commands/deploy.js +15 -20
  25. package/src/commands/fetch.js +7 -10
  26. package/src/commands/finish.js +18 -19
  27. package/src/commands/index.js +10 -11
  28. package/src/commands/merge.js +30 -14
  29. package/src/commands/prompts/branches.js +20 -20
  30. package/src/commands/push.js +11 -14
  31. package/src/commands/rebase.js +17 -19
  32. package/src/commands/release.js +10 -11
  33. package/src/commands/republish.js +11 -14
  34. package/src/commands/start.js +66 -38
  35. package/src/commands/tasks/merge-branch.js +41 -37
  36. package/src/commands/tasks/push-branch.js +5 -11
  37. package/src/commands/tasks/rebase-all-branches.js +19 -24
  38. package/src/commands/tasks/refresh-repository.js +26 -24
  39. package/src/commands/tasks/run-test.js +11 -17
  40. package/src/commands/tasks/update-branch.js +33 -30
  41. package/src/commands/tasks/update-dependencies.js +38 -32
  42. package/src/commands/utils/check-install.js +16 -15
  43. package/src/common/cli/cli.js +55 -57
  44. package/src/common/cli/docker.js +31 -28
  45. package/src/common/cli/docker.test.js +94 -96
  46. package/src/common/cli/git.js +59 -68
  47. package/src/common/cli/git.test.js +187 -189
  48. package/src/common/cli/lerna.js +12 -12
  49. package/src/common/cli/lerna.test.js +38 -40
  50. package/src/common/cli/npm.js +17 -17
  51. package/src/common/cli/npm.test.js +38 -40
  52. package/src/common/cli/yarn.js +17 -17
  53. package/src/common/cli/yarn.test.js +40 -40
  54. package/src/common/configure-git-workspace.js +11 -17
  55. package/src/common/get-config.js +63 -119
  56. package/src/common/get-package-json.js +4 -4
  57. package/src/common/get-release-config.js +4 -5
  58. package/src/common/index.js +10 -10
  59. package/src/common/run-command.js +26 -28
  60. package/src/common/run-command.test.js +35 -39
  61. package/src/index.js +10 -1
  62. package/src/semantic/core/analyze-commits.js +17 -0
  63. package/src/semantic/core/fail.js +29 -0
  64. package/src/semantic/core/generate-notes.js +11 -0
  65. package/src/semantic/core/prepare/bump-version.js +38 -0
  66. package/src/semantic/core/prepare/post.js +38 -0
  67. package/src/semantic/core/prepare/run.js +22 -0
  68. package/src/semantic/core/publish.js +9 -0
  69. package/src/semantic/core/success.js +37 -0
  70. package/src/semantic/core/verify-conditions.js +32 -0
  71. package/src/semantic/core/verify-release.js +9 -0
  72. package/src/semantic/define-config.js +68 -0
  73. package/src/semantic/docker/publish.js +5 -0
  74. package/src/semantic/docker/success.js +9 -0
  75. package/src/semantic/utils/bump-packages-version.js +52 -0
  76. package/src/semantic/utils/bump-packages-version.test.js +75 -0
  77. package/src/semantic/utils/calculate-snapshot-version.js +15 -0
  78. package/src/semantic/utils/calculate-snapshot-version.test.js +67 -0
  79. package/src/semantic/utils/display-package-info.js +11 -0
  80. package/src/semantic/utils/display-release-info.js +12 -0
  81. package/src/semantic/utils/docker-clean-tags.js +51 -0
  82. package/src/semantic/utils/docker-clean-tags.test.js +61 -0
  83. package/src/semantic/utils/docker-publish.js +23 -0
  84. package/src/semantic/utils/docker-publish.test.js +44 -0
  85. package/src/semantic/utils/log-section.js +5 -0
  86. package/src/semantic/utils/release-rules.js +5 -0
  87. package/src/semantic/utils/transform-writer.js +75 -0
  88. package/src/workflow/index.js +22 -22
  89. package/tsconfig.json +54 -0
  90. package/vitest.config.mts +10 -0
  91. package/bin/cm-publish-pages.js +0 -12
  92. package/semantic.js +0 -1
  93. package/src/commands/publish-pages.js +0 -29
  94. package/src/common/cli/heroku.js +0 -21
  95. package/src/common/cli/heroku.test.js +0 -62
  96. package/src/main.js +0 -10
  97. package/src/semantic-release/actions/analyze-commits.js +0 -14
  98. package/src/semantic-release/actions/fail.js +0 -16
  99. package/src/semantic-release/actions/generate-notes.js +0 -12
  100. package/src/semantic-release/actions/index.js +0 -8
  101. package/src/semantic-release/actions/prepare.js +0 -114
  102. package/src/semantic-release/actions/publish.js +0 -17
  103. package/src/semantic-release/actions/success.js +0 -32
  104. package/src/semantic-release/actions/verify-conditions.js +0 -30
  105. package/src/semantic-release/actions/verify-release.js +0 -9
  106. package/src/semantic-release/get-semantic-config.js +0 -115
  107. package/src/semantic-release/utils/bump-packages-version.js +0 -51
  108. package/src/semantic-release/utils/bump-packages-version.test.js +0 -78
  109. package/src/semantic-release/utils/calculate-snapshot-version.js +0 -10
  110. package/src/semantic-release/utils/calculate-snapshot-version.test.js +0 -69
  111. package/src/semantic-release/utils/display-package-info.js +0 -11
  112. package/src/semantic-release/utils/display-release-info.js +0 -12
  113. package/src/semantic-release/utils/docker-clean-tags.js +0 -45
  114. package/src/semantic-release/utils/docker-clean-tags.test.js +0 -63
  115. package/src/semantic-release/utils/docker-publish.js +0 -47
  116. package/src/semantic-release/utils/docker-publish.test.js +0 -67
  117. package/src/semantic-release/utils/ghpages-publish.js +0 -16
  118. package/src/semantic-release/utils/log-section.js +0 -5
  119. /package/src/{semantic-release → semantic}/utils/__mock__/test1/package.json +0 -0
  120. /package/src/{semantic-release → semantic}/utils/__mock__/test1/packages/a/package.json +0 -0
  121. /package/src/{semantic-release → semantic}/utils/__mock__/test1/packages/b/package.json +0 -0
  122. /package/src/{semantic-release → semantic}/utils/__mock__/test2/package.json +0 -0
  123. /package/src/{semantic-release → semantic}/utils/__mock__/test2/packages/a/package.json +0 -0
  124. /package/src/{semantic-release → semantic}/utils/__mock__/test2/packages/b/package.json +0 -0
@@ -1,13 +1,14 @@
1
- import chalk from 'chalk'
2
- import figures from 'figures'
3
- import { Fetch } from './fetch.js'
4
- import { git } from '../common/cli/git.js'
5
- import { updateBranch } from './tasks/update-branch.js'
6
- import { updateDependencies } from './tasks/update-dependencies.js'
7
- import { runTest } from './tasks/run-test.js'
1
+ import chalk from "chalk";
2
+ import figures from "figures";
3
+
4
+ import { git } from "../common/cli/git.js";
5
+ import { Fetch } from "./fetch.js";
6
+ import { runTest } from "./tasks/run-test.js";
7
+ import { updateBranch } from "./tasks/update-branch.js";
8
+ import { updateDependencies } from "./tasks/update-dependencies.js";
8
9
 
9
10
  export class Rebase extends Fetch {
10
- mapContext (commander, context) {
11
+ mapContext(commander, context) {
11
12
  return {
12
13
  ...context,
13
14
  useYarn: context.HAS_YARN,
@@ -19,20 +20,17 @@ export class Rebase extends Fetch {
19
20
  skipTest: !commander.cucumber && !commander.unitTest,
20
21
  skipUnit: !commander.unitTest,
21
22
  skipE2E: context.HAS_E2E ? !commander.cucumber : true
22
- }
23
+ };
23
24
  }
24
25
 
25
- getTasks (context) {
26
- return [
27
- ...super.getTasks(context),
28
- updateBranch(context),
29
- updateDependencies(context),
30
- ...runTest(context)
31
- ]
26
+ getTasks(context) {
27
+ return [...super.getTasks(context), updateBranch(context), updateDependencies(context), ...runTest(context)];
32
28
  }
33
29
 
34
- success (context) {
35
- // eslint-disable-next-line no-console
36
- console.log(chalk.green(figures.tick), `Branch ${chalk.green(context.featureBranch)} rebased from ${chalk.green(context.fromBranch)} HEAD`)
30
+ success(context) {
31
+ console.log(
32
+ chalk.green(figures.tick),
33
+ `Branch ${chalk.green(context.featureBranch)} rebased from ${chalk.green(context.fromBranch)} HEAD`
34
+ );
37
35
  }
38
36
  }
@@ -1,22 +1,21 @@
1
- import semantic_release from 'semantic-release'
1
+ import semantic_release from "semantic-release";
2
2
 
3
- delete process.env.CIRCLE_PR_NUMBER
4
- delete process.env.CIRCLE_PULL_REQUEST
5
- delete process.env.CI_PULL_REQUEST
3
+ delete process.env.CIRCLE_PR_NUMBER;
4
+ delete process.env.CIRCLE_PULL_REQUEST;
5
+ delete process.env.CI_PULL_REQUEST;
6
6
 
7
- export function release (options = {}) {
7
+ export function release(options = {}) {
8
8
  semantic_release({
9
- dryRun: process.argv.includes('--dry-run'),
9
+ dryRun: process.argv.includes("--dry-run"),
10
10
  ci: false,
11
11
  noCi: true,
12
12
  ...options
13
13
  })
14
14
  .then(() => {
15
- process.exitCode = 0
15
+ process.exitCode = 0;
16
16
  })
17
17
  .catch((err) => {
18
- // eslint-disable-next-line no-console
19
- console.log('Error while releasing', err)
20
- process.exitCode = 1
21
- })
18
+ console.log("Error while releasing", err);
19
+ process.exitCode = 1;
20
+ });
22
21
  }
@@ -1,24 +1,21 @@
1
- import chalk from 'chalk'
2
- import figures from 'figures'
3
- import { Fetch } from './fetch.js'
4
- import { rebaseAllBranches } from './tasks/rebase-all-branches.js'
1
+ import chalk from "chalk";
2
+ import figures from "figures";
3
+
4
+ import { Fetch } from "./fetch.js";
5
+ import { rebaseAllBranches } from "./tasks/rebase-all-branches.js";
5
6
 
6
7
  export class Republish extends Fetch {
7
- mapContext (commander, context) {
8
+ mapContext(commander, context) {
8
9
  return {
9
10
  ...super.mapContext(commander, context)
10
- }
11
+ };
11
12
  }
12
13
 
13
- getTasks (context) {
14
- return [
15
- ...super.getTasks(context),
16
- rebaseAllBranches(context)
17
- ]
14
+ getTasks(context) {
15
+ return [...super.getTasks(context), rebaseAllBranches(context)];
18
16
  }
19
17
 
20
- success (context) {
21
- // eslint-disable-next-line no-console
22
- console.log(chalk.green(figures.tick), 'All branches rebased and pushed.')
18
+ success() {
19
+ console.log(chalk.green(figures.tick), "All branches rebased and pushed.");
23
20
  }
24
21
  }
@@ -1,82 +1,110 @@
1
- import chalk from 'chalk'
2
- import figures from 'figures'
3
- import { git } from '../common/cli/git.js'
4
- import { branches } from './prompts/branches.js'
5
- import { Fetch } from './fetch.js'
1
+ import chalk from "chalk";
2
+ import figures from "figures";
6
3
 
7
- import { updateDependencies } from './tasks/update-dependencies.js'
8
- import { WORKFLOW_CONFIGURATION } from '../workflow/index.js'
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
9
 
10
- function sanitize (name) {
11
- return name.replace(/[/\\_|. ]/gi, '-').split('-').filter(Boolean).join('-')
10
+ function sanitize(name) {
11
+ return name
12
+ .replace(/[/\\_|. ]/gi, "-")
13
+ .split("-")
14
+ .filter(Boolean)
15
+ .join("-");
12
16
  }
13
17
 
14
18
  export class Start extends Fetch {
15
- mapContext (options, context) {
16
- options.branchName = options.branchName || ''
17
- const type = WORKFLOW_CONFIGURATION
18
- .map(({ type }) => type)
19
- .find((t) => options.branchName.startsWith(`${t}-`))
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
+ }
20
32
 
21
33
  return {
22
34
  ...context,
23
35
  useYarn: context.HAS_YARN,
24
36
  origin: context.ORIGIN,
37
+ jiraId: options.jiraId,
25
38
  branchName: options.branchName,
26
39
  type
27
- }
40
+ };
28
41
  }
29
42
 
30
- prompt (context) {
43
+ prompt(context) {
31
44
  return [
32
45
  {
33
- type: 'list',
34
- name: 'type',
35
- message: 'Choose the type of your branch:',
36
- choices: ['fix', 'feat', 'chore', 'docs', 'tech'],
46
+ type: "input",
47
+ name: "jiraId",
48
+ message: "What is the Jira ID ? (leave blank to skip)",
49
+ default: context.jiraId,
50
+ when: !context.jiraId
51
+ },
52
+ {
53
+ type: "list",
54
+ name: "type",
55
+ message: "Choose the type of your branch:",
56
+ choices: ["fix", "feat", "chore", "docs", "tech"],
37
57
  default: context.type,
38
- when: !context.type
58
+ when: !context.type && !context.jiraId
39
59
  },
40
60
  {
41
- type: 'input',
42
- name: 'branchName',
43
- message: 'What is the branch name ?',
44
- validate (branch) {
61
+ type: "input",
62
+ name: "branchName",
63
+ message: "What is the branch name ?",
64
+ validate(branch) {
45
65
  if (!branch.length) {
46
- return 'Branch name is required'
66
+ return "Branch name is required";
47
67
  }
48
68
 
49
69
  if (git.branchExists(branch, context.origin)) {
50
- return `${branch} already exists`
70
+ return `${branch} already exists`;
51
71
  }
52
72
 
53
- return true
73
+ return true;
54
74
  },
55
75
 
56
76
  when: !context.branchName
57
77
  },
58
78
 
59
79
  branches(context)
60
- ]
80
+ ];
61
81
  }
62
82
 
63
- getTasks (context) {
64
- context.branchName = sanitize(context.branchName)
65
- context.featureBranch = context.branchName.includes(context.type + '-') ? context.branchName : `${context.type}-${context.branchName}`
66
- context.fromBranch = context.fromBranch || context.PRODUCTION_BRANCH
83
+ getTasks(context) {
84
+ context.branchName = sanitize(context.branchName);
85
+
86
+ context.featureBranch = context.jiraId
87
+ ? `${context.jiraId}-${context.branchName}`
88
+ : context.branchName.includes(context.type + "-")
89
+ ? context.branchName
90
+ : `${context.type}-${context.branchName}`;
91
+
92
+ context.fromBranch = context.fromBranch || context.PRODUCTION_BRANCH;
67
93
 
68
94
  return [
69
95
  ...super.getTasks(context),
70
96
  {
71
97
  title: `Create branch from ${chalk.green(context.fromBranch)}`,
72
- task: () => git.checkout('--no-track', '-b', context.featureBranch, context.fromBranch).toObservable()
98
+ task: () => git.checkout("--no-track", "-b", context.featureBranch, context.fromBranch).toObservable()
73
99
  },
74
100
  updateDependencies(context)
75
- ]
101
+ ];
76
102
  }
77
103
 
78
- success (context) {
79
- // eslint-disable-next-line no-console
80
- console.log(chalk.green(figures.tick), `New branch ${chalk.green(context.featureBranch)} created from ${chalk.green(context.fromBranch)} HEAD`)
104
+ success(context) {
105
+ console.log(
106
+ chalk.green(figures.tick),
107
+ `New branch ${chalk.green(context.featureBranch)} created from ${chalk.green(context.fromBranch)} HEAD`
108
+ );
81
109
  }
82
110
  }
@@ -1,61 +1,65 @@
1
- import { git } from '../../common/index.js'
1
+ import { git } from "../../common/index.js";
2
2
 
3
- function setGHToken (context) {
3
+ function setGHToken(context) {
4
4
  const {
5
5
  logger,
6
- config: { GH_TOKEN, REPOSITORY_URL, ORIGIN }
7
- } = context
6
+ config: { SCM_TOKEN, REPOSITORY_URL, ORIGIN }
7
+ } = context;
8
8
 
9
- if (GH_TOKEN) {
10
- const repository = REPOSITORY_URL.replace('https://', '')
9
+ if (SCM_TOKEN) {
10
+ const repository = REPOSITORY_URL.replace("https://", "");
11
11
 
12
- logger.info(`Configure remote repository ${repository}`)
13
- git.remote('remove', ORIGIN).sync()
14
- git.remote('add', ORIGIN, `https://${GH_TOKEN}@${repository}`).sync()
12
+ logger.info(`Configure remote repository ${repository}`);
13
+ git.remote("remove", ORIGIN).sync();
14
+ git.remote("add", ORIGIN, `https://${SCM_TOKEN}@${repository}`).sync();
15
15
  }
16
16
  }
17
17
 
18
- async function gitMep (context) {
19
- const { logger, branch, config: { PRODUCTION_BRANCH, ORIGIN } } = context
18
+ async function gitMep(context) {
19
+ const {
20
+ logger,
21
+ branch,
22
+ config: { PRODUCTION_BRANCH, ORIGIN }
23
+ } = context;
20
24
 
21
- logger.info(`Branch ${branch.name} is candidate to MEP`)
25
+ logger.info(`Branch ${branch.name} is candidate to MEP`);
22
26
 
23
- git.reset('--hard')
24
- git.clean('-f', '-d').sync()
27
+ git.reset("--hard");
28
+ git.clean("-f", "-d").sync();
25
29
 
26
- logger.info('Checkout production branch')
30
+ logger.info("Checkout production branch");
27
31
 
28
- git.config('--replace-all', 'remote.origin.fetch', '+refs/heads/*:refs/remotes/origin/*')
29
- git.fetch().sync()
30
- git.fetch('--tags').sync()
31
- git.checkout('-qf', PRODUCTION_BRANCH).sync()
32
+ git.config("--replace-all", "remote.origin.fetch", "+refs/heads/*:refs/remotes/origin/*");
33
+ git.fetch().sync();
34
+ git.fetch("--tags").sync();
35
+ git.checkout("-qf", PRODUCTION_BRANCH).sync();
32
36
 
33
- logger.info(`Current branch: ${PRODUCTION_BRANCH}`)
37
+ logger.info(`Current branch: ${PRODUCTION_BRANCH}`);
34
38
 
35
- const building = git.getLastCommitMsg()
36
- logger.info('Last commit message on production', building)
39
+ const building = git.getLastCommitMsg();
40
+ logger.info("Last commit message on production", building);
37
41
 
38
- logger.info(`Merge ${branch.name} into ${PRODUCTION_BRANCH} branch`)
39
- git.merge('--no-ff', '-m', `${branch.name}`, branch.name)
40
- logger.info(`${branch.name} merged into ${PRODUCTION_BRANCH} branch`)
42
+ logger.info(`Merge ${branch.name} into ${PRODUCTION_BRANCH} branch`);
43
+ git.merge("--no-ff", "-m", `${branch.name}`, branch.name);
44
+ logger.info(`${branch.name} merged into ${PRODUCTION_BRANCH} branch`);
41
45
 
42
- setGHToken(context)
46
+ setGHToken(context);
43
47
 
44
- logger.info(`Push ${PRODUCTION_BRANCH} branch`)
45
- await git.push(ORIGIN, PRODUCTION_BRANCH)
46
- logger.info(`${PRODUCTION_BRANCH} branch pushed`)
48
+ logger.info(`Push ${PRODUCTION_BRANCH} branch`);
49
+ await git.push(ORIGIN, PRODUCTION_BRANCH);
50
+ logger.info(`${PRODUCTION_BRANCH} branch pushed`);
47
51
 
48
- logger.info(`Remove ${ORIGIN}/${branch.name} branch`)
49
- await git.push(ORIGIN, ':' + branch.name)
50
- logger.info(`${ORIGIN}/${branch.name} branch correctly removed`)
52
+ logger.info(`Remove ${ORIGIN}/${branch.name} branch`);
53
+ await git.push(ORIGIN, ":" + branch.name);
54
+ logger.info(`${ORIGIN}/${branch.name} branch correctly removed`);
51
55
  }
52
56
 
53
- export function mergeBranch (context) {
54
- const { BRANCH_NAME, PRODUCTION_BRANCH } = context
55
- return ({
57
+ export function mergeBranch(context) {
58
+ const { BRANCH_NAME, PRODUCTION_BRANCH } = context;
59
+ return {
56
60
  title: `Merge ${BRANCH_NAME} into ${PRODUCTION_BRANCH}`,
57
61
  task: async () => {
58
- await gitMep(context)
62
+ await gitMep(context);
59
63
  }
60
- })
64
+ };
61
65
  }
@@ -1,16 +1,10 @@
1
- import { git } from '../../common/cli/git.js'
1
+ import { git } from "../../common/cli/git.js";
2
2
 
3
- export function pushBranch ({ origin = 'origin', featureBranch, upstream = true, noVerify = true }) {
4
- return ({
3
+ export function pushBranch({ origin = "origin", featureBranch, upstream = true, noVerify = true }) {
4
+ return {
5
5
  title: `Push ${featureBranch}`,
6
6
  task: () => {
7
- return git.push(...[
8
- upstream ? '-u' : '',
9
- '-f',
10
- origin,
11
- featureBranch,
12
- noVerify ? '--no-verify' : ''
13
- ].filter(Boolean)).toObservable()
7
+ return git.push(...[upstream ? "-u" : "", "-f", origin, featureBranch, noVerify ? "--no-verify" : ""].filter(Boolean)).toObservable();
14
8
  }
15
- })
9
+ };
16
10
  }
@@ -1,34 +1,29 @@
1
- import { git } from '../../common/cli/git.js'
1
+ import { git } from "../../common/cli/git.js";
2
2
 
3
- export function rebaseAllBranches (context) {
4
- const { origin = 'origin', upstream = true, noVerify = true } = context
5
- return ({
6
- title: 'Rebase all branches',
3
+ export function rebaseAllBranches(context) {
4
+ const { origin = "origin", upstream = true, noVerify = true } = context;
5
+ return {
6
+ title: "Rebase all branches",
7
7
  task: async () => {
8
- const remoteBranches = git.branches('-r')
9
- .filter(b => !new RegExp(`${context.PRODUCTION_BRANCH}|${context.DEVELOP_BRANCH}`).test(b))
8
+ const remoteBranches = git
9
+ .branches("-r")
10
+ .filter((b) => !new RegExp(`${context.PRODUCTION_BRANCH}|${context.DEVELOP_BRANCH}`).test(b));
10
11
  for (const remoteBranch of remoteBranches) {
11
- const branch = remoteBranch.split('/')[1]
12
+ const branch = remoteBranch.split("/")[1];
12
13
  try {
13
- await git.branch('-D', branch)
14
- } catch (e) {}
14
+ await git.branch("-D", branch);
15
+ } catch {}
15
16
  try {
16
- await git.checkout('--track', remoteBranch)
17
- await git.rebase(`${origin}/${context.PRODUCTION_BRANCH}`)
18
- await git.push(...[
19
- upstream ? '-u' : '',
20
- '-f',
21
- origin,
22
- branch,
23
- noVerify ? '--no-verify' : ''
24
- ].filter(Boolean))
25
- } catch (e) {
17
+ await git.checkout("--track", remoteBranch);
18
+ await git.rebase(`${origin}/${context.PRODUCTION_BRANCH}`);
19
+ await git.push(...[upstream ? "-u" : "", "-f", origin, branch, noVerify ? "--no-verify" : ""].filter(Boolean));
20
+ } catch {
26
21
  try {
27
- await git.rebase('--abort')
28
- await git.reset('--hard')
29
- } catch (e) {}
22
+ await git.rebase("--abort");
23
+ await git.reset("--hard");
24
+ } catch {}
30
25
  }
31
26
  }
32
27
  }
33
- })
28
+ };
34
29
  }
@@ -1,32 +1,34 @@
1
- import { catchError, EMPTY } from 'rxjs'
2
- import Listr from 'listr'
3
- import { git } from '../../common/index.js'
1
+ import Listr from "listr";
2
+ import { catchError, EMPTY } from "rxjs";
4
3
 
5
- function pipe (observable, output) {
6
- observable.pipe(catchError((err) => {
7
- output.push(err)
8
- return EMPTY
9
- }))
4
+ import { git } from "../../common/index.js";
10
5
 
11
- observable.subscribe(result => {
12
- output.push(result)
13
- })
6
+ function pipe(observable, output) {
7
+ observable.pipe(
8
+ catchError((err) => {
9
+ output.push(err);
10
+ return EMPTY;
11
+ })
12
+ );
14
13
 
15
- return observable
14
+ observable.subscribe((result) => {
15
+ output.push(result);
16
+ });
17
+
18
+ return observable;
16
19
  }
17
20
 
18
- export function refreshRepository (context) {
19
- const {
20
- output = []
21
- } = context
21
+ export function refreshRepository(context) {
22
+ const { output = [] } = context;
22
23
 
23
24
  return {
24
- title: 'Refresh local repository',
25
- task: () => new Listr([
26
- {
27
- title: 'Git fetch',
28
- task: () => pipe(git.fetch('--prune').toObservable(), output)
29
- }
30
- ])
31
- }
25
+ title: "Refresh local repository",
26
+ task: () =>
27
+ new Listr([
28
+ {
29
+ title: "Git fetch",
30
+ task: () => pipe(git.fetch("--prune").toObservable(), output)
31
+ }
32
+ ])
33
+ };
32
34
  }
@@ -1,29 +1,23 @@
1
- import { git, npm, yarn } from '../../common/index.js'
1
+ import { git, npm, yarn } from "../../common/index.js";
2
2
 
3
- export const runTest = ({
4
- E2E_CMD,
5
- useYarn,
6
- skipTest,
7
- skipUnit,
8
- skipE2E
9
- }) => {
10
- const manager = useYarn ? yarn : npm
3
+ export const runTest = ({ E2E_CMD, useYarn, skipTest, skipUnit, skipE2E }) => {
4
+ const manager = useYarn ? yarn : npm;
11
5
 
12
6
  return [
13
7
  {
14
- title: 'Unit test',
8
+ title: "Unit test",
15
9
  skip: () => skipTest || skipUnit,
16
- task: () => manager.run('test')
10
+ task: () => manager.run("test")
17
11
  },
18
12
  {
19
- title: 'E2E test',
13
+ title: "E2E test",
20
14
  skip: () => skipTest || skipE2E,
21
- task: () => manager.run(E2E_CMD || 'test_e2e')
15
+ task: () => manager.run(E2E_CMD || "test_e2e")
22
16
  },
23
17
  {
24
- title: 'Reset changes',
18
+ title: "Reset changes",
25
19
  skip: () => skipTest,
26
- task: () => git.reset('--hard') // reset files updated unit test
20
+ task: () => git.reset("--hard") // reset files updated unit test
27
21
  }
28
- ]
29
- }
22
+ ];
23
+ };
@@ -1,40 +1,43 @@
1
- import chalk from 'chalk'
2
- import Listr from 'listr'
3
- import { git } from '../../common/cli/git.js'
1
+ import chalk from "chalk";
2
+ import Listr from "listr";
4
3
 
5
- async function checkBranchRemoteStatus ({ featureBranch, origin, force }) {
6
- const isBranchExists = git.branchExists(featureBranch, origin)
4
+ import { git } from "../../common/cli/git.js";
5
+
6
+ async function checkBranchRemoteStatus({ featureBranch, origin, force }) {
7
+ const isBranchExists = git.branchExists(featureBranch, origin);
7
8
 
8
9
  if (isBranchExists && !force) {
9
- const result = git.checkBranchRemoteStatus(featureBranch)
10
+ const result = git.checkBranchRemoteStatus(featureBranch);
10
11
 
11
12
  if (result) {
12
- throw new Error('Remote branch changed, check diff before continue')
13
+ throw new Error("Remote branch changed, check diff before continue");
13
14
  }
14
15
  }
15
16
  }
16
17
 
17
18
  export const updateBranch = ({ origin, featureBranch, fromBranch, force, checkStatus = true, rebase = true }) => {
18
- return ({
19
- title: 'Rebase branch',
20
- task: () => new Listr(
21
- [
22
- {
23
- title: 'Check status',
24
- enabled: () => checkStatus,
25
- task: () => checkBranchRemoteStatus({
26
- force,
27
- featureBranch,
28
- origin
29
- })
30
- },
31
- {
32
- title: `Rebase from ${origin}/${chalk.green(fromBranch)}`,
33
- enabled: () => rebase,
34
- task: () => git.rebase(`${origin}/${fromBranch}`).toObservable()
35
- }
36
- ],
37
- { concurrent: false }
38
- )
39
- })
40
- }
19
+ return {
20
+ title: "Rebase branch",
21
+ task: () =>
22
+ new Listr(
23
+ [
24
+ {
25
+ title: "Check status",
26
+ enabled: () => checkStatus,
27
+ task: () =>
28
+ checkBranchRemoteStatus({
29
+ force,
30
+ featureBranch,
31
+ origin
32
+ })
33
+ },
34
+ {
35
+ title: `Rebase from ${origin}/${chalk.green(fromBranch)}`,
36
+ enabled: () => rebase,
37
+ task: () => git.rebase(`${origin}/${fromBranch}`).toObservable()
38
+ }
39
+ ],
40
+ { concurrent: false }
41
+ )
42
+ };
43
+ };