@cmflow/cli 1.1.0 → 2.0.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 (124) hide show
  1. package/.prettierignore +5 -0
  2. package/.prettierrc +10 -0
  3. package/README.md +130 -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 +36 -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 +52 -48
  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/conditional.js +25 -0
  64. package/src/semantic/core/fail.js +21 -0
  65. package/src/semantic/core/generate-notes.js +11 -0
  66. package/src/semantic/core/prepare/bump-version.js +38 -0
  67. package/src/semantic/core/prepare/post.js +38 -0
  68. package/src/semantic/core/prepare/run.js +22 -0
  69. package/src/semantic/core/success.js +33 -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 +15 -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,26 +1,23 @@
1
- import chalk from 'chalk'
2
- import figures from 'figures'
3
- import { Rebase } from './rebase.js'
4
- import { pushBranch } from './tasks/push-branch.js'
1
+ import chalk from "chalk";
2
+ import figures from "figures";
3
+
4
+ import { Rebase } from "./rebase.js";
5
+ import { pushBranch } from "./tasks/push-branch.js";
5
6
 
6
7
  export class Push extends Rebase {
7
- mapContext (commander, context) {
8
+ mapContext(commander, context) {
8
9
  return {
9
10
  ...super.mapContext(commander, context),
10
11
  force: !!commander.force,
11
12
  checkStatus: true
12
- }
13
+ };
13
14
  }
14
15
 
15
- getTasks (context) {
16
- return [
17
- ...super.getTasks(context),
18
- pushBranch(context)
19
- ]
16
+ getTasks(context) {
17
+ return [...super.getTasks(context), pushBranch(context)];
20
18
  }
21
19
 
22
- success (context) {
23
- // eslint-disable-next-line no-console
24
- console.log(chalk.green(figures.tick), 'Branch', chalk.green(context.featureBranch), 'rebased and pushed.')
20
+ success(context) {
21
+ console.log(chalk.green(figures.tick), "Branch", chalk.green(context.featureBranch), "rebased and pushed.");
25
22
  }
26
23
  }
@@ -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,31 +1,33 @@
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'
6
-
7
- import { updateDependencies } from './tasks/update-dependencies.js'
8
- import { WORKFLOW_CONFIGURATION } from '../workflow/index.js'
9
-
10
- function sanitize (name) {
11
- return name.replace(/[/\\_|. ]/gi, '-').split('-').filter(Boolean).join('-')
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("-");
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}-`));
20
22
 
21
23
  if (!options.branchName && options.jiraId) {
22
- options.branchName = options.jiraId
24
+ options.branchName = options.jiraId;
23
25
  }
24
26
 
25
- if (options.branchName.startsWith('CMAB-')) {
26
- const [, key, ...rest] = options.branchName.split('-')
27
- options.jiraId = `CMAB-${key}`
28
- options.branchName = rest.join('-')
27
+ if (options.branchName.startsWith("CMAB-")) {
28
+ const [, key, ...rest] = options.branchName.split("-");
29
+ options.jiraId = `CMAB-${key}`;
30
+ options.branchName = rest.join("-");
29
31
  }
30
32
 
31
33
  return {
@@ -35,72 +37,74 @@ export class Start extends Fetch {
35
37
  jiraId: options.jiraId,
36
38
  branchName: options.branchName,
37
39
  type
38
- }
40
+ };
39
41
  }
40
42
 
41
- prompt (context) {
43
+ prompt(context) {
42
44
  return [
43
45
  {
44
- type: 'input',
45
- name: 'jiraId',
46
- message: 'What is the Jira ID ? (leave blank to skip)',
46
+ type: "input",
47
+ name: "jiraId",
48
+ message: "What is the Jira ID ? (leave blank to skip)",
47
49
  default: context.jiraId,
48
50
  when: !context.jiraId
49
51
  },
50
52
  {
51
- type: 'list',
52
- name: 'type',
53
- message: 'Choose the type of your branch:',
54
- choices: ['fix', 'feat', 'chore', 'docs', 'tech'],
53
+ type: "list",
54
+ name: "type",
55
+ message: "Choose the type of your branch:",
56
+ choices: ["fix", "feat", "chore", "docs", "tech"],
55
57
  default: context.type,
56
58
  when: !context.type && !context.jiraId
57
59
  },
58
60
  {
59
- type: 'input',
60
- name: 'branchName',
61
- message: 'What is the branch name ?',
62
- validate (branch) {
61
+ type: "input",
62
+ name: "branchName",
63
+ message: "What is the branch name ?",
64
+ validate(branch) {
63
65
  if (!branch.length) {
64
- return 'Branch name is required'
66
+ return "Branch name is required";
65
67
  }
66
68
 
67
69
  if (git.branchExists(branch, context.origin)) {
68
- return `${branch} already exists`
70
+ return `${branch} already exists`;
69
71
  }
70
72
 
71
- return true
73
+ return true;
72
74
  },
73
75
 
74
76
  when: !context.branchName
75
77
  },
76
78
 
77
79
  branches(context)
78
- ]
80
+ ];
79
81
  }
80
82
 
81
- getTasks (context) {
82
- context.branchName = sanitize(context.branchName)
83
+ getTasks(context) {
84
+ context.branchName = sanitize(context.branchName);
83
85
 
84
86
  context.featureBranch = context.jiraId
85
87
  ? `${context.jiraId}-${context.branchName}`
86
- : context.branchName.includes(context.type + '-')
88
+ : context.branchName.includes(context.type + "-")
87
89
  ? context.branchName
88
- : `${context.type}-${context.branchName}`
90
+ : `${context.type}-${context.branchName}`;
89
91
 
90
- context.fromBranch = context.fromBranch || context.PRODUCTION_BRANCH
92
+ context.fromBranch = context.fromBranch || context.PRODUCTION_BRANCH;
91
93
 
92
94
  return [
93
95
  ...super.getTasks(context),
94
96
  {
95
97
  title: `Create branch from ${chalk.green(context.fromBranch)}`,
96
- task: () => git.checkout('--no-track', '-b', context.featureBranch, context.fromBranch).toObservable()
98
+ task: () => git.checkout("--no-track", "-b", context.featureBranch, context.fromBranch).toObservable()
97
99
  },
98
100
  updateDependencies(context)
99
- ]
101
+ ];
100
102
  }
101
103
 
102
- success (context) {
103
- // eslint-disable-next-line no-console
104
- 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
+ );
105
109
  }
106
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
+ };