* Match a Pi packages array entry against our plugin source. * * Pi `packages` entries are sources like: * - "npm:@cortexkit/pi-magic-context" * - "npm:@cortexkit/pi-magic-context@1.0.0" * - { name: "@cortexkit/pi-magic-context", source: "npm:..." } * - "file:/path/to/local/dev" * *
(entry: unknown)
| 203 | * entries by design (so dev installs don't get silently overridden). |
| 204 | */ |
| 205 | function matchesPiPackage(entry: unknown): boolean { |
| 206 | if (typeof entry === "string") { |
| 207 | if (entry.startsWith("file:")) return false; |
| 208 | return entry.includes(PLUGIN_NAME); |
| 209 | } |
| 210 | if (entry !== null && typeof entry === "object") { |
| 211 | const obj = entry as { name?: unknown; source?: unknown }; |
| 212 | if (typeof obj.name === "string" && obj.name === PLUGIN_NAME) return true; |
| 213 | if (typeof obj.source === "string") return matchesPiPackage(obj.source); |
| 214 | } |
| 215 | return false; |
| 216 | } |
| 217 | |
| 218 | function ensureDir(filePath: string): void { |
| 219 | const dir = dirname(filePath); |
no outgoing calls
no test coverage detected