()
| 47 | } |
| 48 | |
| 49 | async ensurePluginEntry(): Promise<PluginEntryResult> { |
| 50 | const settingsPath = getPiUserExtensionsPath(); |
| 51 | try { |
| 52 | const settings = readPiSettings() ?? {}; |
| 53 | const packages = Array.isArray(settings.packages) |
| 54 | ? (settings.packages as unknown[]) |
| 55 | : []; |
| 56 | |
| 57 | const idx = packages.findIndex((entry) => matchesPiPackage(entry)); |
| 58 | if (idx === -1) { |
| 59 | packages.push(PI_PACKAGE_SOURCE); |
| 60 | settings.packages = packages; |
| 61 | writePiSettings(settings); |
| 62 | return { |
| 63 | ok: true, |
| 64 | action: "added", |
| 65 | message: `Added ${PI_PACKAGE_SOURCE} to ${settingsPath}.`, |
| 66 | configPath: settingsPath, |
| 67 | }; |
| 68 | } |
| 69 | return { |
| 70 | ok: true, |
| 71 | action: "already_present", |
| 72 | message: `Plugin entry already present in ${settingsPath}.`, |
| 73 | configPath: settingsPath, |
| 74 | }; |
| 75 | } catch (err) { |
| 76 | return { |
| 77 | ok: false, |
| 78 | action: "error", |
| 79 | message: `Failed to update ${settingsPath}: ${(err as Error).message}`, |
| 80 | configPath: settingsPath, |
| 81 | }; |
| 82 | } |
| 83 | } |
| 84 | |
| 85 | async removePluginEntry(): Promise<PluginEntryResult> { |
| 86 | const settingsPath = getPiUserExtensionsPath(); |
nothing calls this directly
no test coverage detected