@lpm-registry/cli 0.58.0 → 0.59.1

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 +25 -44
  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 +42 -82
  6. package/scripts/install-binary.js +219 -550
  7. package/CHANGELOG.md +0 -197
  8. package/LICENSE +0 -15
  9. package/index.d.ts +0 -131
  10. package/index.js +0 -31
  11. package/lib/api.js +0 -398
  12. package/lib/commands/add.js +0 -1217
  13. package/lib/commands/audit.js +0 -283
  14. package/lib/commands/cache.js +0 -209
  15. package/lib/commands/check-name.js +0 -112
  16. package/lib/commands/config.js +0 -186
  17. package/lib/commands/doctor.js +0 -140
  18. package/lib/commands/info.js +0 -215
  19. package/lib/commands/init.js +0 -146
  20. package/lib/commands/install.js +0 -264
  21. package/lib/commands/login.js +0 -595
  22. package/lib/commands/logout.js +0 -94
  23. package/lib/commands/marketplace-compare.js +0 -164
  24. package/lib/commands/marketplace-earnings.js +0 -89
  25. package/lib/commands/mcp-setup.js +0 -363
  26. package/lib/commands/npmrc.js +0 -178
  27. package/lib/commands/open.js +0 -82
  28. package/lib/commands/outdated.js +0 -291
  29. package/lib/commands/pool-stats.js +0 -100
  30. package/lib/commands/publish.js +0 -949
  31. package/lib/commands/quality.js +0 -211
  32. package/lib/commands/remove.js +0 -82
  33. package/lib/commands/run.js +0 -14
  34. package/lib/commands/search.js +0 -143
  35. package/lib/commands/setup.js +0 -221
  36. package/lib/commands/skills.js +0 -898
  37. package/lib/commands/token-rotate.js +0 -25
  38. package/lib/commands/uninstall.js +0 -107
  39. package/lib/commands/whoami.js +0 -129
  40. package/lib/config.js +0 -328
  41. package/lib/constants.js +0 -190
  42. package/lib/ecosystem.js +0 -501
  43. package/lib/editor-skills.js +0 -321
  44. package/lib/editors.js +0 -215
  45. package/lib/import-rewriter.js +0 -364
  46. package/lib/install-targets/mcp-server.js +0 -245
  47. package/lib/install-targets/vscode-extension.js +0 -178
  48. package/lib/install-targets.js +0 -82
  49. package/lib/integrity.js +0 -179
  50. package/lib/lpm-config-prompts.js +0 -102
  51. package/lib/lpm-config.js +0 -408
  52. package/lib/oidc.js +0 -166
  53. package/lib/project-utils.js +0 -152
  54. package/lib/quality/checks.js +0 -687
  55. package/lib/quality/display.js +0 -155
  56. package/lib/quality/score.js +0 -118
  57. package/lib/quality/swift-checks.js +0 -447
  58. package/lib/safe-path.js +0 -180
  59. package/lib/secure-store.js +0 -321
  60. package/lib/swift-project.js +0 -637
  61. package/lib/ui.js +0 -40
  62. package/scripts/__tests__/install-binary.test.js +0 -346
@@ -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
- }