mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Introduce sample bundled extension example
- Use new sample bundled extension in open-lens for documentation purposes Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
parent
027e57196a
commit
38eaac2550
@ -198,6 +198,7 @@
|
||||
"@k8slens/core": "^6.4.0-beta.13",
|
||||
"@k8slens/ensure-binaries": "^6.4.0-beta.13",
|
||||
"@k8slens/generate-tray-icons": "^6.4.0-beta.13",
|
||||
"@k8slens/sample-extension": "^6.4.0-beta.13",
|
||||
"@ogre-tools/fp": "^12.0.1",
|
||||
"@ogre-tools/injectable": "^12.0.1",
|
||||
"@ogre-tools/injectable-extension-for-auto-registration": "^12.0.1",
|
||||
|
||||
@ -0,0 +1,15 @@
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import { bundledExtensionInjectionToken } from "@k8slens/core/common";
|
||||
import manifest from "@k8slens/sample-extension/package.json";
|
||||
|
||||
const sampleBundledExtensionInjectable = getInjectable({
|
||||
id: "sample-bundled-extension",
|
||||
instantiate: () => ({
|
||||
manifest,
|
||||
main: async () => (await import("@k8slens/sample-extension/main")).default,
|
||||
renderer: async () => (await import("@k8slens/sample-extension/renderer")).default,
|
||||
}),
|
||||
injectionToken: bundledExtensionInjectionToken,
|
||||
});
|
||||
|
||||
export default sampleBundledExtensionInjectable;
|
||||
2
packages/sample-extension/.gitignore
vendored
Normal file
2
packages/sample-extension/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
dist/
|
||||
node_modules/
|
||||
3
packages/sample-extension/README.md
Normal file
3
packages/sample-extension/README.md
Normal file
@ -0,0 +1,3 @@
|
||||
# Description
|
||||
|
||||
This is a sample extension example to document how to set up bundled extensions when dealing with `@k8slens/core`
|
||||
1
packages/sample-extension/main.ts
Normal file
1
packages/sample-extension/main.ts
Normal file
@ -0,0 +1 @@
|
||||
export default null;
|
||||
44
packages/sample-extension/package.json
Normal file
44
packages/sample-extension/package.json
Normal file
@ -0,0 +1,44 @@
|
||||
{
|
||||
"name": "@k8slens/sample-extension",
|
||||
"version": "6.4.0-beta.13",
|
||||
"description": "Sample bundled extension for open-lens",
|
||||
"license": "MIT",
|
||||
"private": false,
|
||||
"publishConfig": {
|
||||
"access": "public",
|
||||
"registry": "https://registry.npmjs.org/"
|
||||
},
|
||||
"exports": {
|
||||
"./package.json": "./package.json",
|
||||
"./main": "./dist/main.js",
|
||||
"./renderer": "./dist/renderer.js"
|
||||
},
|
||||
"typesVersions": {
|
||||
"*": {
|
||||
"./main": [
|
||||
"./dist/main.d.ts"
|
||||
],
|
||||
"./renderer": [
|
||||
"./dist/renderer.d.ts"
|
||||
]
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"clean": "rimraf dist/",
|
||||
"build": "webpack --config webpack.ts",
|
||||
"lint": "exit 0",
|
||||
"prepare": "yarn run build",
|
||||
"prepare:dev": "yarn run build",
|
||||
"prepare:test": "yarn run build"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@k8slens/extensions": "6.4.0-beta.13",
|
||||
"@types/node": "16",
|
||||
"rimraf": "^4.1.2",
|
||||
"ts-loader": "^9.4.2",
|
||||
"ts-node": "^10.9.1",
|
||||
"typescript": "^4.9.5",
|
||||
"webpack": "^5.75.0",
|
||||
"webpack-cli": "^5.0.1"
|
||||
}
|
||||
}
|
||||
11
packages/sample-extension/renderer.tsx
Normal file
11
packages/sample-extension/renderer.tsx
Normal file
@ -0,0 +1,11 @@
|
||||
import { Renderer } from "@k8slens/extensions";
|
||||
|
||||
export default class extends Renderer.LensExtension {
|
||||
async onActivate() {
|
||||
console.log("Activating @k8slens/sample-extension");
|
||||
}
|
||||
|
||||
async onDeactivate() {
|
||||
console.log("Disabling @k8slens/sample-extension");
|
||||
}
|
||||
}
|
||||
19
packages/sample-extension/tsconfig.json
Normal file
19
packages/sample-extension/tsconfig.json
Normal file
@ -0,0 +1,19 @@
|
||||
{
|
||||
"extends": "../../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "dist/",
|
||||
"paths": {
|
||||
"*": [
|
||||
"node_modules/*",
|
||||
"types/*"
|
||||
]
|
||||
},
|
||||
"declaration": true,
|
||||
},
|
||||
"include": [
|
||||
"*",
|
||||
],
|
||||
"exclude": [
|
||||
"node_modules",
|
||||
]
|
||||
}
|
||||
83
packages/sample-extension/webpack.ts
Normal file
83
packages/sample-extension/webpack.ts
Normal file
@ -0,0 +1,83 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import path from "path";
|
||||
|
||||
export default [
|
||||
{
|
||||
entry: "./renderer.tsx",
|
||||
context: __dirname,
|
||||
target: "electron-renderer",
|
||||
mode: "production",
|
||||
optimization: {
|
||||
minimize: false,
|
||||
},
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: /\.tsx?$/,
|
||||
use: "ts-loader",
|
||||
exclude: /node_modules/,
|
||||
},
|
||||
],
|
||||
},
|
||||
externals: [
|
||||
{
|
||||
"@k8slens/extensions": "var global.LensExtensions",
|
||||
"react": "var global.React",
|
||||
"react-dom": "var global.ReactDOM",
|
||||
"mobx": "var global.Mobx",
|
||||
"mobx-react": "var global.MobxReact",
|
||||
},
|
||||
],
|
||||
resolve: {
|
||||
extensions: [".tsx", ".ts", ".js"],
|
||||
},
|
||||
output: {
|
||||
libraryTarget: "commonjs2",
|
||||
globalObject: "this",
|
||||
filename: "renderer.js",
|
||||
path: path.resolve(__dirname, "dist"),
|
||||
},
|
||||
},
|
||||
{
|
||||
entry: "./main.ts",
|
||||
context: __dirname,
|
||||
target: "electron-main",
|
||||
mode: "production",
|
||||
optimization: {
|
||||
minimize: false,
|
||||
},
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: /\.tsx?$/,
|
||||
use: "ts-loader",
|
||||
exclude: /node_modules/,
|
||||
},
|
||||
],
|
||||
},
|
||||
externals: [
|
||||
{
|
||||
"@k8slens/extensions": "var global.LensExtensions",
|
||||
"react": "var global.React",
|
||||
"react-dom": "var global.ReactDOM",
|
||||
"mobx": "var global.Mobx",
|
||||
"mobx-react": "var global.MobxReact",
|
||||
},
|
||||
],
|
||||
resolve: {
|
||||
extensions: [".tsx", ".ts", ".js"],
|
||||
},
|
||||
output: {
|
||||
libraryTarget: "commonjs2",
|
||||
globalObject: "this",
|
||||
filename: "main.js",
|
||||
path: path.resolve(__dirname, "dist"),
|
||||
},
|
||||
node: {
|
||||
__dirname: false,
|
||||
},
|
||||
},
|
||||
];
|
||||
5017
packages/sample-extension/yarn.lock
Normal file
5017
packages/sample-extension/yarn.lock
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user