@gesslar/uglier 0.0.1 → 0.0.3
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 +29 -1
- package/bin/install.js +215 -0
- package/package.json +11 -2
- package/src/uglier.js +1 -1
package/README.md
CHANGED
|
@@ -30,8 +30,36 @@ kthx
|
|
|
30
30
|
|
|
31
31
|
## Install
|
|
32
32
|
|
|
33
|
+
### Quick Install (Recommended)
|
|
34
|
+
|
|
35
|
+
The easiest way to install `@gesslar/uglier` and all its dependencies:
|
|
36
|
+
|
|
37
|
+
```sh
|
|
38
|
+
npx @gesslar/uglier
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
This will automatically install:
|
|
42
|
+
|
|
43
|
+
- `@gesslar/uglier`
|
|
44
|
+
- `eslint` (if not already installed)
|
|
45
|
+
- `@stylistic/eslint-plugin`
|
|
46
|
+
- `eslint-plugin-jsdoc`
|
|
47
|
+
- `globals`
|
|
48
|
+
|
|
49
|
+
### Manual Install
|
|
50
|
+
|
|
51
|
+
If you prefer to install manually:
|
|
52
|
+
|
|
53
|
+
```sh
|
|
54
|
+
npm install --save-dev @gesslar/uglier eslint @stylistic/eslint-plugin eslint-plugin-jsdoc globals
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### View Available Configs
|
|
58
|
+
|
|
59
|
+
To see all available config blocks:
|
|
60
|
+
|
|
33
61
|
```sh
|
|
34
|
-
|
|
62
|
+
npx @gesslar/uglier --help
|
|
35
63
|
```
|
|
36
64
|
|
|
37
65
|
## Usage
|
package/bin/install.js
ADDED
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file install.js - Auto-installer for @gesslar/uglier
|
|
5
|
+
*
|
|
6
|
+
* @description
|
|
7
|
+
* This script can be run via `npx @gesslar/uglier` to automatically install
|
|
8
|
+
* the package and all its dependencies to the current project.
|
|
9
|
+
*
|
|
10
|
+
* It will:
|
|
11
|
+
* 1. Install @gesslar/uglier as a dev dependency
|
|
12
|
+
* 2. Install eslint as a peer dependency (if not present)
|
|
13
|
+
* 3. Install all required plugins as dev dependencies
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import {execSync} from "child_process"
|
|
17
|
+
import {dirname} from "path"
|
|
18
|
+
import {fileURLToPath} from "url"
|
|
19
|
+
import {FileObject, DirectoryObject} from "@gesslar/toolkit"
|
|
20
|
+
import c from "@gesslar/colours"
|
|
21
|
+
|
|
22
|
+
const __filename = fileURLToPath(import.meta.url)
|
|
23
|
+
const __dirname = dirname(__filename)
|
|
24
|
+
|
|
25
|
+
const PACKAGE_NAME = "@gesslar/uglier"
|
|
26
|
+
|
|
27
|
+
// Dependencies that need to be installed
|
|
28
|
+
const REQUIRED_DEPS = [
|
|
29
|
+
"@stylistic/eslint-plugin",
|
|
30
|
+
"eslint-plugin-jsdoc",
|
|
31
|
+
"globals"
|
|
32
|
+
]
|
|
33
|
+
|
|
34
|
+
const PEER_DEPS = [
|
|
35
|
+
"eslint"
|
|
36
|
+
]
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Execute a command and return output
|
|
40
|
+
* @param {string} cmd - Command to execute
|
|
41
|
+
* @returns {string} Command output
|
|
42
|
+
*/
|
|
43
|
+
function exec(cmd) {
|
|
44
|
+
try {
|
|
45
|
+
return execSync(cmd, {encoding: "utf8", stdio: "pipe"})
|
|
46
|
+
} catch(error) {
|
|
47
|
+
console.error(`Error executing: ${cmd}`)
|
|
48
|
+
console.error(error.message)
|
|
49
|
+
process.exit(1)
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Get available configs from the source file
|
|
55
|
+
* @returns {Promise<Array<{name: string, description: string}>|null>} Available configs
|
|
56
|
+
*/
|
|
57
|
+
async function getAvailableConfigs() {
|
|
58
|
+
try {
|
|
59
|
+
// Try to read from installed package or local source
|
|
60
|
+
const localDir = new DirectoryObject(`${__dirname}/../src`)
|
|
61
|
+
const installedDir = new DirectoryObject(`${process.cwd()}/node_modules/${PACKAGE_NAME}/src`)
|
|
62
|
+
|
|
63
|
+
const localSource = new FileObject("uglier.js", localDir)
|
|
64
|
+
const installedSource = new FileObject("uglier.js", installedDir)
|
|
65
|
+
|
|
66
|
+
let uglierFile = null
|
|
67
|
+
|
|
68
|
+
if(await localSource.exists) {
|
|
69
|
+
uglierFile = localSource
|
|
70
|
+
} else if(await installedSource.exists) {
|
|
71
|
+
uglierFile = installedSource
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if(!uglierFile) {
|
|
75
|
+
return null
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const source = await uglierFile.read()
|
|
79
|
+
|
|
80
|
+
// Extract config names and their JSDoc descriptions
|
|
81
|
+
const configs = []
|
|
82
|
+
// Match individual config blocks within CONFIGS object
|
|
83
|
+
const configBlockRegex = /\/\*\*\s*\n\s*\*\s*([^\n@*]+?)\s*\n(?:\s*\*[^\n]*\n)*?\s*\*\/\s*\n\s*["']([^"']+)["']:\s*\([^)]*\)\s*=>/g
|
|
84
|
+
let match
|
|
85
|
+
|
|
86
|
+
while((match = configBlockRegex.exec(source)) !== null) {
|
|
87
|
+
configs.push({
|
|
88
|
+
name: match[2],
|
|
89
|
+
description: match[1].trim()
|
|
90
|
+
})
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
return configs
|
|
94
|
+
} catch(error) {
|
|
95
|
+
return null
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Show help information
|
|
101
|
+
*/
|
|
102
|
+
async function showHelp() {
|
|
103
|
+
console.log(c`{F027}@gesslar/uglier{/} - Composable ESLint flat config`)
|
|
104
|
+
|
|
105
|
+
console.log()
|
|
106
|
+
console.log("Usage:")
|
|
107
|
+
console.log()
|
|
108
|
+
console.log(c` {<B}npx @gesslar/uglier{B>} Install package and dependencies`)
|
|
109
|
+
console.log(c` {<B}npx @gesslar/uglier --help{B>} Show this help`)
|
|
110
|
+
console.log()
|
|
111
|
+
|
|
112
|
+
const configs = await getAvailableConfigs()
|
|
113
|
+
|
|
114
|
+
if(configs && configs.length > 0) {
|
|
115
|
+
console.log(c`Available config blocks:`)
|
|
116
|
+
console.log()
|
|
117
|
+
|
|
118
|
+
for(const {name, description} of configs) {
|
|
119
|
+
console.log(c` {<B}${name.padEnd(20)}{B>} ${description}`)
|
|
120
|
+
}
|
|
121
|
+
} else {
|
|
122
|
+
console.log("Install the package to see available config blocks.\n")
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
console.log()
|
|
126
|
+
console.log(`Documentation at https://github.com/gesslar/uglier.`)
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Check if a package is already installed
|
|
131
|
+
* @param {string} packageName - Name of package to check
|
|
132
|
+
* @returns {Promise<boolean>} True if installed
|
|
133
|
+
*/
|
|
134
|
+
async function isInstalled(packageName) {
|
|
135
|
+
try {
|
|
136
|
+
const packageJsonFile = new FileObject("package.json", process.cwd())
|
|
137
|
+
|
|
138
|
+
if(!(await packageJsonFile.exists)) {
|
|
139
|
+
console.warn(c`No {<B}package.json{B>} found. Please run {<B}'npm init'{B>} first.`)
|
|
140
|
+
process.exit(1)
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
const packageJson = await packageJsonFile.loadData("json")
|
|
144
|
+
const allDeps = {
|
|
145
|
+
...packageJson.dependencies,
|
|
146
|
+
...packageJson.devDependencies,
|
|
147
|
+
...packageJson.peerDependencies
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
return packageName in allDeps
|
|
151
|
+
} catch(error) {
|
|
152
|
+
return false
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Main installation routine
|
|
158
|
+
*/
|
|
159
|
+
async function install() {
|
|
160
|
+
console.log(c`Installing {<B}${PACKAGE_NAME}{B>}...`)
|
|
161
|
+
console.log()
|
|
162
|
+
|
|
163
|
+
const toInstall = []
|
|
164
|
+
|
|
165
|
+
// Check if main package is already installed
|
|
166
|
+
if(!(await isInstalled(PACKAGE_NAME))) {
|
|
167
|
+
toInstall.push(PACKAGE_NAME)
|
|
168
|
+
} else {
|
|
169
|
+
console.log(c`{F070}✓{/} {<B}${PACKAGE_NAME}{B>} already installed`)
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// Check peer dependencies
|
|
173
|
+
for(const dep of PEER_DEPS) {
|
|
174
|
+
if(!(await isInstalled(dep))) {
|
|
175
|
+
toInstall.push(dep)
|
|
176
|
+
} else {
|
|
177
|
+
console.log(c`{F070}✓{/} {<B}${dep}{B>} already installed`)
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
// Check required dependencies
|
|
182
|
+
for(const dep of REQUIRED_DEPS) {
|
|
183
|
+
if(!(await isInstalled(dep))) {
|
|
184
|
+
toInstall.push(dep)
|
|
185
|
+
} else {
|
|
186
|
+
console.log(c`{F070}✓{/} {<B}${dep}{B>} already installed`)
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
// Install missing packages
|
|
191
|
+
if(toInstall.length > 0) {
|
|
192
|
+
console.log(c`\n{F027} Installing:{/} ${toInstall.map(p => c`{F172}${p}{/}`).join(", ")}\n`)
|
|
193
|
+
|
|
194
|
+
const installCmd = `npm install -D ${toInstall.join(" ")}`
|
|
195
|
+
|
|
196
|
+
console.log(c`{F244}Running: ${installCmd}{/}`)
|
|
197
|
+
exec(installCmd)
|
|
198
|
+
|
|
199
|
+
console.log()
|
|
200
|
+
console.log(c`{F070}✓{/} Installation successful.`)
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
console.log()
|
|
204
|
+
console.log(c`{F039}For detailed setup and configuration options, visit:{/}`)
|
|
205
|
+
console.log(c`https://github.com/gesslar/uglier#readme`)
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
// Parse command line arguments and run
|
|
209
|
+
const args = process.argv.slice(2)
|
|
210
|
+
|
|
211
|
+
if(args.includes("--help") || args.includes("-h")) {
|
|
212
|
+
await showHelp()
|
|
213
|
+
} else {
|
|
214
|
+
await install()
|
|
215
|
+
}
|
package/package.json
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gesslar/uglier",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"description": "Composable ESLint flat config blocks for stylistic, JSDoc, and environment presets.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/uglier.js",
|
|
7
7
|
"exports": "./src/uglier.js",
|
|
8
|
+
"bin": {
|
|
9
|
+
"uglier": "./bin/install.js"
|
|
10
|
+
},
|
|
8
11
|
"files": [
|
|
9
|
-
"src"
|
|
12
|
+
"src",
|
|
13
|
+
"bin"
|
|
10
14
|
],
|
|
11
15
|
"keywords": [
|
|
12
16
|
"eslint",
|
|
@@ -33,5 +37,10 @@
|
|
|
33
37
|
"@stylistic/eslint-plugin": "^5.6.1",
|
|
34
38
|
"eslint-plugin-jsdoc": "^61.4.0",
|
|
35
39
|
"globals": "^16.5.0"
|
|
40
|
+
},
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"@gesslar/colours": "^0.0.1",
|
|
43
|
+
"@gesslar/toolkit": "^0.8.0",
|
|
44
|
+
"@gesslar/uglier": "^0.0.1"
|
|
36
45
|
}
|
|
37
46
|
}
|
package/src/uglier.js
CHANGED
|
@@ -171,7 +171,7 @@ const CONFIGS = {
|
|
|
171
171
|
}],
|
|
172
172
|
"@stylistic/quotes": ["error", "double", {
|
|
173
173
|
avoidEscape: true,
|
|
174
|
-
allowTemplateLiterals:
|
|
174
|
+
allowTemplateLiterals: true,
|
|
175
175
|
}],
|
|
176
176
|
"@stylistic/semi": ["error", "never"],
|
|
177
177
|
"@stylistic/space-before-function-paren": ["error", "never"],
|