@lpm-registry/cli 0.46.0 → 0.47.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/bin/lpm.js CHANGED
@@ -17,331 +17,340 @@
17
17
  * 3. Fall through to JS CLI implementation
18
18
  */
19
19
 
20
- import { execFileSync } from "node:child_process"
21
- import fs from "node:fs"
22
- import { createRequire } from "node:module"
23
- import os from "node:os"
24
- import path from "node:path"
25
- import { fileURLToPath } from "node:url"
20
+ import { execFileSync } from "node:child_process";
21
+ import fs from "node:fs";
22
+ import { createRequire } from "node:module";
23
+ import os from "node:os";
24
+ import path from "node:path";
25
+ import { fileURLToPath } from "node:url";
26
26
 
27
- const __dirname = path.dirname(fileURLToPath(import.meta.url))
28
- const require = createRequire(import.meta.url)
27
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
28
+ const require = createRequire(import.meta.url);
29
29
 
30
30
  // ─── Try native binary (Tier 1: platform package) ──────────────────
31
31
 
32
32
  const PLATFORMS = {
33
- "darwin-arm64": { pkg: "@lpm-registry/cli-darwin-arm64", binary: "lpm" },
34
- "darwin-x64": { pkg: "@lpm-registry/cli-darwin-x64", binary: "lpm" },
35
- "linux-x64": { pkg: "@lpm-registry/cli-linux-x64", binary: "lpm" },
36
- "linux-arm64": { pkg: "@lpm-registry/cli-linux-arm64", binary: "lpm" },
37
- "win32-x64": { pkg: "@lpm-registry/cli-win32-x64", binary: "lpm.exe" },
38
- }
33
+ "darwin-arm64": { pkg: "@lpm-registry/cli-darwin-arm64", binary: "lpm" },
34
+ "darwin-x64": { pkg: "@lpm-registry/cli-darwin-x64", binary: "lpm" },
35
+ "linux-x64": { pkg: "@lpm-registry/cli-linux-x64", binary: "lpm" },
36
+ "linux-arm64": { pkg: "@lpm-registry/cli-linux-arm64", binary: "lpm" },
37
+ "win32-x64": { pkg: "@lpm-registry/cli-win32-x64", binary: "lpm.exe" },
38
+ };
39
39
 
40
40
  // Allow override via environment variable (for debugging / custom builds)
41
- const envBinary = process.env.LPM_BINARY_PATH
41
+ const envBinary = process.env.LPM_BINARY_PATH;
42
42
  if (envBinary && fs.existsSync(envBinary)) {
43
- runBinary(envBinary)
43
+ runBinary(envBinary);
44
44
  }
45
45
 
46
46
  // Try platform package from optionalDependencies
47
- const platform = `${process.platform}-${os.arch()}`
48
- const platformInfo = PLATFORMS[platform]
47
+ const platform = `${process.platform}-${os.arch()}`;
48
+ const platformInfo = PLATFORMS[platform];
49
49
 
50
50
  if (platformInfo) {
51
- try {
52
- const pkgJsonPath = require.resolve(`${platformInfo.pkg}/package.json`)
53
- const binaryPath = path.join(path.dirname(pkgJsonPath), platformInfo.binary)
54
- if (fs.existsSync(binaryPath)) {
55
- runBinary(binaryPath)
56
- }
57
- } catch {
58
- // Package not installed
59
- }
51
+ try {
52
+ const pkgJsonPath = require.resolve(`${platformInfo.pkg}/package.json`);
53
+ const binaryPath = path.join(
54
+ path.dirname(pkgJsonPath),
55
+ platformInfo.binary,
56
+ );
57
+ if (fs.existsSync(binaryPath)) {
58
+ runBinary(binaryPath);
59
+ }
60
+ } catch {
61
+ // Package not installed
62
+ }
60
63
  }
61
64
 
62
65
  // ─── Try native binary (Tier 2: downloaded by postinstall) ─────────
63
66
 
64
67
  const legacyBinaryName =
