.
This commit is contained in:
parent
e8eda7ff32
commit
127061d04c
11 changed files with 912 additions and 914 deletions
25
biome.json
25
biome.json
|
|
@ -1,16 +1,15 @@
|
||||||
{
|
{
|
||||||
"$schema": "node_modules/@biomejs/biome/configuration_schema.json",
|
"$schema": "node_modules/@biomejs/biome/configuration_schema.json",
|
||||||
|
"extends": ["node_modules/p-comuns/Documentos/biome.json"],
|
||||||
|
|
||||||
"files": {
|
"files": {},
|
||||||
"ignore": []
|
"formatter": { "formatWithErrors": true },
|
||||||
},
|
"linter": {
|
||||||
"formatter": { "formatWithErrors": true },
|
"enabled": true,
|
||||||
"linter": {
|
"rules": {
|
||||||
"enabled": true,
|
"complexity": {
|
||||||
"rules": {
|
"useLiteralKeys": "off"
|
||||||
"complexity": {
|
}
|
||||||
"useLiteralKeys": "off"
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
2
dist/index.js.map
vendored
2
dist/index.js.map
vendored
File diff suppressed because one or more lines are too long
2
dist/mapear_pasta.js
vendored
2
dist/mapear_pasta.js
vendored
|
|
@ -12,7 +12,7 @@ const mapearPasta = ({ prefixos, pasta, arquivoDestino, variavel, }) => {
|
||||||
const pasta_estaticos = pasta.endsWith("/") ? pasta : `${pasta}/`;
|
const pasta_estaticos = pasta.endsWith("/") ? pasta : `${pasta}/`;
|
||||||
if (!node_fs_1.default.existsSync(pasta_estaticos))
|
if (!node_fs_1.default.existsSync(pasta_estaticos))
|
||||||
throw new Error(`Pasta ${pasta_estaticos} não existe`);
|
throw new Error(`Pasta ${pasta_estaticos} não existe`);
|
||||||
const gerar = (async () => {
|
const _gerar = (async () => {
|
||||||
// listar arquivos da pasta estáticos
|
// listar arquivos da pasta estáticos
|
||||||
const files = (0, glob_1.globSync)(`${pasta_estaticos}**/*`, { nodir: true });
|
const files = (0, glob_1.globSync)(`${pasta_estaticos}**/*`, { nodir: true });
|
||||||
const arquivo_ts = `
|
const arquivo_ts = `
|
||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C,KAAK,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;wBAC5B,KAAK,CAAC,KAAK,CAAC,GAAG,iBAAiB,SAAS,CACvC,OAAO,CAAC,KAAK,CAAC,eAAe,CAAC,MAAM,GAAG,CAAC,CAAC,CAC1C,KAAK,CAAA;oBACR,CAAC;yBAAM,CAAC;wBACN,KAAK,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,CAAA;wBACjC,KAAK,GAAG,KAAK,CAAC,KAAK,CAAO,CAAA;oBAC5B,CAAC;gBACH,CAAC;YACH,CAAC;YAED,OAAO,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;iBACrC,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC;iBACrB,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,CAAA;QAC1B,CAAC,CAAC,EAAE;;KAEH,CAAA;QAED,iCAAiC;QACjC,MAAM,YAAY,GAAG,mBAAI,CAAC,OAAO,CAAC,cAAc,CAAC,CAAA;QACjD,IAAI,CAAC,iBAAE,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE,CAAC;YACjC,iBAAE,CAAC,SAAS,CAAC,YAAY,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;QACjD,CAAC;QAED,mBAAmB;QAEnB,iBAAE,CAAC,aAAa,CAAC,cAAc,EAAE,UAAU,CAAC,CAAA;IAC9C,CAAC,CAAC,EAAE,CAAA;AACN,CAAC,CAAA;AApFY,QAAA,WAAW,eAoFvB"}
|
||||||
|
|
@ -1,19 +1,19 @@
|
||||||
import { z } from "zod";
|
import { z } from "zod"
|
||||||
import { PORTA, PREFIXO } from "../PREFIXO";
|
import { PORTA, PREFIXO } from "../PREFIXO"
|
||||||
|
|
||||||
const validar = z
|
const validar = z
|
||||||
.object({
|
.object({
|
||||||
PORTA: z.string(),
|
PORTA: z.string(),
|
||||||
PREFIXO: z.string().regex(/^\/\w+$/),
|
PREFIXO: z.string().regex(/^\/\w+$/),
|
||||||
})
|
})
|
||||||
.safeParse({ PORTA, PREFIXO });
|
.safeParse({ PORTA, PREFIXO })
|
||||||
|
|
||||||
if ("error" in validar) {
|
if ("error" in validar) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
validar.error?.errors
|
validar.error?.errors
|
||||||
.map((erro) => `${erro.path}: ${erro.message}`)
|
.map((erro) => `${erro.path}: ${erro.message}`)
|
||||||
.join("\n"),
|
.join("\n"),
|
||||||
);
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export const ambiente = validar.data;
|
export const ambiente = validar.data
|
||||||
|
|
|
||||||
|
|
@ -1,26 +1,26 @@
|
||||||
import path from "node:path";
|
import path from "node:path"
|
||||||
import { cdn_carro_de_boi } from "p-comuns";
|
import { cdn_carro_de_boi } from "p-comuns"
|
||||||
import { mapearPasta } from "../src/mapear_pasta";
|
import { mapearPasta } from "../src/mapear_pasta"
|
||||||
|
|
||||||
const pasta_estaticos = path.resolve(process.cwd(), "estaticos");
|
const pasta_estaticos = path.resolve(process.cwd(), "estaticos")
|
||||||
const pasta_src = path.resolve(process.cwd(), "src");
|
const pasta_src = path.resolve(process.cwd(), "src")
|
||||||
const version = process.env.npm_package_version;
|
const _version = process.env.npm_package_version
|
||||||
|
|
||||||
export const gerar = (async () => {
|
export const gerar = (async () => {
|
||||||
mapearPasta({
|
mapearPasta({
|
||||||
prefixos: {
|
prefixos: {
|
||||||
relativo: "/estaticos",
|
relativo: "/estaticos",
|
||||||
"link-local": "http://localhost:5020/estaticos",
|
"link-local": "http://localhost:5020/estaticos",
|
||||||
"link-servidor": `${cdn_carro_de_boi}/estaticos`,
|
"link-servidor": `${cdn_carro_de_boi}/estaticos`,
|
||||||
node_modules: "node_modules/p-estaticos/estaticos",
|
node_modules: "node_modules/p-estaticos/estaticos",
|
||||||
},
|
},
|
||||||
arquivoDestino: path.resolve(pasta_src, "index.ts"),
|
arquivoDestino: path.resolve(pasta_src, "index.ts"),
|
||||||
pasta: pasta_estaticos,
|
pasta: pasta_estaticos,
|
||||||
});
|
})
|
||||||
})();
|
})()
|
||||||
|
|
||||||
if (process.argv.includes("gerar")) {
|
if (process.argv.includes("gerar")) {
|
||||||
gerar.then(() => {
|
gerar.then(() => {
|
||||||
console.log("Arquivo gerado com sucesso");
|
console.log("Arquivo gerado com sucesso")
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,164 +1,163 @@
|
||||||
import fs from "node:fs";
|
import fs from "node:fs"
|
||||||
import path from "node:path";
|
import path from "node:path"
|
||||||
import cors from "@fastify/cors";
|
import cors from "@fastify/cors"
|
||||||
import { renderToStaticMarkup } from "react-dom/server";
|
import fastifyStatc from "@fastify/static"
|
||||||
import { estaticos } from "../src";
|
import dayjs from "dayjs"
|
||||||
import { ambiente } from "./ambiente";
|
import Fastify from "fastify"
|
||||||
import { gerar } from "./listar_arquivos";
|
import type React from "react"
|
||||||
|
import { renderToStaticMarkup } from "react-dom/server"
|
||||||
|
import { estaticos } from "../src"
|
||||||
|
import { ambiente } from "./ambiente"
|
||||||
|
import { gerar } from "./listar_arquivos"
|
||||||
|
|
||||||
// biome-ignore lint/style/useImportType: <explanation>
|
const { PORTA, PREFIXO } = ambiente
|
||||||
import React, {} from "react";
|
|
||||||
|
|
||||||
import fastifyStatc from "@fastify/static";
|
const _iframe = String(Math.random())
|
||||||
import dayjs from "dayjs";
|
|
||||||
import Fastify, {} from "fastify";
|
|
||||||
|
|
||||||
const { PORTA, PREFIXO } = ambiente;
|
|
||||||
|
|
||||||
const _iframe = String(Math.random());
|
|
||||||
|
|
||||||
const criarHtml = (entrada: {
|
const criarHtml = (entrada: {
|
||||||
// biome-ignore lint/complexity/noBannedTypes: <explanation>
|
[key: string]: string | {}
|
||||||
[key: string]: string | {};
|
|
||||||
}): React.JSX.Element[] => {
|
}): React.JSX.Element[] => {
|
||||||
const retorno = [] as React.JSX.Element[];
|
const retorno = [] as React.JSX.Element[]
|
||||||
|
|
||||||
for (const [k, v] of Object.entries(entrada)) {
|
for (const [k, v] of Object.entries(entrada)) {
|
||||||
if (typeof v === "string") {
|
if (typeof v === "string") {
|
||||||
retorno.push(
|
retorno.push(
|
||||||
<p key={Math.random()}>
|
<p key={Math.random()}>
|
||||||
<a target={_iframe} href={`${v}?aleatório=${Math.random()}`}>
|
<a
|
||||||
{v}
|
target={_iframe}
|
||||||
</a>
|
href={`${v}?aleatório=${Math.random()}`}
|
||||||
</p>,
|
>
|
||||||
);
|
{v}
|
||||||
} else {
|
</a>
|
||||||
retorno.push(
|
</p>,
|
||||||
<div
|
)
|
||||||
key={Math.random()}
|
} else {
|
||||||
style={{
|
retorno.push(
|
||||||
margin: 10,
|
<div
|
||||||
padding: 5,
|
key={Math.random()}
|
||||||
borderColor: "black",
|
style={{
|
||||||
borderWidth: "1px",
|
margin: 10,
|
||||||
borderStyle: "solid",
|
padding: 5,
|
||||||
}}
|
borderColor: "black",
|
||||||
>
|
borderWidth: "1px",
|
||||||
<details>
|
borderStyle: "solid",
|
||||||
<summary>{k}</summary>
|
}}
|
||||||
{criarHtml(v)}
|
>
|
||||||
</details>
|
<details>
|
||||||
</div>,
|
<summary>{k}</summary>
|
||||||
);
|
{criarHtml(v)}
|
||||||
}
|
</details>
|
||||||
}
|
</div>,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return retorno;
|
return retorno
|
||||||
};
|
}
|
||||||
|
|
||||||
gerar.then(() => {
|
gerar.then(() => {
|
||||||
const fastify = Fastify({
|
const fastify = Fastify({
|
||||||
logger: false,
|
logger: false,
|
||||||
|
|
||||||
ignoreTrailingSlash: true,
|
ignoreTrailingSlash: true,
|
||||||
});
|
})
|
||||||
|
|
||||||
fastify.addHook("onSend", async (request, reply) => {
|
fastify.addHook("onSend", async (request, reply) => {
|
||||||
console.log(
|
console.log(
|
||||||
[
|
[
|
||||||
dayjs().format("YYYY-MM-DD HH:mm:ss"),
|
dayjs().format("YYYY-MM-DD HH:mm:ss"),
|
||||||
request.method,
|
request.method,
|
||||||
request.url,
|
request.url,
|
||||||
reply.statusCode,
|
reply.statusCode,
|
||||||
request.headers.site || request.headers.referer,
|
request.headers.site || request.headers.referer,
|
||||||
].join(" "),
|
].join(" "),
|
||||||
);
|
)
|
||||||
});
|
})
|
||||||
|
|
||||||
//cors
|
//cors
|
||||||
fastify.register(cors, {
|
fastify.register(cors, {
|
||||||
origin: "*",
|
origin: "*",
|
||||||
});
|
})
|
||||||
|
|
||||||
fastify.route({
|
fastify.route({
|
||||||
method: "GET",
|
method: "GET",
|
||||||
url: "/",
|
url: "/",
|
||||||
handler: (req, res) => {
|
handler: (_req, res) => {
|
||||||
res.redirect(`${PREFIXO}/`);
|
res.redirect(`${PREFIXO}/`)
|
||||||
},
|
},
|
||||||
});
|
})
|
||||||
|
|
||||||
fastify.route({
|
fastify.route({
|
||||||
method: "GET",
|
method: "GET",
|
||||||
url: `${PREFIXO}/`,
|
url: `${PREFIXO}/`,
|
||||||
handler: async (request, reply) => {
|
handler: async (_request, reply) => {
|
||||||
const html = (
|
const html = (
|
||||||
<html lang="pt-BR">
|
<html lang="pt-BR">
|
||||||
<head>
|
<head>
|
||||||
<title>Arquivos Estáticos</title>
|
<title>Arquivos Estáticos</title>
|
||||||
</head>{" "}
|
</head>{" "}
|
||||||
<body>
|
<body>
|
||||||
<h4>Arquivos Estáticos</h4>
|
<h4>Arquivos Estáticos</h4>
|
||||||
<table width={"100%"}>
|
<table width={"100%"}>
|
||||||
<tr>
|
<tr>
|
||||||
<td width={"50%"}> {criarHtml(estaticos("relativo"))} </td>
|
<td width={"50%"}> {criarHtml(estaticos("relativo"))} </td>
|
||||||
<td width={"50%"}>
|
<td width={"50%"}>
|
||||||
<iframe
|
<iframe
|
||||||
title="Iframe"
|
title="Iframe"
|
||||||
name={_iframe}
|
name={_iframe}
|
||||||
height={600}
|
height={600}
|
||||||
width={"100%"}
|
width={"100%"}
|
||||||
/>
|
/>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
);
|
)
|
||||||
|
|
||||||
const renderHtml = renderToStaticMarkup(html, {});
|
const renderHtml = renderToStaticMarkup(html, {})
|
||||||
|
|
||||||
// htlm utf-8
|
// htlm utf-8
|
||||||
reply.header("content-type", "text/html; charset=utf-8");
|
reply.header("content-type", "text/html; charset=utf-8")
|
||||||
reply.send(renderHtml);
|
reply.send(renderHtml)
|
||||||
},
|
},
|
||||||
});
|
})
|
||||||
|
|
||||||
fastify.register(fastifyStatc, {
|
fastify.register(fastifyStatc, {
|
||||||
root: path.join(process.cwd(), "estaticos"),
|
root: path.join(process.cwd(), "estaticos"),
|
||||||
prefix: PREFIXO,
|
prefix: PREFIXO,
|
||||||
});
|
})
|
||||||
|
|
||||||
// 404
|
// 404
|
||||||
fastify.setNotFoundHandler((request, reply) => {
|
fastify.setNotFoundHandler((request, reply) => {
|
||||||
const html404 = fs.readFileSync(
|
const html404 = fs.readFileSync(
|
||||||
path.join(process.cwd(), estaticos("relativo").html["404.html"]),
|
path.join(process.cwd(), estaticos("relativo").html["404.html"]),
|
||||||
"utf8",
|
"utf8",
|
||||||
);
|
)
|
||||||
|
|
||||||
reply.header("content-type", "text/html; charset=utf-8");
|
reply.header("content-type", "text/html; charset=utf-8")
|
||||||
|
|
||||||
reply
|
reply
|
||||||
.code(404)
|
.code(404)
|
||||||
.send(html404.replace("{ERRO}", `Página não encontrada: ${request.url}`));
|
.send(html404.replace("{ERRO}", `Página não encontrada: ${request.url}`))
|
||||||
});
|
})
|
||||||
|
|
||||||
const jaEstaRodando = fetch(`http://0.0.0.0:${PORTA}`)
|
const jaEstaRodando = fetch(`http://0.0.0.0:${PORTA}`)
|
||||||
.then(() => true)
|
.then(() => true)
|
||||||
.catch(() => false);
|
.catch(() => false)
|
||||||
|
|
||||||
jaEstaRodando.then((jaEstaRodando) => {
|
jaEstaRodando.then((jaEstaRodando) => {
|
||||||
!jaEstaRodando &&
|
!jaEstaRodando &&
|
||||||
fastify.listen(
|
fastify.listen(
|
||||||
{ port: Number(PORTA), host: "0.0.0.0" },
|
{ port: Number(PORTA), host: "0.0.0.0" },
|
||||||
(err, address) => {
|
(err, address) => {
|
||||||
if (err) throw err;
|
if (err) throw err
|
||||||
console.log(
|
console.log(
|
||||||
`${new Date().toISOString()} Servidor ${PREFIXO} Rodando em ${address}`,
|
`${new Date().toISOString()} Servidor ${PREFIXO} Rodando em ${address}`,
|
||||||
);
|
)
|
||||||
},
|
},
|
||||||
);
|
)
|
||||||
|
|
||||||
jaEstaRodando && console.log(`Servidor ${PREFIXO} já está rodando`);
|
jaEstaRodando && console.log(`Servidor ${PREFIXO} já está rodando`)
|
||||||
});
|
})
|
||||||
});
|
})
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "p-estaticos",
|
"name": "p-estaticos",
|
||||||
"version": "0.61.0",
|
"version": "0.68.0",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|
@ -23,13 +23,13 @@
|
||||||
"@fastify/static": "^7.0.4",
|
"@fastify/static": "^7.0.4",
|
||||||
"dayjs": "^1.11.11",
|
"dayjs": "^1.11.11",
|
||||||
"fastify": "^4.27.0",
|
"fastify": "^4.27.0",
|
||||||
"p-comuns": "git+http://leitura:eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE3MTQ3NTA1NzYsImlzcyI6IkdpdG5lc3MiLCJwaWQiOjgsInRrbiI6eyJ0eXAiOiJwYXQiLCJpZCI6MzJ9fQ.OYdExOVQm5UI3wfeTaWjmD0o65Y1hrjFz5EvMB1a__U@git.idz.one:3000/git/multi-modulos-ambientais/_comuns.git#producao",
|
"p-comuns": "git+https://leitura:eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE3MTQ3NTA1NzYsImlzcyI6IkdpdG5lc3MiLCJwaWQiOjgsInRrbiI6eyJ0eXAiOiJwYXQiLCJpZCI6MzJ9fQ.OYdExOVQm5UI3wfeTaWjmD0o65Y1hrjFz5EvMB1a__U@git.idz.one/git/multi-modulos-ambientais/_comuns.git#producao",
|
||||||
"react": "^18.3.1",
|
"react": "^18.3.1",
|
||||||
"react-dom": "^18.3.1",
|
"react-dom": "^18.3.1",
|
||||||
"zod": "3.23.8"
|
"zod": "3.23.8"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@biomejs/biome": "latest",
|
"@biomejs/biome": "^2.0.6",
|
||||||
"@types/node": "^20.11.30",
|
"@types/node": "^20.11.30",
|
||||||
"@types/react": "^18.3.1",
|
"@types/react": "^18.3.1",
|
||||||
"@types/react-dom": "^18.3.0",
|
"@types/react-dom": "^18.3.0",
|
||||||
|
|
|
||||||
86
pnpm-lock.yaml
generated
86
pnpm-lock.yaml
generated
|
|
@ -21,8 +21,8 @@ importers:
|
||||||
specifier: ^4.27.0
|
specifier: ^4.27.0
|
||||||
version: 4.29.0
|
version: 4.29.0
|
||||||
p-comuns:
|
p-comuns:
|
||||||
specifier: git+http://leitura:eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE3MTQ3NTA1NzYsImlzcyI6IkdpdG5lc3MiLCJwaWQiOjgsInRrbiI6eyJ0eXAiOiJwYXQiLCJpZCI6MzJ9fQ.OYdExOVQm5UI3wfeTaWjmD0o65Y1hrjFz5EvMB1a__U@git.idz.one:3000/git/multi-modulos-ambientais/_comuns.git#producao
|
specifier: git+https://leitura:eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE3MTQ3NTA1NzYsImlzcyI6IkdpdG5lc3MiLCJwaWQiOjgsInRrbiI6eyJ0eXAiOiJwYXQiLCJpZCI6MzJ9fQ.OYdExOVQm5UI3wfeTaWjmD0o65Y1hrjFz5EvMB1a__U@git.idz.one/git/multi-modulos-ambientais/_comuns.git#producao
|
||||||
version: git+http://leitura:eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE3MTQ3NTA1NzYsImlzcyI6IkdpdG5lc3MiLCJwaWQiOjgsInRrbiI6eyJ0eXAiOiJwYXQiLCJpZCI6MzJ9fQ.OYdExOVQm5UI3wfeTaWjmD0o65Y1hrjFz5EvMB1a__U@git.idz.one:3000/git/multi-modulos-ambientais/_comuns.git#1350348900bece75a07fcb16f1cca9f7f07cac2d
|
version: git+https://leitura:eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE3MTQ3NTA1NzYsImlzcyI6IkdpdG5lc3MiLCJwaWQiOjgsInRrbiI6eyJ0eXAiOiJwYXQiLCJpZCI6MzJ9fQ.OYdExOVQm5UI3wfeTaWjmD0o65Y1hrjFz5EvMB1a__U@git.idz.one/git/multi-modulos-ambientais/_comuns.git#eb88195f6a25edc93a21b82c83224c0b6fac4023
|
||||||
react:
|
react:
|
||||||
specifier: ^18.3.1
|
specifier: ^18.3.1
|
||||||
version: 18.3.1
|
version: 18.3.1
|
||||||
|
|
@ -34,8 +34,8 @@ importers:
|
||||||
version: 3.23.8
|
version: 3.23.8
|
||||||
devDependencies:
|
devDependencies:
|
||||||
'@biomejs/biome':
|
'@biomejs/biome':
|
||||||
specifier: latest
|
specifier: ^2.0.6
|
||||||
version: 1.9.4
|
version: 2.0.6
|
||||||
'@types/node':
|
'@types/node':
|
||||||
specifier: ^20.11.30
|
specifier: ^20.11.30
|
||||||
version: 20.17.19
|
version: 20.17.19
|
||||||
|
|
@ -63,55 +63,55 @@ importers:
|
||||||
|
|
||||||
packages:
|
packages:
|
||||||
|
|
||||||
'@biomejs/biome@1.9.4':
|
'@biomejs/biome@2.0.6':
|
||||||
resolution: {integrity: sha512-1rkd7G70+o9KkTn5KLmDYXihGoTaIGO9PIIN2ZB7UJxFrWw04CZHPYiMRjYsaDvVV7hP1dYNRLxSANLaBFGpog==}
|
resolution: {integrity: sha512-RRP+9cdh5qwe2t0gORwXaa27oTOiQRQvrFf49x2PA1tnpsyU7FIHX4ZOFMtBC4QNtyWsN7Dqkf5EDbg4X+9iqA==}
|
||||||
engines: {node: '>=14.21.3'}
|
engines: {node: '>=14.21.3'}
|
||||||
hasBin: true
|
hasBin: true
|
||||||
|
|
||||||
'@biomejs/cli-darwin-arm64@1.9.4':
|
'@biomejs/cli-darwin-arm64@2.0.6':
|
||||||
resolution: {integrity: sha512-bFBsPWrNvkdKrNCYeAp+xo2HecOGPAy9WyNyB/jKnnedgzl4W4Hb9ZMzYNbf8dMCGmUdSavlYHiR01QaYR58cw==}
|
resolution: {integrity: sha512-AzdiNNjNzsE6LfqWyBvcL29uWoIuZUkndu+wwlXW13EKcBHbbKjNQEZIJKYDc6IL+p7bmWGx3v9ZtcRyIoIz5A==}
|
||||||
engines: {node: '>=14.21.3'}
|
engines: {node: '>=14.21.3'}
|
||||||
cpu: [arm64]
|
cpu: [arm64]
|
||||||
os: [darwin]
|
os: [darwin]
|
||||||
|
|
||||||
'@biomejs/cli-darwin-x64@1.9.4':
|
'@biomejs/cli-darwin-x64@2.0.6':
|
||||||
resolution: {integrity: sha512-ngYBh/+bEedqkSevPVhLP4QfVPCpb+4BBe2p7Xs32dBgs7rh9nY2AIYUL6BgLw1JVXV8GlpKmb/hNiuIxfPfZg==}
|
resolution: {integrity: sha512-wJjjP4E7bO4WJmiQaLnsdXMa516dbtC6542qeRkyJg0MqMXP0fvs4gdsHhZ7p9XWTAmGIjZHFKXdsjBvKGIJJQ==}
|
||||||
engines: {node: '>=14.21.3'}
|
engines: {node: '>=14.21.3'}
|
||||||
cpu: [x64]
|
cpu: [x64]
|
||||||
os: [darwin]
|
os: [darwin]
|
||||||
|
|
||||||
'@biomejs/cli-linux-arm64-musl@1.9.4':
|
'@biomejs/cli-linux-arm64-musl@2.0.6':
|
||||||
resolution: {integrity: sha512-v665Ct9WCRjGa8+kTr0CzApU0+XXtRgwmzIf1SeKSGAv+2scAlW6JR5PMFo6FzqqZ64Po79cKODKf3/AAmECqA==}
|
resolution: {integrity: sha512-CVPEMlin3bW49sBqLBg2x016Pws7eUXA27XYDFlEtponD0luYjg2zQaMJ2nOqlkKG9fqzzkamdYxHdMDc2gZFw==}
|
||||||
engines: {node: '>=14.21.3'}
|
engines: {node: '>=14.21.3'}
|
||||||
cpu: [arm64]
|
cpu: [arm64]
|
||||||
os: [linux]
|
os: [linux]
|
||||||
|
|
||||||
'@biomejs/cli-linux-arm64@1.9.4':
|
'@biomejs/cli-linux-arm64@2.0.6':
|
||||||
resolution: {integrity: sha512-fJIW0+LYujdjUgJJuwesP4EjIBl/N/TcOX3IvIHJQNsAqvV2CHIogsmA94BPG6jZATS4Hi+xv4SkBBQSt1N4/g==}
|
resolution: {integrity: sha512-ZSVf6TYo5rNMUHIW1tww+rs/krol7U5A1Is/yzWyHVZguuB0lBnIodqyFuwCNqG9aJGyk7xIMS8HG0qGUPz0SA==}
|
||||||
engines: {node: '>=14.21.3'}
|
engines: {node: '>=14.21.3'}
|
||||||
cpu: [arm64]
|
cpu: [arm64]
|
||||||
os: [linux]
|
os: [linux]
|
||||||
|
|
||||||
'@biomejs/cli-linux-x64-musl@1.9.4':
|
'@biomejs/cli-linux-x64-musl@2.0.6':
|
||||||
resolution: {integrity: sha512-gEhi/jSBhZ2m6wjV530Yy8+fNqG8PAinM3oV7CyO+6c3CEh16Eizm21uHVsyVBEB6RIM8JHIl6AGYCv6Q6Q9Tg==}
|
resolution: {integrity: sha512-mKHE/e954hR/hSnAcJSjkf4xGqZc/53Kh39HVW1EgO5iFi0JutTN07TSjEMg616julRtfSNJi0KNyxvc30Y4rQ==}
|
||||||
engines: {node: '>=14.21.3'}
|
engines: {node: '>=14.21.3'}
|
||||||
cpu: [x64]
|
cpu: [x64]
|
||||||
os: [linux]
|
os: [linux]
|
||||||
|
|
||||||
'@biomejs/cli-linux-x64@1.9.4':
|
'@biomejs/cli-linux-x64@2.0.6':
|
||||||
resolution: {integrity: sha512-lRCJv/Vi3Vlwmbd6K+oQ0KhLHMAysN8lXoCI7XeHlxaajk06u7G+UsFSO01NAs5iYuWKmVZjmiOzJ0OJmGsMwg==}
|
resolution: {integrity: sha512-geM1MkHTV1Kh2Cs/Xzot9BOF3WBacihw6bkEmxkz4nSga8B9/hWy5BDiOG3gHDGIBa8WxT0nzsJs2f/hPqQIQw==}
|
||||||
engines: {node: '>=14.21.3'}
|
engines: {node: '>=14.21.3'}
|
||||||
cpu: [x64]
|
cpu: [x64]
|
||||||
os: [linux]
|
os: [linux]
|
||||||
|
|
||||||
'@biomejs/cli-win32-arm64@1.9.4':
|
'@biomejs/cli-win32-arm64@2.0.6':
|
||||||
resolution: {integrity: sha512-tlbhLk+WXZmgwoIKwHIHEBZUwxml7bRJgk0X2sPyNR3S93cdRq6XulAZRQJ17FYGGzWne0fgrXBKpl7l4M87Hg==}
|
resolution: {integrity: sha512-290V4oSFoKaprKE1zkYVsDfAdn0An5DowZ+GIABgjoq1ndhvNxkJcpxPsiYtT7slbVe3xmlT0ncdfOsN7KruzA==}
|
||||||
engines: {node: '>=14.21.3'}
|
engines: {node: '>=14.21.3'}
|
||||||
cpu: [arm64]
|
cpu: [arm64]
|
||||||
os: [win32]
|
os: [win32]
|
||||||
|
|
||||||
'@biomejs/cli-win32-x64@1.9.4':
|
'@biomejs/cli-win32-x64@2.0.6':
|
||||||
resolution: {integrity: sha512-8Y5wMhVIPaWe6jw2H+KlEm4wP/f7EW3810ZLmDlrEEy5KvBsb9ECEfu/kMWD484ijfQ8+nIi0giMgu9g1UAuuA==}
|
resolution: {integrity: sha512-bfM1Bce0d69Ao7pjTjUS+AWSZ02+5UHdiAP85Th8e9yV5xzw6JrHXbL5YWlcEKQ84FIZMdDc7ncuti1wd2sdbw==}
|
||||||
engines: {node: '>=14.21.3'}
|
engines: {node: '>=14.21.3'}
|
||||||
cpu: [x64]
|
cpu: [x64]
|
||||||
os: [win32]
|
os: [win32]
|
||||||
|
|
@ -429,9 +429,9 @@ packages:
|
||||||
resolution: {integrity: sha512-0eJJY6hXLGf1udHwfNftBqH+g73EU4B504nZeKpz1sYRKafAghwxEJunB2O7rDZkL4PGfsMVnTXZ2EjibbqcsA==}
|
resolution: {integrity: sha512-0eJJY6hXLGf1udHwfNftBqH+g73EU4B504nZeKpz1sYRKafAghwxEJunB2O7rDZkL4PGfsMVnTXZ2EjibbqcsA==}
|
||||||
engines: {node: '>=14.0.0'}
|
engines: {node: '>=14.0.0'}
|
||||||
|
|
||||||
p-comuns@git+http://leitura:eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE3MTQ3NTA1NzYsImlzcyI6IkdpdG5lc3MiLCJwaWQiOjgsInRrbiI6eyJ0eXAiOiJwYXQiLCJpZCI6MzJ9fQ.OYdExOVQm5UI3wfeTaWjmD0o65Y1hrjFz5EvMB1a__U@git.idz.one:3000/git/multi-modulos-ambientais/_comuns.git#1350348900bece75a07fcb16f1cca9f7f07cac2d:
|
p-comuns@git+https://leitura:eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE3MTQ3NTA1NzYsImlzcyI6IkdpdG5lc3MiLCJwaWQiOjgsInRrbiI6eyJ0eXAiOiJwYXQiLCJpZCI6MzJ9fQ.OYdExOVQm5UI3wfeTaWjmD0o65Y1hrjFz5EvMB1a__U@git.idz.one/git/multi-modulos-ambientais/_comuns.git#eb88195f6a25edc93a21b82c83224c0b6fac4023:
|
||||||
resolution: {commit: 1350348900bece75a07fcb16f1cca9f7f07cac2d, repo: http://leitura:eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE3MTQ3NTA1NzYsImlzcyI6IkdpdG5lc3MiLCJwaWQiOjgsInRrbiI6eyJ0eXAiOiJwYXQiLCJpZCI6MzJ9fQ.OYdExOVQm5UI3wfeTaWjmD0o65Y1hrjFz5EvMB1a__U@git.idz.one:3000/git/multi-modulos-ambientais/_comuns.git, type: git}
|
resolution: {commit: eb88195f6a25edc93a21b82c83224c0b6fac4023, repo: https://leitura:eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE3MTQ3NTA1NzYsImlzcyI6IkdpdG5lc3MiLCJwaWQiOjgsInRrbiI6eyJ0eXAiOiJwYXQiLCJpZCI6MzJ9fQ.OYdExOVQm5UI3wfeTaWjmD0o65Y1hrjFz5EvMB1a__U@git.idz.one/git/multi-modulos-ambientais/_comuns.git, type: git}
|
||||||
version: 0.93.0
|
version: 0.110.0
|
||||||
|
|
||||||
p-finally@1.0.0:
|
p-finally@1.0.0:
|
||||||
resolution: {integrity: sha512-LICb2p9CB7FS+0eR1oqWnHhp0FljGLZCWBE9aix0Uye9W8LTQPwMTYVGWQWIw9RdQiDg4+epXQODwIYJtSJaow==}
|
resolution: {integrity: sha512-LICb2p9CB7FS+0eR1oqWnHhp0FljGLZCWBE9aix0Uye9W8LTQPwMTYVGWQWIw9RdQiDg4+epXQODwIYJtSJaow==}
|
||||||
|
|
@ -647,39 +647,39 @@ packages:
|
||||||
|
|
||||||
snapshots:
|
snapshots:
|
||||||
|
|
||||||
'@biomejs/biome@1.9.4':
|
'@biomejs/biome@2.0.6':
|
||||||
optionalDependencies:
|
optionalDependencies:
|
||||||
'@biomejs/cli-darwin-arm64': 1.9.4
|
'@biomejs/cli-darwin-arm64': 2.0.6
|
||||||
'@biomejs/cli-darwin-x64': 1.9.4
|
'@biomejs/cli-darwin-x64': 2.0.6
|
||||||
'@biomejs/cli-linux-arm64': 1.9.4
|
'@biomejs/cli-linux-arm64': 2.0.6
|
||||||
'@biomejs/cli-linux-arm64-musl': 1.9.4
|
'@biomejs/cli-linux-arm64-musl': 2.0.6
|
||||||
'@biomejs/cli-linux-x64': 1.9.4
|
'@biomejs/cli-linux-x64': 2.0.6
|
||||||
'@biomejs/cli-linux-x64-musl': 1.9.4
|
'@biomejs/cli-linux-x64-musl': 2.0.6
|
||||||
'@biomejs/cli-win32-arm64': 1.9.4
|
'@biomejs/cli-win32-arm64': 2.0.6
|
||||||
'@biomejs/cli-win32-x64': 1.9.4
|
'@biomejs/cli-win32-x64': 2.0.6
|
||||||
|
|
||||||
'@biomejs/cli-darwin-arm64@1.9.4':
|
'@biomejs/cli-darwin-arm64@2.0.6':
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
'@biomejs/cli-darwin-x64@1.9.4':
|
'@biomejs/cli-darwin-x64@2.0.6':
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
'@biomejs/cli-linux-arm64-musl@1.9.4':
|
'@biomejs/cli-linux-arm64-musl@2.0.6':
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
'@biomejs/cli-linux-arm64@1.9.4':
|
'@biomejs/cli-linux-arm64@2.0.6':
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
'@biomejs/cli-linux-x64-musl@1.9.4':
|
'@biomejs/cli-linux-x64-musl@2.0.6':
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
'@biomejs/cli-linux-x64@1.9.4':
|
'@biomejs/cli-linux-x64@2.0.6':
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
'@biomejs/cli-win32-arm64@1.9.4':
|
'@biomejs/cli-win32-arm64@2.0.6':
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
'@biomejs/cli-win32-x64@1.9.4':
|
'@biomejs/cli-win32-x64@2.0.6':
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
'@fastify/accept-negotiator@1.1.0': {}
|
'@fastify/accept-negotiator@1.1.0': {}
|
||||||
|
|
@ -1013,7 +1013,7 @@ snapshots:
|
||||||
|
|
||||||
on-exit-leak-free@2.1.2: {}
|
on-exit-leak-free@2.1.2: {}
|
||||||
|
|
||||||
p-comuns@git+http://leitura:eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE3MTQ3NTA1NzYsImlzcyI6IkdpdG5lc3MiLCJwaWQiOjgsInRrbiI6eyJ0eXAiOiJwYXQiLCJpZCI6MzJ9fQ.OYdExOVQm5UI3wfeTaWjmD0o65Y1hrjFz5EvMB1a__U@git.idz.one:3000/git/multi-modulos-ambientais/_comuns.git#1350348900bece75a07fcb16f1cca9f7f07cac2d:
|
p-comuns@git+https://leitura:eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE3MTQ3NTA1NzYsImlzcyI6IkdpdG5lc3MiLCJwaWQiOjgsInRrbiI6eyJ0eXAiOiJwYXQiLCJpZCI6MzJ9fQ.OYdExOVQm5UI3wfeTaWjmD0o65Y1hrjFz5EvMB1a__U@git.idz.one/git/multi-modulos-ambientais/_comuns.git#eb88195f6a25edc93a21b82c83224c0b6fac4023:
|
||||||
dependencies:
|
dependencies:
|
||||||
cross-fetch: 4.1.0
|
cross-fetch: 4.1.0
|
||||||
zod: 3.24.1
|
zod: 3.24.1
|
||||||
|
|
|
||||||
1250
src/index.ts
1250
src/index.ts
File diff suppressed because it is too large
Load diff
|
|
@ -1,35 +1,35 @@
|
||||||
// esse arquivo não pode ser importado em index.ts para não gerar conflito
|
// esse arquivo não pode ser importado em index.ts para não gerar conflito
|
||||||
|
|
||||||
import fs from "node:fs";
|
import fs from "node:fs"
|
||||||
import path from "node:path";
|
import path from "node:path"
|
||||||
import { globSync } from "glob";
|
import { globSync } from "glob"
|
||||||
|
|
||||||
export const mapearPasta = ({
|
export const mapearPasta = ({
|
||||||
prefixos,
|
prefixos,
|
||||||
pasta,
|
pasta,
|
||||||
arquivoDestino,
|
arquivoDestino,
|
||||||
variavel,
|
variavel,
|
||||||
}: {
|
}: {
|
||||||
prefixos: { [k: string]: string };
|
prefixos: { [k: string]: string }
|
||||||
pasta: string;
|
pasta: string
|
||||||
arquivoDestino: string;
|
arquivoDestino: string
|
||||||
variavel?: string;
|
variavel?: string
|
||||||
}) => {
|
}) => {
|
||||||
const pasta_estaticos = pasta.endsWith("/") ? pasta : `${pasta}/`;
|
const pasta_estaticos = pasta.endsWith("/") ? pasta : `${pasta}/`
|
||||||
if (!fs.existsSync(pasta_estaticos))
|
if (!fs.existsSync(pasta_estaticos))
|
||||||
throw new Error(`Pasta ${pasta_estaticos} não existe`);
|
throw new Error(`Pasta ${pasta_estaticos} não existe`)
|
||||||
|
|
||||||
const gerar = (async () => {
|
const _gerar = (async () => {
|
||||||
// listar arquivos da pasta estáticos
|
// listar arquivos da pasta estáticos
|
||||||
const files = globSync(`${pasta_estaticos}**/*`, { nodir: true });
|
const files = globSync(`${pasta_estaticos}**/*`, { nodir: true })
|
||||||
|
|
||||||
const arquivo_ts = `
|
const arquivo_ts = `
|
||||||
|
|
||||||
|
|
||||||
const Prefixos = {
|
const Prefixos = {
|
||||||
${Object.entries(prefixos)
|
${Object.entries(prefixos)
|
||||||
.map(([k, v]) => `"${k}": "${v.replace(/"/g, '\\"')}"`)
|
.map(([k, v]) => `"${k}": "${v.replace(/"/g, '\\"')}"`)
|
||||||
.join(",\n")}
|
.join(",\n")}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -41,7 +41,7 @@ export const mapearPasta = ({
|
||||||
const prefixo = Prefixos[caminho];
|
const prefixo = Prefixos[caminho];
|
||||||
|
|
||||||
return ${(() => {
|
return ${(() => {
|
||||||
/*
|
/*
|
||||||
|
|
||||||
${files
|
${files
|
||||||
.map((f) => f.slice(pasta_estaticos.length))
|
.map((f) => f.slice(pasta_estaticos.length))
|
||||||
|
|
@ -50,42 +50,42 @@ export const mapearPasta = ({
|
||||||
|
|
||||||
|
|
||||||
*/
|
*/
|
||||||
type tp = {
|
type tp = {
|
||||||
[key: string]: string | tp;
|
[key: string]: string | tp
|
||||||
};
|
}
|
||||||
|
|
||||||
const arquivos = {} as tp;
|
const arquivos = {} as tp
|
||||||
|
|
||||||
for (const arquivo of files) {
|
for (const arquivo of files) {
|
||||||
const partes = arquivo.slice(pasta_estaticos.length).split("/");
|
const partes = arquivo.slice(pasta_estaticos.length).split("/")
|
||||||
let pasta = arquivos;
|
let pasta = arquivos
|
||||||
for (const [i, parte] of partes.entries()) {
|
for (const [i, parte] of partes.entries()) {
|
||||||
if (i === partes.length - 1) {
|
if (i === partes.length - 1) {
|
||||||
pasta[parte] = `~~~\${prefixo}${encodeURI(
|
pasta[parte] = `~~~\${prefixo}${encodeURI(
|
||||||
arquivo.slice(pasta_estaticos.length - 1),
|
arquivo.slice(pasta_estaticos.length - 1),
|
||||||
)}~~~`;
|
)}~~~`
|
||||||
} else {
|
} else {
|
||||||
pasta[parte] = pasta[parte] || {};
|
pasta[parte] = pasta[parte] || {}
|
||||||
pasta = pasta[parte] as tp;
|
pasta = pasta[parte] as tp
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return JSON.stringify(arquivos, null, 2)
|
return JSON.stringify(arquivos, null, 2)
|
||||||
.replace(/"~~~/g, "`")
|
.replace(/"~~~/g, "`")
|
||||||
.replace(/~~~"/g, "`");
|
.replace(/~~~"/g, "`")
|
||||||
})()};
|
})()};
|
||||||
};
|
};
|
||||||
`;
|
`
|
||||||
|
|
||||||
// criar pasta de arquivo destino
|
// criar pasta de arquivo destino
|
||||||
const pastaDestino = path.dirname(arquivoDestino);
|
const pastaDestino = path.dirname(arquivoDestino)
|
||||||
if (!fs.existsSync(pastaDestino)) {
|
if (!fs.existsSync(pastaDestino)) {
|
||||||
fs.mkdirSync(pastaDestino, { recursive: true });
|
fs.mkdirSync(pastaDestino, { recursive: true })
|
||||||
}
|
}
|
||||||
|
|
||||||
// escrever arquivo
|
// escrever arquivo
|
||||||
|
|
||||||
fs.writeFileSync(arquivoDestino, arquivo_ts);
|
fs.writeFileSync(arquivoDestino, arquivo_ts)
|
||||||
})();
|
})()
|
||||||
};
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue