@lpm-registry/cli 0.2.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.
Files changed (54) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/LICENSE +15 -0
  3. package/README.md +406 -0
  4. package/bin/lpm.js +334 -0
  5. package/index.d.ts +131 -0
  6. package/index.js +31 -0
  7. package/lib/api.js +324 -0
  8. package/lib/commands/add.js +1217 -0
  9. package/lib/commands/audit.js +283 -0
  10. package/lib/commands/cache.js +209 -0
  11. package/lib/commands/check-name.js +112 -0
  12. package/lib/commands/config.js +174 -0
  13. package/lib/commands/doctor.js +142 -0
  14. package/lib/commands/info.js +215 -0
  15. package/lib/commands/init.js +146 -0
  16. package/lib/commands/install.js +217 -0
  17. package/lib/commands/login.js +547 -0
  18. package/lib/commands/logout.js +94 -0
  19. package/lib/commands/marketplace-compare.js +164 -0
  20. package/lib/commands/marketplace-earnings.js +89 -0
  21. package/lib/commands/mcp-setup.js +363 -0
  22. package/lib/commands/open.js +82 -0
  23. package/lib/commands/outdated.js +291 -0
  24. package/lib/commands/pool-stats.js +100 -0
  25. package/lib/commands/publish.js +707 -0
  26. package/lib/commands/quality.js +211 -0
  27. package/lib/commands/remove.js +82 -0
  28. package/lib/commands/run.js +14 -0
  29. package/lib/commands/search.js +143 -0
  30. package/lib/commands/setup.js +92 -0
  31. package/lib/commands/skills.js +863 -0
  32. package/lib/commands/token-rotate.js +25 -0
  33. package/lib/commands/whoami.js +129 -0
  34. package/lib/config.js +240 -0
  35. package/lib/constants.js +190 -0
  36. package/lib/ecosystem.js +501 -0
  37. package/lib/editors.js +215 -0
  38. package/lib/import-rewriter.js +364 -0
  39. package/lib/install-targets/mcp-server.js +245 -0
  40. package/lib/install-targets/vscode-extension.js +178 -0
  41. package/lib/install-targets.js +82 -0
  42. package/lib/integrity.js +179 -0
  43. package/lib/lpm-config-prompts.js +102 -0
  44. package/lib/lpm-config.js +408 -0
  45. package/lib/project-utils.js +152 -0
  46. package/lib/quality/checks.js +654 -0
  47. package/lib/quality/display.js +139 -0
  48. package/lib/quality/score.js +115 -0
  49. package/lib/quality/swift-checks.js +447 -0
  50. package/lib/safe-path.js +180 -0
  51. package/lib/secure-store.js +288 -0
  52. package/lib/swift-project.js +637 -0
  53. package/lib/ui.js +40 -0
  54. package/package.json +74 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,36 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ ## [0.2.0] - 2025-02-14
