Skip to content
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

Fix datasource without backend template and update test CI #206

Merged
merged 5 commits into from
Mar 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,14 @@ jobs:

- name: '@grafana/create-plugin - test an app plugin generation'
run: yarn workspace @grafana/create-plugin run generate-app && (cd ./packages/create-plugin/generated && yarn install --prefer-offline && yarn build && yarn lint)
- name: '@grafana/create-plugin - test an app with backend plugin generation'
run: yarn workspace @grafana/create-plugin run generate-app-backend && (cd ./packages/create-plugin/generated && yarn install --prefer-offline && yarn build && yarn lint)
- name: '@grafana/create-plugin - test panel plugin generation'
run: yarn workspace @grafana/create-plugin run generate-panel && (cd ./packages/create-plugin/generated && yarn install --prefer-offline && yarn build && yarn lint)
- name: '@grafana/create-plugin - test datasource plugin generation'
run: yarn workspace @grafana/create-plugin run generate-datasource && (cd ./packages/create-plugin/generated && yarn install --prefer-offline && yarn build && yarn lint)
- name: '@grafana/create-plugin - test datasource with backend plugin generation'
run: yarn workspace @grafana/create-plugin run generate-datasource-backend && (cd ./packages/create-plugin/generated && yarn install --prefer-offline && yarn build && yarn lint)

- name: '@grafana/sign-plugin - build'
run: yarn workspace @grafana/sign-plugin run build
Expand Down
3 changes: 2 additions & 1 deletion packages/create-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
"generate-app": "tsc && yarn clean-generated && CREATE_PLUGIN_DEV=true node ./scripts/generate-app.js",
"generate-app-backend": "tsc && yarn clean-generated && CREATE_PLUGIN_DEV=true node ./scripts/generate-app-backend.js",
"generate-panel": "tsc && yarn clean-generated && CREATE_PLUGIN_DEV=true node ./scripts/generate-panel.js",
"generate-datasource": "tsc && yarn clean-generated && CREATE_PLUGIN_DEV=true node ./scripts/generate-datasource.js",
"generate-datasource": "tsc && yarn clean-generated && CREATE_PLUGIN_DEV=true node ./scripts/generate-datasource-without-backend.js",
"generate-datasource-backend": "tsc && yarn clean-generated && CREATE_PLUGIN_DEV=true node ./scripts/generate-datasource-with-backend.js",
"lint": "eslint --cache --ext .js,.jsx,.ts,.tsx ./src",
"lint:fix": "yarn lint --fix",
"test": "jest",
Expand Down
4 changes: 2 additions & 2 deletions packages/create-plugin/scripts/generate-app-backend.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const nodePlop = require('node-plop');
const path = require('path');
const fs = require('fs');

async function generateApp() {
async function generate() {
const plopFile = path.join(__dirname, '../dist/commands/generate.plopfile.js');
if (!fs.existsSync(plopFile)) {
console.error('Run build first');
Expand All @@ -21,4 +21,4 @@ async function generateApp() {
});
}

generateApp();
generate();
4 changes: 2 additions & 2 deletions packages/create-plugin/scripts/generate-app.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const nodePlop = require('node-plop');
const path = require('path');
const fs = require('fs');

async function generatePanel() {
async function generate() {
const plopFile = path.join(__dirname, '../dist/commands/generate.plopfile.js');
if (!fs.existsSync(plopFile)) {
console.error('Run build first');
Expand All @@ -21,4 +21,4 @@ async function generatePanel() {
});
}

generatePanel();
generate();
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const nodePlop = require('node-plop');
const path = require('path');
const fs = require('fs');

async function generatePanel() {
async function generate() {
const plopFile = path.join(__dirname, '../dist/commands/generate.plopfile.js');
if (!fs.existsSync(plopFile)) {
console.error('Run build first');
Expand All @@ -21,4 +21,4 @@ async function generatePanel() {
});
}

generatePanel();
generate();
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
const nodePlop = require('node-plop');
const path = require('path');
const fs = require('fs');

async function generate() {
const plopFile = path.join(__dirname, '../dist/commands/generate.plopfile.js');
if (!fs.existsSync(plopFile)) {
console.error('Run build first');
process.exit(1);
}
const plop = await nodePlop(plopFile);
const generator = plop.getGenerator('create-plugin');
await generator.runActions({
pluginName: 'my-plugin',
orgName: 'my-org',
pluginDescription: 'Auto-generated datasource',
pluginType: 'datasource',
hasBackend: false,
hasGithubWorkflows: true,
hasGithubLevitateWorkflow: true,
});
}

generate();
4 changes: 2 additions & 2 deletions packages/create-plugin/scripts/generate-panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const nodePlop = require('node-plop');
const path = require('path');
const fs = require('fs');

async function generatePanel() {
async function generate() {
const plopFile = path.join(__dirname, '../dist/commands/generate.plopfile.js');
if (!fs.existsSync(plopFile)) {
console.error('Run build first');
Expand All @@ -20,4 +20,4 @@ async function generatePanel() {
});
}

generatePanel();
generate();
2 changes: 1 addition & 1 deletion packages/create-plugin/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export enum PLUGIN_TYPES {
// and will be available to use in the templates.
// Example: "@grafana/ui": "{{ grafanaVersion }}"
export const EXTRA_TEMPLATE_VARIABLES = {
grafanaVersion: '9.2.5',
grafanaVersion: '9.3.8',
};

export const GRAFANA_FE_PACKAGES = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
FieldType,
} from '@grafana/data';

import { MyQuery, MyDataSourceOptions, DEFAULT_QUERY } from './types';
import { MyQuery, MyDataSourceOptions } from './types';

export class DataSource extends DataSourceApi<MyQuery, MyDataSourceOptions> {
constructor(instanceSettings: DataSourceInstanceSettings<MyDataSourceOptions>) {
Expand Down