@wyxos/zephyr 0.1.10 → 0.1.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/package.json +1 -1
- package/src/index.mjs +28 -5
package/package.json
CHANGED
package/src/index.mjs
CHANGED
|
@@ -13,7 +13,7 @@ const SERVERS_FILE = path.join(GLOBAL_CONFIG_DIR, 'servers.json')
|
|
|
13
13
|
const PROJECT_LOCK_FILE = 'deploy.lock'
|
|
14
14
|
const PENDING_TASKS_FILE = 'pending-tasks.json'
|
|
15
15
|
const RELEASE_SCRIPT_NAME = 'release'
|
|
16
|
-
const RELEASE_SCRIPT_COMMAND = 'npx @wyxos/zephyr@
|
|
16
|
+
const RELEASE_SCRIPT_COMMAND = 'npx @wyxos/zephyr@latest'
|
|
17
17
|
|
|
18
18
|
const logProcessing = (message = '') => console.log(chalk.yellow(message))
|
|
19
19
|
const logSuccess = (message = '') => console.log(chalk.green(message))
|
|
@@ -130,6 +130,24 @@ async function getGitStatus(rootDir) {
|
|
|
130
130
|
return output.trim()
|
|
131
131
|
}
|
|
132
132
|
|
|
133
|
+
function hasStagedChanges(statusOutput) {
|
|
134
|
+
if (!statusOutput || statusOutput.length === 0) {
|
|
135
|
+
return false
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
const lines = statusOutput.split('\n').filter((line) => line.trim().length > 0)
|
|
139
|
+
|
|
140
|
+
return lines.some((line) => {
|
|
141
|
+
const firstChar = line[0]
|
|
142
|
+
// In git status --porcelain format:
|
|
143
|
+
// - First char is space: unstaged changes (e.g., " M file")
|
|
144
|
+
// - First char is '?': untracked files (e.g., "?? file")
|
|
145
|
+
// - First char is letter (M, A, D, etc.): staged changes (e.g., "M file")
|
|
146
|
+
// Only return true for staged changes, not unstaged or untracked
|
|
147
|
+
return firstChar && firstChar !== ' ' && firstChar !== '?'
|
|
148
|
+
})
|
|
149
|
+
}
|
|
150
|
+
|
|
133
151
|
async function getUpstreamRef(rootDir) {
|
|
134
152
|
try {
|
|
135
153
|
const output = await runCommandCapture('git', ['rev-parse', '--abbrev-ref', '--symbolic-full-name', '@{u}'], {
|
|
@@ -275,7 +293,13 @@ async function ensureLocalRepositoryState(targetBranch, rootDir = process.cwd())
|
|
|
275
293
|
return
|
|
276
294
|
}
|
|
277
295
|
|
|
278
|
-
|
|
296
|
+
if (!hasStagedChanges(statusAfterCheckout)) {
|
|
297
|
+
await ensureCommittedChangesPushed(targetBranch, rootDir)
|
|
298
|
+
logProcessing('No staged changes detected. Unstaged or untracked files will not affect deployment. Proceeding with deployment.')
|
|
299
|
+
return
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
logWarning(`Staged changes detected on ${targetBranch}. A commit is required before deployment.`)
|
|
279
303
|
|
|
280
304
|
const { commitMessage } = await runPrompt([
|
|
281
305
|
{
|
|
@@ -288,8 +312,7 @@ async function ensureLocalRepositoryState(targetBranch, rootDir = process.cwd())
|
|
|
288
312
|
|
|
289
313
|
const message = commitMessage.trim()
|
|
290
314
|
|
|
291
|
-
logProcessing('Committing
|
|
292
|
-
await runCommand('git', ['add', '-A'], { cwd: rootDir })
|
|
315
|
+
logProcessing('Committing staged changes before deployment...')
|
|
293
316
|
await runCommand('git', ['commit', '-m', message], { cwd: rootDir })
|
|
294
317
|
await runCommand('git', ['push', 'origin', targetBranch], { cwd: rootDir })
|
|
295
318
|
logSuccess(`Committed and pushed changes to origin/${targetBranch}.`)
|
|
@@ -336,7 +359,7 @@ async function ensureProjectReleaseScript(rootDir) {
|
|
|
336
359
|
{
|
|
337
360
|
type: 'confirm',
|
|
338
361
|
name: 'installReleaseScript',
|
|
339
|
-
message: 'Add "release" script to package.json that runs "npx @wyxos/zephyr@
|
|
362
|
+
message: 'Add "release" script to package.json that runs "npx @wyxos/zephyr@latest"?',
|
|
340
363
|
default: true
|
|
341
364
|
}
|
|
342
365
|
])
|