Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
78566de7
Unverified
Commit
78566de7
authored
Apr 24, 2020
by
Carl Bergquist
Committed by
GitHub
Apr 24, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adds template for backend datasource (#23864)
parent
6f02b515
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
15 deletions
+21
-15
packages/grafana-toolkit/src/cli/tasks/plugin.create.ts
+6
-7
packages/grafana-toolkit/src/cli/tasks/plugin/create.ts
+15
-8
No files found.
packages/grafana-toolkit/src/cli/tasks/plugin.create.ts
View file @
78566de7
import
{
prompt
}
from
'inquirer'
;
import
{
prompt
}
from
'inquirer'
;
import
path
from
'path'
;
import
path
from
'path'
;
import
{
Task
,
TaskRunner
}
from
'./task'
;
import
{
promptConfirm
}
from
'../utils/prompt'
;
import
{
promptConfirm
}
from
'../utils/prompt'
;
import
{
import
{
getPluginIdFromName
,
verifyGitExists
,
promptPluginType
,
fetchTemplate
,
fetchTemplate
,
promptPluginDetails
,
formatPluginDetails
,
formatPluginDetails
,
getPluginIdFromName
,
prepareJsonFiles
,
prepareJsonFiles
,
promptPluginDetails
,
promptPluginType
,
removeGitFiles
,
removeGitFiles
,
verifyGitExists
,
}
from
'./plugin/create'
;
}
from
'./plugin/create'
;
import
{
Task
,
TaskRunner
}
from
'./task'
;
interface
PluginCreateOptions
{
interface
PluginCreateOptions
{
name
?:
string
;
name
?:
string
;
...
@@ -38,7 +37,7 @@ const pluginCreateRunner: TaskRunner<PluginCreateOptions> = async ({ name }) =>
...
@@ -38,7 +37,7 @@ const pluginCreateRunner: TaskRunner<PluginCreateOptions> = async ({ name }) =>
}
while
((
await
prompt
<
{
confirm
:
boolean
}
>
(
promptConfirm
(
'confirm'
,
'Is that ok?'
))).
confirm
===
false
);
}
while
((
await
prompt
<
{
confirm
:
boolean
}
>
(
promptConfirm
(
'confirm'
,
'Is that ok?'
))).
confirm
===
false
);
// 5. Update json files (package.json, src/plugin.json)
// 5. Update json files (package.json, src/plugin.json)
await
prepareJsonFiles
({
pluginDetails
,
pluginPath
:
destPath
});
await
prepareJsonFiles
({
type
:
type
,
pluginDetails
,
pluginPath
:
destPath
});
// 6. Remove cloned repository .git dir
// 6. Remove cloned repository .git dir
await
removeGitFiles
(
destPath
);
await
removeGitFiles
(
destPath
);
...
...
packages/grafana-toolkit/src/cli/tasks/plugin/create.ts
View file @
78566de7
import
chalk
from
'chalk'
;
import
commandExists
from
'command-exists'
;
import
commandExists
from
'command-exists'
;
import
{
readFileSync
,
promises
as
fs
}
from
'fs'
;
import
{
promises
as
fs
,
readFileSync
}
from
'fs'
;
import
{
prompt
}
from
'inquirer'
;
import
{
prompt
}
from
'inquirer'
;
import
kebabCase
from
'lodash/kebabCase'
;
import
kebabCase
from
'lodash/kebabCase'
;
import
path
from
'path'
;
import
path
from
'path'
;
import
gitPromise
from
'simple-git/promise'
;
import
gitPromise
from
'simple-git/promise'
;
import
{
promptConfirm
,
promptInput
}
from
'../../utils/prompt'
;
import
{
useSpinner
}
from
'../../utils/useSpinner'
;
import
{
rmdir
}
from
'../../utils/rmdir'
;
import
{
rmdir
}
from
'../../utils/rmdir'
;
import
{
promptInput
,
promptConfirm
}
from
'../../utils/prompt'
;
import
{
useSpinner
}
from
'../../utils/useSpinner'
;
import
chalk
from
'chalk'
;
const
simpleGit
=
gitPromise
(
process
.
cwd
());
const
simpleGit
=
gitPromise
(
process
.
cwd
());
...
@@ -21,12 +20,13 @@ interface PluginDetails {
...
@@ -21,12 +20,13 @@ interface PluginDetails {
keywords
:
string
;
keywords
:
string
;
}
}
type
PluginType
=
'angular-panel'
|
'react-panel'
|
'datasource-plugin'
;
type
PluginType
=
'angular-panel'
|
'react-panel'
|
'datasource-plugin'
|
'backend-datasource-plugin'
;
const
RepositoriesPaths
=
{
const
RepositoriesPaths
=
{
'angular-panel'
:
'https://github.com/grafana/simple-angular-panel.git'
,
'angular-panel'
:
'https://github.com/grafana/simple-angular-panel.git'
,
'react-panel'
:
'https://github.com/grafana/simple-react-panel.git'
,
'react-panel'
:
'https://github.com/grafana/simple-react-panel.git'
,
'datasource-plugin'
:
'https://github.com/grafana/simple-datasource.git'
,
'datasource-plugin'
:
'https://github.com/grafana/simple-datasource.git'
,
'backend-datasource-plugin'
:
'https://github.com/grafana/simple-datasource-backend.git'
,
};
};
export
const
getGitUsername
=
async
()
=>
{
export
const
getGitUsername
=
async
()
=>
{
...
@@ -64,6 +64,7 @@ export const promptPluginType = async () =>
...
@@ -64,6 +64,7 @@ export const promptPluginType = async () =>
{
name
:
'Angular panel'
,
value
:
'angular-panel'
},
{
name
:
'Angular panel'
,
value
:
'angular-panel'
},
{
name
:
'React panel'
,
value
:
'react-panel'
},
{
name
:
'React panel'
,
value
:
'react-panel'
},
{
name
:
'Datasource plugin'
,
value
:
'datasource-plugin'
},
{
name
:
'Datasource plugin'
,
value
:
'datasource-plugin'
},
{
name
:
'Backend datasource plugin'
,
value
:
'backend-datasource-plugin'
},
],
],
},
},
]);
]);
...
@@ -100,9 +101,9 @@ export const fetchTemplate = useSpinner<{ type: PluginType; dest: string }>(
...
@@ -100,9 +101,9 @@ export const fetchTemplate = useSpinner<{ type: PluginType; dest: string }>(
}
}
);
);
export
const
prepareJsonFiles
=
useSpinner
<
{
pluginDetails
:
PluginDetails
;
pluginPath
:
string
}
>
(
export
const
prepareJsonFiles
=
useSpinner
<
{
type
:
PluginType
;
pluginDetails
:
PluginDetails
;
pluginPath
:
string
}
>
(
'Saving package.json and plugin.json files'
,
'Saving package.json and plugin.json files'
,
async
({
pluginDetails
,
pluginPath
})
=>
{
async
({
type
,
pluginDetails
,
pluginPath
})
=>
{
const
packageJsonPath
=
path
.
resolve
(
pluginPath
,
'package.json'
);
const
packageJsonPath
=
path
.
resolve
(
pluginPath
,
'package.json'
);
const
pluginJsonPath
=
path
.
resolve
(
pluginPath
,
'src/plugin.json'
);
const
pluginJsonPath
=
path
.
resolve
(
pluginPath
,
'src/plugin.json'
);
const
packageJson
:
any
=
JSON
.
parse
(
readFileSync
(
packageJsonPath
,
'utf8'
));
const
packageJson
:
any
=
JSON
.
parse
(
readFileSync
(
packageJsonPath
,
'utf8'
));
...
@@ -115,6 +116,12 @@ export const prepareJsonFiles = useSpinner<{ pluginDetails: PluginDetails; plugi
...
@@ -115,6 +116,12 @@ export const prepareJsonFiles = useSpinner<{ pluginDetails: PluginDetails; plugi
pluginJson
.
name
=
pluginDetails
.
name
;
pluginJson
.
name
=
pluginDetails
.
name
;
pluginJson
.
id
=
pluginId
;
pluginJson
.
id
=
pluginId
;
if
(
type
===
'backend-datasource-plugin'
)
{
pluginJson
.
backend
=
true
;
pluginJson
.
executable
=
'gpx_'
+
pluginDetails
.
name
;
}
pluginJson
.
info
=
{
pluginJson
.
info
=
{
...
pluginJson
.
info
,
...
pluginJson
.
info
,
description
:
pluginDetails
.
description
,
description
:
pluginDetails
.
description
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment