@lpm-registry/cli 0.57.0 → 0.59.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 (62) hide show
  1. package/README.md +21 -45
  2. package/bin/lpm.js +2 -354
  3. package/bin/lpx.js +4 -0
  4. package/bin/native.js +154 -0
  5. package/package.json +40 -82
  6. package/CHANGELOG.md +0 -197
  7. package/LICENSE +0 -15
  8. package/index.d.ts +0 -131
  9. package/index.js +0 -31
  10. package/lib/api.js +0 -398
  11. package/lib/commands/add.js +0 -1217
  12. package/lib/commands/audit.js +0 -283
  13. package/lib/commands/cache.js +0 -209
  14. package/lib/commands/check-name.js +0 -112
  15. package/lib/commands/config.js +0 -186
  16. package/lib/commands/doctor.js +0 -140
  17. package/lib/commands/info.js +0 -215
  18. package/lib/commands/init.js +0 -146
  19. package/lib/commands/install.js +0 -264
  20. package/lib/commands/login.js +0 -595
  21. package/lib/commands/logout.js +0 -94
  22. package/lib/commands/marketplace-compare.js +0 -164
  23. package/lib/commands/marketplace-earnings.js +0 -89
  24. package/lib/commands/mcp-setup.js +0 -363
  25. package/lib/commands/npmrc.js +0 -178
  26. package/lib/commands/open.js +0 -82
  27. package/lib/commands/outdated.js +0 -291
  28. package/lib/commands/pool-stats.js +0 -100
  29. package/lib/commands/publish.js +0 -949
  30. package/lib/commands/quality.js +0 -211
  31. package/lib/commands/remove.js +0 -82
  32. package/lib/commands/run.js +0 -14
  33. package/lib/commands/search.js +0 -143
  34. package/lib/commands/setup.js +0 -221
  35. package/lib/commands/skills.js +0 -898
  36. package/lib/commands/token-rotate.js +0 -25
  37. package/lib/commands/uninstall.js +0 -107
  38. package/lib/commands/whoami.js +0 -129
  39. package/lib/config.js +0 -328
  40. package/lib/constants.js +0 -190
  41. package/lib/ecosystem.js +0 -501
  42. package/lib/editor-skills.js +0 -321
  43. package/lib/editors.js +0 -215
  44. package/lib/import-rewriter.js +0 -364
  45. package/lib/install-targets/mcp-server.js +0 -245
  46. package/lib/install-targets/vscode-extension.js +0 -178
  47. package/lib/install-targets.js +0 -82
  48. package/lib/integrity.js +0 -179
  49. package/lib/lpm-config-prompts.js +0 -102
  50. package/lib/lpm-config.js +0 -408
  51. package/lib/oidc.js +0 -166
  52. package/lib/project-utils.js +0 -152
  53. package/lib/quality/checks.js +0 -687
  54. package/lib/quality/display.js +0 -155
  55. package/lib/quality/score.js +0 -118
  56. package/lib/quality/swift-checks.js +0 -447
  57. package/lib/safe-path.js +0 -180
  58. package/lib/secure-store.js +0 -321
  59. package/lib/swift-project.js +0 -637
  60. package/lib/ui.js +0 -40
  61. package/scripts/__tests__/install-binary.test.js +0 -346
  62. package/scripts/install-binary.js +0 -571
@@ -1,152 +0,0 @@
1
- import fs from "node:fs"
2
- import path from "node:path"
3
-
4
- /**
5
- * Detect the consumer project type.
6
- * Returns a framework string for JS projects, or a Swift project type.
7
- * Priority: Package.swift → .xcodeproj → .xcworkspace → JS frameworks → unknown
8
- */
9
- export function detectFramework() {
10
- const cwd = process.cwd()
11
-
12
- // Check for Swift projects first
13
- if (fs.existsSync(path.join(cwd, "Package.swift"))) return "swift-spm"
14
-
15
- // Check for Xcode projects (without Package.swift = app project)
16
- const entries = fs.readdirSync(cwd)
17
- if (entries.some(e => e.endsWith(".xcodeproj"))) return "swift-xcode"
18
- if (entries.some(e => e.endsWith(".xcworkspace"))) return "swift-xcode"
19
-
20
- // JS frameworks
21
- const pkgPath = path.join(cwd, "package.json")
22
- if (!fs.existsSync(pkgPath)) return "unknown"
23
-
24
- try {
25
- const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf-8"))
26
- const deps = { ...pkg.dependencies, ...pkg.devDependencies }
27
-
28
- if (deps.next) {
29
- if (fs.existsSync(path.join(cwd, "app"))) return "next-app"
30
- return "next-pages"
31
- }
32
- if (deps["@remix-run/react"]) return "remix"
33
- if (deps.vite) return "vite"
34
- } catch (_e) {
35
- return "unknown"
36
- }
37
- return "unknown"
38
- }
39
-
40
- /**
41
- * Check if the detected framework is a Swift project.
42
- * @param {string} framework
43
- * @returns {boolean}
44
- */
45
- export function isSwiftProject(framework) {
46
- return framework === "swift-spm" || framework === "swift-xcode"
47
- }
48
-
49
- export function getDefaultPath(framework, swiftTarget) {
50
- switch (framework) {
51
- case "swift-spm":
52
- return swiftTarget ? `Sources/${swiftTarget}` : "Sources"
53
- case "swift-xcode":
54
- // Target-specific path is set in add.js via ensureXcodeLocalPackage().
55
- // This default is a fallback only used when no target name is known.
56
- return swiftTarget
57
- ? `Packages/LPMComponents/Sources/${swiftTarget}`
58
- : "Packages/LPMComponents/Sources/LPMComponents"
59
- case "next-app":
60
- if (fs.existsSync(path.join(process.cwd(), "components"))) {
61
- return "components"
62
- }
63
- return "src/components"
64
- case "next-pages":
65
- case "vite":
66
- case "remix":
67
- return "src/components"
68
- default:
69
- return "components"
70
- }
71
- }
72
-
73
- export function getProjectAliases() {
74
- const cwd = process.cwd()
75
- const tsConfigPath = path.join(cwd, "tsconfig.json")
76
- const jsConfigPath = path.join(cwd, "jsconfig.json")
77
-
78
- let configPath
79
- if (fs.existsSync(tsConfigPath)) configPath = tsConfigPath
80
- else if (fs.existsSync(jsConfigPath)) configPath = jsConfigPath
81
-
82
- if (!configPath) return {}
83
-
84
- try {
85
- // Simple JSON parse (might fail with comments)
86
- const content = fs.readFileSync(configPath, "utf-8")
87
- // Basic comment stripping
88
- const jsonContent = content.replace(
89
- /\/\*[\s\S]*?\*\/|([^\\:]|^)\/\/.*$/gm,
90
- "$1",
91
- )
92
- const config = JSON.parse(jsonContent)
93
- return config.compilerOptions?.paths || {}
94
- } catch (_e) {
95
- return {}
96
- }
97
- }
98
-
99
- export function getUserImportPrefix() {
100
- const aliases = getProjectAliases()
101
- // Look for an alias that points to ./src or ./
102
- for (const [alias, paths] of Object.entries(aliases)) {
103
- if (
104
- Array.isArray(paths) &&
105
- paths.some(p => p.startsWith("./src") || p.startsWith("src"))
106
- ) {
107
- return alias.replace("/*", "")
108
- }
109
- }
110
- return "@" // Default fallback
111
- }
112
-
113
- /**
114
- * Resolve the import alias that maps to a given directory.
115
- *
116
- * Given a target directory like "src/components/design-system" and aliases
117
- * like { "@/*": ["./src/*"] }, returns "@/components/design-system".
118
- *
119
- * @param {string} targetDirRelative - Target directory relative to project root
120
- * @param {Record<string, string[]>} aliases - Parsed tsconfig/jsconfig paths
121
- * @returns {string | null} The resolved alias path, or null if no alias covers this directory
122
- */
123
- export function resolveAliasForDirectory(targetDirRelative, aliases) {
124
- const normalized = targetDirRelative
125
- .replace(/\\/g, "/")
126
- .replace(/^\.\//, "")
127
- .replace(/\/$/, "")
128
-
129
- for (const [aliasPattern, aliasPaths] of Object.entries(aliases)) {
130
- if (!aliasPattern.endsWith("/*")) continue
131
- if (!Array.isArray(aliasPaths)) continue
132
-
133
- const aliasPrefix = aliasPattern.slice(0, -2) // "@/*" → "@"
134
-
135
- for (const aliasPath of aliasPaths) {
136
- const mappedDir = aliasPath
137
- .replace(/^\.\//, "")
138
- .replace(/\/\*$/, "")
139
- .replace(/\/$/, "")
140
-
141
- if (normalized.startsWith(`${mappedDir}/`)) {
142
- const remainder = normalized.slice(mappedDir.length + 1)
143
- return `${aliasPrefix}/${remainder}`
144
- }
145
- if (normalized === mappedDir) {
146
- return aliasPrefix
147
- }
148
- }
149
- }
150
-
151
- return null
152
- }