@vheissulabs/prettier-config 1.1.0 → 1.3.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.
- package/README.md +7 -1
- package/bin/init.js +33 -0
- package/index.js +1 -1
- package/package.json +4 -1
package/README.md
CHANGED
|
@@ -10,7 +10,13 @@ npm install --save-dev @vheissulabs/prettier-config
|
|
|
10
10
|
|
|
11
11
|
## Usage
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
Run the init script to automatically add the config to your package.json:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npx vheissu-prettier-init
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Or manually add to your `package.json`:
|
|
14
20
|
|
|
15
21
|
```json
|
|
16
22
|
{
|
package/bin/init.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const fs = require('fs')
|
|
4
|
+
const path = require('path')
|
|
5
|
+
|
|
6
|
+
const packageJsonPath = path.join(process.cwd(), 'package.json')
|
|
7
|
+
|
|
8
|
+
if (!fs.existsSync(packageJsonPath)) {
|
|
9
|
+
console.error('❌ No package.json found in current directory')
|
|
10
|
+
process.exit(1)
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'))
|
|
14
|
+
|
|
15
|
+
if (packageJson.prettier) {
|
|
16
|
+
console.log('⚠️ Prettier config already exists in package.json')
|
|
17
|
+
console.log(' Current value:', JSON.stringify(packageJson.prettier))
|
|
18
|
+
process.exit(0)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
packageJson.prettier = '@vheissulabs/prettier-config'
|
|
22
|
+
|
|
23
|
+
// Preserve formatting by detecting indent
|
|
24
|
+
const originalContent = fs.readFileSync(packageJsonPath, 'utf8')
|
|
25
|
+
const indent = originalContent.match(/^(\s+)/m)?.[1] || ' '
|
|
26
|
+
|
|
27
|
+
fs.writeFileSync(
|
|
28
|
+
packageJsonPath,
|
|
29
|
+
JSON.stringify(packageJson, null, indent.length) + '\n'
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
console.log('✅ Added prettier config to package.json')
|
|
33
|
+
console.log(' "prettier": "@vheissulabs/prettier-config"')
|
package/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vheissulabs/prettier-config",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "Shared Prettier configuration for VheissuLabs projects",
|
|
5
5
|
"main": "index.js",
|
|
6
|
+
"bin": {
|
|
7
|
+
"vheissu-prettier-init": "./bin/init.js"
|
|
8
|
+
},
|
|
6
9
|
"keywords": [
|
|
7
10
|
"prettier",
|
|
8
11
|
"config",
|