@grafana/create-plugin 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -4,11 +4,18 @@ Create Grafana plugins with ease.
4
4
 
5
5
  **ToC**
6
6
 
7
- - [Create a new plugin](#create-a-new-plugin)
8
- - [Migrate your existing plugin](#migrate-your-existing-plugin)
9
- - [Update your plugin build config](#update-your-plugin-build-config)
10
- - [Start developing your plugin](#start-developing-your-plugin)
11
- - [Contributing](#contributing)
7
+ - [Grafana / Create Plugin](#grafana--create-plugin)
8
+ - [Create a new plugin](#create-a-new-plugin)
9
+ - [Quick overview](#quick-overview)
10
+ - [`yarn` (1.x)](#yarn-1x)
11
+ - [`yarn` (> 2.x)](#yarn--2x)
12
+ - [`npx`](#npx)
13
+ - [`npm`](#npm)
14
+ - [Migrate your existing plugin](#migrate-your-existing-plugin)
15
+ - [Things to check after migration](#things-to-check-after-migration)
16
+ - [Update your plugin build config](#update-your-plugin-build-config)
17
+ - [Customizing or extending the basic configs](#customizing-or-extending-the-basic-configs)
18
+ - [Contributing](#contributing)
12
19
 
13
20
  **Links**
14
21
 
@@ -16,46 +23,39 @@ Create Grafana plugins with ease.
16
23
  - [Plugin migration guide](https://grafana.com/docs/grafana/latest/developers/plugins/migration-guide/)
17
24
 
18
25
  **`@grafana/create-plugin`** works on macOS, Windows and Linux.<br />
19
- If something doesnt work, please [file an issue](https://github.com/grafana/create-plugin/issues/new).<br />
26
+ If something doesn't work, please [file an issue](https://github.com/grafana/create-plugin/issues/new).<br />
20
27
  If you have questions or need help, please ask in [GitHub Discussions](https://github.com/grafana/create-plugin/discussions).
21
28
 
22
29
  ## Create a new plugin
23
30
 
24
31
  ### Quick overview
25
32
 
26
- The following commands scaffold a Grafana plugin inside the `./my-plugin` folder:
33
+ Run the command in the folder where you want to store your plugins. The new plugin will be scaffolded in a sub-directory of the folder where you run the command.
27
34
 
28
- ```bash
29
- mkdir my-plugin && cd my-plugin
30
- yarn create @grafana/plugin
31
- yarn install
32
- yarn dev
33
- ```
35
+ You can run the command with the package manager of your choice:
34
36
 
35
- Alterntives:
36
-
37
- #### [`npx`](https://github.com/npm/npx)
37
+ #### [`yarn`](https://classic.yarnpkg.com/blog/2017/05/12/introducing-yarn/) (1.x)
38
38
 
39
39
  ```bash
40
- npx @grafana/create-plugin
40
+ yarn create @grafana/plugin
41
41
  ```
42
42
 
43
- #### [`npm`](https://docs.npmjs.com/cli/v7/commands/npm-init)
43
+ #### [`yarn`](https://yarnpkg.com/cli/dlx) (> 2.x)
44
44
 
45
45
  ```bash
46
- npm init @grafana/plugin
46
+ yarn dlx @grafana/create-plugin
47
47
  ```
48
48
 
49
- #### [`yarn`](https://classic.yarnpkg.com/blog/2017/05/12/introducing-yarn/) (1.x)
49
+ #### [`npx`](https://github.com/npm/npx)
50
50
 
51
51
  ```bash
52
- yarn create @grafana/plugin
52
+ npx @grafana/create-plugin
53
53
  ```
54
54
 
55
- #### [`yarn`](https://yarnpkg.com/cli/dlx) (> 2.x)
55
+ #### [`npm`](https://docs.npmjs.com/cli/v7/commands/npm-init)
56
56
 
57
57
  ```bash
58
- yarn dlx @grafana/create-plugin
58
+ npm init @grafana/plugin
59
59
  ```
60
60
 
61
61
  ---
@@ -97,47 +97,10 @@ npx @grafana/create-plugin update
97
97
 
98
98
  ---
99
99
 
100
- ## Start developing your plugin
101
-
102
- We have put together the following dev scripts for you, so you can start coding right away:
103
-
104
- #### `yarn dev`
105
-
106
- Starts the build in watch mode.
107
- The build output (plugin bundle) is going to be exported to `./dist`.
108
-
109
- #### `yarn build`
110
-
111
- Creates a production build for your plugin.
112
- The build output is going to be exported to `./dist`.
113
-
114
- #### `yarn test`
115
-
116
- Runs the tests under `./src` directory in watch mode.
117
- Give your test files a `.test.tsx` or `.test.ts` extension.
118
-
119
- #### `yarn test:ci`
120
-
121
- Runs the tests and returns with either a zero or a non-zero exit status.
122
-
123
- #### `yarn typecheck`
124
-
125
- Runs the Typescript compiler against the codebase in a dry-run mode to highlight any type errors or warnings.
126
-
127
- #### `yarn lint`
128
-
129
- Runs ESLint against the codebase.
130
-
131
- #### `yarn lint:fix`
132
-
133
- Runs ESLint against the codebase and attempts to fix the simpler errors.
134
-
135
- ---
136
-
137
100
  ## Customizing or extending the basic configs
138
101
 
139
102
  You can read more about customizing or extending the basic configuration [here](templates/common/.config/README.md)
140
103
 
141
104
  ## Contributing
142
105
 
143
- We are always grateful for contribution! See the [CONTRIBUTING.md](./CONTRIBUTING.md) for more information.
106
+ We are always grateful for contribution! See the [CONTRIBUTING.md](../CONTRIBUTING.md) for more information.
package/jest.config.js CHANGED
@@ -1,20 +1,5 @@
1
+ const sharedConfig = require('../../jest.config.base');
1
2
  module.exports = {
2
- testMatch: ['<rootDir>/src/**/*.{spec,test,jest}.{js,jsx,ts,tsx}'],
3
- transform: {
4
- '^.+\\.(t|j)sx?$': [
5
- '@swc/jest',
6
- {
7
- sourceMaps: true,
8
- jsc: {
9
- parser: {
10
- syntax: 'typescript',
11
- tsx: true,
12
- decorators: false,
13
- dynamicImport: true,
14
- },
15
- },
16
- },
17
- ],
18
- },
3
+ ...sharedConfig,
19
4
  modulePathIgnorePatterns: ['<rootDir>/templates/'],
20
5
  };
package/package.json CHANGED
@@ -1,8 +1,11 @@
1
1
  {
2
2
  "name": "@grafana/create-plugin",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "main": "index.js",
5
- "repository": "git@github.com:grafana/create-plugin.git",
5
+ "repository": {
6
+ "directory": "packages/create-plugin",
7
+ "url": "git@github.com:grafana/create-plugin.git"
8
+ },
6
9
  "author": "Grafana",
7
10
  "license": "Apache-2.0",
8
11
  "bin": "./dist/bin/run.js",
@@ -17,42 +20,27 @@
17
20
  "generate-app": "tsc && yarn clean-generated && CREATE_PLUGIN_DEV=true node ./dist/bin/run.js -- create-plugin 'Sample app' 'sample-org' 'This is a sample app.' 'app' 't' 't' 't'",
18
21
  "generate-panel": "tsc && yarn clean-generated && CREATE_PLUGIN_DEV=true node ./dist/bin/run.js -- create-plugin 'Sample panel' 'sample-org' 'This is a sample panel.' 'panel' 't' 't' 't'",
19
22
  "generate-datasource": "tsc && yarn clean-generated && CREATE_PLUGIN_DEV=true node ./dist/bin/run.js -- create-plugin 'Sample datasource' 'sample-org' 'This is a sample datasource.' 'datasource' 't' 't' 't'",
20
- "lint": "eslint --cache --ignore-path ./.gitignore --ext .js,.jsx,.ts,.tsx ./src",
23
+ "lint": "eslint --cache --ext .js,.jsx,.ts,.tsx ./src",
21
24
  "lint:fix": "yarn lint --fix",
22
- "test": "jest --watch",
25
+ "test": "jest",
23
26
  "typecheck": "tsc --noEmit"
24
27
  },
25
28
  "dependencies": {
26
- "@grafana/tsconfig": "^1.2.0-rc1",
27
- "@swc/core": "^1.2.162",
28
29
  "@types/minimist": "^1.2.2",
29
30
  "@types/mkdirp": "^1.0.2",
30
31
  "@types/semver": "^7.3.9",
31
32
  "enquirer": "^2.3.6",
32
33
  "glob": "^7.1.7",
33
- "jest": "^27.5.1",
34
- "marked-terminal": "^5.1.1",
35
34
  "marked": "^4.0.12",
35
+ "marked-terminal": "^5.1.1",
36
36
  "mkdirp": "^1.0.4",
37
37
  "plop": "^2.7.4",
38
38
  "semver": "^7.3.5"
39
39
  },
40
40
  "devDependencies": {
41
- "@grafana/eslint-config": "^2.5.0",
42
- "@swc/jest": "^0.2.20",
43
41
  "@types/glob": "^7.0.0",
44
- "@types/jest": "^27.4.1",
45
- "@typescript-eslint/eslint-plugin": "^4.33.0",
46
- "@typescript-eslint/parser": "^4.33.0",
47
- "eslint": "^7.32.0",
48
- "eslint-config-prettier": "^8.3.0",
49
- "eslint-plugin-jsdoc": "^36.1.0",
50
- "eslint-plugin-prettier": "^4.0.0",
51
42
  "eslint-plugin-react": "^7.26.1",
52
- "eslint-plugin-react-hooks": "^4.2.0",
53
- "nodemon": "^2.0.13",
54
- "tsc-watch": "^4.5.0",
55
- "typescript": "^4.4.3"
43
+ "eslint-plugin-react-hooks": "^4.2.0"
56
44
  },
57
45
  "nodemonConfig": {
58
46
  "watch": [
@@ -109,12 +109,12 @@ We need to update the `scripts` in the `package.json` to use the extended Webpac
109
109
 
110
110
  **Update for `build`:**
111
111
  ```diff
112
- -"build": "TS_NODE_PROJECT=\"./.config/webpack/tsconfig.webpack.json\" webpack -c ./.config/webpack/webpack.config.ts --env production",
113
- +"build": "TS_NODE_PROJECT=\"./.config/webpack/tsconfig.webpack.json\" webpack -c ./webpack.config.ts --env production",
112
+ -"build": "webpack -c ./.config/webpack/webpack.config.ts --env production",
113
+ +"build": "webpack -c ./webpack.config.ts --env production",
114
114
  ```
115
115
 
116
116
  **Update for `dev`:**
117
117
  ```diff
118
- -"dev": "TS_NODE_PROJECT=\"./.config/webpack/tsconfig.webpack.json\" webpack -w -c ./.config/webpack/webpack.config.ts --env development",
119
- +"dev": "TS_NODE_PROJECT=\"./.config/webpack/tsconfig.webpack.json\" webpack -w -c ./webpack.config.ts --env development",
118
+ -"dev": "webpack -w -c ./.config/webpack/webpack.config.ts --env development",
119
+ +"dev": "webpack -w -c ./webpack.config.ts --env development",
120
120
  ```
@@ -12,6 +12,14 @@
12
12
  "typeRoots": ["../node_modules/@types"],
13
13
  "resolveJsonModule": true
14
14
  },
15
+ "ts-node": {
16
+ "compilerOptions": {
17
+ "module": "commonjs",
18
+ "target": "es5",
19
+ "esModuleInterop": true
20
+ },
21
+ "transpileOnly": true
22
+ },
15
23
  "include": ["../src", "./types"],
16
24
  "extends": "@grafana/tsconfig"
17
25
  }
@@ -1,3 +1,7 @@
1
+ // force timezone to UTC to allow tests to work regardless of local timezone
2
+ // generally used by snapshots, but can affect specific tests
3
+ process.env.TZ = 'UTC';
4
+
1
5
  module.exports = {
2
6
  // Jest configuration provided by Grafana scaffolding
3
7
  ...require('./.config/jest.config'),
@@ -3,8 +3,8 @@
3
3
  "version": "1.0.0",
4
4
  "description": "{{ sentenceCase pluginDescription }}",
5
5
  "scripts": {
6
- "build": "TS_NODE_PROJECT=\"./.config/webpack/tsconfig.webpack.json\" webpack -c ./.config/webpack/webpack.config.ts --env production",
7
- "dev": "TS_NODE_PROJECT=\"./.config/webpack/tsconfig.webpack.json\" webpack -w -c ./.config/webpack/webpack.config.ts --env development",
6
+ "build": "webpack -c ./.config/webpack/webpack.config.ts --env production",
7
+ "dev": "webpack -w -c ./.config/webpack/webpack.config.ts --env development",
8
8
  "test": "jest --watch --onlyChanged",
9
9
  "test:ci": "jest --maxWorkers 4",
10
10
  "typecheck": "tsc --noEmit",
@@ -120,10 +120,10 @@ jobs:
120
120
  - name: Lint plugin
121
121
  run: |
122
122
  git clone https://github.com/grafana/plugin-validator
123
- pushd ./plugin-validator/cmd/plugincheck
123
+ pushd ./plugin-validator/pkg/cmd/plugincheck2
124
124
  go install
125
125
  popd
126
- plugincheck $\{{ steps.metadata.outputs.archive }}
126
+ plugincheck2 -config ./plugin-validator/config/publishing.yaml $\{{ steps.metadata.outputs.archive }}
127
127
 
128
128
  - name: Create release
129
129
  id: create_release
package/tsconfig.json CHANGED
@@ -1,17 +1,8 @@
1
1
  {
2
2
  "compilerOptions": {
3
- "esModuleInterop": true,
4
- "removeComments": true,
5
- "preserveConstEnums": true,
6
- "outDir": "./dist",
7
- "noImplicitAny": true,
8
- "noImplicitReturns": true,
9
- "noImplicitThis": true,
10
- "noUnusedLocals": true,
11
- "pretty": true,
12
- "forceConsistentCasingInFileNames": true,
13
- "allowSyntheticDefaultImports": true,
3
+ "outDir": "./dist"
14
4
  },
15
- "include": ["src"],
16
5
  "exclude": ["node_modules", "templates"],
17
- }
6
+ "extends": "../../tsconfig.base.json",
7
+ "include": ["src"]
8
+ }
package/.eslintrc DELETED
@@ -1,6 +0,0 @@
1
- {
2
- "extends": ["@grafana/eslint-config"],
3
- "rules": {
4
- "react/prop-types": "off"
5
- }
6
- }
@@ -1,49 +0,0 @@
1
- on:
2
- push:
3
- tags:
4
- - 'v*'
5
-
6
- name: Create Release
7
-
8
- jobs:
9
- publish:
10
- name: Publish to npm
11
- runs-on: ubuntu-latest
12
- steps:
13
- - uses: actions/checkout@v2
14
-
15
- - name: Setup environment
16
- uses: actions/setup-node@v2.5.1
17
- with:
18
- node-version: '16'
19
- registry-url: 'https://registry.npmjs.org'
20
- cache: 'yarn'
21
-
22
- - name: Install dependencies
23
- run: yarn install --immutable
24
-
25
- - name: Build package
26
- run: yarn build
27
-
28
- - name: Publish
29
- run: npm publish --access public
30
- env:
31
- NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
32
-
33
- create-github-release:
34
- name: Create GitHub Release
35
- runs-on: ubuntu-latest
36
- needs: publish
37
- steps:
38
- - name: Checkout code
39
- uses: actions/checkout@v3
40
-
41
- - name: Create Release Notes
42
- uses: actions/github-script@v4.0.2
43
- with:
44
- github-token: ${{secrets.GH_BOT_ACCESS_TOKEN}}
45
- script: |
46
- await github.request(`POST /repos/${{ github.repository }}/releases`, {
47
- tag_name: "${{ github.ref }}",
48
- generate_release_notes: true
49
- });
@@ -1,51 +0,0 @@
1
- name: NPM bump version
2
-
3
- on:
4
- workflow_dispatch:
5
- inputs:
6
- version:
7
- description: 'Semver type of new version (major / minor / patch)'
8
- required: true
9
- type: choice
10
- options:
11
- - patch
12
- - minor
13
- - major
14
-
15
- jobs:
16
- bump-version:
17
- runs-on: ubuntu-latest
18
-
19
- steps:
20
- - uses: actions/checkout@v3
21
- with:
22
- token: ${{ secrets.GH_BOT_ACCESS_TOKEN }}
23
-
24
- - name: Setup environment
25
- uses: actions/setup-node@v3.1.1
26
- with:
27
- node-version: '16'
28
- cache: 'yarn'
29
-
30
- - name: Install dependencies
31
- run: yarn install --immutable
32
-
33
- - name: Check types
34
- run: yarn typecheck
35
-
36
- - name: Lint
37
- run: yarn lint
38
-
39
- - name: Unit tests
40
- run: yarn jest
41
-
42
- - name: Setup Git
43
- run: |
44
- git config user.name 'grafanabot'
45
- git config user.email 'bot@grafana.com'
46
-
47
- - name: bump version
48
- run: npm version ${{ github.event.inputs.version }}
49
-
50
- - name: Push latest version
51
- run: git push origin main --follow-tags
@@ -1,31 +0,0 @@
1
- name: test
2
- on: push
3
-
4
- jobs:
5
- test:
6
- runs-on: ubuntu-latest
7
- name: Run unit tests
8
- steps:
9
- - name: Checkout repository
10
- uses: actions/checkout@v2
11
- with:
12
- ref: ${{ github.ref }}
13
- - name: Setup .npmrc file for NPM registry
14
- uses: actions/setup-node@v2
15
- with:
16
- node-version: '16'
17
- registry-url: 'https://registry.npmjs.org'
18
- - name: Install dependencies
19
- run: yarn
20
- - name: Check types
21
- run: yarn typecheck
22
- - name: Lint
23
- run: yarn lint
24
- - name: Unit tests
25
- run: yarn jest
26
- - name: test an app plugin generation
27
- run: yarn generate-app && (cd generated && yarn && yarn build && yarn lint)
28
- - name: test panel plugin generation
29
- run: yarn generate-panel && (cd generated && yarn && yarn build && yarn lint)
30
- - name: test datasource plugin generation
31
- run: yarn generate-datasource && (cd generated && yarn && yarn build && yarn lint)
package/.prettierrc DELETED
@@ -1,10 +0,0 @@
1
- {
2
- "endOfLine": "auto",
3
- "printWidth": 120,
4
- "trailingComma": "es5",
5
- "semi": true,
6
- "jsxSingleQuote": false,
7
- "singleQuote": true,
8
- "useTabs": false,
9
- "tabWidth": 2
10
- }
package/CONTRIBUTING.md DELETED
@@ -1,42 +0,0 @@
1
- # Contributing to Grafana / Create Plugin
2
-
3
- We are always grateful to receive contribution!<br />
4
- The following guidelines help you on how to start with the codebase and how to submit your work.
5
-
6
- ## Installation
7
-
8
- ### Prerequisites
9
-
10
- You need to have `npm` or `yarn` installed.
11
-
12
- ### Installing
13
-
14
- ```bash
15
- git clone git@github.com:grafana/create-plugin.git
16
- cd create-plugin
17
- yarn install
18
- ```
19
-
20
- ## Overview
21
-
22
- ### Technologies
23
-
24
- - [**`Plop`**](https://github.com/plopjs/plop) - we are using Plop for the CLI tool and for scaffolding
25
-
26
- ### Folder structure
27
-
28
- _Work in progress._
29
-
30
- ## Development
31
-
32
- ### Conventions
33
-
34
- _Work in progress._
35
-
36
- ### Developing the templates
37
-
38
- _Work in progress._
39
-
40
- ### Submitting a Pull Request
41
-
42
- _Work in progress._
package/docs/example.mp4 DELETED
Binary file
@@ -1,9 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "module": "commonjs",
4
- "target": "es5",
5
- "esModuleInterop": true
6
- },
7
- "transpileOnly": true,
8
- "transpiler": "ts-node/transpilers/swc-experimental"
9
- }