@oxog/dockcraft 1.1.0 → 1.2.0

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/CHANGELOG.md CHANGED
@@ -5,6 +5,55 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [Unreleased]
9
+
10
+ ## [1.2.0] - 2026-12-02
11
+
12
+ ### Changed
13
+ - `"sideEffects": false` is declared, so bundlers can drop unused exports. Importing
14
+ the library has no side effects (the CLI is a separate `bin` file).
15
+
16
+ ### Internal
17
+ - Tooling: adopted oxog-standard. Lint is ESLint 10 with typescript-eslint
18
+ recommended-type-checked; managed CI (Node 18 to 26) and Trusted Publishing release
19
+ workflow; packed-archive checks with publint and Are The Types Wrong.
20
+
21
+ ## [1.1.1] - 2026-12-01
22
+
23
+ ### Fixed
24
+
25
+ - **`--output ./docker` / `output.dir` produced a compose file that could not
26
+ build.** It said `build: .`, which Compose resolves relative to the compose
27
+ file, so the build context was `./docker` (no `package.json`). When the
28
+ output directory is a subdirectory of the working directory, the app now builds
29
+ from the project root: `build: { context: .., dockerfile: docker/Dockerfile }`.
30
+ Docker only reads `.dockerignore` from the context root, so in that case the
31
+ ignore file is now written as `docker/Dockerfile.dockerignore` (the
32
+ Dockerfile-specific ignore file BuildKit reads) instead of `docker/.dockerignore`,
33
+ and it also keeps the generated files and `docker/.env*` out of the image.
34
+ `dockcraft generate` prints the matching `docker compose -f docker/docker-compose.yml up -d`.
35
+ Output to the working directory (the default) or to a directory outside it is
36
+ unchanged (`build: .`, `.dockerignore`).
37
+ - docker-compose.yml no longer contains `version: "3.9"`, which Docker Compose v2
38
+ reports as obsolete on every command.
39
+ - The app container got `POSTGRES_URL` while `.env.example` documented the same
40
+ value as `DATABASE_URL`. Both files now contain both names (`DATABASE_URL` is an
41
+ alias of `POSTGRES_URL`; nothing was renamed, so existing apps keep working).
42
+ `.env.example` also lists `<SERVICE>_URL` for plugin services, which the app
43
+ container already received. MySQL, MongoDB and Redis variables already matched.
44
+ - `PortConflictError`, `NoPortAvailableError` and `FileWriteError` were exported
45
+ but never thrown. `resolvePort` now rejects with `PortConflictError` (port of a
46
+ `'fixed'` strategy in use) and `NoPortAvailableError` (no free port in the range or
47
+ above the preferred port; the `'auto'` message is now
48
+ `No available port in range <port>-65535`), and failed file writes in
49
+ `dockcraft()` and `dockcraft init` reject with `FileWriteError`, whose message
50
+ includes the file system error and whose `cause` is that error. They still are
51
+ `instanceof Error` (and `DockcraftError`).
52
+ - `dockcraft init` without a terminal (CI, piped or closed stdin) and without
53
+ `-y` stopped at the first prompt and exited with code 0 without writing a
54
+ config. It now exits with code 1 and says to pass `-y`/`--yes` (or to run it in
55
+ a terminal); it still runs when every needed value is given as an option.
56
+
8
57
  ## [1.1.0] - 2026-11-30
9
58
 
10
59
  ### Fixed
@@ -179,5 +228,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
179
228
 
180
229
  ---
181
230
 
231
+ [1.2.0]: https://github.com/ersinkoc/DockCraft/releases/tag/v1.2.0
232
+ [1.1.1]: https://github.com/ersinkoc/DockCraft/releases/tag/v1.1.1
182
233
  [1.1.0]: https://github.com/ersinkoc/DockCraft/releases/tag/v1.1.0
183
234
  [1.0.0]: https://github.com/ersinkoc/DockCraft/releases/tag/v1.0.0
