removido bun
This commit is contained in:
parent
3cf79e06e4
commit
30f581db65
13 changed files with 2317 additions and 1706 deletions
92
dist-back/mapear_pasta.js
Normal file
92
dist-back/mapear_pasta.js
Normal file
|
|
@ -0,0 +1,92 @@
|
|||
var __create = Object.create;
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __getProtoOf = Object.getPrototypeOf;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
||||
// If the importer is in node compatibility mode or this is not an ESM
|
||||
// file that has been converted to a CommonJS file using a Babel-
|
||||
// compatible transform (i.e. "__esModule" has not been set), then set
|
||||
// "default" to the CommonJS "module.exports" for node compatibility.
|
||||
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
||||
mod
|
||||
));
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
var mapear_pasta_exports = {};
|
||||
__export(mapear_pasta_exports, {
|
||||
mapearPasta: () => mapearPasta
|
||||
});
|
||||
module.exports = __toCommonJS(mapear_pasta_exports);
|
||||
var import_node_fs = __toESM(require("node:fs"));
|
||||
var import_node_path = __toESM(require("node:path"));
|
||||
var import_glob = require("glob");
|
||||
const mapearPasta = ({
|
||||
prefixos,
|
||||
pasta,
|
||||
arquivoDestino,
|
||||
variavel
|
||||
}) => {
|
||||
const pasta_estaticos = pasta.endsWith("/") ? pasta : `${pasta}/`;
|
||||
if (!import_node_fs.default.existsSync(pasta_estaticos))
|
||||
throw new Error(`Pasta ${pasta_estaticos} n\xE3o existe`);
|
||||
const _gerar = (async () => {
|
||||
const files = (0, import_glob.globSync)(`${pasta_estaticos}**/*`, { nodir: true });
|
||||
const arquivo_ts = `
|
||||
|
||||
|
||||
const Prefixos = {
|
||||
${Object.entries(prefixos).map(([k, v]) => `"${k}": "${v.replace(/"/g, '\\"')}"`).join(",\n")}
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
* @param caminho
|
||||
* @returns String
|
||||
*/
|
||||
export const ${variavel || "estaticos"} = (caminho: keyof typeof Prefixos) => {
|
||||
const prefixo = Prefixos[caminho];
|
||||
|
||||
return ${(() => {
|
||||
const arquivos = {};
|
||||
for (const arquivo of files) {
|
||||
const partes = arquivo.slice(pasta_estaticos.length).split("/");
|
||||
let pasta2 = arquivos;
|
||||
for (const [i, parte] of partes.entries()) {
|
||||
if (i === partes.length - 1) {
|
||||
pasta2[parte] = `~~~\${prefixo}${encodeURI(
|
||||
arquivo.slice(pasta_estaticos.length - 1)
|
||||
)}~~~`;
|
||||
} else {
|
||||
pasta2[parte] = pasta2[parte] || {};
|
||||
pasta2 = pasta2[parte];
|
||||
}
|
||||
}
|
||||
}
|
||||
return JSON.stringify(arquivos, null, 2).replace(/"~~~/g, "`").replace(/~~~"/g, "`");
|
||||
})()};
|
||||
};
|
||||
`;
|
||||
const pastaDestino = import_node_path.default.dirname(arquivoDestino);
|
||||
if (!import_node_fs.default.existsSync(pastaDestino)) {
|
||||
import_node_fs.default.mkdirSync(pastaDestino, { recursive: true });
|
||||
}
|
||||
import_node_fs.default.writeFileSync(arquivoDestino, arquivo_ts);
|
||||
})();
|
||||
};
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
mapearPasta
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue