@bagelink/workspace 1.7.41 → 1.7.45

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 CHANGED
@@ -209,6 +209,12 @@ export default defineWorkspace(configs)
209
209
  message: "Create/update vite.config.ts?",
210
210
  initial: true
211
211
  },
212
+ {
213
+ type: "confirm",
214
+ name: "createTsConfig",
215
+ message: "Create tsconfig.app.json with path aliases?",
216
+ initial: true
217
+ },
212
218
  {
213
219
  type: "confirm",
214
220
  name: "generateNetlify",
@@ -222,6 +228,9 @@ export default defineWorkspace(configs)
222
228
  if (setupResponse.updateViteConfig) {
223
229
  updateViteConfig(root);
224
230
  }
231
+ if (setupResponse.createTsConfig) {
232
+ createTsConfig(root);
233
+ }
225
234
  if (setupResponse.generateNetlify) {
226
235
  const prodConfig = {
227
236
  host: productionHost,
@@ -273,6 +282,31 @@ function updatePackageJsonScripts(root) {
273
282
  console.error("\u274C Failed to update package.json:", error);
274
283
  }
275
284
  }
285
+ function createTsConfig(root) {
286
+ const tsConfigPath = node_path.resolve(root, "tsconfig.app.json");
287
+ const tsConfigExists = node_fs.existsSync(tsConfigPath);
288
+ if (tsConfigExists) {
289
+ console.log("\u26A0\uFE0F tsconfig.app.json already exists, skipping");
290
+ return;
291
+ }
292
+ const tsConfigContent = `{
293
+ "extends": "../tsconfig.json",
294
+ "compilerOptions": {
295
+ "composite": true,
296
+ "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
297
+ "baseUrl": ".",
298
+ "paths": {
299
+ "@/*": ["./src/*"],
300
+ "@shared/*": ["../shared/*"]
301
+ }
302
+ },
303
+ "include": ["src/**/*", "src/**/*.vue"],
304
+ "exclude": ["node_modules"]
305
+ }
306
+ `;
307
+ node_fs.writeFileSync(tsConfigPath, tsConfigContent, "utf-8");
308
+ console.log("\u2705 Created tsconfig.app.json");
309
+ }
276
310
  function updateViteConfig(root) {
277
311
  const viteConfigPath = node_path.resolve(root, "vite.config.ts");
278
312
  const viteConfigExists = node_fs.existsSync(viteConfigPath);
@@ -311,6 +345,28 @@ export default defineConfig({
311
345
  console.log("\u2705 Created vite.config.ts");
312
346
  }
313
347
 
348
+ const REDUNDANT_FILES = [
349
+ // Old ESLint configs
350
+ ".eslintrc",
351
+ ".eslintrc.json",
352
+ ".eslintrc.js",
353
+ ".eslintrc.cjs",
354
+ ".eslintrc.yaml",
355
+ ".eslintrc.yml",
356
+ // Oxlint
357
+ "oxlint.json",
358
+ // Old Prettier configs (we create .prettierrc)
359
+ "prettier.config.js",
360
+ "prettier.config.cjs",
361
+ "prettier.config.mjs",
362
+ ".prettierrc.json",
363
+ ".prettierrc.yaml",
364
+ ".prettierrc.yml",
365
+ ".prettierrc.js",
366
+ ".prettierrc.cjs",
367
+ ".prettierrc.mjs",
368
+ ".prettierrc.toml"
369
+ ];
314
370
  async function setupLint(root = process__default.cwd(), isWorkspace = false) {
315
371
  console.log("\n\u{1F50D} Setting up linting...\n");
316
372
  const response = await prompts__default([
@@ -325,6 +381,12 @@ async function setupLint(root = process__default.cwd(), isWorkspace = false) {
325
381
  { title: "Git Hooks", value: "githooks", selected: false }
326
382
  ]
327
383
  },
384
+ {
385
+ type: "confirm",
386
+ name: "cleanRedundant",
387
+ message: "Clean up redundant lint config files?",
388
+ initial: true
389
+ },
328
390
  {
329
391
  type: "confirm",
330
392
  name: "installDeps",
@@ -336,7 +398,10 @@ async function setupLint(root = process__default.cwd(), isWorkspace = false) {
336
398
  console.log("\n\u274C Setup cancelled.\n");
337
399
  process__default.exit(1);
338
400
  }
339
- const { configs, installDeps } = response;
401
+ const { configs, cleanRedundant, installDeps } = response;
402
+ if (cleanRedundant) {
403
+ await cleanRedundantFiles(root);
404
+ }
340
405
  if (configs.includes("eslint")) {
341
406
  createEslintConfig(root, isWorkspace);
342
407
  }
@@ -441,6 +506,44 @@ function createGitHooks(root) {
441
506
  console.log("\u2139\uFE0F Add simple-git-hooks and lint-staged to devDependencies");
442
507
  console.log(" Then run: npx simple-git-hooks");
443
508
  }
509
+ async function cleanRedundantFiles(root) {
510
+ const foundFiles = [];
511
+ for (const file of REDUNDANT_FILES) {
512
+ const filePath = node_path.resolve(root, file);
513
+ if (node_fs.existsSync(filePath)) {
514
+ foundFiles.push(file);
515
+ }
516
+ }
517
+ if (foundFiles.length === 0) {
518
+ console.log("\u2728 No redundant files found");
519
+ return;
520
+ }
521
+ console.log("\n\u{1F4CB} Found redundant files:");
522
+ foundFiles.forEach((file) => {
523
+ console.log(` - ${file}`);
524
+ });
525
+ const confirmResponse = await prompts__default({
526
+ type: "confirm",
527
+ name: "confirm",
528
+ message: `Delete ${foundFiles.length} redundant file${foundFiles.length > 1 ? "s" : ""}?`,
529
+ initial: true
530
+ });
531
+ if (!confirmResponse.confirm) {
532
+ console.log("\u23ED\uFE0F Skipped cleaning redundant files");
533
+ return;
534
+ }
535
+ let deleted = 0;
536
+ for (const file of foundFiles) {
537
+ try {
538
+ node_fs.unlinkSync(node_path.resolve(root, file));
539
+ console.log(`\u{1F5D1}\uFE0F Deleted ${file}`);
540
+ deleted++;
541
+ } catch (error) {
542
+ console.error(`\u274C Failed to delete ${file}:`, error);
543
+ }
544
+ }
545
+ console.log(`\u2705 Cleaned up ${deleted} file${deleted > 1 ? "s" : ""}`);
546
+ }
444
547
  function updatePackageJsonLint(root, configs) {
445
548
  const packageJsonPath = node_path.resolve(root, "package.json");
446
549
  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';
@@ -202,6 +202,12 @@ export default defineWorkspace(configs)
202
202
  message: "Create/update vite.config.ts?",
203
203
  initial: true
204
204
  },
205
+ {
206
+ type: "confirm",
207
+ name: "createTsConfig",
208
+ message: "Create tsconfig.app.json with path aliases?",
209
+ initial: true
210
+ },
205
211
  {
206
212
  type: "confirm",
207
213
  name: "generateNetlify",
@@ -215,6 +221,9 @@ export default defineWorkspace(configs)
215
221
  if (setupResponse.updateViteConfig) {
216
222
  updateViteConfig(root);
217
223
  }
224
+ if (setupResponse.createTsConfig) {
225
+ createTsConfig(root);
226
+ }
218
227
  if (setupResponse.generateNetlify) {
219
228
  const prodConfig = {
220
229
  host: productionHost,
@@ -266,6 +275,31 @@ function updatePackageJsonScripts(root) {
266
275
  console.error("\u274C Failed to update package.json:", error);
267
276
  }
268
277
  }
278
+ function createTsConfig(root) {
279
+ const tsConfigPath = resolve(root, "tsconfig.app.json");
280
+ const tsConfigExists = existsSync(tsConfigPath);
281
+ if (tsConfigExists) {
282
+ console.log("\u26A0\uFE0F tsconfig.app.json already exists, skipping");
283
+ return;
284
+ }
285
+ const tsConfigContent = `{
286
+ "extends": "../tsconfig.json",
287
+ "compilerOptions": {
288
+ "composite": true,
289
+ "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
290
+ "baseUrl": ".",
291
+ "paths": {
292
+ "@/*": ["./src/*"],
293
+ "@shared/*": ["../shared/*"]
294
+ }
295
+ },
296
+ "include": ["src/**/*", "src/**/*.vue"],
297
+ "exclude": ["node_modules"]
298
+ }
299
+ `;
300
+ writeFileSync(tsConfigPath, tsConfigContent, "utf-8");
301
+ console.log("\u2705 Created tsconfig.app.json");
302
+ }
269
303
  function updateViteConfig(root) {
270
304
  const viteConfigPath = resolve(root, "vite.config.ts");
271
305
  const viteConfigExists = existsSync(viteConfigPath);
@@ -304,6 +338,28 @@ export default defineConfig({
304
338
  console.log("\u2705 Created vite.config.ts");
305
339
  }
306
340
 
341
+ const REDUNDANT_FILES = [
342
+ // Old ESLint configs
343
+ ".eslintrc",
344
+ ".eslintrc.json",
345
+ ".eslintrc.js",
346
+ ".eslintrc.cjs",
347
+ ".eslintrc.yaml",
348
+ ".eslintrc.yml",
349
+ // Oxlint
350
+ "oxlint.json",
351
+ // Old Prettier configs (we create .prettierrc)
352
+ "prettier.config.js",
353
+ "prettier.config.cjs",
354
+ "prettier.config.mjs",
355
+ ".prettierrc.json",
356
+ ".prettierrc.yaml",
357
+ ".prettierrc.yml",
358
+ ".prettierrc.js",
359
+ ".prettierrc.cjs",
360
+ ".prettierrc.mjs",
361
+ ".prettierrc.toml"
362
+ ];
307
363
  async function setupLint(root = process.cwd(), isWorkspace = false) {
308
364
  console.log("\n\u{1F50D} Setting up linting...\n");
309
365
  const response = await prompts([
@@ -318,6 +374,12 @@ async function setupLint(root = process.cwd(), isWorkspace = false) {
318
374
  { title: "Git Hooks", value: "githooks", selected: false }
319
375
  ]
320
376
  },
377
+ {
378
+ type: "confirm",
379
+ name: "cleanRedundant",
380
+ message: "Clean up redundant lint config files?",
381
+ initial: true
382
+ },
321
383
  {
322
384
  type: "confirm",
323
385
  name: "installDeps",
@@ -329,7 +391,10 @@ async function setupLint(root = process.cwd(), isWorkspace = false) {
329
391
  console.log("\n\u274C Setup cancelled.\n");
330
392
  process.exit(1);
331
393
  }
332
- const { configs, installDeps } = response;
394
+ const { configs, cleanRedundant, installDeps } = response;
395
+ if (cleanRedundant) {
396
+ await cleanRedundantFiles(root);
397
+ }
333
398
  if (configs.includes("eslint")) {
334
399
  createEslintConfig(root, isWorkspace);
335
400
  }
@@ -434,6 +499,44 @@ function createGitHooks(root) {
434
499
  console.log("\u2139\uFE0F Add simple-git-hooks and lint-staged to devDependencies");
435
500
  console.log(" Then run: npx simple-git-hooks");
436
501
  }
502
+ async function cleanRedundantFiles(root) {
503
+ const foundFiles = [];
504
+ for (const file of REDUNDANT_FILES) {
505
+ const filePath = resolve(root, file);
506
+ if (existsSync(filePath)) {
507
+ foundFiles.push(file);
508
+ }
509
+ }
510
+ if (foundFiles.length === 0) {
511
+ console.log("\u2728 No redundant files found");
512
+ return;
513
+ }
514
+ console.log("\n\u{1F4CB} Found redundant files:");
515
+ foundFiles.forEach((file) => {
516
+ console.log(` - ${file}`);
517
+ });
518
+ const confirmResponse = await prompts({
519
+ type: "confirm",
520
+ name: "confirm",
521
+ message: `Delete ${foundFiles.length} redundant file${foundFiles.length > 1 ? "s" : ""}?`,
522
+ initial: true
523
+ });
524
+ if (!confirmResponse.confirm) {
525
+ console.log("\u23ED\uFE0F Skipped cleaning redundant files");
526
+ return;
527
+ }
528
+ let deleted = 0;
529
+ for (const file of foundFiles) {
530
+ try {
531
+ unlinkSync(resolve(root, file));
532
+ console.log(`\u{1F5D1}\uFE0F Deleted ${file}`);
533
+ deleted++;
534
+ } catch (error) {
535
+ console.error(`\u274C Failed to delete ${file}:`, error);
536
+ }
537
+ }
538
+ console.log(`\u2705 Cleaned up ${deleted} file${deleted > 1 ? "s" : ""}`);
539
+ }
437
540
  function updatePackageJsonLint(root, configs) {
438
541
  const packageJsonPath = resolve(root, "package.json");
439
542
  if (!existsSync(packageJsonPath)) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@bagelink/workspace",
3
3
  "type": "module",
4
- "version": "1.7.41",
4
+ "version": "1.7.45",
5
5
  "description": "Monorepo workspace tooling for Bagel projects with proxy and config management",
6
6
  "author": {
7
7
  "name": "Bagel Studio",
package/src/init.ts CHANGED
@@ -91,6 +91,12 @@ export default defineWorkspace(configs)
91
91
  message: 'Create/update vite.config.ts?',
92
92
  initial: true,
93
93
  },
94
+ {
95
+ type: 'confirm',
96
+ name: 'createTsConfig',
97
+ message: 'Create tsconfig.app.json with path aliases?',
98
+ initial: true,
99
+ },
94
100
  {
95
101
  type: 'confirm',
96
102
  name: 'generateNetlify',
@@ -107,6 +113,10 @@ export default defineWorkspace(configs)
107
113
  updateViteConfig(root)
108
114
  }
109
115
 
116
+ if (setupResponse.createTsConfig) {
117
+ createTsConfig(root)
118
+ }
119
+
110
120
  if (setupResponse.generateNetlify) {
111
121
  const prodConfig: WorkspaceConfig = {
112
122
  host: productionHost,
@@ -216,6 +226,38 @@ function updatePackageJsonScripts(root: string): void {
216
226
  }
217
227
  }
218
228
 
229
+ /**
230
+ * Create tsconfig.app.json with path aliases
231
+ */
232
+ function createTsConfig(root: string): void {
233
+ const tsConfigPath = resolve(root, 'tsconfig.app.json')
234
+ const tsConfigExists = existsSync(tsConfigPath)
235
+
236
+ if (tsConfigExists) {
237
+ console.log('⚠️ tsconfig.app.json already exists, skipping')
238
+ return
239
+ }
240
+
241
+ const tsConfigContent = `{
242
+ "extends": "../tsconfig.json",
243
+ "compilerOptions": {
244
+ "composite": true,
245
+ "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
246
+ "baseUrl": ".",
247
+ "paths": {
248
+ "@/*": ["./src/*"],
249
+ "@shared/*": ["../shared/*"]
250
+ }
251
+ },
252
+ "include": ["src/**/*", "src/**/*.vue"],
253
+ "exclude": ["node_modules"]
254
+ }
255
+ `
256
+
257
+ writeFileSync(tsConfigPath, tsConfigContent, 'utf-8')
258
+ console.log('✅ Created tsconfig.app.json')
259
+ }
260
+
219
261
  /**
220
262
  * Create or update vite.config.ts
221
263
  */
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
  */
@@ -0,0 +1,23 @@
1
+ {
2
+ "extends": "../tsconfig.json",
3
+ "compilerOptions": {
4
+ "composite": true,
5
+ "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
6
+ "baseUrl": ".",
7
+ "paths": {
8
+ "@/*": [
9
+ "./src/*"
10
+ ],
11
+ "@shared/*": [
12
+ "../shared/*"
13
+ ]
14
+ }
15
+ },
16
+ "include": [
17
+ "src/**/*",
18
+ "src/**/*.vue"
19
+ ],
20
+ "exclude": [
21
+ "node_modules"
22
+ ]
23
+ }