package/README.md CHANGED
@@ -98,6 +98,15 @@ dockcraft presets
98
98
  ```
99
99
 
100
100
  `init` refuses to overwrite an existing config unless `--force` is given.
101
+ Without a terminal (CI, piped stdin) `init` cannot prompt: pass `-y` to use
102
+ the defaults for every value not given as an option, otherwise it exits with
103
+ code 1.
104
+
105
+ `generate --output ./docker` (or `output.dir`) writes the files to a
106
+ subdirectory; the compose file then builds from the project root
107
+ (`build: { context: .., dockerfile: docker/Dockerfile }`) and the ignore file is
108
+ written as `docker/Dockerfile.dockerignore`, which BuildKit reads for that
109
+ Dockerfile. Run it with `docker compose -f docker/docker-compose.yml up -d`.
101
110
  Commands exit with code 1 on errors (invalid config, unknown command or
102
111
  preset, invalid ports). `dockcraft ports --json` prints JSON only.
103
112
 
@@ -169,6 +178,11 @@ const portInRange = await resolvePort({
169
178
  });
170
179
  ```
171
180
 
181
+ `resolvePort` rejects with a `PortConflictError` when a `'fixed'` port is in
182
+ use and with a `NoPortAvailableError` when no port is free; failed writes in
183
+ `dockcraft()` reject with a `FileWriteError` (its `cause` is the file system
184
+ error). All of them extend `DockcraftError` (and `Error`) and have a `code`.
185
+
172
186
  ### Connection Strings
173
187
 
