Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create Plugin: Update yarn scripts and instructions to work post scaffold #168

Merged
merged 3 commits into from
Jan 12, 2023

Conversation

sarahzinger
Copy link
Member

@sarahzinger sarahzinger commented Dec 5, 2022

What this PR does / why we need it:
We were recently using the create-plugin module and did some user testing with someone new to plugin development and found a few of the yarn scripts as described in the Getting Started docs were either missing, had typos, or threw non obvious errors

Here is a summary/description changes:

  • removed yarn watch. It looks like yarn dev runs yarn watch and yarn watch is not defined in the package.json that is generated.
  • updated yarn test instructions to mention git init. If you try to run this before running git init you get the error message --watch is not supported without git/hg, please use --watchAll which sort of explains what's going on but it's a bit non intuitive that you need to run git init for yarn test. I suppose an alternative here would be to switch the test command to jest --watchAll not sure which is preferable from a user experience, I suppose it depends on how many tests the average datasource has and how quickly they run. I imagine most are minimally tested and run quickly but I could be mistaken in that belief.
  • update yarn test:ci from yarn lint:ci pretty sure this is just a typo
  • updated yarn test:ci to pass even if there are no tests. While It's really lovely to force testing, if you're new to writing a plugin and just following the commands in the readme to verify you have everything up and running it can be a bit overwhelming to read and easy to think you've done something "wrong" and to know what to do to fix it:
yarn run v1.22.18
$ jest --maxWorkers 4
No tests found, exiting with code 1
Run with `--passWithNoTests` to exit with code 0
In {long path}
  25 files checked.
  testMatch:{{long path}/src/**/__tests__/**/*.{js,jsx,ts,tsx},{long path}/src/**/*.{spec,test,jest}.{js,jsx,ts,tsx}, {long path}/src/**/*.{spec,test,jest}.{js,jsx,ts,tsx} - 0 matches
  testPathIgnorePatterns: /node_modules/ - 25 matches
  testRegex:  - 0 matches
Pattern:  - 0 matches
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

as opposed to

yarn run v1.22.18
$ jest --passWithNoTests --maxWorkers 4
No tests found, exiting with code 0
✨  Done in 0.79s.

is I think clear but still encouraging the user to add some tests when they can.

📦 Published PR as canary version: Canary Versions

✨ Test out this PR locally via:

npm install @grafana/create-plugin@0.8.2-canary.168.6036dd3.0
# or 
yarn add @grafana/create-plugin@0.8.2-canary.168.6036dd3.0

@jackw jackw self-requested a review December 12, 2022 09:33
@jackw jackw added create-plugin related to the create-plugin tool patch Increment the patch version when merged labels Dec 14, 2022
@sarahzinger
Copy link
Member Author

I rebased, but a few questions

  • should dev/watch be separate supported scripts?
  • Also I'm not sure I follow what should be in the docs website vs in the repo if they should contain the same content or not
  • in terms of why the test files are not getting copied over I'm not sure, maybe something with utils.getEntries not picking up test.ts files? I'm not sure I'll have time to investigate right now sadly.

If it's helpful, feel free to take over this pr and do with it what you'd like or close it in favor of other changes! Just wanted to share some stuff we found!

@jackw jackw added the release Create a release when this pr is merged label Jan 11, 2023
@jackw jackw changed the title Updates some of our yarn scripts and instructions so that they work on the first try Create Plugin: Update yarn scripts and instructions to work post scaffold Jan 11, 2023
@jackw
Copy link
Collaborator

jackw commented Jan 11, 2023

If it's helpful, feel free to take over this pr and do with it what you'd like or close it in favor of other changes! Just wanted to share some stuff we found!

Thanks @sarahzinger, again really appreciate you taking the time here. I've updated the bits n pieces I think are required before merging.

I rebased, but a few questions

  • should dev/watch be separate supported scripts?

No, I think you were right in removing the doc references to watch.

  • Also I'm not sure I follow what should be in the docs website vs in the repo if they should contain the same content or not

Right now we're aiming to keep them as aligned as possible whilst we start to drive devs towards the website.

  • in terms of why the test files are not getting copied over I'm not sure, maybe something with utils.getEntries not picking up test.ts files? I'm not sure I'll have time to investigate right now sadly.

We build up a list of files to scaffold based on the common templates, then the templates for the plugin type and finally the backend templates if requested during the scaffolding prompts. Moving the module.test.ts template into the common directory resolves this.

@jackw jackw added the type/docs Changes only affect the documentation label Jan 11, 2023
@jackw jackw requested a review from mckn January 12, 2023 13:29
Copy link
Collaborator

@mckn mckn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@jackw jackw merged commit ad3a168 into main Jan 12, 2023
@jackw jackw deleted the yarn-scripts-fix branch January 12, 2023 13:40
@grafanabot
Copy link
Contributor

🚀 PR was released in @grafana/create-plugin@0.8.3 🚀

@grafanabot grafanabot added the released This issue/pull request has been released. label Jan 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
create-plugin related to the create-plugin tool patch Increment the patch version when merged release Create a release when this pr is merged released This issue/pull request has been released. type/docs Changes only affect the documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants