@dimensional-innovations/tool-config 3.1.0 → 5.0.0

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 (78) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +7 -120
  3. package/package.json +21 -14
  4. package/bin/lib/ci-setup.js +0 -142
  5. package/bin/lib/formatting.js +0 -103
  6. package/bin/lib/handlers/eslint.js +0 -61
  7. package/bin/lib/handlers/prettier.js +0 -83
  8. package/bin/lib/handlers/semantic-release.js +0 -60
  9. package/bin/lib/handlers/stylelint.js +0 -85
  10. package/bin/lib/handlers/typescript.js +0 -156
  11. package/bin/lib/package-manager.js +0 -201
  12. package/bin/lib/ui.js +0 -239
  13. package/bin/lib/uninstall.js +0 -199
  14. package/bin/lib/validators.js +0 -28
  15. package/bin/setup-tool-config.js +0 -442
  16. package/src/detectors.js +0 -286
  17. package/src/index.js +0 -69
  18. package/src/tools/eslint/index.js +0 -282
  19. package/src/tools/eslint/presets/base.js +0 -82
  20. package/src/tools/eslint/presets/environments/browser.js +0 -16
  21. package/src/tools/eslint/presets/environments/node.js +0 -21
  22. package/src/tools/eslint/presets/environments/universal.js +0 -18
  23. package/src/tools/eslint/presets/frameworks/angular.js +0 -74
  24. package/src/tools/eslint/presets/frameworks/astro.js +0 -38
  25. package/src/tools/eslint/presets/frameworks/node.js +0 -57
  26. package/src/tools/eslint/presets/frameworks/react.js +0 -76
  27. package/src/tools/eslint/presets/frameworks/solid.js +0 -45
  28. package/src/tools/eslint/presets/frameworks/svelte.js +0 -78
  29. package/src/tools/eslint/presets/frameworks/vanilla.js +0 -16
  30. package/src/tools/eslint/presets/frameworks/vue.js +0 -154
  31. package/src/tools/eslint/presets/imports.js +0 -47
  32. package/src/tools/eslint/presets/typescript.js +0 -142
  33. package/src/tools/prettier/README.md +0 -398
  34. package/src/tools/prettier/index.js +0 -132
  35. package/src/tools/prettier/presets/base.js +0 -36
  36. package/src/tools/prettier/presets/frameworks/astro.js +0 -15
  37. package/src/tools/prettier/presets/frameworks/react.js +0 -15
  38. package/src/tools/prettier/presets/frameworks/svelte.js +0 -22
  39. package/src/tools/prettier/presets/frameworks/vanilla.js +0 -13
  40. package/src/tools/prettier/presets/frameworks/vue.js +0 -21
  41. package/src/tools/prettier/presets/prettierignore.js +0 -56
  42. package/src/tools/semantic-release/CI_SETUP.md +0 -66
  43. package/src/tools/semantic-release/README.md +0 -533
  44. package/src/tools/semantic-release/index.js +0 -130
  45. package/src/tools/semantic-release/presets/default.js +0 -37
  46. package/src/tools/semantic-release/presets/library.js +0 -58
  47. package/src/tools/semantic-release/presets/monorepo.js +0 -48
  48. package/src/tools/semantic-release/templates/.gitlab-ci.yml +0 -89
  49. package/src/tools/semantic-release/templates/bitbucket-pipelines.yml +0 -100
  50. package/src/tools/semantic-release/templates/github-workflow.yml +0 -107
  51. package/src/tools/stylelint/README.md +0 -425
  52. package/src/tools/stylelint/index.js +0 -195
  53. package/src/tools/stylelint/presets/base.js +0 -50
  54. package/src/tools/stylelint/presets/css-modules.js +0 -43
  55. package/src/tools/stylelint/presets/frameworks/react.js +0 -18
  56. package/src/tools/stylelint/presets/frameworks/svelte.js +0 -28
  57. package/src/tools/stylelint/presets/frameworks/vanilla.js +0 -14
  58. package/src/tools/stylelint/presets/frameworks/vue.js +0 -38
  59. package/src/tools/stylelint/presets/scss.js +0 -83
  60. package/src/tools/stylelint/presets/tailwind.js +0 -49
  61. package/src/tools/typescript/README.md +0 -665
  62. package/src/tools/typescript/checker-detection.js +0 -113
  63. package/src/tools/typescript/index.js +0 -202
  64. package/src/tools/typescript/presets/base.js +0 -58
  65. package/src/tools/typescript/presets/environments/browser.js +0 -10
  66. package/src/tools/typescript/presets/environments/node.js +0 -11
  67. package/src/tools/typescript/presets/environments/universal.js +0 -11
  68. package/src/tools/typescript/presets/frameworks/angular.js +0 -11
  69. package/src/tools/typescript/presets/frameworks/astro.js +0 -11
  70. package/src/tools/typescript/presets/frameworks/electron.js +0 -100
  71. package/src/tools/typescript/presets/frameworks/node.js +0 -12
  72. package/src/tools/typescript/presets/frameworks/react.js +0 -10
  73. package/src/tools/typescript/presets/frameworks/solid.js +0 -11
  74. package/src/tools/typescript/presets/frameworks/svelte.js +0 -10
  75. package/src/tools/typescript/presets/frameworks/vanilla.js +0 -9
  76. package/src/tools/typescript/presets/frameworks/vue.js +0 -17
  77. package/src/utils/ignore-patterns.js +0 -157
  78. package/src/utils/package-reader.js +0 -42