65
- process.platform === "win32" ? "lpm-bin.exe" : "lpm-bin"
66
- const legacyBinaryPath = path.join(__dirname, legacyBinaryName)
68
+ process.platform === "win32" ? "lpm-bin.exe" : "lpm-bin";
69
+ const legacyBinaryPath = path.join(__dirname, legacyBinaryName);
67
70
 
68
71
  if (fs.existsSync(legacyBinaryPath)) {
69
- runBinary(legacyBinaryPath)
72
+ runBinary(legacyBinaryPath);
70
73
  }
71
74
 
72
75
  // ─── JS CLI fallback (Tier 3) ──────────────────────────────────────
73
76
 
74
- import { Command } from "commander"
75
- import updateNotifier from "update-notifier"
76
- import { add } from "../lib/commands/add.js"
77
- import { audit } from "../lib/commands/audit.js"
78
- import { cache } from "../lib/commands/cache.js"
79
- import { checkName } from "../lib/commands/check-name.js"
80
- import { config } from "../lib/commands/config.js"
81
- import { doctor } from "../lib/commands/doctor.js"
82
- import { info } from "../lib/commands/info.js"
83
- import { init } from "../lib/commands/init.js"
84
- import { install } from "../lib/commands/install.js"
85
- import { login } from "../lib/commands/login.js"
86
- import { logout } from "../lib/commands/logout.js"
87
- import { marketplaceCompare } from "../lib/commands/marketplace-compare.js"
88
- import { marketplaceEarnings } from "../lib/commands/marketplace-earnings.js"
89
- import { mcpRemove, mcpSetup, mcpStatus } from "../lib/commands/mcp-setup.js"
90
- import { npmrc } from "../lib/commands/npmrc.js"
91
- import { openDashboard } from "../lib/commands/open.js"
92
- import { outdated } from "../lib/commands/outdated.js"
93
- import { poolStats } from "../lib/commands/pool-stats.js"
94
- import { publish } from "../lib/commands/publish.js"
95
- import { quality } from "../lib/commands/quality.js"
96
- import { remove } from "../lib/commands/remove.js"
97
- import { run } from "../lib/commands/run.js"
98
- import { search } from "../lib/commands/search.js"
99
- import { setup } from "../lib/commands/setup.js"
77
+ import { Command } from "commander";
78
+ import updateNotifier from "update-notifier";
79
+ import { add } from "../lib/commands/add.js";
80
+ import { audit } from "../lib/commands/audit.js";
81
+ import { cache } from "../lib/commands/cache.js";
82
+ import { checkName } from "../lib/commands/check-name.js";
83
+ import { config } from "../lib/commands/config.js";
84
+ import { doctor } from "../lib/commands/doctor.js";
85
+ import { info } from "../lib/commands/info.js";
86
+ import { init } from "../lib/commands/init.js";
87
+ import { install } from "../lib/commands/install.js";
88
+ import { login } from "../lib/commands/login.js";
89
+ import { logout } from "../lib/commands/logout.js";
90
+ import { marketplaceCompare } from "../lib/commands/marketplace-compare.js";
91
+ import { marketplaceEarnings } from "../lib/commands/marketplace-earnings.js";
92
+ import { mcpRemove, mcpSetup, mcpStatus } from "../lib/commands/mcp-setup.js";
93
+ import { npmrc } from "../lib/commands/npmrc.js";
94
+ import { openDashboard } from "../lib/commands/open.js";
95
+ import { outdated } from "../lib/commands/outdated.js";
96
+ import { poolStats } from "../lib/commands/pool-stats.js";
97
+ import { publish } from "../lib/commands/publish.js";
98
+ import { quality } from "../lib/commands/quality.js";
99
+ import { remove } from "../lib/commands/remove.js";
100
+ import { run } from "../lib/commands/run.js";
101
+ import { search } from "../lib/commands/search.js";
102
+ import { setup } from "../lib/commands/setup.js";
100
103
  import {
101
- skillsClean,
102
- skillsInstall,
103
- skillsList,
104
- skillsValidate,
105
- } from "../lib/commands/skills.js"
106
- import { rotateToken } from "../lib/commands/token-rotate.js"
107
- import { uninstall } from "../lib/commands/uninstall.js"
108
- import { whoami } from "../lib/commands/whoami.js"
104
+ skillsClean,
105
+ skillsInstall,
106
+ skillsList,
107
+ skillsValidate,
108
+ } from "../lib/commands/skills.js";
109
+ import { rotateToken } from "../lib/commands/token-rotate.js";
110
+ import { uninstall } from "../lib/commands/uninstall.js";
111
+ import { whoami } from "../lib/commands/whoami.js";
109
112
 
