@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
@@ -0,0 +1,67 @@
1
+ import stylistic from "@stylistic/eslint-plugin";
2
+ import typescriptEslint from "@typescript-eslint/eslint-plugin";
3
+ import typescriptParser from "@typescript-eslint/parser";
4
+ import pluginPrettierRecommended from "eslint-plugin-prettier/recommended";
5
+ import pluginSimpleImportSort from "eslint-plugin-simple-import-sort";
6
+ import vitest from "eslint-plugin-vitest";
7
+ import globals from "globals";
8
+
9
+ export default [
10
+ {
11
+ ignores: [
12
+ "node_modules",
13
+ "dist",
14
+ "**/public",
15
+ "reports",
16
+ "**/coverage",
17
+ "**/reports",
18
+ "**/dist",
19
+ "**/node_modules",
20
+ ".yarn",
21
+ "**/__generated__/**"
22
+ ]
23
+ },
24
+ {
25
+ languageOptions: {
26
+ sourceType: "module",
27
+ parser: typescriptParser,
28
+ parserOptions: {
29
+ ecmaVersion: "latest",
30
+ sourceType: "module"
31
+ },
32
+ globals: {
33
+ ...globals.node
34
+ }
35
+ },
36
+ plugins: {
37
+ ...stylistic.configs.recommended.plugins,
38
+ "@typescript-eslint": typescriptEslint,
39
+ "simple-import-sort": pluginSimpleImportSort
40
+ },
41
+ rules: {
42
+ ...stylistic.configs.recommended.rules,
43
+ "@stylistic/lines-between-class-members": ["error", "always", { exceptAfterOverload: true }],
44
+ "@typescript-eslint/no-unused-vars": "error",
45
+ "simple-import-sort/imports": "error",
46
+ "simple-import-sort/exports": "error"
47
+ }
48
+ },
49
+ {
50
+ files: ["*/*.spec.{js,mjs,cjs,jsx,mjsx,ts,tsx,mtsx}", "*/*.test.{js,mjs,cjs,jsx,mjsx,ts,tsx,mtsx}"], // or any other pattern
51
+ plugins: {
52
+ vitest
53
+ },
54
+ rules: {
55
+ ...vitest.configs.recommended.rules, // you can also use vitest.configs.all.rules to enable all rules
56
+ "vitest/consistent-test-it": [
57
+ "error",
58
+ {
59
+ fn: "it",
60
+ withinDescribe: "it"
61
+ }
62
+ ],
63
+ "vitest/no-alias-methods": "error"
64
+ }
65
+ },
66
+ pluginPrettierRecommended
67
+ ];
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@cmflow/cli",
3
- "version": "1.1.0",
3
+ "version": "2.0.0-alpha.1",
4
4
  "description": "An awesome Git Flow",
5
5
  "author": "camfou",
6
6
  "license": "MIT",
7
7
  "email": "camfou@gmail.com",
8
8
  "main": "./src/index.js",
9
- "module": "./src/main.js",
9
+ "module": "./src/index.js",
10
10
  "type": "module",
11
11
  "private": false,
12
12
  "bin": {
@@ -26,8 +26,14 @@
26
26
  "cmchangelog": "bin/cm-changelog.js",
27
27
  "cmconfig": "bin/cm-config.js"
28
28
  },
29
+ "exports": {
30
+ ".": "./index.js",
31
+ "./semantic/prepare/*": "./src/semantic-release/core/prepare/*.js",
32
+ "./semantic/*": "./src/semantic-release/core/*.js",
33
+ "./semantic/docker/*": "./src/semantic-release/docker/*.js"
34
+ },
29
35
  "dependencies": {
30
- "axios": "^0.27.2",
36
+ "axios": "1.8.2",
31
37
  "chalk": "^4.1.0",
32
38
  "commander": "5.1.0",
33
39
  "conventional-changelog": "3.1.25",
@@ -46,17 +52,20 @@
46
52
  "split": "1.0.1"
47
53
  },
