// // Apple Container for Nova. // // Entry point: wires up the sidebar, the extension's commands and the Docker // language server, and tears them all down again on deactivate. // const { ContainerSidebar } = require("./Sidebar/ContainerSidebar"); const { Hostnames } = require("./Hostnames"); const { DockerLanguageClient } = require("./LanguageClients/DockerLanguageClient"); const { ContainerCLI } = require("./Interfaces/ContainerCLI"); const { Commands } = require("./Commands"); const notify = require("./Utilities/Notify"); let sidebar = null; let languageClient = null; let commands = null; let hostnames = null; exports.activate = async function () { commands = new Commands({ sidebar: () => sidebar, restartLanguageServer: () => (languageClient ? languageClient.restart() : null) }); if (!(await installed())) { notify.configFailure( "Apple Container was not found", "Install it from github.com/apple/container, or set the path to the container tool in the extension's preferences.", "apple-container-missing" ); } else { sidebar = new ContainerSidebar(); hostnames = new Hostnames({ reload: () => (sidebar ? sidebar.reload() : null) }); } languageClient = new DockerLanguageClient(); await languageClient.start(); }; exports.deactivate = function () { if (sidebar) { sidebar.dispose(); sidebar = null; } if (languageClient) { languageClient.dispose(); languageClient = null; } if (hostnames) { hostnames.dispose(); hostnames = null; } if (commands) { commands.dispose(); commands = null; } }; // The CLI is the one hard requirement: without it there is nothing to show. async function installed() { try { await ContainerCLI.version(); return true; } catch (error) { return false; } }