@cmflow/cli 1.1.0 → 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 +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/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,42 +1,42 @@
1
1
  export const WORKFLOW_CONFIGURATION = [
2
2
  {
3
- type: 'feat',
4
- label: 'Features',
5
- release: 'minor'
3
+ type: "feat",
4
+ label: "Features",
5
+ release: "minor"
6
6
  },
7
7
  {
8
- type: 'fix',
9
- label: 'Bug Fixes',
10
- release: 'patch'
8
+ type: "fix",
9
+ label: "Bug Fixes",
10
+ release: "patch"
11
11
  },
12
12
  {
13
- type: 'chore',
14
- label: 'Chores',
13
+ type: "chore",
14
+ label: "Chores",
15
15
  release: false
16
16
  },
17
17
  {
18
- type: 'ci',
19
- label: 'CI',
18
+ type: "ci",
19
+ label: "CI",
20
20
  release: false
21
21
  },
22
22
  {
23
- type: 'docs',
24
- label: 'Documentation',
25
- release: 'patch'
23
+ type: "docs",
24
+ label: "Documentation",
25
+ release: "patch"
26
26
  },
27
27
  {
28
- type: 'tech',
29
- label: 'Technical Improvements',
30
- release: 'patch'
28
+ type: "tech",
29
+ label: "Technical Improvements",
30
+ release: "patch"
31
31
  },
32
32
  {
33
- type: 'refactor',
34
- label: 'Technical Improvements',
35
- release: 'patch'
33
+ type: "refactor",
34
+ label: "Technical Improvements",
35
+ release: "patch"
36
36
  },
37
37
  {
38
- type: 'default',
39
- label: 'Miscellaneous',
38
+ type: "default",
39
+ label: "Miscellaneous",
40
40
  release: false
41
41
  }
42
- ]
42
+ ];
package/tsconfig.json ADDED
@@ -0,0 +1,54 @@
1
+ {
2
+ "compilerOptions": {
3
+ "baseUrl": ".",
4
+ "target": "esnext",
5
+ "module": "NodeNext",
6
+ "moduleResolution": "NodeNext",
7
+ "sourceMap": true,
8
+ "declaration": false,
9
+ "experimentalDecorators": true,
10
+ "emitDecoratorMetadata": true,
11
+ "skipLibCheck": true,
12
+ "skipDefaultLibCheck": true,
13
+ "isolatedModules": false,
14
+ "allowJs": true,
15
+ "suppressImplicitAnyIndexErrors": false,
16
+ "noImplicitAny": true,
17
+ "strictNullChecks": true,
18
+ "strictPropertyInitialization": false,
19
+ "noUnusedLocals": false,
20
+ "noUnusedParameters": false,
21
+ "allowSyntheticDefaultImports": true,
22
+ "importHelpers": true,
23
+ "newLine": "LF",
24
+ "noEmit": true,
25
+ "esModuleInterop": true,
26
+ "resolveJsonModule": true,
27
+ "useDefineForClassFields": false,
28
+ "lib": [
29
+ "ESNext",
30
+ "dom",
31
+ "ESNext.AsyncIterable"
32
+ ],
33
+ "noResolve": false,
34
+ "preserveConstEnums": true,
35
+ "verbatimModuleSyntax": true,
36
+ "outDir": "./dist",
37
+ "types": [
38
+ "vitest/globals",
39
+ "vitest/importMeta",
40
+ "vite/client",
41
+ "node",
42
+ "vitest"
43
+ ]
44
+ },
45
+ "include": [
46
+ "vite.config.mts",
47
+ "./src/**",
48
+ "./src/**/*.spec.js",
49
+ "./src/**/*.test.js"
50
+ ],
51
+ "exclude": [
52
+ "node_modules"
53
+ ]
54
+ }
@@ -0,0 +1,10 @@
1
+ // eslint-disable-next-line import/no-unresolved
2
+ import { defineConfig } from 'vitest/config'
3
+
4
+ export default defineConfig({
5
+ test: {
6
+ globals: true,
7
+ environment: 'node'
8
+ // ... Specify options here.
9
+ }
10
+ })
@@ -1,12 +0,0 @@
1
- #!/usr/bin/env node
2
- import commander from 'commander'
3
-
4
- import { commands, runCommand } from '../src/index.js'
5
-
6
- commander
7
- .usage('cmpublishpages [options]')
8
- .alias('cm publish-pages')
9
- .option('-s, --source <source>', 'Publish given directory on the github pages')
10
- .parse(process.argv)
11
-
12
- runCommand(commands.PublishPages, commander)
package/semantic.js DELETED
@@ -1 +0,0 @@
1
- export * from './src/semantic-release/actions/index.js'
@@ -1,29 +0,0 @@
1
- import chalk from 'chalk'
2
- import figures from 'figures'
3
- import { ghPagesPublish } from '../semantic-release/utils/ghpages-publish.js'
4
-
5
- export class PublishPages {
6
- mapContext (commander, context) {
7
- return {
8
- ...context
9
- }
10
- }
11
-
12
- prompt (context) {
13
- return []
14
- }
15
-
16
- getTasks (context) {
17
- return [
18
- {
19
- title: 'Publish github pages',
20
- task: () => ghPagesPublish(context)
21
- }
22
- ]
23
- }
24
-
25
- success (context) {
26
- // eslint-disable-next-line no-console
27
- console.log(chalk.green(figures.tick), 'Github pages deployed')
28
- }
29
- }
@@ -1,21 +0,0 @@
1
- import { Cli } from './cli.js'
2
-
3
- export class HerokuCli extends Cli {
4
- constructor () {
5
- super('heroku')
6
- }
7
-
8
- containerLogin (...args) {
9
- return this.run('container:login', ...args)
10
- }
11
-
12
- containerPush (...args) {
13
- return this.run('container:push', ...args)
14
- }
15
-
16
- containerRelease (...args) {
17
- return this.run('container:release', ...args)
18
- }
19
- }
20
-
21
- export const heroku = new HerokuCli()
@@ -1,62 +0,0 @@
1
- import { beforeEach, describe, expect, it, jest } from '@jest/globals'
2
-
3
- jest.unstable_mockModule('execa', () => {
4
- const execaMock = jest.fn()
5
- execaMock.sync = jest.fn()
6
- return { default: execaMock }
7
- })
8
- const { default: execa } = await import('execa')
9
-
10
- const { Cli } = await import('./cli.js')
11
- const { heroku } = await import('./heroku.js')
12
-
13
- execa.sync.mockImplementation((...args) => {
14
- return {
15
- stdout: `CMD: ${[].concat(...args.filter(arg => typeof arg === 'string' || Array.isArray(arg))).join(' ')}`
16
- }
17
- })
18
-
19
- execa.mockReturnValue({})
20
-
21
- describe('HerokuCli', () => {
22
- beforeEach(() => {
23
- jest.spyOn(Cli, 'getRaw').mockImplementation((...args) => {
24
- return `CMD: ${[].concat(...args.filter(arg => typeof arg === 'string' || Array.isArray(arg))).join(' ')}`
25
- })
26
- })
27
- describe('containerLogin', () => {
28
- it('should run cmd', () => {
29
- const result = heroku.containerLogin('arg').sync()
30
-
31
- expect(result.stdout).toEqual('CMD: heroku container:login arg')
32
- expect(execa.sync).toHaveBeenCalledWith('heroku', ['container:login', 'arg'], {
33
- cwd: process.cwd(),
34
- stdio: 'inherit'
35
- })
36
- })
37
- })
38
-
39
- describe('containerPush', () => {
40
- it('should run cmd', () => {
41
- const result = heroku.containerPush('arg').sync()
42
-
43
- expect(result.stdout).toEqual('CMD: heroku container:push arg')
44
- expect(execa.sync).toHaveBeenCalledWith('heroku', ['container:push', 'arg'], {
45
- cwd: process.cwd(),
46
- stdio: 'inherit'
47
- })
48
- })
49
- })
50
-
51
- describe('containerRelease', () => {
52
- it('should run cmd', () => {
53
- const result = heroku.containerRelease('arg').sync()
54
-
55
- expect(result.stdout).toEqual('CMD: heroku container:release arg')
56
- expect(execa.sync).toHaveBeenCalledWith('heroku', ['container:release', 'arg'], {
57
- cwd: process.cwd(),
58
- stdio: 'inherit'
59
- })
60
- })
61
- })
62
- })
package/src/main.js DELETED
@@ -1,10 +0,0 @@
1
- import * as commands from './commands/index.js'
2
-
3
- export * from './workflow/index.js'
4
- export * from './common/index.js'
5
- export * from './commands/release.js'
6
- export * from './semantic-release/get-semantic-config.js'
7
-
8
- export {
9
- commands
10
- }
@@ -1,14 +0,0 @@
1
- import * as commitAnalyzerPlugins from '@semantic-release/commit-analyzer'
2
- import { calculateSnapshotVersion } from '../utils/calculate-snapshot-version.js'
3
-
4
- export async function analyzeCommits (pluginConfig, context) {
5
- if (context.branch && context.branch.type !== 'prerelease') {
6
- return commitAnalyzerPlugins.analyzeCommits(pluginConfig, context)
7
- }
8
- const analyzedCommits = await commitAnalyzerPlugins.analyzeCommits(pluginConfig, context)
9
- context.nextRelease = context.nextRelease || {}
10
- context.nextRelease.type = analyzedCommits
11
- context.nextRelease.version = calculateSnapshotVersion(context)
12
- context.lastRelease.version = null
13
- return 'patch'
14
- }
@@ -1,16 +0,0 @@
1
- import * as githubPlugins from '@semantic-release/github'
2
- import { git } from '../../common/index.js'
3
-
4
- export async function fail (pluginConfig, context) {
5
- if (context.branch && context.branch.type !== 'prerelease') {
6
- const { tagFormat, config: { ORIGIN } } = context
7
-
8
- try {
9
- // eslint-disable-next-line no-template-curly-in-string
10
- await git.push('--delete', ORIGIN, tagFormat.replace('${version}', context.nextRelease.version))
11
- } catch (er) {
12
- }
13
-
14
- await githubPlugins.fail(pluginConfig, context)
15
- }
16
- }
@@ -1,12 +0,0 @@
1
- import * as releaseNotesPlugins from '@semantic-release/release-notes-generator'
2
- import { getConfig, npm, yarn } from '../../common/index.js'
3
-
4
- export async function generateNotes (pluginConfig, context) {
5
- context.config = getConfig()
6
- if (context.branch.type === 'release' && !context.config.SKIP_GITHUB_PUBLISH) {
7
- if (context.config.HAS_BUILD_CHANGELOG) {
8
- await (context.config.HAS_YARN ? yarn : npm).run('build_changelog')
9
- }
10
- return releaseNotesPlugins.generateNotes(pluginConfig, context)
11
- }
12
- }
@@ -1,8 +0,0 @@
1
- export * from './verify-conditions.js'
2
- export * from './analyze-commits.js'
3
- export * from './verify-release.js'
4
- export * from './generate-notes.js'
5
- export * from './prepare.js'
6
- export * from './publish.js'
7
- export * from './success.js'
8
- export * from './fail.js'
@@ -1,114 +0,0 @@
1
- import { dockerPublish } from '../utils/docker-publish.js'
2
- import { configureGitWorkspace, getConfig, git, lerna, npm, yarn } from '../../common/index.js'
3
- import { bumpPackagesVersion } from '../utils/bump-packages-version.js'
4
-
5
- async function gitPrepareRelease (pluginConfig, context) {
6
- context.config = getConfig()
7
- const {
8
- logger,
9
- config: {
10
- CI_NAME,
11
- BUILD_NUMBER
12
- }
13
- } = context
14
-
15
- logger.info('Adding files to commit')
16
- git.add('-A').sync()
17
-
18
- logger.info('Get commit stage status')
19
- git.status()
20
-
21
- const revisionMessage = `${CI_NAME} build: ${context.branch.name} ${BUILD_NUMBER} ${context.nextRelease.gitTag} [ci skip]`
22
-
23
- logger.info('Commit changes with revision message: ')
24
- logger.info(revisionMessage)
25
-
26
- git.commit('-m', revisionMessage).sync()
27
-
28
- logger.success('Change committed')
29
- }
30
-
31
- export async function prepare (pluginConfig, context) {
32
- context.config = getConfig()
33
- const {
34
- branch,
35
- config: {
36
- RELEASE_CANDIDATE_TAG,
37
- HAS_BUILD,
38
- HAS_E2E,
39
- E2E_CMD,
40
- SKIP_DEPLOY,
41
- SKIP_E2E,
42
- SKIP_GITHUB_PUBLISH,
43
- HAS_YARN,
44
- HAS_LERNA,
45
- BUMP_METHOD,
46
- WORKSPACES
47
- },
48
- logger
49
- } = context
50
- const pkgManager = HAS_YARN ? yarn : npm
51
-
52
- logger.info(`Start bump version for all packages using method: ${BUMP_METHOD}`)
53
-
54
- switch (BUMP_METHOD) {
55
- case 'native':
56
- logger.info('Using package manager')
57
- npm.newVersion(context.nextRelease.version)
58
- break
59
- case 'lerna':
60
- if (HAS_LERNA) {
61
- await lerna.newVersion(context.nextRelease.version)
62
- }
63
- break
64
- case 'cmflow':
65
- await bumpPackagesVersion(context.nextRelease.version, WORKSPACES)
66
- await pkgManager.install()
67
- break
68
- case 'native:lerna':
69
- default:
70
- npm.newVersion(context.nextRelease.version)
71
-
72
- if (HAS_LERNA) {
73
- await lerna.newVersion(context.nextRelease.version)
74
- }
75
- }
76
-
77
- logger.info('Bump version finished with success...')
78
-
79
- if (HAS_BUILD && !SKIP_DEPLOY) {
80
- logger.info('Start build task')
81
- await pkgManager.run('build')
82
- logger.info('Build task finished with success...')
83
- } else {
84
- logger.info('Skipping build task')
85
- }
86
-
87
- if (HAS_E2E && !SKIP_DEPLOY && !SKIP_E2E) {
88
- logger.info('Start test_e2e task')
89
- await pkgManager.run(E2E_CMD || 'test_e2e')
90
- logger.info('test_e2e task finished with success...')
91
- } else {
92
- logger.info('Skipping test_e2e task')
93
- }
94
-
95
- if (!SKIP_GITHUB_PUBLISH) {
96
- if (branch.type === 'release') {
97
- logger.info('Prepare release')
98
- configureGitWorkspace(context)
99
- return gitPrepareRelease(pluginConfig, context)
100
- }
101
-
102
- const lastCommitMessage = git.getLastCommitMsg()
103
- logger.info('Last commit message:', lastCommitMessage)
104
- if (lastCommitMessage.includes(RELEASE_CANDIDATE_TAG)) {
105
- process.exit(0)
106
- }
107
- }
108
-
109
- if (!SKIP_DEPLOY) {
110
- await dockerPublish(context)
111
- }
112
- // avoid next semantic-release steps when is a prerelease or release branch with SKIP_GITHUB_PUBLISH
113
- process.exit(0)
114
- }
@@ -1,17 +0,0 @@
1
- import * as githubPlugins from '@semantic-release/github'
2
- import { dockerPublish } from '../utils/docker-publish.js'
3
- import { ghPagesPublish } from '../utils/ghpages-publish.js'
4
-
5
- export async function publish (pluginConfig, context) {
6
- const { branch, env: { SKIP_GITHUB_PUBLISH, GITHUB_PAGES_PATH } } = context
7
-
8
- if (!SKIP_GITHUB_PUBLISH && branch.type === 'release') {
9
- await githubPlugins.publish(pluginConfig, context)
10
- }
11
-
12
- if (GITHUB_PAGES_PATH && branch.type === 'release') {
13
- await ghPagesPublish(context)
14
- }
15
-
16
- await dockerPublish(context)
17
- }
@@ -1,32 +0,0 @@
1
- import * as githubPlugins from '@semantic-release/github'
2
- import { dockerCleanTags } from '../utils/docker-clean-tags.js'
3
- import { getConfig } from '../../common/get-config.js'
4
- import { git } from '../../common/index.js'
5
-
6
- async function githubSuccess (pluginConfig, context) {
7
- const { logger, config: { PRODUCTION_BRANCH, ORIGIN, DEVELOP_BRANCH } } = context
8
- await git.push('--quiet', '--set-upstream', ORIGIN, PRODUCTION_BRANCH)
9
-
10
- if (PRODUCTION_BRANCH !== DEVELOP_BRANCH) {
11
- logger.start(`Reset HEAD of ${ORIGIN}/${DEVELOP_BRANCH} branch to HEAD of ${ORIGIN}/${PRODUCTION_BRANCH} `)
12
- await git.push('-f', ORIGIN, `refs/remotes/${ORIGIN}/${PRODUCTION_BRANCH}:refs/heads/${DEVELOP_BRANCH}`)
13
- logger.success(`${ORIGIN}/${DEVELOP_BRANCH} branch correctly updated`)
14
- }
15
-
16
- await githubPlugins.success(pluginConfig, context)
17
- }
18
-
19
- export async function success (pluginConfig, context) {
20
- context.config = getConfig()
21
- const { branch, config: { SKIP_GITHUB_PUBLISH } } = context
22
-
23
- if (branch.type !== 'prerelease' && !SKIP_GITHUB_PUBLISH) {
24
- await githubSuccess(pluginConfig, context)
25
- }
26
-
27
- try {
28
- await dockerCleanTags(context)
29
- } catch (er) {
30
- context.logger.warn(er)
31
- }
32
- }
@@ -1,30 +0,0 @@
1
- import chalk from 'chalk'
2
- import * as githubPlugins from '@semantic-release/github'
3
- import { getConfig, git } from '../../common/index.js'
4
-
5
- export function verifyConditions (pluginConfig, context) {
6
- context.config = getConfig()
7
- if (pluginConfig.dryRun) {
8
- return
9
- }
10
-
11
- const { branch, config: { USER, EMAIL, ORIGIN } } = context
12
-
13
- if (USER && EMAIL) {
14
- context.logger.info('Configure git with username')
15
-
16
- git.config('--global', 'user.name', USER)
17
- git.config('--global', 'user.email', EMAIL)
18
-
19
- context.logger.info('Configure git branch')
20
- context.logger.success('Workspace is correctly configured')
21
- } else {
22
- context.logger.error(chalk.red('Ignore git configuration (Empty GIT_USER_EMAIL or/and GIT_USER_NAME variables)'))
23
- process.exit(1)
24
- }
25
- git.fetch().sync()
26
- git.checkout(branch.name).sync()
27
- git.branch(`--set-upstream-to=${ORIGIN}/${branch.name}`, branch.name).sync()
28
-
29
- return githubPlugins.verifyConditions(pluginConfig, context)
30
- }
@@ -1,9 +0,0 @@
1
- import { displayPackageInfo } from '../utils/display-package-info.js'
2
- import { displayReleaseInfo } from '../utils/display-release-info.js'
3
- import { getConfig } from '../../common/index.js'
4
-
5
- export function verifyRelease (pluginConfig, context) {
6
- context.config = getConfig()
7
- displayPackageInfo(context)
8
- displayReleaseInfo(context)
9
- }
@@ -1,115 +0,0 @@
1
- import { getConfig } from '../common/get-config.js'
2
- import { WORKFLOW_CONFIGURATION } from '../workflow/index.js'
3
-
4
- const releaseRules = WORKFLOW_CONFIGURATION.map(({ label, ...props }) => props)
5
- const commitTypeMapping = WORKFLOW_CONFIGURATION.reduce((obj, { type, label }) => {
6
- return {
7
- ...obj,
8
- [type]: label
9
- }
10
- }, {})
11
-
12
- const transformCommitType = commit => {
13
- if (commitTypeMapping[commit.type]) {
14
- return commitTypeMapping[commit.type]
15
- }
16
-
17
- return commitTypeMapping.default
18
- }
19
-
20
- const transform = (commit, context) => {
21
- const issues = []
22
-
23
- commit.notes.forEach(note => {
24
- note.title = 'BREAKING CHANGES'
25
- })
26
-
27
- commit.type = transformCommitType(commit)
28
-
29
- if (commit.message && commit.message.match(/^[\w-]+$/i)) {
30
- return
31
- }
32
-
33
- if (commit.subject) {
34
- commit.subject = commit.subject.replace('[MEP]', '')
35
- }
36
-
37
- if (commit.scope === '*') {
38
- commit.scope = ''
39
- }
40
-
41
- if (typeof commit.hash === 'string') {
42
- commit.shortHash = commit.hash.substring(0, 7)
43
- }
44
-
45
- if (typeof commit.subject === 'string') {
46
- let url = context.repository
47
- ? `${context.host}/${context.owner}/${context.repository}`
48
- : context.repoUrl
49
- if (url) {
50
- url = `${url}/issues/`
51
- // Issue URLs.
52
- commit.subject = commit.subject.replace(/#([0-9]+)/g, (_, issue) => {
53
- issues.push(issue)
54
- return `[#${issue}](${url}${issue})`
55
- })
56
- }
57
- if (context.host) {
58
- // User URLs.
59
- commit.subject = commit.subject.replace(
60
- /\B@([a-z0-9](?:-?[a-z0-9/]){0,38})/g,
61
- (_, username) => {
62
- if (username.includes('/')) {
63
- return `@${username}`
64
- }
65
-
66
- return `[@${username}](${context.host}/${username})`
67
- }
68
- )
69
- }
70
- }
71
-
72
- // remove references that already appear in the subject
73
- commit.references = commit.references.filter(reference => {
74
- if (issues.indexOf(reference.issue) === -1) {
75
- return true
76
- }
77
-
78
- return false
79
- })
80
-
81
- return commit
82
- }
83
-
84
- export function getSemanticConfig () {
85
- const config = getConfig()
86
-
87
- return {
88
- noCi: config.PRODUCTION_BRANCH !== config.BRANCH_NAME,
89
- branches: [
90
- {
91
- name: config.PRODUCTION_BRANCH,
92
- channel: 'release'
93
- },
94
- // Use this hack to always run semantic-release (as prerelease for feature/fix branch)
95
- {
96
- name: config.BRANCH_NAME,
97
- channel: 'prerelease',
98
- prerelease: true
99
- }
100
- ],
101
- verifyConditions: ['@cmflow/cli/semantic'],
102
- analyzeCommits: ['@cmflow/cli/semantic'],
103
- verifyRelease: ['@cmflow/cli/semantic'],
104
- generateNotes: ['@cmflow/cli/semantic'],
105
- prepare: ['@cmflow/cli/semantic'],
106
- publish: ['@cmflow/cli/semantic'],
107
- success: ['@cmflow/cli/semantic'],
108
- fail: ['@cmflow/cli/semantic'],
109
- releaseRules,
110
- parserOpts: {
111
- noteKeywords: ['BREAKING CHANGE', 'BREAKING CHANGES']
112
- },
113
- writerOpts: { transform }
114
- }
115
- }