@agiflowai/scaffold-mcp 0.3.0 → 0.3.2
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/ScaffoldConfigLoader-BhrrsLya.js +3 -0
- package/dist/{ScaffoldConfigLoader-CI0T6zdG.js → ScaffoldConfigLoader-CvIJEFcI.js} +34 -25
- package/dist/ScaffoldService-CEJt8Yw4.js +4 -0
- package/dist/{ScaffoldService-CnJ1nj1v.js → ScaffoldService-N6X24Vw0.js} +70 -59
- package/dist/{TemplateService-CnxvhRVW.js → TemplateService-Em2i9bb7.js} +27 -5
- package/dist/TemplateService-Z2SW_58N.js +4 -0
- package/dist/{VariableReplacementService-Bq0GDhTo.js → VariableReplacementService-BGmF2DVE.js} +15 -7
- package/dist/VariableReplacementService-BLwdHUSz.js +4 -0
- package/dist/chunk-nOFOJqeH.js +30 -0
- package/dist/index.js +535 -439
- package/dist/logger-Dno88AK9.js +32 -0
- package/package.json +5 -4
- package/dist/ScaffoldConfigLoader-DhthV6xq.js +0 -3
- package/dist/ScaffoldService-CDhYAUrp.js +0 -3
- package/dist/TemplateService-PmTU3_On.js +0 -3
- package/dist/VariableReplacementService-CrxFJrqU.js +0 -3
|
@@ -1,42 +1,46 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
const require_chunk = require('./chunk-nOFOJqeH.js');
|
|
2
|
+
let node_path = require("node:path");
|
|
3
|
+
node_path = require_chunk.__toESM(node_path);
|
|
4
|
+
let js_yaml = require("js-yaml");
|
|
5
|
+
js_yaml = require_chunk.__toESM(js_yaml);
|
|
6
|
+
let zod = require("zod");
|
|
7
|
+
zod = require_chunk.__toESM(zod);
|
|
4
8
|
|
|
5
9
|
//#region src/services/ScaffoldConfigLoader.ts
|
|
6
|
-
const VariablesSchemaSchema = z.object({
|
|
7
|
-
type: z.literal("object"),
|
|
8
|
-
properties: z.record(z.any()),
|
|
9
|
-
required: z.array(z.string()),
|
|
10
|
-
additionalProperties: z.boolean()
|
|
10
|
+
const VariablesSchemaSchema = zod.z.object({
|
|
11
|
+
type: zod.z.literal("object"),
|
|
12
|
+
properties: zod.z.record(zod.z.any()),
|
|
13
|
+
required: zod.z.array(zod.z.string()),
|
|
14
|
+
additionalProperties: zod.z.boolean()
|
|
11
15
|
});
|
|
12
|
-
const ScaffoldConfigEntrySchema = z.object({
|
|
13
|
-
name: z.string(),
|
|
14
|
-
description: z.string().optional(),
|
|
15
|
-
instruction: z.string().optional(),
|
|
16
|
-
targetFolder: z.string().optional(),
|
|
16
|
+
const ScaffoldConfigEntrySchema = zod.z.object({
|
|
17
|
+
name: zod.z.string(),
|
|
18
|
+
description: zod.z.string().optional(),
|
|
19
|
+
instruction: zod.z.string().optional(),
|
|
20
|
+
targetFolder: zod.z.string().optional(),
|
|
17
21
|
variables_schema: VariablesSchemaSchema,
|
|
18
|
-
includes: z.array(z.string()),
|
|
19
|
-
generator: z.string().optional(),
|
|
20
|
-
patterns: z.array(z.string()).optional()
|
|
22
|
+
includes: zod.z.array(zod.z.string()),
|
|
23
|
+
generator: zod.z.string().optional(),
|
|
24
|
+
patterns: zod.z.array(zod.z.string()).optional()
|
|
21
25
|
});
|
|
22
|
-
const ScaffoldYamlSchema = z.object({
|
|
23
|
-
boilerplate: z.union([ScaffoldConfigEntrySchema, z.array(ScaffoldConfigEntrySchema)]).optional(),
|
|
24
|
-
features: z.union([ScaffoldConfigEntrySchema, z.array(ScaffoldConfigEntrySchema)]).optional()
|
|
25
|
-
}).catchall(z.union([ScaffoldConfigEntrySchema, z.array(ScaffoldConfigEntrySchema)]));
|
|
26
|
+
const ScaffoldYamlSchema = zod.z.object({
|
|
27
|
+
boilerplate: zod.z.union([ScaffoldConfigEntrySchema, zod.z.array(ScaffoldConfigEntrySchema)]).optional(),
|
|
28
|
+
features: zod.z.union([ScaffoldConfigEntrySchema, zod.z.array(ScaffoldConfigEntrySchema)]).optional()
|
|
29
|
+
}).catchall(zod.z.union([ScaffoldConfigEntrySchema, zod.z.array(ScaffoldConfigEntrySchema)]));
|
|
26
30
|
var ScaffoldConfigLoader = class {
|
|
27
31
|
constructor(fileSystem, templateService) {
|
|
28
32
|
this.fileSystem = fileSystem;
|
|
29
33
|
this.templateService = templateService;
|
|
30
34
|
}
|
|
31
35
|
async parseArchitectConfig(templatePath) {
|
|
32
|
-
const architectPath =
|
|
36
|
+
const architectPath = node_path.default.join(templatePath, "scaffold.yaml");
|
|
33
37
|
if (!await this.fileSystem.pathExists(architectPath)) return null;
|
|
34
38
|
try {
|
|
35
39
|
const content = await this.fileSystem.readFile(architectPath, "utf8");
|
|
36
|
-
const rawConfig =
|
|
40
|
+
const rawConfig = js_yaml.default.load(content);
|
|
37
41
|
return ScaffoldYamlSchema.parse(rawConfig);
|
|
38
42
|
} catch (error) {
|
|
39
|
-
if (error instanceof z.ZodError) {
|
|
43
|
+
if (error instanceof zod.z.ZodError) {
|
|
40
44
|
const errorMessages = error.errors.map((err) => `${err.path.join(".")}: ${err.message}`).join("; ");
|
|
41
45
|
throw new Error(`scaffold.yaml validation failed: ${errorMessages}`);
|
|
42
46
|
}
|
|
@@ -124,7 +128,7 @@ var ScaffoldConfigLoader = class {
|
|
|
124
128
|
const config = architectConfig[scaffoldType];
|
|
125
129
|
if (config.includes && Array.isArray(config.includes)) for (const includeFile of config.includes) {
|
|
126
130
|
const parsed = this.parseIncludeEntry(includeFile, {});
|
|
127
|
-
const sourcePath =
|
|
131
|
+
const sourcePath = node_path.default.join(templatePath, parsed.sourcePath);
|
|
128
132
|
const liquidSourcePath = `${sourcePath}.liquid`;
|
|
129
133
|
const sourceExists = await this.fileSystem.pathExists(sourcePath);
|
|
130
134
|
const liquidExists = await this.fileSystem.pathExists(liquidSourcePath);
|
|
@@ -139,4 +143,9 @@ var ScaffoldConfigLoader = class {
|
|
|
139
143
|
};
|
|
140
144
|
|
|
141
145
|
//#endregion
|
|
142
|
-
|
|
146
|
+
Object.defineProperty(exports, 'ScaffoldConfigLoader', {
|
|
147
|
+
enumerable: true,
|
|
148
|
+
get: function () {
|
|
149
|
+
return ScaffoldConfigLoader;
|
|
150
|
+
}
|
|
151
|
+
});
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
const require_chunk = require('./chunk-nOFOJqeH.js');
|
|
2
|
+
const require_logger = require('./logger-Dno88AK9.js');
|
|
3
|
+
let node_path = require("node:path");
|
|
4
|
+
node_path = require_chunk.__toESM(node_path);
|
|
5
|
+
let fs_extra = require("fs-extra");
|
|
6
|
+
fs_extra = require_chunk.__toESM(fs_extra);
|
|
7
|
+
let node_url = require("node:url");
|
|
8
|
+
node_url = require_chunk.__toESM(node_url);
|
|
5
9
|
|
|
6
|
-
//#region rolldown:runtime
|
|
7
|
-
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
8
|
-
|
|
9
|
-
//#endregion
|
|
10
10
|
//#region src/services/ScaffoldProcessingService.ts
|
|
11
11
|
/**
|
|
12
12
|
* Shared service for common scaffolding operations like processing templates and tracking files
|
|
@@ -43,7 +43,7 @@ var ScaffoldProcessingService = class {
|
|
|
43
43
|
* Automatically handles .liquid template files by stripping the extension
|
|
44
44
|
*/
|
|
45
45
|
async copyAndProcess(sourcePath, targetPath, variables, createdFiles, existingFiles) {
|
|
46
|
-
await this.fileSystem.ensureDir(
|
|
46
|
+
await this.fileSystem.ensureDir(node_path.default.dirname(targetPath));
|
|
47
47
|
if (await this.fileSystem.pathExists(targetPath) && existingFiles) {
|
|
48
48
|
await this.trackExistingFiles(targetPath, existingFiles);
|
|
49
49
|
return;
|
|
@@ -66,18 +66,18 @@ var ScaffoldProcessingService = class {
|
|
|
66
66
|
try {
|
|
67
67
|
items = await this.fileSystem.readdir(dirPath);
|
|
68
68
|
} catch (error) {
|
|
69
|
-
|
|
69
|
+
require_logger.log.warn(`Cannot read directory ${dirPath}: ${error}`);
|
|
70
70
|
return;
|
|
71
71
|
}
|
|
72
72
|
for (const item of items) {
|
|
73
73
|
if (!item) continue;
|
|
74
|
-
const itemPath =
|
|
74
|
+
const itemPath = node_path.default.join(dirPath, item);
|
|
75
75
|
try {
|
|
76
76
|
const stat = await this.fileSystem.stat(itemPath);
|
|
77
77
|
if (stat.isDirectory()) await this.trackCreatedFilesRecursive(itemPath, createdFiles);
|
|
78
78
|
else if (stat.isFile()) createdFiles.push(itemPath);
|
|
79
79
|
} catch (error) {
|
|
80
|
-
|
|
80
|
+
require_logger.log.warn(`Cannot stat ${itemPath}: ${error}`);
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
83
|
}
|
|
@@ -89,18 +89,18 @@ var ScaffoldProcessingService = class {
|
|
|
89
89
|
try {
|
|
90
90
|
items = await this.fileSystem.readdir(dirPath);
|
|
91
91
|
} catch (error) {
|
|
92
|
-
|
|
92
|
+
require_logger.log.warn(`Cannot read directory ${dirPath}: ${error}`);
|
|
93
93
|
return;
|
|
94
94
|
}
|
|
95
95
|
for (const item of items) {
|
|
96
96
|
if (!item) continue;
|
|
97
|
-
const itemPath =
|
|
97
|
+
const itemPath = node_path.default.join(dirPath, item);
|
|
98
98
|
try {
|
|
99
99
|
const stat = await this.fileSystem.stat(itemPath);
|
|
100
100
|
if (stat.isDirectory()) await this.trackExistingFilesRecursive(itemPath, existingFiles);
|
|
101
101
|
else if (stat.isFile()) existingFiles.push(itemPath);
|
|
102
102
|
} catch (error) {
|
|
103
|
-
|
|
103
|
+
require_logger.log.warn(`Cannot stat ${itemPath}: ${error}`);
|
|
104
104
|
}
|
|
105
105
|
}
|
|
106
106
|
}
|
|
@@ -129,32 +129,32 @@ var TemplatesManager = class TemplatesManager {
|
|
|
129
129
|
*/
|
|
130
130
|
static async findTemplatesPath(startPath = process.cwd()) {
|
|
131
131
|
const workspaceRoot = await TemplatesManager.findWorkspaceRoot(startPath);
|
|
132
|
-
const toolkitConfigPath =
|
|
133
|
-
if (await
|
|
132
|
+
const toolkitConfigPath = node_path.default.join(workspaceRoot, TemplatesManager.TOOLKIT_CONFIG_FILE);
|
|
133
|
+
if (await fs_extra.pathExists(toolkitConfigPath)) {
|
|
134
134
|
const yaml = await import("js-yaml");
|
|
135
|
-
const content = await
|
|
135
|
+
const content = await fs_extra.readFile(toolkitConfigPath, "utf-8");
|
|
136
136
|
const config = yaml.load(content);
|
|
137
137
|
if (config?.templatesPath) {
|
|
138
|
-
const templatesPath$1 =
|
|
139
|
-
if (await
|
|
138
|
+
const templatesPath$1 = node_path.default.isAbsolute(config.templatesPath) ? config.templatesPath : node_path.default.join(workspaceRoot, config.templatesPath);
|
|
139
|
+
if (await fs_extra.pathExists(templatesPath$1)) return templatesPath$1;
|
|
140
140
|
else throw new Error(`Templates path specified in toolkit.yaml does not exist: ${templatesPath$1}`);
|
|
141
141
|
}
|
|
142
142
|
}
|
|
143
|
-
const templatesPath =
|
|
144
|
-
if (await
|
|
143
|
+
const templatesPath = node_path.default.join(workspaceRoot, TemplatesManager.TEMPLATES_FOLDER);
|
|
144
|
+
if (await fs_extra.pathExists(templatesPath)) return templatesPath;
|
|
145
145
|
throw new Error(`Templates folder not found at ${templatesPath}.\nEither create a 'templates' folder or specify templatesPath in toolkit.yaml`);
|
|
146
146
|
}
|
|
147
147
|
/**
|
|
148
148
|
* Find the workspace root by searching upwards for .git folder
|
|
149
149
|
*/
|
|
150
150
|
static async findWorkspaceRoot(startPath) {
|
|
151
|
-
let currentPath =
|
|
152
|
-
const rootPath =
|
|
151
|
+
let currentPath = node_path.default.resolve(startPath);
|
|
152
|
+
const rootPath = node_path.default.parse(currentPath).root;
|
|
153
153
|
while (true) {
|
|
154
|
-
const gitPath =
|
|
155
|
-
if (await
|
|
154
|
+
const gitPath = node_path.default.join(currentPath, ".git");
|
|
155
|
+
if (await fs_extra.pathExists(gitPath)) return currentPath;
|
|
156
156
|
if (currentPath === rootPath) return process.cwd();
|
|
157
|
-
currentPath =
|
|
157
|
+
currentPath = node_path.default.dirname(currentPath);
|
|
158
158
|
}
|
|
159
159
|
}
|
|
160
160
|
/**
|
|
@@ -167,32 +167,32 @@ var TemplatesManager = class TemplatesManager {
|
|
|
167
167
|
*/
|
|
168
168
|
static findTemplatesPathSync(startPath = process.cwd()) {
|
|
169
169
|
const workspaceRoot = TemplatesManager.findWorkspaceRootSync(startPath);
|
|
170
|
-
const toolkitConfigPath =
|
|
171
|
-
if (
|
|
172
|
-
const yaml =
|
|
173
|
-
const content =
|
|
170
|
+
const toolkitConfigPath = node_path.default.join(workspaceRoot, TemplatesManager.TOOLKIT_CONFIG_FILE);
|
|
171
|
+
if (fs_extra.pathExistsSync(toolkitConfigPath)) {
|
|
172
|
+
const yaml = require("js-yaml");
|
|
173
|
+
const content = fs_extra.readFileSync(toolkitConfigPath, "utf-8");
|
|
174
174
|
const config = yaml.load(content);
|
|
175
175
|
if (config?.templatesPath) {
|
|
176
|
-
const templatesPath$1 =
|
|
177
|
-
if (
|
|
176
|
+
const templatesPath$1 = node_path.default.isAbsolute(config.templatesPath) ? config.templatesPath : node_path.default.join(workspaceRoot, config.templatesPath);
|
|
177
|
+
if (fs_extra.pathExistsSync(templatesPath$1)) return templatesPath$1;
|
|
178
178
|
else throw new Error(`Templates path specified in toolkit.yaml does not exist: ${templatesPath$1}`);
|
|
179
179
|
}
|
|
180
180
|
}
|
|
181
|
-
const templatesPath =
|
|
182
|
-
if (
|
|
181
|
+
const templatesPath = node_path.default.join(workspaceRoot, TemplatesManager.TEMPLATES_FOLDER);
|
|
182
|
+
if (fs_extra.pathExistsSync(templatesPath)) return templatesPath;
|
|
183
183
|
throw new Error(`Templates folder not found at ${templatesPath}.\nEither create a 'templates' folder or specify templatesPath in toolkit.yaml`);
|
|
184
184
|
}
|
|
185
185
|
/**
|
|
186
186
|
* Find the workspace root synchronously by searching upwards for .git folder
|
|
187
187
|
*/
|
|
188
188
|
static findWorkspaceRootSync(startPath) {
|
|
189
|
-
let currentPath =
|
|
190
|
-
const rootPath =
|
|
189
|
+
let currentPath = node_path.default.resolve(startPath);
|
|
190
|
+
const rootPath = node_path.default.parse(currentPath).root;
|
|
191
191
|
while (true) {
|
|
192
|
-
const gitPath =
|
|
193
|
-
if (
|
|
192
|
+
const gitPath = node_path.default.join(currentPath, ".git");
|
|
193
|
+
if (fs_extra.pathExistsSync(gitPath)) return currentPath;
|
|
194
194
|
if (currentPath === rootPath) return process.cwd();
|
|
195
|
-
currentPath =
|
|
195
|
+
currentPath = node_path.default.dirname(currentPath);
|
|
196
196
|
}
|
|
197
197
|
}
|
|
198
198
|
/**
|
|
@@ -202,8 +202,8 @@ var TemplatesManager = class TemplatesManager {
|
|
|
202
202
|
* @returns true if templates folder exists and is a directory
|
|
203
203
|
*/
|
|
204
204
|
static async isInitialized(templatesPath) {
|
|
205
|
-
if (!await
|
|
206
|
-
return (await
|
|
205
|
+
if (!await fs_extra.pathExists(templatesPath)) return false;
|
|
206
|
+
return (await fs_extra.stat(templatesPath)).isDirectory();
|
|
207
207
|
}
|
|
208
208
|
/**
|
|
209
209
|
* Get the scaffold config file name
|
|
@@ -237,8 +237,8 @@ var ScaffoldService = class {
|
|
|
237
237
|
async useBoilerplate(options) {
|
|
238
238
|
try {
|
|
239
239
|
const { projectName, packageName, targetFolder, templateFolder, boilerplateName, variables = {} } = options;
|
|
240
|
-
const targetPath =
|
|
241
|
-
const templatePath =
|
|
240
|
+
const targetPath = node_path.default.isAbsolute(targetFolder) ? node_path.default.join(targetFolder, projectName) : node_path.default.join(process.cwd(), targetFolder, projectName);
|
|
241
|
+
const templatePath = node_path.default.join(this.templatesRootPath, templateFolder);
|
|
242
242
|
const validationResult = await this.scaffoldConfigLoader.validateTemplate(templatePath, "boilerplate");
|
|
243
243
|
if (!validationResult.isValid) return {
|
|
244
244
|
success: false,
|
|
@@ -287,9 +287,9 @@ var ScaffoldService = class {
|
|
|
287
287
|
async useFeature(options) {
|
|
288
288
|
try {
|
|
289
289
|
const { projectPath, templateFolder, featureName, variables = {} } = options;
|
|
290
|
-
const targetPath =
|
|
291
|
-
const templatePath =
|
|
292
|
-
const projectName =
|
|
290
|
+
const targetPath = node_path.default.resolve(projectPath);
|
|
291
|
+
const templatePath = node_path.default.join(this.templatesRootPath, templateFolder);
|
|
292
|
+
const projectName = node_path.default.basename(targetPath);
|
|
293
293
|
const validationResult = await this.scaffoldConfigLoader.validateTemplate(templatePath, "features");
|
|
294
294
|
if (!validationResult.isValid) return {
|
|
295
295
|
success: false,
|
|
@@ -338,12 +338,12 @@ var ScaffoldService = class {
|
|
|
338
338
|
*/
|
|
339
339
|
async processScaffold(params) {
|
|
340
340
|
const { config, targetPath, templatePath, allVariables, scaffoldType } = params;
|
|
341
|
-
|
|
342
|
-
|
|
341
|
+
require_logger.log.debug("Config generator:", config.generator);
|
|
342
|
+
require_logger.log.debug("Config:", JSON.stringify(config, null, 2));
|
|
343
343
|
if (config.generator) {
|
|
344
|
-
|
|
344
|
+
require_logger.log.info("Using custom generator:", config.generator);
|
|
345
345
|
try {
|
|
346
|
-
const generator = (await import(
|
|
346
|
+
const generator = (await import(node_path.default.join(templatePath, "generators", config.generator))).default;
|
|
347
347
|
if (typeof generator !== "function") return {
|
|
348
348
|
success: false,
|
|
349
349
|
message: `Invalid generator: ${config.generator} does not export a default function`
|
|
@@ -358,12 +358,12 @@ var ScaffoldService = class {
|
|
|
358
358
|
variableReplacer: this.variableReplacer,
|
|
359
359
|
ScaffoldProcessingService: this.processingService.constructor,
|
|
360
360
|
getRootPath: () => {
|
|
361
|
-
const __dirname =
|
|
362
|
-
return
|
|
361
|
+
const __dirname$1 = node_path.default.dirname((0, node_url.fileURLToPath)(require("url").pathToFileURL(__filename).href));
|
|
362
|
+
return node_path.default.join(__dirname$1, "../../../../..");
|
|
363
363
|
},
|
|
364
364
|
getProjectPath: (projectPath) => {
|
|
365
|
-
const __dirname =
|
|
366
|
-
const rootPath =
|
|
365
|
+
const __dirname$1 = node_path.default.dirname((0, node_url.fileURLToPath)(require("url").pathToFileURL(__filename).href));
|
|
366
|
+
const rootPath = node_path.default.join(__dirname$1, "../../../../..");
|
|
367
367
|
return projectPath.replace(rootPath, "").replace("/", "");
|
|
368
368
|
}
|
|
369
369
|
});
|
|
@@ -380,15 +380,15 @@ var ScaffoldService = class {
|
|
|
380
380
|
const parsed = this.scaffoldConfigLoader.parseIncludeEntry(includeEntry, allVariables);
|
|
381
381
|
if (!this.scaffoldConfigLoader.shouldIncludeFile(parsed.conditions, allVariables)) continue;
|
|
382
382
|
parsedIncludes.push(parsed);
|
|
383
|
-
const targetFilePath =
|
|
383
|
+
const targetFilePath = node_path.default.join(targetPath, parsed.targetPath);
|
|
384
384
|
if (await this.fileSystem.pathExists(targetFilePath)) warnings.push(`File/folder ${parsed.targetPath} already exists and will be preserved`);
|
|
385
385
|
}
|
|
386
386
|
await this.fileSystem.ensureDir(targetPath);
|
|
387
387
|
const createdFiles = [];
|
|
388
388
|
const existingFiles = [];
|
|
389
389
|
for (const parsed of parsedIncludes) {
|
|
390
|
-
const sourcePath =
|
|
391
|
-
const targetFilePath =
|
|
390
|
+
const sourcePath = node_path.default.join(templatePath, parsed.sourcePath);
|
|
391
|
+
const targetFilePath = node_path.default.join(targetPath, parsed.targetPath);
|
|
392
392
|
await this.processingService.copyAndProcess(sourcePath, targetFilePath, allVariables, createdFiles, existingFiles);
|
|
393
393
|
}
|
|
394
394
|
let message = `Successfully scaffolded ${scaffoldType} at ${targetPath}`;
|
|
@@ -405,4 +405,15 @@ var ScaffoldService = class {
|
|
|
405
405
|
};
|
|
406
406
|
|
|
407
407
|
//#endregion
|
|
408
|
-
|
|
408
|
+
Object.defineProperty(exports, 'ScaffoldService', {
|
|
409
|
+
enumerable: true,
|
|
410
|
+
get: function () {
|
|
411
|
+
return ScaffoldService;
|
|
412
|
+
}
|
|
413
|
+
});
|
|
414
|
+
Object.defineProperty(exports, 'TemplatesManager', {
|
|
415
|
+
enumerable: true,
|
|
416
|
+
get: function () {
|
|
417
|
+
return TemplatesManager;
|
|
418
|
+
}
|
|
419
|
+
});
|
|
@@ -1,14 +1,18 @@
|
|
|
1
|
-
|
|
1
|
+
const require_chunk = require('./chunk-nOFOJqeH.js');
|
|
2
|
+
const require_logger = require('./logger-Dno88AK9.js');
|
|
3
|
+
let liquidjs = require("liquidjs");
|
|
4
|
+
liquidjs = require_chunk.__toESM(liquidjs);
|
|
2
5
|
|
|
3
6
|
//#region src/services/TemplateService.ts
|
|
4
7
|
var TemplateService = class {
|
|
5
8
|
liquid;
|
|
6
9
|
constructor() {
|
|
7
|
-
this.liquid = new Liquid({
|
|
10
|
+
this.liquid = new liquidjs.Liquid({
|
|
8
11
|
strictFilters: false,
|
|
9
12
|
strictVariables: false
|
|
10
13
|
});
|
|
11
14
|
this.setupCustomFilters();
|
|
15
|
+
require_logger.log.info("TemplateService initialized");
|
|
12
16
|
}
|
|
13
17
|
toPascalCase(str) {
|
|
14
18
|
const camelCase = str.replace(/[-_\s]+(.)?/g, (_, char) => char ? char.toUpperCase() : "");
|
|
@@ -46,12 +50,25 @@ var TemplateService = class {
|
|
|
46
50
|
else if (str.endsWith("s") && !str.endsWith("ss")) return str.slice(0, -1);
|
|
47
51
|
else return str;
|
|
48
52
|
});
|
|
53
|
+
this.liquid.registerFilter("strip", (str) => {
|
|
54
|
+
return str.trim();
|
|
55
|
+
});
|
|
49
56
|
}
|
|
50
57
|
renderString(template, variables) {
|
|
51
58
|
try {
|
|
52
|
-
|
|
59
|
+
require_logger.log.debug("Rendering template", {
|
|
60
|
+
variables,
|
|
61
|
+
templatePreview: template.substring(0, 100)
|
|
62
|
+
});
|
|
63
|
+
const result = this.liquid.parseAndRenderSync(template, variables);
|
|
64
|
+
require_logger.log.debug("Rendered template", { resultPreview: result.substring(0, 100) });
|
|
65
|
+
return result;
|
|
53
66
|
} catch (error) {
|
|
54
|
-
|
|
67
|
+
require_logger.log.error("LiquidJS rendering error", {
|
|
68
|
+
error: error instanceof Error ? error.message : String(error),
|
|
69
|
+
templatePreview: template.substring(0, 200),
|
|
70
|
+
variables
|
|
71
|
+
});
|
|
55
72
|
return template;
|
|
56
73
|
}
|
|
57
74
|
}
|
|
@@ -61,4 +78,9 @@ var TemplateService = class {
|
|
|
61
78
|
};
|
|
62
79
|
|
|
63
80
|
//#endregion
|
|
64
|
-
|
|
81
|
+
Object.defineProperty(exports, 'TemplateService', {
|
|
82
|
+
enumerable: true,
|
|
83
|
+
get: function () {
|
|
84
|
+
return TemplateService;
|
|
85
|
+
}
|
|
86
|
+
});
|
package/dist/{VariableReplacementService-Bq0GDhTo.js → VariableReplacementService-BGmF2DVE.js}
RENAMED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
const require_chunk = require('./chunk-nOFOJqeH.js');
|
|
2
|
+
const require_logger = require('./logger-Dno88AK9.js');
|
|
3
|
+
let node_path = require("node:path");
|
|
4
|
+
node_path = require_chunk.__toESM(node_path);
|
|
2
5
|
|
|
3
6
|
//#region src/services/VariableReplacementService.ts
|
|
4
7
|
var VariableReplacementService = class {
|
|
@@ -30,18 +33,18 @@ var VariableReplacementService = class {
|
|
|
30
33
|
try {
|
|
31
34
|
items = await this.fileSystem.readdir(dirPath);
|
|
32
35
|
} catch (error) {
|
|
33
|
-
|
|
36
|
+
require_logger.log.warn(`Skipping directory ${dirPath}: ${error}`);
|
|
34
37
|
return;
|
|
35
38
|
}
|
|
36
39
|
for (const item of items) {
|
|
37
40
|
if (!item) continue;
|
|
38
|
-
const itemPath =
|
|
41
|
+
const itemPath = node_path.default.join(dirPath, item);
|
|
39
42
|
try {
|
|
40
43
|
const stat = await this.fileSystem.stat(itemPath);
|
|
41
44
|
if (stat.isDirectory()) await this.processFilesForVariableReplacement(itemPath, variables);
|
|
42
45
|
else if (stat.isFile()) await this.replaceVariablesInFile(itemPath, variables);
|
|
43
46
|
} catch (error) {
|
|
44
|
-
|
|
47
|
+
require_logger.log.warn(`Skipping item ${itemPath}: ${error}`);
|
|
45
48
|
}
|
|
46
49
|
}
|
|
47
50
|
}
|
|
@@ -52,14 +55,19 @@ var VariableReplacementService = class {
|
|
|
52
55
|
const renderedContent = this.templateService.renderString(content, variables);
|
|
53
56
|
await this.fileSystem.writeFile(filePath, renderedContent, "utf8");
|
|
54
57
|
} catch (error) {
|
|
55
|
-
|
|
58
|
+
require_logger.log.warn(`Skipping file ${filePath}: ${error}`);
|
|
56
59
|
}
|
|
57
60
|
}
|
|
58
61
|
isBinaryFile(filePath) {
|
|
59
|
-
const ext =
|
|
62
|
+
const ext = node_path.default.extname(filePath).toLowerCase();
|
|
60
63
|
return this.binaryExtensions.includes(ext);
|
|
61
64
|
}
|
|
62
65
|
};
|
|
63
66
|
|
|
64
67
|
//#endregion
|
|
65
|
-
|
|
68
|
+
Object.defineProperty(exports, 'VariableReplacementService', {
|
|
69
|
+
enumerable: true,
|
|
70
|
+
get: function () {
|
|
71
|
+
return VariableReplacementService;
|
|
72
|
+
}
|
|
73
|
+
});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
//#region rolldown:runtime
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
10
|
+
key = keys[i];
|
|
11
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
12
|
+
get: ((k) => from[k]).bind(null, key),
|
|
13
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
19
|
+
value: mod,
|
|
20
|
+
enumerable: true
|
|
21
|
+
}) : target, mod));
|
|
22
|
+
|
|
23
|
+
//#endregion
|
|
24
|
+
|
|
25
|
+
Object.defineProperty(exports, '__toESM', {
|
|
26
|
+
enumerable: true,
|
|
27
|
+
get: function () {
|
|
28
|
+
return __toESM;
|
|
29
|
+
}
|
|
30
|
+
});
|