110
113
  // Load package.json
111
114
  const pkg = JSON.parse(
112
- fs.readFileSync(path.join(__dirname, "../package.json"), "utf-8"),
113
- )
115
+ fs.readFileSync(path.join(__dirname, "../package.json"), "utf-8"),
116
+ );
114
117
 
115
118
  // Check for updates
116
- updateNotifier({ pkg }).notify()
119
+ updateNotifier({ pkg }).notify();
117
120
 
118
- const program = new Command()
121
+ const program = new Command();
119
122
 
120
123
  program
121
- .name("lpm")
122
- .description("CLI for Licensed Package Manager")
123
- .version(pkg.version)
124
+ .name("lpm")
125
+ .description("CLI for Licensed Package Manager")
126
+ .version(pkg.version);
124
127
 
125
128
  // Authentication
126
129
  program
127
- .command("login")
128
- .alias("l")
129
- .description("Authenticate with the registry")
130
- .action(login)
130
+ .command("login")
131
+ .alias("l")
132
+ .description("Authenticate with the registry")
133
+ .action(login);
131
134
  program
132
- .command("logout")
133
- .alias("lo")
134
- .description("Clear stored authentication token")
135
- .option("--revoke", "Also revoke the token on the server")
136
- .option("--clear-cache", "Clear local package cache")
137
- .action(logout)
135
+ .command("logout")
136
+ .alias("lo")
137
+ .description("Clear stored authentication token")
138
+ .option("--revoke", "Also revoke the token on the server")
139
+ .option("--clear-cache", "Clear local package cache")
140
+ .action(logout);
138
141
  program
139
- .command("whoami")
140
- .description("Check current authenticated user")
141
- .option("--json", "Output in JSON format")
142
- .action(whoami)
142
+ .command("whoami")
143
+ .description("Check current authenticated user")
144
+ .option("--json", "Output in JSON format")
145
+ .action(whoami);
143
146
 
144
147
  // Package Management
145
148
  program
146
- .command("init")
147
- .description("Interactively create a package.json for LPM")
148
- .action(init)
149
+ .command("init")
150
+ .description("Interactively create a package.json for LPM")
151
+ .action(init);
149
152
  program
150
- .command("install [packages...]")
151
- .alias("i")
152
- .description("Install packages")
153
- .option("--json", "Machine-readable JSON output")
154
- .option("--no-skills", "Skip fetching Agent Skills")
155
- .option("--pm <manager>", "Package manager to use")
156
- .action(install)
153
+ .command("install [packages...]")
154
+ .alias("i")
155
+ .description("Install packages")
156
+ .option("--json", "Machine-readable JSON output")
157
+ .option("--no-skills", "Skip fetching Agent Skills")
158
+ .option("--pm <manager>", "Package manager to use")
159
+ .action(install);
157
160
  program
158
- .command("uninstall <packages...>")
159
- .aliases(["un", "unlink"])
160
- .description("Uninstall packages")
161
- .option("--pm <manager>", "Package manager to use")
162
- .action(uninstall)
161
+ .command("uninstall <packages...>")
162
+ .aliases(["un", "unlink"])
163
+ .description("Uninstall packages")
164
+ .option("--pm <manager>", "Package manager to use")
165
+ .action(uninstall);
163
166
  program
