@lpm-registry/cli 0.2.5 → 0.2.6
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/CHANGELOG.md +20 -0
- package/README.md +28 -9
- package/bin/lpm.js +9 -0
- package/lib/commands/doctor.js +7 -9
- package/lib/commands/install.js +66 -22
- package/lib/commands/skills.js +12 -1
- package/lib/commands/uninstall.js +107 -0
- package/lib/config.js +37 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,26 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
|
|
5
|
+
## [0.2.6] - 2026-03-21
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
|
|
9
|
+
- **`lpm uninstall` command** — Mirrors `npm uninstall` with automatic registry auth. Aliases: `lpm un`, `lpm unlink`.
|
|
10
|
+
- **`--pm` flag for install/uninstall** — Choose package manager: `lpm install --pm pnpm`. Supports npm (default), pnpm, yarn, bun.
|
|
11
|
+
- **`lpm config set packageManager`** — Set default package manager globally. Also available via `LPM_PACKAGE_MANAGER` env var.
|
|
12
|
+
|
|
13
|
+
### Changed
|
|
14
|
+
|
|
15
|
+
- `lpm install` now shows package list before install: "Found 15 LPM packages in package.json"
|
|
16
|
+
- Skills install now scoped to explicit packages when specified (`lpm install @lpm.dev/pkg` only fetches skills for that package)
|
|
17
|
+
- Skills install skips `file:`, `link:`, `workspace:` dependencies (local packages)
|
|
18
|
+
- `lpm doctor` registry check fixed — uses `/-/whoami` endpoint instead of non-existent `/health`
|
|
19
|
+
- Publish script updated with version bumping, git commit/tag/push, and `--dry-run` support
|
|
20
|
+
|
|
21
|
+
### Fixed
|
|
22
|
+
|
|
23
|
+
- pnpm/yarn/bun compatibility — no longer passes npm-specific `--userconfig` flag. Uses project `.npmrc` with backup/restore for non-npm package managers.
|
|
24
|
+
|
|
5
25
|
## [0.2.5] - 2026-03-19
|
|
6
26
|
|
|
7
27
|
### Added
|
package/README.md
CHANGED
|
@@ -65,23 +65,28 @@ lpm whoami
|
|
|
65
65
|
|
|
66
66
|
### Project Setup
|
|
67
67
|
|
|
68
|
-
####
|
|
68
|
+
#### Generate .npmrc Token (Local Dev)
|
|
69
69
|
|
|
70
|
-
|
|
70
|
+
Generate a 30-day read-only token for your project. Makes `npm install` work with LPM packages.
|
|
71
71
|
|
|
72
72
|
```bash
|
|
73
|
-
lpm
|
|
73
|
+
lpm npmrc # 30-day token (default)
|
|
74
|
+
lpm npmrc --days 7 # 7-day token
|
|
75
|
+
lpm npmrc --days 90 # 90-day token
|
|
74
76
|
```
|
|
75
77
|
|
|
76
|
-
|
|
78
|
+
Automatically adds `.npmrc` to `.gitignore` to prevent token leaks.
|
|
77
79
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
80
|
+
#### Setup .npmrc (CI/CD)
|
|
81
|
+
|
|
82
|
+
Configure `.npmrc` for CI/CD environments.
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
lpm setup # Writes ${LPM_TOKEN} placeholder
|
|
86
|
+
lpm setup --oidc # OIDC — no secrets needed (GitHub Actions, GitLab CI)
|
|
82
87
|
```
|
|
83
88
|
|
|
84
|
-
For deployment, set the `LPM_TOKEN` environment variable
|
|
89
|
+
For deployment platforms (Vercel, Netlify), set the `LPM_TOKEN` environment variable.
|
|
85
90
|
|
|
86
91
|
### Package Management
|
|
87
92
|
|
|
@@ -120,6 +125,7 @@ lpm install @lpm.dev/owner.package-name
|
|
|
120
125
|
lpm install @lpm.dev/tolgaergin.utils @lpm.dev/acme.helpers
|
|
121
126
|
lpm install # Install all @lpm.dev packages from package.json
|
|
122
127
|
lpm install --no-skills # Skip fetching Agent Skills
|
|
128
|
+
lpm install --pm pnpm # Use pnpm instead of npm
|
|
123
129
|
lpm i # Shortcut
|
|
124
130
|
```
|
|
125
131
|
|
|
@@ -128,6 +134,19 @@ Agent Skills are fetched by default for packages that include them.
|
|
|
128
134
|
| Option | Description |
|
|
129
135
|
| ------------- | ---------------------------------------- |
|
|
130
136
|
| `--no-skills` | Skip fetching Agent Skills after install |
|
|
137
|
+
| `--pm <name>` | Package manager: npm (default), pnpm, yarn, bun |
|
|
138
|
+
|
|
139
|
+
Set a default package manager: `lpm config set packageManager pnpm`
|
|
140
|
+
|
|
141
|
+
#### Uninstall
|
|
142
|
+
|
|
143
|
+
Uninstall packages with automatic registry authentication.
|
|
144
|
+
|
|
145
|
+
```bash
|
|
146
|
+
lpm uninstall @lpm.dev/owner.package-name
|
|
147
|
+
lpm uninstall --pm pnpm # Use pnpm
|
|
148
|
+
lpm un # Shortcut
|
|
149
|
+
```
|
|
131
150
|
|
|
132
151
|
#### Add (Source Code)
|
|
133
152
|
|
package/bin/lpm.js
CHANGED
|
@@ -36,6 +36,7 @@ import {
|
|
|
36
36
|
skillsValidate,
|
|
37
37
|
} from "../lib/commands/skills.js"
|
|
38
38
|
import { rotateToken } from "../lib/commands/token-rotate.js"
|
|
39
|
+
import { uninstall } from "../lib/commands/uninstall.js"
|
|
39
40
|
import { whoami } from "../lib/commands/whoami.js"
|
|
40
41
|
|
|
41
42
|
// Load package.json
|
|
@@ -93,8 +94,16 @@ program
|
|
|
93
94
|
.description("Install packages with automatic registry authentication")
|
|
94
95
|
.option("--json", "Machine-readable JSON output")
|
|
95
96
|
.option("--no-skills", "Skip fetching Agent Skills after install")
|
|
97
|
+
.option("--pm <manager>", "Package manager to use (npm, pnpm, yarn, bun)")
|
|
96
98
|
.action(install)
|
|
97
99
|
|
|
100
|
+
program
|
|
101
|
+
.command("uninstall <packages...>")
|
|
102
|
+
.aliases(["un", "unlink"])
|
|
103
|
+
.description("Uninstall packages via package manager")
|
|
104
|
+
.option("--pm <manager>", "Package manager to use (npm, pnpm, yarn, bun)")
|
|
105
|
+
.action(uninstall)
|
|
106
|
+
|
|
98
107
|
program
|
|
99
108
|
.command("publish")
|
|
100
109
|
.alias("p")
|
package/lib/commands/doctor.js
CHANGED
|
@@ -24,16 +24,14 @@ export async function doctor() {
|
|
|
24
24
|
// 2. Check Registry Reachability
|
|
25
25
|
const spinnerApi = createSpinner("Checking registry connection...").start()
|
|
26
26
|
try {
|
|
27
|
-
// Assuming we have a health endpoint or similar. Using the registry URL from config or default.
|
|
28
27
|
const registryUrl = getRegistryUrl()
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
28
|
+
// Use /-/whoami without a token — a 401 "Missing token" proves the registry is reachable.
|
|
29
|
+
// Only network errors (ECONNREFUSED, timeout) indicate the registry is down.
|
|
30
|
+
await fetch(`${registryUrl}/api/registry/-/whoami`, {
|
|
31
|
+
signal: AbortSignal.timeout(10000),
|
|
32
|
+
})
|
|
33
|
+
spinnerApi.succeed(`Registry reachable at ${registryUrl}`)
|
|
34
|
+
checks.push({ name: "Registry API", status: "ok" })
|
|
37
35
|
} catch (err) {
|
|
38
36
|
spinnerApi.fail(`Could not connect to registry: ${err.message}`)
|
|
39
37
|
checks.push({ name: "Registry API", status: "fail" })
|
package/lib/commands/install.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { spawn } from "node:child_process"
|
|
2
2
|
import fs from "node:fs"
|
|
3
3
|
import path from "node:path"
|
|
4
|
-
import { getRegistryUrl, getToken } from "../config.js"
|
|
4
|
+
import { getPackageManager, getRegistryUrl, getToken } from "../config.js"
|
|
5
5
|
import { createSpinner, log, printHeader } from "../ui.js"
|
|
6
6
|
import { skillsInstall } from "./skills.js"
|
|
7
7
|
|
|
@@ -44,6 +44,9 @@ export async function install(packages, options) {
|
|
|
44
44
|
process.exit(1)
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
+
// Track if user specified packages explicitly (for scoped skills fetch)
|
|
48
|
+
const explicitPackages = packages && packages.length > 0
|
|
49
|
+
|
|
47
50
|
if (!packages || packages.length === 0) {
|
|
48
51
|
// No packages specified - read from package.json
|
|
49
52
|
const packageJsonPath = path.resolve(process.cwd(), "package.json")
|
|
@@ -99,17 +102,16 @@ export async function install(packages, options) {
|
|
|
99
102
|
}
|
|
100
103
|
|
|
101
104
|
if (!isJson) {
|
|
102
|
-
log.info(
|
|
103
|
-
|
|
104
|
-
|
|
105
|
+
log.info(`Found ${packages.length} LPM packages in package.json:`)
|
|
106
|
+
for (const pkg of packages) {
|
|
107
|
+
log.info(` ${pkg}`)
|
|
108
|
+
}
|
|
105
109
|
}
|
|
106
110
|
}
|
|
107
111
|
|
|
108
112
|
let spinner
|
|
109
113
|
if (!isJson) {
|
|
110
|
-
spinner = createSpinner(
|
|
111
|
-
`Preparing to install ${packages.join(", ")}...`,
|
|
112
|
-
).start()
|
|
114
|
+
spinner = createSpinner("Configuring registry authentication...").start()
|
|
113
115
|
}
|
|
114
116
|
|
|
115
117
|
const baseRegistryUrl = getRegistryUrl()
|
|
@@ -126,26 +128,54 @@ export async function install(packages, options) {
|
|
|
126
128
|
@lpm.dev:registry=${registryUrl}
|
|
127
129
|
`
|
|
128
130
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
131
|
+
const pm = getPackageManager(options?.pm)
|
|
132
|
+
|
|
133
|
+
// For npm we can use --userconfig with a temp file.
|
|
134
|
+
// For pnpm/yarn/bun we write a temporary project .npmrc (all PMs read it).
|
|
135
|
+
const projectNpmrcPath = path.resolve(process.cwd(), ".npmrc")
|
|
136
|
+
let existingNpmrc = null
|
|
137
|
+
let tempNpmrcPath = null
|
|
138
|
+
|
|
139
|
+
if (pm === "npm") {
|
|
140
|
+
// npm supports --userconfig — use a separate temp file (doesn't touch project .npmrc)
|
|
141
|
+
tempNpmrcPath = path.resolve(process.cwd(), `.npmrc.lpm-${Date.now()}`)
|
|
142
|
+
fs.writeFileSync(tempNpmrcPath, npmrcContent)
|
|
143
|
+
} else {
|
|
144
|
+
// pnpm/yarn/bun read project .npmrc — back up existing, write temp, restore after
|
|
145
|
+
if (fs.existsSync(projectNpmrcPath)) {
|
|
146
|
+
existingNpmrc = fs.readFileSync(projectNpmrcPath, "utf8")
|
|
147
|
+
}
|
|
148
|
+
fs.writeFileSync(projectNpmrcPath, npmrcContent)
|
|
149
|
+
}
|
|
132
150
|
|
|
133
151
|
if (!isJson) {
|
|
134
|
-
spinner.succeed(
|
|
152
|
+
spinner.succeed(`Configuration generated. Running ${pm} install...`)
|
|
135
153
|
}
|
|
136
154
|
|
|
137
|
-
|
|
138
|
-
|
|
155
|
+
const pmArgs =
|
|
156
|
+
pm === "npm"
|
|
157
|
+
? ["install", ...packages, "--userconfig", tempNpmrcPath]
|
|
158
|
+
: ["install", ...packages]
|
|
139
159
|
|
|
140
160
|
// In JSON mode, capture stdout/stderr instead of inheriting
|
|
141
|
-
const child = spawn(
|
|
161
|
+
const child = spawn(pm, pmArgs, {
|
|
142
162
|
stdio: isJson ? "pipe" : "inherit",
|
|
143
163
|
env: { ...process.env, LPM_TOKEN: token },
|
|
144
164
|
})
|
|
145
165
|
|
|
146
166
|
const cleanup = () => {
|
|
147
|
-
if (
|
|
148
|
-
|
|
167
|
+
if (pm === "npm") {
|
|
168
|
+
// Remove temp file
|
|
169
|
+
if (tempNpmrcPath && fs.existsSync(tempNpmrcPath)) {
|
|
170
|
+
fs.unlinkSync(tempNpmrcPath)
|
|
171
|
+
}
|
|
172
|
+
} else {
|
|
173
|
+
// Restore original .npmrc (or remove if there wasn't one)
|
|
174
|
+
if (existingNpmrc !== null) {
|
|
175
|
+
fs.writeFileSync(projectNpmrcPath, existingNpmrc)
|
|
176
|
+
} else if (fs.existsSync(projectNpmrcPath)) {
|
|
177
|
+
fs.unlinkSync(projectNpmrcPath)
|
|
178
|
+
}
|
|
149
179
|
}
|
|
150
180
|
}
|
|
151
181
|
|
|
@@ -168,11 +198,19 @@ export async function install(packages, options) {
|
|
|
168
198
|
packages: packages.map(p => ({ name: p })),
|
|
169
199
|
npmOutput: (stdout + stderr).trim(),
|
|
170
200
|
warnings: [],
|
|
171
|
-
errors: code !== 0 ? [
|
|
201
|
+
errors: code !== 0 ? [`${pm} install failed with code ${code}`] : [],
|
|
172
202
|
}
|
|
173
203
|
process.stdout.write(`${JSON.stringify(output, null, 2)}\n`)
|
|
174
204
|
if (code !== 0) process.exit(code)
|
|
175
|
-
if (fetchSkills)
|
|
205
|
+
if (fetchSkills) {
|
|
206
|
+
if (explicitPackages) {
|
|
207
|
+
for (const pkg of packages.filter(isLpmPackage)) {
|
|
208
|
+
await skillsInstall(pkg, { json: true })
|
|
209
|
+
}
|
|
210
|
+
} else {
|
|
211
|
+
await skillsInstall(null, { json: true })
|
|
212
|
+
}
|
|
213
|
+
}
|
|
176
214
|
})
|
|
177
215
|
|
|
178
216
|
child.on("error", err => {
|
|
@@ -182,7 +220,7 @@ export async function install(packages, options) {
|
|
|
182
220
|
packages: packages.map(p => ({ name: p })),
|
|
183
221
|
npmOutput: "",
|
|
184
222
|
warnings: [],
|
|
185
|
-
errors: [`Failed to start
|
|
223
|
+
errors: [`Failed to start ${pm}: ${err.message}`],
|
|
186
224
|
}
|
|
187
225
|
process.stdout.write(`${JSON.stringify(output, null, 2)}\n`)
|
|
188
226
|
process.exit(1)
|
|
@@ -191,19 +229,25 @@ export async function install(packages, options) {
|
|
|
191
229
|
child.on("close", async code => {
|
|
192
230
|
cleanup()
|
|
193
231
|
if (code !== 0) {
|
|
194
|
-
log.error(
|
|
232
|
+
log.error(`${pm} install failed with code ${code}`)
|
|
195
233
|
process.exit(code)
|
|
196
234
|
} else {
|
|
197
235
|
log.success("Packages installed successfully.")
|
|
198
236
|
if (fetchSkills) {
|
|
199
237
|
console.log("")
|
|
200
|
-
|
|
238
|
+
if (explicitPackages) {
|
|
239
|
+
for (const pkg of packages.filter(isLpmPackage)) {
|
|
240
|
+
await skillsInstall(pkg)
|
|
241
|
+
}
|
|
242
|
+
} else {
|
|
243
|
+
await skillsInstall(null)
|
|
244
|
+
}
|
|
201
245
|
}
|
|
202
246
|
}
|
|
203
247
|
})
|
|
204
248
|
|
|
205
249
|
child.on("error", err => {
|
|
206
|
-
log.error(`Failed to start
|
|
250
|
+
log.error(`Failed to start ${pm}: ${err.message}`)
|
|
207
251
|
cleanup()
|
|
208
252
|
process.exit(1)
|
|
209
253
|
})
|
package/lib/commands/skills.js
CHANGED
|
@@ -322,7 +322,18 @@ function getLpmDependencies() {
|
|
|
322
322
|
const allDeps = { ...pkg.dependencies, ...pkg.devDependencies }
|
|
323
323
|
|
|
324
324
|
return Object.entries(allDeps)
|
|
325
|
-
.filter(([name]) =>
|
|
325
|
+
.filter(([name, version]) => {
|
|
326
|
+
if (!name.startsWith("@lpm.dev/")) return false
|
|
327
|
+
// Skip local file/link references — they have their own .lpm/skills/
|
|
328
|
+
if (
|
|
329
|
+
version.startsWith("file:") ||
|
|
330
|
+
version.startsWith("link:") ||
|
|
331
|
+
version.startsWith("workspace:")
|
|
332
|
+
) {
|
|
333
|
+
return false
|
|
334
|
+
}
|
|
335
|
+
return true
|
|
336
|
+
})
|
|
326
337
|
.map(([name, version]) => ({
|
|
327
338
|
fullName: name,
|
|
328
339
|
shortName: name.replace("@lpm.dev/", ""),
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { spawn } from "node:child_process"
|
|
2
|
+
import fs from "node:fs"
|
|
3
|
+
import path from "node:path"
|
|
4
|
+
import { getPackageManager, getRegistryUrl, getToken } from "../config.js"
|
|
5
|
+
import { createSpinner, log, printHeader } from "../ui.js"
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Uninstall LPM packages.
|
|
9
|
+
* Creates a temporary .npmrc with auth, runs the package manager's uninstall, and cleans up.
|
|
10
|
+
*
|
|
11
|
+
* @param {string[]} packages - Package names to uninstall
|
|
12
|
+
* @param {object} [options]
|
|
13
|
+
* @param {string} [options.pm] - Package manager override (npm, pnpm, yarn, bun)
|
|
14
|
+
*/
|
|
15
|
+
export async function uninstall(packages, options) {
|
|
16
|
+
printHeader()
|
|
17
|
+
|
|
18
|
+
if (!packages || packages.length === 0) {
|
|
19
|
+
log.error("Please specify at least one package to uninstall.")
|
|
20
|
+
log.info("Usage: lpm uninstall @lpm.dev/owner.package-name")
|
|
21
|
+
process.exit(1)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const token = await getToken()
|
|
25
|
+
if (!token) {
|
|
26
|
+
log.error(
|
|
27
|
+
'You must be logged in to uninstall packages. Run "lpm login" first.',
|
|
28
|
+
)
|
|
29
|
+
process.exit(1)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const pm = getPackageManager(options?.pm)
|
|
33
|
+
const spinner = createSpinner(
|
|
34
|
+
`Preparing to uninstall ${packages.join(", ")}...`,
|
|
35
|
+
).start()
|
|
36
|
+
|
|
37
|
+
const baseRegistryUrl = getRegistryUrl()
|
|
38
|
+
const registryUrl = baseRegistryUrl.endsWith("/api/registry")
|
|
39
|
+
? baseRegistryUrl
|
|
40
|
+
: `${baseRegistryUrl}/api/registry`
|
|
41
|
+
const registryHost = registryUrl.replace(/^https?:/, "")
|
|
42
|
+
|
|
43
|
+
const npmrcContent = `${registryHost}/:_authToken=${token}
|
|
44
|
+
@lpm.dev:registry=${registryUrl}
|
|
45
|
+
`
|
|
46
|
+
|
|
47
|
+
const projectNpmrcPath = path.resolve(process.cwd(), ".npmrc")
|
|
48
|
+
let existingNpmrc = null
|
|
49
|
+
let tempNpmrcPath = null
|
|
50
|
+
|
|
51
|
+
if (pm === "npm") {
|
|
52
|
+
tempNpmrcPath = path.resolve(process.cwd(), `.npmrc.lpm-${Date.now()}`)
|
|
53
|
+
fs.writeFileSync(tempNpmrcPath, npmrcContent)
|
|
54
|
+
} else {
|
|
55
|
+
if (fs.existsSync(projectNpmrcPath)) {
|
|
56
|
+
existingNpmrc = fs.readFileSync(projectNpmrcPath, "utf8")
|
|
57
|
+
}
|
|
58
|
+
fs.writeFileSync(projectNpmrcPath, npmrcContent)
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
spinner.succeed(`Configuration generated. Running ${pm} uninstall...`)
|
|
62
|
+
|
|
63
|
+
const pmArgs =
|
|
64
|
+
pm === "npm"
|
|
65
|
+
? ["uninstall", ...packages, "--userconfig", tempNpmrcPath]
|
|
66
|
+
: ["uninstall", ...packages]
|
|
67
|
+
|
|
68
|
+
const child = spawn(pm, pmArgs, {
|
|
69
|
+
stdio: "inherit",
|
|
70
|
+
env: { ...process.env, LPM_TOKEN: token },
|
|
71
|
+
})
|
|
72
|
+
|
|
73
|
+
const cleanup = () => {
|
|
74
|
+
if (pm === "npm") {
|
|
75
|
+
if (tempNpmrcPath && fs.existsSync(tempNpmrcPath)) {
|
|
76
|
+
fs.unlinkSync(tempNpmrcPath)
|
|
77
|
+
}
|
|
78
|
+
} else {
|
|
79
|
+
if (existingNpmrc !== null) {
|
|
80
|
+
fs.writeFileSync(projectNpmrcPath, existingNpmrc)
|
|
81
|
+
} else if (fs.existsSync(projectNpmrcPath)) {
|
|
82
|
+
fs.unlinkSync(projectNpmrcPath)
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
child.on("close", code => {
|
|
88
|
+
cleanup()
|
|
89
|
+
if (code !== 0) {
|
|
90
|
+
log.error(`${pm} uninstall failed with code ${code}`)
|
|
91
|
+
process.exit(code)
|
|
92
|
+
} else {
|
|
93
|
+
log.success("Packages uninstalled successfully.")
|
|
94
|
+
}
|
|
95
|
+
})
|
|
96
|
+
|
|
97
|
+
child.on("error", err => {
|
|
98
|
+
log.error(`Failed to start ${pm}: ${err.message}`)
|
|
99
|
+
cleanup()
|
|
100
|
+
process.exit(1)
|
|
101
|
+
})
|
|
102
|
+
|
|
103
|
+
process.on("SIGINT", () => {
|
|
104
|
+
cleanup()
|
|
105
|
+
process.exit()
|
|
106
|
+
})
|
|
107
|
+
}
|
package/lib/config.js
CHANGED
|
@@ -183,6 +183,32 @@ export function setRetries(count) {
|
|
|
183
183
|
config.set("retries", count)
|
|
184
184
|
}
|
|
185
185
|
|
|
186
|
+
// ============================================================================
|
|
187
|
+
// Package Manager Configuration
|
|
188
|
+
// ============================================================================
|
|
189
|
+
|
|
190
|
+
const VALID_PACKAGE_MANAGERS = new Set(["npm", "pnpm", "yarn", "bun"])
|
|
191
|
+
const DEFAULT_PACKAGE_MANAGER = "npm"
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Get the configured package manager for install/uninstall operations.
|
|
195
|
+
* Priority: --pm flag > LPM_PACKAGE_MANAGER env > config > "npm"
|
|
196
|
+
* @param {string} [override] - CLI flag override (--pm value)
|
|
197
|
+
* @returns {string}
|
|
198
|
+
*/
|
|
199
|
+
export function getPackageManager(override) {
|
|
200
|
+
const pm =
|
|
201
|
+
override ||
|
|
202
|
+
process.env.LPM_PACKAGE_MANAGER ||
|
|
203
|
+
config.get("packageManager", DEFAULT_PACKAGE_MANAGER)
|
|
204
|
+
|
|
205
|
+
if (!VALID_PACKAGE_MANAGERS.has(pm)) {
|
|
206
|
+
return DEFAULT_PACKAGE_MANAGER
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
return pm
|
|
210
|
+
}
|
|
211
|
+
|
|
186
212
|
// ============================================================================
|
|
187
213
|
// General Configuration Access
|
|
188
214
|
// ============================================================================
|
|
@@ -197,6 +223,7 @@ export async function getAllConfig() {
|
|
|
197
223
|
|
|
198
224
|
return {
|
|
199
225
|
registryUrl: getRegistryUrl(),
|
|
226
|
+
packageManager: getPackageManager(),
|
|
200
227
|
timeout: getTimeout(),
|
|
201
228
|
retries: getRetries(),
|
|
202
229
|
secureStorage: usingKeychain ? "keychain" : "encrypted-file",
|
|
@@ -213,6 +240,7 @@ export function getConfigValue(key) {
|
|
|
213
240
|
const configMap = {
|
|
214
241
|
registry: getRegistryUrl,
|
|
215
242
|
registryUrl: getRegistryUrl,
|
|
243
|
+
packageManager: getPackageManager,
|
|
216
244
|
timeout: getTimeout,
|
|
217
245
|
retries: getRetries,
|
|
218
246
|
}
|
|
@@ -232,6 +260,15 @@ export function setConfigValue(key, value) {
|
|
|
232
260
|
const configMap = {
|
|
233
261
|
registry: setRegistryUrl,
|
|
234
262
|
registryUrl: setRegistryUrl,
|
|
263
|
+
packageManager: val => {
|
|
264
|
+
if (VALID_PACKAGE_MANAGERS.has(val)) {
|
|
265
|
+
config.set("packageManager", val)
|
|
266
|
+
} else {
|
|
267
|
+
throw new Error(
|
|
268
|
+
`Invalid package manager "${val}". Valid options: ${[...VALID_PACKAGE_MANAGERS].join(", ")}`,
|
|
269
|
+
)
|
|
270
|
+
}
|
|
271
|
+
},
|
|
235
272
|
timeout: val => setTimeout(Number(val)),
|
|
236
273
|
retries: val => setRetries(Number(val)),
|
|
237
274
|
}
|