Skip to content

Commit

Permalink
updates to latest create-plugin (#90)
Browse files Browse the repository at this point in the history
* updates to latest create-plugin

* update yarn

* debug release
  • Loading branch information
briangann authored Oct 18, 2023
1 parent df7154a commit 7578172
Show file tree
Hide file tree
Showing 9 changed files with 975 additions and 945 deletions.
2 changes: 1 addition & 1 deletion .config/.eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* In order to extend the configuration follow the steps in
* https://grafana.com/developers/plugin-tools/create-a-plugin/extend-a-plugin/extend-configurations#extend-the-eslint-config
*/
{
{
"extends": ["@grafana/eslint-config"],
"root": true,
"rules": {
Expand Down
18 changes: 9 additions & 9 deletions .config/.prettierrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
*/

module.exports = {
"endOfLine": "auto",
"printWidth": 120,
"trailingComma": "es5",
"semi": true,
"jsxSingleQuote": false,
"singleQuote": true,
"useTabs": false,
"tabWidth": 2
};
endOfLine: 'auto',
printWidth: 120,
trailingComma: 'es5',
semi: true,
jsxSingleQuote: false,
singleQuote: true,
useTabs: false,
tabWidth: 2,
};
6 changes: 3 additions & 3 deletions .config/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ set up the Jest DOM for the testing library and to apply some polyfills. ([link

#### ESM errors with Jest

A common issue found with the current jest config involves importing an npm package which only offers an ESM build. These packages cause jest to error with `SyntaxError: Cannot use import statement outside a module`. To work around this we provide a list of known packages to pass to the `[transformIgnorePatterns](https://jestjs.io/docs/configuration#transformignorepatterns-arraystring)` jest configuration property. If need be this can be extended in the following way:
A common issue with the current jest config involves importing an npm package that only offers an ESM build. These packages cause jest to error with `SyntaxError: Cannot use import statement outside a module`. To work around this, we provide a list of known packages to pass to the `[transformIgnorePatterns](https://jestjs.io/docs/configuration#transformignorepatterns-arraystring)` jest configuration property. If need be, this can be extended in the following way:

```javascript
process.env.TZ = 'UTC';
Expand Down Expand Up @@ -142,7 +142,7 @@ We need to update the `scripts` in the `package.json` to use the extended Webpac

### Configure grafana image to use when running docker

By default `grafana-enterprise` will be used as the docker image for all docker related commands. If you want to override this behaviour simply alter the `docker-compose.yaml` by adding the following build arg `grafana_image`.
By default, `grafana-enterprise` will be used as the docker image for all docker related commands. If you want to override this behavior, simply alter the `docker-compose.yaml` by adding the following build arg `grafana_image`.

**Example:**

Expand All @@ -159,6 +159,6 @@ services:
grafana_image: ${GRAFANA_IMAGE:-grafana}
```
In this example we are assigning the environment variable `GRAFANA_IMAGE` to the build arg `grafana_image` with a default value of `grafana`. This will give you the possibility to set the value while running the docker-compose commands which might be convinent in some scenarios.
In this example, we assign the environment variable `GRAFANA_IMAGE` to the build arg `grafana_image` with a default value of `grafana`. This will allow you to set the value while running the docker-compose commands, which might be convenient in some scenarios.

---
2 changes: 1 addition & 1 deletion .config/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* In order to extend the configuration follow the steps in
* https://grafana.com/developers/plugin-tools/create-a-plugin/extend-a-plugin/extend-configurations#extend-the-typescript-config
*/
{
{
"compilerOptions": {
"alwaysStrict": true,
"declaration": false,
Expand Down
7 changes: 3 additions & 4 deletions .config/webpack/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@ import fs from 'fs';
import process from 'process';
import os from 'os';
import path from 'path';
import util from 'util';
import { glob } from 'glob';
import { SOURCE_DIR } from './constants';


export function isWSL() {
if (process.platform !== 'linux') {
return false;
Expand All @@ -21,7 +19,7 @@ export function isWSL() {
} catch {
return false;
}
}
}

export function getPackageJson() {
return require(path.resolve(process.cwd(), 'package.json'));
Expand All @@ -40,7 +38,8 @@ export function hasReadme() {
export async function getEntries(): Promise<Record<string, string>> {
const pluginsJson = await glob('**/src/**/plugin.json', { absolute: true });

const plugins = await Promise.all(pluginsJson.map((pluginJson) => {
const plugins = await Promise.all(
pluginsJson.map((pluginJson) => {
const folder = path.dirname(pluginJson);
return glob(`${folder}/module.{ts,tsx,js,jsx}`, { absolute: true });
})
Expand Down
16 changes: 8 additions & 8 deletions .config/webpack/webpack.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ const config = async (env): Promise<Configuration> => {
loader: 'swc-loader',
options: {
jsc: {
baseUrl: './src',
baseUrl: path.resolve(__dirname, 'src'),
target: 'es2015',
loose: false,
parser: {
Expand All @@ -97,7 +97,7 @@ const config = async (env): Promise<Configuration> => {
},
{
test: /\.css$/,
use: ["style-loader", "css-loader"]
use: ['style-loader', 'css-loader'],
},
{
test: /\.s[ac]ss$/,
Expand Down Expand Up @@ -135,7 +135,8 @@ const config = async (env): Promise<Configuration> => {
type: 'amd',
},
path: path.resolve(process.cwd(), DIST_DIR),
publicPath: '/',
publicPath: `public/plugins/${pluginJson.id}/`,
uniqueName: pluginJson.id,
},

plugins: [
Expand Down Expand Up @@ -197,17 +198,16 @@ const config = async (env): Promise<Configuration> => {
modules: [path.resolve(process.cwd(), 'src'), 'node_modules'],
unsafeCache: true,
},
}
};

if(isWSL()) {
if (isWSL()) {
baseConfig.watchOptions = {
poll: 3000,
ignored: /node_modules/,
}}

};
}

return baseConfig;

};

export default config;
8 changes: 7 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,13 @@ jobs:
echo "path=release_notes.md" >> $GITHUB_OUTPUT
- name: Check package version
run: if [ "v$\{{ steps.metadata.outputs.plugin-version }}" != "$\{{ steps.metadata.outputs.github-tag }}" ]; then printf "\033[0;31mPlugin version doesn't match tag name\033[0m\n"; exit 1; fi
run: |
if [ "v$\{{ steps.metadata.outputs.plugin-version }}" != "$\{{ steps.metadata.outputs.github-tag }}" ]; then
printf "\033[0;31mPlugin version doesn't match tag name\033[0m\n";
printf "metadata version: v$\{{ steps.metadata.outputs.plugin-version }}";
printf "github-tag version: v$\{{ steps.metadata.outputs.github-tag }}";
exit 1;
fi
- name: Package plugin
id: package-plugin
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"@grafana/e2e-selectors": "10.1.2",
"@grafana/eslint-config": "6.0.1",
"@grafana/tsconfig": "^1.3.0-rc1",
"@swc/core": "1.3.75",
"@swc/core": "^1.3.90",
"@swc/helpers": "^0.5.0",
"@swc/jest": "^0.2.26",
"@testing-library/jest-dom": "^5.16.5",
Expand Down
Loading

0 comments on commit 7578172

Please sign in to comment.