Skip to content

Commit 2433c2e

Browse files
committed
AINATIVEM-45 fix appComposeService YAML indentation — split dedent blocks, indent explicitly
1 parent 30ccf70 commit 2433c2e

1 file changed

Lines changed: 32 additions & 14 deletions

File tree

src/generators/node/database.ts

Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -306,9 +306,8 @@ function dockerComposeContent(options: GeneratorOptions): string {
306306

307307
function appComposeService(options: GeneratorOptions, hasDatabaseService: boolean): string {
308308
const databaseUrlOverride = composeDatabaseUrlOverride(options);
309-
const dependsOn = hasDatabaseService ? '\n' + indent('depends_on:\n db:\n condition: service_healthy', 2) : '';
310309

311-
return dedent`
310+
const main = dedent`
312311
app:
313312
build:
314313
context: .
@@ -324,19 +323,38 @@ function appComposeService(options: GeneratorOptions, hasDatabaseService: boolea
324323
- '3000:3000'
325324
volumes:
326325
- ./package.json:/app/package.json:ro
327-
- app_node_modules:/app/node_modules${dependsOn}
328-
develop:
329-
watch:
330-
- action: sync
331-
path: ./src
332-
target: /app/src
333-
initial_sync: true
334-
- action: sync+restart
335-
path: ./tsconfig.json
336-
target: /app/tsconfig.json
337-
- action: rebuild
338-
path: ./package.json
326+
- app_node_modules:/app/node_modules
339327
`;
328+
329+
const dependsOn = hasDatabaseService
330+
? indent(
331+
dedent`
332+
depends_on:
333+
db:
334+
condition: service_healthy
335+
`,
336+
2,
337+
)
338+
: null;
339+
340+
const develop = indent(
341+
dedent`
342+
develop:
343+
watch:
344+
- action: sync
345+
path: ./src
346+
target: /app/src
347+
initial_sync: true
348+
- action: sync+restart
349+
path: ./tsconfig.json
350+
target: /app/tsconfig.json
351+
- action: rebuild
352+
path: ./package.json
353+
`,
354+
2,
355+
);
356+
357+
return [main, ...(dependsOn ? [dependsOn] : []), develop].join('\n');
340358
}
341359

342360
function composeDatabaseUrlOverride(options: GeneratorOptions): string {

0 commit comments

Comments
 (0)