48
54
  "devDependencies": {
49
- "eslint": "8.53.0",
50
- "eslint-config-standard": "17.1.0",
51
- "eslint-plugin-import": "2.29.0",
52
- "eslint-plugin-node": "11.1.0",
53
- "eslint-plugin-promise": "6.1.1",
54
- "eslint-plugin-standard": "5.0.0",
55
- "eslint-plugin-n": "16.3.0",
55
+ "@stylistic/eslint-plugin": "^4.2.0",
56
+ "@typescript-eslint/parser": "8.26.1",
57
+ "@typescript-eslint/eslint-plugin": "8.26.1",
58
+ "eslint": "9.21.0",
59
+ "eslint-config-prettier": "10.0.2",
60
+ "eslint-formatter-junit": "^8.40.0",
61
+ "eslint-plugin-prettier": "5.2.3",
62
+ "eslint-plugin-simple-import-sort": "12.1.1",
63
+ "eslint-plugin-vitest": "0.5.4",
56
64
  "husky": "4.3.6",
57
- "jest": "^29.7.0",
58
- "jest-junit": "^11.0.1",
59
- "lint-staged": "10.5.3"
65
+ "prettier": "3.5.1",
66
+ "lint-staged": "10.5.3",
67
+ "vitest": "^3.0.8",
68
+ "typescript": "5.8.2"
60
69
  },
61
70
  "peerDependencies": {
62
71
  "@semantic-release/commit-analyzer": "^11.1.0",
@@ -67,19 +76,16 @@
67
76
  "@semantic-release/commit-analyzer": {
68
77
  "optional": true
69
78
  },
70
- "@semantic-release/github": {
71
- "optional": true
72
- },
73
79
  "@semantic-release/release-notes-generator": {
74
80
  "optional": true
75
81
  }
76
82
  },
77
83
  "scripts": {
78
84
  "test": "yarn lint && yarn test_unit",
79
- "test_unit": "NODE_OPTIONS=--experimental-vm-modules jest",
80
- "lint": "eslint -c .eslintrc {src,bin}/**/*.js",
81
- "lint_ci": "eslint -c .eslintrc {src,bin}/**/*.js --format junit --output-file ./reports/eslint.xml",
82
- "lint_fix": "eslint -c .eslintrc {src,bin}/**/*.js --fix",
85
+ "test_unit": "vitest run",
86
+ "lint": "eslint",
87
+ "lint_ci": "eslint --format junit --output-file ./reports/eslint.xml",
88
+ "lint_fix": "eslint --fix",
83
89
  "release": "node bin/cmrelease.js",
84
90
  "release_dry_run": "node bin/cmrelease.js --dry-run",
85
91
  "build_changelog": "node bin/cm-changelog.js"
@@ -92,7 +98,7 @@
92
98
  },
93
99
  "lint-staged": {
94
100
  "*.js": [
95
- "eslint -c .eslintrc --fix",
101
+ "eslint --fix",
96
102
  "git add"
97
103
  ]
98
104
  },
@@ -1,22 +1,39 @@
1
- import { getConfig } from './src/index.js'
1
+ import { defineConfig } from "./src/index.js";
2
2
 
