Skip to content

Commit

Permalink
add remaining plugins, refactor exports and add test and lint commands
Browse files Browse the repository at this point in the history
Signed-off-by: Gabriel Bernal <gabrielbernalp@gmail.com>
  • Loading branch information
jgbernalp committed Jan 15, 2025
1 parent e843f45 commit 45dc2cb
Show file tree
Hide file tree
Showing 240 changed files with 25,434 additions and 6,093 deletions.
20 changes: 20 additions & 0 deletions .cjs.swcrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"$schema": "https://json.schemastore.org/swcrc",
"jsc": {
"parser": {
"syntax": "typescript",
"tsx": true
},
"target": "es2018",
"transform": {
"react": {
"runtime": "automatic",
"useBuiltins": true
}
}
},
"module": {
"type": "commonjs"
},
"exclude": ["\\.(stories|test)\\."]
}
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ module.exports = {
'import/order': 'error',
// you must disable the base rule as it can report incorrect errors
'no-unused-vars': 'off',
'@typescript-eslint/no-unused-vars': ['error'],
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }],

'react/prop-types': 'off',
'react-hooks/exhaustive-deps': 'error',
Expand Down
33 changes: 23 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on:

jobs:
get-schemas-deps:
name: "Get dependencies for plugin schemas"
name: 'Get dependencies for plugin schemas'
runs-on: ubuntu-latest
steps:
- name: checkout
Expand All @@ -22,7 +22,7 @@ jobs:
enable_go: true
- uses: ./.github/perses-ci/actions/install_percli
with:
cli_version: "v0.50.0-rc.0"
cli_version: 'v0.50.0-rc.0'
- run: go run ./scripts/get-schemas-deps/get-schemas-deps.go
- name: store plugin schema dependencies
uses: actions/upload-artifact@v4
Expand All @@ -32,8 +32,8 @@ jobs:
*/cue.mod/pkg
build:
name: "build"
needs: "get-schemas-deps"
name: 'build'
needs: 'get-schemas-deps'
runs-on: ubuntu-latest
steps:
- name: checkout
Expand All @@ -59,7 +59,7 @@ jobs:
!node_modules
lint:
name: "lint"
name: 'lint'
runs-on: ubuntu-latest
steps:
- name: checkout
Expand All @@ -71,9 +71,22 @@ jobs:
- run: npm ci
- run: npm run lint

test:
name: 'test'
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v4
- uses: perses/github-actions@v0.5.2
- uses: ./.github/perses-ci/actions/setup_environment
with:
enable_npm: true
- run: npm ci
- run: npm run test

validate-schemas:
name: "Validate plugin schemas"
needs: "get-schemas-deps"
name: 'Validate plugin schemas'
needs: 'get-schemas-deps'
runs-on: ubuntu-latest
steps:
- name: checkout
Expand All @@ -82,7 +95,7 @@ jobs:
- uses: ./.github/perses-ci/actions/setup_environment
with:
enable_go: true
cue_version: "v0.11.0"
cue_version: 'v0.11.0'
enable_cue: true
- name: retrieve plugin schema dependencies
uses: actions/download-artifact@v4
Expand All @@ -91,8 +104,8 @@ jobs:
- run: go run ./scripts/validate-schemas/validate-schemas.go

release:
name: "release"
needs: "build"
name: 'release'
needs: 'build'
runs-on: ubuntu-latest
permissions:
contents: write
Expand Down
23 changes: 23 additions & 0 deletions BarChart/jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright 2023 The Perses Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

import type { Config } from '@jest/types';
import shared from '../jest.shared';

const jestConfig: Config.InitialOptions = {
...shared,

setupFilesAfterEnv: [...(shared.setupFilesAfterEnv ?? []), '<rootDir>/src/setup-tests.ts'],
};

export default jestConfig;
9 changes: 6 additions & 3 deletions BarChart/package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
{
"name": "@perses-dev/bar-chart",
"private": true,
"version": "0.3.1",
"version": "0.4.0",
"scripts": {
"dev": "rsbuild dev",
"build": "rsbuild build",
"lint": "eslint src --ext .ts,.tsx"
"lint": "eslint src --ext .ts,.tsx",
"test": "cross-env LC_ALL=C TZ=UTC jest",
"type-check": "tsc --noEmit"
},
"dependencies": {
"@module-federation/enhanced": "^0.1.11"
Expand All @@ -23,7 +25,8 @@
"lodash": "^4.17.21",
"react": "^17.0.2 || ^18.0.0",
"react-dom": "^17.0.2 || ^18.0.0",
"use-resize-observer": "^9.0.0"
"use-resize-observer": "^9.0.0",
"immer": "^9.0.15"
},
"files": [
"dist"
Expand Down
3 changes: 2 additions & 1 deletion BarChart/rsbuild.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default defineConfig({
new ModuleFederationPlugin({
name: 'BarChart',
exposes: {
'./BarChart': './src/Chart.tsx',
'./BarChart': './src/BarChart.ts',
},
shared: {
react: { requiredVersion: '^18.2.0', singleton: true },
Expand All @@ -51,6 +51,7 @@ export default defineConfig({
'@hookform/resolvers': { singleton: true },
'use-resize-observer': { requiredVersion: '^9.1.0', singleton: true },
'mdi-material-ui': { requiredVersion: '^7.4.0', singleton: true },
immer: { singleton: true },
},
dts: false,
runtime: false,
Expand Down
32 changes: 32 additions & 0 deletions BarChart/src/BarChart.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Copyright 2023 The Perses Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

import { PanelPlugin } from '@perses-dev/plugin-system';
import { createInitialBarChartOptions, BarChartOptions } from './bar-chart-model';
import { BarChartOptionsEditorSettings } from './BarChartOptionsEditorSettings';
import { BarChartPanel } from './BarChartPanel';

/**
* The core BarChart panel plugin for Perses.
*/
export const BarChart: PanelPlugin<BarChartOptions> = {
PanelComponent: BarChartPanel,
panelOptionsEditorComponents: [
{
label: 'Settings',
content: BarChartOptionsEditorSettings,
},
],
supportedQueryTypes: ['TimeSeriesQuery'],
createInitialOptions: createInitialBarChartOptions,
};
120 changes: 0 additions & 120 deletions BarChart/src/BarChart.tsx

This file was deleted.

Loading

0 comments on commit 45dc2cb

Please sign in to comment.