@cmflow/cli 2.1.0 → 2.2.0

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.
Binary file
package/README.md CHANGED
@@ -155,6 +155,40 @@ export default defineConfig({
155
155
  })
156
156
  ```
157
157
 
158
+ ### Sync repository plugin (@cmflow/cli/semantic/core/sync-repository)
159
+
160
+ This plugin synchronizes your remote repository after publishing:
161
+ - It pushes the current branch to the remote (with --set-upstream) if it is part of the candidate branches.
162
+ - It then synchronizes the development branch with the production branch if they are different.
163
+
164
+ Options:
165
+ - pluginOptions.branches: Allows you to explicitly define the list of branches that must be pushed to synchronize the remote. Example:
166
+
167
+ ```javascript
168
+ export default defineConfig({
169
+ publish: [
170
+ [
171
+ '@cmflow/cli/semantic/core/conditional',
172
+ {
173
+ run: [
174
+ [
175
+ '@cmflow/cli/semantic/core/sync-repository',
176
+ { branches: ['main', 'develop', 'release'] }
177
+ ],
178
+ '@semantic-release/github'
179
+ ]
180
+ }
181
+ ]
182
+ ]
183
+ })
184
+ ```
185
+
186
+ Default behavior:
187
+ - If pluginOptions.branches is not provided, the plugin falls back to semantic-release's branches configuration (options.branches). Values can be strings or branch objects; in the latter case, only the branch name is used.
188
+
189
+ Notes:
190
+ - PRODUCTION_BRANCH and DEVELOP_BRANCH are defined via the CmFlow configuration (flow.branch.production and flow.branch.develop) and are used for the synchronization between production and develop.
191
+
158
192
  ### Build and E2E Test
159
193
 
160
194
  CmFlow release are able to run `build` and `test_e2e` task during the prepare step. It's useful when you want to
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cmflow/cli",
3
- "version": "2.1.0",
3
+ "version": "2.2.0",
4
4
  "description": "An awesome Git Flow",
5
5
  "author": "camfou",
6
6
  "license": "MIT",
@@ -18,12 +18,12 @@ export async function prepare(pluginConfig, context) {
18
18
  logger.info("Get commit stage status");
19
19
  git.status();
20
20
 
21
- const revisionMessage = `${CI_NAME} build: ${context.branch.name} ${BUILD_NUMBER} ${context.nextRelease.gitTag} [ci skip]`;
21
+ const revisionMessage = `chore: ${CI_NAME} build ${context.branch.name} ${BUILD_NUMBER} ${context.nextRelease.gitTag} [ci skip]`;
22
22
 
23
23
  logger.info("Commit changes with revision message: ");
24
24
  logger.info(revisionMessage);
25
25
 
26
- git.commit("-m", revisionMessage).sync();
26
+ git.commit("-m", revisionMessage, "--no-verify").sync();
27
27
 
28
28
  logger.success("Change committed");
29
29
  }
@@ -20,8 +20,14 @@ export default async function syncRepository(pluginConfig, context) {
20
20
 
21
21
  await asyncCatchError(() => git.fetch());
22
22
 
23
- if ([PRODUCTION_BRANCH, "alpha", "beta", "rc"].includes(context.branch.name)) {
24
- logger.info(`Push ${PRODUCTION_BRANCH}`);
23
+ const candidateBranches =
24
+ pluginConfig.branches ||
25
+ context.options.branches?.map((branch) => {
26
+ return branch.name || branch;
27
+ });
28
+
29
+ if (candidateBranches.includes(context.branch.name)) {
30
+ logger.info(`Push ${context.branch.name}`);
25
31
 
26
32
  await asyncCatchError(() => {
27
33
  logger.info(`git push --quiet --set-upstream ${ORIGIN} ${context.branch.name}`);