grafana / plugin-tools

Create Grafana plugins with ease.
https://grafana.com/developers/plugin-tools/
Apache License 2.0
58 stars 32 forks source link

Bug: Generated templates doesn't include mock for react-inline-svg for @grafana/ui #189

Closed yesoreyeram closed 1 year ago

yesoreyeram commented 1 year ago

Package Name

create-plugin

What happened?

when using create-plugin it doesn't include the mock for react-inline-svg component defined here.

https://github.com/grafana/plugin-tools/blob/648d226cd34cecfaf840b26afe86166d29b9bf57/packages/create-plugin/templates/common/.config/jest.config.js#L11-L14

image

What you expected to happen

mock for react-inline-svg should be included in the config generated

How to reproduce it (as minimally and precisely as possible)

npx @grafana/create-plugin       
? What is going to be the name of your plugin? something
? What is the organization name of your plugin? yesoreyeram
? How would you describe your plugin? some nice thing
? What kind of plugin would you like?  datasource
? Do you want a backend part of your plugin? Yes
? Do you want to add Github CI and Release workflows? No

cat yesoreyeram-something-datasource/.config/jest.config.js

Environment

System:
    OS: macOS 13.0.1
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
    Memory: 645.56 MB / 16.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 16.16.0 - /usr/local/bin/node
    Yarn: 1.22.19 - ~/.yarn/bin/yarn
    npm: 9.3.1 - /usr/local/bin/npm
  Browsers:
    Chrome: 109.0.5414.87
    Firefox: 108.0.2
    Safari: 16.1

Additional context

No response

jackw commented 1 year ago

Try as I might I cannot reproduce this issue locally. Looking at the prompts and screenshots suggests you're using an older version of create-plugin. Is it possible you installed it globally and npx is picking it up from there? Alternatively I think npx caches things in ls $(npm config get cache)/_npx.

A quick way to test if it's an environment issue or a bug in the code would be to do npx @grafana/create-plugin@0.9.0 and see if it continues to happen.

Here's the output from my runs locally. The react-inlinesvg.tsx mock is mentioned in the list of scaffolded files:

