@modulify/conventional-release 0.1.0 → 0.1.2

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.
@@ -0,0 +1,67 @@
1
+ import { DEFAULT_CHANGELOG_FILE } from "./constants.mjs";
2
+ import { GitCommander } from "@modulify/git-toolkit";
3
+ import { Runner } from "@modulify/git-toolkit/shell";
4
+ import { existsSync, readFileSync } from "node:fs";
5
+ import { join } from "node:path";
6
+ import { Client } from "@modulify/conventional-git";
7
+ import { writeChangelog } from "@modulify/conventional-changelog";
8
+ //#region src/runtime.ts
9
+ /** Creates the default runtime used by the public planning and release APIs. */
10
+ function createRuntime({ cwd = process.cwd(), dry = false, changelogFile = DEFAULT_CHANGELOG_FILE } = {}) {
11
+ const sh = new Runner(cwd);
12
+ return {
13
+ cwd,
14
+ dry,
15
+ changelogFile,
16
+ packageManager: resolvePackageManager(cwd),
17
+ history: new Client({ cwd }),
18
+ writeChangelog: (changes) => writeChangelog(changes, { file: dry ? void 0 : join(cwd, changelogFile) }),
19
+ sh,
20
+ git: createGit(sh)
21
+ };
22
+ }
23
+ function createGit(sh) {
24
+ const git = new GitCommander({ sh });
25
+ return {
26
+ add: (files) => git.add(files),
27
+ commit: (options) => git.commit(options),
28
+ tag: (options) => git.tag(options)
29
+ };
30
+ }
31
+ function resolvePackageManager(cwd) {
32
+ const command = readPackageManager(cwd) ?? inferPackageManagerFromLockfile(cwd) ?? "npm";
33
+ return {
34
+ command,
35
+ lockfile: resolveLockfile(cwd, command)
36
+ };
37
+ }
38
+ function readPackageManager(cwd) {
39
+ const file = join(cwd, "package.json");
40
+ if (!existsSync(file)) return null;
41
+ const content = JSON.parse(readFileSync(file, "utf-8"));
42
+ if (typeof content.packageManager !== "string" || content.packageManager === "") return null;
43
+ const [name] = content.packageManager.split("@");
44
+ return isPackageManagerName(name) ? name : null;
45
+ }
46
+ function inferPackageManagerFromLockfile(cwd) {
47
+ if (existsSync(join(cwd, "yarn.lock"))) return "yarn";
48
+ if (existsSync(join(cwd, "pnpm-lock.yaml"))) return "pnpm";
49
+ if (existsSync(join(cwd, "package-lock.json"))) return "npm";
50
+ if (existsSync(join(cwd, "bun.lock"))) return "bun";
51
+ if (existsSync(join(cwd, "bun.lockb"))) return "bun";
52
+ return null;
53
+ }
54
+ function resolveLockfile(cwd, command) {
55
+ if (command === "bun" && existsSync(join(cwd, "bun.lockb"))) return "bun.lockb";
56
+ return {
57
+ yarn: "yarn.lock",
58
+ pnpm: "pnpm-lock.yaml",
59
+ npm: "package-lock.json",
60
+ bun: "bun.lock"
61
+ }[command];
62
+ }
63
+ function isPackageManagerName(value) {
64
+ return value === "yarn" || value === "pnpm" || value === "npm" || value === "bun";
65
+ }
66
+ //#endregion
67
+ export { createRuntime };
package/package.json CHANGED
@@ -1,9 +1,14 @@
1
1
  {
2
2
  "name": "@modulify/conventional-release",
3
3
  "type": "module",
4
- "version": "0.1.0",
4
+ "version": "0.1.2",
5
5
  "license": "ISC",
6
6
  "homepage": "https://github.com/modulify/conventional/tree/main/packages/conventional-release#readme",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/modulify/conventional.git",
10
+ "directory": "packages/conventional-release"
11
+ },
7
12
  "engines": {
8
13
  "node": ">=20.0.0"
9
14
  },
@@ -38,25 +43,25 @@
38
43
  }
39
44
  },
40
45
  "dependencies": {
41
- "@modulify/conventional-bump": "^0.1.0",
42
- "@modulify/conventional-changelog": "^0.1.0",
43
- "@modulify/conventional-git": "^0.1.0",
46
+ "@modulify/conventional-bump": "^0.1.2",
47
+ "@modulify/conventional-changelog": "^0.1.2",
48
+ "@modulify/conventional-git": "^0.1.2",
44
49
  "@modulify/git-toolkit": "^0.0.2",
45
50
  "@modulify/pkg": "^1.0.1",
46
51
  "chalk": "^5.6.2",
47
52
  "figures": "^6.1.0",
48
- "semver": "^7.7.3",
53
+ "semver": "^7.7.4",
49
54
  "yargs": "^17.7.2"
50
55
  },
51
56
  "devDependencies": {
52
- "@types/node": "^22.18.6",
57
+ "@types/node": "^25.6.0",
53
58
  "@types/semver": "^7.7.1",
54
59
  "@types/yargs": "^17.0.35",
55
60
  "tslib": "^2.8.1",
56
61
  "typescript": "^5.9.3",
57
- "vite": "^7.3.0",
62
+ "vite": "^8.0.8",
58
63
  "vite-plugin-dts": "^4.5.4",
59
- "vitest": "^4.0.16"
64
+ "vitest": "^4.1.4"
60
65
  },
61
66
  "author": {
62
67
  "name": "modulify",
@@ -81,9 +86,9 @@
81
86
  "bin/*.cjs",
82
87
  "bin/*.js",
83
88
  "bin/*.mjs",
84
- "dist/*.cjs",
85
- "dist/*.mjs",
86
- "dist/*.d.ts",
89
+ "dist/**/*.cjs",
90
+ "dist/**/*.mjs",
91
+ "dist/**/*.d.ts",
87
92
  "types/*.d.ts",
88
93
  "LICENSE.md",
89
94
  "README.md"
@@ -62,6 +62,8 @@ export interface Options extends Range {
62
62
  mode?: Mode
63
63
  /** Explicit semantic release type override. */
64
64
  releaseAs?: SemverReleaseType
65
+ /** Whether automatic stable recommendations should be downgraded for pre-1.0.0 releases. */
66
+ preMajor?: boolean
65
67
  /** Prerelease channel used when generating prerelease versions. */
66
68
  prerelease?: 'alpha' | 'beta' | 'rc'
67
69
  /** Whether dependency installation should run after manifest updates, or extra arguments appended after the installation subcommand. */