Turns the empty scaffold into a working Nova extension for Apple Container and container-compose, in the shape of the Docker Suite extension. Sidebar (Scripts/Sidebar): - System, Containers, Images, Volumes and Networks sections - Containers grouped into compose projects via the com.docker.compose.project label container-compose stamps; project rows drive compose up/down/build against the matching workspace file - Lifecycle, shell, logs, inspect, browse and copy commands per resource - Apple Container publishes no event stream, so the sidebar polls while visible and only reloads a section when a fingerprint of its data changes, which keeps selection and expansion intact Hostnames (Scripts/Hostnames.js): - A container's hostname is <name>.<domain> and the domain lives in Apple Container's config.toml, which has no CLI setter, so the Hostname Domain preference reads and writes that file directly - Changing it offers to register the domain with macOS and restart the services; the write preserves the file's other tables and its mode Language support: - Dockerfile and Compose syntaxes backed by tree-sitter grammars built by Tools/build-syntaxes.sh, pinned to revisions that generate ABI 14 - The Compose syntax is named dockercompose because that is the languageId docker-language-server recognises compose files by - docker-language-server is downloaded on first use rather than bundled, at roughly 40 MB Icons are generated by Tools/make-icons.py so they can be regenerated rather than hand-maintained. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01UnSBcR5Lywz5Fbj5FmVbfc
54 lines
1.5 KiB
JavaScript
54 lines
1.5 KiB
JavaScript
//
|
|
// Notification helpers. Each notification uses a stable identifier so that
|
|
// repeated failures replace one another rather than stacking up.
|
|
//
|
|
|
|
function notify(identifier, title, body, actions) {
|
|
let request = new NotificationRequest(identifier);
|
|
request.title = title;
|
|
request.body = body;
|
|
|
|
if (actions && actions.length > 0) {
|
|
request.actions = actions.map((action) => action.title);
|
|
}
|
|
|
|
return nova.notifications.add(request).then((reply) => {
|
|
if (!actions || reply.actionIdx === undefined || reply.actionIdx === null) {
|
|
return reply;
|
|
}
|
|
|
|
let action = actions[reply.actionIdx];
|
|
if (action && action.handler) {
|
|
action.handler();
|
|
}
|
|
return reply;
|
|
});
|
|
}
|
|
|
|
// Reports a failed operation, logging the underlying error for the console.
|
|
function failure(title, error, identifier) {
|
|
let message = error instanceof Error ? error.message : String(error || "");
|
|
|
|
if (nova.inDevMode()) {
|
|
console.error(title, message);
|
|
}
|
|
|
|
return notify(identifier || "apple-container-failure", title, message);
|
|
}
|
|
|
|
// Reports a failure with a shortcut to the extension's preferences.
|
|
function configFailure(title, error, identifier) {
|
|
let message = error instanceof Error ? error.message : String(error || "");
|
|
|
|
return notify(identifier || "apple-container-config", title, message, [
|
|
{ title: "Preferences", handler: () => nova.openConfig() },
|
|
{ title: "Dismiss" }
|
|
]);
|
|
}
|
|
|
|
function info(title, body, identifier) {
|
|
return notify(identifier || "apple-container-info", title, body);
|
|
}
|
|
|
|
module.exports = { notify, failure, configFailure, info };
|