@programinglive/commiter 1.0.11 → 1.0.12

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/CHANGELOG.md CHANGED
@@ -2,6 +2,13 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [1.0.12](https://github.com/programinglive/commiter/compare/v1.0.11...v1.0.12) (2025-10-29)
6
+
7
+
8
+ ### ✨ Features
9
+
10
+ * auto-detect test command during release ([602e30e](https://github.com/programinglive/commiter/commit/602e30e94ff7c58b35f8c54bd495c0334352c72c))
11
+
5
12
  ### [1.0.11](https://github.com/programinglive/commiter/compare/v1.0.10...v1.0.11) (2025-10-29)
6
13
 
7
14
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@programinglive/commiter",
3
- "version": "1.0.11",
4
- "description": "Commit convention tooling for standard-version releases with beautiful changelogs",
3
+ "version": "1.0.12",
4
+ "description": "Commiter keeps repositories release-ready by enforcing conventional commits, generating icon-rich changelog entries, and orchestrating semantic version bumps without manual toil. It bootstraps Husky hooks, commitlint rules, and release scripts that inspect history, detect framework-specific test commands, run them automatically, tag git releases, coordinate npm publishing, surface release metrics, enforce project-specific checks, and give maintainers observability across distributed teams. Plus!",
5
5
  "main": "index.js",
6
6
  "bin": {
7
7
  "commiter": "./index.js"
@@ -1,6 +1,8 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  const { spawnSync } = require('child_process');
4
+ const fs = require('fs');
5
+ const path = require('path');
4
6
 
5
7
  const VALID_RELEASE_TYPES = new Set([
6
8
  'major',
@@ -14,6 +16,13 @@ const VALID_RELEASE_TYPES = new Set([
14
16
 
15
17
  const SEMVER_REGEX = /^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/;
16
18
 
19
+ const LOCKFILE_PREFERENCES = [
20
+ { manager: 'pnpm', file: 'pnpm-lock.yaml' },
21
+ { manager: 'yarn', file: 'yarn.lock' },
22
+ { manager: 'bun', file: 'bun.lockb' },
23
+ { manager: 'npm', file: 'package-lock.json' }
24
+ ];
25
+
17
26
  function getCliArguments(argv = process.argv) {
18
27
  const rawArgs = argv.slice(2);
19
28
  if (rawArgs.length === 0) {
@@ -61,6 +70,63 @@ function buildStandardVersionArgs({ releaseType, extraArgs }) {
61
70
  return args;
62
71
  }
63
72
 
73
+ function loadPackageJson(cwd = process.cwd()) {
74
+ try {
75
+ const packageJsonPath = path.join(cwd, 'package.json');
76
+ const contents = fs.readFileSync(packageJsonPath, 'utf8');
77
+ return JSON.parse(contents);
78
+ } catch (error) {
79
+ return null;
80
+ }
81
+ }
82
+
83
+ function detectPackageManager({ env = process.env, cwd = process.cwd() } = {}) {
84
+ const userAgent = env.npm_config_user_agent || '';
85
+ if (userAgent.startsWith('pnpm/')) return 'pnpm';
86
+ if (userAgent.startsWith('yarn/')) return 'yarn';
87
+ if (userAgent.startsWith('bun/')) return 'bun';
88
+
89
+ for (const { manager, file } of LOCKFILE_PREFERENCES) {
90
+ if (fs.existsSync(path.join(cwd, file))) {
91
+ return manager;
92
+ }
93
+ }
94
+
95
+ return 'npm';
96
+ }
97
+
98
+ function buildTestCommand(packageManager) {
99
+ switch (packageManager) {
100
+ case 'pnpm':
101
+ return { command: 'pnpm', args: ['test'] };
102
+ case 'yarn':
103
+ return { command: 'yarn', args: ['test'] };
104
+ case 'bun':
105
+ return { command: 'bun', args: ['test'] };
106
+ default:
107
+ return { command: 'npm', args: ['test'] };
108
+ }
109
+ }
110
+
111
+ function runProjectTests({ spawn = spawnSync, env = process.env, cwd = process.cwd() } = {}) {
112
+ const packageJson = loadPackageJson(cwd);
113
+ const scripts = packageJson && packageJson.scripts ? packageJson.scripts : {};
114
+
115
+ if (!scripts.test) {
116
+ console.log('ℹ️ Skipping tests: no "test" script detected in package.json');
117
+ return { status: 0 };
118
+ }
119
+
120
+ const packageManager = detectPackageManager({ env, cwd });
121
+ const { command, args } = buildTestCommand(packageManager);
122
+
123
+ console.log(`🧪 Running tests with ${packageManager} ${args.join(' ')}`.trim());
124
+ return spawn(command, args, {
125
+ stdio: 'inherit',
126
+ env
127
+ });
128
+ }
129
+
64
130
  function runRelease({ argv = process.argv, env = process.env, spawn = spawnSync } = {}) {
65
131
  const { releaseType: cliReleaseType, extraArgs } = getCliArguments(argv);
66
132
  const inferredReleaseType = cliReleaseType || getNpmRunArgument(env);
@@ -69,6 +135,11 @@ function runRelease({ argv = process.argv, env = process.env, spawn = spawnSync
69
135
  extraArgs
70
136
  });
71
137
 
138
+ const testResult = runProjectTests({ spawn, env });
139
+ if (testResult && typeof testResult.status === 'number' && testResult.status !== 0) {
140
+ return testResult;
141
+ }
142
+
72
143
  const standardVersionBin = require.resolve('standard-version/bin/cli.js');
73
144
  return spawn(process.execPath, [standardVersionBin, ...standardVersionArgs], {
74
145
  stdio: 'inherit'
@@ -93,5 +164,8 @@ module.exports = {
93
164
  getCliArguments,
94
165
  getNpmRunArgument,
95
166
  buildStandardVersionArgs,
167
+ loadPackageJson,
168
+ detectPackageManager,
169
+ runProjectTests,
96
170
  runRelease
97
171
  };