@jtl-software/create-cloud-app 0.0.24 → 0.0.25
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.js +22 -25
- package/package.json +2 -1
package/dist/index.js
CHANGED
|
@@ -999,6 +999,22 @@ function buildShortDescription(description) {
|
|
|
999
999
|
if (description.length <= SHORT_DESCRIPTION_MAX_LENGTH) return description;
|
|
1000
1000
|
return description.slice(0, SHORT_DESCRIPTION_MAX_LENGTH - 1).trimEnd() + "\u2026";
|
|
1001
1001
|
}
|
|
1002
|
+
function buildPlaceholders(opts) {
|
|
1003
|
+
return {
|
|
1004
|
+
"{{APP_NAME}}": opts.appName,
|
|
1005
|
+
"{{APP_NAME_PASCAL}}": toPascalCase(opts.appName),
|
|
1006
|
+
"{{APP_TECHNICAL_NAME}}": buildTechnicalName(opts.appName),
|
|
1007
|
+
"{{APP_DESCRIPTION}}": opts.description,
|
|
1008
|
+
"{{APP_DESCRIPTION_SHORT}}": buildShortDescription(opts.description)
|
|
1009
|
+
};
|
|
1010
|
+
}
|
|
1011
|
+
function applyPlaceholders(content, replacements) {
|
|
1012
|
+
let result = content;
|
|
1013
|
+
for (const [key, value] of Object.entries(replacements)) {
|
|
1014
|
+
result = result.replaceAll(key, value);
|
|
1015
|
+
}
|
|
1016
|
+
return result;
|
|
1017
|
+
}
|
|
1002
1018
|
var BINARY_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
1003
1019
|
".png",
|
|
1004
1020
|
".jpg",
|
|
@@ -1022,10 +1038,7 @@ function transformPackageJson(content, appName, templateType, replacements) {
|
|
|
1022
1038
|
for (const field of PACKAGE_JSON_STRIP_FIELDS) {
|
|
1023
1039
|
delete pkg[field];
|
|
1024
1040
|
}
|
|
1025
|
-
|
|
1026
|
-
for (const [key, value] of Object.entries(replacements)) {
|
|
1027
|
-
result = result.replaceAll(key, value);
|
|
1028
|
-
}
|
|
1041
|
+
const result = applyPlaceholders(JSON.stringify(pkg, null, 2), replacements);
|
|
1029
1042
|
return result + "\n";
|
|
1030
1043
|
}
|
|
1031
1044
|
function copyDir(src, dest, replacements, templateType, appName) {
|
|
@@ -1036,9 +1049,7 @@ function copyDir(src, dest, replacements, templateType, appName) {
|
|
|
1036
1049
|
if (destName.startsWith("_git")) {
|
|
1037
1050
|
destName = `.${destName.slice(1)}`;
|
|
1038
1051
|
}
|
|
1039
|
-
|
|
1040
|
-
destName = destName.replaceAll(key, value);
|
|
1041
|
-
}
|
|
1052
|
+
destName = applyPlaceholders(destName, replacements);
|
|
1042
1053
|
const destPath = path2.join(dest, destName);
|
|
1043
1054
|
if (entry.isDirectory()) {
|
|
1044
1055
|
copyDir(srcPath, destPath, replacements);
|
|
@@ -1053,11 +1064,8 @@ function copyDir(src, dest, replacements, templateType, appName) {
|
|
|
1053
1064
|
if (BINARY_EXTENSIONS.has(ext)) {
|
|
1054
1065
|
fs2.copyFileSync(srcPath, destPath);
|
|
1055
1066
|
} else {
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
content = content.replaceAll(key, value);
|
|
1059
|
-
}
|
|
1060
|
-
fs2.writeFileSync(destPath, content);
|
|
1067
|
+
const content = fs2.readFileSync(srcPath, "utf-8");
|
|
1068
|
+
fs2.writeFileSync(destPath, applyPlaceholders(content, replacements));
|
|
1061
1069
|
}
|
|
1062
1070
|
}
|
|
1063
1071
|
}
|
|
@@ -1066,11 +1074,7 @@ function buildReplacements(base, template) {
|
|
|
1066
1074
|
const extra = template.meta.extraReplacements ?? {};
|
|
1067
1075
|
const resolved = {};
|
|
1068
1076
|
for (const [key, value] of Object.entries(extra)) {
|
|
1069
|
-
|
|
1070
|
-
for (const [baseKey, baseValue] of Object.entries(base)) {
|
|
1071
|
-
resolvedValue = resolvedValue.replaceAll(baseKey, baseValue);
|
|
1072
|
-
}
|
|
1073
|
-
resolved[key] = resolvedValue;
|
|
1077
|
+
resolved[key] = applyPlaceholders(value, base);
|
|
1074
1078
|
}
|
|
1075
1079
|
return { ...base, ...resolved };
|
|
1076
1080
|
}
|
|
@@ -1083,14 +1087,7 @@ async function scaffold({
|
|
|
1083
1087
|
targetDir: customTargetDir
|
|
1084
1088
|
}) {
|
|
1085
1089
|
const targetDir = customTargetDir ?? path2.resolve(process.cwd(), appName);
|
|
1086
|
-
const
|
|
1087
|
-
const baseReplacements = {
|
|
1088
|
-
"{{APP_NAME}}": appName,
|
|
1089
|
-
"{{APP_NAME_PASCAL}}": pascalName,
|
|
1090
|
-
"{{APP_TECHNICAL_NAME}}": buildTechnicalName(appName),
|
|
1091
|
-
"{{APP_DESCRIPTION}}": description,
|
|
1092
|
-
"{{APP_DESCRIPTION_SHORT}}": buildShortDescription(description)
|
|
1093
|
-
};
|
|
1090
|
+
const baseReplacements = buildPlaceholders({ appName, description });
|
|
1094
1091
|
if (fs2.existsSync(targetDir)) {
|
|
1095
1092
|
throw new Error(`Directory "${appName}" already exists`);
|
|
1096
1093
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jtl-software/create-cloud-app",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.25",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "CLI tool for scaffolding JTL Platform cloud apps",
|
|
6
6
|
"bin": {
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
"@clack/prompts": "^1.2.0",
|
|
21
21
|
"@jtl-software/cloud-app-template-backend-dotnet": "0.0.12",
|
|
22
22
|
"@jtl-software/cloud-app-template-backend-node": "0.0.14",
|
|
23
|
+
"@jtl-software/cloud-app-template-backend-php": "0.1.0",
|
|
23
24
|
"@jtl-software/cloud-app-template-frontend-react": "0.0.16",
|
|
24
25
|
"@jtl-software/cloud-app-template-shared": "0.0.6",
|
|
25
26
|
"picocolors": "^1.1.1"
|