mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Add generator docs
Signed-off-by: Hung-Han (Henry) Chen <1474479+chenhunghan@users.noreply.github.com>
This commit is contained in:
parent
3197e3a1fe
commit
f0bdcd366d
65
docs/extensions/get-started/generator.md
Normal file
65
docs/extensions/get-started/generator.md
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
# New Extension Project with Generator
|
||||||
|
|
||||||
|
The [Lens Extension Generator](https://github.com/lensapp/generator-lens-ext) scaffolds a project ready for development. Install Yeoman and Lens Extension Generator with:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm install -g yo generator-lens-ext
|
||||||
|
```
|
||||||
|
|
||||||
|
Run the generator and fill out a few fields for a TypeScript project:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
yo lens-ext
|
||||||
|
# ? What type of extension do you want to create? New Extension (TypeScript)
|
||||||
|
# ? What's the name of your extension? my-first-lens-ext
|
||||||
|
# ? What's the description of your extension? My hello world extension
|
||||||
|
# ? What's your extension's publisher name? @my-org/my-first-lens-ext
|
||||||
|
# ? Initialize a git repository? Yes
|
||||||
|
# ? Install dependencies after initialization? Yes
|
||||||
|
# ? Which package manager to use? yarn
|
||||||
|
# ? symlink created extension folder to ~/.k8slens/extensions (mac/linux) or :User
|
||||||
|
s<user>.k8slensextensions (win)? Yes
|
||||||
|
```
|
||||||
|
|
||||||
|
Start webpack, which watches the `my-first-lens-ext` folder.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd my-first-lens-ext
|
||||||
|
npm start # start the webpack server in watch mode
|
||||||
|
```
|
||||||
|
|
||||||
|
Then, open Lens, you should see a Hello World item in the menu:
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
## Developing the Extension
|
||||||
|
|
||||||
|
Try to change `my-first-lens-ext/renderer.tsx` to "Hello Lens!":
|
||||||
|
|
||||||
|
```tsx
|
||||||
|
clusterPageMenus = [
|
||||||
|
{
|
||||||
|
target: { pageId: "hello" },
|
||||||
|
title: "Hello Lens",
|
||||||
|
components: {
|
||||||
|
Icon: ExampleIcon,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
```
|
||||||
|
|
||||||
|
Then, Reload Lens by CMD+R (Mac) / Ctrl+R (Linux/Windows), you should see the menu item text changes:
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
## Debugging the Extension
|
||||||
|
|
||||||
|
[Testing](../testing-and-publishing/testing.md)
|
||||||
|
|
||||||
|
## Next steps
|
||||||
|
|
||||||
|
You can take a closer look at [Common Capabilities](../capabilities/common-capabilities.md) of extension, how to [style](../capabilities/styling.md) the extension. Or the [Extension Anatomy](anatomy.md).
|
||||||
|
|
||||||
|
Welcome to to raise an [issue](https://github.com/lensapp/generator-lens-ext/issues) for Lens Extension Generator, if you find problems, or have feature requests.
|
||||||
|
|
||||||
|
The source code of the generator is hosted at [Github](https://github.com/lensapp/generator-lens-ext)
|
||||||
BIN
docs/extensions/get-started/images/hello-lens.png
Normal file
BIN
docs/extensions/get-started/images/hello-lens.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 60 KiB |
BIN
docs/extensions/get-started/images/hello-world.png
Normal file
BIN
docs/extensions/get-started/images/hello-world.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 62 KiB |
@ -1,5 +1,11 @@
|
|||||||
# Your First Extension
|
# Your First Extension
|
||||||
|
|
||||||
|
We recommend to always use [Yeoman generator for Lens Extension](https://github.com/lensapp/generator-lens-ext) to start new extension project. [Read the generator guide here](generator.md).
|
||||||
|
|
||||||
|
If you want to setup the project manually, please continue reading.
|
||||||
|
|
||||||
|
## First Extension
|
||||||
|
|
||||||
In this topic, you'll learn the basics of building extensions by creating an extension that adds a "Hello World" page to a cluster menu.
|
In this topic, you'll learn the basics of building extensions by creating an extension that adds a "Hello World" page to a cluster menu.
|
||||||
|
|
||||||
## Install the Extension
|
## Install the Extension
|
||||||
|
|||||||
@ -22,6 +22,7 @@ nav:
|
|||||||
- Getting Started:
|
- Getting Started:
|
||||||
- Overview: extensions/get-started/overview.md
|
- Overview: extensions/get-started/overview.md
|
||||||
- Your First Extension: extensions/get-started/your-first-extension.md
|
- Your First Extension: extensions/get-started/your-first-extension.md
|
||||||
|
- Generator: extensions/get-started/generator.md
|
||||||
- Extension Anatomy: extensions/get-started/anatomy.md
|
- Extension Anatomy: extensions/get-started/anatomy.md
|
||||||
- Wrapping Up: extensions/get-started/wrapping-up.md
|
- Wrapping Up: extensions/get-started/wrapping-up.md
|
||||||
- Extension Capabilities:
|
- Extension Capabilities:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user