174
188
  ```typescript
@@ -389,7 +403,7 @@ Multi-stage build with:
389
403
 
390
404
  ### docker-compose.yml
391
405
 
392
- Complete setup with:
406
+ Compose Specification file (no obsolete top-level `version`) with:
393
407
  - All services with dependencies
394
408
  - Port mappings
395
409
  - Environment variables
@@ -419,6 +433,11 @@ Environment template with:
419
433
  - Service configurations
420
434
  - Required variables
421
435
 
436
+ It lists the same variables the app container gets: `POSTGRES_URL` (also as
437
+ `DATABASE_URL`), `MYSQL_URL`, `MONGO_URL`, `REDIS_URL`, `<SERVICE>_URL` for
438
+ plugin services, and the `*_HOST`, `*_PORT`, `*_USER`, `*_PASSWORD` and
439
+ database variables of each service.
440
+
422
441
  ## License
423
442
 
424
443
  MIT
package/dist/cli/index.js CHANGED
@@ -6,7 +6,7 @@
6
6
  */
7
7
 
8
8
  // src/version.ts
9
- var VERSION = "1.1.0";
9
+ var VERSION = "1.2.0";
10
10
 
11
11
  // src/cli/parser.ts
12
12
  function parseArgs(args) {
@@ -263,6 +263,63 @@ async function multiselect(question, options) {
263
263
  // src/utils/fs.ts
264
264
  import { promises as fs } from "fs";
265
265
  import { join, dirname, basename, extname, relative } from "path";
266
+
267
+ // src/types.ts
268
+ var DockcraftError = class extends Error {
269
+ constructor(message, code) {
270
+ super(message);
271
+ this.code = code;
272
+ this.name = "DockcraftError";
273
+ }
274
+ };
275
+ var ConfigError = class extends DockcraftError {
276
+ constructor(message, code = "CONFIG_ERROR") {
277
+ super(message, code);
278
+ this.name = "ConfigError";
279
+ }
280
+ };
281
+ var ValidationError = class extends DockcraftError {
282
+ constructor(message, errors, code = "VALIDATION_ERROR") {
283
+ super(message, code);
284
+ this.errors = errors;
285
+ this.name = "ValidationError";
286
+ }
287
+ };
288
+ var PortConflictError = class extends DockcraftError {
289
+ constructor(port, code = "PORT_CONFLICT") {
290
+ super(`Port ${port} is already in use`, code);
291
+ this.name = "PortConflictError";
292
+ }
293
+ };
294
+ var NoPortAvailableError = class extends DockcraftError {
295
+ constructor(range, code = "NO_PORT_AVAILABLE") {
296
+ super(`No available port in range ${range[0]}-${range[1]}`, code);
297
+ this.name = "NoPortAvailableError";
298
+ }
299
+ };
300
+ var FileWriteError = class extends DockcraftError {
301
+ constructor(path, code = "FILE_WRITE_ERROR", cause) {
302
+ super(`Failed to write file: ${path}${cause instanceof Error ? ` (${cause.message})` : ""}`, code);
303
+ this.name = "FileWriteError";
304
+ if (cause !== void 0) {
305
+ this.cause = cause;
306
+ }
307
+ }
308
+ };
309
+ var PresetNotFoundError = class extends DockcraftError {
310
+ constructor(name, code = "PRESET_NOT_FOUND") {
311
+ super(`Preset '${name}' not found`, code);
312
+ this.name = "PresetNotFoundError";
313
+ }
314
+ };
315
+ var ServiceNotFoundError = class extends DockcraftError {
316
+ constructor(name, code = "SERVICE_NOT_FOUND") {
317
+ super(`Service '${name}' not found`, code);
318
+ this.name = "ServiceNotFoundError";
319
+ }
320
+ };
321
+
322
+ // src/utils/fs.ts
266
323
  async function ensureDir(path) {
267
324
  try {
268
325
  await fs.mkdir(path, { recursive: true });
@@ -274,6 +331,13 @@ async function ensureDir(path) {
274
331
  }
275
332
  }
276
333
  async function writeFile(filePath, content, mode) {
334
+ try {
335
+ await writeFileAtomic(filePath, content, mode);
336
+ } catch (error2) {
337
+ throw new FileWriteError(filePath, "FILE_WRITE_ERROR", error2);
338
+ }
339
+ }
340
+ async function writeFileAtomic(filePath, content, mode) {
277
341
  const dir = dirname(filePath);
278
342
  await ensureDir(dir);
279
343
  const suffix = `${process.pid}.${Date.now().toString(36)}.${Math.random().toString(36).slice(2)}`;
@@ -597,15 +661,19 @@ function defaultProjectName(dir) {
597
661
  const name = basename2(dir).replace(/[^a-zA-Z0-9_-]/g, "-").replace(/^[^a-zA-Z]+/, "");
598
662
  return isProjectName(name) ? name : "my-app";
599
663
  }
664
+ function noTerminalMessage(question) {
665
+ return `Cannot ask "${question.replace(/:$/, "")}": stdin is not a terminal. Run "dockcraft init" in a terminal, or pass -y/--yes to use the defaults (and --name, --port, --preset, --services, --output to set values).`;
666
+ }
600
667
  async function init(args) {
601
668
  title("Dockcraft Init");
602
669
  const skipPrompts = getBooleanFlag(args, "yes");
603
670
  const force = getBooleanFlag(args, "force");
604
- const ask = (question, defaultValue) => skipPrompts ? Promise.resolve(defaultValue) : prompt(question, defaultValue);
671
+ const interactive = (question, ask2) => process.stdin.isTTY ? ask2() : Promise.reject(new Error(noTerminalMessage(question)));
672
+ const ask = (question, defaultValue) => skipPrompts ? Promise.resolve(defaultValue) : interactive(question, () => prompt(question, defaultValue));
605
673
  const name = getOption(args, "name") || await ask("Project name", defaultProjectName(process.cwd()));
606
674
  if (!isProjectName(name)) {
607
675
  throw new Error(
608
- `Invalid project name '${name}'. Must start with a letter and contain only letters, numbers, hyphens, and underscores.`
676
+ `Invalid project name '${String(name)}'. Must start with a letter and contain only letters, numbers, hyphens, and underscores.`
609
677
  );
610
678
  }
611
679
  const preset = getOption(args, "preset");
@@ -622,7 +690,7 @@ async function init(args) {
622
690
  info(`Creating config for "${name}"`);
623
691
  let selectedPreset = preset;
624
692
  if (!selectedPreset && !skipPrompts) {
625
- const usePreset = await confirm("Use a preset?");
693
+ const usePreset = await interactive("Use a preset?", () => confirm("Use a preset?"));
626
694
  if (usePreset) {
627
695
  selectedPreset = await select("Select preset:", presets3);
628
696
  }
@@ -631,7 +699,10 @@ async function init(args) {
631
699
  if (getOption(args, "services")) {
632
700
  selectedServices = parseList(args, "services");
633
701
  } else if (!skipPrompts && !selectedPreset) {
634
- selectedServices = await multiselect("Select services:", [...INIT_SERVICES]);
702
+ selectedServices = await interactive(
703
+ "Select services:",
704
+ () => multiselect("Select services:", [...INIT_SERVICES])
705
+ );
635
706
  }
636
707
  const unknown = selectedServices.filter((s) => !INIT_SERVICES.includes(s));
637
708
  if (unknown.length > 0) {
@@ -678,40 +749,6 @@ function generateConfig(name, preset, services2, port) {
678
749
  return content;
679
750
  }
680
751
 
681
- // src/types.ts
682
- var DockcraftError = class extends Error {
683
- constructor(message, code) {
684
- super(message);
685
- this.code = code;
686
- this.name = "DockcraftError";
687
- }
688
- };
689
- var ConfigError = class extends DockcraftError {
690
- constructor(message, code = "CONFIG_ERROR") {
691
- super(message, code);
692
- this.name = "ConfigError";
693
- }
694
- };
695
- var ValidationError = class extends DockcraftError {
696
- constructor(message, errors, code = "VALIDATION_ERROR") {
697
- super(message, code);
698
- this.errors = errors;
699
- this.name = "ValidationError";
700
- }
701
- };
702
- var PresetNotFoundError = class extends DockcraftError {
703
- constructor(name, code = "PRESET_NOT_FOUND") {
704
- super(`Preset '${name}' not found`, code);
705
- this.name = "PresetNotFoundError";
706
- }
707
- };
708
- var ServiceNotFoundError = class extends DockcraftError {
709
- constructor(name, code = "SERVICE_NOT_FOUND") {
710
- super(`Service '${name}' not found`, code);
711
- this.name = "ServiceNotFoundError";
712
- }
713
- };
714
-
715
752
  // src/services/image.ts
716
753
  function variantImage(repository, version, variant) {
717
754
  if (version === "latest") {
@@ -914,7 +951,8 @@ async function resolvePort(options = {}) {
914
951
  if (await isPortAvailable(preferred)) {
915
952
  return preferred;
916
953
  }
917
- throw new Error(`Port ${preferred} is already in use`);
954
+ throw new PortConflictError(preferred);
955
+ // @ts-expect-error -- TS7029: the fall-through to 'auto' (no range given) is intended
918
956
  case "range":
919
957
  if (range) {
920
958
  const [start, end = start + 100] = range;
@@ -922,7 +960,7 @@ async function resolvePort(options = {}) {
922
960
  if (port !== void 0) {
923
961
  return port;
924
962
  }
925
- throw new Error(`No available port in range ${start}-${end}`);
963
+ throw new NoPortAvailableError([start, end]);
926
964
  }
927
965
  // Fall through to auto if no range specified
928
966
  case "auto":
@@ -931,7 +969,7 @@ async function resolvePort(options = {}) {
931
969
  if (port !== void 0) {
932
970
  return port;
933
971
  }
934
- throw new Error(`No available port found starting from ${preferred}`);
972
+ throw new NoPortAvailableError([preferred, 65535]);
935
973
  }
936
974
  }
937
975
  }
@@ -1287,8 +1325,8 @@ function validateServiceConfig(name, config) {
1287
1325
  if (!isComposeServiceName(name)) {
1288
1326
  errors.push({
1289
1327
  code: "INVALID_SERVICE_NAME",
1290
- message: `Invalid service name '${name}'. Must start with a letter or digit and contain only letters, digits, '.', '_' and '-'.`,
1291
- path: `services.${name}`,
1328
+ message: `Invalid service name '${String(name)}'. Must start with a letter or digit and contain only letters, digits, '.', '_' and '-'.`,
1329
+ path: `services.${String(name)}`,
1292
1330
  value: name
1293
1331
  });
1294
1332
  }
@@ -1305,6 +1343,7 @@ function validateServiceConfig(name, config) {
1305
1343
  if (svc.version !== void 0 && !isVersion(svc.version)) {
1306
1344
  errors.push({
1307
1345
  code: "INVALID_VERSION",
1346
+ // eslint-disable-next-line @typescript-eslint/no-base-to-string -- echoes whatever invalid value was given
1308
1347
  message: `Invalid version '${String(svc.version)}' for service '${name}'. Must be a valid Docker image tag.`,
1309
1348
  path: `services.${name}.version`,
1310
1349
  value: svc.version
@@ -1313,6 +1352,7 @@ function validateServiceConfig(name, config) {
1313
1352
  if (svc.image !== void 0 && !isDockerImage(svc.image)) {
1314
1353
  errors.push({
1315
1354
  code: "INVALID_IMAGE",
1355
+ // eslint-disable-next-line @typescript-eslint/no-base-to-string -- echoes whatever invalid value was given
1316
1356
  message: `Invalid image '${String(svc.image)}' for service '${name}'. Must be a Docker image reference such as 'elasticsearch:8.11.0'.`,
1317
1357
  path: `services.${name}.image`,
1318
1358
  value: svc.image
@@ -1625,14 +1665,41 @@ function yamlScalar(str) {
1625
1665
  return JSON.stringify(str);
1626
1666
  }
1627
1667
 
1668
+ // src/generators/paths.ts
1669
+ import { isAbsolute as isAbsolute2, join as join3, relative as relative2 } from "path";
1670
+ function currentDir() {
1671
+ return typeof process !== "undefined" && typeof process.cwd === "function" ? process.cwd() : "/";
1672
+ }
1673
+ function outputSubdir(dir) {
1674
+ if (!dir) {
1675
+ return void 0;
1676
+ }
1677
+ const root = currentDir();
1678
+ const subdir = relative2(root, isAbsolute2(dir) ? dir : join3(root, dir)).replace(/\\/g, "/");
1679
+ if (subdir === "" || subdir === ".." || subdir.startsWith("../") || isAbsolute2(subdir)) {
1680
+ return void 0;
1681
+ }
1682
+ return subdir;
1683
+ }
1684
+ function pathToRoot(subdir) {
1685
+ return subdir.split("/").map(() => "..").join("/");
1686
+ }
1687
+
1628
1688
  // src/generators/compose.ts
1629
1689
  function composeLiteral(value) {
1630
1690
  return value.replace(/\$/g, "$$$$");
1631
1691
  }
1692
+ function composeBuild(outputDir) {
1693
+ const subdir = outputSubdir(outputDir);
1694
+ if (subdir === void 0) {
1695
+ return ".";
1696
+ }
1697
+ return { context: pathToRoot(subdir), dockerfile: `${subdir}/Dockerfile` };
1698
+ }
1632
1699
  function generateCompose(config, _context) {
1633
1700
  const { app, services: services2 } = config;
1634
1701
  const appService = {
1635
- build: ".",
1702
+ build: composeBuild(config.output.dir),
1636
1703
  ports: [`${app.port}:${app.port}`],
1637
1704
  environment: generateAppEnvironment(config),
1638
1705
  depends_on: Object.keys(services2),
@@ -1651,13 +1718,20 @@ function generateCompose(config, _context) {
1651
1718
  composeServices[serviceName] = generateServiceConfig(serviceConfig);
1652
1719
  }
1653
1720
  const compose = {
1654
- version: "3.9",
1655
1721
  services: composeServices,
1656
1722
  volumes: generateVolumeDefinitions(config)
1657
1723
  };
1658
1724
  return `${toYaml(compose)}
