build: update npm install command to use --legacy-peer-deps

This change modifies the build scripts to use --legacy-peer-deps flag when installing npm dependencies to resolve potential peer dependency conflicts during the build process. The change is applied to both bash (build.sh) and batch (build.bat) build scripts.
This commit is contained in:
Luiz Costa
2025-11-18 10:23:55 -03:00
parent 20129a1ac7
commit ac4f232e5e
787 changed files with 82341 additions and 121690 deletions
+25 -21
View File
@@ -1,10 +1,11 @@
const path = require('path');
const fs = require('fs');
const Keyv = require('keyv');
const { writeJSON, tryParse } = require('./utils');
const { del } = require('./del');
var path = require('path');
var fs = require('fs');
var Keyv = require('keyv');
var utils = require('./utils');
var del = require('./del');
var writeJSON = utils.writeJSON;
const cache = {
var cache = {
/**
* Load a cache identified by the given Id. If the element does not exists, then initialize an empty
* cache storage. If specified `cacheDir` will be used as the directory to persist the data to. If omitted
@@ -15,16 +16,16 @@ const cache = {
* @param [cacheDir] {String} directory for the cache entry
*/
load: function (docId, cacheDir) {
const me = this;
var me = this;
me.keyv = new Keyv();
me.__visited = {};
me.__persisted = {};
me._pathToFile = cacheDir ? path.resolve(cacheDir, docId) : path.resolve(__dirname, '../.cache/', docId);
if (fs.existsSync(me._pathToFile)) {
me._persisted = tryParse(me._pathToFile, {});
me._persisted = utils.tryParse(me._pathToFile, {});
}
},
@@ -34,6 +35,7 @@ const cache = {
set _persisted(value) {
this.__persisted = value;
this.keyv.set('persisted', value);
},
get _visited() {
@@ -42,6 +44,7 @@ const cache = {
set _visited(value) {
this.__visited = value;
this.keyv.set('visited', value);
},
/**
@@ -50,9 +53,9 @@ const cache = {
* @param {String} pathToFile the path to the file containing the info for the cache
*/
loadFile: function (pathToFile) {
const me = this;
const dir = path.dirname(pathToFile);
const fName = path.basename(pathToFile);
var me = this;
var dir = path.dirname(pathToFile);
var fName = path.basename(pathToFile);
me.load(fName, dir);
},
@@ -106,10 +109,10 @@ const cache = {
* @private
*/
_prune: function () {
const me = this;
const obj = {};
var me = this;
var obj = {};
const keys = Object.keys(me._visited);
var keys = Object.keys(me._visited);
// no keys visited for either get or set value
if (keys.length === 0) {
@@ -131,7 +134,8 @@ const cache = {
* @method save
*/
save: function (noPrune) {
const me = this;
var me = this;
!noPrune && me._prune();
writeJSON(me._pathToFile, me._persisted);
},
@@ -149,7 +153,7 @@ const cache = {
* @method destroy
*/
destroy: function () {
const me = this;
var me = this;
me._visited = {};
me._persisted = {};
@@ -180,13 +184,13 @@ module.exports = {
* @returns {cache} cache instance
*/
create: function (docId, cacheDir) {
const obj = Object.create(cache);
var obj = Object.create(cache);
obj.load(docId, cacheDir);
return obj;
},
createFromFile: function (filePath) {
const obj = Object.create(cache);
var obj = Object.create(cache);
obj.loadFile(filePath);
return obj;
},
@@ -199,7 +203,7 @@ module.exports = {
* @returns {Boolean} true if the cache folder was deleted. False otherwise
*/
clearCacheById: function (docId, cacheDir) {
const filePath = cacheDir ? path.resolve(cacheDir, docId) : path.resolve(__dirname, '../.cache/', docId);
var filePath = cacheDir ? path.resolve(cacheDir, docId) : path.resolve(__dirname, '../.cache/', docId);
return del(filePath);
},
/**
@@ -208,7 +212,7 @@ module.exports = {
* @returns {Boolean} true if the cache folder was deleted. False otherwise
*/
clearAll: function (cacheDir) {
const filePath = cacheDir ? path.resolve(cacheDir) : path.resolve(__dirname, '../.cache/');
var filePath = cacheDir ? path.resolve(cacheDir) : path.resolve(__dirname, '../.cache/');
return del(filePath);
},
};
+10 -27
View File
@@ -1,30 +1,13 @@
const fs = require('fs');
const path = require('path');
function del(targetPath) {
if (!fs.existsSync(targetPath)) {
return false;
}
try {
if (fs.statSync(targetPath).isDirectory()) {
// If it's a directory, delete its contents first
fs.readdirSync(targetPath).forEach(file => {
const curPath = path.join(targetPath, file);
if (fs.statSync(curPath).isFile()) {
fs.unlinkSync(curPath); // Delete file
}
});
fs.rmdirSync(targetPath); // Delete the now-empty directory
} else {
fs.unlinkSync(targetPath); // If it's a file, delete it directly
}
var rimraf = require('rimraf').sync;
var fs = require('fs');
module.exports = function del(file) {
if (fs.existsSync(file)) {
//if rimraf doesn't throw then the file has been deleted or didn't exist
rimraf(file, {
glob: false,
});
return true;
} catch (error) {
console.error(`Error while deleting ${targetPath}: ${error.message}`);
}
}
module.exports = { del };
return false;
};
+41 -39
View File
@@ -1,42 +1,44 @@
const fs = require('fs');
const path = require('path');
const flatted = require('flatted');
var fs = require('fs');
var path = require('path');
var flatted = require('flatted');
function tryParse(filePath, defaultValue) {
let result;
try {
result = readJSON(filePath);
} catch (ex) {
result = defaultValue;
}
return result;
}
module.exports = {
tryParse: function (filePath, defaultValue) {
var result;
try {
result = this.readJSON(filePath);
} catch (ex) {
result = defaultValue;
}
return result;
},
/**
* Read json file synchronously using flatted
*
* @param {String} filePath Json filepath
* @returns {*} parse result
*/
function readJSON(filePath) {
return flatted.parse(
fs.readFileSync(filePath, {
encoding: 'utf8',
})
);
}
/**
* Read json file synchronously using flatted
*
* @method readJSON
* @param {String} filePath Json filepath
* @returns {*} parse result
*/
readJSON: function (filePath) {
return flatted.parse(
fs.readFileSync(filePath, {
encoding: 'utf8',
})
);
},
/**
* Write json file synchronously using circular-json
*
* @param {String} filePath Json filepath
* @param {*} data Object to serialize
*/
function writeJSON(filePath, data) {
fs.mkdirSync(path.dirname(filePath), {
recursive: true,
});
fs.writeFileSync(filePath, flatted.stringify(data));
}
module.exports = { tryParse, readJSON, writeJSON };
/**
* Write json file synchronously using circular-json
*
* @method writeJSON
* @param {String} filePath Json filepath
* @param {*} data Object to serialize
*/
writeJSON: function (filePath, data) {
fs.mkdirSync(path.dirname(filePath), {
recursive: true,
});
fs.writeFileSync(filePath, flatted.stringify(data));
},
};