mirror of
https://github.com/espocrm/espocrm.git
synced 2026-03-03 02:47:03 +00:00
libs without src support
This commit is contained in:
@@ -27,33 +27,48 @@
|
||||
************************************************************************/
|
||||
|
||||
const BuildUtils = {
|
||||
/**
|
||||
* @param {Array} libs
|
||||
* @return {{src: string, file: string}[]}
|
||||
*/
|
||||
getBundleLibList: function(libs) {
|
||||
const list = [];
|
||||
|
||||
libs.forEach(item => {
|
||||
if (!item.bundle) {
|
||||
return;
|
||||
const getFile = item => {
|
||||
if (item.amdId) {
|
||||
return item.amdId + '.js';
|
||||
}
|
||||
|
||||
if (item.files) {
|
||||
item.files.forEach(item => list.push(item.src));
|
||||
return item.src.split('/').slice(-1);
|
||||
};
|
||||
|
||||
return;
|
||||
}
|
||||
libs.filter(item => item.bundle)
|
||||
.forEach(item => {
|
||||
if (item.files) {
|
||||
item.files.forEach(item => list.push({
|
||||
src: item.src,
|
||||
file: getFile(item),
|
||||
}));
|
||||
|
||||
if (!item.src) {
|
||||
throw new Error("No lib src.");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
list.push(item.src);
|
||||
});
|
||||
if (!item.src) {
|
||||
return;
|
||||
}
|
||||
|
||||
list.push({
|
||||
src: item.src,
|
||||
file: getFile(item),
|
||||
});
|
||||
});
|
||||
|
||||
return list;
|
||||
},
|
||||
|
||||
getPreparedBundleLibList: function (libs) {
|
||||
return BuildUtils.getBundleLibList(libs)
|
||||
.map(file => 'client/lib/original/' + file.split('/').slice(-1));
|
||||
.map(item => 'client/lib/original/' + item.file);
|
||||
},
|
||||
|
||||
destToOriginalDest: function (dest) {
|
||||
@@ -114,7 +129,7 @@ const BuildUtils = {
|
||||
}
|
||||
|
||||
if (!item.src) {
|
||||
throw new Error("No lib src.");
|
||||
return;
|
||||
}
|
||||
|
||||
list.push({
|
||||
|
||||
22
js/diff.js
22
js/diff.js
@@ -556,19 +556,27 @@ class Diff
|
||||
.parse(
|
||||
cp.execSync("git show " + commitHash + ":frontend/libs.json").toString() || '[]'
|
||||
)
|
||||
.filter(item => item.bundle);
|
||||
.filter(item => item.bundle)
|
||||
.filter(item => item.src || item.files);
|
||||
}
|
||||
|
||||
let libNewDataList = require(this.espoPath + '/frontend/libs.json')
|
||||
.filter(item => !item.bundle);
|
||||
|
||||
let bundledNewDataList = require(this.espoPath + '/frontend/libs.json')
|
||||
.filter(item => item.bundle);
|
||||
.filter(item => item.bundle)
|
||||
.filter(item => item.src || item.files);
|
||||
|
||||
let resolveItemDest = item =>
|
||||
item.dest || 'client/lib/' + item.src.split('/').pop();
|
||||
|
||||
let resolveBundledItemDest = item => 'client/lib/original/' + item.src.split('/').pop();
|
||||
const resolveBundledItemDest = item => {
|
||||
if (item.amdId) {
|
||||
return `'client/lib/original/${item.amdId}.js`;
|
||||
}
|
||||
|
||||
return 'client/lib/original/' + item.src.split('/').pop();
|
||||
};
|
||||
|
||||
let resolveItemName = item => {
|
||||
if (item.name) {
|
||||
@@ -759,6 +767,10 @@ class Diff
|
||||
return;
|
||||
}
|
||||
|
||||
if (!item.src) {
|
||||
return;
|
||||
}
|
||||
|
||||
data.filesToCopy.push(resolveBundledItemDest(item));
|
||||
});
|
||||
|
||||
@@ -786,6 +798,10 @@ class Diff
|
||||
return;
|
||||
}
|
||||
|
||||
if (!item.src) {
|
||||
return;
|
||||
}
|
||||
|
||||
data.filesToDelete.push(resolveBundledItemDest(item));
|
||||
});
|
||||
|
||||
|
||||
@@ -94,8 +94,7 @@ const addSuppressAmd = path => {
|
||||
fs.writeFileSync(path, contents, {encoding: 'utf-8'});
|
||||
}
|
||||
|
||||
/** @var {string[]} */
|
||||
const libSrcList = buildUtils.getBundleLibList(libs);
|
||||
const bundleLibDataList = buildUtils.getBundleLibList(libs);
|
||||
|
||||
const amdIdMap = {};
|
||||
const suppressAmdMap = {};
|
||||
@@ -114,8 +113,10 @@ libs.forEach(item => {
|
||||
amdIdMap[item.src] = 'lib!' + item.amdId;
|
||||
});
|
||||
|
||||
libSrcList.forEach(src => {
|
||||
const dest = originalLibDir + '/' + src.split('/').slice(-1);
|
||||
bundleLibDataList.forEach(item => {
|
||||
const src = item.src;
|
||||
|
||||
const dest = originalLibDir + '/' + item.file;
|
||||
|
||||
fs.copyFileSync(src, dest);
|
||||
stripSourceMappingUrl(dest);
|
||||
|
||||
Reference in New Issue
Block a user