@gesslar/uglier 0.3.0 → 0.4.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 CHANGED
@@ -42,6 +42,8 @@ npx @gesslar/uglier
42
42
 
43
43
  This automatically installs `@gesslar/uglier`, `eslint`, and all dependencies.
44
44
 
45
+ **Package Manager Support:** Automatically detects and uses your preferred package manager (npm, pnpm, yarn, or Bun). Use `pnpx`, `yarn dlx`, or `bunx` instead of `npx` - the installer will detect your choice and install packages accordingly.
46
+
45
47
  ## Usage
46
48
 
47
49
  ### Generated Config
@@ -165,6 +167,11 @@ npx @gesslar/uglier init node web # Multiple targets
165
167
 
166
168
  # Show available configs
167
169
  npx @gesslar/uglier --help
170
+
171
+ # Works with any package manager
172
+ pnpx @gesslar/uglier init node # pnpm
173
+ yarn dlx @gesslar/uglier init node # yarn
174
+ bunx @gesslar/uglier init node # bun
168
175
  ```
169
176
 
170
177
  ## Manual Installation
@@ -172,7 +179,17 @@ npx @gesslar/uglier --help
172
179
  If you prefer manual control:
173
180
 
174
181
  ```bash
175
- npm install -D @gesslar/uglier eslint
182
+ # npm
183
+ npm i -D @gesslar/uglier eslint
184
+
185
+ # pnpm
186
+ pnpm i -D @gesslar/uglier eslint
187
+
188
+ # yarn
189
+ yarn add -D @gesslar/uglier eslint
190
+
191
+ # bun
192
+ bun add -d @gesslar/uglier eslint
176
193
  ```
177
194
 
178
195
  Note: `@stylistic/eslint-plugin`, `eslint-plugin-jsdoc`, and `globals` are bundled as dependencies.
package/bin/install.js CHANGED
@@ -26,6 +26,7 @@ import {dirname} from "path"
26
26
  import {fileURLToPath} from "url"
27
27
  import {FileObject, DirectoryObject} from "@gesslar/toolkit"
28
28
  import c from "@gesslar/colours"
29
+ import {detectAgent} from "@skarab/detect-package-manager"
29
30
 
30
31
  const __filename = fileURLToPath(import.meta.url)
31
32
  const __dirname = dirname(__filename)
@@ -38,6 +39,28 @@ const PEER_DEPS = [
38
39
  "eslint"
39
40
  ]
40
41
 
42
+ /**
43
+ * Get install command for detected package manager
44
+ *
45
+ * @returns {Promise<{manager: string, installCmd: string}>} Package manager info
46
+ */
47
+ async function getPackageManagerInfo() {
48
+ const agent = await detectAgent()
49
+ const manager = agent?.name || "npm"
50
+
51
+ const commands = {
52
+ npm: "npm i -D",
53
+ pnpm: "pnpm i -D",
54
+ yarn: "yarn add -D",
55
+ bun: "bun add -d"
56
+ }
57
+
58
+ return {
59
+ manager,
60
+ installCmd: commands[manager] || commands.npm
61
+ }
62
+ }
63
+
41
64
  /**
42
65
  * Execute a command and return output
43
66
  *
@@ -145,7 +168,7 @@ async function isInstalled(packageName) {
145
168
  const packageJsonFile = new FileObject("package.json", process.cwd())
146
169
 
147
170
  if(!(await packageJsonFile.exists)) {
148
- console.warn(c`No {<B}package.json{B>} found. Please run {<B}'npm init'{B>} first.`)
171
+ console.warn(c`No {<B}package.json{B>} found. Please initialize your project first.`)
149
172
  process.exit(1)
150
173
  }
151
174
 
@@ -191,10 +214,12 @@ async function install() {
191
214
  if(toInstall.length > 0) {
192
215
  console.log(c`\n{F027} Installing:{/} ${toInstall.map(p => c`{F172}${p}{/}`).join(", ")}`)
193
216
 
194
- const installCmd = `npm install -D ${toInstall.join(" ")}`
217
+ const {manager, installCmd} = await getPackageManagerInfo()
218
+ const fullCmd = `${installCmd} ${toInstall.join(" ")}`
195
219
 
196
- console.log(c`{F244}Running: ${installCmd}{/}`)
197
- exec(installCmd)
220
+ console.log(c`{F244}Using package manager: ${manager}{/}`)
221
+ console.log(c`{F244}Running: ${fullCmd}{/}`)
222
+ exec(fullCmd)
198
223
 
199
224
  console.log()
200
225
  console.log(c`{F070}✓{/} Installation successful.`)
package/package.json CHANGED
@@ -6,7 +6,7 @@
6
6
  "email": "bmw@gesslar.dev",
7
7
  "url": "https://gesslar.dev"
8
8
  },
9
- "version": "0.3.0",
9
+ "version": "0.4.0",
10
10
  "repository": {
11
11
  "type": "git",
12
12
  "url": "git+https://github.com/gesslar/uglier.git"
@@ -44,6 +44,7 @@
44
44
  "dependencies": {
45
45
  "@gesslar/colours": "^0.0.1",
46
46
  "@gesslar/toolkit": "^3.4.0",
47
+ "@skarab/detect-package-manager": "^1.0.0",
47
48
  "@stylistic/eslint-plugin": "^5.6.1",
48
49
  "eslint-plugin-jsdoc": "^61.5.0",
49
50
  "globals": "^16.5.0"