mirror of
https://github.com/espocrm/espocrm.git
synced 2026-03-03 02:47:03 +00:00
transpiler changes
This commit is contained in:
@@ -26,11 +26,34 @@
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
const Transpiler = require('../../js/transpiler');
|
||||
const Transpiler = require('./transpiler/transpiler');
|
||||
|
||||
(new Transpiler({})).process();
|
||||
let file;
|
||||
|
||||
(new Transpiler({
|
||||
let fIndex = process.argv.findIndex(item => item === '-f');
|
||||
|
||||
if (fIndex > 0) {
|
||||
file = process.argv.at(fIndex + 1);
|
||||
|
||||
if (!file) {
|
||||
throw new Error(`No file specified.`);
|
||||
}
|
||||
}
|
||||
|
||||
const transpiler1 = new Transpiler({
|
||||
file: file,
|
||||
});
|
||||
|
||||
const transpiler2 = new Transpiler({
|
||||
mod: 'crm',
|
||||
path: 'client/modules/crm',
|
||||
})).process();
|
||||
file: file,
|
||||
});
|
||||
|
||||
const result1 = transpiler1.process();
|
||||
const result2 = transpiler2.process();
|
||||
|
||||
let count = result1.transpiled.length + result2.transpiled.length;
|
||||
let copiedCount = result1.copied.length + result2.copied.length;
|
||||
|
||||
console.log(`\n transpiled: ${count}, copied: ${copiedCount}`)
|
||||
@@ -37,25 +37,53 @@ class Transpiler {
|
||||
* path?: string,
|
||||
* destDir?: string,
|
||||
* mod?: string,
|
||||
* file?: string,
|
||||
* }} config
|
||||
*/
|
||||
constructor(config) {
|
||||
this.path = (config.path ?? 'client') + '/src';
|
||||
this.destDir = config.destDir || 'client/lib/transpiled';
|
||||
this.mod = config.mod;
|
||||
this.file = config.file;
|
||||
|
||||
this.contentsCache = {};
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {{
|
||||
* transpiled: string[],
|
||||
* copied: string[],
|
||||
* }}
|
||||
*/
|
||||
process() {
|
||||
let allFiles = globSync(this.path + '/**/*.js')
|
||||
.map(file => file.replaceAll('\\', '/'));
|
||||
|
||||
if (this.file) {
|
||||
let file = this.file.replaceAll('\\', '/');
|
||||
|
||||
if (!allFiles.includes(file)) {
|
||||
return {
|
||||
transpiled: [],
|
||||
copied: [],
|
||||
};
|
||||
}
|
||||
|
||||
allFiles = [file];
|
||||
}
|
||||
|
||||
let files = allFiles.filter(file => this.#isToBeTranspiled(file));
|
||||
let otherFiles = allFiles.filter(file => !files.includes(file));
|
||||
|
||||
let otherFiles = !this.file ?
|
||||
allFiles.filter(file => !files.includes(file)) : [];
|
||||
|
||||
files.forEach(file => this.#processFile(file));
|
||||
otherFiles.forEach(file => this.#copyFile(file));
|
||||
|
||||
return {
|
||||
transpiled: files,
|
||||
copied: otherFiles,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
Reference in New Issue
Block a user