@bagelink/workspace 1.7.41 ā 1.7.43
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/dist/bin/bgl.cjs +70 -1
- package/dist/bin/bgl.mjs +71 -2
- package/package.json +1 -1
- package/src/lint.ts +90 -2
package/dist/bin/bgl.cjs
CHANGED
|
@@ -311,6 +311,28 @@ export default defineConfig({
|
|
|
311
311
|
console.log("\u2705 Created vite.config.ts");
|
|
312
312
|
}
|
|
313
313
|
|
|
314
|
+
const REDUNDANT_FILES = [
|
|
315
|
+
// Old ESLint configs
|
|
316
|
+
".eslintrc",
|
|
317
|
+
".eslintrc.json",
|
|
318
|
+
".eslintrc.js",
|
|
319
|
+
".eslintrc.cjs",
|
|
320
|
+
".eslintrc.yaml",
|
|
321
|
+
".eslintrc.yml",
|
|
322
|
+
// Oxlint
|
|
323
|
+
"oxlint.json",
|
|
324
|
+
// Old Prettier configs (we create .prettierrc)
|
|
325
|
+
"prettier.config.js",
|
|
326
|
+
"prettier.config.cjs",
|
|
327
|
+
"prettier.config.mjs",
|
|
328
|
+
".prettierrc.json",
|
|
329
|
+
".prettierrc.yaml",
|
|
330
|
+
".prettierrc.yml",
|
|
331
|
+
".prettierrc.js",
|
|
332
|
+
".prettierrc.cjs",
|
|
333
|
+
".prettierrc.mjs",
|
|
334
|
+
".prettierrc.toml"
|
|
335
|
+
];
|
|
314
336
|
async function setupLint(root = process__default.cwd(), isWorkspace = false) {
|
|
315
337
|
console.log("\n\u{1F50D} Setting up linting...\n");
|
|
316
338
|
const response = await prompts__default([
|
|
@@ -325,6 +347,12 @@ async function setupLint(root = process__default.cwd(), isWorkspace = false) {
|
|
|
325
347
|
{ title: "Git Hooks", value: "githooks", selected: false }
|
|
326
348
|
]
|
|
327
349
|
},
|
|
350
|
+
{
|
|
351
|
+
type: "confirm",
|
|
352
|
+
name: "cleanRedundant",
|
|
353
|
+
message: "Clean up redundant lint config files?",
|
|
354
|
+
initial: true
|
|
355
|
+
},
|
|
328
356
|
{
|
|
329
357
|
type: "confirm",
|
|
330
358
|
name: "installDeps",
|
|
@@ -336,7 +364,10 @@ async function setupLint(root = process__default.cwd(), isWorkspace = false) {
|
|
|
336
364
|
console.log("\n\u274C Setup cancelled.\n");
|
|
337
365
|
process__default.exit(1);
|
|
338
366
|
}
|
|
339
|
-
const { configs, installDeps } = response;
|
|
367
|
+
const { configs, cleanRedundant, installDeps } = response;
|
|
368
|
+
if (cleanRedundant) {
|
|
369
|
+
await cleanRedundantFiles(root);
|
|
370
|
+
}
|
|
340
371
|
if (configs.includes("eslint")) {
|
|
341
372
|
createEslintConfig(root, isWorkspace);
|
|
342
373
|
}
|
|
@@ -441,6 +472,44 @@ function createGitHooks(root) {
|
|
|
441
472
|
console.log("\u2139\uFE0F Add simple-git-hooks and lint-staged to devDependencies");
|
|
442
473
|
console.log(" Then run: npx simple-git-hooks");
|
|
443
474
|
}
|
|
475
|
+
async function cleanRedundantFiles(root) {
|
|
476
|
+
const foundFiles = [];
|
|
477
|
+
for (const file of REDUNDANT_FILES) {
|
|
478
|
+
const filePath = node_path.resolve(root, file);
|
|
479
|
+
if (node_fs.existsSync(filePath)) {
|
|
480
|
+
foundFiles.push(file);
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
if (foundFiles.length === 0) {
|
|
484
|
+
console.log("\u2728 No redundant files found");
|
|
485
|
+
return;
|
|
486
|
+
}
|
|
487
|
+
console.log("\n\u{1F4CB} Found redundant files:");
|
|
488
|
+
foundFiles.forEach((file) => {
|
|
489
|
+
console.log(` - ${file}`);
|
|
490
|
+
});
|
|
491
|
+
const confirmResponse = await prompts__default({
|
|
492
|
+
type: "confirm",
|
|
493
|
+
name: "confirm",
|
|
494
|
+
message: `Delete ${foundFiles.length} redundant file${foundFiles.length > 1 ? "s" : ""}?`,
|
|
495
|
+
initial: true
|
|
496
|
+
});
|
|
497
|
+
if (!confirmResponse.confirm) {
|
|
498
|
+
console.log("\u23ED\uFE0F Skipped cleaning redundant files");
|
|
499
|
+
return;
|
|
500
|
+
}
|
|
501
|
+
let deleted = 0;
|
|
502
|
+
for (const file of foundFiles) {
|
|
503
|
+
try {
|
|
504
|
+
node_fs.unlinkSync(node_path.resolve(root, file));
|
|
505
|
+
console.log(`\u{1F5D1}\uFE0F Deleted ${file}`);
|
|
506
|
+
deleted++;
|
|
507
|
+
} catch (error) {
|
|
508
|
+
console.error(`\u274C Failed to delete ${file}:`, error);
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
console.log(`\u2705 Cleaned up ${deleted} file${deleted > 1 ? "s" : ""}`);
|
|
512
|
+
}
|
|
444
513
|
function updatePackageJsonLint(root, configs) {
|
|
445
514
|
const packageJsonPath = node_path.resolve(root, "package.json");
|
|
446
515
|
if (!node_fs.existsSync(packageJsonPath)) {
|
package/dist/bin/bgl.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { resolve } from 'node:path';
|
|
3
3
|
import process from 'node:process';
|
|
4
|
-
import { existsSync, readFileSync, readdirSync, writeFileSync, mkdirSync } from 'node:fs';
|
|
4
|
+
import { existsSync, readFileSync, readdirSync, writeFileSync, unlinkSync, mkdirSync } from 'node:fs';
|
|
5
5
|
import { spawn } from 'node:child_process';
|
|
6
6
|
import prompts from 'prompts';
|
|
7
7
|
import { w as writeNetlifyConfig } from '../shared/workspace.Twuo1PFw.mjs';
|
|
@@ -304,6 +304,28 @@ export default defineConfig({
|
|
|
304
304
|
console.log("\u2705 Created vite.config.ts");
|
|
305
305
|
}
|
|
306
306
|
|
|
307
|
+
const REDUNDANT_FILES = [
|
|
308
|
+
// Old ESLint configs
|
|
309
|
+
".eslintrc",
|
|
310
|
+
".eslintrc.json",
|
|
311
|
+
".eslintrc.js",
|
|
312
|
+
".eslintrc.cjs",
|
|
313
|
+
".eslintrc.yaml",
|
|
314
|
+
".eslintrc.yml",
|
|
315
|
+
// Oxlint
|
|
316
|
+
"oxlint.json",
|
|
317
|
+
// Old Prettier configs (we create .prettierrc)
|
|
318
|
+
"prettier.config.js",
|
|
319
|
+
"prettier.config.cjs",
|
|
320
|
+
"prettier.config.mjs",
|
|
321
|
+
".prettierrc.json",
|
|
322
|
+
".prettierrc.yaml",
|
|
323
|
+
".prettierrc.yml",
|
|
324
|
+
".prettierrc.js",
|
|
325
|
+
".prettierrc.cjs",
|
|
326
|
+
".prettierrc.mjs",
|
|
327
|
+
".prettierrc.toml"
|
|
328
|
+
];
|
|
307
329
|
async function setupLint(root = process.cwd(), isWorkspace = false) {
|
|
308
330
|
console.log("\n\u{1F50D} Setting up linting...\n");
|
|
309
331
|
const response = await prompts([
|
|
@@ -318,6 +340,12 @@ async function setupLint(root = process.cwd(), isWorkspace = false) {
|
|
|
318
340
|
{ title: "Git Hooks", value: "githooks", selected: false }
|
|
319
341
|
]
|
|
320
342
|
},
|
|
343
|
+
{
|
|
344
|
+
type: "confirm",
|
|
345
|
+
name: "cleanRedundant",
|
|
346
|
+
message: "Clean up redundant lint config files?",
|
|
347
|
+
initial: true
|
|
348
|
+
},
|
|
321
349
|
{
|
|
322
350
|
type: "confirm",
|
|
323
351
|
name: "installDeps",
|
|
@@ -329,7 +357,10 @@ async function setupLint(root = process.cwd(), isWorkspace = false) {
|
|
|
329
357
|
console.log("\n\u274C Setup cancelled.\n");
|
|
330
358
|
process.exit(1);
|
|
331
359
|
}
|
|
332
|
-
const { configs, installDeps } = response;
|
|
360
|
+
const { configs, cleanRedundant, installDeps } = response;
|
|
361
|
+
if (cleanRedundant) {
|
|
362
|
+
await cleanRedundantFiles(root);
|
|
363
|
+
}
|
|
333
364
|
if (configs.includes("eslint")) {
|
|
334
365
|
createEslintConfig(root, isWorkspace);
|
|
335
366
|
}
|
|
@@ -434,6 +465,44 @@ function createGitHooks(root) {
|
|
|
434
465
|
console.log("\u2139\uFE0F Add simple-git-hooks and lint-staged to devDependencies");
|
|
435
466
|
console.log(" Then run: npx simple-git-hooks");
|
|
436
467
|
}
|
|
468
|
+
async function cleanRedundantFiles(root) {
|
|
469
|
+
const foundFiles = [];
|
|
470
|
+
for (const file of REDUNDANT_FILES) {
|
|
471
|
+
const filePath = resolve(root, file);
|
|
472
|
+
if (existsSync(filePath)) {
|
|
473
|
+
foundFiles.push(file);
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
if (foundFiles.length === 0) {
|
|
477
|
+
console.log("\u2728 No redundant files found");
|
|
478
|
+
return;
|
|
479
|
+
}
|
|
480
|
+
console.log("\n\u{1F4CB} Found redundant files:");
|
|
481
|
+
foundFiles.forEach((file) => {
|
|
482
|
+
console.log(` - ${file}`);
|
|
483
|
+
});
|
|
484
|
+
const confirmResponse = await prompts({
|
|
485
|
+
type: "confirm",
|
|
486
|
+
name: "confirm",
|
|
487
|
+
message: `Delete ${foundFiles.length} redundant file${foundFiles.length > 1 ? "s" : ""}?`,
|
|
488
|
+
initial: true
|
|
489
|
+
});
|
|
490
|
+
if (!confirmResponse.confirm) {
|
|
491
|
+
console.log("\u23ED\uFE0F Skipped cleaning redundant files");
|
|
492
|
+
return;
|
|
493
|
+
}
|
|
494
|
+
let deleted = 0;
|
|
495
|
+
for (const file of foundFiles) {
|
|
496
|
+
try {
|
|
497
|
+
unlinkSync(resolve(root, file));
|
|
498
|
+
console.log(`\u{1F5D1}\uFE0F Deleted ${file}`);
|
|
499
|
+
deleted++;
|
|
500
|
+
} catch (error) {
|
|
501
|
+
console.error(`\u274C Failed to delete ${file}:`, error);
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
console.log(`\u2705 Cleaned up ${deleted} file${deleted > 1 ? "s" : ""}`);
|
|
505
|
+
}
|
|
437
506
|
function updatePackageJsonLint(root, configs) {
|
|
438
507
|
const packageJsonPath = resolve(root, "package.json");
|
|
439
508
|
if (!existsSync(packageJsonPath)) {
|
package/package.json
CHANGED
package/src/lint.ts
CHANGED
|
@@ -1,8 +1,35 @@
|
|
|
1
|
-
import { existsSync, readFileSync, writeFileSync } from 'node:fs'
|
|
1
|
+
import { existsSync, readFileSync, unlinkSync, writeFileSync } from 'node:fs'
|
|
2
2
|
import { resolve } from 'node:path'
|
|
3
3
|
import process from 'node:process'
|
|
4
4
|
import prompts from 'prompts'
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* List of redundant lint config files that can be safely removed
|
|
8
|
+
* after setting up the new lint configuration
|
|
9
|
+
*/
|
|
10
|
+
const REDUNDANT_FILES = [
|
|
11
|
+
// Old ESLint configs
|
|
12
|
+
'.eslintrc',
|
|
13
|
+
'.eslintrc.json',
|
|
14
|
+
'.eslintrc.js',
|
|
15
|
+
'.eslintrc.cjs',
|
|
16
|
+
'.eslintrc.yaml',
|
|
17
|
+
'.eslintrc.yml',
|
|
18
|
+
// Oxlint
|
|
19
|
+
'oxlint.json',
|
|
20
|
+
// Old Prettier configs (we create .prettierrc)
|
|
21
|
+
'prettier.config.js',
|
|
22
|
+
'prettier.config.cjs',
|
|
23
|
+
'prettier.config.mjs',
|
|
24
|
+
'.prettierrc.json',
|
|
25
|
+
'.prettierrc.yaml',
|
|
26
|
+
'.prettierrc.yml',
|
|
27
|
+
'.prettierrc.js',
|
|
28
|
+
'.prettierrc.cjs',
|
|
29
|
+
'.prettierrc.mjs',
|
|
30
|
+
'.prettierrc.toml',
|
|
31
|
+
]
|
|
32
|
+
|
|
6
33
|
/**
|
|
7
34
|
* Set up linting in a project
|
|
8
35
|
*/
|
|
@@ -24,6 +51,12 @@ export async function setupLint(
|
|
|
24
51
|
{ title: 'Git Hooks', value: 'githooks', selected: false },
|
|
25
52
|
],
|
|
26
53
|
},
|
|
54
|
+
{
|
|
55
|
+
type: 'confirm',
|
|
56
|
+
name: 'cleanRedundant',
|
|
57
|
+
message: 'Clean up redundant lint config files?',
|
|
58
|
+
initial: true,
|
|
59
|
+
},
|
|
27
60
|
{
|
|
28
61
|
type: 'confirm',
|
|
29
62
|
name: 'installDeps',
|
|
@@ -37,7 +70,12 @@ export async function setupLint(
|
|
|
37
70
|
process.exit(1)
|
|
38
71
|
}
|
|
39
72
|
|
|
40
|
-
const { configs, installDeps } = response
|
|
73
|
+
const { configs, cleanRedundant, installDeps } = response
|
|
74
|
+
|
|
75
|
+
// Clean up redundant files first
|
|
76
|
+
if (cleanRedundant) {
|
|
77
|
+
await cleanRedundantFiles(root)
|
|
78
|
+
}
|
|
41
79
|
|
|
42
80
|
// Create config files
|
|
43
81
|
if (configs.includes('eslint')) {
|
|
@@ -182,6 +220,56 @@ function createGitHooks(root: string): void {
|
|
|
182
220
|
console.log(' Then run: npx simple-git-hooks')
|
|
183
221
|
}
|
|
184
222
|
|
|
223
|
+
/**
|
|
224
|
+
* Clean up redundant lint configuration files
|
|
225
|
+
*/
|
|
226
|
+
async function cleanRedundantFiles(root: string): Promise<void> {
|
|
227
|
+
const foundFiles: string[] = []
|
|
228
|
+
|
|
229
|
+
// Check which redundant files exist
|
|
230
|
+
for (const file of REDUNDANT_FILES) {
|
|
231
|
+
const filePath = resolve(root, file)
|
|
232
|
+
if (existsSync(filePath)) {
|
|
233
|
+
foundFiles.push(file)
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
if (foundFiles.length === 0) {
|
|
238
|
+
console.log('⨠No redundant files found')
|
|
239
|
+
return
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
console.log('\nš Found redundant files:')
|
|
243
|
+
foundFiles.forEach((file) => { console.log(` - ${file}`) })
|
|
244
|
+
|
|
245
|
+
const confirmResponse = await prompts({
|
|
246
|
+
type: 'confirm',
|
|
247
|
+
name: 'confirm',
|
|
248
|
+
message: `Delete ${foundFiles.length} redundant file${foundFiles.length > 1 ? 's' : ''}?`,
|
|
249
|
+
initial: true,
|
|
250
|
+
})
|
|
251
|
+
|
|
252
|
+
if (!confirmResponse.confirm) {
|
|
253
|
+
console.log('āļø Skipped cleaning redundant files')
|
|
254
|
+
return
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
// Delete confirmed files
|
|
258
|
+
let deleted = 0
|
|
259
|
+
for (const file of foundFiles) {
|
|
260
|
+
try {
|
|
261
|
+
unlinkSync(resolve(root, file))
|
|
262
|
+
console.log(`šļø Deleted ${file}`)
|
|
263
|
+
deleted++
|
|
264
|
+
}
|
|
265
|
+
catch (error) {
|
|
266
|
+
console.error(`ā Failed to delete ${file}:`, error)
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
console.log(`ā
Cleaned up ${deleted} file${deleted > 1 ? 's' : ''}`)
|
|
271
|
+
}
|
|
272
|
+
|
|
185
273
|
/**
|
|
186
274
|
* Update package.json with lint scripts
|
|
187
275
|
*/
|