3
- process.env.PRODUCTION_BRANCH = 'master'
4
- process.env.DEVELOP_BRANCH = 'master'
5
- process.env.DEPLOY_ON_DOCKER = 'false'
6
- const config = getConfig()
7
-
8
- export default {
9
- branches: ['master', { name: config.BRANCH_NAME, prerelease: true }],
10
- plugins: [
11
- './semantic'
3
+ export default defineConfig({
4
+ branches: [
5
+ "master",
6
+ {
7
+ name: "alpha",
8
+ prerelease: true,
9
+ channel: "alpha"
10
+ },
11
+ {
12
+ name: "beta",
13
+ prerelease: true,
14
+ channel: "beta"
15
+ },
16
+ {
17
+ name: "rc",
18
+ prerelease: true,
19
+ channel: "rc"
20
+ }
21
+ ],
22
+ verifyConditions: ["./src/semantic/core/verify-conditions.js"],
23
+ analyzeCommits: ["@semantic-release/commit-analyzer"],
24
+ verifyRelease: ["./src/semantic/core/verify-release.js"],
25
+ generateNotes: ["./src/semantic/core/generate-notes.js"],
26
+ prepare: ["./src/semantic/core/prepare/bump-version.js", "./src/semantic/core/prepare/post.js"],
27
+ publish: ["@semantic-release/github"],
28
+ success: [
29
+ [
30
+ "./src/semantic/core/success.js",
31
+ {
32
+ when: () => true
33
+ }
34
+ ],
35
+ "@semantic-release/github"
12
36
  ],
13
- verifyConditions: ['./semantic'],
14
- analyzeCommits: ['./semantic'],
15
- verifyRelease: ['./semantic'],
16
- generateNotes: ['./semantic'],
17
- prepare: ['./semantic'],
18
- publish: ['./semantic'],
19
- success: ['./semantic'],
20
- fail: ['./semantic'],
37
+ fail: ["@semantic-release/github"],
21
38
  npmPublish: false
22
- }
39
+ });
@@ -1,47 +1,47 @@
1
- import conventionalChangelog from 'conventional-changelog'
2
- import { Observable } from 'rxjs'
3
- import { createWriteStream } from 'fs'
1
+ import conventionalChangelog from "conventional-changelog";
2
+ import { createWriteStream } from "fs";
3
+ import { Observable } from "rxjs";
4
4
 
5
5
  export class Changelog {
6
- mapContext (commander, config) {
6
+ mapContext(commander, config) {
7
7
  return {
8
- preset: commander.preset || 'angular',
8
+ preset: commander.preset || "angular",
9
9
  releaseCount: commander.releaseCount || 0,
10
10
  outfile: `${process.cwd()}/CHANGELOG.md`,
11
- // eslint-disable-next-line no-template-curly-in-string
12
- tagPrefix: (config.tagFormat || commander.tagPrefix || '').replace('${version}', '')
13
- }
11
+
12
+ tagPrefix: (config.tagFormat || commander.tagPrefix || "").replace("${version}", "")
13
+ };
14
14
  }
15
15
 
16
- exec ({ preset, releaseCount, outfile, tagPrefix }) {
17
- const writableStream = createWriteStream(outfile, { encoding: 'utf8' })
16
+ exec({ preset, releaseCount, outfile, tagPrefix }) {
17
+ const writableStream = createWriteStream(outfile, { encoding: "utf8" });
18
18
 
19
- return new Observable(observer => {
19
+ return new Observable((observer) => {
20
20
  const stream = conventionalChangelog({
21
21
  preset,
22
22
  releaseCount,
23
23
  path: `${process.cwd()}/package.json`,
24
24
  tagPrefix
25
- })
25
+ });
26
26
 
27
- stream.pipe(writableStream)
27
+ stream.pipe(writableStream);
28
28
 
29
- stream.on('error', (err) => {
30
- observer.error(err)
31
- })
29
+ stream.on("error", (err) => {
30
+ observer.error(err);
31
+ });
32
32
 
33
- stream.on('end', () => {
34
- observer.complete()
35
- })
36
- })
33
+ stream.on("end", () => {
34
+ observer.complete();
35
+ });
36
+ });
37
37
  }
38
38
 
39
- getTasks (ctx) {
39
+ getTasks(ctx) {
40
40
  return [
41
41
  {
42
- title: 'Generate changelog',
42
+ title: "Generate changelog",
43
43
  task: () => this.exec(ctx)
44
44
  }
45
- ]
45
+ ];
46
46
  }
47
47
  }
@@ -1,29 +1,29 @@
1
- import chalk from 'chalk'
2
- import figures from 'figures'
3
- import { dockerCleanTags } from '../semantic-release/utils/docker-clean-tags.js'
1
+ import chalk from "chalk";
2
+ import figures from "figures";
3
+
4
+ import { dockerCleanTags } from "../semantic/utils/docker-clean-tags.js";
4
5
 
