@cmflow/cli 2.0.0-rc.3 → 2.0.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.
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cmflow/cli",
3
- "version": "2.0.0-rc.3",
3
+ "version": "2.0.1",
4
4
  "description": "An awesome Git Flow",
5
5
  "author": "camfou",
6
6
  "license": "MIT",
@@ -87,7 +87,7 @@
87
87
  "lint_fix": "eslint --fix",
88
88
  "release": "node bin/cmrelease.js",
89
89
  "release_dry_run": "node bin/cmrelease.js --dry-run",
90
- "jira_releases": "node --env-file=.env bin/cm.js jira-releases --project-id CMAB --component API --tag 0.3238.2 --verbose"
90
+ "jira_releases": "node --env-file=.env bin/cm.js jira-releases --project-id CMAB --component API --tag 0.3241.2 --verbose --update"
91
91
  },
92
92
  "husky": {
93
93
  "hooks": {
@@ -34,5 +34,6 @@ export default defineConfig({
34
34
  publish: ["./src/semantic/core/sync-repository.js", "@semantic-release/github"],
35
35
  success: ["@semantic-release/github"],
36
36
  fail: ["@semantic-release/github"],
37
- npmPublish: false
37
+ npmPublish: false,
38
+ writerOpts: {}
38
39
  });
@@ -9,9 +9,20 @@ import { updateJiraRelease } from "../common/back/jira/jira-releases.js";
9
9
  const TYPES = {
10
10
  Story: "feat",
11
11
  "Sous-tâche": "tech",
12
+ Tâche: "chore",
12
13
  Bug: "fix"
13
14
  };
14
15
 
16
+ function getSummary(issue) {
17
+ return issue.fields.summary
18
+ .replace("CLONE -", "")
19
+ .replace("[FEAT]", "")
20
+ .replace(/\[(.*)]:/, "$1 -")
21
+ .replace("[BUG]", "")
22
+ .replace("[FIX]", "")
23
+ .trim();
24
+ }
25
+
15
26
  export class JiraReleases {
16
27
  mapContext(commander, context) {
17
28
  return {
@@ -71,11 +82,12 @@ Au menu de cette livraison :
71
82
  ${context.releases
72
83
  .map((release) => {
73
84
  const issues = release.issues.map((issue) => {
74
- return ` - ${TYPES[issue.fields.issuetype.name] || issue.fields.issuetype}(${issue.key}): ${issue.fields.summary}`;
85
+ return ` - ${TYPES[issue.fields.issuetype.name] || issue.fields.issuetype.name}(${issue.key}): ${getSummary(issue)}`;
75
86
  });
76
87
 
77
- return (context.releases.length > 1 ? "- v" + release.version + ":\n" : "") + issues.join(",\n");
88
+ return issues.length ? (context.releases.length > 1 ? "- v" + release.version + ":\n" : "") + issues.join(",\n") : false;
78
89
  })
90
+ .filter((line) => line !== false)
79
91
  .join("\n\n")}
80
92
 
81
93
  L'équipe API
@@ -47,7 +47,7 @@ export async function httpRequest(endpoint, options = {}) {
47
47
  ...options,
48
48
  message: `Fail to retrieved data from ${callee}`,
49
49
  url,
50
- method,
50
+ method: method.toUpperCase(),
51
51
  status: response.status,
52
52
  response: await response.json()
53
53
  });
@@ -57,7 +57,7 @@ export async function httpRequest(endpoint, options = {}) {
57
57
  console.info({
58
58
  message: `Successfully retrieved data from ${callee}`,
59
59
  url,
60
- method,
60
+ method: method.toUpperCase(),
61
61
  status: response.status
62
62
  });
63
63
 
@@ -23,17 +23,16 @@ export async function jiraIssueMoveTo(issue, toTransition) {
23
23
 
24
24
  if (transition) {
25
25
  await jiraRequest(`/rest/api/3/issue/${issue.key}/transitions`, {
26
- method: "POST",
26
+ method: "post",
27
27
  headers: {
28
28
  "Content-Type": "application/json",
29
29
  Accept: "application/json"
30
30
  },
31
- body: JSON.stringify({
31
+ body: {
32
32
  transition: {
33
- id: transition.id,
34
- notifyUsers: false
33
+ id: transition.id
35
34
  }
36
- })
35
+ }
37
36
  });
38
37
  }
39
38
  }
@@ -16,12 +16,12 @@ export async function updateJiraRelease(release) {
16
16
  const endpoint = `/rest/api/3/version/${release.id}`;
17
17
 
18
18
  await jiraRequest(endpoint, {
19
- method: "PUT",
19
+ method: "put",
20
20
  headers: {
21
21
  "Content-Type": "application/json",
22
22
  Accept: "application/json"
23
23
  },
24
- body: JSON.stringify({
24
+ body: {
25
25
  id: release.id,
26
26
  description: release.description,
27
27
  name: release.name,
@@ -29,7 +29,7 @@ export async function updateJiraRelease(release) {
29
29
  released: release.released,
30
30
  projectId: release.projectId,
31
31
  releaseDate: release.releaseDate
32
- })
32
+ }
33
33
  });
34
34
  }
35
35
 
@@ -6,6 +6,10 @@ export async function jiraRequest(endpoint, opts = {}) {
6
6
  const jiraUrl = `${JIRA_API}${endpoint}`;
7
7
  const auth = Buffer.from(`${JIRA_EMAIL}:${JIRA_TOKEN}`).toString("base64");
8
8
 
9
+ if (opts.body && opts.headers?.["Content-Type"] === "application/json") {
10
+ opts.body = JSON.stringify(opts.body);
11
+ }
12
+
9
13
  return httpRequest(jiraUrl, {
10
14
  ...opts,
11
15
  callee: "JIRA",
@@ -1,7 +1,13 @@
1
1
  import fs from "fs";
2
2
 
3
3
  export function getPackageJson() {
4
- const content = fs.readFileSync(`${process.cwd()}/package.json`, { encoding: "utf8" });
4
+ try {
5
+ const content = fs.readFileSync(`${process.cwd()}/package.json`, { encoding: "utf8" });
5
6
 
6
- return JSON.parse(content);
7
+ return JSON.parse(content);
8
+ } catch {
9
+ return {
10
+ name: "@clubmed/root"
11
+ };
12
+ }
7
13
  }
@@ -45,7 +45,7 @@ async function runAll(step, pluginConfig, context, defaultCondition) {
45
45
  await taskFunction(pluginConfig, context);
46
46
  context.logger.success(` Completed conditional step "${step}" of plugin "${task}"`);
47
47
  } catch (er) {
48
- context.logger.fail(` Fail conditional step "${step}" of plugin "${task}"`);
48
+ context.logger.error(` Fail conditional step "${step}" of plugin "${task}"`);
49
49
  throw er;
50
50
  }
51
51
  }