From 6dfad3b352908742413cf5720f72a727948bcbeb Mon Sep 17 00:00:00 2001 From: Dominik Prokop Date: Sun, 26 Apr 2020 13:16:04 +0200 Subject: [PATCH] grafana/toolkit: Do not suggest Angular panel anymore, add note about Grafana tutorials (#23902) --- .../src/cli/tasks/plugin.create.ts | 4 ++ .../src/cli/tasks/plugin/create.ts | 39 +++++++++++++++---- 2 files changed, 35 insertions(+), 8 deletions(-) diff --git a/packages/grafana-toolkit/src/cli/tasks/plugin.create.ts b/packages/grafana-toolkit/src/cli/tasks/plugin.create.ts index 5c5af1f5346..e5bf8286734 100644 --- a/packages/grafana-toolkit/src/cli/tasks/plugin.create.ts +++ b/packages/grafana-toolkit/src/cli/tasks/plugin.create.ts @@ -6,6 +6,7 @@ import { formatPluginDetails, getPluginIdFromName, prepareJsonFiles, + printGrafanaTutorialsDetails, promptPluginDetails, promptPluginType, removeGitFiles, @@ -41,6 +42,9 @@ const pluginCreateRunner: TaskRunner = async ({ name }) => // 6. Remove cloned repository .git dir await removeGitFiles(destPath); + + // 7. Promote Grafana Tutorials :) + printGrafanaTutorialsDetails(type); }; export const pluginCreateTask = new Task('plugin:create task', pluginCreateRunner); diff --git a/packages/grafana-toolkit/src/cli/tasks/plugin/create.ts b/packages/grafana-toolkit/src/cli/tasks/plugin/create.ts index 12d9920bda5..f8238303db7 100644 --- a/packages/grafana-toolkit/src/cli/tasks/plugin/create.ts +++ b/packages/grafana-toolkit/src/cli/tasks/plugin/create.ts @@ -20,14 +20,23 @@ interface PluginDetails { keywords: string; } -type PluginType = 'angular-panel' | 'react-panel' | 'datasource-plugin' | 'backend-datasource-plugin'; +type PluginType = 'panel-plugin' | 'datasource-plugin' | 'backend-datasource-plugin'; -const RepositoriesPaths = { - 'angular-panel': 'https://github.com/grafana/simple-angular-panel.git', - 'react-panel': 'https://github.com/grafana/simple-react-panel.git', +const PluginNames: Record = { + 'panel-plugin': 'Grafana Panel Plugin', + 'datasource-plugin': 'Grafana Data Source Plugin', + 'backend-datasource-plugin': 'Grafana Backend Datasource Plugin', +}; +const RepositoriesPaths: Record = { + 'panel-plugin': 'https://github.com/grafana/simple-react-panel.git', 'datasource-plugin': 'https://github.com/grafana/simple-datasource.git', 'backend-datasource-plugin': 'https://github.com/grafana/simple-datasource-backend.git', }; +const TutorialPaths: Record = { + 'panel-plugin': 'https://grafana.com/tutorials/build-a-panel-plugin', + 'datasource-plugin': 'https://grafana.com/tutorials/build-a-data-source-plugin', + 'backend-datasource-plugin': 'TODO', +}; export const getGitUsername = async () => { const name = await simpleGit.raw(['config', '--global', 'user.name']); @@ -61,10 +70,9 @@ export const promptPluginType = async () => message: 'Select plugin type', name: 'type', choices: [ - { name: 'Angular panel', value: 'angular-panel' }, - { name: 'React panel', value: 'react-panel' }, - { name: 'Datasource plugin', value: 'datasource-plugin' }, - { name: 'Backend datasource plugin', value: 'backend-datasource-plugin' }, + { name: 'Panel Plugin', value: 'panel-plugin' }, + { name: 'Datasource Plugin', value: 'datasource-plugin' }, + { name: 'Backend Datasource Plugin', value: 'backend-datasource-plugin' }, ], }, ]); @@ -159,4 +167,19 @@ export const formatPluginDetails = (details: PluginDetails) => { console.log(); console.groupEnd(); }; + +export const printGrafanaTutorialsDetails = (type: PluginType) => { + console.group(); + console.log(); + console.log(chalk.bold.yellow(`Congrats! You have just created ${PluginNames[type]}.`)); + console.log(); + if (type !== 'backend-datasource-plugin') { + console.log(`${PluginNames[type]} tutorial: ${TutorialPaths[type]}`); + } + console.log( + 'Learn more about Grafana Plugins at https://grafana.com/docs/grafana/latest/plugins/developing/development/' + ); + console.log(); + console.groupEnd(); +}; /* eslint-enable no-console */