@cmflow/cli 3.1.5 → 3.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.
- package/.yarn/install-state.gz +0 -0
- package/package.json +1 -1
- package/src/common/back/directus/directus-flow.js +3 -3
- package/src/common/back/directus/directus-flow.test.js +1 -1
- package/src/common/back/jira/jira-releases.js +1 -8
- package/src/common/back/jira/jira-request.js +2 -3
- package/src/common/back/jira/jira-request.spec.js +1 -1
- package/src/common/cli/bun.js +33 -0
- package/src/common/cli/bun.test.js +51 -0
- package/src/common/get-config.js +4 -2
- package/src/common/get-package-manager.js +5 -0
- package/src/common/index.js +1 -0
- package/src/semantic/core/prepare/bump-version.js +2 -1
package/.yarn/install-state.gz
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
@@ -23,7 +23,7 @@ export async function triggerDirectusFlow(projectId, versions, opts = {}) {
|
|
|
23
23
|
Authorization: `Bearer ${DIRECTUS_ACCESS_TOKEN}`,
|
|
24
24
|
"Content-Type": "application/json"
|
|
25
25
|
},
|
|
26
|
-
|
|
26
|
+
data: {
|
|
27
27
|
projectId,
|
|
28
28
|
versions
|
|
29
29
|
},
|
|
@@ -32,8 +32,8 @@ export async function triggerDirectusFlow(projectId, versions, opts = {}) {
|
|
|
32
32
|
...opts
|
|
33
33
|
};
|
|
34
34
|
|
|
35
|
-
if (options.
|
|
36
|
-
options.
|
|
35
|
+
if (options.data && options.headers?.["Content-Type"] === "application/json") {
|
|
36
|
+
options.data = JSON.stringify(options.data);
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
return httpRequest(endpoint, options);
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { jiraRequest } from "./jira-request.js";
|
|
2
|
-
import { jiraSearch } from "./jira-search.js";
|
|
3
2
|
|
|
4
3
|
export async function getJiraReleases(projectId) {
|
|
5
4
|
const endpoint = `/rest/api/3/project/${projectId}/versions?expand`;
|
|
@@ -21,7 +20,7 @@ export async function updateJiraRelease(release) {
|
|
|
21
20
|
"Content-Type": "application/json",
|
|
22
21
|
Accept: "application/json"
|
|
23
22
|
},
|
|
24
|
-
|
|
23
|
+
data: {
|
|
25
24
|
id: release.id,
|
|
26
25
|
description: release.description,
|
|
27
26
|
name: release.name,
|
|
@@ -35,9 +34,3 @@ export async function updateJiraRelease(release) {
|
|
|
35
34
|
console.log(`Error while updating jira release ${release.id}`, er);
|
|
36
35
|
}
|
|
37
36
|
}
|
|
38
|
-
|
|
39
|
-
export async function getJiraVersionRelatedIssues(projectId, tagVersion) {
|
|
40
|
-
return jiraSearch(`project = "${projectId}" AND fixVersion="${tagVersion}" ORDER BY created DESC`, {
|
|
41
|
-
fields: ["summary", "issuetype", "status", "assignee", "reporter", "created", "updated"]
|
|
42
|
-
});
|
|
43
|
-
}
|
|
@@ -8,9 +8,8 @@ export async function jiraRequest(endpoint, opts = {}) {
|
|
|
8
8
|
const jiraUrl = `${JIRA_API}${endpoint}`;
|
|
9
9
|
const auth = Buffer.from(`${JIRA_EMAIL}:${JIRA_TOKEN}`).toString("base64");
|
|
10
10
|
|
|
11
|
-
if (opts.
|
|
12
|
-
opts.data = JSON.stringify(opts.
|
|
13
|
-
delete opts.body;
|
|
11
|
+
if (opts.data && opts.headers?.["Content-Type"] === "application/json") {
|
|
12
|
+
opts.data = JSON.stringify(opts.data);
|
|
14
13
|
}
|
|
15
14
|
|
|
16
15
|
return httpRequest(jiraUrl, {
|
|
@@ -34,7 +34,7 @@ describe("jiraRequest", () => {
|
|
|
34
34
|
method: "post",
|
|
35
35
|
params: { key: "value" },
|
|
36
36
|
headers: { "Content-Type": "application/json" },
|
|
37
|
-
|
|
37
|
+
data: { key: "value" }
|
|
38
38
|
});
|
|
39
39
|
|
|
40
40
|
expect(httpRequest).toHaveBeenCalledWith(expect.stringContaining("/test-endpoint"), {
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Cli } from "./cli.js";
|
|
2
|
+
|
|
3
|
+
class BunCli extends Cli {
|
|
4
|
+
constructor() {
|
|
5
|
+
super("bun");
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
newVersion(version) {
|
|
9
|
+
return this.pm("version", "--no-git-tag-version", version);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
pm(...args) {
|
|
13
|
+
return this.sync("pm", ...args);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
run(...args) {
|
|
17
|
+
return super.run("run", ...args);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
install(...args) {
|
|
21
|
+
return super.run("install", ...args);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Reinstall dependencies without bun.lock mutation
|
|
26
|
+
* @returns {Promise<unknown>}
|
|
27
|
+
*/
|
|
28
|
+
restore() {
|
|
29
|
+
return super.run("install", "--frozen-lockfile");
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export const bun = new BunCli();
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
vi.mock("execa", () => {
|
|
2
|
+
const execaMock = vi.fn();
|
|
3
|
+
execaMock.sync = vi.fn();
|
|
4
|
+
return { default: execaMock };
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
const { default: execa } = await import("execa");
|
|
8
|
+
const { bun } = await import("./bun.js");
|
|
9
|
+
const { Cli } = await import("./cli.js");
|
|
10
|
+
|
|
11
|
+
execa.sync.mockImplementation((...args) => {
|
|
12
|
+
return {
|
|
13
|
+
stdout: `CMD: ${[].concat(...args.filter((arg) => typeof arg === "string" || Array.isArray(arg))).join(" ")}`
|
|
14
|
+
};
|
|
15
|
+
});
|
|
16
|
+
execa.mockReturnValue({});
|
|
17
|
+
|
|
18
|
+
describe("BunCli", () => {
|
|
19
|
+
beforeEach(() => {
|
|
20
|
+
vi.spyOn(Cli, "getRaw").mockImplementation((...args) => {
|
|
21
|
+
return `CMD: ${[].concat(...args.filter((arg) => typeof arg === "string" || Array.isArray(arg))).join(" ")}`;
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
describe("newVersion", () => {
|
|
25
|
+
it("should run newVersion cmd", () => {
|
|
26
|
+
const result = bun.newVersion("1.0.0");
|
|
27
|
+
|
|
28
|
+
expect(result.stdout).toEqual("CMD: bun pm version --no-git-tag-version 1.0.0");
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
describe("run", () => {
|
|
32
|
+
it('should run "run" cmd', async () => {
|
|
33
|
+
await bun.run("run-arg");
|
|
34
|
+
|
|
35
|
+
expect(execa).toHaveBeenCalledWith("bun", ["run", "run-arg"], {
|
|
36
|
+
cwd: process.cwd(),
|
|
37
|
+
stdio: "inherit"
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
describe("install", () => {
|
|
42
|
+
it('should run "install" cmd', async () => {
|
|
43
|
+
await bun.install("install-arg");
|
|
44
|
+
|
|
45
|
+
expect(execa).toHaveBeenCalledWith("bun", ["install", "install-arg"], {
|
|
46
|
+
cwd: process.cwd(),
|
|
47
|
+
stdio: "inherit"
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
});
|
package/src/common/get-config.js
CHANGED
|
@@ -99,19 +99,21 @@ export function getConfig() {
|
|
|
99
99
|
|
|
100
100
|
const HAS_YARN = hasYarn();
|
|
101
101
|
const HAS_PNPM = fs.existsSync(join(process.cwd(), "pnpm-lock.yaml"));
|
|
102
|
+
const HAS_BUN = fs.existsSync(join(process.cwd(), "bun.lock")) || fs.existsSync(join(process.cwd(), "bun.lockb"));
|
|
102
103
|
const IS_YARN_BERRY = HAS_YARN ? fs.existsSync(join(process.cwd(), ".yamlrc.yml")) : false;
|
|
103
104
|
let BUMP_METHOD = get(pkg, "flow.bumpMethod", "default");
|
|
104
105
|
|
|
105
|
-
if ((IS_YARN_BERRY || HAS_PNPM) && ["native", "default"].includes(BUMP_METHOD)) {
|
|
106
|
+
if ((IS_YARN_BERRY || HAS_PNPM || HAS_BUN) && ["native", "default"].includes(BUMP_METHOD)) {
|
|
106
107
|
BUMP_METHOD = "cmflow";
|
|
107
108
|
}
|
|
108
109
|
|
|
109
110
|
return {
|
|
110
111
|
pkg,
|
|
111
|
-
PACKAGE_MANAGER: HAS_PNPM ? "pnpm" : HAS_YARN ? "yarn" : "npm",
|
|
112
|
+
PACKAGE_MANAGER: HAS_PNPM ? "pnpm" : HAS_BUN ? "bun" : HAS_YARN ? "yarn" : "npm",
|
|
112
113
|
PROJECT_NAME: PROJECT_NAME || projectName,
|
|
113
114
|
HAS_YARN,
|
|
114
115
|
HAS_PNPM,
|
|
116
|
+
HAS_BUN,
|
|
115
117
|
IS_YARN_BERRY,
|
|
116
118
|
HAS_LERNA: (pkg.dependencies && pkg.dependencies.lerna) || (pkg.devDependencies && pkg.devDependencies.lerna),
|
|
117
119
|
CI_SKIP: "[ci skip]",
|
|
@@ -1,7 +1,12 @@
|
|
|
1
|
+
import { bun } from "./cli/bun.js";
|
|
1
2
|
import { npm } from "./cli/npm.js";
|
|
2
3
|
import { pnpm } from "./cli/pnpm.js";
|
|
3
4
|
import { yarn } from "./cli/yarn.js";
|
|
4
5
|
|
|
5
6
|
export function getPackageManager(pkgManager) {
|
|
7
|
+
if (pkgManager === "bun") {
|
|
8
|
+
return bun;
|
|
9
|
+
}
|
|
10
|
+
|
|
6
11
|
return pkgManager === "yarn" ? yarn : pkgManager === "pnpm" ? pnpm : npm;
|
|
7
12
|
}
|
package/src/common/index.js
CHANGED
|
@@ -7,6 +7,7 @@ export async function prepare(_, context) {
|
|
|
7
7
|
config: { PACKAGE_MANAGER, HAS_LERNA, BUMP_METHOD, WORKSPACES },
|
|
8
8
|
logger
|
|
9
9
|
} = context;
|
|
10
|
+
const versionPackageManager = PACKAGE_MANAGER === "yarn" ? "npm" : PACKAGE_MANAGER;
|
|
10
11
|
|
|
11
12
|
logger.info(`Start bump version for all packages using method: ${BUMP_METHOD}`);
|
|
12
13
|
|
|
@@ -26,7 +27,7 @@ export async function prepare(_, context) {
|
|
|
26
27
|
break;
|
|
27
28
|
case "native:lerna":
|
|
28
29
|
default:
|
|
29
|
-
getPackageManager(
|
|
30
|
+
getPackageManager(versionPackageManager).newVersion(context.nextRelease.version);
|
|
30
31
|
|
|
31
32
|
if (HAS_LERNA) {
|
|
32
33
|
await lerna.newVersion(context.nextRelease.version);
|