@cmflow/cli 2.0.0-alpha.8 → 2.0.0-rc.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.
- package/.yarn/install-state.gz +0 -0
- package/README.md +41 -34
- package/package.json +2 -4
- package/release.config.mjs +1 -1
- package/src/common/configure-git-workspace.js +6 -1
- package/src/common/get-config.js +17 -4
- package/src/semantic/core/conditional.js +16 -3
- package/src/semantic/core/exit.js +14 -0
- package/src/semantic/core/{prepare/run.js → run.js} +2 -2
- package/src/semantic/core/{publish/sync-repository.js → sync-repository.js} +2 -2
- package/src/semantic/define-config.js +0 -26
- package/src/semantic/utils/transform-writer.js +2 -0
- package/src/semantic/core/publish/exit.js +0 -7
package/.yarn/install-state.gz
CHANGED
|
Binary file
|
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<h1 style="text-align: center" align="center"
|
|
1
|
+
<h1 style="text-align: center" align="center">@clubmed/cli aka ClubMed Flow </h1>
|
|
2
2
|
|
|
3
3
|
<div align="center">
|
|
4
4
|
|
|
@@ -47,64 +47,63 @@ Then create `release.config.js` with this configuration:
|
|
|
47
47
|
import { defineConfig } from '@cmflow/cli'
|
|
48
48
|
|
|
49
49
|
export default defineConfig({
|
|
50
|
-
verifyConditions: ['@cmflow/cli/semantic/verify-conditions'],
|
|
51
|
-
analyzeCommits: ['@cmflow/cli/semantic/analyze-commits'],
|
|
52
|
-
verifyRelease: ['@cmflow/cli/semantic/verify-release'],
|
|
50
|
+
verifyConditions: ['@cmflow/cli/semantic/core/verify-conditions'],
|
|
51
|
+
analyzeCommits: ['@cmflow/cli/semantic/core/analyze-commits'],
|
|
52
|
+
verifyRelease: ['@cmflow/cli/semantic/core/verify-release'],
|
|
53
53
|
generateNotes: [
|
|
54
54
|
[
|
|
55
55
|
"@cmflow/cli/semantic/conditional", // add this task to trigger build npm task
|
|
56
56
|
{
|
|
57
57
|
// when: (context) => context.branch.type === "release" // default condition to run the task
|
|
58
|
-
run: ["@semantic-release/release-notes-generator"]
|
|
58
|
+
run: ["@semantic-release/core/release-notes-generator"]
|
|
59
59
|
}
|
|
60
60
|
]
|
|
61
61
|
],
|
|
62
62
|
prepare: [
|
|
63
|
-
'@cmflow/cli/semantic/prepare/bump-version',
|
|
63
|
+
'@cmflow/cli/semantic/core/prepare/bump-version',
|
|
64
64
|
[
|
|
65
|
-
'@cmflow/cli/semantic/prepare/run', // add this task to trigger build npm task
|
|
65
|
+
'@cmflow/cli/semantic/core/prepare/run', // add this task to trigger build npm task
|
|
66
66
|
{
|
|
67
67
|
command: 'build'
|
|
68
68
|
}
|
|
69
69
|
],
|
|
70
70
|
[
|
|
71
|
-
'@cmflow/cli/semantic/prepare/run', // add this task to trigger build npm task
|
|
71
|
+
'@cmflow/cli/semantic/core/prepare/run', // add this task to trigger build npm task
|
|
72
72
|
{
|
|
73
73
|
command: 'test_e2e'
|
|
74
74
|
}
|
|
75
75
|
],
|
|
76
76
|
[
|
|
77
|
-
'@cmflow/cli/semantic/conditional', // add this task to trigger build npm task
|
|
77
|
+
'@cmflow/cli/semantic/core/conditional', // add this task to trigger build npm task
|
|
78
78
|
{
|
|
79
79
|
// when: (context) => context.branch.type === "release" // default condition to run the task
|
|
80
80
|
run: [
|
|
81
|
-
'@cmflow/semantic/core/prepare/commit'
|
|
81
|
+
'@cmflow/cli/semantic/core/prepare/commit'
|
|
82
82
|
]
|
|
83
83
|
}
|
|
84
84
|
]
|
|
85
85
|
],
|
|
86
86
|
publish: [
|
|
87
87
|
[
|
|
88
|
-
'@cmflow/cli/semantic/conditional',
|
|
88
|
+
'@cmflow/cli/semantic/core/conditional',
|
|
89
89
|
{
|
|
90
90
|
// when: (context) => context.branch.type === "release" // default condition to run the task
|
|
91
91
|
run: [
|
|
92
|
-
'@cmflow/cli/semantic/
|
|
92
|
+
'@cmflow/cli/semantic/core/sync-repository',
|
|
93
93
|
'@semantic-release/github'
|
|
94
94
|
] // only run if the conditional rule is true
|
|
95
95
|
}
|
|
96
96
|
],
|
|
97
97
|
[
|
|
98
|
-
'@cmflow/cli/semantic/
|
|
98
|
+
'@cmflow/cli/semantic/core/exit', // run process.exit(0) if the branch is not a release branch - legacy: maybe not necessary now all task are conditional
|
|
99
99
|
{
|
|
100
|
-
when: (context) => context.
|
|
101
|
-
run: '@cmflow/cli/semantic/publish/exit.js'
|
|
100
|
+
when: (context) => context.nextRelease.channel === 'prerelease'
|
|
102
101
|
}
|
|
103
102
|
]
|
|
104
103
|
],
|
|
105
104
|
success: [
|
|
106
105
|
[
|
|
107
|
-
'@cmflow/cli/semantic/conditional',
|
|
106
|
+
'@cmflow/cli/semantic/core/conditional',
|
|
108
107
|
{
|
|
109
108
|
// when: (context) => context.branch.type === "release" // default condition to run the task
|
|
110
109
|
run: '@semantic-release/github' // only run if the conditional rule is true
|
|
@@ -113,7 +112,7 @@ export default defineConfig({
|
|
|
113
112
|
],
|
|
114
113
|
fail: [
|
|
115
114
|
[
|
|
116
|
-
"@cmflow/cli/semantic/conditional",
|
|
115
|
+
"@cmflow/cli/semantic/core/conditional",
|
|
117
116
|
{
|
|
118
117
|
// when: (context) => context.branch.type === "release" // default condition to run the task
|
|
119
118
|
run: '@semantic-release/github' // only run if the conditional rule is true
|
|
@@ -139,7 +138,7 @@ Now, CmFlow and semantic release are correctly installed on your project.
|
|
|
139
138
|
|
|
140
139
|
### Condition step (publish, success, fail)
|
|
141
140
|
|
|
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
|
|
141
|
+
CMFlow provide a `@cmflow/cli/semantic/core/conditional` task to run one task or many task only if a condition is true. The condition is a
|
|
143
142
|
function that takes the semantic context as parameter and return a boolean.
|
|
144
143
|
|
|
145
144
|
You can customize the condition to run the task by adding a `when` property to the configuration object.
|
|
@@ -147,7 +146,7 @@ You can customize the condition to run the task by adding a `when` property to t
|
|
|
147
146
|
```javascript
|
|
148
147
|
export default defineConfig({
|
|
149
148
|
publish: [
|
|
150
|
-
'@cmflow/cli/semantic/conditional',
|
|
149
|
+
'@cmflow/cli/semantic/core/conditional',
|
|
151
150
|
{
|
|
152
151
|
when: (context) => context.branch.type === 'release', // default condition to run the task
|
|
153
152
|
run: ['@semantic-release/github', '@semantic-release/github'] // only run if the conditional rule is true
|
|
@@ -172,6 +171,26 @@ Example:
|
|
|
172
171
|
}
|
|
173
172
|
}
|
|
174
173
|
```
|
|
174
|
+
Then:
|
|
175
|
+
|
|
176
|
+
```javascript
|
|
177
|
+
export default defineConfig({
|
|
178
|
+
prepare: [
|
|
179
|
+
[
|
|
180
|
+
'@cmflow/cli/semantic/core/run',
|
|
181
|
+
{
|
|
182
|
+
command: 'build'
|
|
183
|
+
}
|
|
184
|
+
],
|
|
185
|
+
[
|
|
186
|
+
'@cmflow/cli/semantic/core/run',
|
|
187
|
+
{
|
|
188
|
+
command: 'test_e2e'
|
|
189
|
+
}
|
|
190
|
+
]
|
|
191
|
+
]
|
|
192
|
+
})
|
|
193
|
+
```
|
|
175
194
|
|
|
176
195
|
### Generate release.info file
|
|
177
196
|
|
|
@@ -202,33 +221,21 @@ import { defineConfig } from '@cmflow/cli'
|
|
|
202
221
|
|
|
203
222
|
export default defineConfig({
|
|
204
223
|
publish: [
|
|
205
|
-
[
|
|
206
|
-
'@cmflow/cli/semantic/conditional',
|
|
207
|
-
{
|
|
208
|
-
run: '@semantic-release/github'
|
|
209
|
-
}
|
|
210
|
-
],
|
|
211
224
|
'@cmflow/cli/semantic/docker/publish'
|
|
212
225
|
]
|
|
213
226
|
});
|
|
214
227
|
```
|
|
215
228
|
|
|
216
|
-
### Clean docker tags
|
|
229
|
+
### Publish & Clean docker tags
|
|
217
230
|
|
|
218
231
|
```js
|
|
219
232
|
import { defineConfig } from '@cmflow/cli'
|
|
220
233
|
|
|
221
234
|
export default defineConfig({
|
|
222
235
|
success: [
|
|
223
|
-
|
|
224
|
-
'@cmflow/cli/semantic/success',
|
|
225
|
-
{
|
|
226
|
-
runAfter: '@semantic-release/github' // only run if the conditional rule is true
|
|
227
|
-
}
|
|
228
|
-
],
|
|
229
|
-
'@cmflow/cli/semantic/docker/publish'
|
|
236
|
+
'@cmflow/cli/semantic/docker/success'
|
|
230
237
|
]
|
|
231
|
-
})
|
|
238
|
+
})
|
|
232
239
|
```
|
|
233
240
|
|
|
234
241
|
### Configure CI
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cmflow/cli",
|
|
3
|
-
"version": "2.0.0-
|
|
3
|
+
"version": "2.0.0-rc.1",
|
|
4
4
|
"description": "An awesome Git Flow",
|
|
5
5
|
"author": "camfou",
|
|
6
6
|
"license": "MIT",
|
|
@@ -26,9 +26,7 @@
|
|
|
26
26
|
},
|
|
27
27
|
"exports": {
|
|
28
28
|
".": "./src/index.js",
|
|
29
|
-
"./semantic
|
|
30
|
-
"./semantic/*": "./src/semantic/core/*.js",
|
|
31
|
-
"./semantic/docker/*": "./src/semantic/docker/*.js"
|
|
29
|
+
"./semantic/*": "./src/semantic/*.js"
|
|
32
30
|
},
|
|
33
31
|
"dependencies": {
|
|
34
32
|
"any-observable": "0.5.1",
|
package/release.config.mjs
CHANGED
|
@@ -31,7 +31,7 @@ export default defineConfig({
|
|
|
31
31
|
]
|
|
32
32
|
],
|
|
33
33
|
prepare: ["./src/semantic/core/prepare/bump-version.js", "./src/semantic/core/prepare/commit.js"],
|
|
34
|
-
publish: ["./src/semantic/core/
|
|
34
|
+
publish: ["./src/semantic/core/sync-repository.js", "@semantic-release/github"],
|
|
35
35
|
success: ["@semantic-release/github"],
|
|
36
36
|
fail: ["@semantic-release/github"],
|
|
37
37
|
npmPublish: false
|
|
@@ -3,7 +3,7 @@ import { git } from "./cli/git.js";
|
|
|
3
3
|
export function configureGitWorkspace(context) {
|
|
4
4
|
const {
|
|
5
5
|
logger,
|
|
6
|
-
config: { SCM_TOKEN, REPOSITORY_URL, ORIGIN, GIT_USER_NAME, GIT_USER_EMAIL }
|
|
6
|
+
config: { SCM_TOKEN, REPOSITORY_URL, ORIGIN, GIT_USER_NAME, GIT_USER_EMAIL, GIT_DISABLE_SSL }
|
|
7
7
|
} = context;
|
|
8
8
|
|
|
9
9
|
if (GIT_USER_NAME && GIT_USER_EMAIL) {
|
|
@@ -11,6 +11,11 @@ export function configureGitWorkspace(context) {
|
|
|
11
11
|
git.config("--global", "user.email", `"${GIT_USER_EMAIL}"`);
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
+
if (GIT_DISABLE_SSL) {
|
|
15
|
+
logger.info("Disable SSL verification");
|
|
16
|
+
git.config("--global", "http.sslVerify", "false");
|
|
17
|
+
}
|
|
18
|
+
|
|
14
19
|
if (SCM_TOKEN) {
|
|
15
20
|
const repository = REPOSITORY_URL.replace("https://", "");
|
|
16
21
|
|
package/src/common/get-config.js
CHANGED
|
@@ -74,8 +74,20 @@ export function getCI() {
|
|
|
74
74
|
export function getConfig() {
|
|
75
75
|
const pkg = getPackageJson();
|
|
76
76
|
const [owner, projectName] = pkg.name.replace(/^@/, "").split("/");
|
|
77
|
-
const {
|
|
78
|
-
|
|
77
|
+
const {
|
|
78
|
+
PROJECT_NAME,
|
|
79
|
+
DOCKER_HUB_ID,
|
|
80
|
+
DOCKER_HUB_PWD,
|
|
81
|
+
REF_COMMIT,
|
|
82
|
+
GH_TOKEN,
|
|
83
|
+
SCM_TOKEN,
|
|
84
|
+
REPOSITORY_URL,
|
|
85
|
+
GIT_DISABLE_SSL,
|
|
86
|
+
GIT_USER_NAME,
|
|
87
|
+
GIT_USER_EMAIL,
|
|
88
|
+
GITLAB_USER_EMAIL,
|
|
89
|
+
GITLAB_USER_NAME
|
|
90
|
+
} = process.env;
|
|
79
91
|
|
|
80
92
|
const HAS_YARN = hasYarn();
|
|
81
93
|
const IS_YARN_BERRY = HAS_YARN ? fs.existsSync(join(process.cwd(), ".yamlrc.yml")) : false;
|
|
@@ -113,8 +125,9 @@ export function getConfig() {
|
|
|
113
125
|
GH_TOKEN,
|
|
114
126
|
SCM_TOKEN: GH_TOKEN || SCM_TOKEN,
|
|
115
127
|
REPOSITORY_URL: get(pkg, "repository.url", get(pkg, "repository", REPOSITORY_URL)),
|
|
116
|
-
GIT_USER_NAME,
|
|
117
|
-
GIT_USER_EMAIL,
|
|
128
|
+
GIT_USER_NAME: GIT_USER_NAME || GITLAB_USER_NAME,
|
|
129
|
+
GIT_USER_EMAIL: GIT_USER_EMAIL || GITLAB_USER_EMAIL,
|
|
130
|
+
GIT_DISABLE_SSL,
|
|
118
131
|
BUMP_METHOD,
|
|
119
132
|
WORKSPACES: pkg.workspaces || [],
|
|
120
133
|
...getCI()
|
|
@@ -23,9 +23,14 @@ export function fail(pluginConfig, context) {
|
|
|
23
23
|
async function runAll(step, pluginConfig, context, defaultCondition) {
|
|
24
24
|
context.config = getConfig();
|
|
25
25
|
|
|
26
|
-
const condition = pluginConfig.when !== undefined ? pluginConfig.
|
|
26
|
+
const condition = pluginConfig.when !== undefined ? pluginConfig.when(context) : defaultCondition;
|
|
27
27
|
|
|
28
|
-
if (condition
|
|
28
|
+
if (!condition) {
|
|
29
|
+
context.logger.info(`Skip step "${step}" of plugin(s) "${pluginConfig.run}"`);
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (pluginConfig.run) {
|
|
29
34
|
const tasks = [].concat(pluginConfig.run);
|
|
30
35
|
|
|
31
36
|
for (const task of tasks) {
|
|
@@ -34,7 +39,15 @@ async function runAll(step, pluginConfig, context, defaultCondition) {
|
|
|
34
39
|
const taskFunction = mod[step];
|
|
35
40
|
|
|
36
41
|
if (taskFunction) {
|
|
37
|
-
|
|
42
|
+
context.logger.log(` Start conditional step "${step}" of plugin "${task}"`);
|
|
43
|
+
|
|
44
|
+
try {
|
|
45
|
+
await taskFunction(pluginConfig, context);
|
|
46
|
+
context.logger.success(` Completed conditional step "${step}" of plugin "${task}"`);
|
|
47
|
+
} catch (er) {
|
|
48
|
+
context.logger.fail(` Fail conditional step "${step}" of plugin "${task}"`);
|
|
49
|
+
throw er;
|
|
50
|
+
}
|
|
38
51
|
}
|
|
39
52
|
}
|
|
40
53
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { getConfig } from "../../common/index.js";
|
|
2
|
+
|
|
3
|
+
export default async function exit(pluginConfig, context) {
|
|
4
|
+
context.config = getConfig();
|
|
5
|
+
const condition = pluginConfig.when !== undefined ? pluginConfig.when(context) : true;
|
|
6
|
+
|
|
7
|
+
if (condition) {
|
|
8
|
+
// avoid next semantic-release steps when is a prerelease or release branch with SKIP_GITHUB_PUBLISH
|
|
9
|
+
context.logger.success("Skip next semantic-release steps");
|
|
10
|
+
process.exit(0);
|
|
11
|
+
} else {
|
|
12
|
+
context.logger.success("Continue next semantic-release steps");
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { getConfig, npm, yarn } from "
|
|
1
|
+
import { getConfig, npm, yarn } from "../../common/index.js";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* @param pluginConfig {{command: string}}
|
|
5
5
|
* @param context
|
|
6
6
|
* @return {Promise<void>}
|
|
7
7
|
*/
|
|
8
|
-
export async function
|
|
8
|
+
export default async function runCommand(pluginConfig, context) {
|
|
9
9
|
context.config = getConfig();
|
|
10
10
|
const {
|
|
11
11
|
config: { HAS_YARN },
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { getConfig, git } from "
|
|
1
|
+
import { getConfig, git } from "../../common/index.js";
|
|
2
2
|
|
|
3
|
-
export async function
|
|
3
|
+
export default async function syncRepository(pluginConfig, context) {
|
|
4
4
|
context.config = getConfig();
|
|
5
5
|
|
|
6
6
|
const {
|
|
@@ -30,34 +30,8 @@ export function defineConfig(opts = {}) {
|
|
|
30
30
|
generateNotes: ["@cmflow/cli/semantic/generate-notes"],
|
|
31
31
|
prepare: [
|
|
32
32
|
"@cmflow/cli/semantic/prepare/bump-version",
|
|
33
|
-
// '@cmflow/cli/semantic/prepare/build',
|
|
34
|
-
// '@cmflow/cli/semantic/prepare/e2e',
|
|
35
33
|
"@cmflow/cli/semantif/prepare/post" // need to avoid semantic next step
|
|
36
34
|
],
|
|
37
|
-
publish: [
|
|
38
|
-
[
|
|
39
|
-
"@cmflow/cli/semantic/publish",
|
|
40
|
-
{
|
|
41
|
-
runAfter: opts.runAfter
|
|
42
|
-
}
|
|
43
|
-
]
|
|
44
|
-
],
|
|
45
|
-
success: [
|
|
46
|
-
[
|
|
47
|
-
"@cmflow/cli/semantic/success",
|
|
48
|
-
{
|
|
49
|
-
runAfter: opts.runAfter
|
|
50
|
-
}
|
|
51
|
-
]
|
|
52
|
-
],
|
|
53
|
-
fail: [
|
|
54
|
-
[
|
|
55
|
-
"@cmflow/cli/semantic/fail",
|
|
56
|
-
{
|
|
57
|
-
runAfter: opts.runAfter
|
|
58
|
-
}
|
|
59
|
-
]
|
|
60
|
-
],
|
|
61
35
|
releaseRules,
|
|
62
36
|
parserOpts: {
|
|
63
37
|
noteKeywords: ["BREAKING CHANGE", "BREAKING CHANGES"]
|
|
@@ -1,7 +0,0 @@
|
|
|
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
|
-
}
|