1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

mark Lens as handling lens:// URIs, log when it happens

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton 2020-12-07 12:15:08 -05:00
parent fc20b22bb5
commit 24b5352614
3 changed files with 77 additions and 73 deletions

2
electron-builder.yml Normal file
View File

@ -0,0 +1,2 @@
fileAssociations:
- lens

View File

@ -23,9 +23,9 @@
"compile:i18n": "yarn run lingui compile", "compile:i18n": "yarn run lingui compile",
"compile:extension-types": "yarn run webpack --config webpack.extensions.ts", "compile:extension-types": "yarn run webpack --config webpack.extensions.ts",
"npm:fix-package-version": "yarn run ts-node build/set_npm_version.ts", "npm:fix-package-version": "yarn run ts-node build/set_npm_version.ts",
"build:linux": "yarn run compile && electron-builder --linux --dir -c.productName=Lens", "build:linux": "yarn run compile && electron-builder --linux --config electron-builder.yml --dir -c.productName=Lens",
"build:mac": "yarn run compile && electron-builder --mac --dir -c.productName=Lens", "build:mac": "yarn run compile && electron-builder --mac --config electron-builder.yml --dir -c.productName=Lens",
"build:win": "yarn run compile && electron-builder --win --dir -c.productName=Lens", "build:win": "yarn run compile && electron-builder --win --config electron-builder.yml --dir -c.productName=Lens",
"test": "jest --env=jsdom src $@", "test": "jest --env=jsdom src $@",
"integration": "jest --coverage integration $@", "integration": "jest --coverage integration $@",
"dist": "yarn run compile && electron-builder --publish onTag", "dist": "yarn run compile && electron-builder --publish onTag",

View File

@ -34,6 +34,7 @@ let clusterManager: ClusterManager;
let windowManager: WindowManager; let windowManager: WindowManager;
app.setName(appName); app.setName(appName);
app.setAsDefaultProtocolClient("lens");
if (!process.env.CICD) { if (!process.env.CICD) {
app.setPath("userData", workingDir); app.setPath("userData", workingDir);
@ -45,13 +46,12 @@ if (app.commandLine.getSwitchValue("proxy-server") !== "") {
process.env.HTTPS_PROXY = app.commandLine.getSwitchValue("proxy-server"); process.env.HTTPS_PROXY = app.commandLine.getSwitchValue("proxy-server");
} }
app.on("ready", async () => { app
.on("ready", async () => {
logger.info(`🚀 Starting Lens from "${workingDir}"`); logger.info(`🚀 Starting Lens from "${workingDir}"`);
await shellSync(); await shellSync();
const updater = new AppUpdater(); (new AppUpdater()).start();
updater.start();
registerFileProtocol("static", __static); registerFileProtocol("static", __static);
@ -109,24 +109,26 @@ app.on("ready", async () => {
setTimeout(() => { setTimeout(() => {
appEventBus.emit({ name: "service", action: "start" }); appEventBus.emit({ name: "service", action: "start" });
}, 1000); }, 1000);
}); })
.on("activate", (event, hasVisibleWindows) => {
app.on("activate", (event, hasVisibleWindows) => {
logger.info("APP:ACTIVATE", { hasVisibleWindows }); logger.info("APP:ACTIVATE", { hasVisibleWindows });
if (!hasVisibleWindows) { if (!hasVisibleWindows) {
windowManager?.initMainWindow(false); windowManager?.initMainWindow(false);
} }
}); })
.on("will-quit", (event) => { // Quit app on Cmd+Q (MacOS)
// Quit app on Cmd+Q (MacOS)
app.on("will-quit", (event) => {
logger.info("APP:QUIT"); logger.info("APP:QUIT");
appEventBus.emit({name: "app", action: "close"}); appEventBus.emit({name: "app", action: "close"});
event.preventDefault(); // prevent app's default shutdown (e.g. required for telemetry, etc.) event.preventDefault(); // prevent app's default shutdown (e.g. required for telemetry, etc.)
clusterManager?.stop(); // close cluster connections clusterManager?.stop(); // close cluster connections
return; // skip exit to make tray work, to quit go to app's global menu or tray's menu return; // skip exit to make tray work, to quit go to app's global menu or tray's menu
})
.on("open-url", (event, url) => {
// protocol handler for macOS
logger.info("open-url", { url });
event.preventDefault();
}); });
// Extensions-api runtime exports // Extensions-api runtime exports