164
- .command("publish")
165
- .alias("p")
166
- .description("Publish a package to the registry")
167
- .option("--check", "Quality check only")
168
- .option("--min-score <score>", "Minimum quality score")
169
- .option("--provenance", "Force OIDC provenance")
170
- .option("--dry-run", "Preview without publishing")
171
- .action(publish)
167
+ .command("publish")
168
+ .alias("p")
169
+ .description("Publish a package to the registry")
170
+ .option("--check", "Quality check only")
171
+ .option("--min-score <score>", "Minimum quality score")
172
+ .option("--provenance", "Force OIDC provenance")
173
+ .option("--dry-run", "Preview without publishing")
174
+ .action(publish);
172
175
  program
173
- .command("add <package>")
174
- .description("Extract package source code")
175
- .option("-p, --path <path>", "Target directory")
176
- .option("-f, --force", "Overwrite existing files")
177
- .option("-y, --yes", "Accept defaults")
178
- .option("--alias <alias>", "Import alias prefix")
179
- .option("--target <name>", "Swift SPM target")
180
- .option("--json", "JSON output")
181
- .option("--dry-run", "Preview only")
182
- .action(add)
176
+ .command("add <package>")
177
+ .description("Extract package source code")
178
+ .option("-p, --path <path>", "Target directory")
179
+ .option("-f, --force", "Overwrite existing files")
180
+ .option("-y, --yes", "Accept defaults")
181
+ .option("--alias <alias>", "Import alias prefix")
182
+ .option("--target <name>", "Swift SPM target")
183
+ .option("--json", "JSON output")
184
+ .option("--dry-run", "Preview only")
185
+ .action(add);
183
186
  program
184
- .command("remove <package>")
185
- .alias("rm")
186
- .description("Remove a previously added package")
187
- .action(remove)
187
+ .command("remove <package>")
188
+ .alias("rm")
189
+ .description("Remove a previously added package")
190
+ .action(remove);
188
191
 
189
192
  // Discovery
190
193
  program
191
- .command("search <query>")
192
- .description("Search packages")
193
- .option("--limit <n>", "Max results", "20")
194
- .option("--json", "JSON output")
195
- .action((q, o) => search(q, { ...o, limit: parseInt(o.limit, 10) }))
194
+ .command("search <query>")
195
+ .description("Search packages")
196
+ .option("--limit <n>", "Max results", "20")
197
+ .option("--json", "JSON output")
198
+ .action((q, o) => search(q, { ...o, limit: parseInt(o.limit, 10) }));
196
199
  program
197
- .command("info <package>")
198
- .description("Package info")
199
- .option("--json", "JSON output")
200
- .option("-a, --all-versions", "Show all versions")
201
- .action(info)
200
+ .command("info <package>")
201
+ .description("Package info")
202
+ .option("--json", "JSON output")
203
+ .option("-a, --all-versions", "Show all versions")
204
+ .action(info);
202
205
  program
203
- .command("check-name <name>")
204
- .description("Check name availability")
205
- .option("--json", "JSON output")
206
- .action(checkName)
206
+ .command("check-name <name>")
207
+ .description("Check name availability")
208
+ .option("--json", "JSON output")
209
+ .action(checkName);
207
210
  program
208
- .command("quality <package>")
209
- .description("Quality report")
210
- .option("--json", "JSON output")
211
- .action(quality)
211
+ .command("quality <package>")
212
+ .description("Quality report")
213
+ .option("--json", "JSON output")
214
+ .action(quality);
212
215
 
213
216
  // Maintenance
214
217
  program
215
- .command("audit [action]")
216
- .description("Security audit")
217
- .option("--json", "JSON output")
218
- .option("--level <level>", "Minimum severity")
219
- .action(audit)
218
+ .command("audit [action]")
219
+ .description("Security audit")
220
+ .option("--json", "JSON output")
221
+ .option("--level <level>", "Minimum severity")
222
+ .action(audit);
220
223
  program
221
- .command("outdated")
222
- .description("Check outdated deps")
223
- .option("--json", "JSON output")
224
- .option("--all", "Show all deps")
225
- .action(outdated)
226
- program.command("doctor").description("Health check").action(doctor)
224
+ .command("outdated")
225
+ .description("Check outdated deps")
226
+ .option("--json", "JSON output")
227
+ .option("--all", "Show all deps")
228
+ .action(outdated);
229
+ program.command("doctor").description("Health check").action(doctor);
227
230
 
