@cmflow/cli 1.1.1-alpha.1 → 2.0.0-alpha.10
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.
- package/.yarn/install-state.gz +0 -0
- package/.yarn/releases/yarn-4.7.0.cjs +935 -0
- package/.yarnrc.yml +3 -0
- package/README.md +78 -10
- package/bin/cm-config.js +0 -0
- package/bin/cm-fetch.js +0 -0
- package/bin/cm-finish.js +0 -0
- package/bin/cm-merge.js +0 -0
- package/bin/cm-publish.js +0 -0
- package/bin/cm-push.js +0 -0
- package/bin/cm-rebase.js +0 -0
- package/bin/cm-republish.js +0 -0
- package/bin/cm-start.js +0 -0
- package/bin/cm.js +0 -0
- package/bin/cmrelease.js +0 -0
- package/package.json +25 -29
- package/release.config.mjs +8 -22
- package/src/commands/index.js +0 -1
- package/src/semantic/core/conditional.js +42 -0
- package/src/semantic/core/prepare/commit.js +29 -0
- package/src/semantic/core/prepare/release-info.js +5 -0
- package/src/semantic/core/publish/exit.js +7 -0
- package/src/semantic/core/publish/sync-repository.js +42 -0
- package/src/semantic/utils/release-rules.js +11 -1
- package/src/semantic/utils/transform-writer.js +2 -0
- package/bin/cm-changelog.js +0 -26
- package/src/commands/changelog.js +0 -47
- package/src/semantic/core/fail.js +0 -29
- package/src/semantic/core/generate-notes.js +0 -11
- package/src/semantic/core/prepare/post.js +0 -38
- package/src/semantic/core/publish.js +0 -9
- package/src/semantic/core/success.js +0 -37
package/.yarnrc.yml
ADDED
package/README.md
CHANGED
|
@@ -50,7 +50,15 @@ export default defineConfig({
|
|
|
50
50
|
verifyConditions: ['@cmflow/cli/semantic/verify-conditions'],
|
|
51
51
|
analyzeCommits: ['@cmflow/cli/semantic/analyze-commits'],
|
|
52
52
|
verifyRelease: ['@cmflow/cli/semantic/verify-release'],
|
|
53
|
-
generateNotes: [
|
|
53
|
+
generateNotes: [
|
|
54
|
+
[
|
|
55
|
+
"@cmflow/cli/semantic/conditional", // add this task to trigger build npm task
|
|
56
|
+
{
|
|
57
|
+
// when: (context) => context.branch.type === "release" // default condition to run the task
|
|
58
|
+
run: ["@semantic-release/release-notes-generator"]
|
|
59
|
+
}
|
|
60
|
+
]
|
|
61
|
+
],
|
|
54
62
|
prepare: [
|
|
55
63
|
'@cmflow/cli/semantic/prepare/bump-version',
|
|
56
64
|
[
|
|
@@ -65,29 +73,50 @@ export default defineConfig({
|
|
|
65
73
|
command: 'test_e2e'
|
|
66
74
|
}
|
|
67
75
|
],
|
|
68
|
-
|
|
76
|
+
[
|
|
77
|
+
'@cmflow/cli/semantic/conditional', // add this task to trigger build npm task
|
|
78
|
+
{
|
|
79
|
+
// when: (context) => context.branch.type === "release" // default condition to run the task
|
|
80
|
+
run: [
|
|
81
|
+
'@cmflow/cli/semantic/core/prepare/commit'
|
|
82
|
+
]
|
|
83
|
+
}
|
|
84
|
+
]
|
|
69
85
|
],
|
|
70
86
|
publish: [
|
|
71
87
|
[
|
|
72
|
-
'@cmflow/cli/semantic/
|
|
88
|
+
'@cmflow/cli/semantic/conditional',
|
|
73
89
|
{
|
|
74
|
-
|
|
90
|
+
// when: (context) => context.branch.type === "release" // default condition to run the task
|
|
91
|
+
run: [
|
|
92
|
+
'@cmflow/cli/semantic/publish/sync-repository',
|
|
93
|
+
'@semantic-release/github'
|
|
94
|
+
] // only run if the conditional rule is true
|
|
95
|
+
}
|
|
96
|
+
],
|
|
97
|
+
[
|
|
98
|
+
'@cmflow/cli/semantic/conditional', // run process.exit(0) if the branch is not a release branch - legacy: maybe not necessary now all task are conditional
|
|
99
|
+
{
|
|
100
|
+
when: (context) => context.branch.type !== 'release',
|
|
101
|
+
run: '@cmflow/cli/semantic/publish/exit.js'
|
|
75
102
|
}
|
|
76
103
|
]
|
|
77
104
|
],
|
|
78
105
|
success: [
|
|
79
106
|
[
|
|
80
|
-
'@cmflow/cli/semantic/
|
|
107
|
+
'@cmflow/cli/semantic/conditional',
|
|
81
108
|
{
|
|
82
|
-
|
|
109
|
+
// when: (context) => context.branch.type === "release" // default condition to run the task
|
|
110
|
+
run: '@semantic-release/github' // only run if the conditional rule is true
|
|
83
111
|
}
|
|
84
112
|
]
|
|
85
113
|
],
|
|
86
114
|
fail: [
|
|
87
115
|
[
|
|
88
|
-
|
|
116
|
+
"@cmflow/cli/semantic/conditional",
|
|
89
117
|
{
|
|
90
|
-
|
|
118
|
+
// when: (context) => context.branch.type === "release" // default condition to run the task
|
|
119
|
+
run: '@semantic-release/github' // only run if the conditional rule is true
|
|
91
120
|
}
|
|
92
121
|
]
|
|
93
122
|
],
|
|
@@ -108,6 +137,25 @@ Then edit your `package.json` add the following tasks on script property:
|
|
|
108
137
|
|
|
109
138
|
Now, CmFlow and semantic release are correctly installed on your project.
|
|
110
139
|
|
|
140
|
+
### Condition step (publish, success, fail)
|
|
141
|
+
|
|
142
|
+
CMFlow provide a `@cmflow/cli/semantic/conditional` task to run one task or many task only if a condition is true. The condition is a
|
|
143
|
+
function that takes the semantic context as parameter and return a boolean.
|
|
144
|
+
|
|
145
|
+
You can customize the condition to run the task by adding a `when` property to the configuration object.
|
|
146
|
+
|
|
147
|
+
```javascript
|
|
148
|
+
export default defineConfig({
|
|
149
|
+
publish: [
|
|
150
|
+
'@cmflow/cli/semantic/conditional',
|
|
151
|
+
{
|
|
152
|
+
when: (context) => context.branch.type === 'release', // default condition to run the task
|
|
153
|
+
run: ['@semantic-release/github', '@semantic-release/github'] // only run if the conditional rule is true
|
|
154
|
+
}
|
|
155
|
+
]
|
|
156
|
+
})
|
|
157
|
+
```
|
|
158
|
+
|
|
111
159
|
### Build and E2E Test
|
|
112
160
|
|
|
113
161
|
CmFlow release are able to run `build` and `test_e2e` task during the prepare step. It's useful when you want to
|
|
@@ -125,6 +173,26 @@ Example:
|
|
|
125
173
|
}
|
|
126
174
|
```
|
|
127
175
|
|
|
176
|
+
### Generate release.info file
|
|
177
|
+
|
|
178
|
+
CmFlow release generate a `release.info` file in the root of your project. This file contains the branch name.
|
|
179
|
+
|
|
180
|
+
```js
|
|
181
|
+
import { defineConfig } from '@cmflow/cli'
|
|
182
|
+
|
|
183
|
+
export default defineConfig({
|
|
184
|
+
prepare: [
|
|
185
|
+
'@cmflow/cli/semantic/prepare/bump-version',
|
|
186
|
+
[
|
|
187
|
+
'@cmflow/cli/semantic/prepare/release-info',
|
|
188
|
+
{
|
|
189
|
+
path: './resources/release.info'
|
|
190
|
+
}
|
|
191
|
+
]
|
|
192
|
+
]
|
|
193
|
+
})
|
|
194
|
+
```
|
|
195
|
+
|
|
128
196
|
### Deploy on Docker Hub
|
|
129
197
|
|
|
130
198
|
Add the following configuration to your `release.config.js`:
|
|
@@ -135,9 +203,9 @@ import { defineConfig } from '@cmflow/cli'
|
|
|
135
203
|
export default defineConfig({
|
|
136
204
|
publish: [
|
|
137
205
|
[
|
|
138
|
-
'@cmflow/cli/semantic/
|
|
206
|
+
'@cmflow/cli/semantic/conditional',
|
|
139
207
|
{
|
|
140
|
-
|
|
208
|
+
run: '@semantic-release/github'
|
|
141
209
|
}
|
|
142
210
|
],
|
|
143
211
|
'@cmflow/cli/semantic/docker/publish'
|
package/bin/cm-config.js
CHANGED
|
File without changes
|
package/bin/cm-fetch.js
CHANGED
|
File without changes
|
package/bin/cm-finish.js
CHANGED
|
File without changes
|
package/bin/cm-merge.js
CHANGED
|
File without changes
|
package/bin/cm-publish.js
CHANGED
|
File without changes
|
package/bin/cm-push.js
CHANGED
|
File without changes
|
package/bin/cm-rebase.js
CHANGED
|
File without changes
|
package/bin/cm-republish.js
CHANGED
|
File without changes
|
package/bin/cm-start.js
CHANGED
|
File without changes
|
package/bin/cm.js
CHANGED
|
File without changes
|
package/bin/cmrelease.js
CHANGED
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cmflow/cli",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0-alpha.10",
|
|
4
4
|
"description": "An awesome Git Flow",
|
|
5
5
|
"author": "camfou",
|
|
6
6
|
"license": "MIT",
|
|
@@ -8,36 +8,31 @@
|
|
|
8
8
|
"main": "./src/index.js",
|
|
9
9
|
"module": "./src/index.js",
|
|
10
10
|
"type": "module",
|
|
11
|
-
"private": false,
|
|
12
11
|
"bin": {
|
|
12
|
+
"checkfeatures": "./bin/checkfeatures.sh",
|
|
13
13
|
"cm": "./bin/cm.js",
|
|
14
|
+
"cmconfig": "bin/cm-config.js",
|
|
15
|
+
"cmexpedit": "./bin/cmexpedit.sh",
|
|
14
16
|
"cmfetch": "bin/cm-fetch.js",
|
|
15
|
-
"cmrebase": "bin/cm-rebase.js",
|
|
16
17
|
"cmfinish": "bin/cm-finish.js",
|
|
17
|
-
"
|
|
18
|
+
"cmmerge": "./bin/cm-merge.js",
|
|
18
19
|
"cmpublish": "bin/cm-publish.js",
|
|
19
|
-
"cmrepublish": "bin/cm-republish.js",
|
|
20
|
-
"cmpush": "bin/cm-push.js",
|
|
21
20
|
"cmpull": "./bin/cmpull.sh",
|
|
22
|
-
"
|
|
23
|
-
"
|
|
21
|
+
"cmpush": "bin/cm-push.js",
|
|
22
|
+
"cmrebase": "bin/cm-rebase.js",
|
|
24
23
|
"cmrelease": "./bin/cmrelease.js",
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"cmconfig": "bin/cm-config.js"
|
|
24
|
+
"cmrepublish": "bin/cm-republish.js",
|
|
25
|
+
"cmstart": "bin/cm-start.js"
|
|
28
26
|
},
|
|
29
27
|
"exports": {
|
|
30
|
-
".": "./index.js",
|
|
31
|
-
"./semantic
|
|
32
|
-
"./semantic/*": "./src/semantic-release/core/*.js",
|
|
33
|
-
"./semantic/docker/*": "./src/semantic-release/docker/*.js"
|
|
28
|
+
".": "./src/index.js",
|
|
29
|
+
"./semantic/*": "./src/semantic/*.js"
|
|
34
30
|
},
|
|
35
31
|
"dependencies": {
|
|
32
|
+
"any-observable": "0.5.1",
|
|
36
33
|
"axios": "1.8.2",
|
|
37
34
|
"chalk": "^4.1.0",
|
|
38
35
|
"commander": "5.1.0",
|
|
39
|
-
"conventional-changelog": "3.1.25",
|
|
40
|
-
"conventional-changelog-cli": "2.2.2",
|
|
41
36
|
"execa": "5.1.1",
|
|
42
37
|
"figures": "3.2.0",
|
|
43
38
|
"fs-extra": "^10.1.0",
|
|
@@ -47,14 +42,16 @@
|
|
|
47
42
|
"listr": "0.14.3",
|
|
48
43
|
"lodash": "4.17.21",
|
|
49
44
|
"rxjs": "7.8.1",
|
|
50
|
-
"semantic-release": "
|
|
51
|
-
"semver": "7.
|
|
45
|
+
"semantic-release": ">=24.2.3",
|
|
46
|
+
"semver": "7.7.1",
|
|
52
47
|
"split": "1.0.1"
|
|
53
48
|
},
|
|
54
49
|
"devDependencies": {
|
|
50
|
+
"@semantic-release/github": "11.0.1",
|
|
51
|
+
"@semantic-release/release-notes-generator": ">=14.0.3",
|
|
55
52
|
"@stylistic/eslint-plugin": "^4.2.0",
|
|
56
|
-
"@typescript-eslint/parser": "8.26.1",
|
|
57
53
|
"@typescript-eslint/eslint-plugin": "8.26.1",
|
|
54
|
+
"@typescript-eslint/parser": "8.26.1",
|
|
58
55
|
"eslint": "9.21.0",
|
|
59
56
|
"eslint-config-prettier": "10.0.2",
|
|
60
57
|
"eslint-formatter-junit": "^8.40.0",
|
|
@@ -62,15 +59,14 @@
|
|
|
62
59
|
"eslint-plugin-simple-import-sort": "12.1.1",
|
|
63
60
|
"eslint-plugin-vitest": "0.5.4",
|
|
64
61
|
"husky": "4.3.6",
|
|
65
|
-
"prettier": "3.5.1",
|
|
66
62
|
"lint-staged": "10.5.3",
|
|
67
|
-
"
|
|
68
|
-
"typescript": "5.8.2"
|
|
63
|
+
"prettier": "3.5.1",
|
|
64
|
+
"typescript": "5.8.2",
|
|
65
|
+
"vitest": "^3.0.8"
|
|
69
66
|
},
|
|
70
67
|
"peerDependencies": {
|
|
71
|
-
"@semantic-release/commit-analyzer": "
|
|
72
|
-
"@semantic-release/
|
|
73
|
-
"@semantic-release/release-notes-generator": "^12.1.0"
|
|
68
|
+
"@semantic-release/commit-analyzer": ">=13.0.1",
|
|
69
|
+
"@semantic-release/release-notes-generator": ">=14.0.3"
|
|
74
70
|
},
|
|
75
71
|
"peerDependenciesMeta": {
|
|
76
72
|
"@semantic-release/commit-analyzer": {
|
|
@@ -87,8 +83,7 @@
|
|
|
87
83
|
"lint_ci": "eslint --format junit --output-file ./reports/eslint.xml",
|
|
88
84
|
"lint_fix": "eslint --fix",
|
|
89
85
|
"release": "node bin/cmrelease.js",
|
|
90
|
-
"release_dry_run": "node bin/cmrelease.js --dry-run"
|
|
91
|
-
"build_changelog": "node bin/cm-changelog.js"
|
|
86
|
+
"release_dry_run": "node bin/cmrelease.js --dry-run"
|
|
92
87
|
},
|
|
93
88
|
"husky": {
|
|
94
89
|
"hooks": {
|
|
@@ -107,5 +102,6 @@
|
|
|
107
102
|
"develop": "master",
|
|
108
103
|
"production": "master"
|
|
109
104
|
}
|
|
110
|
-
}
|
|
105
|
+
},
|
|
106
|
+
"packageManager": "yarn@4.7.0"
|
|
111
107
|
}
|
package/release.config.mjs
CHANGED
|
@@ -20,33 +20,19 @@ export default defineConfig({
|
|
|
20
20
|
}
|
|
21
21
|
],
|
|
22
22
|
verifyConditions: ["./src/semantic/core/verify-conditions.js"],
|
|
23
|
-
analyzeCommits: ["
|
|
23
|
+
analyzeCommits: ["@semantic-release/commit-analyzer"],
|
|
24
24
|
verifyRelease: ["./src/semantic/core/verify-release.js"],
|
|
25
|
-
generateNotes: [
|
|
26
|
-
prepare: ["./src/semantic/core/prepare/bump-version.js", "./src/semantic/core/prepare/post.js"],
|
|
27
|
-
publish: [
|
|
25
|
+
generateNotes: [
|
|
28
26
|
[
|
|
29
|
-
"./src/semantic/core/
|
|
27
|
+
"./src/semantic/core/conditional",
|
|
30
28
|
{
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
]
|
|
34
|
-
],
|
|
35
|
-
success: [
|
|
36
|
-
[
|
|
37
|
-
"./src/semantic/core/success.js",
|
|
38
|
-
{
|
|
39
|
-
runAfter: "@semantic-release/github"
|
|
40
|
-
}
|
|
41
|
-
]
|
|
42
|
-
],
|
|
43
|
-
fail: [
|
|
44
|
-
[
|
|
45
|
-
"./src/semantic/core/fail.js",
|
|
46
|
-
{
|
|
47
|
-
runAfter: "@semantic-release/github"
|
|
29
|
+
run: ["@semantic-release/release-notes-generator"]
|
|
48
30
|
}
|
|
49
31
|
]
|
|
50
32
|
],
|
|
33
|
+
prepare: ["./src/semantic/core/prepare/bump-version.js", "./src/semantic/core/prepare/commit.js"],
|
|
34
|
+
publish: ["./src/semantic/core/publish/sync-repository.js", "@semantic-release/github"],
|
|
35
|
+
success: ["@semantic-release/github"],
|
|
36
|
+
fail: ["@semantic-release/github"],
|
|
51
37
|
npmPublish: false
|
|
52
38
|
});
|
package/src/commands/index.js
CHANGED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { getConfig } from "../../common/index.js";
|
|
2
|
+
|
|
3
|
+
export function prepare(pluginConfig, context) {
|
|
4
|
+
return runAll("prepare", pluginConfig, context, context.branch?.type === "release");
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export function success(pluginConfig, context) {
|
|
8
|
+
return runAll("success", pluginConfig, context, context.branch?.type === "release");
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function publish(pluginConfig, context) {
|
|
12
|
+
return runAll("publish", pluginConfig, context, context.branch?.type === "release");
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function generateNotes(pluginConfig, context) {
|
|
16
|
+
return runAll("generateNotes", pluginConfig, context, context.branch?.type === "release");
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function fail(pluginConfig, context) {
|
|
20
|
+
return runAll("fail", pluginConfig, context, context.branch?.type === "release");
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
async function runAll(step, pluginConfig, context, defaultCondition) {
|
|
24
|
+
context.config = getConfig();
|
|
25
|
+
|
|
26
|
+
const condition = pluginConfig.when !== undefined ? pluginConfig.if(context) : defaultCondition;
|
|
27
|
+
|
|
28
|
+
if (condition && pluginConfig.run) {
|
|
29
|
+
const tasks = [].concat(pluginConfig.run);
|
|
30
|
+
|
|
31
|
+
for (const task of tasks) {
|
|
32
|
+
if (typeof task === "string") {
|
|
33
|
+
const mod = await import(task);
|
|
34
|
+
const taskFunction = mod[step];
|
|
35
|
+
|
|
36
|
+
if (taskFunction) {
|
|
37
|
+
await taskFunction(pluginConfig, context);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { configureGitWorkspace, getConfig, git } from "../../../common/index.js";
|
|
2
|
+
|
|
3
|
+
export async function prepare(pluginConfig, context) {
|
|
4
|
+
context.config = getConfig();
|
|
5
|
+
|
|
6
|
+
const {
|
|
7
|
+
logger,
|
|
8
|
+
config: { CI_NAME, BUILD_NUMBER }
|
|
9
|
+
} = context;
|
|
10
|
+
|
|
11
|
+
logger.info("Prepare release");
|
|
12
|
+
|
|
13
|
+
configureGitWorkspace(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
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { getConfig } from "../../../common/index.js";
|
|
2
|
+
|
|
3
|
+
export async function prepare(pluginConfig, context) {
|
|
4
|
+
context.config = getConfig();
|
|
5
|
+
// avoid next semantic-release steps when is a prerelease or release branch with SKIP_GITHUB_PUBLISH
|
|
6
|
+
process.exit(0);
|
|
7
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { getConfig, git } from "../../../common/index.js";
|
|
2
|
+
|
|
3
|
+
export async function publish(pluginConfig, context) {
|
|
4
|
+
context.config = getConfig();
|
|
5
|
+
|
|
6
|
+
const {
|
|
7
|
+
logger,
|
|
8
|
+
config: { PRODUCTION_BRANCH, ORIGIN, DEVELOP_BRANCH }
|
|
9
|
+
} = context;
|
|
10
|
+
|
|
11
|
+
logger.info("Prepare release");
|
|
12
|
+
|
|
13
|
+
async function asyncCatchError(fn) {
|
|
14
|
+
try {
|
|
15
|
+
return await fn();
|
|
16
|
+
} catch (er) {
|
|
17
|
+
context.logger.error(String(er), er.stack);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
await asyncCatchError(() => git.fetch());
|
|
22
|
+
|
|
23
|
+
if ([PRODUCTION_BRANCH, "alpha", "beta", "rc"].includes(context.branch.name)) {
|
|
24
|
+
logger.info(`Push ${PRODUCTION_BRANCH}`);
|
|
25
|
+
|
|
26
|
+
await asyncCatchError(() => {
|
|
27
|
+
logger.info(`git push --quiet --set-upstream ${ORIGIN} ${context.branch.name}`);
|
|
28
|
+
|
|
29
|
+
return git.push("--quiet", "--set-upstream", ORIGIN, context.branch.name);
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (PRODUCTION_BRANCH !== DEVELOP_BRANCH) {
|
|
34
|
+
logger.info(`Sync ${DEVELOP_BRANCH} with ${PRODUCTION_BRANCH}`);
|
|
35
|
+
logger.info(`git push -f ${ORIGIN} ${PRODUCTION_BRANCH}:refs/heads/${DEVELOP_BRANCH}`);
|
|
36
|
+
|
|
37
|
+
await asyncCatchError(async () => {
|
|
38
|
+
await git.push("-f", ORIGIN, `${PRODUCTION_BRANCH}:refs/heads/${DEVELOP_BRANCH}`);
|
|
39
|
+
logger.success(`${ORIGIN}/${DEVELOP_BRANCH} branch correctly updated`);
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -2,4 +2,14 @@ import omit from "lodash/omit.js";
|
|
|
2
2
|
|
|
3
3
|
import { WORKFLOW_CONFIGURATION } from "../../workflow/index.js";
|
|
4
4
|
|
|
5
|
-
export const releaseRules =
|
|
5
|
+
export const releaseRules = [
|
|
6
|
+
{
|
|
7
|
+
breaking: true,
|
|
8
|
+
release: "major"
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
revert: true,
|
|
12
|
+
release: "patch"
|
|
13
|
+
},
|
|
14
|
+
...WORKFLOW_CONFIGURATION.map((props) => omit(props, ["label"]))
|
|
15
|
+
];
|
package/bin/cm-changelog.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import commander from "commander";
|
|
4
|
-
|
|
5
|
-
import { commands, runCommand } from "../src/index.js";
|
|
6
|
-
|
|
7
|
-
commander
|
|
8
|
-
.usage("cmchangelog [options]")
|
|
9
|
-
.alias("cm changelog")
|
|
10
|
-
.option(
|
|
11
|
-
"-p, --preset <preset>",
|
|
12
|
-
"Name of the preset you want to use. Must be one of the following:\n" +
|
|
13
|
-
"angular, atom, codemirror, ember, eslint, express, jquery, jscs or jshint",
|
|
14
|
-
"angular"
|
|
15
|
-
)
|
|
16
|
-
.option(
|
|
17
|
-
"-r, --release-count <count>",
|
|
18
|
-
"How many releases to be generated from the latest\n" +
|
|
19
|
-
"If 0, the whole changelog will be regenerated and the outfile will be overwritten\n" +
|
|
20
|
-
"Default: 0",
|
|
21
|
-
0
|
|
22
|
-
)
|
|
23
|
-
.option("-t, --tag-prefix <prefix>", "Tag prefix to consider when reading the tags")
|
|
24
|
-
.parse(process.argv);
|
|
25
|
-
|
|
26
|
-
runCommand(commands.Changelog, commander);
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import conventionalChangelog from "conventional-changelog";
|
|
2
|
-
import { createWriteStream } from "fs";
|
|
3
|
-
import { Observable } from "rxjs";
|
|
4
|
-
|
|
5
|
-
export class Changelog {
|
|
6
|
-
mapContext(commander, config) {
|
|
7
|
-
return {
|
|
8
|
-
preset: commander.preset || "angular",
|
|
9
|
-
releaseCount: commander.releaseCount || 0,
|
|
10
|
-
outfile: `${process.cwd()}/CHANGELOG.md`,
|
|
11
|
-
|
|
12
|
-
tagPrefix: (config.tagFormat || commander.tagPrefix || "").replace("${version}", "")
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
exec({ preset, releaseCount, outfile, tagPrefix }) {
|
|
17
|
-
const writableStream = createWriteStream(outfile, { encoding: "utf8" });
|
|
18
|
-
|
|
19
|
-
return new Observable((observer) => {
|
|
20
|
-
const stream = conventionalChangelog({
|
|
21
|
-
preset,
|
|
22
|
-
releaseCount,
|
|
23
|
-
path: `${process.cwd()}/package.json`,
|
|
24
|
-
tagPrefix
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
stream.pipe(writableStream);
|
|
28
|
-
|
|
29
|
-
stream.on("error", (err) => {
|
|
30
|
-
observer.error(err);
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
stream.on("end", () => {
|
|
34
|
-
observer.complete();
|
|
35
|
-
});
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
getTasks(ctx) {
|
|
40
|
-
return [
|
|
41
|
-
{
|
|
42
|
-
title: "Generate changelog",
|
|
43
|
-
task: () => this.exec(ctx)
|
|
44
|
-
}
|
|
45
|
-
];
|
|
46
|
-
}
|
|
47
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { git } from "../../common/index.js";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Remove the tag from the git repository if the release is not a prerelease.
|
|
5
|
-
*
|
|
6
|
-
* Add runAfter property with the semantic-release plugin name to run after the fail task.
|
|
7
|
-
*
|
|
8
|
-
* @param pluginConfig {{runAfter: string}}
|
|
9
|
-
* @param context
|
|
10
|
-
* @return {Promise<void>}
|
|
11
|
-
*/
|
|
12
|
-
export async function fail(pluginConfig, context) {
|
|
13
|
-
if (context.branch && context.branch.type !== "prerelease") {
|
|
14
|
-
const {
|
|
15
|
-
tagFormat,
|
|
16
|
-
config: { ORIGIN }
|
|
17
|
-
} = context;
|
|
18
|
-
|
|
19
|
-
try {
|
|
20
|
-
await git.push("--delete", ORIGIN, tagFormat.replace("${version}", context.nextRelease.version));
|
|
21
|
-
} catch {}
|
|
22
|
-
|
|
23
|
-
if (pluginConfig.runAfter) {
|
|
24
|
-
const { fail } = await import(pluginConfig.runAfter);
|
|
25
|
-
|
|
26
|
-
await fail(pluginConfig, context);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import * as releaseNotesPlugins from "@semantic-release/release-notes-generator";
|
|
2
|
-
|
|
3
|
-
import { getConfig } from "../../common/index.js";
|
|
4
|
-
|
|
5
|
-
export async function generateNotes(pluginConfig, context) {
|
|
6
|
-
context.config = getConfig();
|
|
7
|
-
|
|
8
|
-
if (context.branch.type === "release") {
|
|
9
|
-
return releaseNotesPlugins.generateNotes(pluginConfig, context);
|
|
10
|
-
}
|
|
11
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { configureGitWorkspace, getConfig, git } from "../../../common/index.js";
|
|
2
|
-
|
|
3
|
-
export async function prepare(pluginConfig, context) {
|
|
4
|
-
context.config = getConfig();
|
|
5
|
-
const { branch } = context;
|
|
6
|
-
|
|
7
|
-
if (branch.type === "release") {
|
|
8
|
-
context.config = getConfig();
|
|
9
|
-
|
|
10
|
-
const {
|
|
11
|
-
logger,
|
|
12
|
-
config: { CI_NAME, BUILD_NUMBER }
|
|
13
|
-
} = context;
|
|
14
|
-
|
|
15
|
-
logger.info("Prepare release");
|
|
16
|
-
|
|
17
|
-
configureGitWorkspace(context);
|
|
18
|
-
|
|
19
|
-
logger.info("Adding files to commit");
|
|
20
|
-
git.add("-A").sync();
|
|
21
|
-
|
|
22
|
-
logger.info("Get commit stage status");
|
|
23
|
-
git.status();
|
|
24
|
-
|
|
25
|
-
const revisionMessage = `${CI_NAME} build: ${context.branch.name} ${BUILD_NUMBER} ${context.nextRelease.gitTag} [ci skip]`;
|
|
26
|
-
|
|
27
|
-
logger.info("Commit changes with revision message: ");
|
|
28
|
-
logger.info(revisionMessage);
|
|
29
|
-
|
|
30
|
-
git.commit("-m", revisionMessage).sync();
|
|
31
|
-
|
|
32
|
-
logger.success("Change committed");
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
// avoid next semantic-release steps when is a prerelease or release branch with SKIP_GITHUB_PUBLISH
|
|
37
|
-
process.exit(0);
|
|
38
|
-
}
|