mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
prod-build fix
Signed-off-by: Roman <ixrock@gmail.com>
This commit is contained in:
parent
1ad91af835
commit
d0d88e5ba7
2
.gitignore
vendored
2
.gitignore
vendored
@ -5,7 +5,7 @@ node_modules/
|
|||||||
yarn-error.log
|
yarn-error.log
|
||||||
coverage/
|
coverage/
|
||||||
tmp/
|
tmp/
|
||||||
static/build/client/
|
static/build/**
|
||||||
binaries/client/
|
binaries/client/
|
||||||
binaries/server/
|
binaries/server/
|
||||||
locales/**/**.js
|
locales/**/**.js
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
"productName": "Lens",
|
"productName": "Lens",
|
||||||
"description": "Lens - The Kubernetes IDE",
|
"description": "Lens - The Kubernetes IDE",
|
||||||
"version": "3.6.0-dev",
|
"version": "3.6.0-dev",
|
||||||
"main": "out/main.js",
|
"main": "static/build/main.js",
|
||||||
"copyright": "© 2020, Lakend Labs, Inc.",
|
"copyright": "© 2020, Lakend Labs, Inc.",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"author": {
|
"author": {
|
||||||
@ -12,7 +12,7 @@
|
|||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "concurrently -k \"yarn dev-run -C\" \"yarn dev:main\" \"yarn dev:renderer\"",
|
"dev": "concurrently -k \"yarn dev-run -C\" \"yarn dev:main\" \"yarn dev:renderer\"",
|
||||||
"dev-run": "nodemon --watch out/main.* --exec \"electron --inspect .\" $@",
|
"dev-run": "nodemon --watch static/build/main.js --exec \"electron --inspect .\" $@",
|
||||||
"dev:main": "env DEBUG=true yarn compile:main --watch $@",
|
"dev:main": "env DEBUG=true yarn compile:main --watch $@",
|
||||||
"dev:renderer": "env DEBUG=true yarn compile:renderer --watch $@",
|
"dev:renderer": "env DEBUG=true yarn compile:renderer --watch $@",
|
||||||
"compile": "env NODE_ENV=production concurrently yarn:compile:*",
|
"compile": "env NODE_ENV=production concurrently yarn:compile:*",
|
||||||
@ -87,7 +87,7 @@
|
|||||||
{
|
{
|
||||||
"from": "static/",
|
"from": "static/",
|
||||||
"to": "static/",
|
"to": "static/",
|
||||||
"filter": "**/*"
|
"filter": "!**/main.js"
|
||||||
},
|
},
|
||||||
"LICENSE"
|
"LICENSE"
|
||||||
],
|
],
|
||||||
|
|||||||
@ -10,16 +10,27 @@ export const isDevelopment = isDebugging || !isProduction;
|
|||||||
export const isTestEnv = !!process.env.JEST_WORKER_ID;
|
export const isTestEnv = !!process.env.JEST_WORKER_ID;
|
||||||
|
|
||||||
export const appName = `${packageInfo.productName}${isDevelopment ? "Dev" : ""}`
|
export const appName = `${packageInfo.productName}${isDevelopment ? "Dev" : ""}`
|
||||||
|
export const publicPath = "/build/"
|
||||||
|
|
||||||
// System paths
|
// Webpack build paths
|
||||||
export const contextDir = process.cwd();
|
export const contextDir = process.cwd();
|
||||||
export const staticDir = path.join(contextDir, "static");
|
export const buildDir = path.join(contextDir, "static", publicPath);
|
||||||
export const outDir = path.join(contextDir, "out");
|
|
||||||
export const mainDir = path.join(contextDir, "src/main");
|
export const mainDir = path.join(contextDir, "src/main");
|
||||||
export const rendererDir = path.join(contextDir, "src/renderer");
|
export const rendererDir = path.join(contextDir, "src/renderer");
|
||||||
export const htmlTemplate = path.resolve(rendererDir, "template.html");
|
export const htmlTemplate = path.resolve(rendererDir, "template.html");
|
||||||
export const sassCommonVars = path.resolve(rendererDir, "components/vars.scss");
|
export const sassCommonVars = path.resolve(rendererDir, "components/vars.scss");
|
||||||
|
|
||||||
|
// Special runtime paths
|
||||||
|
const globScope = typeof global !== "undefined" ? global : window;
|
||||||
|
Object.defineProperty(globScope, "__static", {
|
||||||
|
get() {
|
||||||
|
if (isDevelopment) {
|
||||||
|
return path.resolve(contextDir, "static");
|
||||||
|
}
|
||||||
|
return path.resolve(process.resourcesPath, "static")
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
// Apis
|
// Apis
|
||||||
export const apiPrefix = "/api" // local router apis
|
export const apiPrefix = "/api" // local router apis
|
||||||
export const apiKubePrefix = "/api-kube" // k8s cluster apis
|
export const apiKubePrefix = "/api-kube" // k8s cluster apis
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
import "../common/system-ca"
|
import "../common/system-ca"
|
||||||
import "../common/prometheus-providers"
|
import "../common/prometheus-providers"
|
||||||
import { app, dialog } from "electron"
|
import { app, dialog } from "electron"
|
||||||
import { appName, staticDir } from "../common/vars";
|
import { appName } from "../common/vars";
|
||||||
import path from "path"
|
import path from "path"
|
||||||
import { LensProxy } from "./lens-proxy"
|
import { LensProxy } from "./lens-proxy"
|
||||||
import { WindowManager } from "./window-manager";
|
import { WindowManager } from "./window-manager";
|
||||||
@ -19,6 +19,10 @@ import { workspaceStore } from "../common/workspace-store";
|
|||||||
import { tracker } from "../common/tracker";
|
import { tracker } from "../common/tracker";
|
||||||
import logger from "./logger"
|
import logger from "./logger"
|
||||||
|
|
||||||
|
const workingDir = path.join(app.getPath("appData"), appName);
|
||||||
|
app.setName(appName);
|
||||||
|
app.setPath("userData", workingDir);
|
||||||
|
|
||||||
let windowManager: WindowManager;
|
let windowManager: WindowManager;
|
||||||
let clusterManager: ClusterManager;
|
let clusterManager: ClusterManager;
|
||||||
let proxyServer: LensProxy;
|
let proxyServer: LensProxy;
|
||||||
@ -30,17 +34,13 @@ if (app.commandLine.getSwitchValue("proxy-server") !== "") {
|
|||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
await shellSync();
|
await shellSync();
|
||||||
|
|
||||||
const workingDir = path.join(app.getPath("appData"), appName);
|
|
||||||
app.setName(appName);
|
|
||||||
app.setPath("userData", workingDir);
|
|
||||||
logger.info(`🚀 Starting Lens from "${workingDir}"`)
|
logger.info(`🚀 Starting Lens from "${workingDir}"`)
|
||||||
|
|
||||||
tracker.event("app", "start");
|
tracker.event("app", "start");
|
||||||
const updater = new AppUpdater()
|
const updater = new AppUpdater()
|
||||||
updater.start();
|
updater.start();
|
||||||
|
|
||||||
registerFileProtocol("static", staticDir);
|
registerFileProtocol("static", __static);
|
||||||
|
|
||||||
// find free port
|
// find free port
|
||||||
let proxyPort: number
|
let proxyPort: number
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import http from "http"
|
|||||||
import path from "path"
|
import path from "path"
|
||||||
import { readFile } from "fs-extra"
|
import { readFile } from "fs-extra"
|
||||||
import { Cluster } from "./cluster"
|
import { Cluster } from "./cluster"
|
||||||
import { apiPrefix, appName, outDir } from "../common/vars";
|
import { apiPrefix, appName, publicPath } from "../common/vars";
|
||||||
import { helmRoute, kubeconfigRoute, metricsRoute, portForwardRoute, resourceApplierRoute, watchRoute } from "./routes";
|
import { helmRoute, kubeconfigRoute, metricsRoute, portForwardRoute, resourceApplierRoute, watchRoute } from "./routes";
|
||||||
|
|
||||||
export interface RouterRequestOpts {
|
export interface RouterRequestOpts {
|
||||||
@ -95,14 +95,14 @@ export class Router {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async handleStaticFile(filePath: string, res: http.ServerResponse) {
|
async handleStaticFile(filePath: string, res: http.ServerResponse) {
|
||||||
const asset = path.join(outDir, filePath);
|
const asset = path.join(__static, filePath);
|
||||||
try {
|
try {
|
||||||
const data = await readFile(asset);
|
const data = await readFile(asset);
|
||||||
res.setHeader("Content-Type", this.getMimeType(asset));
|
res.setHeader("Content-Type", this.getMimeType(asset));
|
||||||
res.write(data)
|
res.write(data)
|
||||||
res.end()
|
res.end()
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
this.handleStaticFile(`${appName}.html`, res);
|
this.handleStaticFile(`${publicPath}/${appName}.html`, res);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import type { ClusterId } from "../common/cluster-store";
|
import type { ClusterId } from "../common/cluster-store";
|
||||||
import { BrowserWindow, ipcMain, shell, WebContents, webContents } from "electron"
|
import { BrowserWindow, dialog, ipcMain, shell, WebContents, webContents } from "electron"
|
||||||
import windowStateKeeper from "electron-window-state"
|
import windowStateKeeper from "electron-window-state"
|
||||||
import { observable } from "mobx";
|
import { observable } from "mobx";
|
||||||
import { initMenu } from "./menu";
|
import { initMenu } from "./menu";
|
||||||
@ -69,10 +69,14 @@ export class WindowManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async showMain() {
|
async showMain() {
|
||||||
await this.showSplash();
|
try {
|
||||||
await this.mainView.loadURL(`http://localhost:${this.proxyPort}`)
|
await this.showSplash();
|
||||||
this.mainView.show();
|
await this.mainView.loadURL(`http://localhost:${this.proxyPort}`)
|
||||||
this.splashWindow.hide();
|
this.mainView.show();
|
||||||
|
this.splashWindow.hide();
|
||||||
|
} catch (err) {
|
||||||
|
dialog.showErrorBox("ERROR!", err.toString())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async showSplash() {
|
async showSplash() {
|
||||||
|
|||||||
@ -7,12 +7,11 @@ import { userStore } from "../../../common/user-store"
|
|||||||
import { navigate } from "../../navigation";
|
import { navigate } from "../../navigation";
|
||||||
import { Button } from "../button";
|
import { Button } from "../button";
|
||||||
import { Trans } from "@lingui/macro";
|
import { Trans } from "@lingui/macro";
|
||||||
import { staticDir } from "../../../common/vars";
|
|
||||||
import marked from "marked"
|
import marked from "marked"
|
||||||
|
|
||||||
@observer
|
@observer
|
||||||
export class WhatsNew extends React.Component {
|
export class WhatsNew extends React.Component {
|
||||||
releaseNotes = fs.readFileSync(path.join(staticDir, "RELEASE_NOTES.md")).toString();
|
releaseNotes = fs.readFileSync(path.join(__static, "RELEASE_NOTES.md")).toString();
|
||||||
|
|
||||||
ok = () => {
|
ok = () => {
|
||||||
navigate("/");
|
navigate("/");
|
||||||
|
|||||||
3
types/mocks.d.ts
vendored
3
types/mocks.d.ts
vendored
@ -4,6 +4,9 @@ declare module "win-ca"
|
|||||||
declare module "@hapi/call"
|
declare module "@hapi/call"
|
||||||
declare module "@hapi/subtext"
|
declare module "@hapi/subtext"
|
||||||
|
|
||||||
|
// Global path to static assets
|
||||||
|
declare const __static: string;
|
||||||
|
|
||||||
// Support import for custom module extensions
|
// Support import for custom module extensions
|
||||||
// https://www.typescriptlang.org/docs/handbook/modules.html#wildcard-module-declarations
|
// https://www.typescriptlang.org/docs/handbook/modules.html#wildcard-module-declarations
|
||||||
declare module "*.scss" {
|
declare module "*.scss" {
|
||||||
|
|||||||
@ -1,10 +1,10 @@
|
|||||||
import path from "path";
|
import path from "path";
|
||||||
import webpack, { LibraryTarget } from "webpack";
|
import webpack, { LibraryTarget } from "webpack";
|
||||||
import { isDevelopment, outDir } from "./src/common/vars";
|
import { isDevelopment, buildDir } from "./src/common/vars";
|
||||||
|
|
||||||
export const library = "dll"
|
export const library = "dll"
|
||||||
export const libraryTarget: LibraryTarget = "commonjs2"
|
export const libraryTarget: LibraryTarget = "commonjs2"
|
||||||
export const manifestPath = path.resolve(outDir, `${library}.manifest.json`);
|
export const manifestPath = path.resolve(buildDir, `${library}.manifest.json`);
|
||||||
|
|
||||||
export const packages = [
|
export const packages = [
|
||||||
"react", "react-dom",
|
"react", "react-dom",
|
||||||
|
|||||||
@ -1,11 +1,11 @@
|
|||||||
import path from "path";
|
import path from "path";
|
||||||
import webpack from "webpack";
|
import webpack from "webpack";
|
||||||
import ForkTsCheckerPlugin from "fork-ts-checker-webpack-plugin"
|
import ForkTsCheckerPlugin from "fork-ts-checker-webpack-plugin"
|
||||||
import { isDevelopment, isProduction, mainDir, outDir } from "./src/common/vars";
|
import { isDevelopment, isProduction, mainDir, buildDir } from "./src/common/vars";
|
||||||
import nodeExternals from "webpack-node-externals";
|
import nodeExternals from "webpack-node-externals";
|
||||||
|
|
||||||
export default function (): webpack.Configuration {
|
export default function (): webpack.Configuration {
|
||||||
console.info('WEBPACK:main', require("./src/common/vars"), process.env)
|
console.info('WEBPACK:main', require("./src/common/vars"))
|
||||||
return {
|
return {
|
||||||
context: __dirname,
|
context: __dirname,
|
||||||
target: "electron-main",
|
target: "electron-main",
|
||||||
@ -16,7 +16,7 @@ export default function (): webpack.Configuration {
|
|||||||
main: path.resolve(mainDir, "index.ts"),
|
main: path.resolve(mainDir, "index.ts"),
|
||||||
},
|
},
|
||||||
output: {
|
output: {
|
||||||
path: outDir,
|
path: buildDir,
|
||||||
},
|
},
|
||||||
resolve: {
|
resolve: {
|
||||||
extensions: ['.json', '.js', '.ts']
|
extensions: ['.json', '.js', '.ts']
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import { appName, htmlTemplate, isDevelopment, isProduction, outDir, rendererDir, sassCommonVars } from "./src/common/vars";
|
import { appName, htmlTemplate, isDevelopment, isProduction, buildDir, rendererDir, sassCommonVars, publicPath } from "./src/common/vars";
|
||||||
import path from "path";
|
import path from "path";
|
||||||
import webpack from "webpack";
|
import webpack from "webpack";
|
||||||
import HtmlWebpackPlugin from "html-webpack-plugin";
|
import HtmlWebpackPlugin from "html-webpack-plugin";
|
||||||
@ -7,7 +7,7 @@ import TerserPlugin from "terser-webpack-plugin";
|
|||||||
import ForkTsCheckerPlugin from "fork-ts-checker-webpack-plugin"
|
import ForkTsCheckerPlugin from "fork-ts-checker-webpack-plugin"
|
||||||
|
|
||||||
export default function (): webpack.Configuration {
|
export default function (): webpack.Configuration {
|
||||||
console.info('WEBPACK:renderer', require("./src/common/vars"), process.env)
|
console.info('WEBPACK:renderer', require("./src/common/vars"))
|
||||||
return {
|
return {
|
||||||
context: __dirname,
|
context: __dirname,
|
||||||
target: "electron-renderer",
|
target: "electron-renderer",
|
||||||
@ -18,8 +18,8 @@ export default function (): webpack.Configuration {
|
|||||||
[appName]: path.resolve(rendererDir, "bootstrap.tsx"),
|
[appName]: path.resolve(rendererDir, "bootstrap.tsx"),
|
||||||
},
|
},
|
||||||
output: {
|
output: {
|
||||||
publicPath: "/",
|
publicPath: publicPath,
|
||||||
path: outDir,
|
path: buildDir,
|
||||||
filename: '[name].js',
|
filename: '[name].js',
|
||||||
chunkFilename: 'chunks/[name].js',
|
chunkFilename: 'chunks/[name].js',
|
||||||
},
|
},
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user