@wyxos/zephyr 0.1.11 → 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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/index.mjs +26 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wyxos/zephyr",
3
- "version": "0.1.11",
3
+ "version": "0.1.12",
4
4
  "description": "A streamlined deployment tool for web applications with intelligent Laravel project detection",
5
5
  "type": "module",
6
6
  "main": "./src/index.mjs",
package/src/index.mjs CHANGED
@@ -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
- logWarning(`Uncommitted changes detected on ${targetBranch}. A commit is required before deployment.`)
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 local changes before deployment...')
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}.`)