move app build to a separate package

Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
This commit is contained in:
Jari Kolehmainen committed 2023-01-09 16:42:04 +02:00
1 parent bc87eb4f22
commit 11b763e48f
19 files changed
+934 -154

No files matched your search

+291
View File
@@ -0,0 +1,291 @@
/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
const packageJson = require("./package.json");
module.exports = {
ignorePatterns: [
"**/node_modules/**/*",
"**/dist/**/*",
"**/static/**/*",
"**/site/**/*",
"build/webpack/**/*",
],
settings: {
react: {
version: packageJson.devDependencies.react || "detect",
},
"import/parsers": {
"@typescript-eslint/parser": [".ts", ".tsx"],
},
"import/resolver": {
"typescript": {
"alwaysTryTypes": true,
"project": "./tsconfig.json",
},
},
},
overrides: [
{
files: [
"**/*.js",
"**/*.mjs",
],
extends: [
"eslint:recommended",
],
env: {
node: true,
es2022: true,
},
parserOptions: {
sourceType: "module",
},
plugins: [
"header",
"unused-imports",
"react-hooks",
],
rules: {
"no-constant-condition": ["error", { "checkLoops": false }],
"header/header": [2, "../../license-header"],
"comma-dangle": ["error", "always-multiline"],
"comma-spacing": "error",
"indent": ["error", 2, {
"SwitchCase": 1,
}],
"no-unused-vars": "off",
"space-before-function-paren": ["error", {
"anonymous": "always",
"named": "never",
"asyncArrow": "always",
}],
"unused-imports/no-unused-imports": "error",
"unused-imports/no-unused-vars": [
"warn", {
"vars": "all",
"args": "after-used",
"ignoreRestSiblings": true,
},
],
"quotes": ["error", "double", {
"avoidEscape": true,
"allowTemplateLiterals": true,
}],
"object-curly-spacing": ["error", "always", {
"objectsInObjects": false,
"arraysInObjects": true,
}],
"linebreak-style": ["error", "unix"],
"eol-last": ["error", "always"],
"semi": ["error", "always"],
"object-shorthand": "error",
"prefer-template": "error",
"template-curly-spacing": "error",
"no-unused-expressions": "error",
"padding-line-between-statements": [
"error",
{ "blankLine": "always", "prev": "*", "next": "return" },
{ "blankLine": "always", "prev": "*", "next": "block-like" },
{ "blankLine": "always", "prev": "*", "next": "function" },
{ "blankLine": "always", "prev": "*", "next": "class" },
{ "blankLine": "always", "prev": ["const", "let", "var"], "next": "*" },
{ "blankLine": "any", "prev": ["const", "let", "var"], "next": ["const", "let", "var"] },
],
"no-template-curly-in-string": "error",
},
},
{
files: [
"**/*.ts",
"**/*.tsx",
],
parser: "@typescript-eslint/parser",
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:react/recommended",
"plugin:import/recommended",
"plugin:import/typescript",
],
plugins: [
"header",
"unused-imports",
"react-hooks",
],
parserOptions: {
ecmaVersion: 2018,
sourceType: "module",
},
rules: {
"no-constant-condition": ["error", {
"checkLoops": false,
}],
"header/header": [2, "../../license-header"],
"react/prop-types": "off",
"no-invalid-this": "off",
"@typescript-eslint/no-invalid-this": ["error"],
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/interface-name-prefix": "off",
"@typescript-eslint/no-use-before-define": "off",
"@typescript-eslint/no-empty-interface": "off",
"@typescript-eslint/no-var-requires": "off",
"@typescript-eslint/ban-ts-ignore": "off",
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/ban-types": "off",
"@typescript-eslint/ban-ts-comment": "off",
"@typescript-eslint/no-empty-function": "off",
"@typescript-eslint/no-unused-vars": "off",
"no-restricted-imports": ["error", {
"paths": [
{
"name": ".",
"message": "No importing from local index.ts(x?) file. A common way to make circular dependencies.",
},
],
}],
"@typescript-eslint/member-delimiter-style": ["error", {
"multiline": {
"delimiter": "semi",
"requireLast": true,
},
"singleline": {
"delimiter": "semi",
"requireLast": false,
},
}],
"react/jsx-max-props-per-line": ["error", {
"maximum": {
"single": 2,
"multi": 1,
},
}],
"react/jsx-first-prop-new-line": ["error", "multiline"],
"react/jsx-one-expression-per-line": ["error", {
"allow": "single-child",
}],
"react/jsx-indent": ["error", 2],
"react/jsx-indent-props": ["error", 2],
"react/jsx-closing-tag-location": "error",
"react/jsx-wrap-multilines": ["error", {
"declaration": "parens-new-line",
"assignment": "parens-new-line",
"return": "parens-new-line",
"arrow": "parens-new-line",
"condition": "parens-new-line",
"logical": "parens-new-line",
"prop": "parens-new-line",
}],
"react/display-name": "off",
"space-before-function-paren": "off",
"@typescript-eslint/space-before-function-paren": ["error", {
"anonymous": "always",
"named": "never",
"asyncArrow": "always",
}],
"@typescript-eslint/naming-convention": ["error",
{
"selector": "interface",
"format": ["PascalCase"],
"leadingUnderscore": "forbid",
"trailingUnderscore": "forbid",
"custom": {
"regex": "^Props$",
"match": false,
},
},
{
"selector": "typeAlias",
"format": ["PascalCase"],
"leadingUnderscore": "forbid",
"trailingUnderscore": "forbid",
"custom": {
"regex": "^(Props|State)$",
"match": false,
},
},
],
"@typescript-eslint/consistent-type-definitions": ["error", "interface"],
"unused-imports/no-unused-imports-ts": process.env.PROD === "true" ? "error" : "warn",
"unused-imports/no-unused-vars-ts": [
"warn", {
"vars": "all",
"args": "after-used",
"ignoreRestSiblings": true,
},
],
"comman-dangle": "off",
"@typescript-eslint/comma-dangle": ["error", "always-multiline"],
"comma-spacing": "off",
"@typescript-eslint/comma-spacing": "error",
"indent": ["error", 2, {
"SwitchCase": 1,
}],
"quotes": ["error", "double", {
"avoidEscape": true,
"allowTemplateLiterals": true,
}],
"object-curly-spacing": "off",
"@typescript-eslint/object-curly-spacing": ["error", "always", {
"objectsInObjects": false,
"arraysInObjects": true,
}],
"semi": "off",
"@typescript-eslint/semi": ["error"],
"linebreak-style": ["error", "unix"],
"eol-last": ["error", "always"],
"object-shorthand": "error",
"prefer-template": "error",
"template-curly-spacing": "error",
"no-unused-expressions": "off",
"@typescript-eslint/no-unused-expressions": "error",
"padding-line-between-statements": [
"error",
{ "blankLine": "always", "prev": "*", "next": "return" },
{ "blankLine": "always", "prev": "*", "next": "block-like" },
{ "blankLine": "always", "prev": "*", "next": "function" },
{ "blankLine": "always", "prev": "*", "next": "class" },
{ "blankLine": "always", "prev": ["const", "let", "var"], "next": "*" },
{ "blankLine": "any", "prev": ["const", "let", "var"], "next": ["const", "let", "var"] },
],
"react-hooks/rules-of-hooks": "error",
"react-hooks/exhaustive-deps": "off",
"no-template-curly-in-string": "error",
"@typescript-eslint/consistent-type-imports": "error",
},
},
{
files: [
"src/{common,main,renderer}/**/*.ts",
"src/{common,main,renderer}/**/*.tsx",
],
rules: {
"no-restricted-imports": ["error", {
"paths": [
{
"name": ".",
"message": "No importing from local index.ts(x?) file. A common way to make circular dependencies.",
},
{
"name": "..",
"message": "No importing from parent index.ts(x?) file. A common way to make circular dependencies.",
},
],
"patterns": [
{
"group": [
"**/extensions/renderer-api/**/*",
"**/extensions/main-api/**/*",
"**/extensions/common-api/**/*",
],
message: "No importing from the extension api definitions in application code",
},
],
}],
},
},
],
};
+18
View File
@@ -0,0 +1,18 @@
{
"module": {
"type": "commonjs"
},
"jsc": {
"parser": {
"syntax": "typescript",
"tsx": true,
"decorators": true,
"dynamicImport": false
},
"transform": {
"legacyDecorator": true,
"decoratorMetadata": true
},
"target": "es2019"
}
}
+3
View File
@@ -0,0 +1,3 @@
disturl "https://electronjs.org/headers"
target "19.0.4"
runtime "electron"
+6
View File
@@ -0,0 +1,6 @@
/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
export default ""; // mostly path to bundled file or data-url (webpack)
+5 -124
View File
@@ -1,7 +1,6 @@
{
"name": "@k8slens/open-lens",
"productName": "OpenLens",
"description": "OpenLens - Open Source IDE for Kubernetes",
"description": "Lens Desktop Core",
"homepage": "https://github.com/lensapp/lens",
"version": "6.4.0-alpha.0",
"repository": {
@@ -37,7 +36,6 @@
"build/*.plist",
"build/installer.nsh",
"build/notarize.js",
"src/**/*",
"static/build/library/**/*",
"templates/**/*",
"types/*",
@@ -47,37 +45,19 @@
"license": "MIT",
"author": "OpenLens Authors <info@k8slens.dev>",
"scripts": {
"build": "yarn run compile-library",
"dev": "concurrently -i -k \"yarn run dev-run -C\" yarn:dev:*",
"dev-build": "concurrently yarn:compile:*",
"debug-build": "concurrently yarn:compile:main yarn:compile:extension-types",
"dev-run": "nodemon --watch ./static/build/main.js --exec \"electron --remote-debugging-port=9223 --inspect .\"",
"dev:main": "yarn run compile:main --watch --progress",
"dev:renderer": "yarn run ts-node webpack/dev-server.ts",
"build": "yarn run compile:library",
"clean": "rm -rf dist/ static/build binaries/",
"compile-library": "env NODE_ENV=production yarn run webpack --config webpack/library-bundle.ts",
"compile": "env NODE_ENV=production concurrently yarn:compile:*",
"compile:main": "yarn run webpack --config webpack/main.ts",
"compile:renderer": "yarn run webpack --config webpack/renderer.ts",
"compile:extension-types": "yarn run webpack --config webpack/extensions.ts",
"compile:library": "env NODE_ENV=production yarn run webpack --config webpack/library-bundle.ts",
"compile:node-fetch": "yarn run webpack --config ./webpack/node-fetch.ts",
"prepare": "yarn run compile:node-fetch",
"npm:fix-extensions-package-version": "yarn run ts-node build/set_extensions_npm_version.ts",
"build:linux": "yarn run compile && electron-builder --linux --dir",
"build:mac": "yarn run compile && electron-builder --mac --dir",
"build:win": "yarn run compile && electron-builder --win --dir",
"integration": "jest --runInBand --detectOpenHandles --forceExit integration",
"test:unit": "func() { jest ${1} --watch --testPathIgnorePatterns integration; }; func",
"test:integration": "func() { jest ${1:-xyz} --watch --runInBand --detectOpenHandles --forceExit --modulePaths=[\"<rootDir>/integration/\"]; }; func",
"dist": "yarn run compile && electron-builder --publish onTag",
"dist:dir": "yarn run dist --dir -c.compression=store -c.mac.identity=null",
"download:binaries": "yarn run ts-node build/download_binaries.ts",
"build:tray-icons": "yarn run ts-node build/generate-tray-icons.ts",
"build:theme-vars": "yarn run ts-node build/build_theme_vars.ts",
"lint": "PROD=true yarn run eslint --ext js,ts,tsx --max-warnings=0 .",
"lint:fix": "yarn run lint --fix",
"mkdocs-serve-local": "docker build -t mkdocs-serve-local:latest mkdocs/ && docker run --rm -it -p 8000:8000 -v ${PWD}:/docs mkdocs-serve-local:latest",
"verify-docs": "docker build -t mkdocs-serve-local:latest mkdocs/ && docker run --rm -v ${PWD}:/docs mkdocs-serve-local:latest build --strict",
"version-checkout": "cat package.json | jq '.version' -r | xargs printf \"release/v%s\" | xargs git checkout -b",
"version-commit": "cat package.json | jq '.version' -r | xargs printf \"release v%s\" | git commit --no-edit -s -F -",
"version": "yarn run version-checkout && git add package.json && yarn run version-commit",
@@ -124,105 +104,7 @@
],
"runtime": "@side/jest-runtime"
},
"build": {
"generateUpdatesFilesForAllChannels": true,
"files": [
"static/**/*"
],
"afterSign": "build/notarize.js",
"extraResources": [
{
"from": "templates/",
"to": "./templates/",
"filter": "**/*.yaml"
},
"LICENSE"
],
"linux": {
"executableName": "open-lens",
"category": "Network",
"artifactName": "${productName}-${version}.${arch}.${ext}",
"target": [
"deb",
"rpm",
"AppImage"
],
"extraResources": [
{
"from": "binaries/client/linux/${arch}/kubectl",
"to": "./${arch}/kubectl"
},
{
"from": "binaries/client/linux/${arch}/lens-k8s-proxy",
"to": "./${arch}/lens-k8s-proxy"
},
{
"from": "binaries/client/linux/${arch}/helm",
"to": "./${arch}/helm"
}
]
},
"rpm": {
"fpm": [
"--rpm-rpmbuild-define=%define _build_id_links none"
]
},
"mac": {
"executableName": "OpenLens",
"hardenedRuntime": true,
"gatekeeperAssess": false,
"entitlements": "build/entitlements.mac.plist",
"entitlementsInherit": "build/entitlements.mac.plist",
"extraResources": [
{
"from": "binaries/client/darwin/${arch}/kubectl",
"to": "./${arch}/kubectl"
},
{
"from": "binaries/client/darwin/${arch}/lens-k8s-proxy",
"to": "./${arch}/lens-k8s-proxy"
},
{
"from": "binaries/client/darwin/${arch}/helm",
"to": "./${arch}/helm"
}
]
},
"win": {
"executableName": "OpenLens.exe",
"target": [
"nsis"
],
"extraResources": [
{
"from": "binaries/client/windows/${arch}/kubectl.exe",
"to": "./${arch}/kubectl.exe"
},
{
"from": "binaries/client/windows/${arch}/lens-k8s-proxy.exe",
"to": "./${arch}/lens-k8s-proxy.exe"
},
{
"from": "binaries/client/windows/${arch}/helm.exe",
"to": "./${arch}/helm.exe"
}
]
},
"nsis": {
"include": "build/installer.nsh",
"oneClick": false,
"allowElevation": true,
"createStartMenuShortcut": true,
"allowToChangeInstallationDirectory": true
},
"protocols": {
"name": "Lens Protocol Handler",
"schemes": [
"lens"
],
"role": "Viewer"
}
},
"build": {},
"resolutions": {
"@astronautlabs/jsonpath/underscore": "^1.12.1"
},
@@ -326,6 +208,7 @@
"@types/dompurify": "^2.4.0",
"@types/electron-devtools-installer": "^2.2.1",
"@types/fs-extra": "^9.0.13",
"@types/glob": "^8.0.0",
"@types/glob-to-regexp": "^0.4.1",
"@types/gunzip-maybe": "^1.4.0",
"@types/hapi__call": "^9.0.0",
@@ -382,8 +265,6 @@
"deepdash": "^5.3.9",
"dompurify": "^2.4.1",
"electron": "^19.1.9",
"electron-builder": "^23.6.0",
"electron-notarize": "^0.3.0",
"esbuild": "^0.16.13",
"esbuild-loader": "^2.20.0",
"eslint": "^8.30.0",
@@ -7,7 +7,7 @@ import { getInjectionToken } from "@ogre-tools/injectable";
import type packageJson from "../../../package.json";
export type ApplicationInformation = Pick<typeof packageJson, "version" | "config" | "productName" | "copyright" | "description" | "name"> & {
build: Partial<typeof packageJson["build"]> & { publish?: unknown[] };
build: { [key:string]: any } & { publish?: unknown[] };
};
const applicationInformationToken = getInjectionToken<ApplicationInformation>({
+2
View File
@@ -0,0 +1,2 @@
static/build
binaries/
+233
View File
@@ -0,0 +1,233 @@
{
"name": "open-lens",
"private": true,
"productName": "OpenLens",
"description": "OpenLens - Open Source IDE for Kubernetes",
"homepage": "https://github.com/lensapp/lens",
"version": "6.4.0-alpha.0",
"repository": {
"type": "git",
"url": "git+https://github.com/lensapp/lens.git"
},
"keywords": [],
"bugs": {
"url": "https://github.com/lensapp/lens/issues"
},
"main": "static/build/main.js",
"copyright": "© 2023 OpenLens Authors",
"license": "MIT",
"author": "OpenLens Authors <info@k8slens.dev>",
"scripts": {
"build": "npm run compile && electron-builder",
"build:mac": "npm run compile && electron-builder --mac --dir",
"compile": "env NODE_ENV=production webpack --config webpack/webpack.ts --progress",
"postcompile": "npm run build:tray-icons && npm run download:binaries",
"predev": "rm -rf static/build/ && npm run build:tray-icons && npm run download:binaries",
"dev": "concurrently -i -k \"yarn run dev-run -C\" yarn:dev:*",
"dev-run": "nodemon --watch ./static/build/main.js --exec \"electron --remote-debugging-port=9223 --inspect .\"",
"dev:main": "env NODE_ENV=development webpack --config webpack/main.ts --progress --watch",
"dev:renderer": "env NODE_ENV=development ts-node ./webpack/dev-server.ts",
"build:tray-icons": "ts-node ../core/build/generate-tray-icons.ts",
"download:binaries": "ts-node ../core/build/download_binaries.ts"
},
"config": {
"k8sProxyVersion": "0.3.0",
"bundledKubectlVersion": "1.23.3",
"bundledHelmVersion": "3.7.2",
"sentryDsn": "",
"contentSecurityPolicy": "script-src 'unsafe-eval' 'self'; frame-src https://*.lens.app:*/; img-src * data:",
"welcomeRoute": "/welcome"
},
"engines": {
"node": ">=16 <17"
},
"jest": {
"collectCoverage": false,
"verbose": true,
"transform": {
"^.+\\.(t|j)sx?$": [
"@swc/jest"
]
},
"testEnvironment": "jsdom",
"resolver": "<rootDir>/src/jest-28-resolver.js",
"moduleNameMapper": {
"\\.(css|scss)$": "identity-obj-proxy",
"\\.(svg|png|jpg|eot|woff2?|ttf)$": "<rootDir>/__mocks__/assetMock.ts"
},
"modulePathIgnorePatterns": [
"<rootDir>/dist",
"<rootDir>/packages"
],
"setupFiles": [
"<rootDir>/src/jest.setup.ts",
"jest-canvas-mock"
],
"globalSetup": "<rootDir>/src/jest.timezone.ts",
"setupFilesAfterEnv": [
"<rootDir>/src/jest-after-env.setup.ts"
],
"runtime": "@side/jest-runtime"
},
"build": {
"generateUpdatesFilesForAllChannels": true,
"files": [
"static/**/*"
],
"afterSign": "../core/build/notarize.js",
"extraResources": [
{
"from": "templates/",
"to": "./templates/",
"filter": "**/*.yaml"
},
"LICENSE"
],
"linux": {
"category": "Network",
"artifactName": "${productName}-${version}.${arch}.${ext}",
"target": [
"deb",
"rpm",
"AppImage"
],
"extraResources": [
{
"from": "binaries/client/linux/${arch}/kubectl",
"to": "./${arch}/kubectl"
},
{
"from": "binaries/client/linux/${arch}/lens-k8s-proxy",
"to": "./${arch}/lens-k8s-proxy"
},
{
"from": "binaries/client/linux/${arch}/helm",
"to": "./${arch}/helm"
}
]
},
"rpm": {
"fpm": [
"--rpm-rpmbuild-define=%define _build_id_links none"
]
},
"mac": {
"hardenedRuntime": true,
"gatekeeperAssess": false,
"entitlements": "../core/build/entitlements.mac.plist",
"entitlementsInherit": "../core/build/entitlements.mac.plist",
"extraResources": [
{
"from": "binaries/client/darwin/${arch}/kubectl",
"to": "./${arch}/kubectl"
},
{
"from": "binaries/client/darwin/${arch}/lens-k8s-proxy",
"to": "./${arch}/lens-k8s-proxy"
},
{
"from": "binaries/client/darwin/${arch}/helm",
"to": "./${arch}/helm"
}
]
},
"win": {
"target": [
"nsis"
],
"extraResources": [
{
"from": "binaries/client/windows/${arch}/kubectl.exe",
"to": "./${arch}/kubectl.exe"
},
{
"from": "binaries/client/windows/${arch}/lens-k8s-proxy.exe",
"to": "./${arch}/lens-k8s-proxy.exe"
},
{
"from": "binaries/client/windows/${arch}/helm.exe",
"to": "./${arch}/helm.exe"
}
]
},
"nsis": {
"include": "../core/build/installer.nsh",
"oneClick": false,
"allowElevation": true,
"createStartMenuShortcut": true,
"allowToChangeInstallationDirectory": true
},
"protocols": {
"name": "Lens Protocol Handler",
"schemes": [
"lens"
],
"role": "Viewer"
}
},
"dependencies": {
"@k8slens/open-lens": "^6.4.0-alpha.0",
"@ogre-tools/fp": "^12.0.1",
"@ogre-tools/injectable": "^12.0.1",
"@ogre-tools/injectable-extension-for-auto-registration": "^12.0.1",
"@ogre-tools/injectable-extension-for-mobx": "^12.0.1",
"@ogre-tools/injectable-react": "^12.0.1"
},
"devDependencies": {
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.10",
"@types/node": "^16.18.6",
"@types/webpack": "^5.28.0",
"@types/webpack-dev-server": "^4.7.2",
"@types/webpack-env": "^1.18.0",
"@types/webpack-node-externals": "2.5.3",
"autoprefixer": "^10.4.13",
"circular-dependency-plugin": "^5.2.2",
"cli-progress": "^3.11.2",
"concurrently": "^7.6.0",
"css-loader": "^6.7.2",
"electron": "^19.1.9",
"electron-builder": "^23.6.0",
"electron-notarize": "^0.3.0",
"esbuild-loader": "^2.20.0",
"fork-ts-checker-webpack-plugin": "^7.2.14",
"gunzip-maybe": "^1.4.2",
"html-webpack-plugin": "^5.5.0",
"jsdom": "^20.0.3",
"jsonfile": "^6.1.0",
"mini-css-extract-plugin": "^2.7.1",
"monaco-editor-webpack-plugin": "^5.0.0",
"node-loader": "^2.0.0",
"nodemon": "^2.0.20",
"sharp": "^0.31.2",
"style-loader": "^3.3.1",
"tailwindcss": "^3.2.4",
"ts-loader": "^9.4.2",
"ts-node": "^10.9.1",
"type-fest": "^2.14.0",
"typescript": "^4.9.4",
"typescript-plugin-css-modules": "^4.1.1",
"webpack": "^5.75.0",
"webpack-cli": "^4.9.2",
"webpack-dev-server": "^4.11.1",
"webpack-node-externals": "^3.0.0",
"@types/byline": "^4.2.33",
"@types/chart.js": "^2.9.36",
"@types/color": "^3.0.3",
"@types/crypto-js": "^3.1.47",
"@types/lodash": "^4.14.191",
"@types/proper-lockfile": "^4.1.2",
"@types/react-dom": "^17.0.16",
"@types/react-router-dom": "^5.3.3",
"@types/react-virtualized-auto-sizer": "^1.0.1",
"@types/react-window": "^1.8.5",
"@types/request-promise-native": "^1.0.18",
"@types/tar": "^6.1.3",
"@types/tcp-port-used": "^1.0.1",
"@types/url-parse": "^1.4.8",
"@types/uuid": "^8.3.4",
"monaco-editor": "^0.29.1",
"react-select": "^5.7.0",
"typed-emitter": "^1.4.0",
"xterm-addon-fit": "^0.5.0"
}
}
@@ -0,0 +1,17 @@
import { getInjectable } from "@ogre-tools/injectable";
import { applicationInformationToken, ApplicationInformation } from "@k8slens/open-lens/common";
import packageJson from "../../package.json";
const applicationInformationInjectable = getInjectable({
id: "application-information",
injectionToken: applicationInformationToken,
instantiate: () => {
const { version, config, productName, build, copyright, description, name } = packageJson;
return { version, config, productName, build, copyright, description, name } as ApplicationInformation;
},
causesSideEffects: true,
});
export default applicationInformationInjectable;
+38
View File
@@ -0,0 +1,38 @@
import { createContainer } from "@ogre-tools/injectable";
import { autoRegister } from "@ogre-tools/injectable-extension-for-auto-registration";
import { runInAction } from "mobx";
import { createApp, extensionApi } from "@k8slens/open-lens/main";
const di = createContainer("main");
const app = createApp({
di,
mode: process.env.NODE_ENV || "development"
});
runInAction(() => {
try {
autoRegister({
di,
requireContexts: [
require.context("./", true, CONTEXT_MATCHER_FOR_NON_FEATURES),
require.context("../common", true, CONTEXT_MATCHER_FOR_NON_FEATURES),
],
});
} catch (err) {
console.error(err);
process.exit(1);
}
});
app.start().catch((error) => {
console.error(error);
process.exit(1);
})
const { Mobx, LensExtensions, Pty } = extensionApi;
export {
Mobx,
LensExtensions,
Pty
};
+43
View File
@@ -0,0 +1,43 @@
import "@k8slens/open-lens/styles";
import { createContainer } from "@ogre-tools/injectable";
import { runInAction } from "mobx";
import { createApp, extensionApi } from "@k8slens/open-lens/renderer";
import { autoRegister } from "@ogre-tools/injectable-extension-for-auto-registration";
const di = createContainer("renderer");
const app = createApp({
di,
mode: process.env.NODE_ENV || "development"
});
runInAction(() => {
autoRegister({
di,
requireContexts: [
require.context("./", true, CONTEXT_MATCHER_FOR_NON_FEATURES),
require.context("../common", true, CONTEXT_MATCHER_FOR_NON_FEATURES),
],
});
});
app.start();
const {
React,
ReactDOM,
ReactRouter,
ReactRouterDom,
Mobx,
MobxReact,
LensExtensions
} = extensionApi;
export {
React,
ReactDOM,
ReactRouter,
ReactRouterDom,
Mobx,
MobxReact,
LensExtensions
};
+31
View File
@@ -0,0 +1,31 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"paths": {
"*": [
"node_modules/*",
]
},
"plugins": [
{
"name": "typescript-plugin-css-modules"
}
]
},
"include": [
"src/**/*",
"../core/types/*.d.ts"
],
"exclude": [
"out",
"dist",
"coverage",
"binaries",
"static"
],
"references": [
{
"path": "../core"
}
]
}
+45
View File
@@ -0,0 +1,45 @@
/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import Webpack from "webpack";
import WebpackDevServer from "webpack-dev-server";
import renderer from "./renderer";
import { buildDir, webpackDevServerPort } from "./vars";
/**
* API docs:
* @url https://webpack.js.org/configuration/dev-server/
* @url https://github.com/chimurai/http-proxy-middleware
*/
const compiler = Webpack(renderer);
const server = new WebpackDevServer({
setupExitSignals: true,
headers: {
"Access-Control-Allow-Origin": "*",
},
allowedHosts: "127.0.0.1",
host: "localhost",
port: webpackDevServerPort,
static: buildDir, // aka `devServer.contentBase` in webpack@4
hot: "only", // use HMR only without errors
liveReload: false,
devMiddleware: {
writeToDisk: true,
index: "index.html",
publicPath: "/build",
},
proxy: {
"^/$": "/build/",
},
client: {
overlay: false, // don't show warnings and errors on top of rendered app view
logging: "error",
},
}, compiler);
console.info(`[WEBPACK-DEV-SERVER]: created with options`, server.options);
server.start();
+59
View File
@@ -0,0 +1,59 @@
import path from "path";
import type webpack from "webpack";
import { DefinePlugin } from "webpack";
import nodeExternals from "webpack-node-externals";
import { iconsAndImagesWebpackRules } from "./renderer";
import { buildDir, isDevelopment, mainDir } from "./vars";
import { platform } from "process";
const main: webpack.Configuration = ({
name: "lens-app-main",
context: __dirname,
target: "electron-main",
mode: isDevelopment ? "development" : "production",
devtool: isDevelopment ? "cheap-module-source-map" : "source-map",
cache: isDevelopment ? { type: "filesystem" } : false,
entry: {
main: path.resolve(mainDir, "index.ts"),
},
output: {
libraryTarget: "global",
path: buildDir,
},
optimization: {
minimize: false,
},
resolve: {
extensions: [".json", ".js", ".ts"],
},
externals: [
nodeExternals(),
],
module: {
parser: {
javascript: {
commonjsMagicComments: true,
},
},
rules: [
{
test: /\.node$/,
use: "node-loader",
},
{
test: /\.ts$/,
loader: "ts-loader",
options: {},
},
...iconsAndImagesWebpackRules(),
],
},
plugins: [
new DefinePlugin({
CONTEXT_MATCHER_FOR_NON_FEATURES: `/\\.injectable(\\.${platform})?\\.tsx?$/`,
CONTEXT_MATCHER_FOR_FEATURES: `/\\/(renderer|common)\\/.+\\.injectable(\\.${platform})?\\.tsx?$/`,
}),
],
});
export default main;
+185
View File
@@ -0,0 +1,185 @@
/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import path from "path";
import type webpack from "webpack";
import HtmlWebpackPlugin from "html-webpack-plugin";
import MiniCssExtractPlugin from "mini-css-extract-plugin";
import ForkTsCheckerPlugin from "fork-ts-checker-webpack-plugin";
import MonacoWebpackPlugin from "monaco-editor-webpack-plugin";
import CircularDependencyPlugin from "circular-dependency-plugin";
import ReactRefreshWebpackPlugin from "@pmmmwh/react-refresh-webpack-plugin";
import type { WebpackPluginInstance } from "webpack";
import { DefinePlugin } from "webpack";
import { assetsFolderName, isDevelopment, rendererDir, buildDir, htmlTemplate, publicPath, sassCommonVars } from "./vars";
import { platform } from "process";
const renderer: webpack.Configuration = {
target: "electron-renderer",
name: "lens-app-renderer",
mode: isDevelopment ? "development" : "production",
// https://webpack.js.org/configuration/devtool/ (see description of each option)
devtool: isDevelopment ? "cheap-module-source-map" : "source-map",
cache: isDevelopment ? { type: "filesystem" } : false,
entry: {
lens: path.resolve(rendererDir, "index.ts"),
},
output: {
libraryTarget: "global",
globalObject: "this",
publicPath,
path: buildDir,
filename: "[name].js",
chunkFilename: "chunks/[name].js",
assetModuleFilename: `${assetsFolderName}/[name][ext][query]`,
},
watchOptions: {
ignored: /node_modules/, // https://webpack.js.org/configuration/watch/
},
ignoreWarnings: [
/Critical dependency: the request of a dependency is an expression/,
/require.extensions is not supported by webpack./, // handlebars
/\[ReactRefreshPlugin] .*?HMR.*? is not enabled/, // enabled in webpack.dev-server
],
resolve: {
extensions: [
".js", ".jsx", ".json",
".ts", ".tsx",
],
},
externals: {
"node-fetch": "commonjs node-fetch",
"npm": "commonjs npm",
},
optimization: {
minimize: false,
},
module: {
parser: {
javascript: {
commonjsMagicComments: true,
},
},
rules: [
{
test: /\.node$/,
use: "node-loader",
},
{
test: /\.tsx?$/,
loader: "ts-loader",
options: {},
},
cssModulesWebpackRule(),
...iconsAndImagesWebpackRules(),
...fontsLoaderWebpackRules(),
],
},
plugins: [
new DefinePlugin({
CONTEXT_MATCHER_FOR_NON_FEATURES: `/\\.injectable(\\.${platform})?\\.tsx?$/`,
CONTEXT_MATCHER_FOR_FEATURES: `/\\/(renderer|common)\\/.+\\.injectable(\\.${platform})?\\.tsx?$/`,
}),
new ForkTsCheckerPlugin(),
// see also: https://github.com/Microsoft/monaco-editor-webpack-plugin#options
new MonacoWebpackPlugin({
// publicPath: "/",
// filename: "[name].worker.js",
languages: ["json", "yaml"],
globalAPI: isDevelopment,
}),
new HtmlWebpackPlugin({
filename: "index.html",
template: htmlTemplate,
inject: true,
hash: true,
templateParameters: {
assetPath: `${publicPath}${assetsFolderName}`,
},
}),
new CircularDependencyPlugin({
cwd: __dirname,
exclude: /node_modules/,
failOnError: true,
}) as unknown as WebpackPluginInstance,
new MiniCssExtractPlugin({
filename: "[name].css",
}),
...(
isDevelopment
? [new ReactRefreshWebpackPlugin()]
: []
),
],
};
/**
* Import icons and image files.
* Read more about asset types: https://webpack.js.org/guides/asset-modules/
*/
export function iconsAndImagesWebpackRules(): webpack.RuleSetRule[] {
return [
{
test: /\.svg$/,
type: "asset/source", // exports the source code of the asset, so we get XML
},
{
test: /\.(jpg|png|ico)$/,
type: "asset/resource", // path to file, e.g. "/static/build/assets/*"
},
];
}
/**
* Import custom fonts as URL.
*/
export function fontsLoaderWebpackRules(): webpack.RuleSetRule[] {
return [
{
test: /\.(ttf|eot|woff2?)$/,
type: "asset/resource",
},
];
}
export interface CssModulesWebpackRuleOptions {
styleLoader?: string;
}
/**
* Import CSS or SASS styles with modules support (*.module.scss)
*/
export function cssModulesWebpackRule({ styleLoader }: CssModulesWebpackRuleOptions = {}): webpack.RuleSetRule {
styleLoader ??= isDevelopment
? "style-loader"
: MiniCssExtractPlugin.loader;
return {
test: /\.s?css$/,
use: [
styleLoader,
{
loader: "css-loader",
options: {
sourceMap: isDevelopment,
modules: {
auto: /\.module\./i, // https://github.com/webpack-contrib/css-loader#auto
mode: "local", // :local(.selector) by default
localIdentName: "[name]__[local]--[hash:base64:5]",
},
},
},
],
};
}
export default renderer;
+19
View File
@@ -0,0 +1,19 @@
/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import assert from "assert";
import path from "path";
export const isDevelopment = process.env.NODE_ENV !== "production";
export const mainDir = path.join(process.cwd(), "src", "main");
export const buildDir = path.join(process.cwd(), "static", "build");
export const assetsFolderName = "assets";
export const rendererDir = path.join(process.cwd(), "src", "renderer");
export const htmlTemplate = path.resolve(__dirname, "..", "node_modules", "@k8slens", "open-lens", "src/renderer", "template.html");
export const publicPath = "/build/";
export const sassCommonVars = path.resolve(__dirname, "..", "node_modules", "@k8slens", "open-lens", "src", "renderer", "components/vars.scss");
export const webpackDevServerPort = Number(process.env.WEBPACK_DEV_SERVER_PORT) || 9191;
assert(Number.isInteger(webpackDevServerPort), "WEBPACK_DEV_SERVER_PORT environment variable must only be an integer");
+4
View File
@@ -0,0 +1,4 @@
import main from "./main";
import renderer from "./renderer";
export default [main, renderer];