@wyxos/zephyr 0.1.5 → 0.1.6

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 +41 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wyxos/zephyr",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
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
@@ -328,6 +328,29 @@ async function ensureProjectReleaseScript(rootDir) {
328
328
  await fs.writeFile(packageJsonPath, updatedPayload)
329
329
  logSuccess('Added release script to package.json.')
330
330
 
331
+ let isGitRepo = false
332
+
333
+ try {
334
+ await runCommand('git', ['rev-parse', '--is-inside-work-tree'], { cwd: rootDir, silent: true })
335
+ isGitRepo = true
336
+ } catch (error) {
337
+ logWarning('Not a git repository; skipping commit for release script addition.')
338
+ }
339
+
340
+ if (isGitRepo) {
341
+ try {
342
+ await runCommand('git', ['add', 'package.json'], { cwd: rootDir, silent: true })
343
+ await runCommand('git', ['commit', '-m', 'chore: add zephyr release script'], { cwd: rootDir, silent: true })
344
+ logSuccess('Committed package.json release script addition.')
345
+ } catch (error) {
346
+ if (error.exitCode === 1) {
347
+ logWarning('Git commit skipped: nothing to commit or pre-commit hook prevented commit.')
348
+ } else {
349
+ throw error
350
+ }
351
+ }
352
+ }
353
+
331
354
  return true
332
355
  }
333
356
 
@@ -747,10 +770,19 @@ async function runRemoteTasks(config, options = {}) {
747
770
 
748
771
  logProcessing(`Connection established. Running deployment commands in ${remoteCwd}...`)
749
772
 
773
+ const profileBootstrap = [
774
+ 'if [ -f "$HOME/.profile" ]; then . "$HOME/.profile"; fi',
775
+ 'if [ -f "$HOME/.bash_profile" ]; then . "$HOME/.bash_profile"; fi',
776
+ 'if [ -f "$HOME/.bashrc" ]; then . "$HOME/.bashrc"; fi',
777
+ 'if [ -f "$HOME/.zprofile" ]; then . "$HOME/.zprofile"; fi',
778
+ 'if [ -f "$HOME/.zshrc" ]; then . "$HOME/.zshrc"; fi'
779
+ ].join('; ')
780
+
750
781
  const executeRemote = async (label, command, options = {}) => {
751
- const { cwd = remoteCwd, allowFailure = false, printStdout = true } = options
782
+ const { cwd = remoteCwd, allowFailure = false, printStdout = true, bootstrapEnv = true } = options
752
783
  logProcessing(`\n→ ${label}`)
753
- const result = await ssh.execCommand(command, { cwd })
784
+ const wrappedCommand = bootstrapEnv ? `${profileBootstrap}; ${command}` : command
785
+ const result = await ssh.execCommand(wrappedCommand, { cwd })
754
786
 
755
787
  if (printStdout && result.stdout && result.stdout.trim()) {
756
788
  console.log(result.stdout.trim())
@@ -765,6 +797,13 @@ async function runRemoteTasks(config, options = {}) {
765
797
  }
766
798
 
767
799
  if (result.code !== 0 && !allowFailure) {
800
+ const stderr = result.stderr?.trim() ?? ''
801
+ if (/command not found/.test(stderr) || /is not recognized/.test(stderr)) {
802
+ throw new Error(
803
+ `Command failed: ${command}. Ensure the remote environment loads required tools for non-interactive shells (e.g. export PATH in profile scripts).`
804
+ )
805
+ }
806
+
768
807
  throw new Error(`Command failed: ${command}`)
769
808
  }
770
809