@magmonium/cli 0.7.8
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/README.md +392 -0
- package/bin/README.md +244 -0
- package/bin/cli.js +55 -0
- package/bin/commands/assets-wc.js +249 -0
- package/bin/commands/assets.js +943 -0
- package/bin/commands/build.js +242 -0
- package/bin/commands/clean.js +621 -0
- package/bin/commands/compile-i18n.js +91 -0
- package/bin/commands/config-ci.js +266 -0
- package/bin/commands/configure-wc.js +167 -0
- package/bin/commands/connect.js +188 -0
- package/bin/commands/create-app.js +946 -0
- package/bin/commands/deploy.js +100 -0
- package/bin/commands/fix-i18n.js +40 -0
- package/bin/commands/generate.js +765 -0
- package/bin/commands/init/config-files.js +1114 -0
- package/bin/commands/init/mag-assets.js +541 -0
- package/bin/commands/init/mag-cli-config.js +120 -0
- package/bin/commands/init/monorepo-structure.js +735 -0
- package/bin/commands/init/package-json.js +308 -0
- package/bin/commands/init/project-structure.js +189 -0
- package/bin/commands/init/pwa-files.js +204 -0
- package/bin/commands/init/source-files.js +2596 -0
- package/bin/commands/init.js +591 -0
- package/bin/commands/lib.js +508 -0
- package/bin/commands/patch-wc-env.js +136 -0
- package/bin/commands/refractor.js +51 -0
- package/bin/commands/sanitize-i18n.js +41 -0
- package/bin/commands/translate.js +32 -0
- package/bin/commands/zip.js +540 -0
- package/package.json +53 -0
- package/src/compilers/button-group-compiler.d.ts +18 -0
- package/src/compilers/button-group-compiler.d.ts.map +1 -0
- package/src/compilers/button-group-compiler.js +151 -0
- package/src/compilers/button-group-compiler.js.map +1 -0
- package/src/compilers/copy-compiler.d.ts +14 -0
- package/src/compilers/copy-compiler.d.ts.map +1 -0
- package/src/compilers/copy-compiler.js +170 -0
- package/src/compilers/copy-compiler.js.map +1 -0
- package/src/compilers/field-compiler.d.ts +15 -0
- package/src/compilers/field-compiler.d.ts.map +1 -0
- package/src/compilers/field-compiler.js +153 -0
- package/src/compilers/field-compiler.js.map +1 -0
- package/src/compilers/form-compiler.d.ts +15 -0
- package/src/compilers/form-compiler.d.ts.map +1 -0
- package/src/compilers/form-compiler.js +220 -0
- package/src/compilers/form-compiler.js.map +1 -0
- package/src/compilers/logo-compiler.d.ts +14 -0
- package/src/compilers/logo-compiler.d.ts.map +1 -0
- package/src/compilers/logo-compiler.js +114 -0
- package/src/compilers/logo-compiler.js.map +1 -0
- package/src/compilers/options-compiler.d.ts +46 -0
- package/src/compilers/options-compiler.d.ts.map +1 -0
- package/src/compilers/options-compiler.js +329 -0
- package/src/compilers/options-compiler.js.map +1 -0
- package/src/compilers/pwa-build.d.ts +7 -0
- package/src/compilers/pwa-build.d.ts.map +1 -0
- package/src/compilers/pwa-build.js +62 -0
- package/src/compilers/pwa-build.js.map +1 -0
- package/src/compilers/svg-compiler.d.ts +12 -0
- package/src/compilers/svg-compiler.d.ts.map +1 -0
- package/src/compilers/svg-compiler.js +123 -0
- package/src/compilers/svg-compiler.js.map +1 -0
- package/src/compilers/tabs-compiler.d.ts +25 -0
- package/src/compilers/tabs-compiler.d.ts.map +1 -0
- package/src/compilers/tabs-compiler.js +422 -0
- package/src/compilers/tabs-compiler.js.map +1 -0
- package/src/compilers/theme-compiler.d.ts +14 -0
- package/src/compilers/theme-compiler.d.ts.map +1 -0
- package/src/compilers/theme-compiler.js +144 -0
- package/src/compilers/theme-compiler.js.map +1 -0
- package/src/compilers/translation-compiler.d.ts +17 -0
- package/src/compilers/translation-compiler.d.ts.map +1 -0
- package/src/compilers/translation-compiler.js +232 -0
- package/src/compilers/translation-compiler.js.map +1 -0
- package/src/compilers/web-component/index.d.ts +3 -0
- package/src/compilers/web-component/index.d.ts.map +1 -0
- package/src/compilers/web-component/index.js +6 -0
- package/src/compilers/web-component/index.js.map +1 -0
- package/src/compilers/web-component/lib/builder.d.ts +45 -0
- package/src/compilers/web-component/lib/builder.d.ts.map +1 -0
- package/src/compilers/web-component/lib/builder.js +341 -0
- package/src/compilers/web-component/lib/builder.js.map +1 -0
- package/src/compilers/web-component/lib/class-name.d.ts +4 -0
- package/src/compilers/web-component/lib/class-name.d.ts.map +1 -0
- package/src/compilers/web-component/lib/class-name.js +24 -0
- package/src/compilers/web-component/lib/class-name.js.map +1 -0
- package/src/compilers/web-component/lib/config-data.d.ts +9 -0
- package/src/compilers/web-component/lib/config-data.d.ts.map +1 -0
- package/src/compilers/web-component/lib/config-data.js +14 -0
- package/src/compilers/web-component/lib/config-data.js.map +1 -0
- package/src/compilers/web-component/lib/ng-build.d.ts +8 -0
- package/src/compilers/web-component/lib/ng-build.d.ts.map +1 -0
- package/src/compilers/web-component/lib/ng-build.js +685 -0
- package/src/compilers/web-component/lib/ng-build.js.map +1 -0
- package/src/compilers/web-component/lib/resource-inliner.d.ts +9 -0
- package/src/compilers/web-component/lib/resource-inliner.d.ts.map +1 -0
- package/src/compilers/web-component/lib/resource-inliner.js +355 -0
- package/src/compilers/web-component/lib/resource-inliner.js.map +1 -0
- package/src/compilers/web-component/lib/web-component-name.d.ts +3 -0
- package/src/compilers/web-component/lib/web-component-name.d.ts.map +1 -0
- package/src/compilers/web-component/lib/web-component-name.js +47 -0
- package/src/compilers/web-component/lib/web-component-name.js.map +1 -0
- package/src/compilers/web-component/lib/web-component-wrapper.d.ts +3 -0
- package/src/compilers/web-component/lib/web-component-wrapper.d.ts.map +1 -0
- package/src/compilers/web-component/lib/web-component-wrapper.js +335 -0
- package/src/compilers/web-component/lib/web-component-wrapper.js.map +1 -0
- package/src/compilers/web-component/model/type.d.ts +29 -0
- package/src/compilers/web-component/model/type.d.ts.map +1 -0
- package/src/compilers/web-component/model/type.js +3 -0
- package/src/compilers/web-component/model/type.js.map +1 -0
- package/src/compilers/worker-compiler.d.ts +12 -0
- package/src/compilers/worker-compiler.d.ts.map +1 -0
- package/src/compilers/worker-compiler.js +123 -0
- package/src/compilers/worker-compiler.js.map +1 -0
- package/src/compilers/yaml-compiler.d.ts +18 -0
- package/src/compilers/yaml-compiler.d.ts.map +1 -0
- package/src/compilers/yaml-compiler.js +139 -0
- package/src/compilers/yaml-compiler.js.map +1 -0
- package/src/core/base-compiler.d.ts +17 -0
- package/src/core/base-compiler.d.ts.map +1 -0
- package/src/core/base-compiler.js +78 -0
- package/src/core/base-compiler.js.map +1 -0
- package/src/core/config.d.ts +640 -0
- package/src/core/config.d.ts.map +1 -0
- package/src/core/config.js +432 -0
- package/src/core/config.js.map +1 -0
- package/src/core/file-watcher.d.ts +23 -0
- package/src/core/file-watcher.d.ts.map +1 -0
- package/src/core/file-watcher.js +63 -0
- package/src/core/file-watcher.js.map +1 -0
- package/src/index.d.ts +31 -0
- package/src/index.d.ts.map +1 -0
- package/src/index.js +34 -0
- package/src/index.js.map +1 -0
- package/src/types/asset-configs.d.ts +189 -0
- package/src/types/asset-configs.d.ts.map +1 -0
- package/src/types/asset-configs.js +7 -0
- package/src/types/asset-configs.js.map +1 -0
- package/src/types/theme.d.ts +67 -0
- package/src/types/theme.d.ts.map +1 -0
- package/src/types/theme.js +3 -0
- package/src/types/theme.js.map +1 -0
- package/src/utils/file-utils.d.ts +16 -0
- package/src/utils/file-utils.d.ts.map +1 -0
- package/src/utils/file-utils.js +58 -0
- package/src/utils/file-utils.js.map +1 -0
- package/src/utils/i18n-compile-validator.d.ts +20 -0
- package/src/utils/i18n-compile-validator.d.ts.map +1 -0
- package/src/utils/i18n-compile-validator.js +198 -0
- package/src/utils/i18n-compile-validator.js.map +1 -0
- package/src/utils/i18n-fixer.d.ts +39 -0
- package/src/utils/i18n-fixer.d.ts.map +1 -0
- package/src/utils/i18n-fixer.js +396 -0
- package/src/utils/i18n-fixer.js.map +1 -0
- package/src/utils/i18n-sanitizer.d.ts +17 -0
- package/src/utils/i18n-sanitizer.d.ts.map +1 -0
- package/src/utils/i18n-sanitizer.js +101 -0
- package/src/utils/i18n-sanitizer.js.map +1 -0
- package/src/utils/i18n-utils.d.ts +21 -0
- package/src/utils/i18n-utils.d.ts.map +1 -0
- package/src/utils/i18n-utils.js +89 -0
- package/src/utils/i18n-utils.js.map +1 -0
- package/src/utils/interactive-translator.d.ts +18 -0
- package/src/utils/interactive-translator.d.ts.map +1 -0
- package/src/utils/interactive-translator.js +401 -0
- package/src/utils/interactive-translator.js.map +1 -0
- package/src/utils/llama-cpp-translator.d.ts +33 -0
- package/src/utils/llama-cpp-translator.d.ts.map +1 -0
- package/src/utils/llama-cpp-translator.js +267 -0
- package/src/utils/llama-cpp-translator.js.map +1 -0
- package/src/utils/logger.d.ts +14 -0
- package/src/utils/logger.d.ts.map +1 -0
- package/src/utils/logger.js +42 -0
- package/src/utils/logger.js.map +1 -0
- package/src/utils/ollama-translator.d.ts +38 -0
- package/src/utils/ollama-translator.d.ts.map +1 -0
- package/src/utils/ollama-translator.js +371 -0
- package/src/utils/ollama-translator.js.map +1 -0
- package/src/utils/option-utils.d.ts +58 -0
- package/src/utils/option-utils.d.ts.map +1 -0
- package/src/utils/option-utils.js +123 -0
- package/src/utils/option-utils.js.map +1 -0
- package/src/utils/platform-utils.d.ts +33 -0
- package/src/utils/platform-utils.d.ts.map +1 -0
- package/src/utils/platform-utils.js +114 -0
- package/src/utils/platform-utils.js.map +1 -0
- package/src/utils/pwa-utils.d.ts +28 -0
- package/src/utils/pwa-utils.d.ts.map +1 -0
- package/src/utils/pwa-utils.js +48 -0
- package/src/utils/pwa-utils.js.map +1 -0
- package/src/utils/translation-manager.d.ts +43 -0
- package/src/utils/translation-manager.d.ts.map +1 -0
- package/src/utils/translation-manager.js +302 -0
- package/src/utils/translation-manager.js.map +1 -0
- package/src/utils/web-translation-providers.d.ts +53 -0
- package/src/utils/web-translation-providers.d.ts.map +1 -0
- package/src/utils/web-translation-providers.js +190 -0
- package/src/utils/web-translation-providers.js.map +1 -0
- package/src/utils/yaml-utils.d.ts +9 -0
- package/src/utils/yaml-utils.d.ts.map +1 -0
- package/src/utils/yaml-utils.js +26 -0
- package/src/utils/yaml-utils.js.map +1 -0
- package/templates/mag-compile.config.js +77 -0
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.YamlCompiler = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const base_compiler_1 = require("../core/base-compiler");
|
|
6
|
+
const file_utils_1 = require("../utils/file-utils");
|
|
7
|
+
const file_watcher_1 = require("../core/file-watcher");
|
|
8
|
+
const path_1 = tslib_1.__importDefault(require("path"));
|
|
9
|
+
const fs_1 = require("fs");
|
|
10
|
+
const yaml_1 = tslib_1.__importDefault(require("yaml"));
|
|
11
|
+
const ajv_1 = tslib_1.__importDefault(require("ajv"));
|
|
12
|
+
class YamlCompiler extends base_compiler_1.BaseCompiler {
|
|
13
|
+
constructor(config) {
|
|
14
|
+
super(config);
|
|
15
|
+
this.watcher = null;
|
|
16
|
+
this.ajvValidate = null;
|
|
17
|
+
this.assetType = config.assetType;
|
|
18
|
+
this.validationRules = config.validationRules || [];
|
|
19
|
+
if (config.schema) {
|
|
20
|
+
const ajv = new ajv_1.default({ allErrors: true });
|
|
21
|
+
const schema = JSON.parse((0, fs_1.readFileSync)(path_1.default.resolve(process.cwd(), config.schema), 'utf-8'));
|
|
22
|
+
this.ajvValidate = ajv.compile(schema);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
async compile() {
|
|
26
|
+
this.logger.group(`${this.assetType} Compilation`);
|
|
27
|
+
try {
|
|
28
|
+
const yamlFiles = await this.findYAMLFiles();
|
|
29
|
+
if (yamlFiles.length === 0) {
|
|
30
|
+
this.logger.info(`No YAML files found in ${this.assetType.toLowerCase()} input paths`);
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
const assetData = await this.processYAMLFiles(yamlFiles);
|
|
34
|
+
// Write individual JSON files
|
|
35
|
+
for (const [assetName, assetConfig] of Object.entries(assetData)) {
|
|
36
|
+
await this.writeFile(`${assetName}.json`, this.formatOutput(assetConfig));
|
|
37
|
+
}
|
|
38
|
+
this.logger.success(`Compiled ${yamlFiles.length} ${this.assetType.toLowerCase()} files`);
|
|
39
|
+
}
|
|
40
|
+
catch (error) {
|
|
41
|
+
this.logger.error(`${this.assetType} compilation failed: ${error}`);
|
|
42
|
+
throw error;
|
|
43
|
+
}
|
|
44
|
+
finally {
|
|
45
|
+
this.logger.endGroup();
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
async watch() {
|
|
49
|
+
this.watcher = new file_watcher_1.FileWatcher({
|
|
50
|
+
verbose: this.logger.constructor.name === 'Logger',
|
|
51
|
+
});
|
|
52
|
+
this.watcher.on('change', async (filePath) => {
|
|
53
|
+
if (this.isYAMLFile(filePath)) {
|
|
54
|
+
this.logger.info(`${this.assetType} file changed: ${filePath}`);
|
|
55
|
+
await this.compile();
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
this.watcher.on('add', async (filePath) => {
|
|
59
|
+
if (this.isYAMLFile(filePath)) {
|
|
60
|
+
this.logger.info(`${this.assetType} file added: ${filePath}`);
|
|
61
|
+
await this.compile();
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
this.watcher.on('unlink', async (filePath) => {
|
|
65
|
+
if (this.isYAMLFile(filePath)) {
|
|
66
|
+
this.logger.info(`${this.assetType} file removed: ${filePath}`);
|
|
67
|
+
await this.compile();
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
this.watcher.watch(this.config.inputPaths);
|
|
71
|
+
}
|
|
72
|
+
async findYAMLFiles() {
|
|
73
|
+
const patterns = this.config.patterns || ['**/*.yml', '**/*.yaml'];
|
|
74
|
+
const allFiles = [];
|
|
75
|
+
for (const inputPath of this.config.inputPaths) {
|
|
76
|
+
const files = await file_utils_1.FileUtils.findFiles(patterns.map((pattern) => path_1.default.join(inputPath, pattern)), process.cwd());
|
|
77
|
+
allFiles.push(...files);
|
|
78
|
+
}
|
|
79
|
+
return allFiles.filter((file) => this.isYAMLFile(file));
|
|
80
|
+
}
|
|
81
|
+
async processYAMLFiles(files) {
|
|
82
|
+
const assetData = {};
|
|
83
|
+
for (const file of files) {
|
|
84
|
+
try {
|
|
85
|
+
const content = await this.readFile(file);
|
|
86
|
+
const assetName = file_utils_1.FileUtils.getFileName(file);
|
|
87
|
+
// Parse YAML content
|
|
88
|
+
const parsedContent = yaml_1.default.parse(content);
|
|
89
|
+
// Validate content
|
|
90
|
+
this.validateAsset(parsedContent, assetName);
|
|
91
|
+
this.validateWithSchema(parsedContent, file);
|
|
92
|
+
assetData[assetName] = parsedContent;
|
|
93
|
+
this.logger.debug(`✓ Compiled ${path_1.default.basename(file)} → ${assetName}.json`);
|
|
94
|
+
}
|
|
95
|
+
catch (error) {
|
|
96
|
+
this.logger.error(`Failed to process ${this.assetType.toLowerCase()} file ${file}: ${error}`);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return assetData;
|
|
100
|
+
}
|
|
101
|
+
validateAsset(asset, fileName) {
|
|
102
|
+
for (const rule of this.validationRules) {
|
|
103
|
+
const value = asset[rule.field];
|
|
104
|
+
if (rule.required && (value === undefined || value === null)) {
|
|
105
|
+
const message = rule.message ||
|
|
106
|
+
`${this.assetType} file ${fileName} missing required '${rule.field}' field`;
|
|
107
|
+
this.logger.warn(message);
|
|
108
|
+
}
|
|
109
|
+
if (rule.validator && value !== undefined && !rule.validator(value)) {
|
|
110
|
+
const message = rule.message ||
|
|
111
|
+
`${this.assetType} file ${fileName} has invalid '${rule.field}' field`;
|
|
112
|
+
this.logger.warn(message);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
validateWithSchema(data, filePath) {
|
|
117
|
+
if (!this.ajvValidate)
|
|
118
|
+
return;
|
|
119
|
+
const valid = this.ajvValidate(data);
|
|
120
|
+
if (!valid) {
|
|
121
|
+
this.logger.warn(`${this.assetType} validation failed: ${filePath}`);
|
|
122
|
+
for (const err of this.ajvValidate.errors ?? []) {
|
|
123
|
+
this.logger.warn(` - ${err.instancePath || '/'}: ${err.message}`);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
isYAMLFile(filePath) {
|
|
128
|
+
const ext = file_utils_1.FileUtils.getFileExtension(filePath);
|
|
129
|
+
return ext === '.yml' || ext === '.yaml';
|
|
130
|
+
}
|
|
131
|
+
async stopWatching() {
|
|
132
|
+
if (this.watcher) {
|
|
133
|
+
await this.watcher.stop();
|
|
134
|
+
this.watcher = null;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
exports.YamlCompiler = YamlCompiler;
|
|
139
|
+
//# sourceMappingURL=yaml-compiler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"yaml-compiler.js","sourceRoot":"","sources":["../../../../../libs/cli/src/compilers/yaml-compiler.ts"],"names":[],"mappings":";;;;AAAA,yDAAqD;AAErD,oDAAgD;AAChD,uDAAmD;AACnD,wDAAwB;AACxB,2BAAkC;AAClC,wDAAwB;AACxB,sDAA4C;AAE5C,MAAa,YAA0B,SAAQ,4BAAY;IAMzD,YAAY,MAA0B;QACpC,KAAK,CAAC,MAAM,CAAC,CAAC;QANR,YAAO,GAAuB,IAAI,CAAC;QAGnC,gBAAW,GAA4B,IAAI,CAAC;QAIlD,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC,SAAS,CAAC;QAClC,IAAI,CAAC,eAAe,GAAG,MAAM,CAAC,eAAe,IAAI,EAAE,CAAC;QACpD,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;YAClB,MAAM,GAAG,GAAG,IAAI,aAAG,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;YACzC,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CACvB,IAAA,iBAAY,EAAC,cAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,CAClE,CAAC;YACF,IAAI,CAAC,WAAW,GAAG,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,CA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GAAG,IAAI,CAAC,SAAS,uBAAuB,QAAQ,EAAE,CAAC,CAAC;YACrE,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,WAAW,CAAC,MAAM,IAAI,EAAE,EAAE,CAAC;gBAChD,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,GAAG,CAAC,YAAY,IAAI,GAAG,KAAK,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC;YACrE,CAAC;QACH,CAAC;IACH,CAAC;IAEO,UAAU,CAAC,QAAgB;QACjC,MAAM,GAAG,GAAG,sBAAS,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC;QACjD,OAAO,GAAG,KAAK,MAAM,IAAI,GAAG,KAAK,OAAO,CAAC;IAC3C,CAAC;IAED,KAAK,CAAC,YAAY;QAChB,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACjB,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;YAC1B,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;QACtB,CAAC;IACH,CAAC;CACF;AAxKD,oCAwKC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { EventEmitter } from 'events';
|
|
2
|
+
import { CompilerConfig, CompilerOptions } from './config';
|
|
3
|
+
import { Logger } from '../utils/logger';
|
|
4
|
+
export declare abstract class BaseCompiler extends EventEmitter {
|
|
5
|
+
protected config: CompilerConfig;
|
|
6
|
+
protected logger: Logger;
|
|
7
|
+
protected outputPath: string;
|
|
8
|
+
constructor(config: CompilerConfig, options?: CompilerOptions);
|
|
9
|
+
abstract compile(): Promise<void>;
|
|
10
|
+
abstract watch(): Promise<void>;
|
|
11
|
+
compileForSourcePair(inputPaths: string[], outputPath: string): Promise<void>;
|
|
12
|
+
protected ensureOutputDir(): Promise<void>;
|
|
13
|
+
protected writeFile(fileName: string, content: string): Promise<void>;
|
|
14
|
+
protected readFile(filePath: string): Promise<string>;
|
|
15
|
+
protected formatOutput(data: unknown): string;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=base-compiler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base-compiler.d.ts","sourceRoot":"","sources":["../../../../../libs/cli/src/core/base-compiler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAGtC,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAC3D,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAEzC,8BAAsB,YAAa,SAAQ,YAAY;IACrD,SAAS,CAAC,MAAM,EAAE,cAAc,CAAC;IACjC,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC;IACzB,SAAS,CAAC,UAAU,EAAE,MAAM,CAAC;gBAEjB,MAAM,EAAE,cAAc,EAAE,OAAO,GAAE,eAAoB;IAejE,QAAQ,CAAC,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IACjC,QAAQ,CAAC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAGzB,oBAAoB,CACxB,UAAU,EAAE,MAAM,EAAE,EACpB,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,IAAI,CAAC;cAiBA,eAAe,IAAI,OAAO,CAAC,IAAI,CAAC;cAUhC,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;cAe3D,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAS3D,SAAS,CAAC,YAAY,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM;CAG9C"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BaseCompiler = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const events_1 = require("events");
|
|
6
|
+
const fs_1 = require("fs");
|
|
7
|
+
const path_1 = tslib_1.__importDefault(require("path"));
|
|
8
|
+
const logger_1 = require("../utils/logger");
|
|
9
|
+
class BaseCompiler extends events_1.EventEmitter {
|
|
10
|
+
constructor(config, options = {}) {
|
|
11
|
+
super();
|
|
12
|
+
this.config = config;
|
|
13
|
+
this.logger = new logger_1.Logger(options.verbose);
|
|
14
|
+
// Use single output path - prioritize config.outputPath, then config.outputPaths[0], then options, then default
|
|
15
|
+
if (config.outputPath) {
|
|
16
|
+
this.outputPath = config.outputPath;
|
|
17
|
+
}
|
|
18
|
+
else if (config.outputPaths && config.outputPaths.length > 0) {
|
|
19
|
+
this.outputPath = config.outputPaths[0]; // Use first output path for backward compatibility
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
this.outputPath = options.outputPath || './assets';
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
// Method for source-isolated compilation
|
|
26
|
+
async compileForSourcePair(inputPaths, outputPath) {
|
|
27
|
+
// Create a temporary config for this specific source-output pair
|
|
28
|
+
const isolatedConfig = {
|
|
29
|
+
...this.config,
|
|
30
|
+
inputPaths,
|
|
31
|
+
outputPath,
|
|
32
|
+
};
|
|
33
|
+
// Create a temporary compiler instance with isolated paths
|
|
34
|
+
const tempCompiler = Object.create(this);
|
|
35
|
+
tempCompiler.config = isolatedConfig;
|
|
36
|
+
tempCompiler.outputPath = outputPath;
|
|
37
|
+
// Call the actual compile method with isolated context
|
|
38
|
+
await tempCompiler.compile();
|
|
39
|
+
}
|
|
40
|
+
async ensureOutputDir() {
|
|
41
|
+
try {
|
|
42
|
+
// Ensure output directory exists
|
|
43
|
+
await fs_1.promises.mkdir(this.outputPath, { recursive: true });
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
this.logger.error(`Failed to create output directory: ${error}`);
|
|
47
|
+
throw error;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
async writeFile(fileName, content) {
|
|
51
|
+
try {
|
|
52
|
+
await this.ensureOutputDir();
|
|
53
|
+
// Write file to the single output path
|
|
54
|
+
const filePath = path_1.default.join(this.outputPath, fileName);
|
|
55
|
+
await fs_1.promises.writeFile(filePath, content, 'utf-8');
|
|
56
|
+
this.logger.success(`Generated: ${filePath}`);
|
|
57
|
+
this.emit('fileGenerated', { filePath, fileName });
|
|
58
|
+
}
|
|
59
|
+
catch (error) {
|
|
60
|
+
this.logger.error(`Failed to write file: ${error}`);
|
|
61
|
+
throw error;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
async readFile(filePath) {
|
|
65
|
+
try {
|
|
66
|
+
return await fs_1.promises.readFile(filePath, 'utf-8');
|
|
67
|
+
}
|
|
68
|
+
catch (error) {
|
|
69
|
+
this.logger.error(`Failed to read file ${filePath}: ${error}`);
|
|
70
|
+
throw error;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
formatOutput(data) {
|
|
74
|
+
return JSON.stringify(data, null, 2);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
exports.BaseCompiler = BaseCompiler;
|
|
78
|
+
//# sourceMappingURL=base-compiler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base-compiler.js","sourceRoot":"","sources":["../../../../../libs/cli/src/core/base-compiler.ts"],"names":[],"mappings":";;;;AAAA,mCAAsC;AACtC,2BAAoC;AACpC,wDAAwB;AAExB,4CAAyC;AAEzC,MAAsB,YAAa,SAAQ,qBAAY;IAKrD,YAAY,MAAsB,EAAE,UAA2B,EAAE;QAC/D,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,MAAM,GAAG,IAAI,eAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QAE1C,gHAAgH;QAChH,IAAI,MAAM,CAAC,UAAU,EAAE,CAAC;YACtB,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC;QACtC,CAAC;aAAM,IAAI,MAAM,CAAC,WAAW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