@dimensional-innovations/tool-config 4.0.0 → 5.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.
Files changed (83) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +7 -120
  3. package/dist/cli/index.js +1812 -0
  4. package/dist/cli/index.js.map +1 -0
  5. package/dist/index.d.ts +401 -0
  6. package/dist/index.js +2644 -0
  7. package/dist/index.js.map +1 -0
  8. package/package.json +22 -15
  9. package/bin/lib/ci-setup.js +0 -142
  10. package/bin/lib/formatting.js +0 -103
  11. package/bin/lib/handlers/eslint.js +0 -61
  12. package/bin/lib/handlers/prettier.js +0 -83
  13. package/bin/lib/handlers/semantic-release.js +0 -60
  14. package/bin/lib/handlers/stylelint.js +0 -85
  15. package/bin/lib/handlers/typescript.js +0 -156
  16. package/bin/lib/package-manager.js +0 -201
  17. package/bin/lib/ui.js +0 -239
  18. package/bin/lib/uninstall.js +0 -199
  19. package/bin/lib/validators.js +0 -28
  20. package/bin/setup-tool-config.js +0 -442
  21. package/src/detectors.js +0 -286
  22. package/src/index.js +0 -69
  23. package/src/tools/eslint/index.js +0 -282
  24. package/src/tools/eslint/presets/base.js +0 -75
  25. package/src/tools/eslint/presets/environments/browser.js +0 -16
  26. package/src/tools/eslint/presets/environments/node.js +0 -21
  27. package/src/tools/eslint/presets/environments/universal.js +0 -18
  28. package/src/tools/eslint/presets/frameworks/angular.js +0 -80
  29. package/src/tools/eslint/presets/frameworks/astro.js +0 -43
  30. package/src/tools/eslint/presets/frameworks/node.js +0 -63
  31. package/src/tools/eslint/presets/frameworks/react.js +0 -81
  32. package/src/tools/eslint/presets/frameworks/solid.js +0 -50
  33. package/src/tools/eslint/presets/frameworks/svelte.js +0 -65
  34. package/src/tools/eslint/presets/frameworks/vanilla.js +0 -22
  35. package/src/tools/eslint/presets/frameworks/vue.js +0 -159
  36. package/src/tools/eslint/presets/imports.js +0 -47
  37. package/src/tools/eslint/presets/typescript.js +0 -142
  38. package/src/tools/prettier/README.md +0 -398
  39. package/src/tools/prettier/index.js +0 -132
  40. package/src/tools/prettier/presets/base.js +0 -36
  41. package/src/tools/prettier/presets/frameworks/astro.js +0 -15
  42. package/src/tools/prettier/presets/frameworks/react.js +0 -15
  43. package/src/tools/prettier/presets/frameworks/svelte.js +0 -22
  44. package/src/tools/prettier/presets/frameworks/vanilla.js +0 -13
  45. package/src/tools/prettier/presets/frameworks/vue.js +0 -21
  46. package/src/tools/prettier/presets/prettierignore.js +0 -57
  47. package/src/tools/semantic-release/CI_SETUP.md +0 -66
  48. package/src/tools/semantic-release/README.md +0 -533
  49. package/src/tools/semantic-release/index.js +0 -130
  50. package/src/tools/semantic-release/presets/default.js +0 -37
  51. package/src/tools/semantic-release/presets/library.js +0 -58
  52. package/src/tools/semantic-release/presets/monorepo.js +0 -48
  53. package/src/tools/semantic-release/templates/.gitlab-ci.yml +0 -89
  54. package/src/tools/semantic-release/templates/bitbucket-pipelines.yml +0 -100
  55. package/src/tools/semantic-release/templates/github-workflow.yml +0 -107
  56. package/src/tools/stylelint/README.md +0 -425
  57. package/src/tools/stylelint/index.js +0 -195
  58. package/src/tools/stylelint/presets/base.js +0 -50
  59. package/src/tools/stylelint/presets/css-modules.js +0 -43
  60. package/src/tools/stylelint/presets/frameworks/react.js +0 -18
  61. package/src/tools/stylelint/presets/frameworks/svelte.js +0 -28
  62. package/src/tools/stylelint/presets/frameworks/vanilla.js +0 -14
  63. package/src/tools/stylelint/presets/frameworks/vue.js +0 -38
  64. package/src/tools/stylelint/presets/scss.js +0 -83
  65. package/src/tools/stylelint/presets/tailwind.js +0 -49
  66. package/src/tools/typescript/README.md +0 -665
  67. package/src/tools/typescript/checker-detection.js +0 -113
  68. package/src/tools/typescript/index.js +0 -202
  69. package/src/tools/typescript/presets/base.js +0 -58
  70. package/src/tools/typescript/presets/environments/browser.js +0 -10
  71. package/src/tools/typescript/presets/environments/node.js +0 -11
  72. package/src/tools/typescript/presets/environments/universal.js +0 -11
  73. package/src/tools/typescript/presets/frameworks/angular.js +0 -11
  74. package/src/tools/typescript/presets/frameworks/astro.js +0 -11
  75. package/src/tools/typescript/presets/frameworks/electron.js +0 -100
  76. package/src/tools/typescript/presets/frameworks/node.js +0 -12
  77. package/src/tools/typescript/presets/frameworks/react.js +0 -10
  78. package/src/tools/typescript/presets/frameworks/solid.js +0 -11
  79. package/src/tools/typescript/presets/frameworks/svelte.js +0 -10
  80. package/src/tools/typescript/presets/frameworks/vanilla.js +0 -9
  81. package/src/tools/typescript/presets/frameworks/vue.js +0 -17
  82. package/src/utils/ignore-patterns.js +0 -157
  83. package/src/utils/package-reader.js +0 -42
