superset icon indicating copy to clipboard operation
superset copied to clipboard

docs: update creating-viz-plugins.mdx

Open visharavana opened this issue 1 year ago • 11 comments

SUMMARY

An error stating that the current environment lacks a feature required by the generator appears while trying to use the Yeoman generator @superset-ui/superset to create a custom Superset plugin. (See #26352)

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

TESTING INSTRUCTIONS

ADDITIONAL INFORMATION

  • [ ] Has associated issue:
  • [ ] Required feature flags:
  • [ ] Changes UI
  • [ ] Includes DB Migration (follow approval process in SIP-59)
    • [ ] Migration is atomic, supports rollback & is backwards-compatible
    • [ ] Confirm DB migration upgrade and downgrade tested
    • [ ] Runtime estimates and downtime expectations provided
  • [ ] Introduces new feature or API
  • [ ] Removes existing feature or API

visharavana avatar Mar 11 '24 05:03 visharavana

Can you please fill out the PR description template?

rusackas avatar Mar 11 '24 18:03 rusackas

Thanks @visharavana for the PR. Could you please complete the PR description? This helps to provide the necessary context to the reviewers.

john-bodley avatar Mar 11 '24 19:03 john-bodley

@rusackas @john-bodley I updated the description. 

visharavana avatar Mar 12 '24 04:03 visharavana

I think it is not quite right and the correct solution is to install yo@4 installed of the latest version. @rusackas @john-bodley @villebro The doc should tell to run :

npm i -g yo@4

but it does not solve everything because @superset-ui/chart-controls and @superset-ui/core on npm.js are out of sync with master on Github.

The command

npm i -g yo

installs version 5.0 of the CLI tool yo.

If you try to scaffold a plugin with this version you get the error:

yo @superset-ui/superset

Error @superset-ui/superset Current environment doesn't provide some necessary feature this generator needs.

And I did not find any way to investigate these lacking "necessary feature".

Reverting to previous version solves the error:

npm i -g yo@4
cd superset-frontend/packages/generator-superset
npm i
npm link

# you get the prompts to create the boilerplate code

If you install the @superset-ui/superset-generator on npmjs.com you'll run into errors eventually.

The blog post says :

It is recommended to use the version of the template that ships with the version of Superset you are using. This can be installed by doing the following

Issue #27496 is most relevant here. https://www.npmjs.com/package/@superset-ui/core and https://www.npmjs.com/package/@superset-ui/chart-controls are out of sync with master on Github. To use the most recent capabilities the workaround is to point to local files, e.g. on my machine:

"@superset-ui/chart-controls": "file:/home/qleroy/superset/superset-frontend/packages/superset-ui-chart-controls",
"@superset-ui/core": "file:/home/qleroy/superset/superset-frontend/packages/superset-ui-core",

but using local files for a custom plugin will prevent it from publishing it to npm.

qleroy avatar Mar 16 '24 08:03 qleroy

Thank you @qleroy that makes sense. @visharavana would you want to update the files/docs accordingly?

We should obviously pay off this debt at some point and either make things compatible with v5, or try a different approach if the generator is too tedious to maintain weill.

rusackas avatar Mar 17 '24 17:03 rusackas

Thank you @qleroy that makes sense. @visharavana would you want to update the files/docs accordingly?

We should obviously pay off this debt at some point and either make things compatible with v5, or try a different approach if the generator is too tedious to maintain weill.

Thank you @rusackas, yes, I want to update the documents. "npm i -g @superset-ui/generator-superset", this is working quite well for me. Instead of any other approaches please try this.

visharavana avatar Mar 19 '24 05:03 visharavana

@visharavana Have you tried

npm i -g yo@4
cd superset-frontend/packages/generator-superset
npm i
npm link

If you install "npm i -g @superset-ui/generator-superset" you should not be able to build the plugin because there is a bug in the template.

If you use

qleroy avatar Mar 19 '24 13:03 qleroy

@visharavana Have you tried

npm i -g yo@4
cd superset-frontend/packages/generator-superset
npm i
npm link

If you install "npm i -g @superset-ui/generator-superset" you should not be able to build the plugin because there is a bug in the template.

If you use

@qleroy Ok, I understand. Thanks for clarifying the bug in the template. 

visharavana avatar Mar 20 '24 04:03 visharavana

@qleroy Hi Quentin,

Thanks for the analysis, I've tried npm i -g yo@4, but still getting the following error: image

Can I upgrade node to 18.x? As per the Superset doc, Node.js version must be 16.

My Superset version is latest, 3.1.1 afaiu (I've installed it via the git clone https://github.com/apache/superset.git).

Thank you.

mvsenin avatar Mar 27 '24 14:03 mvsenin

@mvsenin do you manage to (globally) install any npm package at all? Your error "yodoctor permission denied" means it requires administrative privileges. Your problem should be related to your npm installation.

qleroy avatar Mar 28 '24 11:03 qleroy

Any update on this ?

LuvKaranwal21 avatar Jun 26 '24 15:06 LuvKaranwal21

Hi @qleroy,

Whenever I try to install the generator using the source from the repo I get warnings of multiple packages complaining about an unsupported engine due to the node version. I've tried with node versions 16.20.2, 18.20.4 and 20.11.1 and all the times npm complains about the same but with different packaged depending on which node version I'm using. Should I just ignore those warnings? Which should be the most appropriate node version to use? the docs says to use Node 16 for creating my own plugins, but in the Dockerfile I see that Node 18 is being used to build the superset image. image

Thanks.

dchiang-arkho avatar Aug 07 '24 05:08 dchiang-arkho

This has needed a rebase for quite some time (the files may have shifted around a while back), so I'll convert it to draft for now, and may eventually close it. Holler when it's ready for merge!

rusackas avatar Apr 14 '25 21:04 rusackas