1659
1725
  `;
1660
1726
  }
1727
+ function connectionStringVar(serviceName) {
1728
+ return `${serviceName.toUpperCase().replace(/[^A-Z0-9_]/g, "_")}_URL`;
1729
+ }
1730
+ function hasDatabaseUrlAlias(config) {
1731
+ return config.services.postgres !== void 0 && !Object.entries(config.services).some(
1732
+ ([name, service]) => Boolean(service.connectionString) && connectionStringVar(name) === "DATABASE_URL"
1733
+ );
1734
+ }
1661
1735
  function generateAppEnvironment(config) {
1662
1736
  const env = ["NODE_ENV=production", `PORT=${config.app.port}`];
1663
1737
  const add = (key, value) => {
@@ -1665,12 +1739,14 @@ function generateAppEnvironment(config) {
1665
1739
  };
1666
1740
  for (const [serviceName, serviceConfig] of Object.entries(config.services)) {
1667
1741
  if (serviceConfig.connectionString) {
1668
- const key = `${serviceName.toUpperCase().replace(/[^A-Z0-9_]/g, "_")}_URL`;
1669
- add(key, serviceConfig.connectionString);
1742
+ add(connectionStringVar(serviceName), serviceConfig.connectionString);
1670
1743
  }
1671
1744
  }
1672
1745
  if (config.services.postgres) {
1673
1746
  const pg = config.services.postgres;
1747
+ if (pg.connectionString && hasDatabaseUrlAlias(config)) {
1748
+ add("DATABASE_URL", pg.connectionString);
1749
+ }
1674
1750
  add("POSTGRES_HOST", pg.name);
1675
1751
  add("POSTGRES_PORT", pg.port);
1676
1752
  add("POSTGRES_USER", pg.env.POSTGRES_USER || "postgres");
@@ -1754,7 +1830,19 @@ function generateVolumeDefinitions(config) {
1754
1830
  }
1755
1831
 
1756
1832
  // src/generators/dockerignore.ts
1757
- function generateDockerignore(_config) {
1833
+ var DOCKERFILE_IGNORE_FILE = "Dockerfile.dockerignore";
1834
+ function dockerignoreFileName(outputDir) {
1835
+ return outputSubdir(outputDir) === void 0 ? ".dockerignore" : DOCKERFILE_IGNORE_FILE;
1836
+ }
1837
+ function outputDirPatterns(outputDir) {
1838
+ const subdir = outputSubdir(outputDir);
1839
+ if (subdir === void 0) {
1840
+ return "";
1841
+ }
1842
+ return ["Dockerfile", "docker-compose.yml", DOCKERFILE_IGNORE_FILE, ".env", ".env.*"].map((file) => `${subdir}/${file}
1843
+ `).join("");
1844
+ }
1845
+ function generateDockerignore(config) {
1758
1846
  return `# Dependencies
