From 5c7a3ee19a068fceec78721769b75681b35e4a3c Mon Sep 17 00:00:00 2001 From: Luiz Silva Date: Tue, 7 May 2024 08:10:35 -0300 Subject: [PATCH] =?UTF-8?q?melhorias=20em=20est=C3=A1ticos?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dist/index.js | 2 +- dist/index.js.map | 2 +- ferramentas/listar_arquivos.ts | 74 ++++++++------- ferramentas/rodar_servidor.tsx | 158 ++++++++++++++++----------------- package.json | 81 ++++++++--------- pnpm-lock.yaml | 14 +++ src/index.ts | 2 +- 7 files changed, 173 insertions(+), 160 deletions(-) diff --git a/dist/index.js b/dist/index.js index 8cdf65d..aa254eb 100644 --- a/dist/index.js +++ b/dist/index.js @@ -4,7 +4,7 @@ exports.estaticos = exports.Prefixos = void 0; exports.Prefixos = { relativo: "/estaticos", "link-local": "http://localhost:5020/estaticos", - "link-servidor": "https://carro-de-boi.idz.one/estaticos", + "link-servidor": "https://carro-de-boi-idz-one.b-cdn.net/estaticos", "relativo-disco": "~estaticos/estaticos", }; /** diff --git a/dist/index.js.map b/dist/index.js.map index 4cae0f0..87ebdfa 100644 --- a/dist/index.js.map +++ b/dist/index.js.map @@ -1 +1 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAa,QAAA,QAAQ,GAAG;IACvB,QAAQ,EAAE,YAAY;IACtB,YAAY,EAAE,iCAAiC;IAC/C,eAAe,EAAE,wCAAwC;IACzD,gBAAgB,EAAE,sBAAsB;CACxC,CAAC;AAEF;;;;;;;;GAQG;AACI,MAAM,SAAS,GAAG,CAAC,OAA8B,EAAE,EAAE;IAC3D,MAAM,OAAO,GAAG,gBAAQ,CAAC,OAAO,CAAC,IAAI,gBAAQ,CAAC,QAAQ,CAAC;IAEvD,OAAO;QACN,KAAK,EAAE;YACN,gBAAgB,EAAE;gBACjB,kCAAkC,EAAE,GAAG,OAAO,wDAAwD;gBACtG,+BAA+B,EAAE,GAAG,OAAO,qDAAqD;gBAChG,oCAAoC,EAAE,GAAG,OAAO,0DAA0D;gBAC1G,oCAAoC,EAAE,GAAG,OAAO,0DAA0D;gBAC1G,2CAA2C,EAAE,GAAG,OAAO,iEAAiE;gBACxH,2CAA2C,EAAE,GAAG,OAAO,iEAAiE;aACxH;YACD,qBAAqB,EAAE;gBACtB,uCAAuC,EAAE,GAAG,OAAO,kEAAkE;gBACrH,uCAAuC,EAAE,GAAG,OAAO,kEAAkE;gBACrH,yCAAyC,EAAE,GAAG,OAAO,oEAAoE;gBACzH,yCAAyC,EAAE,GAAG,OAAO,oEAAoE;gBACzH,gDAAgD,EAAE,GAAG,OAAO,2EAA2E;gBACvI,gDAAgD,EAAE,GAAG,OAAO,2EAA2E;gBACvI,qCAAqC,EAAE,GAAG,OAAO,gEAAgE;gBACjH,qCAAqC,EAAE,GAAG,OAAO,gEAAgE;aACjH;SACD;QACD,OAAO,EAAE;YACR,iBAAiB,EAAE,GAAG,OAAO,0BAA0B;YACvD,qBAAqB,EAAE,GAAG,OAAO,8BAA8B;SAC/D;QACD,IAAI,EAAE;YACL,UAAU,EAAE,GAAG,OAAO,gBAAgB;SACtC;QACD,KAAK,EAAE;YACN,mBAAmB,EAAE,GAAG,OAAO,0BAA0B;YACzD,iBAAiB,EAAE,GAAG,OAAO,wBAAwB;SACrD;KACD,CAAC;AACH,CAAC,CAAC;AApCW,QAAA,SAAS,aAoCpB"} \ No newline at end of file +{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAa,QAAA,QAAQ,GAAG;IACvB,QAAQ,EAAE,YAAY;IACtB,YAAY,EAAE,iCAAiC;IAC/C,eAAe,EAAE,kDAAkD;IACnE,gBAAgB,EAAE,sBAAsB;CACxC,CAAC;AAEF;;;;;;;;GAQG;AACI,MAAM,SAAS,GAAG,CAAC,OAA8B,EAAE,EAAE;IAC3D,MAAM,OAAO,GAAG,gBAAQ,CAAC,OAAO,CAAC,IAAI,gBAAQ,CAAC,QAAQ,CAAC;IAEvD,OAAO;QACN,KAAK,EAAE;YACN,gBAAgB,EAAE;gBACjB,kCAAkC,EAAE,GAAG,OAAO,wDAAwD;gBACtG,+BAA+B,EAAE,GAAG,OAAO,qDAAqD;gBAChG,oCAAoC,EAAE,GAAG,OAAO,0DAA0D;gBAC1G,oCAAoC,EAAE,GAAG,OAAO,0DAA0D;gBAC1G,2CAA2C,EAAE,GAAG,OAAO,iEAAiE;gBACxH,2CAA2C,EAAE,GAAG,OAAO,iEAAiE;aACxH;YACD,qBAAqB,EAAE;gBACtB,uCAAuC,EAAE,GAAG,OAAO,kEAAkE;gBACrH,uCAAuC,EAAE,GAAG,OAAO,kEAAkE;gBACrH,yCAAyC,EAAE,GAAG,OAAO,oEAAoE;gBACzH,yCAAyC,EAAE,GAAG,OAAO,oEAAoE;gBACzH,gDAAgD,EAAE,GAAG,OAAO,2EAA2E;gBACvI,gDAAgD,EAAE,GAAG,OAAO,2EAA2E;gBACvI,qCAAqC,EAAE,GAAG,OAAO,gEAAgE;gBACjH,qCAAqC,EAAE,GAAG,OAAO,gEAAgE;aACjH;SACD;QACD,OAAO,EAAE;YACR,iBAAiB,EAAE,GAAG,OAAO,0BAA0B;YACvD,qBAAqB,EAAE,GAAG,OAAO,8BAA8B;SAC/D;QACD,IAAI,EAAE;YACL,UAAU,EAAE,GAAG,OAAO,gBAAgB;SACtC;QACD,KAAK,EAAE;YACN,mBAAmB,EAAE,GAAG,OAAO,0BAA0B;YACzD,iBAAiB,EAAE,GAAG,OAAO,wBAAwB;SACrD;KACD,CAAC;AACH,CAAC,CAAC;AApCW,QAAA,SAAS,aAoCpB"} \ No newline at end of file diff --git a/ferramentas/listar_arquivos.ts b/ferramentas/listar_arquivos.ts index 332d19b..d95efa7 100644 --- a/ferramentas/listar_arquivos.ts +++ b/ferramentas/listar_arquivos.ts @@ -1,25 +1,23 @@ import { globSync } from "glob"; import path from "node:path"; import fs from "node:fs"; +import { cdn_carro_de_boi } from "~comuns"; const pasta_estaticos = path.resolve(process.cwd(), "estaticos"); const pasta_src = path.resolve(process.cwd(), "src"); -import { ambiente } from "./ambiente"; -const { PREFIXO, PORTA } = ambiente; -const enderecoLocal = `http://127.0.0.1:${PORTA}${PREFIXO}`; export const gerar = (async () => { - // listar arquivos da pasta estáticos - const files = globSync(`${pasta_estaticos}/**/*`, { nodir: true }); + // listar arquivos da pasta estáticos + const files = globSync(`${pasta_estaticos}/**/*`, { nodir: true }); - const arquivo_ts = ` + const arquivo_ts = ` export const Prefixos = { relativo: "/estaticos", "link-local": "http://localhost:5020/estaticos", - "link-servidor": "https://carro-de-boi.idz.one/estaticos", + "link-servidor": "${cdn_carro_de_boi}/estaticos", "relativo-disco": "~estaticos/estaticos", }; @@ -36,7 +34,7 @@ export const gerar = (async () => { const prefixo = Prefixos[caminho] || Prefixos.relativo; return ${(() => { - /* + /* ${files .map((f) => f.slice(pasta_estaticos.length)) @@ -45,43 +43,43 @@ export const gerar = (async () => { */ - type tp = { - [key: string]: string | tp; - }; + type tp = { + [key: string]: string | tp; + }; - const arquivos = {} as tp; + const arquivos = {} as tp; - for (const arquivo of files) { - const partes = arquivo - .slice(pasta_estaticos.length) - .split("/") - .slice(1); - let pasta = arquivos; - for (const [i, parte] of partes.entries()) { - if (i === partes.length - 1) { - pasta[parte] = `~~~\${prefixo}${encodeURI( - arquivo.slice(pasta_estaticos.length), - )}~~~`; - } else { - pasta[parte] = pasta[parte] || {}; - pasta = pasta[parte] as tp; - } - } - } + for (const arquivo of files) { + const partes = arquivo + .slice(pasta_estaticos.length) + .split("/") + .slice(1); + let pasta = arquivos; + for (const [i, parte] of partes.entries()) { + if (i === partes.length - 1) { + pasta[parte] = `~~~\${prefixo}${encodeURI( + arquivo.slice(pasta_estaticos.length), + )}~~~`; + } else { + pasta[parte] = pasta[parte] || {}; + pasta = pasta[parte] as tp; + } + } + } - return JSON.stringify(arquivos, null, 2) - .replace(/"~~~/g, "`") - .replace(/~~~"/g, "`"); - })()}; + return JSON.stringify(arquivos, null, 2) + .replace(/"~~~/g, "`") + .replace(/~~~"/g, "`"); + })()}; }; `; - // escrever arquivo - fs.writeFileSync(path.resolve(pasta_src, "index.ts"), arquivo_ts); + // escrever arquivo + fs.writeFileSync(path.resolve(pasta_src, "index.ts"), arquivo_ts); })(); if (process.argv.includes("gerar")) { - gerar.then(() => { - console.log("Arquivo gerado com sucesso"); - }); + gerar.then(() => { + console.log("Arquivo gerado com sucesso"); + }); } diff --git a/ferramentas/rodar_servidor.tsx b/ferramentas/rodar_servidor.tsx index 67a2ec3..441702c 100644 --- a/ferramentas/rodar_servidor.tsx +++ b/ferramentas/rodar_servidor.tsx @@ -13,95 +13,95 @@ const { PORTA, PREFIXO } = ambiente; const _iframe = String(Math.random()); const criarHtml = (entrada: { - [key: string]: string | {}; + // biome-ignore lint/complexity/noBannedTypes: + [key: string]: string | {}; }): React.JSX.Element[] => { - const retorno = [] as React.JSX.Element[]; + const retorno = [] as React.JSX.Element[]; - for (const [k, v] of Object.entries(entrada)) { - if (typeof v === "string") { - retorno.push( -

- - {v} - -

, - ); - } else { - retorno.push( -
-
- {k} - {criarHtml(v)} -
-
, - ); - } - } + for (const [k, v] of Object.entries(entrada)) { + if (typeof v === "string") { + retorno.push( +

+ + {v} + +

, + ); + } else { + retorno.push( +
+
+ {k} + {criarHtml(v)} +
+
, + ); + } + } - return retorno; + return retorno; }; gerar.then(() => { - const app = express(); - app.use(express.json()); - app.use(express.urlencoded()); + const app = express(); + app.use(express.json()); + app.use(express.urlencoded()); - app.get([PREFIXO, `${PREFIXO}/`], (req, res) => { - const html = ( - - - Arquivos Estáticos - {" "} - -

Arquivos Estáticos

- - - -
{criarHtml(estaticos("relativo"))} -