Skip to content

Commit

Permalink
Merge pull request #70 from ACE-IoT-Solutions/nic
Browse files Browse the repository at this point in the history
Update lockfile
  • Loading branch information
nicfv authored Dec 14, 2024
2 parents 4a6da61 + 2c4221a commit 8e091d2
Show file tree
Hide file tree
Showing 14 changed files with 2,320 additions and 4,015 deletions.
2 changes: 1 addition & 1 deletion .config/.cprc.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"version": "5.3.7"
"version": "5.11.1"
}
6 changes: 6 additions & 0 deletions .config/.eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@
"parserOptions": {
"project": "./tsconfig.json"
}
},
{
"files": ["./tests/**/*"],
"rules": {
"react-hooks/rules-of-hooks": "off"
}
}
]
}
4 changes: 2 additions & 2 deletions .config/jest-setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Object.assign(global, { TextDecoder, TextEncoder });
// https://jestjs.io/docs/manual-mocks#mocking-methods-which-are-not-implemented-in-jsdom
Object.defineProperty(global, 'matchMedia', {
writable: true,
value: jest.fn().mockImplementation((query) => ({
value: (query) => ({
matches: false,
media: query,
onchange: null,
Expand All @@ -22,7 +22,7 @@ Object.defineProperty(global, 'matchMedia', {
addEventListener: jest.fn(),
removeEventListener: jest.fn(),
dispatchEvent: jest.fn(),
})),
}),
});

HTMLCanvasElement.prototype.getContext = () => {};
33 changes: 33 additions & 0 deletions .config/webpack/BuildModeWebpackPlugin.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import * as webpack from 'webpack';

const PLUGIN_NAME = 'BuildModeWebpack';

export class BuildModeWebpackPlugin {
apply(compiler: webpack.Compiler) {
compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => {
compilation.hooks.processAssets.tap(
{
name: PLUGIN_NAME,
stage: webpack.Compilation.PROCESS_ASSETS_STAGE_ADDITIONS,
},
async () => {
const assets = compilation.getAssets();
for (const asset of assets) {
if (asset.name.endsWith('plugin.json')) {
const pluginJsonString = asset.source.source().toString();
const pluginJsonWithBuildMode = JSON.stringify(
{
...JSON.parse(pluginJsonString),
buildMode: compilation.options.mode,
},
null,
4
);
compilation.updateAsset(asset.name, new webpack.sources.RawSource(pluginJsonWithBuildMode));
}
}
}
);
});
}
}
7 changes: 7 additions & 0 deletions .config/webpack/webpack.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ import ForkTsCheckerWebpackPlugin from 'fork-ts-checker-webpack-plugin';
import path from 'path';
import ReplaceInFileWebpackPlugin from 'replace-in-file-webpack-plugin';
import TerserPlugin from 'terser-webpack-plugin';
import { SubresourceIntegrityPlugin } from 'webpack-subresource-integrity';
import { type Configuration, BannerPlugin } from 'webpack';
import LiveReloadPlugin from 'webpack-livereload-plugin';
import VirtualModulesPlugin from 'webpack-virtual-modules';

import { BuildModeWebpackPlugin } from './BuildModeWebpackPlugin';
import { DIST_DIR, SOURCE_DIR } from './constants';
import { getCPConfigVersion, getEntries, getPackageJson, getPluginJson, hasReadme, isWSL } from './utils';

Expand Down Expand Up @@ -180,9 +182,11 @@ const config = async (env): Promise<Configuration> => {
path: path.resolve(process.cwd(), DIST_DIR),
publicPath: `public/plugins/${pluginJson.id}/`,
uniqueName: pluginJson.id,
crossOriginLoading: 'anonymous',
},

plugins: [
new BuildModeWebpackPlugin(),
virtualPublicPath,
// Insert create plugin version information into the bundle
new BannerPlugin({
Expand Down Expand Up @@ -229,6 +233,9 @@ const config = async (env): Promise<Configuration> => {
],
},
]),
new SubresourceIntegrityPlugin({
hashFuncNames: ['sha256'],
}),
...(env.development
? [
new LiveReloadPlugin(),
Expand Down
21 changes: 21 additions & 0 deletions .github/workflows/bundle-stats.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Bundle Stats

on:
pull_request:
branches:
- main

permissions:
contents: write
pull-requests: write
actions: read

jobs:
compare:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- uses: grafana/plugin-actions/bundle-size@main
36 changes: 25 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
- name: Setup Node.js environment
uses: actions/setup-node@v4
with:
node-version: '20'
node-version: '22'
cache: 'npm'

- name: Install dependencies
Expand All @@ -41,7 +41,12 @@ jobs:
- name: Unit tests
run: npm run test:ci
- name: Build frontend
run: npm run build
run: |
if [ "${{ github.event_name }}" == "push" ] && [ "${{ github.ref }}" == "refs/heads/main" ]; then
npm run build -- --profile --json stats.json
else
npm run build
fi
- name: Check for backend
id: check-for-backend
Expand All @@ -55,7 +60,7 @@ jobs:
if: steps.check-for-backend.outputs.has-backend == 'true'
uses: actions/setup-go@v5
with:
go-version: '1.21'
go-version: '1.22'

- name: Test backend
if: steps.check-for-backend.outputs.has-backend == 'true'
Expand Down Expand Up @@ -102,13 +107,27 @@ jobs:
mv dist ${{ steps.metadata.outputs.plugin-id }}
zip ${{ steps.metadata.outputs.archive }} ${{ steps.metadata.outputs.plugin-id }} -r
- name: Check plugin.json
run: |
docker run --pull=always \
-v $PWD/${{ steps.metadata.outputs.archive }}:/archive.zip \
grafana/plugin-validator-cli -analyzer=metadatavalid /archive.zip
- name: Archive Build
uses: actions/upload-artifact@v4
with:
name: ${{ steps.metadata.outputs.plugin-id }}-${{ steps.metadata.outputs.plugin-version }}
path: ${{ steps.metadata.outputs.plugin-id }}
retention-days: 5

- name: Upload stats.json artifact
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
uses: actions/upload-artifact@v4
with:
name: main-branch-stats
path: stats.json
overwrite: true

resolve-versions:
name: Resolve e2e images
runs-on: ubuntu-latest
Expand Down Expand Up @@ -150,7 +169,7 @@ jobs:
- name: Setup Node.js environment
uses: actions/setup-node@v4
with:
node-version: '20'
node-version: '22'
cache: 'npm'

- name: Install dev dependencies
Expand All @@ -161,13 +180,8 @@ jobs:
docker compose pull
DEVELOPMENT=false GRAFANA_VERSION=${{ matrix.GRAFANA_IMAGE.VERSION }} GRAFANA_IMAGE=${{ matrix.GRAFANA_IMAGE.NAME }} docker compose up -d
- name: Wait for Grafana to start
uses: nev7n/wait_for_response@v1
with:
url: 'http://localhost:3000/'
responseCode: 200
timeout: 60000
interval: 500
- name: Wait for grafana server
uses: grafana/plugin-actions/wait-for-grafana@main

- name: Install Playwright Browsers
run: npm exec playwright install chromium --with-deps
Expand Down
26 changes: 26 additions & 0 deletions .github/workflows/cp-update.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Create Plugin Update

on:
workflow_dispatch:
schedule:
- cron: '0 0 1 * *' # run once a month on the 1st day

# To use the default github token with the following elevated permissions make sure to check:
# **Allow GitHub Actions to create and approve pull requests** in https://github.com/ORG_NAME/REPO_NAME/settings/actions.
# Alternatively create a fine-grained personal access token for your repository with
# `contents: read and write` and `pull requests: read and write` and pass it to the action.

permissions:
contents: write
pull-requests: write

jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: grafana/plugin-actions/create-plugin-update@main
# Uncomment to use a fine-grained personal access token instead of default github token
# (For more info on how to generate the token see https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens)
# with:
# Make sure to save the token in your repository secrets
# token: $
2 changes: 1 addition & 1 deletion .github/workflows/is-compatible.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
- name: Setup Node.js environment
uses: actions/setup-node@v4
with:
node-version: '20'
node-version: '22'
cache: 'npm'
- name: Install dependencies
run: npm ci
Expand Down
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

All notable changes to this project will be documented in this file.

## 0.1.5
## Unreleased

- Fix dependabot issues with `ws` and `braces` dependencies
- Fix dependabot issues with dependencies
- `ws`, `braces`, `fast-loops`, `webpack`, `path-to-regexp`

## 0.1.4

Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ services:
context: ./.config
args:
grafana_image: ${GRAFANA_IMAGE:-grafana-enterprise}
grafana_version: ${GRAFANA_VERSION:-11.2.0}
grafana_version: ${GRAFANA_VERSION:-11.3.2}
development: ${DEVELOPMENT:-false}
ports:
- 3000:3000/tcp
Expand Down
Loading

0 comments on commit 8e091d2

Please sign in to comment.