@kepler-app/homebrew-plugin 0.0.0-stage → 1.0.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.
- package/LICENSE +21 -0
- package/README.md +18 -2
- package/dist/index.js +445 -0
- package/dist/manifest.json +117 -0
- package/package.json +41 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Orbiq
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,19 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Kepler Homebrew Plugin
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A [Kepler](https://kplr.space) plugin that surfaces outstanding Homebrew updates as a Look Ahead card and provides a `/brew` search mode to browse and upgrade outdated formulae and casks in your terminal.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Look Ahead card**: Checks `brew outdated --json=v2` (with `HOMEBREW_NO_AUTO_UPDATE=1`) and caches results locally. Hides automatically when up to date, dismisses until the outdated set changes, and jumps into `/brew` (or opens Terminal directly) on click/Return.
|
|
8
|
+
- **`/brew` search mode**: Filter outdated formulae and casks with `installed → current` versions, and run `brew upgrade` (all or single package) in Terminal, iTerm, or copy the command.
|
|
9
|
+
- **Settings**: Choose upgrade action (`Open in Terminal`, `Open in iTerm`, `Copy Command`), Look Ahead card click behavior, cask / `--greedy` inclusion, refresh interval, and custom `brew` executable path.
|
|
10
|
+
|
|
11
|
+
## Development
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
pnpm install
|
|
15
|
+
pnpm run typecheck
|
|
16
|
+
pnpm run install:local
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Requires Kepler with `ctx.process.exec`, `Action.searchMode`, and interactive Look Ahead plugin support (`@kepler-app/plugin-sdk` >= 1.3.0).
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,445 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var KeplerPlugin = (() => {
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
|
|
21
|
+
// src/index.ts
|
|
22
|
+
var src_exports = {};
|
|
23
|
+
__export(src_exports, {
|
|
24
|
+
default: () => src_default
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
// node_modules/.pnpm/@kepler-app+plugin-sdk@1.3.0/node_modules/@kepler-app/plugin-sdk/dist/index.js
|
|
28
|
+
function definePlugin(plugin) {
|
|
29
|
+
return plugin;
|
|
30
|
+
}
|
|
31
|
+
var Icon = {
|
|
32
|
+
sfSymbol(name) {
|
|
33
|
+
return name;
|
|
34
|
+
},
|
|
35
|
+
emoji(char) {
|
|
36
|
+
return char;
|
|
37
|
+
},
|
|
38
|
+
url(httpsUrl) {
|
|
39
|
+
return httpsUrl;
|
|
40
|
+
},
|
|
41
|
+
withBadge(base, badge) {
|
|
42
|
+
return { type: "badge", base, badge };
|
|
43
|
+
},
|
|
44
|
+
rounded(base) {
|
|
45
|
+
return { type: "rounded", base };
|
|
46
|
+
},
|
|
47
|
+
/**
|
|
48
|
+
* Reference an image file inside the plugin bundle.
|
|
49
|
+
* The path is relative to the .keplugin directory and may contain subdirectories.
|
|
50
|
+
* Supported formats: PNG, JPEG, TIFF, GIF, HEIC.
|
|
51
|
+
* Absolute paths and path traversal (`../`) are rejected by the host.
|
|
52
|
+
*/
|
|
53
|
+
asset(path) {
|
|
54
|
+
return { type: "asset", path };
|
|
55
|
+
},
|
|
56
|
+
/**
|
|
57
|
+
* Reference a macOS application icon by its absolute file path.
|
|
58
|
+
* @example Icon.appIcon("/Applications/Safari.app")
|
|
59
|
+
*/
|
|
60
|
+
appIcon(path) {
|
|
61
|
+
return { type: "appIcon", path };
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
var Action = {
|
|
65
|
+
open(path, options = {}) {
|
|
66
|
+
return { type: "open", path, ...options };
|
|
67
|
+
},
|
|
68
|
+
copy(value, options = {}) {
|
|
69
|
+
return { type: "copy", value, ...options };
|
|
70
|
+
},
|
|
71
|
+
url(url, options = {}) {
|
|
72
|
+
return { type: "url", url, ...options };
|
|
73
|
+
},
|
|
74
|
+
appleScript(script, options = {}) {
|
|
75
|
+
return { type: "appleScript", script, ...options };
|
|
76
|
+
},
|
|
77
|
+
copyImage(fileURL, options = {}) {
|
|
78
|
+
return { type: "copyImage", fileURL, ...options };
|
|
79
|
+
},
|
|
80
|
+
searchMode(searchModeID, options = {}) {
|
|
81
|
+
return {
|
|
82
|
+
type: "searchMode",
|
|
83
|
+
...searchModeID != null ? { searchModeID } : {},
|
|
84
|
+
...options.query != null ? { query: options.query } : {}
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
var Accessory = {
|
|
89
|
+
text(value, alwaysVisible) {
|
|
90
|
+
return { type: "text", value, alwaysVisible };
|
|
91
|
+
},
|
|
92
|
+
keyboardShortcut(value, alwaysVisible) {
|
|
93
|
+
return { type: "keyboardShortcut", value, alwaysVisible };
|
|
94
|
+
},
|
|
95
|
+
badge(value, alwaysVisible) {
|
|
96
|
+
return { type: "badge", value, alwaysVisible };
|
|
97
|
+
},
|
|
98
|
+
toggle(value, alwaysVisible) {
|
|
99
|
+
return {
|
|
100
|
+
type: "toggle",
|
|
101
|
+
value,
|
|
102
|
+
...alwaysVisible != null ? { alwaysVisible } : {}
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
var Command = {
|
|
107
|
+
search(config) {
|
|
108
|
+
return config;
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
var LookAhead = {
|
|
112
|
+
items(config) {
|
|
113
|
+
return config;
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
// src/index.ts
|
|
118
|
+
var CACHE_KEY = "outdated-cache";
|
|
119
|
+
var BREW_PATH_KEY = "resolved-brew-path";
|
|
120
|
+
var DEFAULT_BREW_PATHS = ["/opt/homebrew/bin/brew", "/usr/local/bin/brew"];
|
|
121
|
+
function shortNameOf(name) {
|
|
122
|
+
const idx = name.lastIndexOf("/");
|
|
123
|
+
return idx === -1 ? name : name.slice(idx + 1);
|
|
124
|
+
}
|
|
125
|
+
function readOptions(ctx) {
|
|
126
|
+
const brewPath = String(ctx.settings.brewPath ?? "").trim();
|
|
127
|
+
const includeCasks = ctx.settings.includeCasks !== false;
|
|
128
|
+
const greedyCasks = ctx.settings.greedyCasks === true;
|
|
129
|
+
const rawMinutes = Number(ctx.settings.cacheMinutes ?? 30);
|
|
130
|
+
const cacheMinutes = Number.isFinite(rawMinutes) && rawMinutes >= 1 ? rawMinutes : 30;
|
|
131
|
+
const terminalApp = String(ctx.settings.terminalApp ?? "terminal");
|
|
132
|
+
const cardAction = String(ctx.settings.cardAction ?? "searchMode");
|
|
133
|
+
return {
|
|
134
|
+
brewPath,
|
|
135
|
+
includeCasks,
|
|
136
|
+
greedyCasks,
|
|
137
|
+
terminalApp,
|
|
138
|
+
cardAction,
|
|
139
|
+
cacheMs: cacheMinutes * 6e4,
|
|
140
|
+
configKey: `${brewPath}|${includeCasks ? 1 : 0}|${greedyCasks ? 1 : 0}`
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
function escapeAppleScriptString(value) {
|
|
144
|
+
return value.replace(/\\/g, "\\\\").replace(/"/g, '\\"');
|
|
145
|
+
}
|
|
146
|
+
function buildTerminalAction(command, terminalApp) {
|
|
147
|
+
const escaped = escapeAppleScriptString(command);
|
|
148
|
+
if (terminalApp === "copy") {
|
|
149
|
+
return Action.copy(command);
|
|
150
|
+
}
|
|
151
|
+
if (terminalApp === "iterm") {
|
|
152
|
+
return Action.appleScript(
|
|
153
|
+
`tell application "iTerm"
|
|
154
|
+
activate
|
|
155
|
+
create window with default profile command "${escaped}"
|
|
156
|
+
end tell`
|
|
157
|
+
);
|
|
158
|
+
}
|
|
159
|
+
return Action.appleScript(
|
|
160
|
+
`tell application "Terminal"
|
|
161
|
+
activate
|
|
162
|
+
do script "${escaped}"
|
|
163
|
+
end tell`
|
|
164
|
+
);
|
|
165
|
+
}
|
|
166
|
+
function buildArgs(includeCasks, greedyCasks) {
|
|
167
|
+
const args = ["outdated", "--json=v2"];
|
|
168
|
+
if (!includeCasks) {
|
|
169
|
+
args.push("--formula");
|
|
170
|
+
} else if (greedyCasks) {
|
|
171
|
+
args.push("--greedy");
|
|
172
|
+
}
|
|
173
|
+
return args;
|
|
174
|
+
}
|
|
175
|
+
function parseOutdated(stdout, includeCasks) {
|
|
176
|
+
const jsonStart = stdout.indexOf("{");
|
|
177
|
+
if (jsonStart === -1) return [];
|
|
178
|
+
const parsed = JSON.parse(stdout.slice(jsonStart));
|
|
179
|
+
const result = [];
|
|
180
|
+
for (const f of parsed.formulae ?? []) {
|
|
181
|
+
if (!f.name || f.pinned) continue;
|
|
182
|
+
const installed = Array.isArray(f.installed_versions) && f.installed_versions.length > 0 ? f.installed_versions.join(", ") : "?";
|
|
183
|
+
result.push({
|
|
184
|
+
name: f.name,
|
|
185
|
+
shortName: shortNameOf(f.name),
|
|
186
|
+
installed,
|
|
187
|
+
current: f.current_version ?? "?",
|
|
188
|
+
kind: "formula"
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
if (includeCasks) {
|
|
192
|
+
for (const c of parsed.casks ?? []) {
|
|
193
|
+
if (!c.name) continue;
|
|
194
|
+
const installed = Array.isArray(c.installed_versions) && c.installed_versions.length > 0 ? c.installed_versions.join(", ") : "?";
|
|
195
|
+
result.push({
|
|
196
|
+
name: c.name,
|
|
197
|
+
shortName: shortNameOf(c.name),
|
|
198
|
+
installed,
|
|
199
|
+
current: c.current_version ?? "?",
|
|
200
|
+
kind: "cask"
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
result.sort((a, b) => a.shortName.localeCompare(b.shortName));
|
|
205
|
+
return result;
|
|
206
|
+
}
|
|
207
|
+
async function execBrew(ctx, configuredPath, args) {
|
|
208
|
+
const candidates = [];
|
|
209
|
+
if (configuredPath) {
|
|
210
|
+
candidates.push(configuredPath);
|
|
211
|
+
} else {
|
|
212
|
+
const remembered = ctx.storage.get(BREW_PATH_KEY);
|
|
213
|
+
if (remembered) candidates.push(remembered);
|
|
214
|
+
for (const p of DEFAULT_BREW_PATHS) {
|
|
215
|
+
if (!candidates.includes(p)) candidates.push(p);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
for (const executable of candidates) {
|
|
219
|
+
try {
|
|
220
|
+
const res = await ctx.process.exec({
|
|
221
|
+
executable,
|
|
222
|
+
arguments: args,
|
|
223
|
+
environment: {
|
|
224
|
+
HOMEBREW_NO_AUTO_UPDATE: "1",
|
|
225
|
+
HOMEBREW_NO_ENV_HINTS: "1"
|
|
226
|
+
},
|
|
227
|
+
timeoutMs: 7500
|
|
228
|
+
});
|
|
229
|
+
if (res.exitCode === 0) {
|
|
230
|
+
if (!configuredPath) {
|
|
231
|
+
ctx.storage.set(BREW_PATH_KEY, executable);
|
|
232
|
+
}
|
|
233
|
+
return res.stdout;
|
|
234
|
+
}
|
|
235
|
+
} catch {
|
|
236
|
+
continue;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
return null;
|
|
240
|
+
}
|
|
241
|
+
async function getOutdatedPackages(ctx, forceRefresh = false) {
|
|
242
|
+
const opts = readOptions(ctx);
|
|
243
|
+
const nowMs = Date.parse(ctx.now) || Date.now();
|
|
244
|
+
const cached = ctx.storage.get(CACHE_KEY);
|
|
245
|
+
if (!forceRefresh && cached && cached.configKey === opts.configKey && nowMs - cached.fetchedAt < opts.cacheMs) {
|
|
246
|
+
return { packages: cached.packages, fetchedAt: cached.fetchedAt };
|
|
247
|
+
}
|
|
248
|
+
const stdout = await execBrew(
|
|
249
|
+
ctx,
|
|
250
|
+
opts.brewPath,
|
|
251
|
+
buildArgs(opts.includeCasks, opts.greedyCasks)
|
|
252
|
+
);
|
|
253
|
+
if (stdout == null) {
|
|
254
|
+
return cached && cached.configKey === opts.configKey ? { packages: cached.packages, fetchedAt: cached.fetchedAt } : null;
|
|
255
|
+
}
|
|
256
|
+
try {
|
|
257
|
+
const packages = parseOutdated(stdout, opts.includeCasks);
|
|
258
|
+
const entry = {
|
|
259
|
+
fetchedAt: nowMs,
|
|
260
|
+
configKey: opts.configKey,
|
|
261
|
+
packages
|
|
262
|
+
};
|
|
263
|
+
ctx.storage.set(CACHE_KEY, entry);
|
|
264
|
+
return { packages, fetchedAt: nowMs };
|
|
265
|
+
} catch {
|
|
266
|
+
return cached ? { packages: cached.packages, fetchedAt: cached.fetchedAt } : null;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
function fingerprint(packages) {
|
|
270
|
+
const input = packages.map((p) => `${p.kind}:${p.name}@${p.current}`).join("|");
|
|
271
|
+
let hash = 2166136261;
|
|
272
|
+
for (let i = 0; i < input.length; i++) {
|
|
273
|
+
hash ^= input.charCodeAt(i);
|
|
274
|
+
hash = Math.imul(hash, 16777619);
|
|
275
|
+
}
|
|
276
|
+
return (hash >>> 0).toString(36);
|
|
277
|
+
}
|
|
278
|
+
function previewSubtitle(packages) {
|
|
279
|
+
const names = packages.slice(0, 3).map((p) => p.shortName);
|
|
280
|
+
const remaining = packages.length - names.length;
|
|
281
|
+
return remaining > 0 ? `${names.join(", ")} +${remaining} more` : names.join(", ");
|
|
282
|
+
}
|
|
283
|
+
var src_default = definePlugin({
|
|
284
|
+
metadata: {
|
|
285
|
+
id: "com.kepler.homebrew",
|
|
286
|
+
name: "Homebrew",
|
|
287
|
+
version: "1.0.0",
|
|
288
|
+
author: "Leonhard Breuer",
|
|
289
|
+
description: "Show outstanding Homebrew updates in Look Ahead and browse outdated packages.",
|
|
290
|
+
icon: Icon.sfSymbol("shippingbox.fill"),
|
|
291
|
+
permissions: ["process", "appleScript"],
|
|
292
|
+
settings: [
|
|
293
|
+
{
|
|
294
|
+
id: "terminalApp",
|
|
295
|
+
title: "Upgrade Action",
|
|
296
|
+
description: "How upgrade commands are run when selected.",
|
|
297
|
+
kind: "picker",
|
|
298
|
+
defaultValue: "terminal",
|
|
299
|
+
options: [
|
|
300
|
+
{ id: "terminal", title: "Open in Terminal" },
|
|
301
|
+
{ id: "iterm", title: "Open in iTerm" },
|
|
302
|
+
{ id: "copy", title: "Copy Command" }
|
|
303
|
+
]
|
|
304
|
+
},
|
|
305
|
+
{
|
|
306
|
+
id: "cardAction",
|
|
307
|
+
title: "Look Ahead Card Click",
|
|
308
|
+
description: "What happens when you click or press Return on the Look Ahead card.",
|
|
309
|
+
kind: "picker",
|
|
310
|
+
defaultValue: "searchMode",
|
|
311
|
+
options: [
|
|
312
|
+
{ id: "searchMode", title: "Browse Outdated Packages (/brew)" },
|
|
313
|
+
{ id: "upgradeAll", title: "Open Terminal with brew upgrade" }
|
|
314
|
+
]
|
|
315
|
+
},
|
|
316
|
+
{
|
|
317
|
+
id: "includeCasks",
|
|
318
|
+
title: "Include Casks",
|
|
319
|
+
description: "Include outdated Homebrew casks alongside formulae.",
|
|
320
|
+
kind: "toggle",
|
|
321
|
+
defaultValue: true
|
|
322
|
+
},
|
|
323
|
+
{
|
|
324
|
+
id: "greedyCasks",
|
|
325
|
+
title: "Include Auto-Updating Casks (--greedy)",
|
|
326
|
+
description: "Pass --greedy when checking casks.",
|
|
327
|
+
kind: "toggle",
|
|
328
|
+
defaultValue: false
|
|
329
|
+
},
|
|
330
|
+
{
|
|
331
|
+
id: "cacheMinutes",
|
|
332
|
+
title: "Refresh Interval (minutes)",
|
|
333
|
+
description: "How long outdated results are cached before re-running brew.",
|
|
334
|
+
kind: "number",
|
|
335
|
+
defaultValue: 30,
|
|
336
|
+
min: 1,
|
|
337
|
+
max: 1440,
|
|
338
|
+
step: 5
|
|
339
|
+
},
|
|
340
|
+
{
|
|
341
|
+
id: "brewPath",
|
|
342
|
+
title: "Brew Executable Path",
|
|
343
|
+
description: "Leave empty to auto-detect /opt/homebrew/bin/brew or /usr/local/bin/brew.",
|
|
344
|
+
kind: "text",
|
|
345
|
+
defaultValue: ""
|
|
346
|
+
}
|
|
347
|
+
]
|
|
348
|
+
},
|
|
349
|
+
lookAhead: [
|
|
350
|
+
LookAhead.items({
|
|
351
|
+
id: "outdated",
|
|
352
|
+
title: "Homebrew Updates",
|
|
353
|
+
async run(ctx) {
|
|
354
|
+
const result = await getOutdatedPackages(ctx);
|
|
355
|
+
if (!result || result.packages.length === 0) return [];
|
|
356
|
+
const count = result.packages.length;
|
|
357
|
+
const opts = readOptions(ctx);
|
|
358
|
+
const upgradeAllCmd = opts.greedyCasks ? "brew upgrade --greedy" : "brew upgrade";
|
|
359
|
+
const action = opts.cardAction === "upgradeAll" ? buildTerminalAction(upgradeAllCmd, opts.terminalApp) : Action.searchMode("outdated");
|
|
360
|
+
return [
|
|
361
|
+
{
|
|
362
|
+
id: `brew.outdated.${fingerprint(result.packages)}`,
|
|
363
|
+
kind: "plugin",
|
|
364
|
+
title: count === 1 ? "1 Brew update" : `${count} Brew updates`,
|
|
365
|
+
subtitle: previewSubtitle(result.packages),
|
|
366
|
+
icon: "shippingbox.fill",
|
|
367
|
+
iconColor: "orange",
|
|
368
|
+
priority: 40,
|
|
369
|
+
action,
|
|
370
|
+
dismissible: true
|
|
371
|
+
}
|
|
372
|
+
];
|
|
373
|
+
}
|
|
374
|
+
})
|
|
375
|
+
],
|
|
376
|
+
searchModes: [
|
|
377
|
+
Command.search({
|
|
378
|
+
id: "outdated",
|
|
379
|
+
title: "Homebrew Updates",
|
|
380
|
+
subtitle: "Browse outdated Homebrew formulae and casks",
|
|
381
|
+
keywords: ["brew", "homebrew", "outdated", "updates", "upgrade"],
|
|
382
|
+
icon: Icon.sfSymbol("shippingbox.fill"),
|
|
383
|
+
shortcutPrefix: "brew",
|
|
384
|
+
placeholder: "Filter outdated packages (type 'refresh' to recheck)\u2026",
|
|
385
|
+
async run(query, ctx) {
|
|
386
|
+
const forceRefresh = query.normalized === "refresh";
|
|
387
|
+
const result = await getOutdatedPackages(ctx, forceRefresh);
|
|
388
|
+
if (!result) {
|
|
389
|
+
return [
|
|
390
|
+
{
|
|
391
|
+
id: "brew-unavailable",
|
|
392
|
+
title: "Homebrew not found",
|
|
393
|
+
subtitle: "Set the brew executable path in Homebrew plugin settings.",
|
|
394
|
+
icon: Icon.sfSymbol("exclamationmark.triangle.fill")
|
|
395
|
+
}
|
|
396
|
+
];
|
|
397
|
+
}
|
|
398
|
+
const filter = forceRefresh ? "" : query.normalized;
|
|
399
|
+
const packages = filter ? result.packages.filter(
|
|
400
|
+
(p) => p.name.toLowerCase().includes(filter) || p.shortName.toLowerCase().includes(filter) || p.kind.includes(filter)
|
|
401
|
+
) : result.packages;
|
|
402
|
+
if (result.packages.length === 0) {
|
|
403
|
+
return [
|
|
404
|
+
{
|
|
405
|
+
id: "brew-up-to-date",
|
|
406
|
+
title: "Homebrew is up to date",
|
|
407
|
+
subtitle: "All installed packages are on their latest version.",
|
|
408
|
+
icon: Icon.sfSymbol("checkmark.circle.fill")
|
|
409
|
+
}
|
|
410
|
+
];
|
|
411
|
+
}
|
|
412
|
+
const items = [];
|
|
413
|
+
const opts = readOptions(ctx);
|
|
414
|
+
const upgradeAllCmd = opts.greedyCasks ? "brew upgrade --greedy" : "brew upgrade";
|
|
415
|
+
const actionBadge = opts.terminalApp === "copy" ? "Copy" : "Run in Terminal";
|
|
416
|
+
if (!filter || "upgrade all".includes(filter)) {
|
|
417
|
+
items.push({
|
|
418
|
+
id: "brew-upgrade-all",
|
|
419
|
+
title: `Upgrade All (${result.packages.length})`,
|
|
420
|
+
subtitle: upgradeAllCmd,
|
|
421
|
+
icon: Icon.sfSymbol("arrow.down.circle.fill"),
|
|
422
|
+
accessory: Accessory.badge(actionBadge),
|
|
423
|
+
action: buildTerminalAction(upgradeAllCmd, opts.terminalApp)
|
|
424
|
+
});
|
|
425
|
+
}
|
|
426
|
+
for (const pkg of packages) {
|
|
427
|
+
const cmd = pkg.kind === "cask" ? `brew upgrade --cask ${pkg.name}` : `brew upgrade ${pkg.name}`;
|
|
428
|
+
const versionText = `${pkg.installed} \u2192 ${pkg.current}`;
|
|
429
|
+
const subtitle = pkg.shortName !== pkg.name ? `${versionText} \xB7 ${pkg.name}` : versionText;
|
|
430
|
+
items.push({
|
|
431
|
+
id: `brew-${pkg.kind}-${pkg.name}`,
|
|
432
|
+
title: pkg.shortName,
|
|
433
|
+
subtitle,
|
|
434
|
+
icon: Icon.sfSymbol(pkg.kind === "cask" ? "macwindow" : "terminal"),
|
|
435
|
+
accessory: Accessory.badge(pkg.kind === "cask" ? "Cask" : "Formula", true),
|
|
436
|
+
action: buildTerminalAction(cmd, opts.terminalApp)
|
|
437
|
+
});
|
|
438
|
+
}
|
|
439
|
+
return items;
|
|
440
|
+
}
|
|
441
|
+
})
|
|
442
|
+
]
|
|
443
|
+
});
|
|
444
|
+
return __toCommonJS(src_exports);
|
|
445
|
+
})();
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "com.kepler.homebrew",
|
|
3
|
+
"name": "Homebrew",
|
|
4
|
+
"version": "1.0.0",
|
|
5
|
+
"author": "Leonhard Breuer",
|
|
6
|
+
"capabilities": {
|
|
7
|
+
"hasSearchMode": true,
|
|
8
|
+
"isSearchProvider": false,
|
|
9
|
+
"hasWidget": false,
|
|
10
|
+
"lookAhead": true
|
|
11
|
+
},
|
|
12
|
+
"permissions": [
|
|
13
|
+
"process",
|
|
14
|
+
"appleScript"
|
|
15
|
+
],
|
|
16
|
+
"networkUrls": [],
|
|
17
|
+
"description": "Show outstanding Homebrew updates in Look Ahead and browse outdated packages.",
|
|
18
|
+
"icon": "shippingbox.fill",
|
|
19
|
+
"contributions": {
|
|
20
|
+
"searchModes": [
|
|
21
|
+
{
|
|
22
|
+
"id": "outdated",
|
|
23
|
+
"title": "Homebrew Updates",
|
|
24
|
+
"subtitle": "Browse outdated Homebrew formulae and casks",
|
|
25
|
+
"keywords": [
|
|
26
|
+
"brew",
|
|
27
|
+
"homebrew",
|
|
28
|
+
"outdated",
|
|
29
|
+
"updates",
|
|
30
|
+
"upgrade"
|
|
31
|
+
],
|
|
32
|
+
"icon": "shippingbox.fill",
|
|
33
|
+
"shortcutPrefix": "brew",
|
|
34
|
+
"placeholder": "Filter outdated packages (type 'refresh' to recheck)…"
|
|
35
|
+
}
|
|
36
|
+
],
|
|
37
|
+
"searchProviders": [],
|
|
38
|
+
"widgets": [],
|
|
39
|
+
"lookAhead": [
|
|
40
|
+
{
|
|
41
|
+
"id": "outdated",
|
|
42
|
+
"title": "Homebrew Updates"
|
|
43
|
+
}
|
|
44
|
+
]
|
|
45
|
+
},
|
|
46
|
+
"settings": [
|
|
47
|
+
{
|
|
48
|
+
"id": "terminalApp",
|
|
49
|
+
"title": "Upgrade Action",
|
|
50
|
+
"description": "How upgrade commands are run when selected.",
|
|
51
|
+
"kind": "picker",
|
|
52
|
+
"defaultValue": "terminal",
|
|
53
|
+
"options": [
|
|
54
|
+
{
|
|
55
|
+
"id": "terminal",
|
|
56
|
+
"title": "Open in Terminal"
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
"id": "iterm",
|
|
60
|
+
"title": "Open in iTerm"
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
"id": "copy",
|
|
64
|
+
"title": "Copy Command"
|
|
65
|
+
}
|
|
66
|
+
]
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
"id": "cardAction",
|
|
70
|
+
"title": "Look Ahead Card Click",
|
|
71
|
+
"description": "What happens when you click or press Return on the Look Ahead card.",
|
|
72
|
+
"kind": "picker",
|
|
73
|
+
"defaultValue": "searchMode",
|
|
74
|
+
"options": [
|
|
75
|
+
{
|
|
76
|
+
"id": "searchMode",
|
|
77
|
+
"title": "Browse Outdated Packages (/brew)"
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
"id": "upgradeAll",
|
|
81
|
+
"title": "Open Terminal with brew upgrade"
|
|
82
|
+
}
|
|
83
|
+
]
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
"id": "includeCasks",
|
|
87
|
+
"title": "Include Casks",
|
|
88
|
+
"description": "Include outdated Homebrew casks alongside formulae.",
|
|
89
|
+
"kind": "toggle",
|
|
90
|
+
"defaultValue": true
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
"id": "greedyCasks",
|
|
94
|
+
"title": "Include Auto-Updating Casks (--greedy)",
|
|
95
|
+
"description": "Pass --greedy when checking casks.",
|
|
96
|
+
"kind": "toggle",
|
|
97
|
+
"defaultValue": false
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
"id": "cacheMinutes",
|
|
101
|
+
"title": "Refresh Interval (minutes)",
|
|
102
|
+
"description": "How long outdated results are cached before re-running brew.",
|
|
103
|
+
"kind": "number",
|
|
104
|
+
"defaultValue": 30,
|
|
105
|
+
"min": 1,
|
|
106
|
+
"max": 1440,
|
|
107
|
+
"step": 5
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
"id": "brewPath",
|
|
111
|
+
"title": "Brew Executable Path",
|
|
112
|
+
"description": "Leave empty to auto-detect /opt/homebrew/bin/brew or /usr/local/bin/brew.",
|
|
113
|
+
"kind": "text",
|
|
114
|
+
"defaultValue": ""
|
|
115
|
+
}
|
|
116
|
+
]
|
|
117
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,43 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kepler-app/homebrew-plugin",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "See outstanding Homebrew updates in Look Ahead and browse outdated formulae and casks.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"kepler",
|
|
8
|
+
"kepler-plugin",
|
|
9
|
+
"homebrew",
|
|
10
|
+
"brew"
|
|
11
|
+
],
|
|
12
|
+
"files": [
|
|
13
|
+
"dist"
|
|
14
|
+
],
|
|
15
|
+
"kepler": {
|
|
16
|
+
"apiVersion": 1,
|
|
17
|
+
"manifest": "dist/manifest.json",
|
|
18
|
+
"entry": "dist/index.js"
|
|
19
|
+
},
|
|
20
|
+
"license": "MIT",
|
|
21
|
+
"repository": {
|
|
22
|
+
"type": "git",
|
|
23
|
+
"url": "git+https://github.com/orbiq-one/kepler-homebrew.git"
|
|
24
|
+
},
|
|
25
|
+
"homepage": "https://github.com/orbiq-one/kepler-homebrew#readme",
|
|
26
|
+
"publishConfig": {
|
|
27
|
+
"access": "public"
|
|
28
|
+
},
|
|
29
|
+
"scripts": {
|
|
30
|
+
"build": "kepler-plugin bundle src/index.ts --out dist",
|
|
31
|
+
"install:local": "kepler-plugin bundle src/index.ts --out \"$HOME/Library/Application Support/Kepler/Plugins/homebrew.keplugin\"",
|
|
32
|
+
"dev": "tsup --watch",
|
|
33
|
+
"typecheck": "tsc --noEmit",
|
|
34
|
+
"prepublishOnly": "pnpm run typecheck && pnpm run build"
|
|
35
|
+
},
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"@kepler-app/plugin-sdk": "^1.3.0"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"tsup": "^8.5.1",
|
|
41
|
+
"typescript": "~5.9.3"
|
|
42
|
+
}
|
|
43
|
+
}
|