mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Remove docs from lens repo
- Remove all docs apart from extension api auto-generated related docs. All standard Lens IDE docs will now reside in lens-ide repo; - Remove the delete and set-version workflows for the docs. These will now reside in the lens-ide repo; - Amend the existing workflow that builds/publishes the docs to instead create a repository dispatch event to the lens-ide repo. This event will be the trigger for the build/publish docs workflow in lens-ide repo Signed-off-by: Steve Richards <srichards@mirantis.com>
This commit is contained in:
1 parent
5372e3617e
commit
c9c55842da
78 files changed
+14
-3885
No files matched your search
Whitespace-only changes.
@@ -1,46 +0,0 @@
|
||||
# Publishing Extensions
|
||||
|
||||
To be able to easily share extensions with users they need to be published somewhere.
|
||||
Lens currently only supports installing extensions from NPM tarballs.
|
||||
All hosted extensions must, therefore, be retrievable in a NPM tarball.
|
||||
|
||||
## Places To Host Your Extension
|
||||
|
||||
We recommend to host your extension somewhere on the web so that it is easy for people to search for and download it.
|
||||
We recommend either hosting it as an NPM package on https://www.npmjs.com or through GitHub releases.
|
||||
We recommend against using GitHub packages (https://github.com/features/packages) as it requires a GitHub token to access the package.
|
||||
|
||||
### Publishing via NPM
|
||||
|
||||
This is the easiest method of publishing as NPM comes built in with mechanism to get a link to download the package as a tarball.
|
||||
Once you have set up an account with NPM (https://www.npmjs.com/signup) and logged in with their CLI (`npm login`) you will be ready to publish.
|
||||
|
||||
* Run `npm version <major|minor|patch>` to bump the version of your extension by the appropriate amount.
|
||||
* Run `npm publish` to publish your extension to NPM
|
||||
* Run `git push && git push --tags` to push the commit that NPM creates to your git remote.
|
||||
|
||||
It is probably a good idea to put into your README.md the following instructions for your users to get the tarball download link.
|
||||
|
||||
```bash
|
||||
npm view <extension-name> dist.tarball
|
||||
```
|
||||
|
||||
This will output the link that they will need to give to Lens to install your extension.
|
||||
|
||||
### Publish via GitHub Releases
|
||||
|
||||
Another method of publishing your extensions is to do so with the releases mechanism built into GitHub.
|
||||
We recommend reading [GitHub's Releases Documentation](https://docs.github.com/en/free-pro-team@latest/github/administering-a-repository/managing-releases-in-a-repository) for how to actually do the steps of a release.
|
||||
The following will be a quick walk through on how to make the tarball which will be the released file.
|
||||
|
||||
### Making a NPM Tarball of Your Extension
|
||||
|
||||
While this is necessary for hosting on GitHub releases, this is also the means for creating a tarball if you plan on hosting on a different file hosting platform.
|
||||
|
||||
Say you have your project folder at `~/my-extension/` and you want to create an NPM package we need to do the following within your git repo:
|
||||
|
||||
```
|
||||
npm pack
|
||||
```
|
||||
|
||||
This will create a NPM tarball that can be hosted on Github Releases or any other publicly available file hosting service.
|
||||
@@ -1,95 +0,0 @@
|
||||
# Testing Extensions
|
||||
|
||||
## Renderer Process Unit Testing
|
||||
|
||||
UI components in the extension's renderer process are based on React/ReactDOM.
|
||||
These components can be tested by popular React testing tools like [React Testing Library](https://github.com/testing-library/react-testing-library).
|
||||
|
||||
If you are using the [Yeoman Lens Extension Generator](https://github.com/lensapp/generator-lens-ext) to scaffold extension project then the testing environment for render process is already set up for you.
|
||||
Just use `npm start` or `yarn test` to run the tests.
|
||||
|
||||
For example, I have a component `GlobalPageMenuIcon` and want to test if `props.navigate` is called when user clicks the icon.
|
||||
|
||||
My component `GlobalPageMenuIcon`
|
||||
|
||||
```typescript
|
||||
import React from "react"
|
||||
import { Component: { Icon } } from "@k8slens/extensions";
|
||||
|
||||
const GlobalPageMenuIcon = ({ navigate }: { navigate?: () => void }): JSX.Element => (
|
||||
<Icon
|
||||
material="trip_origin"
|
||||
onClick={() => navigate()}
|
||||
data-testid="global-page-menu-icon"
|
||||
/>
|
||||
)
|
||||
```
|
||||
|
||||
The test
|
||||
|
||||
```js
|
||||
import React from "react"
|
||||
import { render, screen, fireEvent } from "@testing-library/react";
|
||||
|
||||
import GlobalPageMenuIcon from "./GlobalPageMenuIcon";
|
||||
|
||||
test("click called navigate()", () => {
|
||||
const navigate = jest.fn();
|
||||
render(<GlobalPageMenuIcon navigate={navigate} />);
|
||||
fireEvent.click(screen.getByTestId("global-page-menu-icon"));
|
||||
expect(navigate).toHaveBeenCalled();
|
||||
});
|
||||
```
|
||||
|
||||
In the example we used [React Testing Library](https://github.com/testing-library/react-testing-library) but any React testing framework can be used to test renderer process UI components.
|
||||
|
||||
There are more example tests in the generator's [template](https://github.com/lensapp/generator-lens-ext/tree/main/generators/app/templates/ext-ts/components).
|
||||
Extend your tests based on the examples.
|
||||
|
||||
## Main Process Unit Testing
|
||||
|
||||
Code in the extension's main process consists of normal JavaScript files that have access to extension api, you can write unit tests using any testing framework.
|
||||
|
||||
If you are using the [Yeoman Lens Extension Generator](https://github.com/lensapp/generator-lens-ext) to scaffold your extension project then the [Jest](https://jestjs.io/) testing environment is set up for you.
|
||||
Just use `npm start` or `yarn test` to run the tests.
|
||||
|
||||
## Tips
|
||||
|
||||
### Console.log
|
||||
|
||||
Extension developers might find `console.log()` useful for printing out information and errors from extensions.
|
||||
To use `console.log()`, note that Lens is based on Electron, and that Electron has two types of processes: [Main and Renderer](https://www.electronjs.org/docs/tutorial/quick-start#main-and-renderer-processes).
|
||||
|
||||
### Renderer Process Logs
|
||||
|
||||
In the Renderer process, `console.log()` is printed in the Console in Developer Tools (**View** > **Toggle Developer Tools**).
|
||||
|
||||
### Main Process Logs
|
||||
|
||||
Viewing the logs from the Main process is a little trickier, since they cannot be printed using Developer Tools.
|
||||
|
||||
#### macOS
|
||||
|
||||
On macOS, view the Main process logs by running Lens from the terminal:
|
||||
|
||||
```bash
|
||||
/Applications/Lens.app/Contents/MacOS/Lens
|
||||
```
|
||||
|
||||
You can also use [Console.app](https://support.apple.com/en-gb/guide/console/welcome/mac) to view the Main process logs.
|
||||
|
||||
#### Linux
|
||||
|
||||
On Linux, you can access the Main process logs using the Lens PID.
|
||||
First get the PID:
|
||||
|
||||
```bash
|
||||
ps aux | grep Lens | grep -v grep
|
||||
```
|
||||
|
||||
Then get the Main process logs using the PID:
|
||||
|
||||
```bash
|
||||
tail -f /proc/[pid]/fd/1 # stdout (console.log)
|
||||
tail -f /proc/[pid]/fd/2 # stdout (console.error)
|
||||
```
|
||||
Reference in new issue
Block a user