diff --git a/paths.js b/paths.js deleted file mode 100644 index 84ee31a8a..000000000 --- a/paths.js +++ /dev/null @@ -1,37 +0,0 @@ -const path = require("path"); - -// Resolve alias -const resolveTo = to => path.join(__dirname, to); - -// Export build paths -module.exports = { - "root": resolveTo("./"), - "package": resolveTo("./package.json"), - "modules": resolveTo("./node_modules"), - "distributions": resolveTo("./distributions"), - "release": resolveTo("./release"), - "public": resolveTo("./public"), - "packages": resolveTo("./packages"), - "icons": resolveTo("./icons"), - //"configs": { - // "colors": "./packages/siimple-colors/colors.json", - // "icons": "./packages/siimple-icons/icons.json", - //}, - //Packages folders - //"packages": { - // "folder": packages, - // "colors": path.join(packages, "siimple-colors"), - // "icons": path.join(packages, "siimple-icons"), - // "lib": path.join(packages, "siimple-lib"), - // "modules": path.join(packages, "siimple-modules"), - // "applications": path.join(packages, "applications") - //}, - ////Colors sources - //"colors": { - // //"lib": path.join(root, "scss", "plugins", "colors", "index.scss"), - // "source": path.join(packages, "siimple-colors", "colors.json"), - //}, - //Legacy paths - "dist": resolveTo("./distributions") -}; - diff --git a/scripts/banner.js b/scripts/banner.js deleted file mode 100644 index 9126716cd..000000000 --- a/scripts/banner.js +++ /dev/null @@ -1,15 +0,0 @@ -module.exports = function () { - let content = []; - content.push("//"); - content.push("// WARNING: THIS FILE IS AUTO-GENERATED. DO NOT EDIT IT."); - content.push("//"); - content.push("// You can generate this file running the following command from the project root:"); - content.push("// $ make build"); - content.push("// Found any bug on this file? Submit a new issue: github.com/siimple/siimple/issues"); - content.push("// Need help? Join our discussion forum: github.com/siimple/siimple/discussions"); - content.push("//"); - content.push(""); - return content.join("\n"); -}; - - diff --git a/scripts/upgrade.js b/scripts/upgrade.js deleted file mode 100644 index 8c05e310f..000000000 --- a/scripts/upgrade.js +++ /dev/null @@ -1,24 +0,0 @@ -const through = require("through2"); - -// Upgrade the version in all package.json files -module.exports = (options) => { - const packages = options.packages || {}; - return through.obj((file, enc, callback) => { - const content = JSON.parse(file.contents.toString()); - const name = content.name; //Get package name - if (typeof packages[name] === "undefined" || content.version === packages[name]) { - return callback(); //Nothing to update - } - //Update package.json fields - content.version = packages[name]; - Object.keys(content.dependencies || {}).forEach((n) => { - if (typeof packages[n] !== "undefined") { - content.dependencies[n] = `^${packages[n]}`; - } - }); - //Save package.json file - file.contents = Buffer.from(JSON.stringify(content, null, " ")); - return callback(null, file); - }); -}; - diff --git a/scripts/utils.js b/scripts/utils.js deleted file mode 100644 index 863c336a5..000000000 --- a/scripts/utils.js +++ /dev/null @@ -1,171 +0,0 @@ -const fs = require("fs"); -const path = require("path"); -const args = require("get-args"); - -//Export constants values -module.exports.endl = "\n"; - -// Convert he provided value to array -module.exports.toArray = (value) => { - return [value].flat(2); -}; - -//Check if the provided value is an string -module.exports.isString = function (value) { - return typeof value === "string"; -}; - -//Check if the provided value is a valid object -module.exports.isObject = function (value) { - return typeof value === "object" && value !== null; -}; - -//Get env variables -module.exports.getEnv = function (callback) { - return callback(args().options || {}); -}; - -//Get a list with all packages available -module.exports.getPackages = function (parent) { - let pkgs = {}; - fs.readdirSync(parent, "utf8").forEach(function (folderName) { - let folderPath = path.join(parent, folderName); - let pkgPath = path.join(folderPath, "package.json"); - //Check if path is not a directory - if (fs.lstatSync(folderPath).isDirectory() === false) { - return null; - } - //Check for no package.json - if (fs.existsSync(pkgPath) === false) { - return null; - } - //Read the package content - let content = JSON.parse(fs.readFileSync(pkgPath, "utf8")); - //Save the package metadata - pkgs[content.name] = content; - }); - //Return the list of available packages - return pkgs; -}; - -//Read a JSON file -module.exports.readJSON = function (file) { - return JSON.parse(fs.readFileSync(file, "utf8")); -}; - -//Write a JSON file -module.exports.writeJSON = function (file, content) { - return fs.writeFileSync(file, JSON.stringify(content, null, " "), "utf8"); -}; - -//For displaying basic logs -module.exports.log = { - "info": (message) => { - return console.log(`[INFO] ${message}`); - }, - "warn": (message) => { - return console.warn(`[WARNING] ${message}`); - }, - "error": (message) => { - console.error(`[ERROR] ${message}`); - return process.exit(1); //Stop process - }, -}; - -//Remove a folder recursive -module.exports.rmdir = function (folder) { - if (fs.existsSync(folder) && fs.statSync(folder).isDirectory()) { - return fs.rmdirSync(folder, {"recursive": true}); - } -}; - -//Create a folder recursive -module.exports.mkdir = function (folder) { - if (fs.existsSync(folder) === false) { - return fs.mkdirSync(folder, {"recursive": true}); - } -}; - -//Get file size -module.exports.fileSize = function (file) { - return (fs.statSync(file).size / 1024).toFixed(2) + " KB"; - // Convert the file size to megabytes (optional) - // let fileSizeInMegabytes = fileSizeInBytes / (1024*1024); -}; - -//Encode the provided file path using safe url base64 encoding -module.exports.encodePath = function (filePath) { - let b64 = Buffer.from(filePath).toString("base64"); - return b64.replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, ""); -}; - -//Map special chars to html codes -let htmlEscapes = { - "&": "&", - "<": "<", - ">": ">", - '"': """, - "'": "'" -}; - -//Escape html >> converts '<', '>', '&', '"' and "'" chars to html codes -module.exports.escapeHtml = function (unsafe) { - return unsafe.replace(/[&<>"']/g, function (match) { - return htmlEscapes[match]; - }); -}; - -//Non closed html tags -let nonClosedHtmlTags = ["meta", "link", "hr", "img", "br"]; - -//Build attributes -let buildAttributes = function (attr) { - if (typeof attr !== "object" || attr === null) { - return []; - } - //Return parsed attributes - let parsedAttributes = []; - Object.keys(attr).forEach(function (key) { - if (typeof attr[key] !== "string") { - return null; //No valid attribute - } - let keyname = (key === "className") ? "class" : key; //Parse attribute - parsedAttributes.push(`${keyname}="${attr[key]}"`); //Save attribute - }); - //Return joined attributes - return parsedAttributes.join(" "); -}; - -//Create a new html string element -module.exports.createElement = function (tagname, attr, children) { - let attributes = buildAttributes(attr); //.join(" "); - let content = (typeof children === "string") ? children : ""; //Parse content - //Check for tag without children - if (nonClosedHtmlTags.indexOf(tagname) > -1) { - return `<${tagname} ${attributes} />`; - } - //Return a closed tag - return `<${tagname} ${attributes}>${content}`; -}; - -//Walkdir iterator -let walkDir = function (folder, base, extlist, callback) { - let folderPath = path.resolve(folder, base); - fs.readdirSync(folderPath, "utf8").forEach(function (file) { - let fullPath = path.join(folderPath, file); - //Check if the file has the provided extension - if (extlist.indexOf(path.extname(file)) !== -1) { - return callback(path.join(base, file)); - } - //Check for a directory - else if (fs.statSync(fullPath).isDirectory() === true) { - return walkDir(folder, path.join(base, file), extlist, callback); - } - }); -}; - -//Export walkdir utility -module.exports.walkdir = function (folder, extlist, callback) { - return walkDir(folder, "./", extlist, callback); -}; -