@habeetat/cli 0.1.0-dev.20260323164114.3a5aac3

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/index.js ADDED
@@ -0,0 +1,592 @@
1
+ 'use strict';
2
+
3
+ var crypto = require('crypto');
4
+ var chalk = require('chalk');
5
+ var execa = require('execa');
6
+ var fs = require('fs');
7
+ var path = require('path');
8
+
9
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
10
+
11
+ var crypto__default = /*#__PURE__*/_interopDefault(crypto);
12
+ var chalk__default = /*#__PURE__*/_interopDefault(chalk);
13
+ var fs__default = /*#__PURE__*/_interopDefault(fs);
14
+ var path__default = /*#__PURE__*/_interopDefault(path);
15
+
16
+ // src/constants.ts
17
+ var CONFIG_FILE = "habeetat.json";
18
+ var ENV_FILE = ".env";
19
+ var COMPOSE_FILE = "docker-compose.yml";
20
+ var DOCKER_REGISTRY = "docker.io/capriisland";
21
+ var IMAGES = {
22
+ backend: "capriisland/habeetat-backend",
23
+ launcher: "capriisland/habeetat-launcher",
24
+ orgManager: "capriisland/habeetat-org-manager",
25
+ platformManager: "capriisland/habeetat-platform-manager",
26
+ sampleCrm: "capriisland/habeetat-sample-crm",
27
+ logtoConfig: "capriisland/habeetat-logto-config"
28
+ };
29
+ var THIRD_PARTY_IMAGES = {
30
+ postgres: "postgres:15-alpine",
31
+ logto: "svhd/logto:1.33",
32
+ nginx: "nginx:1.25-alpine",
33
+ certbot: "certbot/certbot"
34
+ };
35
+ var SERVICES = [
36
+ "logto-db",
37
+ "platform-db",
38
+ "logto-core",
39
+ "backend",
40
+ "launcher",
41
+ "organization-manager",
42
+ "platform-manager",
43
+ "sample-crm",
44
+ "nginx"
45
+ ];
46
+
47
+ // src/templates/docker-compose.ts
48
+ function generateDockerCompose(config) {
49
+ const tag = config.docker.imageTag;
50
+ const registry = config.docker.registry;
51
+ const services = {
52
+ "logto-db": {
53
+ image: THIRD_PARTY_IMAGES.postgres,
54
+ environment: {
55
+ POSTGRES_USER: "${LOGTO_DB_USER}",
56
+ POSTGRES_PASSWORD: "${LOGTO_DB_PASSWORD}",
57
+ POSTGRES_DB: "${LOGTO_DB_NAME}"
58
+ },
59
+ volumes: ["logto-db-data:/var/lib/postgresql/data"],
60
+ networks: ["habeetat-network"],
61
+ restart: "unless-stopped",
62
+ healthcheck: {
63
+ test: ["CMD-SHELL", "pg_isready -U ${LOGTO_DB_USER} -d ${LOGTO_DB_NAME}"],
64
+ interval: "5s",
65
+ timeout: "3s",
66
+ retries: 10
67
+ }
68
+ },
69
+ "platform-db": {
70
+ image: THIRD_PARTY_IMAGES.postgres,
71
+ environment: {
72
+ POSTGRES_USER: "${PLATFORM_DB_USER}",
73
+ POSTGRES_PASSWORD: "${PLATFORM_DB_PASSWORD}",
74
+ POSTGRES_DB: "${PLATFORM_DB_NAME}"
75
+ },
76
+ volumes: ["platform-db-data:/var/lib/postgresql/data"],
77
+ networks: ["habeetat-network"],
78
+ restart: "unless-stopped",
79
+ healthcheck: {
80
+ test: ["CMD-SHELL", "pg_isready -U ${PLATFORM_DB_USER} -d ${PLATFORM_DB_NAME}"],
81
+ interval: "5s",
82
+ timeout: "3s",
83
+ retries: 10
84
+ }
85
+ },
86
+ "logto-core": {
87
+ image: THIRD_PARTY_IMAGES.logto,
88
+ entrypoint: ["sh", "-c"],
89
+ command: ["npm run cli -- db seed -- --swe || true\nnpm run start"],
90
+ depends_on: {
91
+ "logto-db": { condition: "service_healthy" }
92
+ },
93
+ environment: {
94
+ DB_URL: "postgres://${LOGTO_DB_USER}:${LOGTO_DB_PASSWORD}@logto-db:5432/${LOGTO_DB_NAME}",
95
+ ENDPOINT: "${LOGTO_ENDPOINT}",
96
+ ADMIN_ENDPOINT: "${LOGTO_ADMIN_ENDPOINT}",
97
+ ADMIN_CONSOLE_URL: "${LOGTO_ADMIN_ENDPOINT}",
98
+ ADMIN_PORT: "3002",
99
+ TRUST_PROXY_HEADER: "1",
100
+ COOKIE_KEYS: "${ENCRYPTION_KEY}",
101
+ ALLOWED_ORIGINS: "${LOGTO_ENDPOINT},${LOGTO_ADMIN_ENDPOINT},${LAUNCHER_URL},${ORG_MANAGER_URL},${PLATFORM_MANAGER_URL},${SAMPLE_CRM_URL},${BACKEND_API_URL}",
102
+ CORS_ALLOWED_ORIGINS: "${LOGTO_ENDPOINT},${LOGTO_ADMIN_ENDPOINT},${LAUNCHER_URL},${ORG_MANAGER_URL},${PLATFORM_MANAGER_URL},${SAMPLE_CRM_URL},${BACKEND_API_URL}",
103
+ ADMIN_CONSOLE_ALLOWED_ORIGINS: "${LOGTO_ADMIN_ENDPOINT}"
104
+ },
105
+ networks: ["habeetat-network"],
106
+ restart: "unless-stopped",
107
+ healthcheck: {
108
+ test: ["CMD-SHELL", "wget -q --spider http://localhost:3001/oidc/.well-known/openid-configuration || exit 1"],
109
+ interval: "10s",
110
+ timeout: "5s",
111
+ retries: 15,
112
+ start_period: "90s"
113
+ }
114
+ },
115
+ backend: {
116
+ image: `${registry}/habeetat-backend:${tag}`,
117
+ depends_on: {
118
+ "logto-core": { condition: "service_healthy" },
119
+ "platform-db": { condition: "service_healthy" }
120
+ },
121
+ environment: {
122
+ NODE_ENV: "production",
123
+ DATABASE_URL: "postgres://${PLATFORM_DB_USER}:${PLATFORM_DB_PASSWORD}@platform-db:5432/${PLATFORM_DB_NAME}",
124
+ IAM_ISSUER_URL: "${LOGTO_ENDPOINT}/oidc",
125
+ IAM_JWKS_URL: "http://logto-core:3001",
126
+ IAM_AUDIENCE: "${IAM_AUDIENCE}",
127
+ LOGTO_ENDPOINT: "http://logto-core:3001",
128
+ LOGTO_EXTERNAL_ENDPOINT: "${LOGTO_ENDPOINT}",
129
+ SDK_API_RESOURCE: "${IAM_AUDIENCE}",
130
+ LOGTO_M2M_APP_ID: "nhp-m2m-config",
131
+ LOGTO_M2M_APP_SECRET: "${LOGTO_M2M_APP_SECRET}",
132
+ ENCRYPTION_KEY: "${ENCRYPTION_KEY}",
133
+ LAUNCHER_URL: "${LAUNCHER_URL}",
134
+ CORS_ORIGINS: "${CORS_ORIGINS}"
135
+ },
136
+ networks: ["habeetat-network"],
137
+ restart: "unless-stopped",
138
+ healthcheck: {
139
+ test: ["CMD", "curl", "-f", "http://localhost:3001/platform/status"],
140
+ interval: "30s",
141
+ timeout: "10s",
142
+ retries: 3,
143
+ start_period: "60s"
144
+ }
145
+ }
146
+ };
147
+ if (config.services.launcher) {
148
+ services["launcher"] = {
149
+ image: `${registry}/habeetat-launcher:${tag}`,
150
+ depends_on: ["backend"],
151
+ environment: {
152
+ VITE_IAM_LOGTO_ENDPOINT: "${LOGTO_ENDPOINT}",
153
+ VITE_IAM_AUDIENCE: "${IAM_AUDIENCE}",
154
+ VITE_IAM_APP_ID: "nhp-launcher",
155
+ VITE_APP_BASE_URL: "${LAUNCHER_URL}",
156
+ VITE_PLATFORM_API_URL: "${BACKEND_API_URL}"
157
+ },
158
+ networks: ["habeetat-network"],
159
+ restart: "unless-stopped"
160
+ };
161
+ }
162
+ if (config.services.organizationManager) {
163
+ services["organization-manager"] = {
164
+ image: `${registry}/habeetat-org-manager:${tag}`,
165
+ depends_on: ["backend"],
166
+ environment: {
167
+ VITE_LOGTO_ENDPOINT: "${LOGTO_ENDPOINT}",
168
+ VITE_LOGTO_APP_ID: "nhp-org-manager",
169
+ VITE_LOGTO_API_RESOURCE: "${IAM_AUDIENCE}",
170
+ VITE_APP_BASE_URL: "${ORG_MANAGER_URL}",
171
+ VITE_BACKEND_API_URL: "${BACKEND_API_URL}"
172
+ },
173
+ networks: ["habeetat-network"],
174
+ restart: "unless-stopped"
175
+ };
176
+ }
177
+ if (config.services.platformManager) {
178
+ services["platform-manager"] = {
179
+ image: `${registry}/habeetat-platform-manager:${tag}`,
180
+ depends_on: ["backend"],
181
+ environment: {
182
+ VITE_LOGTO_ENDPOINT: "${LOGTO_ENDPOINT}",
183
+ VITE_LOGTO_APP_ID: "nhp-plat-mgr",
184
+ VITE_LOGTO_API_RESOURCE: "${IAM_AUDIENCE}",
185
+ VITE_APP_BASE_URL: "${PLATFORM_MANAGER_URL}",
186
+ VITE_BACKEND_API_URL: "${BACKEND_API_URL}"
187
+ },
188
+ networks: ["habeetat-network"],
189
+ restart: "unless-stopped"
190
+ };
191
+ }
192
+ if (config.services.sampleCrm) {
193
+ services["sample-crm"] = {
194
+ image: `${registry}/habeetat-sample-crm:${tag}`,
195
+ depends_on: ["backend"],
196
+ environment: {
197
+ VITE_LOGTO_ENDPOINT: "${LOGTO_ENDPOINT}",
198
+ VITE_LOGTO_API_RESOURCE: "${IAM_AUDIENCE}",
199
+ VITE_PLATFORM_API_URL: "${BACKEND_API_URL}",
200
+ VITE_APP_BASE_URL: "${SAMPLE_CRM_URL}"
201
+ },
202
+ networks: ["habeetat-network"],
203
+ restart: "unless-stopped"
204
+ };
205
+ }
206
+ const nginxDependsOn = ["logto-core", "backend"];
207
+ if (config.services.launcher) nginxDependsOn.push("launcher");
208
+ if (config.services.organizationManager) nginxDependsOn.push("organization-manager");
209
+ if (config.services.platformManager) nginxDependsOn.push("platform-manager");
210
+ if (config.services.sampleCrm) nginxDependsOn.push("sample-crm");
211
+ const nginxVolumes = ["./nginx/platform.conf:/etc/nginx/conf.d/default.conf:ro"];
212
+ const nginxPorts = ["80:80"];
213
+ if (config.platform.protocol === "https") {
214
+ nginxVolumes.push("./certbot/conf:/etc/letsencrypt:ro");
215
+ nginxVolumes.push("./certbot/www:/var/www/certbot:ro");
216
+ nginxPorts.push("443:443");
217
+ }
218
+ services["nginx"] = {
219
+ image: THIRD_PARTY_IMAGES.nginx,
220
+ depends_on: nginxDependsOn,
221
+ volumes: nginxVolumes,
222
+ ports: nginxPorts,
223
+ networks: ["habeetat-network"],
224
+ restart: "unless-stopped",
225
+ command: `/bin/sh -c 'while :; do sleep 6h & wait $\${!}; nginx -s reload; done & nginx -g "daemon off;"'`
226
+ };
227
+ if (config.platform.protocol === "https") {
228
+ services["certbot"] = {
229
+ image: THIRD_PARTY_IMAGES.certbot,
230
+ volumes: [
231
+ "./certbot/conf:/etc/letsencrypt",
232
+ "./certbot/www:/var/www/certbot"
233
+ ],
234
+ entrypoint: `/bin/sh -c 'trap exit TERM; while :; do certbot renew; sleep 12h & wait $\${!}; done;'`,
235
+ networks: ["habeetat-network"]
236
+ };
237
+ }
238
+ const compose = {
239
+ name: "habeetat",
240
+ services,
241
+ volumes: {
242
+ "logto-db-data": null,
243
+ "platform-db-data": null
244
+ },
245
+ networks: {
246
+ "habeetat-network": {
247
+ driver: "bridge"
248
+ }
249
+ }
250
+ };
251
+ return toYaml(compose);
252
+ }
253
+ function toYaml(obj, indent = 0) {
254
+ const pad = " ".repeat(indent);
255
+ if (obj === null || obj === void 0) return "";
256
+ if (typeof obj === "string") {
257
+ if (obj.includes("\n") || obj.includes("'") || obj.includes('"') || obj.includes(":") || obj.includes("#") || obj.includes("{") || obj.includes("}") || obj.includes("$")) {
258
+ return `'${obj.replace(/'/g, "''")}'`;
259
+ }
260
+ return obj;
261
+ }
262
+ if (typeof obj === "number" || typeof obj === "boolean") return String(obj);
263
+ if (Array.isArray(obj)) {
264
+ if (obj.length === 0) return "[]";
265
+ const allScalar = obj.every(
266
+ (item) => typeof item === "string" || typeof item === "number" || typeof item === "boolean"
267
+ );
268
+ if (allScalar) {
269
+ return obj.map((item) => `
270
+ ${pad}- ${toYaml(item, indent + 2)}`).join("");
271
+ }
272
+ return obj.map((item) => {
273
+ const val = toYaml(item, indent + 2);
274
+ if (typeof item === "object" && item !== null && !Array.isArray(item)) {
275
+ const lines = val.split("\n").filter((l) => l.trim());
276
+ if (lines.length > 0) {
277
+ const first = lines[0].trimStart();
278
+ const rest = lines.slice(1).map((l) => `${pad} ${l.trimStart()}`).join("\n");
279
+ return `
280
+ ${pad}- ${first}${rest ? "\n" + rest : ""}`;
281
+ }
282
+ }
283
+ return `
284
+ ${pad}- ${val}`;
285
+ }).join("");
286
+ }
287
+ if (typeof obj === "object") {
288
+ const entries = Object.entries(obj);
289
+ if (entries.length === 0) return "{}";
290
+ return entries.map(([key, value]) => {
291
+ if (value === null || value === void 0) return `${pad}${key}:`;
292
+ if (typeof value === "object" && !Array.isArray(value)) {
293
+ const nested = toYaml(value, indent + 2);
294
+ return `${pad}${key}:
295
+ ${nested}`;
296
+ }
297
+ if (Array.isArray(value)) {
298
+ const nested = toYaml(value, indent + 2);
299
+ return `${pad}${key}:${nested}`;
300
+ }
301
+ return `${pad}${key}: ${toYaml(value, indent)}`;
302
+ }).join("\n");
303
+ }
304
+ return String(obj);
305
+ }
306
+
307
+ // src/templates/nginx.ts
308
+ function generateNginxConf(config) {
309
+ const domain = config.platform.domain;
310
+ const ssl = config.platform.protocol === "https";
311
+ const upstreams = [
312
+ "upstream logto { server logto-core:3001; }",
313
+ "upstream logto_admin { server logto-core:3002; }",
314
+ "upstream api { server backend:3001; }"
315
+ ];
316
+ if (config.services.launcher) upstreams.push("upstream launcher { server launcher:80; }");
317
+ if (config.services.organizationManager) upstreams.push("upstream organization-manager { server organization-manager:80; }");
318
+ if (config.services.platformManager) upstreams.push("upstream platform-manager { server platform-manager:80; }");
319
+ if (config.services.sampleCrm) upstreams.push("upstream sample-crm { server sample-crm:80; }");
320
+ const proxyHeaders = `
321
+ proxy_set_header Host $host;
322
+ proxy_set_header X-Real-IP $remote_addr;
323
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
324
+ proxy_set_header X-Forwarded-Proto $scheme;`;
325
+ const sslBlock = ssl ? `
326
+ ssl_certificate /etc/letsencrypt/live/${domain}/fullchain.pem;
327
+ ssl_certificate_key /etc/letsencrypt/live/${domain}/privkey.pem;
328
+ include /etc/letsencrypt/options-ssl-nginx.conf;
329
+ ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;` : "";
330
+ const listenDirective = ssl ? "listen 443 ssl" : "listen 80";
331
+ const serverBlocks = [];
332
+ if (ssl) {
333
+ serverBlocks.push(`
334
+ server {
335
+ listen 80;
336
+ server_name ${domain} *.${domain};
337
+ location /.well-known/acme-challenge/ { root /var/www/certbot; }
338
+ location / { return 301 https://$host$request_uri; }
339
+ }`);
340
+ }
341
+ serverBlocks.push(`
342
+ server {
343
+ ${listenDirective};
344
+ server_name iam.${domain};${sslBlock}
345
+ location / {
346
+ proxy_pass http://logto;${proxyHeaders}
347
+ }
348
+ }`);
349
+ serverBlocks.push(`
350
+ server {
351
+ ${listenDirective};
352
+ server_name iam-console.${domain};${sslBlock}
353
+ location / {
354
+ proxy_pass http://logto_admin;${proxyHeaders}
355
+ }
356
+ }`);
357
+ serverBlocks.push(`
358
+ server {
359
+ ${listenDirective};
360
+ server_name api.${domain};${sslBlock}
361
+ location / {
362
+ limit_req zone=api_limit burst=20 nodelay;
363
+ proxy_pass http://api;${proxyHeaders}
364
+ }
365
+ }`);
366
+ if (config.services.launcher) {
367
+ serverBlocks.push(`
368
+ server {
369
+ ${listenDirective};
370
+ server_name launcher.${domain};${sslBlock}
371
+ location / {
372
+ proxy_pass http://launcher;${proxyHeaders}
373
+ }
374
+ }`);
375
+ }
376
+ if (config.services.organizationManager) {
377
+ serverBlocks.push(`
378
+ server {
379
+ ${listenDirective};
380
+ server_name organization-manager.${domain};${sslBlock}
381
+ location / {
382
+ proxy_pass http://organization-manager;${proxyHeaders}
383
+ }
384
+ }`);
385
+ }
386
+ if (config.services.platformManager) {
387
+ serverBlocks.push(`
388
+ server {
389
+ ${listenDirective};
390
+ server_name platform-manager.${domain};${sslBlock}
391
+ location / {
392
+ proxy_pass http://platform-manager;${proxyHeaders}
393
+ }
394
+ }`);
395
+ }
396
+ if (config.services.sampleCrm) {
397
+ serverBlocks.push(`
398
+ server {
399
+ ${listenDirective};
400
+ server_name sample-crm.${domain};${sslBlock}
401
+ location / {
402
+ proxy_pass http://sample-crm;${proxyHeaders}
403
+ }
404
+ }`);
405
+ }
406
+ return `# Habeetat Platform - Nginx Configuration
407
+ # Auto-generated by @habeetat/cli for domain: ${domain}
408
+
409
+ ${upstreams.join("\n")}
410
+
411
+ limit_req_zone $binary_remote_addr zone=api_limit:10m rate=10r/s;
412
+ ${serverBlocks.join("\n")}
413
+ `;
414
+ }
415
+ function randomHex(bytes) {
416
+ return crypto__default.default.randomBytes(bytes).toString("hex");
417
+ }
418
+ function generateSecrets() {
419
+ return {
420
+ logtoDbPassword: randomHex(16),
421
+ platformDbPassword: randomHex(16),
422
+ encryptionKey: randomHex(32),
423
+ logtoM2mAppSecret: randomHex(32)
424
+ };
425
+ }
426
+
427
+ // src/templates/env.ts
428
+ function generateEnvFile(opts) {
429
+ const protocol = opts.ssl ? "https" : "http";
430
+ const domain = opts.domain;
431
+ const secrets = generateSecrets();
432
+ return `# Habeetat Platform - Environment Configuration
433
+ # Generated by @habeetat/cli on ${(/* @__PURE__ */ new Date()).toISOString()}
434
+
435
+ # ============================================
436
+ # Domain Configuration
437
+ # ============================================
438
+ DOMAIN=${domain}
439
+ PROTOCOL=${protocol}
440
+
441
+ # ============================================
442
+ # Service URLs (External - Browser-facing)
443
+ # ============================================
444
+ LOGTO_ENDPOINT=${protocol}://iam.${domain}
445
+ LOGTO_ADMIN_ENDPOINT=${protocol}://iam-console.${domain}
446
+ LAUNCHER_URL=${protocol}://launcher.${domain}
447
+ ORG_MANAGER_URL=${protocol}://organization-manager.${domain}
448
+ PLATFORM_MANAGER_URL=${protocol}://platform-manager.${domain}
449
+ SAMPLE_CRM_URL=${protocol}://sample-crm.${domain}
450
+ BACKEND_API_URL=${protocol}://api.${domain}
451
+ CORS_ORIGINS=${protocol}://launcher.${domain},${protocol}://organization-manager.${domain},${protocol}://platform-manager.${domain},${protocol}://sample-crm.${domain}
452
+
453
+ # ============================================
454
+ # Database Configuration
455
+ # ============================================
456
+ LOGTO_DB_USER=logto
457
+ LOGTO_DB_PASSWORD=${secrets.logtoDbPassword}
458
+ LOGTO_DB_NAME=logto
459
+
460
+ PLATFORM_DB_USER=habeetat
461
+ PLATFORM_DB_PASSWORD=${secrets.platformDbPassword}
462
+ PLATFORM_DB_NAME=habeetat_platform
463
+
464
+ # ============================================
465
+ # Logto IAM Configuration
466
+ # ============================================
467
+ LOGTO_ADMIN_USERNAME=${opts.adminEmail}
468
+ LOGTO_ADMIN_PASSWORD=${opts.adminPassword}
469
+
470
+ IAM_ISSUER_URL=${protocol}://iam.${domain}/oidc
471
+ IAM_AUDIENCE=${protocol}://api.${domain}/api
472
+ SDK_API_RESOURCE=${protocol}://api.${domain}/api
473
+
474
+ LOGTO_M2M_APP_ID=nhp-m2m-config
475
+ LOGTO_M2M_APP_SECRET=${secrets.logtoM2mAppSecret}
476
+
477
+ # ============================================
478
+ # Platform Configuration
479
+ # ============================================
480
+ PLATFORM_ADMIN_EMAIL=${opts.adminEmail}
481
+ PLATFORM_ADMIN_PASSWORD=${opts.adminPassword}
482
+ ORGANIZATION_NAME=${opts.organizationName}
483
+
484
+ # ============================================
485
+ # Security
486
+ # ============================================
487
+ ENCRYPTION_KEY=${secrets.encryptionKey}
488
+
489
+ # ============================================
490
+ # CORS Configuration
491
+ # ============================================
492
+ ALLOWED_ORIGINS=${protocol}://iam-console.${domain},${protocol}://launcher.${domain},${protocol}://organization-manager.${domain},${protocol}://platform-manager.${domain}
493
+ CORS_ALLOWED_ORIGINS=${protocol}://iam-console.${domain},${protocol}://launcher.${domain},${protocol}://organization-manager.${domain},${protocol}://platform-manager.${domain}
494
+ `;
495
+ }
496
+ var prefix = chalk__default.default.cyan("[habeetat]");
497
+ var logger = {
498
+ info: (msg) => console.log(`${prefix} ${msg}`),
499
+ success: (msg) => console.log(`${prefix} ${chalk__default.default.green("\u2713")} ${msg}`),
500
+ warn: (msg) => console.log(`${prefix} ${chalk__default.default.yellow("\u26A0")} ${msg}`),
501
+ error: (msg) => console.error(`${prefix} ${chalk__default.default.red("\u2717")} ${msg}`),
502
+ phase: (msg) => {
503
+ console.log("");
504
+ console.log(chalk__default.default.cyan("\u2550".repeat(56)));
505
+ console.log(chalk__default.default.cyan(` ${msg}`));
506
+ console.log(chalk__default.default.cyan("\u2550".repeat(56)));
507
+ console.log("");
508
+ },
509
+ banner: () => {
510
+ console.log("");
511
+ console.log(chalk__default.default.cyan("\u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557"));
512
+ console.log(chalk__default.default.cyan("\u2551 \u2551"));
513
+ console.log(chalk__default.default.cyan("\u2551 Habeetat Platform CLI \u2551"));
514
+ console.log(chalk__default.default.cyan("\u2551 \u2551"));
515
+ console.log(chalk__default.default.cyan("\u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255D"));
516
+ console.log("");
517
+ }
518
+ };
519
+ async function checkDocker() {
520
+ try {
521
+ const { stdout } = await execa.execaCommand("docker --version");
522
+ const match = stdout.match(/Docker version (\d+)/);
523
+ if (match && parseInt(match[1], 10) >= 20) {
524
+ return true;
525
+ }
526
+ logger.error(`Docker >= 20.0 required. Found: ${stdout.trim()}`);
527
+ return false;
528
+ } catch {
529
+ logger.error("Docker is not installed or not in PATH");
530
+ logger.info("Install Docker: https://docs.docker.com/get-docker/");
531
+ return false;
532
+ }
533
+ }
534
+ async function checkDockerCompose() {
535
+ try {
536
+ await execa.execaCommand("docker compose version");
537
+ return true;
538
+ } catch {
539
+ logger.error("Docker Compose V2 is not available");
540
+ logger.info("Docker Compose V2 is included with Docker Desktop");
541
+ return false;
542
+ }
543
+ }
544
+ async function checkPrerequisites() {
545
+ const docker = await checkDocker();
546
+ const compose = await checkDockerCompose();
547
+ return docker && compose;
548
+ }
549
+ function findProjectRoot(startDir = process.cwd()) {
550
+ let dir = startDir;
551
+ while (dir !== path__default.default.dirname(dir)) {
552
+ if (fs__default.default.existsSync(path__default.default.join(dir, CONFIG_FILE))) {
553
+ return dir;
554
+ }
555
+ dir = path__default.default.dirname(dir);
556
+ }
557
+ return null;
558
+ }
559
+ function loadConfig(projectDir) {
560
+ const dir = projectDir || findProjectRoot();
561
+ if (!dir) {
562
+ throw new Error(
563
+ `Could not find ${CONFIG_FILE}. Are you inside a Habeetat project directory?`
564
+ );
565
+ }
566
+ const configPath = path__default.default.join(dir, CONFIG_FILE);
567
+ const raw = fs__default.default.readFileSync(configPath, "utf-8");
568
+ return JSON.parse(raw);
569
+ }
570
+ function saveConfig(config, projectDir) {
571
+ const configPath = path__default.default.join(projectDir, CONFIG_FILE);
572
+ fs__default.default.writeFileSync(configPath, JSON.stringify(config, null, 2) + "\n", "utf-8");
573
+ }
574
+
575
+ exports.COMPOSE_FILE = COMPOSE_FILE;
576
+ exports.CONFIG_FILE = CONFIG_FILE;
577
+ exports.DOCKER_REGISTRY = DOCKER_REGISTRY;
578
+ exports.ENV_FILE = ENV_FILE;
579
+ exports.IMAGES = IMAGES;
580
+ exports.SERVICES = SERVICES;
581
+ exports.THIRD_PARTY_IMAGES = THIRD_PARTY_IMAGES;
582
+ exports.checkPrerequisites = checkPrerequisites;
583
+ exports.findProjectRoot = findProjectRoot;
584
+ exports.generateDockerCompose = generateDockerCompose;
585
+ exports.generateEnvFile = generateEnvFile;
586
+ exports.generateNginxConf = generateNginxConf;
587
+ exports.generateSecrets = generateSecrets;
588
+ exports.loadConfig = loadConfig;
589
+ exports.logger = logger;
590
+ exports.saveConfig = saveConfig;
591
+ //# sourceMappingURL=index.js.map
592
+ //# sourceMappingURL=index.js.map