@wyxos/zephyr 0.1.7 → 0.1.9
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 +54 -6
package/package.json
CHANGED
package/src/index.mjs
CHANGED
|
@@ -20,6 +20,33 @@ const logSuccess = (message = '') => console.log(chalk.green(message))
|
|
|
20
20
|
const logWarning = (message = '') => console.warn(chalk.yellow(message))
|
|
21
21
|
const logError = (message = '') => console.error(chalk.red(message))
|
|
22
22
|
|
|
23
|
+
let logFilePath = null
|
|
24
|
+
|
|
25
|
+
async function getLogFilePath(rootDir) {
|
|
26
|
+
if (logFilePath) {
|
|
27
|
+
return logFilePath
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const configDir = getProjectConfigDir(rootDir)
|
|
31
|
+
await ensureDirectory(configDir)
|
|
32
|
+
|
|
33
|
+
const now = new Date()
|
|
34
|
+
const dateStr = now.toISOString().replace(/:/g, '-').replace(/\..+/, '')
|
|
35
|
+
logFilePath = path.join(configDir, `${dateStr}.log`)
|
|
36
|
+
|
|
37
|
+
return logFilePath
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
async function writeToLogFile(rootDir, message) {
|
|
41
|
+
const logPath = await getLogFilePath(rootDir)
|
|
42
|
+
const timestamp = new Date().toISOString()
|
|
43
|
+
await fs.appendFile(logPath, `${timestamp} - ${message}\n`)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
async function closeLogFile() {
|
|
47
|
+
logFilePath = null
|
|
48
|
+
}
|
|
49
|
+
|
|
23
50
|
const createSshClient = () => {
|
|
24
51
|
if (typeof globalThis !== 'undefined' && globalThis.__zephyrSSHFactory) {
|
|
25
52
|
return globalThis.__zephyrSSHFactory()
|
|
@@ -795,15 +822,23 @@ async function runRemoteTasks(config, options = {}) {
|
|
|
795
822
|
|
|
796
823
|
const result = await ssh.execCommand(wrappedCommand, execOptions)
|
|
797
824
|
|
|
798
|
-
|
|
799
|
-
|
|
825
|
+
// Log all output to file
|
|
826
|
+
if (result.stdout && result.stdout.trim()) {
|
|
827
|
+
await writeToLogFile(rootDir, `[${label}] STDOUT:\n${result.stdout.trim()}`)
|
|
800
828
|
}
|
|
801
829
|
|
|
802
830
|
if (result.stderr && result.stderr.trim()) {
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
831
|
+
await writeToLogFile(rootDir, `[${label}] STDERR:\n${result.stderr.trim()}`)
|
|
832
|
+
}
|
|
833
|
+
|
|
834
|
+
// Only show errors in terminal
|
|
835
|
+
if (result.code !== 0) {
|
|
836
|
+
if (result.stdout && result.stdout.trim()) {
|
|
837
|
+
logError(`\n[${label}] Output:\n${result.stdout.trim()}`)
|
|
838
|
+
}
|
|
839
|
+
|
|
840
|
+
if (result.stderr && result.stderr.trim()) {
|
|
841
|
+
logError(`\n[${label}] Error:\n${result.stderr.trim()}`)
|
|
807
842
|
}
|
|
808
843
|
}
|
|
809
844
|
|
|
@@ -818,6 +853,11 @@ async function runRemoteTasks(config, options = {}) {
|
|
|
818
853
|
throw new Error(`Command failed: ${command}`)
|
|
819
854
|
}
|
|
820
855
|
|
|
856
|
+
// Show success confirmation with command
|
|
857
|
+
if (result.code === 0) {
|
|
858
|
+
logSuccess(`✓ ${command}`)
|
|
859
|
+
}
|
|
860
|
+
|
|
821
861
|
return result
|
|
822
862
|
}
|
|
823
863
|
|
|
@@ -1022,9 +1062,17 @@ async function runRemoteTasks(config, options = {}) {
|
|
|
1022
1062
|
}
|
|
1023
1063
|
|
|
1024
1064
|
logSuccess('\nDeployment commands completed successfully.')
|
|
1065
|
+
|
|
1066
|
+
const logPath = await getLogFilePath(rootDir)
|
|
1067
|
+
logSuccess(`\nAll task output has been logged to: ${logPath}`)
|
|
1025
1068
|
} catch (error) {
|
|
1069
|
+
const logPath = logFilePath || await getLogFilePath(rootDir).catch(() => null)
|
|
1070
|
+
if (logPath) {
|
|
1071
|
+
logError(`\nTask output has been logged to: ${logPath}`)
|
|
1072
|
+
}
|
|
1026
1073
|
throw new Error(`Deployment failed: ${error.message}`)
|
|
1027
1074
|
} finally {
|
|
1075
|
+
await closeLogFile()
|
|
1028
1076
|
ssh.dispose()
|
|
1029
1077
|
}
|
|
1030
1078
|
}
|