lensapp / lens

Lens - The way the world runs Kubernetes
https://k8slens.dev/
MIT License
22.53k stars 1.47k forks source link

Document using Lens dev build for developing extensions #1291

Open stefcameron opened 3 years ago

stefcameron commented 3 years ago

I define main.ts like this:

import { LensMainExtension, windowManager } from '@k8slens/extensions';
import { getAddUrl } from './routes';

export default class ExtensionMain extends LensMainExtension {
  appMenus = [
    {
      parentId: 'file',
      label: 'foo',                    // <- menu item label
      click() {
        windowManager.navigate(getAddUrl());
      },
    },
  ];
}

Lens loads and adds a "File > foo" item.

If I then update my code to this:

      parentId: 'file',
      label: 'bar',                    // <- menu item label CHANGED
      click() {

and reload Lens with CMD+R, the menu item is still "foo".

I have to kill the Lens process (if I started with DEBUG=true /Applications/Lens.app/Contents/MacOS/Lens) or quit/restart Lens in order to see the updated menu item label.

Version: 4.0.0-alpha.4

ixrock commented 3 years ago

@stefcameron CMD+R doesn't reload electron's main process, you must restart lens. I would recommend you to develop extensions with Lens-dev version where if main process part is changed the app will be restarted automatically.

stefcameron commented 3 years ago

@stefcameron CMD+R doesn't reload electron's main process, you must restart lens. I would recommend you to develop extensions with Lens-dev version where if main process part is changed the app will be restarted automatically.

Thank you! This should be documented, then, alongside the information about the appMenus extension point.

Nokel81 commented 3 years ago

The appMenu's are already documented https://docs.k8slens.dev/latest/extensions/guides/main-extension/#appmenus

But I have updated the title to reflect that the extension development guide should probably mention make dev on the Lens side.

stefcameron commented 3 years ago

The appMenu's are already documented https://docs.k8slens.dev/latest/extensions/guides/main-extension/#appmenus

It doesn't mention having to completely quit Lens and re-open in order to see updates to code that runs in the main process that were may while Lens was running. That's the point here.

But I have updated the title to reflect that the extension development guide should probably mention make dev on the Lens side.

I don't think it's correct to re-title this issue. The docs only mention, "Note that this is the only UI feature that the Main Extension API allows you to customize." But that doesn't tell me that nothing I change that's related to the main process will update until I quit/restart (or kill make dev on the Lens side and run make dev again).

jstrachan commented 3 years ago

@ixrock anyone ever found how to get an extension to also run Lens-dev and reload everything on source change? this would really improve the ability to create extensions nicely