ajustes
This commit is contained in:
parent
0dc2d7a0df
commit
24561a6199
6 changed files with 157 additions and 4 deletions
22
.vscode/settings.json
vendored
22
.vscode/settings.json
vendored
|
|
@ -2,5 +2,27 @@
|
||||||
"editor.codeActionsOnSave": {
|
"editor.codeActionsOnSave": {
|
||||||
"source.organizeImports.biome": "always",
|
"source.organizeImports.biome": "always",
|
||||||
"source.fixAll.biome": "always"
|
"source.fixAll.biome": "always"
|
||||||
|
},
|
||||||
|
"editor.defaultFormatter": "biomejs.biome",
|
||||||
|
"[javascript]": {
|
||||||
|
"editor.defaultFormatter": "biomejs.biome"
|
||||||
|
},
|
||||||
|
"[javascriptreact]": {
|
||||||
|
"editor.defaultFormatter": "biomejs.biome"
|
||||||
|
},
|
||||||
|
"[typescript]": {
|
||||||
|
"editor.defaultFormatter": "biomejs.biome"
|
||||||
|
},
|
||||||
|
"[typescriptreact]": {
|
||||||
|
"editor.defaultFormatter": "biomejs.biome"
|
||||||
|
},
|
||||||
|
"[json]": {
|
||||||
|
"editor.defaultFormatter": "biomejs.biome"
|
||||||
|
},
|
||||||
|
"[jsonc]": {
|
||||||
|
"editor.defaultFormatter": "biomejs.biome"
|
||||||
|
},
|
||||||
|
"[vue]": {
|
||||||
|
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
{
|
{
|
||||||
"$schema": "../node_modules/@biomejs/biome/configuration_schema.json",
|
"$schema": "../node_modules/@biomejs/biome/configuration_schema.json",
|
||||||
"root": false,
|
"root": false,
|
||||||
|
|
||||||
"linter": {
|
"linter": {
|
||||||
"enabled": true,
|
"enabled": true,
|
||||||
"rules": {
|
"rules": {
|
||||||
|
|
@ -38,7 +39,7 @@
|
||||||
"noUselessFragments":"off"
|
"noUselessFragments":"off"
|
||||||
},
|
},
|
||||||
"performance": {
|
"performance": {
|
||||||
"noAccumulatingSpread": "warn"
|
"noAccumulatingSpread": "off"
|
||||||
},
|
},
|
||||||
"a11y": {
|
"a11y": {
|
||||||
"useSemanticElements": "off"
|
"useSemanticElements": "off"
|
||||||
|
|
|
||||||
12
README.md
12
README.md
|
|
@ -8,6 +8,8 @@ Este guia mostra como configurar o [BiomeJS](https://biomejs.dev) para formatar
|
||||||
|
|
||||||
Certifique-se de que o pacote `p-comuns` (ou outro com a configuração compartilhada) esteja disponível no seu projeto. Ele deve conter o arquivo `Documentos/biome.json`.
|
Certifique-se de que o pacote `p-comuns` (ou outro com a configuração compartilhada) esteja disponível no seu projeto. Ele deve conter o arquivo `Documentos/biome.json`.
|
||||||
|
|
||||||
|
pnpm up p-comuns
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
### 2. Instalar o Biome com `pnpm`
|
### 2. Instalar o Biome com `pnpm`
|
||||||
|
|
@ -45,7 +47,7 @@ Inclua o comando abaixo em `"scripts"`:
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"biome": "pnpm exec biome check --write"
|
"biome": "pnpm exec biome check --write",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
@ -73,6 +75,14 @@ Se quiser aplicar o Biome a todo o projeto (não só `src/`), altere o include:
|
||||||
adicionar em .vscode/settings.json
|
adicionar em .vscode/settings.json
|
||||||
|
|
||||||
{
|
{
|
||||||
|
"editor.defaultFormatter": "biomejs.biome",
|
||||||
|
"[javascript]": { "editor.defaultFormatter": "biomejs.biome" },
|
||||||
|
"[javascriptreact]": { "editor.defaultFormatter": "biomejs.biome" },
|
||||||
|
"[typescript]": { "editor.defaultFormatter": "biomejs.biome" },
|
||||||
|
"[typescriptreact]": { "editor.defaultFormatter": "biomejs.biome" },
|
||||||
|
"[json]": { "editor.defaultFormatter": "biomejs.biome" },
|
||||||
|
"[jsonc]": { "editor.defaultFormatter": "biomejs.biome" },
|
||||||
|
"[vue]": {"editor.defaultFormatter": "octref.vetur"},
|
||||||
"editor.codeActionsOnSave": {
|
"editor.codeActionsOnSave": {
|
||||||
"source.organizeImports.biome": "always",
|
"source.organizeImports.biome": "always",
|
||||||
"source.fixAll.biome": "always"
|
"source.fixAll.biome": "always"
|
||||||
|
|
|
||||||
63
dist-back/instalarAmbiente.js
Normal file
63
dist-back/instalarAmbiente.js
Normal file
|
|
@ -0,0 +1,63 @@
|
||||||
|
"use strict";
|
||||||
|
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 __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 import_node_fs = __toESM(require("node:fs"));
|
||||||
|
var import_node_path = __toESM(require("node:path"));
|
||||||
|
const mesclar = (entrada, novo) => {
|
||||||
|
const saida = { ...entrada || {} };
|
||||||
|
for (const [k, v] of Object.entries(novo)) {
|
||||||
|
if (v && typeof v === "object" && !Array.isArray(v)) {
|
||||||
|
saida[k] = mesclar(saida[k], v);
|
||||||
|
} else {
|
||||||
|
saida[k] = v;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return saida;
|
||||||
|
};
|
||||||
|
const abrirJson = (caminho) => {
|
||||||
|
try {
|
||||||
|
return JSON.parse(import_node_fs.default.readFileSync(caminho, "utf-8"));
|
||||||
|
} catch {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const settings_json = {
|
||||||
|
"editor.defaultFormatter": "biomejs.biome",
|
||||||
|
"[javascript]": { "editor.defaultFormatter": "biomejs.biome" },
|
||||||
|
"[javascriptreact]": { "editor.defaultFormatter": "biomejs.biome" },
|
||||||
|
"[typescript]": { "editor.defaultFormatter": "biomejs.biome" },
|
||||||
|
"[typescriptreact]": { "editor.defaultFormatter": "biomejs.biome" },
|
||||||
|
"[json]": { "editor.defaultFormatter": "biomejs.biome" },
|
||||||
|
"[jsonc]": { "editor.defaultFormatter": "biomejs.biome" },
|
||||||
|
"[vue]": { "editor.defaultFormatter": "esbenp.prettier-vscode" },
|
||||||
|
"editor.codeActionsOnSave": {
|
||||||
|
"source.organizeImports.biome": "always",
|
||||||
|
"source.fixAll.biome": "always"
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const caminhoSeting = import_node_path.default.join(process.cwd(), ".vscode/settings.json");
|
||||||
|
import_node_fs.default.mkdirSync(import_node_path.default.dirname(caminhoSeting), { recursive: true });
|
||||||
|
const atual = abrirJson(caminhoSeting);
|
||||||
|
const final = mesclar(atual, settings_json);
|
||||||
|
import_node_fs.default.writeFileSync(caminhoSeting, JSON.stringify(final, null, 2), "utf8");
|
||||||
|
console.log(`\u2705 Configura\xE7\xF5es salvas em ${caminhoSeting}`);
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "p-comuns",
|
"name": "p-comuns",
|
||||||
"version": "0.211.0",
|
"version": "0.212.0",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "./dist-back/index.js",
|
"main": "./dist-back/index.js",
|
||||||
"module": "./dist-front/index.mjs",
|
"module": "./dist-front/index.mjs",
|
||||||
|
|
|
||||||
57
src/instalarAmbiente.ts
Normal file
57
src/instalarAmbiente.ts
Normal file
|
|
@ -0,0 +1,57 @@
|
||||||
|
import fs from "node:fs"
|
||||||
|
import path from "node:path"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mescla objetos recursivamente.
|
||||||
|
* - Adiciona chaves novas
|
||||||
|
* - Sobrescreve valores primitivos
|
||||||
|
* - Mescla objetos aninhados
|
||||||
|
*/
|
||||||
|
const mesclar = (entrada: any, novo: any): any => {
|
||||||
|
const saida = { ...(entrada || {}) }
|
||||||
|
for (const [k, v] of Object.entries(novo)) {
|
||||||
|
if (v && typeof v === "object" && !Array.isArray(v)) {
|
||||||
|
saida[k] = mesclar(saida[k], v)
|
||||||
|
} else {
|
||||||
|
saida[k] = v
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return saida
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Lê JSON ou retorna objeto vazio */
|
||||||
|
const abrirJson = (caminho: string) => {
|
||||||
|
try {
|
||||||
|
return JSON.parse(fs.readFileSync(caminho, "utf-8"))
|
||||||
|
} catch {
|
||||||
|
return {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const settings_json = {
|
||||||
|
"editor.defaultFormatter": "biomejs.biome",
|
||||||
|
"[javascript]": { "editor.defaultFormatter": "biomejs.biome" },
|
||||||
|
"[javascriptreact]": { "editor.defaultFormatter": "biomejs.biome" },
|
||||||
|
"[typescript]": { "editor.defaultFormatter": "biomejs.biome" },
|
||||||
|
"[typescriptreact]": { "editor.defaultFormatter": "biomejs.biome" },
|
||||||
|
"[json]": { "editor.defaultFormatter": "biomejs.biome" },
|
||||||
|
"[jsonc]": { "editor.defaultFormatter": "biomejs.biome" },
|
||||||
|
"[vue]": { "editor.defaultFormatter": "esbenp.prettier-vscode" },
|
||||||
|
"editor.codeActionsOnSave": {
|
||||||
|
"source.organizeImports.biome": "always",
|
||||||
|
"source.fixAll.biome": "always",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
const caminhoSeting = path.join(process.cwd(), ".vscode/settings.json")
|
||||||
|
|
||||||
|
// Garante a pasta .vscode
|
||||||
|
fs.mkdirSync(path.dirname(caminhoSeting), { recursive: true })
|
||||||
|
|
||||||
|
// Mescla e grava
|
||||||
|
const atual = abrirJson(caminhoSeting)
|
||||||
|
const final = mesclar(atual, settings_json)
|
||||||
|
|
||||||
|
fs.writeFileSync(caminhoSeting, JSON.stringify(final, null, 2), "utf8")
|
||||||
|
|
||||||
|
console.log(`✅ Configurações salvas em ${caminhoSeting}`)
|
||||||
Loading…
Add table
Add a link
Reference in a new issue