Skip to content

Commit 780b7cc

Browse files
committedDec 8, 2024
feat: migrate to tinyexec
1 parent 95b8af3 commit 780b7cc

7 files changed

+557
-827
lines changed
 

‎package.json

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "bumpp",
33
"version": "9.8.1",
4-
"packageManager": "pnpm@9.12.3",
4+
"packageManager": "pnpm@9.15.0",
55
"description": "Bump version, commit changes, tag, and push to Git",
66
"author": {
77
"name": "James Messinger",
@@ -60,30 +60,30 @@
6060
"typecheck": "tsc --noEmit"
6161
},
6262
"dependencies": {
63-
"@jsdevtools/ez-spawn": "^3.0.4",
64-
"c12": "^1.11.2",
63+
"c12": "^2.0.1",
6564
"cac": "^6.7.14",
6665
"escalade": "^3.2.0",
6766
"js-yaml": "^4.1.0",
6867
"jsonc-parser": "^3.3.1",
6968
"prompts": "^2.4.2",
7069
"semver": "^7.6.3",
70+
"tinyexec": "^0.3.1",
7171
"tinyglobby": "^0.2.10"
7272
},
7373
"devDependencies": {
74-
"@antfu/eslint-config": "^3.8.0",
74+
"@antfu/eslint-config": "^3.11.2",
7575
"@types/js-yaml": "^4.0.9",
76-
"@types/node": "^22.8.1",
76+
"@types/node": "^22.10.1",
7777
"@types/prompts": "^2.4.9",
7878
"@types/semver": "^7.5.8",
79-
"eslint": "^9.13.0",
79+
"eslint": "^9.16.0",
8080
"esno": "^4.8.0",
81-
"log-symbols": "^6.0.0",
81+
"log-symbols": "^7.0.0",
8282
"npm-check": "^6.0.1",
8383
"picocolors": "^1.1.1",
8484
"rimraf": "^6.0.1",
8585
"tsup": "^8.3.5",
86-
"typescript": "^5.6.3",
87-
"vitest": "^2.1.4"
86+
"typescript": "^5.7.2",
87+
"vitest": "^2.1.8"
8888
}
8989
}

‎pnpm-lock.yaml

+512-788
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎src/cli/index.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { VersionBumpProgress } from '../types/version-bump-progress'
22
import process from 'node:process'
3-
import * as ezSpawn from '@jsdevtools/ez-spawn'
43
import symbols from 'log-symbols'
4+
import { x } from 'tinyexec'
55
import { ProgressEvent } from '../types/version-bump-progress'
66
import { versionBump } from '../version-bump'
77
import { ExitCode } from './exit-code'
@@ -25,7 +25,7 @@ export async function main(): Promise<void> {
2525
}
2626
else {
2727
if (!options.all && !options.noGitCheck) {
28-
checkGitStatus()
28+
await checkGitStatus()
2929
}
3030

3131
if (!quiet)
@@ -39,8 +39,8 @@ export async function main(): Promise<void> {
3939
}
4040
}
4141