228
231
  // Configuration
232
+ const setupCommand = program
233
+ .command("setup")
234
+ .description("Configure .npmrc for CI or local development")
235
+ .action(() => setupCommand.help());
236
+ setupCommand
237
+ .command("ci")
238
+ .description("Generate .npmrc for CI/CD")
239
+ .option("-r, --registry <url>", "Custom registry URL")
240
+ .option("--oidc", "Exchange OIDC token")
241
+ .option("--proxy", "Route all npm traffic through lpm.dev")
242
+ .option("--scoped", "Scoped registry only")
243
+ .action(setup);
244
+ setupCommand
245
+ .command("local")
246
+ .description("Generate read-only .npmrc token for local development")
247
+ .option("-d, --days <number>", "Token expiry days")
248
+ .option("--proxy", "Route all npm traffic through lpm.dev")
249
+ .option("--scoped", "Scoped registry only")
250
+ .action(npmrc);
229
251
  program
230
- .command("setup")
231
- .description("Configure .npmrc")
232
- .option("-r, --registry <url>", "Custom registry URL")
233
- .option("--oidc", "Exchange OIDC token")
234
- .option("--scoped", "Scoped registry only")
235
- .action(setup)
236
- program
237
- .command("npmrc")
238
- .description("Generate read-only .npmrc token")
239
- .option("-d, --days <number>", "Token expiry days")
240
- .option("--scoped", "Scoped registry only")
241
- .action(npmrc)
242
- program
243
- .command("config [action] [key] [value]")
244
- .description("Manage CLI config")
245
- .action(config)
252
+ .command("config [action] [key] [value]")
253
+ .description("Manage CLI config")
254
+ .action(config);
246
255
  program
247
- .command("set <key> <value>")
248
- .description('Shortcut for "lpm config set"')
249
- .action((k, v) => config("set", k, v))
256
+ .command("set <key> <value>")
257
+ .description('Shortcut for "lpm config set"')
258
+ .action((k, v) => config("set", k, v));
250
259
  program
251
- .command("cache <action>")
252
- .description("Manage local cache")
253
- .action(cache)
260
+ .command("cache <action>")
261
+ .description("Manage local cache")
262
+ .action(cache);
254
263
 
255
264
  // Utility
256
265
  program
257
- .command("open")
258
- .description("Open dashboard in browser")
259
- .action(openDashboard)
266
+ .command("open")
267
+ .description("Open dashboard in browser")
268
+ .action(openDashboard);
260
269
  program
261
- .command("run <script>")
262
- .description("Run npm scripts")
263
- .allowUnknownOption()
264
- .action(run)
270
+ .command("run <script>")
271
+ .description("Run npm scripts")
272
+ .allowUnknownOption()
273
+ .action(run);
265
274
 
266
275
  // Subcommands
267
- const token = program.command("token").description("Token management")
268
- token.command("rotate").description("Rotate token").action(rotateToken)
276
+ const token = program.command("token").description("Token management");
277
+ token.command("rotate").description("Rotate token").action(rotateToken);
269
278
 
270
- const pool = program.command("pool").description("Pool revenue")
279
+ const pool = program.command("pool").description("Pool revenue");
271
280
  pool
272
- .command("stats")
273
- .description("Pool earnings")
274
- .option("--json", "JSON output")
275
- .action(poolStats)
281
+ .command("stats")
282
+ .description("Pool earnings")
283
+ .option("--json", "JSON output")
284
+ .action(poolStats);
276
285
 
277
- const mcp = program.command("mcp").description("MCP server")
286
+ const mcp = program.command("mcp").description("MCP server");
278
287
  mcp
279
- .command("setup")
280
- .description("Configure MCP server")
281
- .option("--project", "Project-level config")
282
- .action(mcpSetup)
288
+ .command("setup")
289
+ .description("Configure MCP server")
290
+ .option("--project", "Project-level config")
291
+ .action(mcpSetup);
283
292
  mcp
