@quatrain/app 1.1.3 → 1.1.4
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.d.ts +2 -2
- package/dist/Infra.d.ts.map +1 -1
- package/dist/Infra.js +18 -7
- package/dist/Infra.js.map +1 -1
- package/package.json +1 -1
- package/src/Infra.ts +19 -10
package/dist/Infra.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export declare class AppInfra {
|
|
2
|
-
static start(config
|
|
3
|
-
static stop(
|
|
2
|
+
static start(config: Record<string, any>): Promise<void>;
|
|
3
|
+
static stop(config: Record<string, any>): Promise<void>;
|
|
4
4
|
private static getComposeCommand;
|
|
5
5
|
private static runCompose;
|
|
6
6
|
}
|
package/dist/Infra.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Infra.d.ts","sourceRoot":"","sources":["../src/Infra.ts"],"names":[],"mappings":"AAOA,qBAAa,QAAQ;WAME,KAAK,CAAC,MAAM,CAAC,EAAE,GAAG,
|
|
1
|
+
{"version":3,"file":"Infra.d.ts","sourceRoot":"","sources":["../src/Infra.ts"],"names":[],"mappings":"AAOA,qBAAa,QAAQ;WAME,KAAK,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;WA+BjD,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAYpE,OAAO,CAAC,MAAM,CAAC,iBAAiB;mBAKX,UAAU;CA2CjC"}
|
package/dist/Infra.js
CHANGED
|
@@ -11,10 +11,11 @@ const fs_1 = __importDefault(require("fs"));
|
|
|
11
11
|
const InfraBuilder_1 = require("./InfraBuilder");
|
|
12
12
|
const CodeGenerator_1 = require("./CodeGenerator");
|
|
13
13
|
class AppInfra {
|
|
14
|
-
static async start(config
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
static async start(config) {
|
|
15
|
+
try {
|
|
16
|
+
const targetDir = config.path || './app';
|
|
17
17
|
const fullTargetDir = path_1.default.resolve(process.cwd(), targetDir);
|
|
18
|
+
const composeFile = path_1.default.join(fullTargetDir, 'compose.yaml');
|
|
18
19
|
if (!fs_1.default.existsSync(fullTargetDir)) {
|
|
19
20
|
fs_1.default.mkdirSync(fullTargetDir, { recursive: true });
|
|
20
21
|
}
|
|
@@ -24,12 +25,22 @@ class AppInfra {
|
|
|
24
25
|
fs_1.default.writeFileSync(path_1.default.resolve(fullTargetDir, '.env'), env, 'utf8');
|
|
25
26
|
fs_1.default.writeFileSync(path_1.default.resolve(fullTargetDir, 'Containerfile'), dockerfile, 'utf8');
|
|
26
27
|
log_1.Log.info(`[Infra] Dynamically generated compose.yaml and .env in ${fullTargetDir}`);
|
|
28
|
+
await this.runCompose('up -d --build', composeFile);
|
|
29
|
+
}
|
|
30
|
+
catch (e) {
|
|
31
|
+
log_1.Log.error(`[Infra] Failed to start infrastructure: ${e.message}`);
|
|
27
32
|
}
|
|
28
|
-
return this.runCompose('up -d --build', composeFile);
|
|
29
33
|
}
|
|
30
|
-
static async stop(
|
|
31
|
-
|
|
32
|
-
|
|
34
|
+
static async stop(config) {
|
|
35
|
+
try {
|
|
36
|
+
const targetDir = config.path || './app';
|
|
37
|
+
const composeFile = path_1.default.resolve(process.cwd(), targetDir, 'compose.yaml');
|
|
38
|
+
log_1.Log.info(`[Infra] Stopping infrastructure...`);
|
|
39
|
+
await this.runCompose('down', composeFile);
|
|
40
|
+
}
|
|
41
|
+
catch (e) {
|
|
42
|
+
log_1.Log.error(`[Infra] Failed to stop infrastructure: ${e.message}`);
|
|
43
|
+
}
|
|
33
44
|
}
|
|
34
45
|
static getComposeCommand() {
|
|
35
46
|
return 'podman compose';
|
package/dist/Infra.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Infra.js","sourceRoot":"","sources":["../src/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AAE,CAAC,CAAA;gBAC1C,OAAO,EAAE,CAAA;YACZ,CAAC,CAAC,CAAA;YAGF,IAAI,KAAK,CAAC,MAAM,EAAE,CAAC;gBAChB,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,CAAC,CAAC,CAAA;YACzE,CAAC;YACD,IAAI,KAAK,CAAC,MAAM,EAAE,CAAC;gBAChB,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,CAAC,CAAC,CAAA;YAC3E,CAAC;QACJ,CAAC,CAAC,CAAA;IACL,CAAC;CACH;AAjGD,4BAiGC"}
|
package/package.json
CHANGED
package/src/Infra.ts
CHANGED
|
@@ -11,12 +11,12 @@ export class AppInfra {
|
|
|
11
11
|
* via podman-compose ou docker-compose
|
|
12
12
|
* Si une configuration est fournie, génère d'abord les fichiers compose.yaml et .env dans le dossier app/
|
|
13
13
|
*/
|
|
14
|
-
public static async start(config
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
if (config) {
|
|
18
|
-
// Générer dynamiquement les fichiers de déploiement
|
|
14
|
+
public static async start(config: Record<string, any>): Promise<void> {
|
|
15
|
+
try {
|
|
16
|
+
const targetDir = config.path || './app'
|
|
19
17
|
const fullTargetDir = path.resolve(process.cwd(), targetDir)
|
|
18
|
+
const composeFile = path.join(fullTargetDir, 'compose.yaml')
|
|
19
|
+
|
|
20
20
|
if (!fs.existsSync(fullTargetDir)) {
|
|
21
21
|
fs.mkdirSync(fullTargetDir, { recursive: true })
|
|
22
22
|
}
|
|
@@ -32,17 +32,26 @@ export class AppInfra {
|
|
|
32
32
|
fs.writeFileSync(path.resolve(fullTargetDir, 'Containerfile'), dockerfile, 'utf8')
|
|
33
33
|
|
|
34
34
|
Log.info(`[Infra] Dynamically generated compose.yaml and .env in ${fullTargetDir}`)
|
|
35
|
-
}
|
|
36
35
|
|
|
37
|
-
|
|
36
|
+
await this.runCompose('up -d --build', composeFile)
|
|
37
|
+
} catch (e: any) {
|
|
38
|
+
Log.error(`[Infra] Failed to start infrastructure: ${e.message}`)
|
|
39
|
+
}
|
|
38
40
|
}
|
|
39
41
|
|
|
40
42
|
/**
|
|
41
43
|
* Arrêter l'infrastructure locale
|
|
42
44
|
*/
|
|
43
|
-
public static async stop(
|
|
44
|
-
|
|
45
|
-
|
|
45
|
+
public static async stop(config: Record<string, any>): Promise<void> {
|
|
46
|
+
try {
|
|
47
|
+
const targetDir = config.path || './app'
|
|
48
|
+
const composeFile = path.resolve(process.cwd(), targetDir, 'compose.yaml')
|
|
49
|
+
|
|
50
|
+
Log.info(`[Infra] Stopping infrastructure...`)
|
|
51
|
+
await this.runCompose('down', composeFile)
|
|
52
|
+
} catch (e: any) {
|
|
53
|
+
Log.error(`[Infra] Failed to stop infrastructure: ${e.message}`)
|
|
54
|
+
}
|
|
46
55
|
}
|
|
47
56
|
|
|
48
57
|
private static getComposeCommand(): string {
|