1759
1847
  node_modules/
1760
1848
  npm-debug.log*
@@ -1816,7 +1904,7 @@ temp/
1816
1904
  Dockerfile
1817
1905
  docker-compose.yml
1818
1906
  .dockerignore
1819
-
1907
+ ${outputDirPatterns(config.output.dir)}
1820
1908
  # Package manager lockfiles (optional - uncomment if you want to exclude)
1821
1909
  # package-lock.json
1822
1910
  # yarn.lock
@@ -1825,6 +1913,7 @@ docker-compose.yml
1825
1913
  }
1826
1914
 
1827
1915
  // src/generators/env.ts
1916
+ var BUILT_IN_SERVICES = /* @__PURE__ */ new Set(["postgres", "mysql", "mongo", "redis"]);
1828
1917
  function envValue(value) {
1829
1918
  if (/^[\w@%+=:,./?&-]*$/.test(value)) {
1830
1919
  return value;
@@ -1854,7 +1943,11 @@ PORT=${config.app.port}
1854
1943
  content += `
1855
1944
  # PostgreSQL
1856
1945
  `;
1857
- content += `DATABASE_URL=${envValue(String(pg.connectionString || ""))}
1946
+ if (hasDatabaseUrlAlias(config)) {
1947
+ content += `DATABASE_URL=${envValue(String(pg.connectionString || ""))}
1948
+ `;
1949
+ }
1950
+ content += `POSTGRES_URL=${envValue(String(pg.connectionString || ""))}
1858
1951
  `;
1859
1952
  content += `POSTGRES_HOST=${envValue(String(pg.name))}
1860
1953
  `;
@@ -1916,6 +2009,15 @@ PORT=${config.app.port}
1916
2009
  `;
1917
2010
  if (redis.env.REDIS_PASSWORD) {
1918
2011
  content += `REDIS_PASSWORD=${envValue(String(redis.env.REDIS_PASSWORD))}
2012
+ `;
2013
+ }
2014
+ }
2015
+ for (const [serviceName, service] of Object.entries(config.services)) {
2016
+ if (!BUILT_IN_SERVICES.has(serviceName) && service.connectionString) {
2017
+ content += `
2018
+ # ${serviceName}
2019
+ `;
2020
+ content += `${connectionStringVar(serviceName)}=${envValue(service.connectionString)}
1919
2021
  `;
1920
2022
  }
1921
2023
  }
@@ -2069,7 +2171,8 @@ function generateAll(config, context) {
2069
2171
  } else {
2070
2172
  const generator = GENERATORS[fileType];
2071
2173
  if (generator) {
2072
- result[generator.file] = generator.generate(config, context);
2174
+ const file = fileType === "dockerignore" ? dockerignoreFileName(config.output.dir) : generator.file;
2175
+ result[file] = generator.generate(config, context);
2073
2176
  }
2074
2177
  }
2075
2178
  }