jackwestbrook@Jack's Macbook > ~/Sandbox/plugin-tools-tests > npx @grafana/create-plugin
? What is going to be the name of your plugin? something
? What is the organization name of your plugin? yesoreyeram
? How would you describe your plugin? some nice thing
? What type of plugin would you like? datasource
? Do you want a backend part of your plugin? Yes
? Do you want to add Github CI and Release workflows? No
? Do you want to add a Github workflow for automatically checking "Grafana API compatibility" on PRs? No
✔  ++ /Users/jackwestbrook/Sandbox/plugin-tools-tests/yesoreyeram-something-datasource/go.mod
✔  ++ /Users/jackwestbrook/Sandbox/plugin-tools-tests/yesoreyeram-something-datasource/go.sum
✔  ++ /Users/jackwestbrook/Sandbox/plugin-tools-tests/yesoreyeram-something-datasource/Magefile.go
✔  ++ /Users/jackwestbrook/Sandbox/plugin-tools-tests/yesoreyeram-something-datasource/pkg/main.go
✔  ++ /Users/jackwestbrook/Sandbox/plugin-tools-tests/yesoreyeram-something-datasource/pkg/plugin/datasource_test.go
✔  ++ /Users/jackwestbrook/Sandbox/plugin-tools-tests/yesoreyeram-something-datasource/pkg/plugin/datasource.go
✔  ++ /Users/jackwestbrook/Sandbox/plugin-tools-tests/yesoreyeram-something-datasource/src/datasource.ts
✔  ++ /Users/jackwestbrook/Sandbox/plugin-tools-tests/yesoreyeram-something-datasource/README.md
✔  ++ /Users/jackwestbrook/Sandbox/plugin-tools-tests/yesoreyeram-something-datasource/src/components/ConfigEditor.tsx
✔  ++ /Users/jackwestbrook/Sandbox/plugin-tools-tests/yesoreyeram-something-datasource/src/components/QueryEditor.tsx
✔  ++ /Users/jackwestbrook/Sandbox/plugin-tools-tests/yesoreyeram-something-datasource/src/module.ts
✔  ++ /Users/jackwestbrook/Sandbox/plugin-tools-tests/yesoreyeram-something-datasource/src/plugin.json
✔  ++ /Users/jackwestbrook/Sandbox/plugin-tools-tests/yesoreyeram-something-datasource/src/types.ts
✔  ++ /Users/jackwestbrook/Sandbox/plugin-tools-tests/yesoreyeram-something-datasource/.config/.eslintrc
✔  ++ /Users/jackwestbrook/Sandbox/plugin-tools-tests/yesoreyeram-something-datasource/.config/.prettierrc.js
✔  ++ /Users/jackwestbrook/Sandbox/plugin-tools-tests/yesoreyeram-something-datasource/.config/Dockerfile
✔  ++ /Users/jackwestbrook/Sandbox/plugin-tools-tests/yesoreyeram-something-datasource/.config/jest-setup.js
✔  ++ /Users/jackwestbrook/Sandbox/plugin-tools-tests/yesoreyeram-something-datasource/.config/jest.config.js
✔  ++ /Users/jackwestbrook/Sandbox/plugin-tools-tests/yesoreyeram-something-datasource/.config/jest/mocks/react-inlinesvg.tsx
✔  ++ /Users/jackwestbrook/Sandbox/plugin-tools-tests/yesoreyeram-something-datasource/.config/jest/utils.js
✔  ++ /Users/jackwestbrook/Sandbox/plugin-tools-tests/yesoreyeram-something-datasource/.config/README.md
✔  ++ /Users/jackwestbrook/Sandbox/plugin-tools-tests/yesoreyeram-something-datasource/.config/tsconfig.json
✔  ++ /Users/jackwestbrook/Sandbox/plugin-tools-tests/yesoreyeram-something-datasource/.config/types/custom.d.ts
✔  ++ /Users/jackwestbrook/Sandbox/plugin-tools-tests/yesoreyeram-something-datasource/.config/webpack/constants.ts
✔  ++ /Users/jackwestbrook/Sandbox/plugin-tools-tests/yesoreyeram-something-datasource/.config/webpack/utils.ts
✔  ++ /Users/jackwestbrook/Sandbox/plugin-tools-tests/yesoreyeram-something-datasource/.config/webpack/webpack.config.ts
✔  ++ /Users/jackwestbrook/Sandbox/plugin-tools-tests/yesoreyeram-something-datasource/.eslintrc
✔  ++ /Users/jackwestbrook/Sandbox/plugin-tools-tests/yesoreyeram-something-datasource/.nvmrc
✔  ++ /Users/jackwestbrook/Sandbox/plugin-tools-tests/yesoreyeram-something-datasource/.prettierrc.js
✔  ++ /Users/jackwestbrook/Sandbox/plugin-tools-tests/yesoreyeram-something-datasource/CHANGELOG.md
✔  ++ /Users/jackwestbrook/Sandbox/plugin-tools-tests/yesoreyeram-something-datasource/cypress/integration/01-smoke.spec.ts
✔  ++ /Users/jackwestbrook/Sandbox/plugin-tools-tests/yesoreyeram-something-datasource/docker-compose.yaml
✔  ++ /Users/jackwestbrook/Sandbox/plugin-tools-tests/yesoreyeram-something-datasource/.gitignore
✔  ++ /Users/jackwestbrook/Sandbox/plugin-tools-tests/yesoreyeram-something-datasource/jest-setup.js
✔  ++ /Users/jackwestbrook/Sandbox/plugin-tools-tests/yesoreyeram-something-datasource/jest.config.js
✔  ++ /Users/jackwestbrook/Sandbox/plugin-tools-tests/yesoreyeram-something-datasource/LICENSE
✔  ++ /Users/jackwestbrook/Sandbox/plugin-tools-tests/yesoreyeram-something-datasource/package.json
✔  ++ /Users/jackwestbrook/Sandbox/plugin-tools-tests/yesoreyeram-something-datasource/src/img/logo.svg
✔  ++ /Users/jackwestbrook/Sandbox/plugin-tools-tests/yesoreyeram-something-datasource/src/module.test.ts
✔  ++ /Users/jackwestbrook/Sandbox/plugin-tools-tests/yesoreyeram-something-datasource/src/README.md
✔  ++ /Users/jackwestbrook/Sandbox/plugin-tools-tests/yesoreyeram-something-datasource/tsconfig.json
✔  +- /Users/jackwestbrook/Sandbox/plugin-tools-tests/yesoreyeram-something-datasource/README.md
✔  +- /Users/jackwestbrook/Sandbox/plugin-tools-tests/yesoreyeram-something-datasource/README.md
✔  +- /Users/jackwestbrook/Sandbox/plugin-tools-tests/yesoreyeram-something-datasource/README.md
✔  printSuccessMessage Congratulations on scaffolding a Grafana datasource plugin! 🚀

## What's next?

Run the following commands to get started:

    * cd ./yesoreyeram-something-datasource
    * yarn install to install frontend dependencies.
    * yarn dev to build (and watch) the plugin frontend code.
    * mage -v build:linux to build the plugin backend code. Rerun this command every time you edit your backend files.
    * docker-compose up to start a grafana development server. Restart this command after each time you run mage to run your new backend code.
    * Open http://localhost:3000 in your browser to create a dashboard to begin developing your plugin.

Note: We strongly recommend creating a new Git repository by running git init in ./yesoreyeram-something-datasource before continuing.

    * View create-plugin documentation at https://grafana.github.io/plugin-tools/
    * Learn more about Grafana Plugins at https://grafana.com/docs/grafana/latest/plugins/developing/development/
yesoreyeram commented 1 year ago

yes it was the local version installed. 😞

image

so npx @grafana/create-plugin@0.9.0 fix the issue. Sorry for the inconvenience.