@oxog/dockcraft 1.1.1 → 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/CHANGELOG.md +29 -0
- package/dist/cli/index.js +47 -6
- package/dist/cli/index.js.map +1 -1
- package/dist/index.cjs +45 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +45 -4
- package/dist/index.js.map +1 -1
- package/package.json +11 -7
package/dist/index.cjs
CHANGED
|
@@ -549,6 +549,7 @@ async function resolvePort(options = {}) {
|
|
|
549
549
|
return preferred;
|
|
550
550
|
}
|
|
551
551
|
throw new PortConflictError(preferred);
|
|
552
|
+
// @ts-expect-error -- TS7029: the fall-through to 'auto' (no range given) is intended
|
|
552
553
|
case "range":
|
|
553
554
|
if (range) {
|
|
554
555
|
const [start, end = start + 100] = range;
|
|
@@ -933,8 +934,8 @@ function validateServiceConfig(name, config) {
|
|
|
933
934
|
if (!isComposeServiceName(name)) {
|
|
934
935
|
errors.push({
|
|
935
936
|
code: "INVALID_SERVICE_NAME",
|
|
936
|
-
message: `Invalid service name '${name}'. Must start with a letter or digit and contain only letters, digits, '.', '_' and '-'.`,
|
|
937
|
-
path: `services.${name}`,
|
|
937
|
+
message: `Invalid service name '${String(name)}'. Must start with a letter or digit and contain only letters, digits, '.', '_' and '-'.`,
|
|
938
|
+
path: `services.${String(name)}`,
|
|
938
939
|
value: name
|
|
939
940
|
});
|
|
940
941
|
}
|
|
@@ -951,6 +952,7 @@ function validateServiceConfig(name, config) {
|
|
|
951
952
|
if (svc.version !== void 0 && !isVersion(svc.version)) {
|
|
952
953
|
errors.push({
|
|
953
954
|
code: "INVALID_VERSION",
|
|
955
|
+
// eslint-disable-next-line @typescript-eslint/no-base-to-string -- echoes whatever invalid value was given
|
|
954
956
|
message: `Invalid version '${String(svc.version)}' for service '${name}'. Must be a valid Docker image tag.`,
|
|
955
957
|
path: `services.${name}.version`,
|
|
956
958
|
value: svc.version
|
|
@@ -959,6 +961,7 @@ function validateServiceConfig(name, config) {
|
|
|
959
961
|
if (svc.image !== void 0 && !isDockerImage(svc.image)) {
|
|
960
962
|
errors.push({
|
|
961
963
|
code: "INVALID_IMAGE",
|
|
964
|
+
// eslint-disable-next-line @typescript-eslint/no-base-to-string -- echoes whatever invalid value was given
|
|
962
965
|
message: `Invalid image '${String(svc.image)}' for service '${name}'. Must be a Docker image reference such as 'elasticsearch:8.11.0'.`,
|
|
963
966
|
path: `services.${name}.image`,
|
|
964
967
|
value: svc.image
|
|
@@ -1078,9 +1081,47 @@ function nodeHealthcheckScript(port, path) {
|
|
|
1078
1081
|
}
|
|
1079
1082
|
|
|
1080
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
|
+
]);
|
|
1081
1120
|
function dockerCmd(command) {
|
|
1082
1121
|
const words = command.trim().split(/\s+/);
|
|
1083
|
-
|
|
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))) {
|
|
1084
1125
|
return `CMD ${JSON.stringify(words).replace(/","/g, '", "')}`;
|
|
1085
1126
|
}
|
|
1086
1127
|
return `CMD ${command.trim()}`;
|
|
@@ -1527,7 +1568,7 @@ function envValue(value) {
|
|
|
1527
1568
|
if (!/['\r\n]/.test(value)) {
|
|
1528
1569
|
return `'${value}'`;
|
|
1529
1570
|
}
|
|
1530
|
-
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");
|
|
1531
1572
|
return `"${escaped}"`;
|
|
1532
1573
|
}
|
|
1533
1574
|
function generateEnvExample(config) {
|