@wyxos/zephyr 0.9.4 → 0.9.5
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/package.json
CHANGED
|
@@ -22,6 +22,25 @@ async function isGitIgnored(rootDir, filePath, {runCommand} = {}) {
|
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
+
|
|
26
|
+
async function captureGit(rootDir, args, {runCommand, runCommandCapture} = {}) {
|
|
27
|
+
if (typeof runCommandCapture === 'function') {
|
|
28
|
+
return await runCommandCapture('git', args, {cwd: rootDir})
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (typeof runCommand !== 'function') {
|
|
32
|
+
return ''
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const output = await runCommand('git', args, {capture: true, cwd: rootDir})
|
|
36
|
+
|
|
37
|
+
if (typeof output === 'string') {
|
|
38
|
+
return output
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return output?.stdout ?? ''
|
|
42
|
+
}
|
|
43
|
+
|
|
25
44
|
function parseVersionBumpCommit(line) {
|
|
26
45
|
const [hash, shortHash, subject] = line.split('\0')
|
|
27
46
|
const match = /^chore: bump version to (\d+\.\d+\.\d+(?:[-+][^\s]+)?)$/i.exec(subject ?? '')
|
|
@@ -33,15 +52,11 @@ function parseVersionBumpCommit(line) {
|
|
|
33
52
|
return {hash, shortHash, version: match[1]}
|
|
34
53
|
}
|
|
35
54
|
|
|
36
|
-
async function readVersionBumpCommits(rootDir, {runCommand} = {}) {
|
|
37
|
-
if (typeof runCommand !== 'function') {
|
|
38
|
-
return []
|
|
39
|
-
}
|
|
40
|
-
|
|
55
|
+
async function readVersionBumpCommits(rootDir, {runCommand, runCommandCapture} = {}) {
|
|
41
56
|
try {
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
57
|
+
const stdout = await captureGit(rootDir, ['log', '--format=%H%x00%h%x00%s', '-1000'], {
|
|
58
|
+
runCommand,
|
|
59
|
+
runCommandCapture
|
|
45
60
|
})
|
|
46
61
|
|
|
47
62
|
return stdout
|
|
@@ -98,20 +113,20 @@ function formatVersionReferenceLabel(reference, currentVersion) {
|
|
|
98
113
|
}
|
|
99
114
|
|
|
100
115
|
|
|
101
|
-
async function readRecentAppCommitSubjects(rootDir, versionReference, {runCommand} = {}) {
|
|
102
|
-
if (!versionReference?.hash
|
|
116
|
+
async function readRecentAppCommitSubjects(rootDir, versionReference, {runCommand, runCommandCapture} = {}) {
|
|
117
|
+
if (!versionReference?.hash) {
|
|
103
118
|
return ''
|
|
104
119
|
}
|
|
105
120
|
|
|
106
121
|
try {
|
|
107
|
-
const
|
|
122
|
+
const stdout = await captureGit(rootDir, [
|
|
108
123
|
'log',
|
|
109
124
|
'--format=%s',
|
|
110
125
|
'--max-count=80',
|
|
111
126
|
`${versionReference.hash}..HEAD`
|
|
112
127
|
], {
|
|
113
|
-
|
|
114
|
-
|
|
128
|
+
runCommand,
|
|
129
|
+
runCommandCapture
|
|
115
130
|
})
|
|
116
131
|
|
|
117
132
|
return stdout.trim()
|
|
@@ -138,6 +153,7 @@ async function resolveDeploymentVersionValue(rootDir, {
|
|
|
138
153
|
interactive = false,
|
|
139
154
|
runPrompt,
|
|
140
155
|
runCommand,
|
|
156
|
+
runCommandCapture,
|
|
141
157
|
logProcessing,
|
|
142
158
|
logWarning
|
|
143
159
|
} = {}) {
|
|
@@ -145,9 +161,9 @@ async function resolveDeploymentVersionValue(rootDir, {
|
|
|
145
161
|
return String(versionArg).trim()
|
|
146
162
|
}
|
|
147
163
|
|
|
148
|
-
const versionBumps = await readVersionBumpCommits(rootDir, {runCommand})
|
|
164
|
+
const versionBumps = await readVersionBumpCommits(rootDir, {runCommand, runCommandCapture})
|
|
149
165
|
const versionReference = selectVersionSuggestionReference(pkg.version, versionBumps)
|
|
150
|
-
const commitSubjects = await readRecentAppCommitSubjects(rootDir, versionReference, {runCommand})
|
|
166
|
+
const commitSubjects = await readRecentAppCommitSubjects(rootDir, versionReference, {runCommand, runCommandCapture})
|
|
151
167
|
|
|
152
168
|
return await resolveReleaseType({
|
|
153
169
|
currentVersion: pkg.version,
|
|
@@ -156,6 +172,7 @@ async function resolveDeploymentVersionValue(rootDir, {
|
|
|
156
172
|
interactive,
|
|
157
173
|
runPrompt,
|
|
158
174
|
runCommand,
|
|
175
|
+
runCommandCapture,
|
|
159
176
|
logStep: logProcessing,
|
|
160
177
|
logWarning,
|
|
161
178
|
latestTag: versionReference?.hash ?? null,
|
|
@@ -170,6 +187,7 @@ export async function bumpLocalPackageVersion(rootDir, {
|
|
|
170
187
|
runPrompt,
|
|
171
188
|
skipGitHooks = false,
|
|
172
189
|
runCommand,
|
|
190
|
+
runCommandCapture,
|
|
173
191
|
logProcessing,
|
|
174
192
|
logSuccess,
|
|
175
193
|
logWarning
|
|
@@ -196,6 +214,7 @@ export async function bumpLocalPackageVersion(rootDir, {
|
|
|
196
214
|
interactive,
|
|
197
215
|
runPrompt,
|
|
198
216
|
runCommand,
|
|
217
|
+
runCommandCapture,
|
|
199
218
|
logProcessing,
|
|
200
219
|
logWarning
|
|
201
220
|
})
|
|
@@ -107,14 +107,30 @@ function buildChoiceOrder(suggestedReleaseType) {
|
|
|
107
107
|
]
|
|
108
108
|
}
|
|
109
109
|
|
|
110
|
-
|
|
110
|
+
|
|
111
|
+
async function captureCommand(command, args, {runCommand, runCommandCapture, cwd} = {}) {
|
|
112
|
+
if (typeof runCommandCapture === 'function') {
|
|
113
|
+
return {stdout: await runCommandCapture(command, args, {cwd}), stderr: ''}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
const output = await runCommand(command, args, {capture: true, cwd})
|
|
117
|
+
|
|
118
|
+
if (typeof output === 'string') {
|
|
119
|
+
return {stdout: output, stderr: ''}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
return output ?? {stdout: '', stderr: ''}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
async function readLatestReleaseTag(rootDir, {runCommand, runCommandCapture, latestTag = null} = {}) {
|
|
111
126
|
if (typeof latestTag === 'string' && latestTag.trim() !== '') {
|
|
112
127
|
return latestTag.trim()
|
|
113
128
|
}
|
|
114
129
|
|
|
115
130
|
try {
|
|
116
|
-
const {stdout} = await
|
|
117
|
-
|
|
131
|
+
const {stdout} = await captureCommand('git', ['describe', '--tags', '--abbrev=0'], {
|
|
132
|
+
runCommand,
|
|
133
|
+
runCommandCapture,
|
|
118
134
|
cwd: rootDir
|
|
119
135
|
})
|
|
120
136
|
|
|
@@ -124,14 +140,15 @@ async function readLatestReleaseTag(rootDir, {runCommand, latestTag = null} = {}
|
|
|
124
140
|
}
|
|
125
141
|
}
|
|
126
142
|
|
|
127
|
-
async function readCommitLog(rootDir, {runCommand, latestTag} = {}) {
|
|
143
|
+
async function readCommitLog(rootDir, {runCommand, runCommandCapture, latestTag} = {}) {
|
|
128
144
|
const args = latestTag
|
|
129
145
|
? ['log', '--format=%h %s', `${latestTag}..HEAD`]
|
|
130
146
|
: ['log', '--format=%h %s', '-20']
|
|
131
147
|
|
|
132
148
|
try {
|
|
133
|
-
const {stdout} = await
|
|
134
|
-
|
|
149
|
+
const {stdout} = await captureCommand('git', args, {
|
|
150
|
+
runCommand,
|
|
151
|
+
runCommandCapture,
|
|
135
152
|
cwd: rootDir
|
|
136
153
|
})
|
|
137
154
|
|
|
@@ -141,14 +158,15 @@ async function readCommitLog(rootDir, {runCommand, latestTag} = {}) {
|
|
|
141
158
|
}
|
|
142
159
|
}
|
|
143
160
|
|
|
144
|
-
async function readDiffStat(rootDir, {runCommand, latestTag} = {}) {
|
|
161
|
+
async function readDiffStat(rootDir, {runCommand, runCommandCapture, latestTag} = {}) {
|
|
145
162
|
const args = latestTag
|
|
146
163
|
? ['diff', '--stat', `${latestTag}..HEAD`, '--']
|
|
147
164
|
: ['diff', '--stat', 'HEAD~20..HEAD', '--']
|
|
148
165
|
|
|
149
166
|
try {
|
|
150
|
-
const {stdout} = await
|
|
151
|
-
|
|
167
|
+
const {stdout} = await captureCommand('git', args, {
|
|
168
|
+
runCommand,
|
|
169
|
+
runCommandCapture,
|
|
152
170
|
cwd: rootDir
|
|
153
171
|
})
|
|
154
172
|
|
|
@@ -160,14 +178,15 @@ async function readDiffStat(rootDir, {runCommand, latestTag} = {}) {
|
|
|
160
178
|
|
|
161
179
|
async function buildReleaseSuggestionContext(rootDir, {
|
|
162
180
|
runCommand,
|
|
181
|
+
runCommandCapture,
|
|
163
182
|
currentVersion,
|
|
164
183
|
packageName,
|
|
165
184
|
latestTag = null,
|
|
166
185
|
referenceLabel = null
|
|
167
186
|
} = {}) {
|
|
168
|
-
const resolvedLatestTag = await readLatestReleaseTag(rootDir, {runCommand, latestTag})
|
|
169
|
-
const commitLog = await readCommitLog(rootDir, {runCommand, latestTag: resolvedLatestTag})
|
|
170
|
-
const diffStat = await readDiffStat(rootDir, {runCommand, latestTag: resolvedLatestTag})
|
|
187
|
+
const resolvedLatestTag = await readLatestReleaseTag(rootDir, {runCommand, runCommandCapture, latestTag})
|
|
188
|
+
const commitLog = await readCommitLog(rootDir, {runCommand, runCommandCapture, latestTag: resolvedLatestTag})
|
|
189
|
+
const diffStat = await readDiffStat(rootDir, {runCommand, runCommandCapture, latestTag: resolvedLatestTag})
|
|
171
190
|
|
|
172
191
|
return {
|
|
173
192
|
currentVersion,
|
|
@@ -181,6 +200,7 @@ async function buildReleaseSuggestionContext(rootDir, {
|
|
|
181
200
|
|
|
182
201
|
async function suggestReleaseType(rootDir = process.cwd(), {
|
|
183
202
|
runCommand,
|
|
203
|
+
runCommandCapture,
|
|
184
204
|
currentVersion,
|
|
185
205
|
packageName,
|
|
186
206
|
commandExistsImpl = commandExists,
|
|
@@ -192,6 +212,7 @@ async function suggestReleaseType(rootDir = process.cwd(), {
|
|
|
192
212
|
} = {}) {
|
|
193
213
|
const context = await buildReleaseSuggestionContext(rootDir, {
|
|
194
214
|
runCommand,
|
|
215
|
+
runCommandCapture,
|
|
195
216
|
currentVersion,
|
|
196
217
|
packageName,
|
|
197
218
|
latestTag,
|
|
@@ -288,6 +309,7 @@ export async function resolveReleaseType({
|
|
|
288
309
|
interactive = true,
|
|
289
310
|
runPrompt,
|
|
290
311
|
runCommand,
|
|
312
|
+
runCommandCapture,
|
|
291
313
|
logStep,
|
|
292
314
|
logWarning,
|
|
293
315
|
latestTag = null,
|
|
@@ -300,6 +322,7 @@ export async function resolveReleaseType({
|
|
|
300
322
|
|
|
301
323
|
const suggested = await suggestReleaseType(rootDir, {
|
|
302
324
|
runCommand,
|
|
325
|
+
runCommandCapture,
|
|
303
326
|
currentVersion,
|
|
304
327
|
packageName,
|
|
305
328
|
logStep,
|