@quatrain/app 1.1.8 → 1.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/dist/Infra.js +36 -38
- package/dist/Infra.js.map +1 -1
- package/package.json +3 -3
- package/src/Infra.ts +40 -40
package/dist/Infra.js
CHANGED
|
@@ -51,7 +51,7 @@ class AppInfra {
|
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
53
|
static getComposeCommand() {
|
|
54
|
-
return 'podman
|
|
54
|
+
return 'podman';
|
|
55
55
|
}
|
|
56
56
|
static async runCompose(action, composeFile, onProgress) {
|
|
57
57
|
return new Promise((resolve, reject) => {
|
|
@@ -59,46 +59,44 @@ class AppInfra {
|
|
|
59
59
|
log_1.Log.error(`[Infra] Compose file not found at: ${composeFile}`);
|
|
60
60
|
return reject(new Error(`Compose file not found: ${composeFile}`));
|
|
61
61
|
}
|
|
62
|
-
const
|
|
63
|
-
log_1.Log.info(`[Infra] Executing: ${
|
|
64
|
-
const child = (0, child_process_1.
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
if (errOut2)
|
|
76
|
-
log_1.Log.debug(`[Infra] ${errOut2}`);
|
|
77
|
-
resolve();
|
|
78
|
-
});
|
|
79
|
-
return;
|
|
62
|
+
const args = ['compose', '-f', composeFile, ...action.split(' ')];
|
|
63
|
+
log_1.Log.info(`[Infra] Executing: ${this.getComposeCommand()} ${args.join(' ')}`);
|
|
64
|
+
const child = (0, child_process_1.spawn)(this.getComposeCommand(), args, { shell: false });
|
|
65
|
+
const handleChild = (proc, isFallback) => {
|
|
66
|
+
proc.on('error', (error) => {
|
|
67
|
+
if (!isFallback && error.code === 'ENOENT') {
|
|
68
|
+
log_1.Log.warn(`[Infra] podman not found, falling back to docker...`);
|
|
69
|
+
const fallbackChild = (0, child_process_1.spawn)('docker', args, { shell: false });
|
|
70
|
+
handleChild(fallbackChild, true);
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
log_1.Log.error(`[Infra] Failed to run infrastructure: ${error.message}`);
|
|
74
|
+
reject(error);
|
|
80
75
|
}
|
|
81
|
-
log_1.Log.error(`[Infra] Failed to run infrastructure: ${error.message}`);
|
|
82
|
-
return reject(error);
|
|
83
|
-
}
|
|
84
|
-
if (stdout)
|
|
85
|
-
log_1.Log.debug(`[Infra] ${stdout}`);
|
|
86
|
-
if (stderr)
|
|
87
|
-
log_1.Log.debug(`[Infra] ${stderr}`);
|
|
88
|
-
resolve();
|
|
89
|
-
});
|
|
90
|
-
if (child.stdout) {
|
|
91
|
-
child.stdout.on('data', (data) => {
|
|
92
|
-
const text = data.toString().trim();
|
|
93
|
-
console.log(text);
|
|
94
76
|
});
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
77
|
+
proc.on('close', (code) => {
|
|
78
|
+
if (code !== 0) {
|
|
79
|
+
log_1.Log.error(`[Infra] Command failed with exit code ${code}`);
|
|
80
|
+
return reject(new Error(`Command failed with exit code ${code}`));
|
|
81
|
+
}
|
|
82
|
+
resolve();
|
|
100
83
|
});
|
|
101
|
-
|
|
84
|
+
if (proc.stdout) {
|
|
85
|
+
proc.stdout.on('data', (data) => {
|
|
86
|
+
const text = data.toString().trim();
|
|
87
|
+
if (text)
|
|
88
|
+
console.log(text);
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
if (proc.stderr) {
|
|
92
|
+
proc.stderr.on('data', (data) => {
|
|
93
|
+
const text = data.toString().trim();
|
|
94
|
+
if (text)
|
|
95
|
+
console.error(text);
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
handleChild(child, false);
|
|
102
100
|
});
|
|
103
101
|
}
|
|
104
102
|
}
|
package/dist/Infra.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Infra.js","sourceRoot":"","sources":["../src/Infra.ts"],"names":[],"mappings":";;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"Infra.js","sourceRoot":"","sources":["../src/Infra.ts"],"names":[],"mappings":";;;;;;AAAA,iDAAqC;AACrC,gDAAuB;AACvB,uCAAmC;AACnC,4CAAmB;AACnB,iDAA6C;AAC7C,mDAA+C;AAE/C,MAAa,QAAQ;IAMX,MAAM,CAAC,KAAK,CAAC,KAAK,CACtB,MAA2B,EAC3B,UAAwG;QAExG,IAAI,CAAC;YACF,MAAM,SAAS,GAAG,MAAM,CAAC,IAAI,IAAI,OAAO,CAAA;YACxC,MAAM,aAAa,GAAG,cAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,SAAS,CAAC,CAAA;YAC5D,MAAM,WAAW,GAAG,cAAI,CAAC,IAAI,CAAC,aAAa,EAAE,cAAc,CAAC,CAAA;YAE5D,IAAI,CAAC,YAAE,CAAC,UAAU,CAAC,aAAa,CAAC,EAAE,CAAC;gBACjC,YAAE,CAAC,SAAS,CAAC,aAAa,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;YACnD,CAAC;YAGD,UAAU,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,8BAA8B,EAAE,CAAC,CAAA;YAC1F,6BAAa,CAAC,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC,CAAA;YACzC,UAAU,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,oBAAoB,EAAE,CAAC,CAAA;YAGhF,UAAU,EAAE,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,sCAAsC,EAAE,CAAC,CAAA;YACnG,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,UAAU,EAAE,GAAG,2BAAY,CAAC,KA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f,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE;wBAC7B,MAAM,IAAI,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,CAAA;wBACnC,IAAI,IAAI;4BAAE,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;oBAChC,CAAC,CAAC,CAAA;gBACL,CAAC;YACJ,CAAC,CAAA;YAED,WAAW,CAAC,KAAK,EAAE,KAAK,CAAC,CAAA;QAC5B,CAAC,CAAC,CAAA;IACL,CAAC;CACH;AApHD,4BAoHC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quatrain/app",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.9",
|
|
4
4
|
"license": "AGPL-3.0-only",
|
|
5
5
|
"description": "Quatrain App Bootloader and configuration helpers",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
"author": "Quatrain Développement SAS <developers@quatrain.com>",
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@quatrain/auth": "^1.2.1",
|
|
24
|
-
"@quatrain/backend": "^1.2.
|
|
25
|
-
"@quatrain/core": "^1.2.
|
|
24
|
+
"@quatrain/backend": "^1.2.3",
|
|
25
|
+
"@quatrain/core": "^1.2.4",
|
|
26
26
|
"@quatrain/log": "^1.2.1",
|
|
27
27
|
"@quatrain/messaging": "^1.1.1",
|
|
28
28
|
"@quatrain/queue": "^1.2.1",
|
package/src/Infra.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { spawn } from 'child_process'
|
|
2
2
|
import path from 'path'
|
|
3
3
|
import { Log } from '@quatrain/log'
|
|
4
4
|
import fs from 'fs'
|
|
@@ -66,8 +66,8 @@ export class AppInfra {
|
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
private static getComposeCommand(): string {
|
|
69
|
-
// Prioritize podman
|
|
70
|
-
return 'podman
|
|
69
|
+
// Prioritize podman if working 'modern', otherwise fallback to docker
|
|
70
|
+
return 'podman'
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
private static async runCompose(action: string, composeFile: string, onProgress?: (event: { step: string; status: 'running' | 'success' | 'error'; message: string }) => void): Promise<void> {
|
|
@@ -77,48 +77,48 @@ export class AppInfra {
|
|
|
77
77
|
return reject(new Error(`Compose file not found: ${composeFile}`))
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
-
const
|
|
81
|
-
Log.info(`[Infra] Executing: ${
|
|
80
|
+
const args = ['compose', '-f', composeFile, ...action.split(' ')]
|
|
81
|
+
Log.info(`[Infra] Executing: ${this.getComposeCommand()} ${args.join(' ')}`)
|
|
82
82
|
|
|
83
|
-
const child =
|
|
84
|
-
if (error) {
|
|
85
|
-
// Fallback to docker-compose if podman-compose is not installed
|
|
86
|
-
if (error.message.includes('command not found')) {
|
|
87
|
-
Log.warn(`[Infra] podman compose not found, falling back to docker compose...`)
|
|
88
|
-
exec(`docker compose -f ${composeFile} ${action}`, (err2, out2, errOut2) => {
|
|
89
|
-
if (err2) {
|
|
90
|
-
Log.error(`[Infra] Failed to run infrastructure: ${err2.message}`)
|
|
91
|
-
return reject(err2)
|
|
92
|
-
}
|
|
93
|
-
if (out2) Log.debug(`[Infra] ${out2}`)
|
|
94
|
-
if (errOut2) Log.debug(`[Infra] ${errOut2}`)
|
|
95
|
-
resolve()
|
|
96
|
-
})
|
|
97
|
-
return
|
|
98
|
-
}
|
|
99
|
-
Log.error(`[Infra] Failed to run infrastructure: ${error.message}`)
|
|
100
|
-
return reject(error)
|
|
101
|
-
}
|
|
102
|
-
if (stdout) Log.debug(`[Infra] ${stdout}`)
|
|
103
|
-
if (stderr) Log.debug(`[Infra] ${stderr}`)
|
|
104
|
-
resolve()
|
|
105
|
-
})
|
|
83
|
+
const child = spawn(this.getComposeCommand(), args, { shell: false })
|
|
106
84
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
85
|
+
const handleChild = (proc: ReturnType<typeof spawn>, isFallback: boolean) => {
|
|
86
|
+
proc.on('error', (error: any) => {
|
|
87
|
+
// Fallback to docker if podman is not installed
|
|
88
|
+
if (!isFallback && error.code === 'ENOENT') {
|
|
89
|
+
Log.warn(`[Infra] podman not found, falling back to docker...`)
|
|
90
|
+
const fallbackChild = spawn('docker', args, { shell: false })
|
|
91
|
+
handleChild(fallbackChild, true)
|
|
92
|
+
} else {
|
|
93
|
+
Log.error(`[Infra] Failed to run infrastructure: ${error.message}`)
|
|
94
|
+
reject(error)
|
|
95
|
+
}
|
|
114
96
|
})
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
97
|
+
|
|
98
|
+
proc.on('close', (code) => {
|
|
99
|
+
if (code !== 0) {
|
|
100
|
+
Log.error(`[Infra] Command failed with exit code ${code}`)
|
|
101
|
+
return reject(new Error(`Command failed with exit code ${code}`))
|
|
102
|
+
}
|
|
103
|
+
resolve()
|
|
120
104
|
})
|
|
105
|
+
|
|
106
|
+
// Stream output to console
|
|
107
|
+
if (proc.stdout) {
|
|
108
|
+
proc.stdout.on('data', (data) => {
|
|
109
|
+
const text = data.toString().trim()
|
|
110
|
+
if (text) console.log(text)
|
|
111
|
+
})
|
|
112
|
+
}
|
|
113
|
+
if (proc.stderr) {
|
|
114
|
+
proc.stderr.on('data', (data) => {
|
|
115
|
+
const text = data.toString().trim()
|
|
116
|
+
if (text) console.error(text)
|
|
117
|
+
})
|
|
118
|
+
}
|
|
121
119
|
}
|
|
120
|
+
|
|
121
|
+
handleChild(child, false)
|
|
122
122
|
})
|
|
123
123
|
}
|
|
124
124
|
}
|