@wyxos/zephyr 0.1.5 → 0.1.7
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 +52 -2
package/package.json
CHANGED
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,30 @@ 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
|
+
|
|
781
|
+
const escapeForDoubleQuotes = (value) => value.replace(/(["\\$`])/g, '\\$1')
|
|
782
|
+
|
|
750
783
|
const executeRemote = async (label, command, options = {}) => {
|
|
751
|
-
const { cwd = remoteCwd, allowFailure = false, printStdout = true } = options
|
|
784
|
+
const { cwd = remoteCwd, allowFailure = false, printStdout = true, bootstrapEnv = true } = options
|
|
752
785
|
logProcessing(`\n→ ${label}`)
|
|
753
|
-
|
|
786
|
+
|
|
787
|
+
let wrappedCommand = command
|
|
788
|
+
let execOptions = { cwd }
|
|
789
|
+
|
|
790
|
+
if (bootstrapEnv) {
|
|
791
|
+
const cwdForShell = escapeForDoubleQuotes(cwd)
|
|
792
|
+
wrappedCommand = `${profileBootstrap}; cd "${cwdForShell}" && ${command}`
|
|
793
|
+
execOptions = {}
|
|
794
|
+
}
|
|
795
|
+
|
|
796
|
+
const result = await ssh.execCommand(wrappedCommand, execOptions)
|
|
754
797
|
|
|
755
798
|
if (printStdout && result.stdout && result.stdout.trim()) {
|
|
756
799
|
console.log(result.stdout.trim())
|
|
@@ -765,6 +808,13 @@ async function runRemoteTasks(config, options = {}) {
|
|
|
765
808
|
}
|
|
766
809
|
|
|
767
810
|
if (result.code !== 0 && !allowFailure) {
|
|
811
|
+
const stderr = result.stderr?.trim() ?? ''
|
|
812
|
+
if (/command not found/.test(stderr) || /is not recognized/.test(stderr)) {
|
|
813
|
+
throw new Error(
|
|
814
|
+
`Command failed: ${command}. Ensure the remote environment loads required tools for non-interactive shells (e.g. export PATH in profile scripts).`
|
|
815
|
+
)
|
|
816
|
+
}
|
|
817
|
+
|
|
768
818
|
throw new Error(`Command failed: ${command}`)
|
|
769
819
|
}
|
|
770
820
|
|