@better-fullstack/template-generator 1.6.0 → 1.6.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/browser.d.mts +3 -0
- package/dist/browser.mjs +3 -0
- package/dist/core/template-reader.mjs +1 -1
- package/dist/fs-writer.d.mts +1 -1
- package/dist/fs-writer.d.mts.map +1 -1
- package/dist/fs-writer.mjs +12 -1
- package/dist/fs-writer.mjs.map +1 -1
- package/dist/index.d.mts +177 -240
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +1 -77533
- package/dist/index.mjs.map +1 -1
- package/dist/preflight-validation-CrqUbe6T.mjs +80533 -0
- package/dist/preflight-validation-CrqUbe6T.mjs.map +1 -0
- package/dist/preflight-validation-N9ifOLE9.d.mts +70 -0
- package/dist/preflight-validation-N9ifOLE9.d.mts.map +1 -0
- package/dist/{template-reader-Bjn8sWYU.mjs → template-reader-D1uxgWOQ.mjs} +382 -180
- package/dist/template-reader-D1uxgWOQ.mjs.map +1 -0
- package/dist/{types-Dkk8hmmP.d.mts → types-Jq14WnvH.d.mts} +1 -1
- package/dist/{types-Dkk8hmmP.d.mts.map → types-Jq14WnvH.d.mts.map} +1 -1
- package/package.json +10 -3
- package/templates-binary/java-base/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/dist/template-reader-Bjn8sWYU.mjs.map +0 -1
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { a as VirtualFileTree, i as VirtualFile, n as GeneratorResult, o as VirtualNode, r as VirtualDirectory, t as GeneratorOptions } from "./types-Jq14WnvH.mjs";
|
|
2
|
+
import { a as TEMPLATE_COUNT, c as TemplateData, i as EMBEDDED_TEMPLATES, n as PreflightWarning, o as generateVirtualProject, r as validatePreflightConfig, t as PreflightResult } from "./preflight-validation-N9ifOLE9.mjs";
|
|
3
|
+
export { EMBEDDED_TEMPLATES, GeneratorOptions, GeneratorResult, type PreflightResult, type PreflightWarning, TEMPLATE_COUNT, type TemplateData, VirtualDirectory, VirtualFile, VirtualFileTree, VirtualNode, generateVirtualProject, validatePreflightConfig };
|
package/dist/browser.mjs
ADDED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { a as loadTemplates, i as loadTemplate, n as getTemplatesRoot, o as isBinaryPath, r as listTemplates, t as getBinaryTemplatesRoot } from "../template-reader-
|
|
1
|
+
import { a as loadTemplates, i as loadTemplate, n as getTemplatesRoot, o as isBinaryPath, r as listTemplates, t as getBinaryTemplatesRoot } from "../template-reader-D1uxgWOQ.mjs";
|
|
2
2
|
|
|
3
3
|
export { getTemplatesRoot as TEMPLATES_ROOT, getTemplatesRoot, getBinaryTemplatesRoot, isBinaryPath, listTemplates, loadTemplate, loadTemplates };
|
package/dist/fs-writer.d.mts
CHANGED
package/dist/fs-writer.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fs-writer.d.mts","names":[],"sources":["../src/fs-writer.ts"],"sourcesContent":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"fs-writer.d.mts","names":[],"sources":["../src/fs-writer.ts"],"sourcesContent":[],"mappings":";;;iBAUsB,qBAAA,OAA4B,mCAAmC;iBA4B/D,kBAAA,OACd,0EAGL"}
|
package/dist/fs-writer.mjs
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { t as getBinaryTemplatesRoot } from "./template-reader-
|
|
1
|
+
import { t as getBinaryTemplatesRoot } from "./template-reader-D1uxgWOQ.mjs";
|
|
2
2
|
import { dirname, join } from "pathe";
|
|
3
3
|
import * as fs from "node:fs/promises";
|
|
4
4
|
|
|
5
5
|
//#region src/fs-writer.ts
|
|
6
6
|
const BINARY_FILE_MARKER = "[Binary file]";
|
|
7
|
+
const EXECUTABLE_FILE_NAMES = new Set(["mvnw", "gradlew"]);
|
|
7
8
|
async function writeTreeToFilesystem(tree, destDir) {
|
|
8
9
|
for (const child of tree.root.children) await writeNode(child, destDir, "");
|
|
9
10
|
}
|
|
@@ -15,6 +16,7 @@ async function writeNode(node, baseDir, relativePath) {
|
|
|
15
16
|
await fs.mkdir(dirname(fullPath), { recursive: true });
|
|
16
17
|
if (fileNode.content === BINARY_FILE_MARKER && fileNode.sourcePath) await copyBinaryFile(fileNode.sourcePath, fullPath);
|
|
17
18
|
else if (fileNode.content !== BINARY_FILE_MARKER) await fs.writeFile(fullPath, fileNode.content, "utf-8");
|
|
19
|
+
await maybeMakeExecutable(fullPath, node.name);
|
|
18
20
|
} else {
|
|
19
21
|
await fs.mkdir(fullPath, { recursive: true });
|
|
20
22
|
for (const child of node.children) await writeNode(child, baseDir, nodePath);
|
|
@@ -33,6 +35,7 @@ async function writeSelectedNode(node, baseDir, relativePath, filter, writtenFil
|
|
|
33
35
|
await fs.mkdir(dirname(join(baseDir, nodePath)), { recursive: true });
|
|
34
36
|
if (fileNode.content === BINARY_FILE_MARKER && fileNode.sourcePath) await copyBinaryFile(fileNode.sourcePath, join(baseDir, nodePath));
|
|
35
37
|
else if (fileNode.content !== BINARY_FILE_MARKER) await fs.writeFile(join(baseDir, nodePath), fileNode.content, "utf-8");
|
|
38
|
+
await maybeMakeExecutable(join(baseDir, nodePath), node.name);
|
|
36
39
|
writtenFiles.push(nodePath);
|
|
37
40
|
}
|
|
38
41
|
} else for (const child of node.children) await writeSelectedNode(child, baseDir, nodePath, filter, writtenFiles);
|
|
@@ -45,6 +48,14 @@ async function copyBinaryFile(templatePath, destPath) {
|
|
|
45
48
|
console.warn(`Failed to copy binary file: ${templatePath}`, error);
|
|
46
49
|
}
|
|
47
50
|
}
|
|
51
|
+
async function maybeMakeExecutable(fullPath, fileName) {
|
|
52
|
+
if (!EXECUTABLE_FILE_NAMES.has(fileName)) return;
|
|
53
|
+
try {
|
|
54
|
+
await fs.chmod(fullPath, 493);
|
|
55
|
+
} catch (error) {
|
|
56
|
+
console.warn(`Failed to mark file as executable: ${fullPath}`, error);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
48
59
|
|
|
49
60
|
//#endregion
|
|
50
61
|
export { writeSelectedFiles, writeTreeToFilesystem };
|
package/dist/fs-writer.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fs-writer.mjs","names":["writtenFiles: string[]"],"sources":["../src/fs-writer.ts"],"sourcesContent":["import * as fs from \"node:fs/promises\";\nimport { join, dirname } from \"pathe\";\n\nimport type { VirtualFileTree, VirtualNode, VirtualFile, VirtualDirectory } from \"./types\";\n\nimport { getBinaryTemplatesRoot } from \"./core/template-reader\";\n\nconst BINARY_FILE_MARKER = \"[Binary file]\";\n\nexport async function writeTreeToFilesystem(tree: VirtualFileTree, destDir: string): Promise<void> {\n for (const child of tree.root.children) {\n await writeNode(child, destDir, \"\");\n }\n}\n\nasync function writeNode(node: VirtualNode, baseDir: string, relativePath: string): Promise<void> {\n const fullPath = join(baseDir, relativePath, node.name);\n const nodePath = relativePath ? join(relativePath, node.name) : node.name;\n\n if (node.type === \"file\") {\n const fileNode = node as VirtualFile;\n await fs.mkdir(dirname(fullPath), { recursive: true });\n\n if (fileNode.content === BINARY_FILE_MARKER && fileNode.sourcePath) {\n await copyBinaryFile(fileNode.sourcePath, fullPath);\n } else if (fileNode.content !== BINARY_FILE_MARKER) {\n await fs.writeFile(fullPath, fileNode.content, \"utf-8\");\n }\n } else {\n await fs.mkdir(fullPath, { recursive: true });\n for (const child of (node as VirtualDirectory).children) {\n await writeNode(child, baseDir, nodePath);\n }\n }\n}\n\nexport async function writeSelectedFiles(\n tree: VirtualFileTree,\n destDir: string,\n filter: (filePath: string) => boolean,\n): Promise<string[]> {\n const writtenFiles: string[] = [];\n await writeSelectedNode(tree.root, destDir, \"\", filter, writtenFiles);\n return writtenFiles;\n}\n\nasync function writeSelectedNode(\n node: VirtualNode,\n baseDir: string,\n relativePath: string,\n filter: (filePath: string) => boolean,\n writtenFiles: string[],\n): Promise<void> {\n const nodePath = relativePath ? `${relativePath}/${node.name}` : node.name;\n\n if (node.type === \"file\") {\n if (filter(nodePath)) {\n const fileNode = node as VirtualFile;\n await fs.mkdir(dirname(join(baseDir, nodePath)), { recursive: true });\n\n if (fileNode.content === BINARY_FILE_MARKER && fileNode.sourcePath) {\n await copyBinaryFile(fileNode.sourcePath, join(baseDir, nodePath));\n } else if (fileNode.content !== BINARY_FILE_MARKER) {\n await fs.writeFile(join(baseDir, nodePath), fileNode.content, \"utf-8\");\n }\n writtenFiles.push(nodePath);\n }\n } else {\n for (const child of (node as VirtualDirectory).children) {\n await writeSelectedNode(child, baseDir, nodePath, filter, writtenFiles);\n }\n }\n}\n\nasync function copyBinaryFile(templatePath: string, destPath: string): Promise<void> {\n const templatesRoot = getBinaryTemplatesRoot();\n const sourcePath = join(templatesRoot, templatePath);\n\n try {\n await fs.copyFile(sourcePath, destPath);\n } catch (error) {\n console.warn(`Failed to copy binary file: ${templatePath}`, error);\n }\n}\n"],"mappings":";;;;;AAOA,MAAM,qBAAqB;
|
|
1
|
+
{"version":3,"file":"fs-writer.mjs","names":["writtenFiles: string[]"],"sources":["../src/fs-writer.ts"],"sourcesContent":["import * as fs from \"node:fs/promises\";\nimport { join, dirname } from \"pathe\";\n\nimport type { VirtualFileTree, VirtualNode, VirtualFile, VirtualDirectory } from \"./types\";\n\nimport { getBinaryTemplatesRoot } from \"./core/template-reader\";\n\nconst BINARY_FILE_MARKER = \"[Binary file]\";\nconst EXECUTABLE_FILE_NAMES = new Set([\"mvnw\", \"gradlew\"]);\n\nexport async function writeTreeToFilesystem(tree: VirtualFileTree, destDir: string): Promise<void> {\n for (const child of tree.root.children) {\n await writeNode(child, destDir, \"\");\n }\n}\n\nasync function writeNode(node: VirtualNode, baseDir: string, relativePath: string): Promise<void> {\n const fullPath = join(baseDir, relativePath, node.name);\n const nodePath = relativePath ? join(relativePath, node.name) : node.name;\n\n if (node.type === \"file\") {\n const fileNode = node as VirtualFile;\n await fs.mkdir(dirname(fullPath), { recursive: true });\n\n if (fileNode.content === BINARY_FILE_MARKER && fileNode.sourcePath) {\n await copyBinaryFile(fileNode.sourcePath, fullPath);\n } else if (fileNode.content !== BINARY_FILE_MARKER) {\n await fs.writeFile(fullPath, fileNode.content, \"utf-8\");\n }\n await maybeMakeExecutable(fullPath, node.name);\n } else {\n await fs.mkdir(fullPath, { recursive: true });\n for (const child of (node as VirtualDirectory).children) {\n await writeNode(child, baseDir, nodePath);\n }\n }\n}\n\nexport async function writeSelectedFiles(\n tree: VirtualFileTree,\n destDir: string,\n filter: (filePath: string) => boolean,\n): Promise<string[]> {\n const writtenFiles: string[] = [];\n await writeSelectedNode(tree.root, destDir, \"\", filter, writtenFiles);\n return writtenFiles;\n}\n\nasync function writeSelectedNode(\n node: VirtualNode,\n baseDir: string,\n relativePath: string,\n filter: (filePath: string) => boolean,\n writtenFiles: string[],\n): Promise<void> {\n const nodePath = relativePath ? `${relativePath}/${node.name}` : node.name;\n\n if (node.type === \"file\") {\n if (filter(nodePath)) {\n const fileNode = node as VirtualFile;\n await fs.mkdir(dirname(join(baseDir, nodePath)), { recursive: true });\n\n if (fileNode.content === BINARY_FILE_MARKER && fileNode.sourcePath) {\n await copyBinaryFile(fileNode.sourcePath, join(baseDir, nodePath));\n } else if (fileNode.content !== BINARY_FILE_MARKER) {\n await fs.writeFile(join(baseDir, nodePath), fileNode.content, \"utf-8\");\n }\n await maybeMakeExecutable(join(baseDir, nodePath), node.name);\n writtenFiles.push(nodePath);\n }\n } else {\n for (const child of (node as VirtualDirectory).children) {\n await writeSelectedNode(child, baseDir, nodePath, filter, writtenFiles);\n }\n }\n}\n\nasync function copyBinaryFile(templatePath: string, destPath: string): Promise<void> {\n const templatesRoot = getBinaryTemplatesRoot();\n const sourcePath = join(templatesRoot, templatePath);\n\n try {\n await fs.copyFile(sourcePath, destPath);\n } catch (error) {\n console.warn(`Failed to copy binary file: ${templatePath}`, error);\n }\n}\n\nasync function maybeMakeExecutable(fullPath: string, fileName: string): Promise<void> {\n if (!EXECUTABLE_FILE_NAMES.has(fileName)) return;\n\n try {\n await fs.chmod(fullPath, 0o755);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