@@ -2077,7 +2180,7 @@ function generateAll(config, context) {
2077
2180
  }
2078
2181
 
2079
2182
  // src/core/dockcraft.ts
2080
- import { isAbsolute as isAbsolute2, join as join3, normalize } from "path";
2183
+ import { isAbsolute as isAbsolute3, join as join4, normalize } from "path";
2081
2184
  function validationError(prefix, errors) {
2082
2185
  const errorMessages = errors.map((e) => ` - ${e.message}`).join("\n");
2083
2186
  return new ValidationError(`${prefix}:
@@ -2085,7 +2188,7 @@ ${errorMessages}`, errors);
2085
2188
  }
2086
2189
  function isSafeOutputPath(fileName) {
2087
2190
  if (typeof fileName !== "string" || fileName === "" || fileName.includes("\0")) return false;
2088
- if (isAbsolute2(fileName) || /^[a-zA-Z]:/.test(fileName) || fileName.startsWith("\\")) return false;
2191
+ if (isAbsolute3(fileName) || /^[a-zA-Z]:/.test(fileName) || fileName.startsWith("\\")) return false;
2089
2192
  const normalized = normalize(fileName.replace(/\\/g, "/"));
2090
2193
  return !normalized.split(/[\\/]/).includes("..") && normalized !== ".";
2091
2194
  }
