Thanks to visit codestin.com
Credit goes to github.com

Skip to content

WIP: Add @grafana/toolkit package #17445

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

Merged
merged 37 commits into from
Jun 28, 2019
Merged

WIP: Add @grafana/toolkit package #17445

merged 37 commits into from
Jun 28, 2019

Conversation

dprokop
Copy link
Member

@dprokop dprokop commented Jun 5, 2019

Introduces @grafana/toolkit package and migrates cli tools there.

TODO:

  • Enable building app/plugin using shared rollup config
  • If there is more than one module.ts entry then add manual chunks
  • Enable running tests on app/plugin
  • Introduce common tsconfig
  • Introduce common tslint config
  • Do not expose internal cli commands
  • Validate plugin name/org
    - OK for plugins in grafana repo to skip the org
  • Run typecheck before linting
  • Add watch option to enable easy development (rollup watch, plugin:[dev|watch])

Currently trying with:

@torkelo
Copy link
Member

torkelo commented Jun 5, 2019

It feels a bit strange to move the big project tasks (theme watching, changelog, cherrypick) to this toolkit package that I thought would be more focused on building & testing plugins.

But maybe mixing these is fine?

@dprokop
Copy link
Member Author

dprokop commented Jun 17, 2019

@ryantxu @torkelo see 4caadbf for first attempt for having shared tsconfig for plugins. I assume that there will be cases when extending tsconfig will be necessary.

According to microsoft/TypeScript#29172 some paths are resolved relatively to tsconfig.json location. For example, if I extend the base config from grafana/toolkit (btw got it working only with such extend: "extends": "./node_modules/@grafana/toolkit/src/config/tsconfig.plugin.json"), then in Ryan's grafana-live-app the absolute imports does not work until I override baseUrl in local tsconfig.json . This sucks a little bit unfortunately, seems like the plugin will have to have tsconfig.json specified anyways.

Another issue is that in order for the IDE to pickup grafana/toolkit tsconfig we need to extend it in the local tsconfig. Couldn't make it work with "extends": "@grafana/toolkit" only, as rollup fails when extendig that config.

FYI for testing purposes use yarn link in grafana toolkit root dir.

@dprokop
Copy link
Member Author

dprokop commented Jun 19, 2019

@torkelo @ryantxu see https://github.com/grafana/rss-panel/pull/1 for grafana-toolkit usage reference. Especially interesting is tsconfig.json. Apparently, all path specific options need to be defined in that file for tsc to pickup correct directories (otherwise paths are resolved relatively to original tsconfig file).

I don't like how the default config is extended though, as it requires either path to node modules (as in the example PR https://github.com/grafana/rss-panel/pull/1/files#diff-e5e546dd2eb0351f813d63d1b39dbc48), or we could also introduce package with default tsconfig for plugin. I don't like this idea though.

But to be honest I think that with any of the approaches we take there will be possibility to override defaults, so maybe we should basically provide a basic tsconfig.json file when we will introduce some plugin boilerplate?

@ryantxu
Copy link
Member

ryantxu commented Jun 27, 2019

I think we should merge this soon even if the plugin build stuff still needs work.

@ryantxu
Copy link
Member

ryantxu commented Jun 27, 2019

@dprokop -- I'm trying to make this work with old plugins like:
https://github.com/grafana/kubernetes-app/tree/using-toolkit

I added the option to use the local tslint.json if it exists, this way plugins could migrate slowly if necessary.

I also added the fix=true flag. We could have a second task, but with git I think autofix is the better behavior

@dprokop
Copy link
Member Author

dprokop commented Jun 28, 2019

@ryantxu I have created #17819 to keep track of the progress/todos

@dprokop dprokop requested a review from torkelo June 28, 2019 11:11
@dprokop dprokop merged commit 742e0d5 into master Jun 28, 2019
@ryantxu ryantxu deleted the grafana-toolkit/cli branch July 8, 2019 17:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants