mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
more configuration tweaks
This commit is contained in:
parent
9aa815bc14
commit
ec7b8661d9
16
package.json
16
package.json
@ -3,15 +3,16 @@
|
||||
"productName": "Lens",
|
||||
"description": "Lens - The Kubernetes IDE",
|
||||
"version": "3.5.0-beta.1",
|
||||
"main": "src/main",
|
||||
"main": "dist/main.js",
|
||||
"scripts": {
|
||||
"dev": "DEBUG=true concurrently yarn:dev:*",
|
||||
"dev:main": "webpack-cli --watch --cache --config webpack.main.ts",
|
||||
"dev:render": "webpack-cli --watch --cache --config webpack.renderer.ts",
|
||||
"compile": "concurrently 'yarn download-bins' 'yarn i18n:compile' 'yarn make-dll' && concurrently yarn:compile:*",
|
||||
"dev": "yarn compile:dll && concurrently yarn:dev:* && yarn dev-run",
|
||||
"dev-run": "electron .",
|
||||
"dev:main": "DEBUG=true webpack --watch --config webpack.main.ts",
|
||||
"dev:renderer": "DEBUG=true webpack --watch --config webpack.renderer.ts",
|
||||
"compile": "concurrently 'yarn download-bins' 'yarn i18n:compile' 'yarn compile:dll' && concurrently yarn:compile:*",
|
||||
"compile:main": "webpack -p --progress --config webpack.main.ts",
|
||||
"compile:renderer": "webpack -p --progress --config webpack.renderer.ts",
|
||||
"make-dll": "webpack --config webpack.dll.ts",
|
||||
"compile:dll": "webpack --config webpack.dll.ts",
|
||||
"build:linux": "yarn compile && electron-builder --linux --dir -c.productName=LensDev",
|
||||
"build:mac": "yarn compile && electron-builder --mac --dir -c.productName=LensDev",
|
||||
"build:win": "yarn compile && electron-builder --win --dir -c.productName=LensDev",
|
||||
@ -20,7 +21,7 @@
|
||||
"dist": "yarn compile && electron-builder -p onTag",
|
||||
"dist:win": "yarn compile && electron-builder -p onTag --x64 --ia32",
|
||||
"dist:dir": "yarn dist --dir -c.compression=store -c.mac.identity=null",
|
||||
"postinstall": "patch-package && concurrently 'electron-builder install-app-deps' 'yarn make-dll'",
|
||||
"postinstall": "patch-package && concurrently 'electron-builder install-app-deps' 'yarn compile:dll'",
|
||||
"i18n:extract": "lingui extract",
|
||||
"i18n:compile": "lingui compile",
|
||||
"download-bins": "concurrently yarn:download:*",
|
||||
@ -183,7 +184,6 @@
|
||||
"request-promise-native": "^1.0.8",
|
||||
"semver": "^7.3.2",
|
||||
"shell-env": "^3.0.0",
|
||||
"ssl-root-cas": "^1.3.1",
|
||||
"tar": "^6.0.2",
|
||||
"tcp-port-used": "^1.0.1",
|
||||
"tempy": "^0.5.0",
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
import "mac-ca"
|
||||
import winca from "win-ca/api"
|
||||
import { isWindows } from "./vars";
|
||||
import { isMac, isWindows } from "./vars";
|
||||
|
||||
if (isWindows) {
|
||||
winca.inject("+") // see: https://github.com/ukoloff/win-ca#caveats
|
||||
if (isMac) {
|
||||
// require("mac-ca"); // fixme: crashes
|
||||
}
|
||||
if (isWindows) {
|
||||
require("win-ca").inject("+") // see: https://github.com/ukoloff/win-ca#caveats
|
||||
}
|
||||
|
||||
@ -1,134 +1,22 @@
|
||||
// Main process
|
||||
|
||||
import "../common/system-ca"
|
||||
import "../common/prometheus-providers"
|
||||
import { app, dialog, protocol } from "electron"
|
||||
import { PromiseIpc } from "electron-promise-ipc"
|
||||
import path from "path"
|
||||
import { format as formatUrl } from "url"
|
||||
import logger from "./logger"
|
||||
import initMenu from "./menu"
|
||||
import * as proxy from "./proxy"
|
||||
import { WindowManager } from "./window-manager";
|
||||
import { clusterStore } from "../common/cluster-store"
|
||||
import { tracker } from "./tracker"
|
||||
import { ClusterManager } from "./cluster-manager";
|
||||
import AppUpdater from "./app-updater"
|
||||
import { shellSync } from "./shell-sync"
|
||||
import { getFreePort } from "./port"
|
||||
import { mangleProxyEnv } from "./proxy-env"
|
||||
import { findMainWebContents } from "./webcontents"
|
||||
import { registerStaticProtocol } from "../common/register-static";
|
||||
import { isDevelopment, isMac } from "../common/vars";
|
||||
import { app, BrowserWindow } from "electron"
|
||||
|
||||
mangleProxyEnv()
|
||||
if (app.commandLine.getSwitchValue("proxy-server") !== "") {
|
||||
process.env.HTTPS_PROXY = app.commandLine.getSwitchValue("proxy-server")
|
||||
}
|
||||
const promiseIpc = new PromiseIpc({ timeout: 2000 })
|
||||
console.log('MAIN', process.resourcesPath)
|
||||
|
||||
let windowManager: WindowManager = null;
|
||||
let clusterManager: ClusterManager = null;
|
||||
const vmURL = isDevelopment ? `http://localhost:${process.env.ELECTRON_WEBPACK_WDS_PORT}` : formatUrl({
|
||||
pathname: path.join(__dirname, "index.html"),
|
||||
protocol: "file",
|
||||
slashes: true,
|
||||
})
|
||||
app.whenReady().then(function start() {
|
||||
console.log('APP READY')
|
||||
|
||||
async function main() {
|
||||
await shellSync()
|
||||
var window = new BrowserWindow({
|
||||
width: 600,
|
||||
height: 500,
|
||||
webPreferences: {
|
||||
devTools: true,
|
||||
nodeIntegration: true,
|
||||
}
|
||||
});
|
||||
|
||||
const updater = new AppUpdater()
|
||||
updater.start();
|
||||
|
||||
tracker.event("app", "start");
|
||||
|
||||
registerStaticProtocol();
|
||||
protocol.registerFileProtocol('store', (request, callback) => {
|
||||
const url = request.url.substr(8)
|
||||
callback(path.normalize(`${app.getPath("userData")}/${url}`))
|
||||
}, (error) => {
|
||||
if (error) console.error('Failed to register protocol')
|
||||
})
|
||||
|
||||
let port: number = null
|
||||
// find free port
|
||||
try {
|
||||
port = await getFreePort()
|
||||
} catch (error) {
|
||||
logger.error(error)
|
||||
await dialog.showErrorBox("Lens Error", "Could not find a free port for the cluster proxy")
|
||||
app.quit();
|
||||
}
|
||||
|
||||
// create cluster manager
|
||||
clusterManager = new ClusterManager(clusterStore.getAllClusterObjects(), port)
|
||||
|
||||
// run proxy
|
||||
try {
|
||||
proxy.listen(port, clusterManager)
|
||||
} catch (error) {
|
||||
logger.error(`Could not start proxy (127.0.0:${port}): ${error.message}`)
|
||||
await dialog.showErrorBox("Lens Error", `Could not start proxy (127.0.0:${port}): ${error.message || "unknown error"}`)
|
||||
app.quit();
|
||||
}
|
||||
|
||||
// boot windowmanager
|
||||
windowManager = new WindowManager();
|
||||
windowManager.showMain(vmURL)
|
||||
|
||||
initMenu({
|
||||
logoutHook: async () => {
|
||||
// IPC send needs webContents as we're sending it to renderer
|
||||
promiseIpc.send('logout', findMainWebContents(), {}).then((data: any) => {
|
||||
logger.debug("logout IPC sent");
|
||||
})
|
||||
},
|
||||
showPreferencesHook: async () => {
|
||||
// IPC send needs webContents as we're sending it to renderer
|
||||
promiseIpc.send('navigate', findMainWebContents(), { name: 'preferences-page' }).then((data: any) => {
|
||||
logger.debug("navigate: preferences IPC sent");
|
||||
})
|
||||
},
|
||||
addClusterHook: async () => {
|
||||
promiseIpc.send('navigate', findMainWebContents(), { name: "add-cluster-page" }).then((data: any) => {
|
||||
logger.debug("navigate: add-cluster-page IPC sent");
|
||||
})
|
||||
},
|
||||
showWhatsNewHook: async () => {
|
||||
promiseIpc.send('navigate', findMainWebContents(), { name: "whats-new-page" }).then((data: any) => {
|
||||
logger.debug("navigate: whats-new-page IPC sent");
|
||||
})
|
||||
},
|
||||
clusterSettingsHook: async () => {
|
||||
promiseIpc.send('navigate', findMainWebContents(), { name: "cluster-settings-page" }).then((data: any) => {
|
||||
logger.debug("navigate: cluster-settings-page IPC sent");
|
||||
})
|
||||
},
|
||||
}, promiseIpc)
|
||||
}
|
||||
|
||||
app.on("ready", main)
|
||||
app.on('window-all-closed', function () {
|
||||
// On OS X it is common for applications and their menu bar
|
||||
// to stay active until the user quits explicitly with Cmd + Q
|
||||
if (!isMac) {
|
||||
app.quit();
|
||||
}
|
||||
else {
|
||||
windowManager = null
|
||||
if (clusterManager) clusterManager.stop()
|
||||
}
|
||||
})
|
||||
app.on("activate", () => {
|
||||
if (!windowManager) {
|
||||
logger.debug("activate main window")
|
||||
windowManager = new WindowManager(false)
|
||||
windowManager.showMain(vmURL)
|
||||
}
|
||||
})
|
||||
app.on("will-quit", async (event) => {
|
||||
event.preventDefault(); // To allow mixpanel sending to be executed
|
||||
if (clusterManager) clusterManager.stop()
|
||||
app.exit(0);
|
||||
})
|
||||
window.loadFile("index.html");
|
||||
window.show();
|
||||
});
|
||||
|
||||
134
src/main/index_backup.ts
Normal file
134
src/main/index_backup.ts
Normal file
@ -0,0 +1,134 @@
|
||||
// Main process
|
||||
|
||||
import "../common/system-ca"
|
||||
import "../common/prometheus-providers"
|
||||
import { app, dialog, protocol } from "electron"
|
||||
import { PromiseIpc } from "electron-promise-ipc"
|
||||
import path from "path"
|
||||
import { format as formatUrl } from "url"
|
||||
import logger from "./logger"
|
||||
import initMenu from "./menu"
|
||||
import * as proxy from "./proxy"
|
||||
import { WindowManager } from "./window-manager";
|
||||
import { clusterStore } from "../common/cluster-store"
|
||||
import { tracker } from "./tracker"
|
||||
import { ClusterManager } from "./cluster-manager";
|
||||
import AppUpdater from "./app-updater"
|
||||
import { shellSync } from "./shell-sync"
|
||||
import { getFreePort } from "./port"
|
||||
import { mangleProxyEnv } from "./proxy-env"
|
||||
import { findMainWebContents } from "./webcontents"
|
||||
import { registerStaticProtocol } from "../common/register-static";
|
||||
import { isDevelopment, isMac } from "../common/vars";
|
||||
|
||||
mangleProxyEnv()
|
||||
if (app.commandLine.getSwitchValue("proxy-server") !== "") {
|
||||
process.env.HTTPS_PROXY = app.commandLine.getSwitchValue("proxy-server")
|
||||
}
|
||||
const promiseIpc = new PromiseIpc({ timeout: 2000 })
|
||||
|
||||
let windowManager: WindowManager = null;
|
||||
let clusterManager: ClusterManager = null;
|
||||
const vmURL = isDevelopment ? `http://localhost:${process.env.ELECTRON_WEBPACK_WDS_PORT}` : formatUrl({
|
||||
pathname: path.join(__dirname, "index.html"),
|
||||
protocol: "file",
|
||||
slashes: true,
|
||||
})
|
||||
|
||||
async function main() {
|
||||
await shellSync()
|
||||
|
||||
const updater = new AppUpdater()
|
||||
updater.start();
|
||||
|
||||
tracker.event("app", "start");
|
||||
|
||||
registerStaticProtocol();
|
||||
protocol.registerFileProtocol('store', (request, callback) => {
|
||||
const url = request.url.substr(8)
|
||||
callback(path.normalize(`${app.getPath("userData")}/${url}`))
|
||||
}, (error) => {
|
||||
if (error) console.error('Failed to register protocol')
|
||||
})
|
||||
|
||||
let port: number = null
|
||||
// find free port
|
||||
try {
|
||||
port = await getFreePort()
|
||||
} catch (error) {
|
||||
logger.error(error)
|
||||
await dialog.showErrorBox("Lens Error", "Could not find a free port for the cluster proxy")
|
||||
app.quit();
|
||||
}
|
||||
|
||||
// create cluster manager
|
||||
clusterManager = new ClusterManager(clusterStore.getAllClusterObjects(), port)
|
||||
|
||||
// run proxy
|
||||
try {
|
||||
proxy.listen(port, clusterManager)
|
||||
} catch (error) {
|
||||
logger.error(`Could not start proxy (127.0.0:${port}): ${error.message}`)
|
||||
await dialog.showErrorBox("Lens Error", `Could not start proxy (127.0.0:${port}): ${error.message || "unknown error"}`)
|
||||
app.quit();
|
||||
}
|
||||
|
||||
// boot windowmanager
|
||||
windowManager = new WindowManager();
|
||||
windowManager.showMain(vmURL)
|
||||
|
||||
initMenu({
|
||||
logoutHook: async () => {
|
||||
// IPC send needs webContents as we're sending it to renderer
|
||||
promiseIpc.send('logout', findMainWebContents(), {}).then((data: any) => {
|
||||
logger.debug("logout IPC sent");
|
||||
})
|
||||
},
|
||||
showPreferencesHook: async () => {
|
||||
// IPC send needs webContents as we're sending it to renderer
|
||||
promiseIpc.send('navigate', findMainWebContents(), { name: 'preferences-page' }).then((data: any) => {
|
||||
logger.debug("navigate: preferences IPC sent");
|
||||
})
|
||||
},
|
||||
addClusterHook: async () => {
|
||||
promiseIpc.send('navigate', findMainWebContents(), { name: "add-cluster-page" }).then((data: any) => {
|
||||
logger.debug("navigate: add-cluster-page IPC sent");
|
||||
})
|
||||
},
|
||||
showWhatsNewHook: async () => {
|
||||
promiseIpc.send('navigate', findMainWebContents(), { name: "whats-new-page" }).then((data: any) => {
|
||||
logger.debug("navigate: whats-new-page IPC sent");
|
||||
})
|
||||
},
|
||||
clusterSettingsHook: async () => {
|
||||
promiseIpc.send('navigate', findMainWebContents(), { name: "cluster-settings-page" }).then((data: any) => {
|
||||
logger.debug("navigate: cluster-settings-page IPC sent");
|
||||
})
|
||||
},
|
||||
}, promiseIpc)
|
||||
}
|
||||
|
||||
app.on("ready", main)
|
||||
app.on('window-all-closed', function () {
|
||||
// On OS X it is common for applications and their menu bar
|
||||
// to stay active until the user quits explicitly with Cmd + Q
|
||||
if (!isMac) {
|
||||
app.quit();
|
||||
}
|
||||
else {
|
||||
windowManager = null
|
||||
if (clusterManager) clusterManager.stop()
|
||||
}
|
||||
})
|
||||
app.on("activate", () => {
|
||||
if (!windowManager) {
|
||||
logger.debug("activate main window")
|
||||
windowManager = new WindowManager(false)
|
||||
windowManager.showMain(vmURL)
|
||||
}
|
||||
})
|
||||
app.on("will-quit", async (event) => {
|
||||
event.preventDefault(); // To allow mixpanel sending to be executed
|
||||
if (clusterManager) clusterManager.stop()
|
||||
app.exit(0);
|
||||
})
|
||||
20
src/renderer/index.html
Executable file
20
src/renderer/index.html
Executable file
@ -0,0 +1,20 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Lens - The Kubernetes IDE</title>
|
||||
<meta http-equiv="Content-Security-Policy" content="script-src 'self' 'unsafe-inline';" />
|
||||
</head>
|
||||
<body>
|
||||
|
||||
We are using node <script>document.write(process.versions.node)</script>,
|
||||
Chrome <script>document.write(process.versions.chrome)</script>,
|
||||
and Electron <script>document.write(process.versions.electron)</script>.
|
||||
|
||||
<div id="app"></div>
|
||||
<div id="app_vue"></div>
|
||||
|
||||
<script src="dll.js"></script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@ -1,14 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Lens - The Kubernetes IDE</title>
|
||||
<meta http-equiv="Content-Security-Policy" content="default-src 'self'">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="app"></div>
|
||||
<div id="app_vue"></div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@ -7,7 +7,7 @@
|
||||
"module": "CommonJS",
|
||||
"lib": ["ESNext", "DOM", "DOM.Iterable"],
|
||||
"moduleResolution": "Node",
|
||||
"sourceMap": false,
|
||||
"sourceMap": true,
|
||||
"strict": false,
|
||||
"noImplicitAny": true,
|
||||
"noUnusedLocals": false,
|
||||
|
||||
4
types/mocks.d.ts
vendored
4
types/mocks.d.ts
vendored
@ -1,5 +1,3 @@
|
||||
declare module "electron-promise-ipc"
|
||||
declare module "fix-path"
|
||||
declare module "mac-ca"
|
||||
declare module "win-ca/*"
|
||||
declare module "ssl-root-cas"
|
||||
declare module "win-ca"
|
||||
|
||||
@ -2,8 +2,8 @@ import path from "path";
|
||||
import webpack from "webpack";
|
||||
import { isDevelopment, outDir } from "./src/common/vars";
|
||||
|
||||
export const libName = "dll"
|
||||
export const manifestPath = path.resolve(outDir, `${libName}.manifest.json`);
|
||||
export const fileName = "dll"
|
||||
export const manifestPath = path.resolve(outDir, `${fileName}.manifest.json`);
|
||||
|
||||
export const externalPackages = [
|
||||
"react", "react-dom",
|
||||
@ -16,15 +16,15 @@ export default function (): webpack.Configuration {
|
||||
mode: isDevelopment ? "development" : "production",
|
||||
cache: isDevelopment,
|
||||
entry: {
|
||||
[libName]: externalPackages
|
||||
[fileName]: externalPackages
|
||||
},
|
||||
output: {
|
||||
library: libName,
|
||||
libraryTarget: "commonjs"
|
||||
library: fileName,
|
||||
libraryTarget: "commonjs2"
|
||||
},
|
||||
plugins: [
|
||||
new webpack.DllPlugin({
|
||||
name: libName,
|
||||
name: fileName,
|
||||
path: manifestPath,
|
||||
})
|
||||
],
|
||||
|
||||
@ -1,11 +1,12 @@
|
||||
import path from "path";
|
||||
import webpack from "webpack";
|
||||
import { isProduction, mainDir, outDir } from "./src/common/vars";
|
||||
import { isDevelopment, isProduction, mainDir, outDir } from "./src/common/vars";
|
||||
|
||||
export default function (): webpack.Configuration {
|
||||
return {
|
||||
target: "electron-main",
|
||||
mode: isProduction ? "production" : "development",
|
||||
cache: isDevelopment,
|
||||
entry: {
|
||||
main: path.resolve(mainDir, "index.ts"),
|
||||
},
|
||||
|
||||
@ -4,26 +4,25 @@ import HtmlWebpackPlugin from "html-webpack-plugin";
|
||||
import MiniCssExtractPlugin from "mini-css-extract-plugin";
|
||||
import TerserWebpackPlugin from "terser-webpack-plugin";
|
||||
import { isDevelopment, isProduction, outDir, rendererDir } from "./src/common/vars";
|
||||
import { manifestPath, externalPackages } from "./webpack.dll";
|
||||
import { externalPackages, manifestPath } from "./webpack.dll";
|
||||
|
||||
export default function (): webpack.Configuration {
|
||||
const tsConfigFile = path.resolve("./tsconfig.json");
|
||||
const htmlTemplate = path.resolve(rendererDir, "template.html");
|
||||
const htmlTemplate = path.resolve(rendererDir, "index.html");
|
||||
const sassCommonVars = path.resolve(rendererDir, "components/vars.scss");
|
||||
const tsConfigFile = path.resolve("tsconfig.json");
|
||||
|
||||
return {
|
||||
target: "electron-renderer",
|
||||
mode: isProduction ? "production" : "development",
|
||||
devtool: isProduction ? "source-map" : "cheap-eval-source-map",
|
||||
cache: isDevelopment,
|
||||
devtool: isProduction ? "source-map" : "cheap-module-eval-source-map",
|
||||
externals: externalPackages,
|
||||
cache: isDevelopment,
|
||||
entry: {
|
||||
renderer: path.resolve(rendererDir, "index.tsx"),
|
||||
// renderer_vue: path.resolve(rendererDir, "_vue/index.js"),
|
||||
},
|
||||
output: {
|
||||
path: outDir,
|
||||
publicPath: '/',
|
||||
filename: '[name].js',
|
||||
chunkFilename: 'chunks/[name].js',
|
||||
},
|
||||
|
||||
12
yarn.lock
12
yarn.lock
@ -942,11 +942,6 @@
|
||||
exec-sh "^0.3.2"
|
||||
minimist "^1.2.0"
|
||||
|
||||
"@coolaj86/urequest@^1.3.6":
|
||||
version "1.3.7"
|
||||
resolved "https://registry.yarnpkg.com/@coolaj86/urequest/-/urequest-1.3.7.tgz#66a1d66378dd6534e9c8e68948bf09acf32bab77"
|
||||
integrity sha512-PPrVYra9aWvZjSCKl/x1pJ9ZpXda1652oJrPBYy5rQumJJMkmTBN3ux+sK2xAUwVvv2wnewDlaQaHLxLwSHnIA==
|
||||
|
||||
"@develar/schema-utils@~2.6.5":
|
||||
version "2.6.5"
|
||||
resolved "https://registry.yarnpkg.com/@develar/schema-utils/-/schema-utils-2.6.5.tgz#3ece22c5838402419a6e0425f85742b961d9b6c6"
|
||||
@ -10102,13 +10097,6 @@ sshpk@^1.7.0:
|
||||
safer-buffer "^2.0.2"
|
||||
tweetnacl "~0.14.0"
|
||||
|
||||
ssl-root-cas@^1.3.1:
|
||||
version "1.3.1"
|
||||
resolved "https://registry.yarnpkg.com/ssl-root-cas/-/ssl-root-cas-1.3.1.tgz#6b0566f7de4f0e6be99fbd93dbfbe5c7ab33b949"
|
||||
integrity sha512-KR8J210Wfvjh+iNE9jcQEgbG0VG2713PHreItx6aNCPnkFO8XChz1cJ4iuCGeBj0+8wukLmgHgJqX+O5kRjPkQ==
|
||||
dependencies:
|
||||
"@coolaj86/urequest" "^1.3.6"
|
||||
|
||||
ssri@^6.0.1:
|
||||
version "6.0.1"
|
||||
resolved "https://registry.yarnpkg.com/ssri/-/ssri-6.0.1.tgz#2a3c41b28dd45b62b63676ecb74001265ae9edd8"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user