@cmflow/cli 3.1.6 → 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.
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cmflow/cli",
3
- "version": "3.1.6",
3
+ "version": "3.2.0",
4
4
  "description": "An awesome Git Flow",
5
5
  "author": "camfou",
6
6
  "license": "MIT",
@@ -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
+ });
@@ -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
  }
@@ -1,3 +1,4 @@
1
+ export * from "./cli/bun.js";
1
2
  export * from "./cli/cli.js";
2
3
  export * from "./cli/docker.js";
3
4
  export * from "./cli/git.js";
@@ -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("npm").newVersion(context.nextRelease.version);
30
+ getPackageManager(versionPackageManager).newVersion(context.nextRelease.version);
30
31
 
31
32
  if (HAS_LERNA) {
32
33
  await lerna.newVersion(context.nextRelease.version);