@robosophy/lint 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/bin/lib.mjs +27 -16
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -76,7 +76,7 @@ El instalador no hace un formateo masivo del proyecto. El hook ejecuta lint-stag
|
|
|
76
76
|
|
|
77
77
|
### Dependencias y `package.json`
|
|
78
78
|
|
|
79
|
-
`init` ejecuta npm e instala/actualiza `@robosophy/lint`, ESLint 10, Prettier 3 y lint-staged 16; también
|
|
79
|
+
`init` ejecuta npm e instala/actualiza `@robosophy/lint`, ESLint 10, Prettier 3 y lint-staged 16; con el preset Vue también actualiza `eslint-plugin-vue` a la versión compatible con el preset. Instala o actualiza Husky 9 salvo que uses `--no-husky`. Las versiones antiguas de estas dependencias se migran aunque la configuración previa se respalde; npm también actualiza el lockfile. Otras dependencias legacy de ESLint que no gestione el instalador pueden seguir causando conflictos de peers.
|
|
80
80
|
|
|
81
81
|
El instalador conserva los scripts existentes, agrega `lint: eslint .` solo si no hay un script `lint`, y configura `prepare: husky` cuando Husky está habilitado. Si ya existe un `prepare`, agrega `&& husky` salvo que detecte ya el comando `husky`. Con `--no-husky`, no modifica `prepare` ni agrega Husky.
|
|
82
82
|
|
package/bin/lib.mjs
CHANGED
|
@@ -241,24 +241,26 @@ async function backupExistingConfigs(root, backups, framework, strict, options)
|
|
|
241
241
|
}
|
|
242
242
|
}
|
|
243
243
|
|
|
244
|
-
export function updatePackageJson(packageJson, { noHusky = false } = {}) {
|
|
244
|
+
export function updatePackageJson(packageJson, { framework, noHusky = false } = {}) {
|
|
245
245
|
const updated = structuredClone(packageJson);
|
|
246
246
|
updated.devDependencies ??= {};
|
|
247
|
-
const
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
updated
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
247
|
+
const setDependency = (name, version) => {
|
|
248
|
+
let found = false;
|
|
249
|
+
for (const section of ['dependencies', 'devDependencies', 'peerDependencies']) {
|
|
250
|
+
if (updated[section]?.[name] !== undefined) {
|
|
251
|
+
updated[section][name] = version;
|
|
252
|
+
found = true;
|
|
253
|
+
}
|
|
254
254
|
}
|
|
255
|
-
updated.devDependencies[name] = version;
|
|
255
|
+
if (!found) updated.devDependencies[name] = version;
|
|
256
256
|
};
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
if (
|
|
257
|
+
setDependency('@robosophy/lint', `^${PACKAGE_JSON.version}`);
|
|
258
|
+
setDependency('eslint', '^10.0.0');
|
|
259
|
+
setDependency('prettier', '^3.0.0');
|
|
260
|
+
setDependency('lint-staged', '^16.0.0');
|
|
261
|
+
if (framework === 'vue')
|
|
262
|
+
setDependency('eslint-plugin-vue', PACKAGE_JSON.dependencies['eslint-plugin-vue']);
|
|
263
|
+
if (!noHusky) setDependency('husky', '^9.0.0');
|
|
262
264
|
updated.scripts ??= {};
|
|
263
265
|
|
|
264
266
|
if (!noHusky) {
|
|
@@ -318,6 +320,9 @@ export async function createInstallPlan(root, options = {}) {
|
|
|
318
320
|
'prettier@^3.0.0',
|
|
319
321
|
'lint-staged@^16.0.0',
|
|
320
322
|
];
|
|
323
|
+
if (framework === 'vue') {
|
|
324
|
+
installArgs.push(`eslint-plugin-vue@${PACKAGE_JSON.dependencies['eslint-plugin-vue']}`);
|
|
325
|
+
}
|
|
321
326
|
if (!noHusky) installArgs.push('husky@^9.0.0');
|
|
322
327
|
|
|
323
328
|
return {
|
|
@@ -327,7 +332,7 @@ export async function createInstallPlan(root, options = {}) {
|
|
|
327
332
|
noHusky,
|
|
328
333
|
clean: Boolean(options.clean),
|
|
329
334
|
packageJson,
|
|
330
|
-
packageUpdated: updatePackageJson(packageJson, { noHusky }),
|
|
335
|
+
packageUpdated: updatePackageJson(packageJson, { framework, noHusky }),
|
|
331
336
|
backupTargets,
|
|
332
337
|
files,
|
|
333
338
|
installArgs,
|
|
@@ -410,6 +415,9 @@ async function confirmInstall(plan, options) {
|
|
|
410
415
|
if (plan.noHusky) console.log('Husky omitido (--no-husky).');
|
|
411
416
|
else console.log('Se configurará Husky y el hook .husky/pre-commit.');
|
|
412
417
|
console.log('Se instalarán/actualizarán @robosophy/lint, ESLint, Prettier y lint-staged.');
|
|
418
|
+
if (plan.framework === 'vue') {
|
|
419
|
+
console.log('El preset Vue también actualizará eslint-plugin-vue a una versión compatible.');
|
|
420
|
+
}
|
|
413
421
|
if (plan.backupTargets.length) {
|
|
414
422
|
console.log('Se respaldarán los archivos existentes antes de reemplazarlos:');
|
|
415
423
|
for (const target of plan.backupTargets) console.log(` - ${target}`);
|
|
@@ -447,7 +455,10 @@ export async function initProject(root, options = {}) {
|
|
|
447
455
|
|
|
448
456
|
const packageFile = join(plan.root, 'package.json');
|
|
449
457
|
const currentPackage = JSON.parse(await readFile(packageFile, 'utf8'));
|
|
450
|
-
const packageUpdated = updatePackageJson(currentPackage, {
|
|
458
|
+
const packageUpdated = updatePackageJson(currentPackage, {
|
|
459
|
+
framework: plan.framework,
|
|
460
|
+
noHusky: plan.noHusky,
|
|
461
|
+
});
|
|
451
462
|
await writeFile(packageFile, `${JSON.stringify(packageUpdated, null, 2)}\n`, 'utf8');
|
|
452
463
|
|
|
453
464
|
if (!plan.noHusky && !plan.skipInstall && existsSync(join(plan.root, '.git'))) {
|