42-
export function checkGitStatus() {
43-
const { stdout } = ezSpawn.sync('git', ['status', '--porcelain'])
42+
export async function checkGitStatus() {
43+
const { stdout } = await x('git', ['status', '--porcelain'])
4444
if (stdout.trim()) {
4545
throw new Error(`Git working tree is not clean:\n${stdout}`)
4646
}

‎src/git.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { Operation } from './operation'
2-
import * as ezSpawn from '@jsdevtools/ez-spawn'
2+
import { x } from 'tinyexec'
33
import { ProgressEvent } from './types/version-bump-progress'
44

55
/**
@@ -35,7 +35,7 @@ export async function gitCommit(operation: Operation): Promise<Operation> {
3535
if (!all)
3636
args = args.concat(updatedFiles)
3737

38-
await ezSpawn.async('git', ['commit', ...args])
38+
await x('git', ['commit', ...args])
3939

4040
return operation.update({ event: ProgressEvent.GitCommit, commitMessage })
4141
}
@@ -69,7 +69,7 @@ export async function gitTag(operation: Operation): Promise<Operation> {
6969
args.push('--sign')
7070
}
7171

72-
await ezSpawn.async('git', ['tag', ...args])
72+
await x('git', ['tag', ...args])
7373

7474
return operation.update({ event: ProgressEvent.GitTag, tagName })
7575
}
@@ -82,11 +82,11 @@ export async function gitPush(operation: Operation): Promise<Operation> {
8282
return operation
8383

8484
// Push the commit
85-
await ezSpawn.async('git', 'push')
85+
await x('git', ['push'])
8686

8787
if (operation.options.tag) {
8888
// Push the tag
89-
await ezSpawn.async('git', ['push', '--tags'])
89+
await x('git', ['push', '--tags'])
9090
}
9191

9292
return operation.update({ event: ProgressEvent.GitPush })

‎src/print-commits.ts

+17-17
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { Operation } from './operation'
2-
import * as ezSpawn from '@jsdevtools/ez-spawn'
32
import c from 'picocolors'
3+
import { x } from 'tinyexec'
44

55
const messageColorMap: Record<string, (c: string) => string> = {
66
chore: c.gray,
@@ -92,22 +92,18 @@ export function formatParsedCommits(commits: ParsedCommit[]) {
9292

9393
export async function printRecentCommits(operation: Operation): Promise<void> {
9494
let sha: string | undefined
95-
sha ||= await ezSpawn
96-
.async(
97-
'git',
98-
['rev-list', '-n', '1', `v${operation.state.currentVersion}`],
99-
{ stdio: 'pipe' },
100-
)
95+
sha ||= await x(
96+
'git',
97+
['rev-list', '-n', '1', `v${operation.state.currentVersion}`],
98+
{ nodeOptions: { stdio: 'pipe' }, throwOnError: false },
99+
)
101100
.then(res => res.stdout.trim())
102-
.catch(() => undefined)
103-
sha ||= await ezSpawn
104-
.async(
105-
'git',
106-
['rev-list', '-n', '1', operation.state.currentVersion],
107-
{ stdio: 'pipe' },
108-
)
101+
sha ||= await x(
102+
'git',
103+
['rev-list', '-n', '1', operation.state.currentVersion],
104+
{ nodeOptions: { stdio: 'pipe' }, throwOnError: false },
105+
)
109106
.then(res => res.stdout.trim())
110-
.catch(() => undefined)
111107

112108
if (!sha) {
113109
console.log(
@@ -117,15 +113,19 @@ export async function printRecentCommits(operation: Operation): Promise<void> {
117113
return
118114
}
119115

120-
const { stdout } = await ezSpawn.async(
116+
const { stdout } = await x(
121117
'git',
122118
[
123119
'--no-pager',
124120
'log',
125121
`${sha}..HEAD`,
126122
'--oneline',
127123
],
128-
{ stdio: 'pipe' },
124+
{
125+
nodeOptions: {
126+
stdio: 'pipe',
127+
},
128+
},
129129
)
130130

131131
const parsed = parseCommits(stdout.toString().trim())

‎src/run-npm-script.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { Manifest } from './manifest'
22
import type { Operation } from './operation'
33
import type { NpmScript } from './types/version-bump-progress'
4-
import * as ezSpawn from '@jsdevtools/ez-spawn'
4+
import { x } from 'tinyexec'
55
import { readJsoncFile } from './fs'
66
import { isManifest } from './manifest'
77
import { ProgressEvent } from './types/version-bump-progress'
@@ -16,7 +16,9 @@ export async function runNpmScript(script: NpmScript, operation: Operation): Pro
1616
const { data: manifest } = await readJsoncFile('package.json', cwd)
1717

1818
if (isManifest(manifest) && hasScript(manifest, script)) {
19-
await ezSpawn.async('npm', ['run', script, '--silent'], { stdio: 'inherit' })
19+
await x('npm', ['run', script, '--silent'], {
20+
nodeOptions: { stdio: 'inherit' },
21+
})
2022
operation.update({ event: ProgressEvent.NpmScript, script })
2123
}
2224
}

‎src/version-bump.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import type { VersionBumpOptions } from './types/version-bump-options'
22
import type { VersionBumpResults } from './types/version-bump-results'
33
import process from 'node:process'
4-
import * as ezSpawn from '@jsdevtools/ez-spawn'
54
import symbols from 'log-symbols'
65
import c from 'picocolors'
76
import prompts from 'prompts'
7+
import { x } from 'tinyexec'
88
import { getCurrentVersion } from './get-current-version'
99
import { getNewVersion } from './get-new-version'
1010
import { formatVersionString, gitCommit, gitPush, gitTag } from './git'
@@ -77,7 +77,11 @@ export async function versionBump(arg: (VersionBumpOptions) | string = {}): Prom
7777
}
7878
else {
7979
console.log(symbols.info, 'Executing script', operation.options.execute)
80-
await ezSpawn.async(operation.options.execute, { stdio: 'inherit' })
80+
await x(operation.options.execute, [], {
81+
nodeOptions: {
82+
stdio: 'inherit',
83+
},
84+
})
8185
console.log(symbols.success, 'Script finished')
8286
}
8387
}

0 commit comments

Comments
 (0)
Please sign in to comment.