@oxog/dockcraft 1.2.1 → 1.3.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
@@ -7,6 +7,24 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [1.3.0] - 2026-12-02
11
+
12
+ ### Fixed
13
+
14
+ - **`dockcraft init -p 8080` used `8080` as both the port and the preset.** Any
15
+ single-letter option stood for every long option starting with that letter
16
+ (`-p` for `--port` and `--preset`). Short options are now an explicit list
17
+ (`-n --name`, `-s --services`, `-o --output`, `-f --force`, `-y --yes`,
18
+ `-c --config` / `--check`, `-d --dry-run`, `-r --range`, `-j --json`, `-h`, `-v`,
19
+ shown in each command's `--help`), and a letter that could mean several
20
+ options of the command fails with `Option -p is ambiguous: use --preset or --port.`
21
+
22
+ ### Documentation
23
+
24
+ - `.env.example` is written in the Docker Compose `.env` format; the README now
25
+ says so and explains how the npm `dotenv` package reads its double-quoted values
26
+ differently.
27
+
10
28
  ## [1.2.1] - 2026-12-02
11
29
 
12
30
  ### Fixed
@@ -242,6 +260,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
242
260
 
243
261
  ---
244
262
 
263
+ [1.3.0]: https://github.com/ersinkoc/DockCraft/releases/tag/v1.3.0
245
264
  [1.2.1]: https://github.com/ersinkoc/DockCraft/releases/tag/v1.2.1
246
265
  [1.2.0]: https://github.com/ersinkoc/DockCraft/releases/tag/v1.2.0
247
266
  [1.1.1]: https://github.com/ersinkoc/DockCraft/releases/tag/v1.1.1
package/README.md CHANGED
@@ -438,6 +438,16 @@ It lists the same variables the app container gets: `POSTGRES_URL` (also as
438
438
  plugin services, and the `*_HOST`, `*_PORT`, `*_USER`, `*_PASSWORD` and
439
439
  database variables of each service.
440
440
 
441
+ Values are written in the Docker Compose `.env` format: plain values as-is,
442
+ values with spaces or special characters (`#`, `$`, quotes, ...) in single
443
+ quotes (taken literally), and values that contain a single quote or a line
444
+ break in double quotes with `\\`, `"`, `$`, `\n` and `\r` escaped. Compose
445
+ (`docker compose --env-file`, `env_file:`) reads every value back exactly.
446
+ Other loaders differ only for those double-quoted values: the npm `dotenv`
447
+ package, for example, does not unescape `\\`, `\"` or `\$`, so check such
448
+ values (they only occur when a password or other value contains a `'`) if
449
+ your app loads the file with `dotenv`.
450
+
441
451
  ## License
442
452
 
443
453
  MIT
package/dist/cli/index.js CHANGED
@@ -6,7 +6,7 @@
6
6
  */
7
7
 
8
8
  // src/version.ts
9
- var VERSION = "1.2.1";
9
+ var VERSION = "1.3.0";
10
10
 
11
11
  // src/cli/parser.ts
12
12
  function parseArgs(args) {
@@ -73,17 +73,48 @@ function parseArgs(args) {
73
73
  }
74
74
  return result;
75
75
  }
76
+ var SHORT_ALIASES = {
77
+ help: "h",
78
+ version: "v",
79
+ yes: "y",
80
+ force: "f",
81
+ name: "n",
82
+ services: "s",
83
+ output: "o",
84
+ config: "c",
85
+ "dry-run": "d",
86
+ check: "c",
87
+ range: "r",
88
+ json: "j"
89
+ };
90
+ var COMMAND_OPTIONS = {
91
+ init: ["preset", "name", "port", "services", "output", "force", "yes"],
92
+ generate: ["config", "dry-run", "force", "output"],
93
+ ports: ["check", "range", "json"]
94
+ };
95
+ function ambiguousShortOption(args) {
96
+ const longs = COMMAND_OPTIONS[args.command] ?? [];
97
+ for (const key of [...args.flags, ...args.options.keys()]) {
98
+ if (key.length !== 1 || key === "h" || key === "v") continue;
99
+ if (longs.some((long) => SHORT_ALIASES[long] === key)) continue;
100
+ const candidates = longs.filter((long) => long.startsWith(key));
101
+ if (candidates.length > 1) {
102
+ return `Option -${key} is ambiguous: use ${candidates.map((long) => `--${long}`).join(" or ")}.`;
103
+ }
104
+ }
105
+ return void 0;
106
+ }
76
107
  function hasFlag(args, flag) {
77
108
  if (args.flags.has(flag)) return true;
78
- const firstChar = flag[0];
79
- return firstChar !== void 0 && args.flags.has(firstChar);
109
+ const short = SHORT_ALIASES[flag];
110
+ return short !== void 0 && args.flags.has(short);
80
111
  }
81
112
  function getOption(args, option, defaultValue = "") {
82
113
  const value = args.options.get(option);
83
114
  if (value !== void 0) return value;
84
- const firstChar = option[0];
85
- if (firstChar !== void 0) {
86
- const shortValue = args.options.get(firstChar);
115
+ const short = SHORT_ALIASES[option];
116
+ if (short !== void 0) {
117
+ const shortValue = args.options.get(short);
87
118
  if (shortValue !== void 0) return shortValue;
88
119
  }
89
120
  return defaultValue;
@@ -2484,13 +2515,13 @@ USAGE:
2484
2515
  dockcraft init [options]
2485
2516
 
2486
2517
  OPTIONS:
2487
- --preset <name> Use a preset configuration
2488
- --name <name> Project name
2489
- --port <port> App port
2490
- --services <list> Comma-separated service list
2491
- --output <dir> Directory to write dockcraft.config.mts to
2492
- --force Overwrite an existing config file
2493
- -y, --yes Skip prompts, use defaults (required without a terminal)
2518
+ --preset <name> Use a preset configuration
2519
+ -n, --name <name> Project name
2520
+ --port <port> App port
2521
+ -s, --services <list> Comma-separated service list
2522
+ -o, --output <dir> Directory to write dockcraft.config.mts to
2523
+ -f, --force Overwrite an existing config file
2524
+ -y, --yes Skip prompts, use defaults (required without a terminal)
2494
2525
  `);
2495
2526
  break;
2496
2527
  case "generate":
@@ -2499,10 +2530,10 @@ USAGE:
2499
2530
  dockcraft generate [options]
2500
2531
 
2501
2532
  OPTIONS:
2502
- --config <file> Config file path (default: first of dockcraft.config.{ts,mts,js,mjs,cjs})
2503
- --dry-run Preview without writing
2504
- --force Overwrite existing files
2505
- --output <dir> Output directory
2533
+ -c, --config <file> Config file path (default: first of dockcraft.config.{ts,mts,js,mjs,cjs})
2534
+ -d, --dry-run Preview without writing
2535
+ -f, --force Overwrite existing files
2536
+ -o, --output <dir> Output directory
2506
2537
  `);
2507
2538
  break;
2508
2539
  case "ports":
@@ -2511,9 +2542,9 @@ USAGE:
2511
2542
  dockcraft ports [options]
2512
2543
 
2513
2544
  OPTIONS:
2514
- --check <ports> Check specific ports (comma-separated)
2515
- --range <start-end> Scan port range
2516
- --json Output as JSON
2545
+ -c, --check <ports> Check specific ports (comma-separated)
2546
+ -r, --range <start-end> Scan port range
2547
+ -j, --json Output as JSON
2517
2548
  `);
2518
2549
  break;
2519
2550
  case "presets":
@@ -2563,6 +2594,12 @@ async function main(cliArgs = process.argv.slice(2)) {
2563
2594
  process.exitCode = 1;
2564
2595
  return;
2565
2596
  }
2597
+ const ambiguous = ambiguousShortOption(args);
2598
+ if (ambiguous) {
2599
+ error(ambiguous);
2600
+ process.exitCode = 1;
2601
+ return;
2602
+ }
2566
2603
  try {
2567
2604
  await handler(args);
2568
2605
  } catch (err) {