5
6
  export class Clean {
6
- mapContext (commander, context) {
7
+ mapContext(commander, context) {
7
8
  return {
8
9
  ...context
9
- }
10
+ };
10
11
  }
11
12
 
12
- prompt (context) {
13
- return []
13
+ prompt() {
14
+ return [];
14
15
  }
15
16
 
16
- getTasks (context) {
17
+ getTasks(context) {
17
18
  return [
18
19
  {
19
- title: 'Clean docker tags',
20
+ title: "Clean docker tags",
20
21
  task: () => dockerCleanTags(context)
21
22
  }
22
- ]
23
+ ];
23
24
  }
24
25
 
25
- success (context) {
26
- // eslint-disable-next-line no-console
27
- console.log(chalk.green(figures.tick), 'Docker tags cleaned')
26
+ success() {
27
+ console.log(chalk.green(figures.tick), "Docker tags cleaned");
28
28
  }
29
29
  }
@@ -1,23 +1,23 @@
1
- import { configureGitWorkspace, getConfig } from '../common/index.js'
1
+ import { configureGitWorkspace, getConfig } from "../common/index.js";
2
2
 
3
3
  export class Config {
4
- mapContext (commander, context) {
4
+ mapContext(commander, context) {
5
5
  return {
6
6
  ...context,
7
7
  config: getConfig()
8
- }
8
+ };
9
9
  }
10
10
 
11
- prompt () {
12
- return []
11
+ prompt() {
12
+ return [];
13
13
  }
14
14
 
15
- getTasks (context) {
15
+ getTasks(context) {
16
16
  return [
17
17
  {
18
- title: 'Configure workspace',
18
+ title: "Configure workspace",
19
19
  task: () => configureGitWorkspace(context)
20
20
  }
21
- ]
21
+ ];
22
22
  }
23
23
  }
@@ -1,39 +1,34 @@
1
- import chalk from 'chalk'
2
- import figures from 'figures'
3
- import { deployOnDockerHub, deployOnHeroku } from '../semantic-release/utils/docker-publish.js'
4
- import { getConfig } from '../common/index.js'
1
+ import chalk from "chalk";
2
+ import figures from "figures";
3
+
4
+ import { getConfig } from "../common/index.js";
5
+ import { dockerPublish } from "../semantic/utils/docker-publish.js";
5
6
 
6
7
  export class Deploy {
7
- mapContext (commander, context) {
8
+ mapContext(commander, context) {
8
9
  return {
9
10
  ...context,
10
11
  target: commander.target,
11
12
  config: getConfig()
12
- }
13
+ };
13
14
  }
14
15
 
15
- prompt (context) {
16
- return []
16
+ prompt() {
17
+ return [];
17
18
  }
18
19
 
19
- getTasks (context) {
20
+ getTasks(context) {
20
21
  return [
21
22
  {
22
- title: `Deploy on ${context.target}`,
23
+ title: "Deploy on docker",
23
24
  task: () => {
24
- switch (context.target) {
25
- case 'docker':
26
- return deployOnDockerHub(context)
27
- case 'heroku':
28
- return deployOnHeroku(context)
29
- }
25
+ return dockerPublish(context);
30
26
  }
31
27
  }
32
- ]
28
+ ];
33
29
  }
34
30
 
35
- success (context) {
36
- // eslint-disable-next-line no-console
37
- console.log(chalk.green(figures.tick), 'Github pages deployed')
31
+ success() {
32
+ console.log(chalk.green(figures.tick), "Docker image deployed");
38
33
  }
39
34
  }
@@ -1,21 +1,18 @@
1
- import { refreshRepository } from './tasks/refresh-repository.js'
1
+ import { refreshRepository } from "./tasks/refresh-repository.js";
2
2
 
3
3
  export class Fetch {
4
- mapContext (commander, context) {
4
+ mapContext(commander, context) {
5
5
  return {
6
6
  ...context,
7
7
  output: []
8
- }
8
+ };
9
9
  }
10
10
 
11
- getTasks (context) {
12
- return [
13
- refreshRepository(context)
14
- ]
11
+ getTasks(context) {
12
+ return [refreshRepository(context)];
15
13
  }
16
14
 
17
- success (context) {
18
- // eslint-disable-next-line no-console
19
- console.log(context.output.filter(l => !l.match('Fetching')).join('\n'))
15
+ success(context) {
16
+ console.log(context.output.filter((l) => !l.match("Fetching")).join("\n"));
20
17
  }
21
18
  }
@@ -1,44 +1,43 @@
1
- import chalk from 'chalk'
2
- import figures from 'figures'
3
- import { Rebase } from './rebase.js'
4
- import { git } from '../common/cli/git.js'
5
- import { pushBranch } from './tasks/push-branch.js'
1
+ import chalk from "chalk";
2
+ import figures from "figures";
3
+
4
+ import { git } from "../common/cli/git.js";
5
+ import { Rebase } from "./rebase.js";
6
+ import { pushBranch } from "./tasks/push-branch.js";
6
7
 
7
8
  export class Finish extends Rebase {
8
- mapContext (commander, context) {
9
+ mapContext(commander, context) {
9
10
  return {
10
11
  ...super.mapContext(commander, context),
11
12
  checkStatus: true,
12
13
  force: true
13
- }
14
+ };
14
15
  }
15
16
 
16
- verifyConditions (context) {
17
+ verifyConditions(context) {
17
18
  // Can't finish a production branch
18
19
  if (context.featureBranch === context.fromBranch) {
19
- // eslint-disable-next-line no-console
20
- console.error(chalk.red(`${figures.cross} ${context.fromBranch} cannot be finished`))
21
- process.exit(1)
20
+ console.error(chalk.red(`${figures.cross} ${context.fromBranch} cannot be finished`));
21
+ process.exit(1);
22
22
  }
23
23
  }
24
24
 
25
- getTasks (context) {
25
+ getTasks(context) {
26
26
  return [
27
27
  ...super.getTasks(context),
28
28
  {
29
29
  title: `Add ${context.RELEASE_CANDIDATE_TAG} on last commit`,
30
- task () {
31
- const message = `${git.getLastCommitMsg()} ${context.RELEASE_CANDIDATE_TAG}`
30
+ task() {
31
+ const message = `${git.getLastCommitMsg()} ${context.RELEASE_CANDIDATE_TAG}`;
32
32
 
33
- return git.commit('--amend', '-m', message).toObservable()
33
+ return git.commit("--amend", "-m", message).toObservable();
34
34
  }
35
35
  },
36
36
  pushBranch(context)
37
- ]
37
+ ];
38
38
  }
39
39
 
40
- success (context) {
41
- // eslint-disable-next-line no-console
42
- console.log(chalk.green(figures.tick), 'Branch', chalk.green(context.featureBranch), 'is finished')
40
+ success(context) {
41
+ console.log(chalk.green(figures.tick), "Branch", chalk.green(context.featureBranch), "is finished");
43
42
  }
44
43
  }
@@ -1,11 +1,10 @@
1
- export * from './changelog.js'
2
- export * from './finish.js'
3
- export * from './fetch.js'
4
- export * from './push.js'
5
- export * from './start.js'
6
- export * from './republish.js'
7
- export * from './rebase.js'
8
- export * from './publish-pages.js'
9
- export * from './clean.js'
10
- export * from './deploy.js'
11
- export * from './merge.js'
1
+ export * from "./changelog.js";
2
+ export * from "./clean.js";
3
+ export * from "./deploy.js";
4
+ export * from "./fetch.js";
5
+ export * from "./finish.js";
6
+ export * from "./merge.js";
7
+ export * from "./push.js";
8
+ export * from "./rebase.js";
9
+ export * from "./republish.js";
10
+ export * from "./start.js";
@@ -1,25 +1,41 @@
1
- import chalk from 'chalk'
2
- import figures from 'figures'
3
- import { mergeBranch } from './tasks/merge-branch.js'
4
- import { git } from '../common/cli/git.js'
1
+ import chalk from "chalk";
2
+ import figures from "figures";
3
+
4
+ import { git } from "../common/cli/git.js";
5
+ import { mergeBranch } from "./tasks/merge-branch.js";
5
6
 
6
7
  export class Merge {
7
- getTasks (context) {
8
- const { RELEASE_CANDIDATE_TAG } = context
9
- this.lastCommitMessage = git.getLastCommitMsg()
8
+ getTasks(context) {
9
+ const { RELEASE_CANDIDATE_TAG } = context;
10
+ this.lastCommitMessage = git.getLastCommitMsg();
10
11
  if (this.lastCommitMessage.includes(RELEASE_CANDIDATE_TAG)) {
11
- return [mergeBranch(context)]
12
+ return [mergeBranch(context)];
12
13
  }
13
- return []
14
+ return [];
14
15
  }
15
16
 
16
- success (context) {
17
- const { RELEASE_CANDIDATE_TAG } = context
17
+ success(context) {
18
+ const { RELEASE_CANDIDATE_TAG } = context;
18
19
  if (this.lastCommitMessage.includes(RELEASE_CANDIDATE_TAG)) {
19
- context.logger.info(chalk.green(figures.tick), 'Branch', chalk.green(context.BRANCH_NAME), `merged into ${context.PRODUCTION_BRANCH}`)
20
+ context.logger.info(
21
+ chalk.green(figures.tick),
22
+ "Branch",
23
+ chalk.green(context.BRANCH_NAME),
24
+ `merged into ${context.PRODUCTION_BRANCH}`
25
+ );
20
26
  } else {
21
- context.logger.info(chalk.green(figures.tick), 'Merge branch', chalk.green(context.BRANCH_NAME), `into ${context.PRODUCTION_BRANCH} not required`)
22
- context.logger.info(chalk.green(figures.tick), 'Last commit message : ', chalk.green(this.lastCommitMessage), `does not contains ${RELEASE_CANDIDATE_TAG}`)
27
+ context.logger.info(
28
+ chalk.green(figures.tick),
29
+ "Merge branch",
30
+ chalk.green(context.BRANCH_NAME),
31
+ `into ${context.PRODUCTION_BRANCH} not required`
32
+ );
33
+ context.logger.info(
34
+ chalk.green(figures.tick),
35
+ "Last commit message : ",
36
+ chalk.green(this.lastCommitMessage),
37
+ `does not contains ${RELEASE_CANDIDATE_TAG}`
38
+ );
23
39
  }
24
40
  }
25
41
  }
@@ -1,38 +1,38 @@
1
- import inquirer from 'inquirer'
2
- import { git } from '../../common/index.js'
1
+ import inquirer from "inquirer";
3
2
 
4
- function toRemote (branch, origin) {
5
- branch = branch.replace(`${origin}/`)
6
- return `${origin}/${branch}`
3
+ import { git } from "../../common/index.js";
4
+
5
+ function toRemote(branch, origin) {
6
+ branch = branch.replace(`${origin}/`);
7
+ return `${origin}/${branch}`;
7
8
  }
8
9
 
9
- export function branches ({ fromBranch, origin, PRODUCTION_BRANCH, DEVELOP_BRANCH, message = 'Start your branch from:' }) {
10
- const currentBranch = git.getBranchName()
11
- const originDevelop = `${origin}/${DEVELOP_BRANCH}`
12
- const originProduction = `${origin}/${PRODUCTION_BRANCH}`
10
+ export function branches({ fromBranch, origin, PRODUCTION_BRANCH, DEVELOP_BRANCH, message = "Start your branch from:" }) {
11
+ const currentBranch = git.getBranchName();
12
+ const originDevelop = `${origin}/${DEVELOP_BRANCH}`;
13
+ const originProduction = `${origin}/${PRODUCTION_BRANCH}`;
13
14
 
14
- let startFromBranches = [
15
- originProduction
16
- ]
15
+ let startFromBranches = [originProduction];
17
16
 
18
17
  if (startFromBranches.indexOf(toRemote(currentBranch, origin)) === -1 && git.branchExists(currentBranch, origin)) {
19
- startFromBranches = startFromBranches.concat(toRemote(currentBranch, origin))
18
+ startFromBranches = startFromBranches.concat(toRemote(currentBranch, origin));
20
19
  }
21
20
 
22
- const remoteBranches = git.branchesInfos('-r')
23
- .map(info => info.branch)
24
- .filter(name => !startFromBranches.includes(name) && ![originDevelop, originProduction].includes(name))
21
+ const remoteBranches = git
22
+ .branchesInfos("-r")
23
+ .map((info) => info.branch)
24
+ .filter((name) => !startFromBranches.includes(name) && ![originDevelop, originProduction].includes(name));
25
25
 
26
26
  if (remoteBranches.length) {
27
- startFromBranches = startFromBranches.concat(new inquirer.Separator(), remoteBranches)
27
+ startFromBranches = startFromBranches.concat(new inquirer.Separator(), remoteBranches);
28
28
  }
29
29
 
30
30
  return {
31
- type: 'list',
32
- name: 'fromBranch',
31
+ type: "list",
32
+ name: "fromBranch",
33
33
  message,
34
34
  default: startFromBranches.indexOf(fromBranch || originProduction),
35
35
  choices: startFromBranches,
36
36
  when: !fromBranch || currentBranch !== DEVELOP_BRANCH
37
- }
37
+ };
38
38
  }