@@ -1,442 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- /**
4
- * @dimensional-innovations/tool-config CLI Setup Tool
5
- *
6
- * Interactive configuration generator for ESLint, Prettier, Stylelint, TypeScript, and semantic-release
7
- */
8
-
9
- import prompts from 'prompts'
10
-
11
- import { autoDetect } from '../src/detectors.js'
12
-
13
- import { copyCITemplate } from './lib/ci-setup.js'
14
- import * as eslintHandler from './lib/handlers/eslint.js'
15
- import * as prettierHandler from './lib/handlers/prettier.js'
16
- import * as semanticReleaseHandler from './lib/handlers/semantic-release.js'
17
- import * as stylelintHandler from './lib/handlers/stylelint.js'
18
- import * as typescriptHandler from './lib/handlers/typescript.js'
19
- import { removePackageJsonScripts, updatePackageJsonScripts } from './lib/package-manager.js'
20
- import {
21
- showBanner,
22
- showCICompletion,
23
- showCompletion,
24
- showHelp,
25
- showSection,
26
- showUninstallBanner,
27
- showUninstallCompletion,
28
- showVersion
29
- } from './lib/ui.js'
30
- import {
31
- detectInstalledCI,
32
- detectInstalledTools,
33
- uninstallCIConfig,
34
- uninstallTool
35
- } from './lib/uninstall.js'
36
- import { VALID_TOOLS, validateProvider, validateTool } from './lib/validators.js'
37
-
38
- // Tool handler registry
39
- const TOOL_HANDLERS = {
40
- eslint: eslintHandler,
41
- prettier: prettierHandler,
42
- stylelint: stylelintHandler,
43
- typescript: typescriptHandler,
44
- 'semantic-release': semanticReleaseHandler
45
- }
46
-
47
- /**
48
- * Get tool scripts (wrapper for handler getScripts)
49
- */
50
- function getToolScripts(tool, detected) {
51
- const handler = TOOL_HANDLERS[tool]
52
- return handler.getScripts ? handler.getScripts(detected) : {}
53
- }
54
-
55
- /**
56
- * Setup tools
57
- * @returns {Object} Summary of created files and scripts
58
- */
59
- async function setupTools(tools, detected, cwd, dryRun = false) {
60
- const { createProgress, SYMBOLS, colors } = await import('./lib/formatting.js')
61
-
62
- console.log('')
63
- console.log('Creating configuration files...')
64
- console.log('')
65
-
66
- // Track which tools successfully created configs
67
- const successfulTools = []
68
- const createdFiles = []
69
-
70
- let current = 0
71
- for (const tool of tools) {
72
- current++
73
- const handler = TOOL_HANDLERS[tool]
74
- const filename = handler.getConfigFilename()
75
-
76
- const progressLine = colors.dim(createProgress(current, tools.length, filename))
77
- process.stdout.write(progressLine)
78
-
79
- const success = await handler.writeConfig(cwd, detected, dryRun)
80
-
81
- if (success) {
82
- successfulTools.push(tool)
83
- createdFiles.push(filename)
84
- console.log(` ${SYMBOLS.success}`)
85
- } else {
86
- console.log(` ${SYMBOLS.warning}`)
87
- }
88
- }
89
-
90
- // Only add scripts for tools that created configs
91
- const addedScripts = []
92
- if (successfulTools.length > 0) {
93
- console.log('')
94
- console.log('Adding npm scripts...')
95
- console.log('')
96
-
97
- // Collect all scripts that will be added
98
- for (const tool of successfulTools) {
99
- const scripts = getToolScripts(tool, detected)
100
- addedScripts.push(...Object.keys(scripts))
101
- }
102
-
103
- updatePackageJsonScripts(successfulTools, getToolScripts, { detected, cwd, dryRun })
104
- }
105
-
106
- return {
107
- files: createdFiles,
108
- scripts: addedScripts
109
- }
110
- }
111
-
112
- /**
113
- * Prompt for CI provider if not detected
114
- */
115
- async function promptForProvider() {
116
- const providerResponse = await prompts({
117
- type: 'select',
118
- name: 'provider',
119
- message: 'Which CI/CD platform would you like to use?',
120
- choices: [
121
- { title: 'GitLab CI', value: 'gitlab' },
122
- { title: 'GitHub Actions', value: 'github' },
123
- { title: 'Bitbucket Pipelines', value: 'bitbucket' }
124
- ]
125
- })
126
-
127
- return providerResponse.provider
128
- }
129
-
130
- /**
131
- * Setup CI/CD pipeline
132
- */
133
- async function setupCI(detected, cwd, dryRun, ciProvider = null) {
134
- showSection('🚀 CI/CD Pipeline Setup')
135
-
136
- let provider = ciProvider || detected.gitProvider
137
-
138
- // If provider not detected or unknown, prompt for it
139
- if (!provider || provider === 'unknown') {
140
- const { SYMBOLS } = await import('./lib/formatting.js')
141
- provider = await promptForProvider()
142
- if (!provider) {
143
- console.log(`${SYMBOLS.warning} Skipping CI/CD setup.`)
144
- console.log('')
145
- return
146
- }
147
- }
148
-
149
- console.log('📝 Setting up CI/CD...')
150
- console.log('')
151
- copyCITemplate(provider, cwd, dryRun)
152
- showCICompletion(dryRun)
153
- }
154
-
155
- /**
156
- * Uninstall tools
157
- */
158
- function uninstallTools(tools, detected, cwd, dryRun = false) {
159
- showSection('🗑️ Removing configuration files...')
160
-
161
- let removedCount = 0
162
-
163
- for (const tool of tools) {
164
- console.log(`${tool}:`)
165
- const handler = TOOL_HANDLERS[tool]
166
- const success = uninstallTool(tool, handler, cwd, dryRun)
167
- if (success) {
168
- removedCount++
169
- }
170
- }
171
-
172
- // Remove scripts for successfully uninstalled tools
173
- if (tools.length > 0) {
174
- showSection('📦 Removing package.json scripts...')
175
- removePackageJsonScripts(tools, getToolScripts, { detected, cwd, dryRun })
176
- }
177
-
178
- return removedCount
179
- }
180
-
181
- /**
182
- * Main CLI function
183
- */
184
- async function main() {
185
- // Parse CLI arguments
186
- const args = process.argv.slice(2)
187
- const flags = {
188
- help: args.includes('--help') || args.includes('-h'),
189
- version: args.includes('--version') || args.includes('-v'),
190
- dryRun: args.includes('--dry-run') || args.includes('-d'),
191
- all: args.includes('--all') || args.includes('-a'),
192
- setupCI: args.includes('--setup-ci'),
193
- uninstall: args.includes('--uninstall')
194
- }
195
-
196
- // Check for --ci flag with optional provider
197
- const ciIndex = args.indexOf('--ci')
198
- const ciProvider =
199
- ciIndex !== -1 && args[ciIndex + 1] && !args[ciIndex + 1].startsWith('-')
200
- ? args[ciIndex + 1]
201
- : null
202
- const hasCI = args.includes('--ci')
203
-
204
- // Single tool mode: setup-tool-config eslint (but not --ci provider value)
205
- const singleTool = args.find(arg => !arg.startsWith('-') && arg !== ciProvider)
206
-
207
- // Handle flags
208
- if (flags.help) {
209
- showHelp()
210
- process.exit(0)
211
- }
212
-
213
- if (flags.version) {
214
- showVersion()
215
- process.exit(0)
216
- }
217
-
218
- const cwd = process.cwd()
219
-
220
- // Handle uninstall mode
221
- if (flags.uninstall) {
222
- const detected = autoDetect(cwd)
223
- const installedTools = detectInstalledTools(cwd)
224
- const installedCI = detectInstalledCI(cwd)
225
-
226
- showUninstallBanner(installedTools, installedCI)
227
-
228
- // No tools or CI detected
229
- if (installedTools.length === 0 && !installedCI) {
230
- console.log('Nothing to uninstall.')
231
- process.exit(0)
232
- }
233
-
234
- // Handle --uninstall --ci flag
235
- if (hasCI) {
236
- if (!installedCI) {
237
- console.log('⚠️ No CI/CD configuration detected')
238
- process.exit(0)
239
- }
240
-
241
- showSection('🗑️ Removing CI/CD configuration...')
242
- const success = uninstallCIConfig(installedCI, cwd, flags.dryRun)
243
- showUninstallCompletion(flags.dryRun, success ? 1 : 0)
244
- process.exit(0)
245
- }
246
-
247
- // Handle --uninstall --all flag
248
- if (flags.all) {
249
- if (installedTools.length === 0) {
250
- console.log('⚠️ No tools detected to uninstall')
251
- process.exit(0)
252
- }
253
-
254
- const removedCount = uninstallTools(installedTools, detected, cwd, flags.dryRun)
255
- showUninstallCompletion(flags.dryRun, removedCount)
256
- process.exit(0)
257
- }
258
-
259
- // Handle --uninstall <tool> flag
260
- if (singleTool) {
261
- if (!installedTools.includes(singleTool)) {
262
- console.log(`⚠️ ${singleTool} is not installed`)
263
- process.exit(0)
264
- }
265
-
266
- const removedCount = uninstallTools([singleTool], detected, cwd, flags.dryRun)
267
- showUninstallCompletion(flags.dryRun, removedCount)
268
- process.exit(0)
269
- }
270
-
271
- // Interactive uninstall mode
272
- if (installedTools.length === 0) {
273
- console.log('⚠️ No tools detected to uninstall')
274
- process.exit(0)
275
- }
276
-
277
- const response = await prompts({
278
- type: 'multiselect',
279
- name: 'tools',
280
- message: 'Which tools would you like to uninstall?',
281
- choices: installedTools.map(tool => ({
282
- title: tool,
283
- value: tool,
284
- selected: false
285
- })),
286
- hint: '- Space to select. Return to submit'
287
- })
288
-
289
- if (!response.tools || response.tools.length === 0) {
290
- console.log('')
291
- console.log('❌ No tools selected. Exiting.')
292
- process.exit(0)
293
- }
294
-
295
- const removedCount = uninstallTools(response.tools, detected, cwd, flags.dryRun)
296
-
297
- // Ask about CI removal if detected
298
- if (installedCI) {
299
- const ciResponse = await prompts({
300
- type: 'confirm',
301
- name: 'removeCI',
302
- message: `Remove ${installedCI} CI/CD configuration?`,
303
- initial: false
304
- })
305
-
306
- if (ciResponse.removeCI) {
307
- showSection('🗑️ Removing CI/CD configuration...')
308
- uninstallCIConfig(installedCI, cwd, flags.dryRun)
309
- }
310
- }
311
-
312
- showUninstallCompletion(flags.dryRun, removedCount)
313
- process.exit(0)
314
- }
315
-
316
- // Show banner and auto-detect
317
- const detected = autoDetect(cwd)
318
- showBanner(detected)
319
-
320
- // Handle standalone --setup-ci flag
321
- if (flags.setupCI) {
322
- await setupCI(detected, cwd, flags.dryRun)
323
- process.exit(0)
324
- }
325
-
326
- // Handle --ci flag with provider
327
- if (hasCI && ciProvider) {
328
- validateProvider(ciProvider)
329
- await setupCI(detected, cwd, flags.dryRun, ciProvider)
330
- process.exit(0)
331
- }
332
-
333
- // Handle --all flag
334
- if (flags.all) {
335
- const summary = await setupTools(VALID_TOOLS, detected, cwd, flags.dryRun)
336
- showCompletion(flags.dryRun, summary.files, summary.scripts)
337
- process.exit(0)
338
- }
339
-
340
- // Handle single tool mode
341
- if (singleTool) {
342
- validateTool(singleTool)
343
- const summary = await setupTools([singleTool], detected, cwd, flags.dryRun)
344
-
345
- // If semantic-release + --ci flag, setup CI
346
- if (singleTool === 'semantic-release' && hasCI) {
347
- await setupCI(detected, cwd, flags.dryRun, ciProvider)
348
- }
349
-
350
- showCompletion(flags.dryRun, summary.files, summary.scripts)
351
- process.exit(0)
352
- }
353
-
354
- // Interactive mode
355
- const response = await prompts([
356
- {
357
- type: 'multiselect',
358
- name: 'tools',
359
- message: 'Select development tools to configure:',
360
- choices: [
361
- {
362
- title: 'ESLint Catch bugs and enforce standards',
363
- value: 'eslint',
364
- selected: true
365
- },
366
- {
367
- title: 'Prettier Auto-format code consistently',
368
- value: 'prettier',
369
- selected: true
370
- },
371
- {
372
- title: 'Stylelint Lint CSS, SCSS, and style files',
373
- value: 'stylelint',
374
- selected: false
375
- },
376
- {
377
- title: 'TypeScript Type safety and better tooling',
378
- value: 'typescript',
379
- selected: detected.typescript
380
- },
381
- {
382
- title: 'semantic-release Automated versioning & releases',
383
- value: 'semantic-release',
384
- selected: false
385
- }
386
- ],
387
- hint: ' (Recommended tools are pre-selected)'
388
- }
389
- ])
390
-
391
- if (!response.tools || response.tools.length === 0) {
392
- console.log('')
393
- console.log('❌ No tools selected. Exiting.')
394
- process.exit(0)
395
- }
396
-
397
- const summary = await setupTools(response.tools, detected, cwd, flags.dryRun)
398
-
399
- // If semantic-release selected, prompt for CI setup
400
- if (response.tools.includes('semantic-release')) {
401
- console.log('')
402
- console.log('🚀 semantic-release needs CI/CD to automate releases')
403
- console.log('')
404
-
405
- const ciResponse = await prompts({
406
- type: 'confirm',
407
- name: 'setupCI',
408
- message: 'Setup CI/CD pipeline now?',
409
- initial: true
410
- })
411
-
412
- if (ciResponse.setupCI) {
413
- let provider = detected.gitProvider
414
-
415
- // If provider not detected or unknown, prompt for it
416
- if (!provider || provider === 'unknown') {
417
- provider = await promptForProvider()
418
- if (!provider) {
419
- console.log('⚠️ Skipping CI/CD setup.')
420
- } else {
421
- console.log('📝 Setting up CI/CD...')
422
- console.log('')
423
- copyCITemplate(provider, cwd, flags.dryRun)
424
- }
425
- } else {
426
- console.log('📝 Setting up CI/CD...')
427
- console.log('')
428
- copyCITemplate(provider, cwd, flags.dryRun)
429
- }
430
- }
431
- }
432
-
433
- showCompletion(flags.dryRun, summary.files, summary.scripts)
434
- }
435
-
436
- // Run CLI
437
- main().catch(error => {
438
- console.error('')
439
- console.error('❌ Error:', error.message)
440
- console.error('')
441
- process.exit(1)
442
- })