284
- .command("remove")
285
- .description("Remove MCP server")
286
- .option("--project", "Project-level only")
287
- .action(mcpRemove)
293
+ .command("remove")
294
+ .description("Remove MCP server")
295
+ .option("--project", "Project-level only")
296
+ .action(mcpRemove);
288
297
  mcp
289
- .command("status")
290
- .description("MCP server status")
291
- .option("--verbose", "Show diagnostics")
292
- .action(mcpStatus)
298
+ .command("status")
299
+ .description("MCP server status")
300
+ .option("--verbose", "Show diagnostics")
301
+ .action(mcpStatus);
293
302
 
294
- const skills = program.command("skills").description("Agent Skills")
303
+ const skills = program.command("skills").description("Agent Skills");
295
304
  skills
296
- .command("validate")
297
- .description("Validate skills files")
298
- .option("--json", "JSON output")
299
- .action(skillsValidate)
305
+ .command("validate")
306
+ .description("Validate skills files")
307
+ .option("--json", "JSON output")
308
+ .action(skillsValidate);
300
309
  skills
301
- .command("install [package]")
302
- .description("Install skills")
303
- .option("--json", "JSON output")
304
- .action(skillsInstall)
310
+ .command("install [package]")
311
+ .description("Install skills")
312
+ .option("--json", "JSON output")
313
+ .action(skillsInstall);
305
314
  skills
306
- .command("list")
307
- .description("List available skills")
308
- .option("--json", "JSON output")
309
- .action(skillsList)
315
+ .command("list")
316
+ .description("List available skills")
317
+ .option("--json", "JSON output")
318
+ .action(skillsList);
310
319
  skills
311
- .command("clean")
312
- .description("Remove installed skills")
313
- .option("--json", "JSON output")
314
- .action(skillsClean)
320
+ .command("clean")
321
+ .description("Remove installed skills")
322
+ .option("--json", "JSON output")
323
+ .action(skillsClean);
315
324
 
316
- const marketplace = program.command("marketplace").description("Marketplace")
325
+ const marketplace = program.command("marketplace").description("Marketplace");
317
326
  marketplace
318
- .command("compare <input>")
319
- .description("Find comparable packages")
320
- .option("--json", "JSON output")
321
- .option("--category <category>", "Filter by category")
322
- .option("--limit <n>", "Max results")
323
- .action(marketplaceCompare)
327
+ .command("compare <input>")
328
+ .description("Find comparable packages")
329
+ .option("--json", "JSON output")
330
+ .option("--category <category>", "Filter by category")
331
+ .option("--limit <n>", "Max results")
332
+ .action(marketplaceCompare);
324
333
  marketplace
325
- .command("earnings")
326
- .description("Revenue summary")
327
- .option("--json", "JSON output")
328
- .action(marketplaceEarnings)
334
+ .command("earnings")
335
+ .description("Revenue summary")
336
+ .option("--json", "JSON output")
337
+ .action(marketplaceEarnings);
329
338
 
330
- program.parse()
339
+ program.parse();
331
340
 
332
341
  // ─── Helper ────────────────────────────────────────────────────────
333
342
 
334
343
  function runBinary(binaryPath) {
335
- try {
336
- execFileSync(binaryPath, process.argv.slice(2), {
337
- stdio: "inherit",
338
- env: process.env,
339
- })
340
- process.exit(0)
341
- } catch (err) {
342
- if (err.status != null) {
343
- process.exit(err.status)
344
- }
345
- // Binary failed to execute — fall through to JS CLI
346
- }
344
+ try {
345
+ execFileSync(binaryPath, process.argv.slice(2), {
346
+ stdio: "inherit",
347
+ env: process.env,
348
+ });
349
+ process.exit(0);
350
+ } catch (err) {
351
+ if (err.status != null) {
352
+ process.exit(err.status);
353
+ }
354
+ // Binary failed to execute — fall through to JS CLI
355
+ }
347
356
  }