@aifabrix/builder 2.3.3 → 2.3.5

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/bin/aifabrix.js CHANGED
File without changes
package/lib/infra.js CHANGED
@@ -123,7 +123,7 @@ async function startInfra(developerId = null) {
123
123
  // Dev 0: infra-aifabrix-network, Dev > 0: infra-dev{id}-aifabrix-network
124
124
  const networkName = idNum === 0 ? 'infra-aifabrix-network' : `infra-dev${devId}-aifabrix-network`;
125
125
  const composeContent = template({
126
- devId: devId,
126
+ devId: idNum,
127
127
  postgresPort: ports.postgres,
128
128
  redisPort: ports.redis,
129
129
  pgadminPort: ports.pgadmin,
package/lib/secrets.js CHANGED
@@ -438,7 +438,7 @@ async function generateAdminSecretsEnv(secretsPath) {
438
438
  POSTGRES_PASSWORD=${postgresPassword}
439
439
  PGADMIN_DEFAULT_EMAIL=admin@aifabrix.ai
440
440
  PGADMIN_DEFAULT_PASSWORD=${postgresPassword}
441
- REDIS_HOST=local:localhost:6379
441
+ REDIS_HOST=local:redis:6379
442
442
  REDIS_COMMANDER_USER=admin
443
443
  REDIS_COMMANDER_PASSWORD=${postgresPassword}
444
444
  `;
@@ -16,6 +16,9 @@ const handlebars = require('handlebars');
16
16
  const config = require('../config');
17
17
  const buildCopy = require('./build-copy');
18
18
 
19
+ // Register commonly used helpers
20
+ handlebars.registerHelper('eq', (a, b) => a === b);
21
+
19
22
  // Register Handlebars helper for quoting PostgreSQL identifiers
20
23
  // PostgreSQL requires identifiers with hyphens or special characters to be quoted
21
24
  handlebars.registerHelper('pgQuote', (identifier) => {
@@ -28,21 +28,32 @@ async function findContainer(serviceName, devId = null) {
28
28
  const developerId = devId || await config.getDeveloperId();
29
29
  const idNum = typeof developerId === 'string' ? parseInt(developerId, 10) : developerId;
30
30
  // Dev 0: aifabrix-{serviceName}, Dev > 0: aifabrix-dev{id}-{serviceName}
31
- const containerNamePattern = idNum === 0
32
- ? `aifabrix-${serviceName}`
33
- : `aifabrix-dev${developerId}-${serviceName}`;
34
- let { stdout } = await execAsync(`docker ps --filter "name=${containerNamePattern}" --format "{{.Names}}"`);
35
- let containerName = stdout.trim();
36
- if (!containerName) {
37
- // Fallback to old naming patterns for backward compatibility
38
- ({ stdout } = await execAsync(`docker ps --filter "name=infra-${serviceName}" --format "{{.Names}}"`));
39
- containerName = stdout.trim();
40
- if (!containerName) {
41
- ({ stdout } = await execAsync(`docker ps --filter "name=aifabrix-${serviceName}" --format "{{.Names}}"`));
42
- containerName = stdout.trim();
31
+ const primaryPattern = idNum === 0 ? `aifabrix-${serviceName}` : `aifabrix-dev${developerId}-${serviceName}`;
32
+
33
+ // Search order expected by tests:
34
+ // 1) primaryPattern
35
+ // 2) infra-{serviceName} (old pattern)
36
+ // 3) aifabrix-{serviceName} (base pattern)
37
+ const patternsToTry = [
38
+ primaryPattern,
39
+ `infra-${serviceName}`,
40
+ `aifabrix-${serviceName}`
41
+ ];
42
+
43
+ for (const pattern of patternsToTry) {
44
+ const { stdout } = await execAsync(`docker ps --filter "name=${pattern}" --format "{{.Names}}"`);
45
+ const names = stdout
46
+ .split('\n')
47
+ .map(s => s.trim())
48
+ .filter(s => s.length > 0);
49
+ const exactMatch = names.find(n => n === pattern);
50
+ if (exactMatch || names[0]) {
51
+ return exactMatch || names[0];
43
52
  }
44
53
  }
45
- return containerName;
54
+
55
+ // Not found with any pattern
56
+ return '';
46
57
  } catch (error) {
47
58
  return null;
48
59
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aifabrix/builder",
3
- "version": "2.3.3",
3
+ "version": "2.3.5",
4
4
  "description": "AI Fabrix Local Fabric & Deployment SDK",
5
5
  "main": "lib/index.js",
6
6
  "bin": {
@@ -82,8 +82,10 @@ services:
82
82
 
83
83
  volumes:
84
84
  dev{{devId}}_postgres_data:
85
+ name: {{#if (eq devId 0)}}infra_postgres_data{{else}}infra_dev{{devId}}_postgres_data{{/if}}
85
86
  driver: local
86
87
  dev{{devId}}_redis_data:
88
+ name: {{#if (eq devId 0)}}infra_redis_data{{else}}infra_dev{{devId}}_redis_data{{/if}}
87
89
  driver: local
88
90
 
89
91
  networks:
@@ -14,7 +14,7 @@ services:
14
14
  - {{networkName}}
15
15
  {{#if requiresStorage}}
16
16
  volumes:
17
- - "{{mountVolume}}:/mnt/data"
17
+ - {{#if (eq devId 0)}}aifabrix_{{app.key}}_data{{else}}aifabrix_dev{{devId}}_{{app.key}}_data{{/if}}:/mnt/data
18
18
  {{/if}}
19
19
  healthcheck:
20
20
  test: ["CMD", "curl", "-f", "http://localhost:{{port}}{{healthCheck.path}}"]
@@ -98,6 +98,19 @@ services:
98
98
  restart: "no"
99
99
  {{/if}}
100
100
 
101
+ {{#if requiresStorage}}
102
+ volumes:
103
+ {{#if (eq devId 0)}}
104
+ aifabrix_{{app.key}}_data:
105
+ name: aifabrix_{{app.key}}_data
106
+ driver: local
107
+ {{else}}
108
+ aifabrix_dev{{devId}}_{{app.key}}_data:
109
+ name: aifabrix_dev{{devId}}_{{app.key}}_data
110
+ driver: local
111
+ {{/if}}
112
+ {{/if}}
113
+
101
114
  networks:
102
115
  {{networkName}}:
103
116
  external: true
@@ -14,7 +14,7 @@ services:
14
14
  - {{networkName}}
15
15
  {{#if requiresStorage}}
16
16
  volumes:
17
- - "{{mountVolume}}:/mnt/data"
17
+ - {{#if (eq devId 0)}}aifabrix_{{app.key}}_data{{else}}aifabrix_dev{{devId}}_{{app.key}}_data{{/if}}:/mnt/data
18
18
  {{/if}}
19
19
  healthcheck:
20
20
  test: ["CMD", "curl", "-f", "http://localhost:{{port}}{{healthCheck.path}}"]
@@ -98,6 +98,19 @@ services:
98
98
  restart: "no"
99
99
  {{/if}}
100
100
 
101
+ {{#if requiresStorage}}
102
+ volumes:
103
+ {{#if (eq devId 0)}}
104
+ aifabrix_{{app.key}}_data:
105
+ name: aifabrix_{{app.key}}_data
106
+ driver: local
107
+ {{else}}
108
+ aifabrix_dev{{devId}}_{{app.key}}_data:
109
+ name: aifabrix_dev{{devId}}_{{app.key}}_data
110
+ driver: local
111
+ {{/if}}
112
+ {{/if}}
113
+
101
114
  networks:
102
115
  {{networkName}}:
103
116
  external: true