@@ -1,60 +0,0 @@
1
- /**
2
- * semantic-release handler for setup-tool-config CLI
3
- */
4
-
5
- import { existsSync, writeFileSync } from 'fs'
6
- import { join } from 'path'
7
-
8
- /**
9
- * Get config filename
10
- */
11
- export function getConfigFilename() {
12
- return 'release.config.js'
13
- }
14
-
15
- /**
16
- * Generate config file content
17
- */
18
- export function generateConfigContent() {
19
- return `import { createConfig } from '@dimensional-innovations/tool-config'
20
-
21
- export default createConfig('semantic-release')
22
- `
23
- }
24
-
25
- /**
26
- * Get npm scripts
27
- */
28
- export function getScripts() {
29
- return {
30
- release: 'semantic-release'
31
- }
32
- }
33
-
34
- /**
35
- * Write config file
36
- */
37
- export function writeConfig(cwd, _detected, dryRun = false) {
38
- const filename = getConfigFilename()
39
- const filepath = join(cwd, filename)
40
- const content = generateConfigContent()
41
-
42
- if (existsSync(filepath)) {
43
- console.log(` ⚠️ ${filename} already exists - skipping`)
44
- return false
45
- }
46
-
47
- if (dryRun) {
48
- console.log(` 📄 Would create: ${filename}`)
49
- return true
50
- }
51
-
52
- try {
53
- writeFileSync(filepath, content, 'utf8')
54
- console.log(` ✅ Created: ${filename}`)
55
- return true
56
- } catch (error) {
57
- console.error(` ❌ Failed to create ${filename}:`, error.message)
58
- return false
59
- }
60
- }
@@ -1,85 +0,0 @@
1
- /**
2
- * Stylelint handler for setup-tool-config CLI
3
- */
4
-
5
- import { existsSync, writeFileSync } from 'fs'
6
- import { join } from 'path'
7
-
8
- /**
9
- * Get config filename
10
- */
11
- export function getConfigFilename() {
12
- return 'stylelint.config.js'
13
- }
14
-
15
- /**
16
- * Generate config file content
17
- */
18
- export function generateConfigContent() {
19
- return `import { createConfig } from '@dimensional-innovations/tool-config'
20
-
21
- export default createConfig('stylelint')
22
- `
23
- }
24
-
25
- /**
26
- * Get file extensions for Stylelint based on framework and CSS type
27
- */
28
- function getStylelintExtensions(framework, cssType) {
29
- const extensions = ['css']
30
-
31
- // Add preprocessor extensions
32
- if (cssType.preprocessor === 'scss') {
33
- extensions.push('scss')
34
- } else if (cssType.preprocessor === 'less') {
35
- extensions.push('less')
36
- }
37
-
38
- // Add framework-specific extensions
39
- if (framework === 'vue') extensions.push('vue')
40
- if (framework === 'svelte') extensions.push('svelte')
41
-
42
- return extensions
43
- }
44
-
45
- /**
46
- * Get npm scripts based on detected framework and CSS type
47
- */
48
- export function getScripts(detected) {
49
- const extensions = getStylelintExtensions(detected.framework, detected.cssType)
50
- const pattern =
51
- extensions.length === 1 ? `**/*.${extensions[0]}` : `**/*.{${extensions.join(',')}}`
52
-
53
- return {
54
- style: `stylelint "${pattern}" --allow-empty-input`,
55
- 'style:fix': `stylelint "${pattern}" --fix --allow-empty-input`
56
- }
57
- }
58
-
59
- /**
60
- * Write config file
61
- */
62
- export function writeConfig(cwd, _detected, dryRun = false) {
63
- const filename = getConfigFilename()
64
- const filepath = join(cwd, filename)
65
- const content = generateConfigContent()
66
-
67
- if (existsSync(filepath)) {
68
- console.log(` ⚠️ ${filename} already exists - skipping`)
69
- return false
70
- }
71
-
72
- if (dryRun) {
73
- console.log(` 📄 Would create: ${filename}`)
74
- return true
75
- }
76
-
77
- try {
78
- writeFileSync(filepath, content, 'utf8')
79
- console.log(` ✅ Created: ${filename}`)
80
- return true
81
- } catch (error) {
82
- console.error(` ❌ Failed to create ${filename}:`, error.message)
83
- return false
84
- }
85
- }
@@ -1,156 +0,0 @@
1
- /**
2
- * TypeScript handler for setup-tool-config CLI
3
- */
4
-
5
- import { existsSync, writeFileSync } from 'fs'
6
- import { join } from 'path'
7
-
8
- import {
9
- detectTypeChecker,
10
- getTypeCheckCommand
11
- } from '../../../src/tools/typescript/checker-detection.js'
12
-
13
- /**
14
- * Get config filename
15
- */
16
- export function getConfigFilename() {
17
- return 'tsconfig.json'
18
- }
19
-
20
- /**
21
- * Generate config file content for standard (non-Electron) projects
22
- */
23
- export function generateConfigContent() {
24
- return JSON.stringify(
25
- {
26
- $schema: 'https://json.schemastore.org/tsconfig',
27
- compilerOptions: {
28
- target: 'ES2022',
29
- lib: ['ES2022'],
30
- module: 'ESNext',
31
- moduleResolution: 'Bundler',
32
- strict: true,
33
- esModuleInterop: true,
34
- skipLibCheck: true,
35
- forceConsistentCasingInFileNames: true,
36
- resolveJsonModule: true
37
- },
38
- include: ['src/**/*'],
39
- exclude: ['node_modules', 'dist', 'build', 'out', 'coverage']
40
- },
41
- null,
42
- 2
43
- )
44
- }
45
-
46
- /**
47
- * Get npm scripts based on detected framework and type checker
48
- */
49
- export function getScripts(detected) {
50
- // Electron uses tsc --build for project references
51
- if (detected.electron) {
52
- return {
53
- typecheck: 'tsc --build',
54
- 'typecheck:watch': 'tsc --build --watch'
55
- }
56
- }
57
-
58
- // Standard single-config
59
- const checker = detectTypeChecker(detected.framework, 'auto')
60
- const cmd = getTypeCheckCommand(checker)
61
- const watchCmd = getTypeCheckCommand(checker, { watch: true })
62
-
63
- return {
64
- typecheck: cmd,
65
- 'typecheck:watch': watchCmd
66
- }
67
- }
68
-
69
- /**
70
- * Write Electron multi-config TypeScript files
71
- */
72
- async function writeElectronConfigs(detected, cwd, dryRun = false) {
73
- const files = [
74
- { name: 'tsconfig.json', key: 'root', desc: 'root orchestrator' },
75
- { name: 'tsconfig.node.json', key: 'node', desc: 'main process' },
76
- { name: 'tsconfig.web.json', key: 'web', desc: 'renderer process' },
77
- { name: 'tsconfig.tests.json', key: 'tests', desc: 'test environment' }
78
- ]
79
-
80
- if (dryRun) {
81
- for (const file of files) {
82
- console.log(` 📄 Would create: ${file.name} (${file.desc})`)
83
- }
84
- return true
85
- }
86
-
87
- try {
88
- // Import the factory and generate configs
89
- const { createTypescriptConfig } = await import('../../../src/tools/typescript/index.js')
90
- const configs = await createTypescriptConfig({
91
- electron: true,
92
- renderer: detected.framework,
93
- cwd
94
- })
95
-
96
- // Write all 4 files
97
- let created = 0
98
- for (const file of files) {
99
- const filepath = join(cwd, file.name)
100
-
101
- if (existsSync(filepath)) {
102
- console.log(` ⚠️ ${file.name} already exists - skipping`)
103
- continue
104
- }
105
-
106
- const content = JSON.stringify(configs[file.key], null, 2)
107
- writeFileSync(filepath, `${content}\n`, 'utf8')
108
- console.log(` ✅ Created: ${file.name} (${file.desc})`)
109
- created++
110
- }
111
-
112
- return created > 0
113
- } catch (error) {
114
- console.error(' ❌ Failed to create Electron configs:', error.message)
115
- return false
116
- }
117
- }
118
-
119
- /**
120
- * Write config file
121
- */
122
- export function writeConfig(cwd, detected, dryRun = false) {
123
- // TypeScript tool requires TypeScript to be detected
124
- if (!detected.typescript) {
125
- console.log(' ⚠️ TypeScript not detected - skipping tsconfig generation')
126
- return false
127
- }
128
-
129
- // Special handling for TypeScript with Electron
130
- if (detected.electron) {
131
- return writeElectronConfigs(detected, cwd, dryRun)
132
- }
133
-
134
- const filename = getConfigFilename()
135
- const filepath = join(cwd, filename)
136
- const content = generateConfigContent()
137
-
138
- if (existsSync(filepath)) {
139
- console.log(` ⚠️ ${filename} already exists - skipping`)
140
- return false
141
- }
142
-
143
- if (dryRun) {
144
- console.log(` 📄 Would create: ${filename}`)
145
- return true
146
- }
147
-
148
- try {
149
- writeFileSync(filepath, content, 'utf8')
150
- console.log(` ✅ Created: ${filename}`)
151
- return true
152
- } catch (error) {
153
- console.error(` ❌ Failed to create ${filename}:`, error.message)
154
- return false
155
- }
156
- }
@@ -1,201 +0,0 @@
1
- /**
2
- * Package.json script management for setup-tool-config CLI
3
- */
4
-
5
- import { existsSync, readFileSync, writeFileSync } from 'fs'
6
- import { join } from 'path'
7
-
8
- // Map tool names to their check script names
9
- const CHECK_SCRIPT_MAP = {
10
- prettier: 'prettier',
11
- stylelint: 'style',
12
- eslint: 'lint',
13
- typescript: 'typecheck'
14
- }
15
-
16
- // Order tools from fastest/least critical to slowest/most critical
17
- const CHECK_ORDER = ['prettier', 'stylelint', 'eslint', 'typescript']
18
-
19
- /**
20
- * Generate check-all script command
21
- * @param {string[]} installedTools - Tools that were successfully installed
22
- * @returns {string|null} Command string or null if less than 2 tools
23
- */
24
- function generateCheckAllScript(installedTools) {
25
- const commands = CHECK_ORDER.filter(tool => installedTools.includes(tool))
26
- .map(tool => `yarn ${CHECK_SCRIPT_MAP[tool]}`)
27
- .join(' && ')
28
-
29
- return commands || null
30
- }
31
-
32
- /**
33
- * Update package.json with scripts for tools
34
- * @param {string[]} tools - Array of tool names that successfully created configs
35
- * @param {Function} getScriptsFn - Function that returns scripts for a tool: (tool, detected) => object
36
- * @param {Object} context - Context object with {detected, cwd, dryRun}
37
- */
38
- export function updatePackageJsonScripts(tools, getScriptsFn, context) {
39
- const { detected, cwd, dryRun = false } = context
40
- const packageJsonPath = join(cwd, 'package.json')
41
-
42
- if (!existsSync(packageJsonPath)) {
43
- console.log(' ⚠️ No package.json found - skipping script injection')
44
- return
45
- }
46
-
47
- try {
48
- const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf8'))
49
-
50
- if (!packageJson.scripts) {
51
- packageJson.scripts = {}
52
- }
53
-
54
- const scriptsToAdd = {}
55
- for (const tool of tools) {
56
- const toolScripts = getScriptsFn(tool, detected)
57
- for (const [name, command] of Object.entries(toolScripts)) {
58
- if (!packageJson.scripts[name]) {
59
- scriptsToAdd[name] = command
60
- }
61
- }
62
- }
63
-
64
- // Add or update check-all script if multiple tools installed
65
- // Determine which tools are installed (both existing and new)
66
- const installedTools = []
67
- if (packageJson.scripts.lint || scriptsToAdd.lint) installedTools.push('eslint')
68
- if (packageJson.scripts.prettier || scriptsToAdd.prettier) installedTools.push('prettier')
69
- if (packageJson.scripts.style || scriptsToAdd.style) installedTools.push('stylelint')
70
- if (packageJson.scripts.typecheck || scriptsToAdd.typecheck) installedTools.push('typescript')
71
-
72
- if (installedTools.length >= 2) {
73
- const checkAllCmd = generateCheckAllScript(installedTools)
74
- if (checkAllCmd) {
75
- const existingCheckAll = packageJson.scripts['check-all']
76
-
77
- // Only add if doesn't exist, or update if it's our auto-generated pattern
78
- // Auto-generated scripts follow pattern: "yarn X && yarn Y && ..."
79
- const isAutoGenerated =
80
- existingCheckAll &&
81
- existingCheckAll.startsWith('yarn ') &&
82
- existingCheckAll.includes(' && yarn ')
83
-
84
- if (!existingCheckAll || isAutoGenerated) {
85
- scriptsToAdd['check-all'] = checkAllCmd
86
- }
87
- }
88
- }
89
-
90
- if (Object.keys(scriptsToAdd).length === 0) {
91
- console.log(' ℹ️ All scripts already exist in package.json')
92
- return
93
- }
94
-
95
- if (dryRun) {
96
- console.log(' 📝 Would add scripts to package.json:')
97
- for (const [name, command] of Object.entries(scriptsToAdd)) {
98
- console.log(` "${name}": "${command}"`)
99
- }
100
- return
101
- }
102
-
103
- Object.assign(packageJson.scripts, scriptsToAdd)
104
-
105
- writeFileSync(packageJsonPath, `${JSON.stringify(packageJson, null, 2)}\n`, 'utf8')
106
-
107
- console.log(' ✅ Updated package.json with scripts:')
108
- for (const name of Object.keys(scriptsToAdd)) {
109
- console.log(` - ${name}`)
110
- }
111
- } catch (error) {
112
- console.error(' ❌ Failed to update package.json:', error.message)
113
- }
114
- }
115
-
116
- /**
117
- * Remove scripts from package.json for tools
118
- * @param {string[]} tools - Array of tool names to remove scripts for
119
- * @param {Function} getScriptsFn - Function that returns scripts for a tool: (tool, detected) => object
120
- * @param {Object} context - Context object with {detected, cwd, dryRun}
121
- */
122
- export function removePackageJsonScripts(tools, getScriptsFn, context) {
123
- const { detected, cwd, dryRun = false } = context
124
- const packageJsonPath = join(cwd, 'package.json')
125
-
126
- if (!existsSync(packageJsonPath)) {
127
- console.log(' ℹ️ No package.json found - skipping script removal')
128
- return
129
- }
130
-
131
- try {
132
- const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf8'))
133
-
134
- if (!packageJson.scripts) {
135
- console.log(' ℹ️ No scripts section in package.json')
136
- return
137
- }
138
-
139
- const scriptsToRemove = []
140
-
141
- // Collect script names to remove based on tools
142
- for (const tool of tools) {
143
- const toolScripts = getScriptsFn(tool, detected)
144
- for (const scriptName of Object.keys(toolScripts)) {
145
- const expectedCommand = toolScripts[scriptName]
146
- const actualCommand = packageJson.scripts[scriptName]
147
-
148
- // Only remove if the script exists and matches our expected command
149
- if (actualCommand === expectedCommand) {
150
- scriptsToRemove.push(scriptName)
151
- } else if (actualCommand) {
152
- console.log(` ⚠️ Script "${scriptName}" has been modified - skipping for safety`)
153
- }
154
- }
155
- }
156
-
157
- // Handle check-all script separately
158
- const checkAllScript = packageJson.scripts['check-all']
159
- if (checkAllScript) {
160
- // Only remove if it's auto-generated (follows yarn X && yarn Y pattern)
161
- const isAutoGenerated =
162
- checkAllScript.startsWith('yarn ') && checkAllScript.includes(' && yarn ')
163
-
164
- if (isAutoGenerated) {
165
- scriptsToRemove.push('check-all')
166
- }
167
- }
168
-
169
- if (scriptsToRemove.length === 0) {
170
- console.log(' ℹ️ No scripts to remove from package.json')
171
- return
172
- }
173
-
174
- if (dryRun) {
175
- console.log(' 📝 Would remove scripts from package.json:')
176
- for (const name of scriptsToRemove) {
177
- console.log(` - ${name}`)
178
- }
179
- return
180
- }
181
-
182
- // Remove scripts
183
- for (const scriptName of scriptsToRemove) {
184
- delete packageJson.scripts[scriptName]
185
- }
186
-
187
- // Remove scripts section if empty
188
- if (Object.keys(packageJson.scripts).length === 0) {
189
- delete packageJson.scripts
190
- }
191
-
192
- writeFileSync(packageJsonPath, `${JSON.stringify(packageJson, null, 2)}\n`, 'utf8')
193
-
194
- console.log(' ✅ Removed scripts from package.json:')
195
- for (const name of scriptsToRemove) {
196
- console.log(` - ${name}`)
197
- }
198
- } catch (error) {
199
- console.error(' ❌ Failed to update package.json:', error.message)
200
- }
201
- }