@oxog/dockcraft 1.2.0 → 1.2.1

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.cjs CHANGED
@@ -1081,9 +1081,47 @@ function nodeHealthcheckScript(port, path) {
1081
1081
  }
1082
1082
 
1083
1083
  // src/generators/dockerfile.ts
1084
+ var SHELL_BUILTINS = /* @__PURE__ */ new Set([
1085
+ ".",
1086
+ ":",
1087
+ "!",
1088
+ "alias",
1089
+ "bg",
1090
+ "break",
1091
+ "case",
1092
+ "cd",
1093
+ "command",
1094
+ "continue",
1095
+ "eval",
1096
+ "exec",
1097
+ "exit",
1098
+ "export",
1099
+ "fg",
1100
+ "for",
1101
+ "if",
1102
+ "jobs",
1103
+ "read",
1104
+ "readonly",
1105
+ "return",
1106
+ "set",
1107
+ "shift",
1108
+ "source",
1109
+ "time",
1110
+ "times",
1111
+ "trap",
1112
+ "ulimit",
1113
+ "umask",
1114
+ "unalias",
1115
+ "unset",
1116
+ "until",
1117
+ "wait",
1118
+ "while"
1119
+ ]);
1084
1120
  function dockerCmd(command) {
1085
1121
  const words = command.trim().split(/\s+/);
1086
- if (words.every((word) => /^[\w@%+=:,./-]+$/.test(word))) {
1122
+ const first = words[0] ?? "";
1123
+ const needsShell = SHELL_BUILTINS.has(first) || /^[A-Za-z_]\w*=/.test(first);
1124
+ if (!needsShell && words.every((word) => /^[\w@%+=:,./-]+$/.test(word))) {
1087
1125
  return `CMD ${JSON.stringify(words).replace(/","/g, '", "')}`;
1088
1126
  }
1089
1127
  return `CMD ${command.trim()}`;
@@ -1530,7 +1568,7 @@ function envValue(value) {
1530
1568
  if (!/['\r\n]/.test(value)) {
1531
1569
  return `'${value}'`;
1532
1570
  }
1533
- const escaped = value.replace(/\\/g, "\\\\").replace(/"/g, '\\"').replace(/\n/g, "\\n").replace(/\r/g, "\\r");
1571
+ const escaped = value.replace(/\\/g, "\\\\").replace(/"/g, '\\"').replace(/\$/g, "\\$").replace(/\n/g, "\\n").replace(/\r/g, "\\r");
1534
1572
  return `"${escaped}"`;
1535
1573
  }
1536
1574
  function generateEnvExample(config) {