6
+
7
+ ### Added
8
+ - Quality scoring system with 27 checks across 4 categories
9
+ - `lpm publish --check` and `--min-score` flags for quality gating
10
+ - `lpm add` command for shadcn-style source code delivery
11
+ - `lpm.config.json` support for configurable source packages
12
+ - Secure credential storage (OS keychain with encrypted file fallback)
13
+ - SRI integrity verification for package tarballs
14
+ - Path traversal protection for tarball extraction
15
+ - Exponential backoff retry with rate-limit handling
16
+
17
+ ### Changed
18
+ - Migrated from `node-fetch` to native `fetch` (Node 18+)
19
+ - Removed unused `figlet` and `form-data` dependencies
20
+ - Updated default registry URL to `https://lpm.dev`
21
+
22
+ ### Fixed
23
+ - Missing `await` on `setToken()` in token-rotate command
24
+ - URL construction for `@lpm.dev/owner.pkg` format in open command
25
+ - Inconsistent limit field names in doctor command
26
+
27
+ ## [0.1.0] - 2024-12-01
28
+
29
+ ### Added
30
+ - Initial CLI release
31
+ - `lpm login`, `lpm logout`, `lpm whoami` authentication commands
32
+ - `lpm publish`, `lpm install` package management
33
+ - `lpm search`, `lpm info` package discovery
34
+ - `lpm audit`, `lpm outdated` security and maintenance checks
35
+ - `lpm doctor` health checks
36
+ - `lpm config`, `lpm cache` configuration management
package/LICENSE ADDED
@@ -0,0 +1,15 @@
1
+ ISC License
2
+
3
+ Copyright (c) 2024-2025 LPM
4
+
5
+ Permission to use, copy, modify, and/or distribute this software for any
6
+ purpose with or without fee is hereby granted, provided that the above
7
+ copyright notice and this permission notice appear in all copies.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
10
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
12
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
14
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15
+ PERFORMANCE OF THIS SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,406 @@
1
+ # LPM CLI
2
+
3
+ The command-line interface for the Licensed Package Manager (LPM).
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install -g @lpm-registry/cli
9
+ ```
10
+
11
+ ## Command Shortcuts
12
+
13
+ LPM provides convenient aliases for common commands:
14
+
15
+ | Shortcut | Full Command | Description |
16
+ |----------|--------------|-------------|
17
+ | `lpm i` | `lpm install` | Install packages |
18
+ | `lpm p` | `lpm publish` | Publish package |
19
+ | `lpm l` | `lpm login` | Log in |
20
+ | `lpm lo` | `lpm logout` | Log out |
21
+ | `lpm set <key> <value>` | `lpm config set` | Set config |
22
+
23
+ ## Package Name Format
24
+
25
+ LPM uses the `@lpm.dev` scope for all packages with dot notation:
26
+
27
+ ```
28
+ @lpm.dev/owner.package-name
29
+ ```
30
+
31
+ Examples:
32
+ - `@lpm.dev/tolgaergin.my-utils` (personal package)
33
+ - `@lpm.dev/acme-corp.design-system` (org package)
34
+
35
+ ## Commands
36
+
37
+ ### Authentication
38
+
39
+ #### Login
40
+
41
+ Authenticate with the registry. Opens your browser for secure OAuth login.
42
+
43
+ ```bash
44
+ lpm login
45
+ ```
46
+
47
+ #### Logout
48
+
49
+ Clear stored authentication token. Optionally revoke on server and clear cache.
50
+
51
+ ```bash
52
+ lpm logout
53
+ lpm logout --revoke # Also revoke token on server
54
+ lpm logout --clear-cache # Also clear local package cache
55
+ ```
56
+
57
+ #### Check Identity
58
+
59
+ See who you are logged in as and check plan status.
60
+
61
+ ```bash
62
+ lpm whoami
63
+ ```
64
+
65
+ ### Project Setup
66
+
67
+ #### Setup .npmrc
68
+
69
+ Configure your project's `.npmrc` for LPM packages. Required for CI/CD deployments.
70
+
71
+ ```bash
72
+ lpm setup
73
+ ```
74
+
75
+ This creates a `.npmrc` file with the LPM registry configuration:
76
+
77
+ ```ini
78
+ # LPM Registry
79
+ @lpm.dev:registry=https://lpm.dev/api/registry
80
+ //lpm.dev/api/registry/:_authToken=${LPM_TOKEN}
81
+ ```
82
+
83
+ For deployment, set the `LPM_TOKEN` environment variable on your platform (Vercel, Netlify, etc.).
84
+
85
+ ### Package Management
86
+
87
+ #### Initialize a Package
88
+
89
+ Scaffold a new package with `package.json` configured for LPM.
90
+
91
+ ```bash
92
+ lpm init
93
+ ```
94
+
95
+ #### Publish
96
+
97
+ Publish the current package to the registry. Automatically verifies you have the required token scope. Includes a quality score report on every publish.
98
+
99
+ ```bash
100
+ lpm publish
101
+ lpm publish --check # Run quality checks without publishing
102
+ lpm publish --min-score 80 # Block publish if quality score < 80
103
+ lpm publish --check --min-score 90 # Check only, fail if below 90 (useful in CI)
104
+ ```
105
+
106
+ | Option | Description |
107
+ |--------|-------------|
108
+ | `--check` | Run quality checks and display report, then exit without publishing |
109
+ | `--min-score <n>` | Set minimum quality score (0-100) required to publish |
110
+
111
+ > **Note:** If `.lpm/skills/` exists in your package but skills aren't included in the tarball, the CLI warns you to add `.lpm` to the `files` field in package.json.
112
+
113
+ #### Install
114
+
115
+ Install packages from the registry with automatic authentication.
116
+
117
+ ```bash
118
+ lpm install @lpm.dev/owner.package-name
119
+ lpm install @lpm.dev/tolgaergin.utils @lpm.dev/acme.helpers
120
+ lpm install # Install all @lpm.dev packages from package.json
121
+ lpm install --no-skills # Skip fetching Agent Skills
122
+ lpm i # Shortcut
123
+ ```
124
+
125
+ Agent Skills are fetched by default for packages that include them.
126
+
127
+ | Option | Description |
128
+ |--------|-------------|
129
+ | `--no-skills` | Skip fetching Agent Skills after install |
130
+
131
+ #### Add (Source Code)
132
+
133
+ Download and extract package source code directly into your project (shadcn-style).
134
+
135
+ ```bash
136
+ # JavaScript
137
+ lpm add @lpm.dev/owner.component
138
+ lpm add @lpm.dev/tolgaergin.button --path ./src/ui/Button
139
+ lpm add @lpm.dev/owner.component --force # Overwrite without prompting
140
+ lpm add @lpm.dev/owner.component --no-skills # Skip fetching Agent Skills
141
+
142
+ # Swift (auto-detects project type)
143
+ lpm add @lpm.dev/acme.swift-charts
144
+ ```
145
+
146
+ Agent Skills are fetched by default for packages that include them.
147
+
148
+ For Swift projects, the CLI auto-detects whether you have a `Package.swift` (SPM package) or `.xcodeproj` (Xcode app project):
149
+
150
+ - **SPM packages:** Files are copied into the appropriate `Sources/{target}/` directory. SPM auto-discovers new `.swift` files.
151
+ - **Xcode app projects:** The CLI scaffolds a local SPM package at `Packages/LPMComponents/`, copies source files, and auto-links the package in your `.xcodeproj` file. Xcode hot-reloads the change — no restart needed.
152
+
153
+ ### Package Discovery
154
+
155
+ #### Search
156
+
157
+ Search for packages in the marketplace.
158
+
159
+ ```bash
160
+ lpm search <query>
161
+ lpm search button --limit 50
162
+ lpm search datepicker --json
163
+ ```
164
+
165
+ #### Info
166
+
167
+ Show detailed information about a package.
168
+
169
+ ```bash
170
+ lpm info @lpm.dev/owner.package
171
+ lpm info @lpm.dev/tolgaergin.utils -a # Show all versions
172
+ lpm info @lpm.dev/owner.package --all-versions
173
+ lpm info @lpm.dev/owner.package --json
174
+ ```
175
+
176
+ #### Check Name
177
+
178
+ Check if a package name is available on the registry.
179
+
180
+ ```bash
181
+ lpm check-name acme.new-package
182
+ lpm check-name acme.new-package --json
183
+ ```
184
+
185
+ #### Quality
186
+
187
+ Show the server-side quality report for a published package. Displays the score, tier, and breakdown of all 28 checks.
188
+
189
+ ```bash
190
+ lpm quality @lpm.dev/owner.package
191
+ lpm quality @lpm.dev/owner.package --json
192
+ ```
193
+
194
+ ### Skills
195
+
196
+ Manage Agent Skills for AI coding assistants.
197
+
198
+ #### `lpm skills validate`
199
+ Validate `.lpm/skills/*.md` files in the current directory. Checks file format, frontmatter, content, size limits, and blocked patterns. Shows quality score impact.
200
+
201
+ #### `lpm skills install [package]`
202
+ Fetch and install skills from the registry. Without a package argument, installs skills for all `@lpm.dev/*` dependencies in package.json. Saves to `.lpm/skills/{package-name}/` and adds `.lpm/skills/` to `.gitignore`.
203
+
204
+ #### `lpm skills list`
205
+ List available skills for all installed `@lpm.dev/*` packages. Shows which packages have skills, how many, and whether they're installed locally.
206
+
207
+ #### `lpm skills clean`
208
+ Remove the `.lpm/skills/` directory and all locally installed skills.
209
+
210
+ ### Security & Maintenance
211
+
212
+ #### Audit
213
+
214
+ Scan dependencies for known security vulnerabilities.
215
+
216
+ ```bash
217
+ lpm audit
218
+ lpm audit --level high # Only show high+ severity
219
+ lpm audit --json # JSON output for CI
220
+ lpm audit fix # Attempt automatic fixes
221
+ ```
222
+
223
+ #### Outdated
224
+
225
+ Check for outdated dependencies.
226
+
227
+ ```bash
228
+ lpm outdated
229
+ lpm outdated --all # Show all deps, not just outdated
230
+ lpm outdated --json # JSON output for CI
231
+ ```
232
+
233
+ #### Doctor
234
+
235
+ Check your CLI setup, connection, and configuration.
236
+
237
+ ```bash
238
+ lpm doctor
239
+ ```
240
+
241
+ ### Configuration
242
+
243
+ #### Config
244
+
245
+ Manage CLI configuration values.
246
+
247
+ ```bash
248
+ lpm config list # Show all config
249
+ lpm config get registry # Get specific value
250
+ lpm config set registry https://... # Set registry URL
251
+ lpm config set timeout 60000 # Set request timeout (ms)
252
+ lpm config set retries 5 # Set max retries
253
+ lpm config delete <key> # Reset to default
254
+ ```
255
+
256
+ #### Cache
257
+
258
+ Manage local package cache.
259
+
260
+ ```bash
261
+ lpm cache list # Show cached packages with sizes
262
+ lpm cache clean # Clear all cached packages
263
+ lpm cache path # Show cache directory location
264
+ ```
265
+
266
+ ### Utilities
267
+
268
+ #### Open Dashboard
269
+
270
+ Open the dashboard or package page in your browser.
271
+
272
+ ```bash
273
+ lpm open
274
+ ```
275
+
276
+ #### Run npm Scripts
277
+
278
+ Forward commands to npm run.
279
+
280
+ ```bash
281
+ lpm run dev # Same as npm run dev
282
+ lpm run build # Same as npm run build
283
+ lpm run test -- --watch # Pass arguments through
284
+ ```
285
+
286
+ #### Token Management
287
+
288
+ Rotate your authentication token.
289
+
290
+ ```bash
291
+ lpm token rotate
292
+ ```
293
+
294
+ ### Pool Revenue
295
+
296
+ #### Pool Stats
297
+
298
+ Show your Pool earnings estimate for the current billing period. Displays per-package breakdown with install counts, weighted downloads, share percentage, and estimated earnings.
299
+
300
+ ```bash
301
+ lpm pool stats
302
+ lpm pool stats --json
303
+ ```
304
+
305
+ ### Marketplace
306
+
307
+ #### Compare
308
+
309
+ Find comparable packages by name or category. Useful for pricing research and competitive analysis.
310
+
311
+ ```bash
312
+ lpm marketplace compare "form builder"
313
+ lpm marketplace compare ui --category ui-components
314
+ lpm marketplace compare auth --limit 5
315
+ lpm marketplace compare "form builder" --json
316
+ ```
317
+
318
+ #### Earnings
319
+
320
+ Show your Marketplace revenue summary including total sales, gross revenue, platform fees, and net revenue.
321
+
322
+ ```bash
323
+ lpm marketplace earnings
324
+ lpm marketplace earnings --json
325
+ ```
326
+
327
+ ## API Reference
328
+
329
+ The CLI exports utilities for programmatic use:
330
+
331
+ ```js
332
+ import {
333
+ generateIntegrity,
334
+ verifyIntegrity,
335
+ runQualityChecks,
336
+ parseLpmPackageReference,
337
+ detectFramework,
338
+ } from "@lpm-registry/cli"
339
+ ```
340
+
341
+ ### Integrity
342
+
343
+ | Function | Description |
344
+ |----------|-------------|
345
+ | `generateIntegrity(buffer, algorithm?)` | Generate an SRI integrity hash (default: `sha512`) |
346
+ | `verifyIntegrity(buffer, expected)` | Verify a buffer against an SRI integrity string |
347
+ | `verifyIntegrityMultiple(buffer, integrities)` | Verify against multiple integrity strings |
348
+ | `parseIntegrity(integrity)` | Parse an SRI string into `{ algorithm, digest }` |
349
+
350
+ ### Path Safety
351
+
352
+ | Function | Description |
353
+ |----------|-------------|
354
+ | `validateComponentPath(root, path)` | Validate a component install path stays within project |
355
+ | `validateTarballPaths(extractDir, paths)` | Check tarball entries for path traversal attacks |
356
+ | `resolveSafePath(base, user)` | Safely resolve a user-provided path |
357
+ | `sanitizeFilename(name)` | Strip dangerous characters from a filename |
358
+
359
+ ### Quality
360
+
361
+ | Function | Description |
362
+ |----------|-------------|
363
+ | `runQualityChecks({ packageJson, readme, lpmConfig, files, unpackedSize })` | Run all 28 quality checks and return score, checks, and tier |
364
+
365
+ ### Package Config
366
+
367
+ | Function | Description |
368
+ |----------|-------------|
369
+ | `parseLpmPackageReference(ref)` | Parse `@lpm.dev/owner.pkg@version?key=val` into components |
370
+ | `readLpmConfig(dir)` | Read and validate `lpm.config.json` from a directory |
371
+ | `validateLpmConfig(config)` | Validate a parsed config object |
372
+ | `filterFiles(files, config, params)` | Filter file rules based on config conditions |
373
+
374
+ ### Project Utils
375
+
376
+ | Function | Description |
377
+ |----------|-------------|
378
+ | `detectFramework()` | Detect the project framework (nextjs, vite, remix, astro) |
379
+ | `getDefaultPath(framework, name)` | Get the default component install path for a framework |
380
+ | `getUserImportPrefix()` | Get the user's import alias prefix (e.g. `@/`, `~/`) |
381
+
382
+ ## Security
383
+
384
+ LPM CLI uses secure credential storage:
385
+
386
+ - **macOS**: System Keychain
387
+ - **Windows**: Windows Credential Manager
388
+ - **Linux**: libsecret (GNOME Keyring, KWallet)
389
+
390
+ If native keychain is unavailable, credentials are stored in an encrypted file with AES-256-GCM.
391
+
392
+ ## Configuration File
393
+
394
+ Configuration is stored in:
395
+
396
+ - **macOS**: `~/Library/Preferences/lpm-cli-nodejs/`
397
+ - **Windows**: `%APPDATA%/lpm-cli-nodejs/Config/`
398
+ - **Linux**: `~/.config/lpm-cli-nodejs/`
399
+
400
+ ## Environment Variables
401
+
402
+ | Variable | Description |
403
+ | ------------------ | --------------------- |
404
+ | `DEBUG=true` | Enable debug output |
405
+ | `LPM_REGISTRY_URL` | Override registry URL |
406
+ | `LPM_TOKEN` | Override auth token |