@@ -2131,7 +2234,7 @@ async function dockcraft(config, options = {}) {
2131
2234
  const outputDir = resolved.output.dir ?? "./";
2132
2235
  if (!options.dryRun) {
2133
2236
  for (const [fileName, content] of Object.entries(generated)) {
2134
- const filePath = join3(outputDir, fileName);
2237
+ const filePath = join4(outputDir, fileName);
2135
2238
  const exists = await fileExists(filePath);
2136
2239
  if (exists && !resolved.output.overwrite) {
2137
2240
  continue;
@@ -2186,7 +2289,9 @@ async function generate(args) {
2186
2289
  info(`Skipped ${skipped} existing file(s); use --force to overwrite them.`);
2187
2290
  }
2188
2291
  console.log("");
2189
- success('Done! Run "docker compose up -d" to start services');
2292
+ const subdir = outputSubdir(result.config.output.dir);
2293
+ const composeFile = subdir === void 0 ? "" : ` -f ${subdir}/docker-compose.yml`;
2294
+ success(`Done! Run "docker compose${composeFile} up -d" to start services`);
2190
2295
  }
2191
2296
 
2192
2297
  // src/ports/defaults.ts
@@ -2347,7 +2452,7 @@ OPTIONS:
2347
2452
  --services <list> Comma-separated service list
2348
2453
  --output <dir> Directory to write dockcraft.config.mts to
2349
2454
  --force Overwrite an existing config file
2350
- -y, --yes Skip prompts, use defaults
2455
+ -y, --yes Skip prompts, use defaults (required without a terminal)
2351
2456
  `);
2352
2457
  break;
2353
2458
  case "generate":