@wyxos/zephyr 0.2.20 → 0.2.21
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 +1 -1
- package/src/dependency-scanner.mjs +11 -31
- package/src/release-node.mjs +24 -6
package/package.json
CHANGED
|
@@ -31,7 +31,7 @@ function isLocalPathOutsideRepo(depPath, rootDir) {
|
|
|
31
31
|
// Check if resolved path is outside the repository root
|
|
32
32
|
// Use path.relative to check if the path goes outside
|
|
33
33
|
const relative = path.relative(normalizedRoot, normalizedResolved)
|
|
34
|
-
|
|
34
|
+
|
|
35
35
|
// If relative path starts with .., it's outside the repo
|
|
36
36
|
// Also check if the resolved path doesn't start with the root + separator (for absolute paths)
|
|
37
37
|
return relative.startsWith('..') || !normalizedResolved.startsWith(normalizedRoot + path.sep)
|
|
@@ -256,31 +256,8 @@ async function commitDependencyUpdates(rootDir, updatedFiles, promptFn, logFn) {
|
|
|
256
256
|
return false
|
|
257
257
|
}
|
|
258
258
|
|
|
259
|
-
const statusBefore = await getGitStatus(rootDir)
|
|
260
|
-
|
|
261
|
-
// Avoid accidentally committing unrelated staged changes
|
|
262
|
-
if (hasStagedChanges(statusBefore)) {
|
|
263
|
-
if (logFn) {
|
|
264
|
-
logFn('Staged changes detected. Skipping auto-commit of dependency updates.')
|
|
265
|
-
}
|
|
266
|
-
return false
|
|
267
|
-
}
|
|
268
|
-
|
|
269
259
|
const fileList = updatedFiles.map((f) => path.basename(f)).join(', ')
|
|
270
260
|
|
|
271
|
-
const { shouldCommit } = await promptFn([
|
|
272
|
-
{
|
|
273
|
-
type: 'confirm',
|
|
274
|
-
name: 'shouldCommit',
|
|
275
|
-
message: `Commit dependency updates now? (${fileList})`,
|
|
276
|
-
default: true
|
|
277
|
-
}
|
|
278
|
-
])
|
|
279
|
-
|
|
280
|
-
if (!shouldCommit) {
|
|
281
|
-
return false
|
|
282
|
-
}
|
|
283
|
-
|
|
284
261
|
// Stage the updated files
|
|
285
262
|
for (const file of updatedFiles) {
|
|
286
263
|
try {
|
|
@@ -290,11 +267,6 @@ async function commitDependencyUpdates(rootDir, updatedFiles, promptFn, logFn) {
|
|
|
290
267
|
}
|
|
291
268
|
}
|
|
292
269
|
|
|
293
|
-
const newStatus = await getGitStatus(rootDir)
|
|
294
|
-
if (!hasStagedChanges(newStatus)) {
|
|
295
|
-
return false
|
|
296
|
-
}
|
|
297
|
-
|
|
298
270
|
// Build commit message
|
|
299
271
|
const commitMessage = `chore: update local file dependencies to online versions (${fileList})`
|
|
300
272
|
|
|
@@ -302,7 +274,7 @@ async function commitDependencyUpdates(rootDir, updatedFiles, promptFn, logFn) {
|
|
|
302
274
|
logFn('Committing dependency updates...')
|
|
303
275
|
}
|
|
304
276
|
|
|
305
|
-
await runCommand('git', ['commit', '-m', commitMessage], { cwd: rootDir })
|
|
277
|
+
await runCommand('git', ['commit', '-m', commitMessage, '--', ...updatedFiles], { cwd: rootDir })
|
|
306
278
|
|
|
307
279
|
if (logFn) {
|
|
308
280
|
logFn('Dependency updates committed.')
|
|
@@ -371,6 +343,9 @@ async function validateLocalDependencies(rootDir, promptFn, logFn = null) {
|
|
|
371
343
|
throw new Error('Release cancelled: local file dependencies must be updated before release.')
|
|
372
344
|
}
|
|
373
345
|
|
|
346
|
+
// If we cannot commit the update, do not proceed (otherwise release-node will fail later with a dirty tree).
|
|
347
|
+
// We allow users to opt-in to committing together with existing staged changes via prompt.
|
|
348
|
+
|
|
374
349
|
// Track which files were updated
|
|
375
350
|
const updatedFiles = new Set()
|
|
376
351
|
|
|
@@ -437,7 +412,12 @@ async function validateLocalDependencies(rootDir, promptFn, logFn = null) {
|
|
|
437
412
|
|
|
438
413
|
// Commit the changes if any files were updated
|
|
439
414
|
if (updatedFiles.size > 0) {
|
|
440
|
-
await commitDependencyUpdates(rootDir, Array.from(updatedFiles), promptFn, logFn)
|
|
415
|
+
const committed = await commitDependencyUpdates(rootDir, Array.from(updatedFiles), promptFn, logFn)
|
|
416
|
+
if (!committed) {
|
|
417
|
+
throw new Error(
|
|
418
|
+
'Release cancelled: dependency updates were applied but were not committed. Commit/stash your changes and rerun.'
|
|
419
|
+
)
|
|
420
|
+
}
|
|
441
421
|
}
|
|
442
422
|
}
|
|
443
423
|
|
package/src/release-node.mjs
CHANGED
|
@@ -126,13 +126,25 @@ async function runTests(skipTests, pkg, rootDir = process.cwd()) {
|
|
|
126
126
|
logStep('Running test suite...')
|
|
127
127
|
|
|
128
128
|
try {
|
|
129
|
+
const testRunScript = pkg?.scripts?.['test:run'] ?? ''
|
|
130
|
+
const testScript = pkg?.scripts?.test ?? ''
|
|
131
|
+
const usesNodeTest = (script) => /\bnode\b.*\s--test\b/.test(script)
|
|
132
|
+
|
|
129
133
|
// Prefer test:run if available, otherwise use test with --run and --reporter flags
|
|
130
134
|
if (hasScript(pkg, 'test:run')) {
|
|
131
|
-
|
|
132
|
-
|
|
135
|
+
if (usesNodeTest(testRunScript)) {
|
|
136
|
+
await runCommand('npm', ['run', 'test:run'], { cwd: rootDir })
|
|
137
|
+
} else {
|
|
138
|
+
// Pass reporter flag to test:run script
|
|
139
|
+
await runCommand('npm', ['run', 'test:run', '--', '--reporter=dot'], { cwd: rootDir })
|
|
140
|
+
}
|
|
133
141
|
} else {
|
|
134
|
-
|
|
135
|
-
|
|
142
|
+
if (usesNodeTest(testScript)) {
|
|
143
|
+
await runCommand('npm', ['test'], { cwd: rootDir })
|
|
144
|
+
} else {
|
|
145
|
+
// For test script, pass --run and --reporter flags (works with vitest)
|
|
146
|
+
await runCommand('npm', ['test', '--', '--run', '--reporter=dot'], { cwd: rootDir })
|
|
147
|
+
}
|
|
136
148
|
}
|
|
137
149
|
|
|
138
150
|
logSuccess('Tests passed.')
|
|
@@ -217,7 +229,13 @@ async function runLibBuild(skipBuild, pkg, rootDir = process.cwd()) {
|
|
|
217
229
|
return hasLibChanges
|
|
218
230
|
}
|
|
219
231
|
|
|
220
|
-
async function ensureNpmAuth(rootDir = process.cwd()) {
|
|
232
|
+
async function ensureNpmAuth(pkg, rootDir = process.cwd()) {
|
|
233
|
+
const isPrivate = pkg?.publishConfig?.access === 'restricted'
|
|
234
|
+
if (isPrivate) {
|
|
235
|
+
logStep('Skipping npm authentication check (package is private/restricted).')
|
|
236
|
+
return
|
|
237
|
+
}
|
|
238
|
+
|
|
221
239
|
logStep('Confirming npm authentication...')
|
|
222
240
|
try {
|
|
223
241
|
const result = await runCommand('npm', ['whoami'], { capture: true, cwd: rootDir })
|
|
@@ -452,7 +470,7 @@ export async function releaseNode() {
|
|
|
452
470
|
await runLint(skipLint, pkg, rootDir)
|
|
453
471
|
await runTests(skipTests, pkg, rootDir)
|
|
454
472
|
await runLibBuild(skipBuild, pkg, rootDir)
|
|
455
|
-
await ensureNpmAuth(rootDir)
|
|
473
|
+
await ensureNpmAuth(pkg, rootDir)
|
|
456
474
|
|
|
457
475
|
const updatedPkg = await bumpVersion(releaseType, rootDir)
|
|
458
476
|
await runBuild(skipBuild, updatedPkg, rootDir)
|