@grafana/create-plugin 5.0.0 → 5.1.0-canary.1030.f3736ae.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commands/generate.command.js +4 -1
- package/dist/utils/utils.cli.js +16 -1
- package/dist/utils/utils.console.js +3 -0
- package/dist/utils/utils.templates.js +1 -1
- package/package.json +2 -2
- package/src/commands/generate.command.ts +5 -1
- package/src/utils/utils.cli.ts +17 -1
- package/src/utils/utils.console.ts +4 -0
- package/src/utils/utils.templates.ts +2 -1
|
@@ -3,7 +3,7 @@ import chalk from 'chalk';
|
|
|
3
3
|
import { mkdir, readdir, writeFile } from 'node:fs/promises';
|
|
4
4
|
import path from 'node:path';
|
|
5
5
|
import { EXTRA_TEMPLATE_VARIABLES, IS_DEV, PLUGIN_TYPES, TEMPLATE_PATHS } from '../constants.js';
|
|
6
|
-
import { printError } from '../utils/utils.console.js';
|
|
6
|
+
import { printError, printWarning } from '../utils/utils.console.js';
|
|
7
7
|
import { directoryExists, getExportFileName, isFile } from '../utils/utils.files.js';
|
|
8
8
|
import { getExportPath } from '../utils/utils.path.js';
|
|
9
9
|
import { renderTemplateFromFile, getTemplateData } from '../utils/utils.templates.js';
|
|
@@ -21,6 +21,9 @@ export const generate = async (argv) => {
|
|
|
21
21
|
printError(`**Aborting plugin scaffold. '${exportPath}' exists and contains files.**`);
|
|
22
22
|
process.exit(1);
|
|
23
23
|
}
|
|
24
|
+
if (answers.hasBackend && answers.pluginType === PLUGIN_TYPES.panel) {
|
|
25
|
+
printWarning(`Backend ignored as incompatible with plugin type: ${PLUGIN_TYPES.panel}.`);
|
|
26
|
+
}
|
|
24
27
|
const actions = getTemplateActions({ templateData, exportPath });
|
|
25
28
|
const failures = await generateFiles({ actions });
|
|
26
29
|
const changes = [
|
package/dist/utils/utils.cli.js
CHANGED
|
@@ -1,4 +1,19 @@
|
|
|
1
1
|
import minimist from 'minimist';
|
|
2
|
+
import { printWarning } from './utils.console.js';
|
|
2
3
|
export const args = process.argv.slice(2);
|
|
3
|
-
export const argv = minimist(args, {
|
|
4
|
+
export const argv = minimist(args, {
|
|
5
|
+
alias: {
|
|
6
|
+
f: 'force',
|
|
7
|
+
pluginType: 'plugin-type',
|
|
8
|
+
hasBackend: 'backend',
|
|
9
|
+
pluginName: 'plugin-name',
|
|
10
|
+
orgName: 'org-name',
|
|
11
|
+
},
|
|
12
|
+
boolean: ['force', 'hasBackend'],
|
|
13
|
+
string: ['pluginType', 'pluginName', 'orgName', 'feature-flags'],
|
|
14
|
+
unknown: (arg) => {
|
|
15
|
+
printWarning(`Ignoring unknown option: ${arg}.`);
|
|
16
|
+
return false;
|
|
17
|
+
},
|
|
18
|
+
});
|
|
4
19
|
export const commandName = argv._[0] || 'generate';
|
|
@@ -24,6 +24,9 @@ export function printSuccessMessage(msg) {
|
|
|
24
24
|
export function printError(error) {
|
|
25
25
|
console.error(displayAsMarkdown(`\n❌ ${error}`));
|
|
26
26
|
}
|
|
27
|
+
export function printWarning(error) {
|
|
28
|
+
console.warn(displayAsMarkdown(`\n⚠️ ${error}`));
|
|
29
|
+
}
|
|
27
30
|
export async function confirmPrompt(message) {
|
|
28
31
|
const question = await prompt({
|
|
29
32
|
name: 'confirmPrompt',
|
|
@@ -73,7 +73,7 @@ export function getTemplateData(cliArgs) {
|
|
|
73
73
|
...EXTRA_TEMPLATE_VARIABLES,
|
|
74
74
|
pluginId: normalizeId(cliArgs.pluginName, cliArgs.orgName, cliArgs.pluginType),
|
|
75
75
|
pluginName: cliArgs.pluginName,
|
|
76
|
-
hasBackend: cliArgs.hasBackend,
|
|
76
|
+
hasBackend: cliArgs.pluginType !== PLUGIN_TYPES.panel && cliArgs.hasBackend,
|
|
77
77
|
orgName: cliArgs.orgName,
|
|
78
78
|
pluginType: cliArgs.pluginType,
|
|
79
79
|
packageManagerName,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@grafana/create-plugin",
|
|
3
|
-
"version": "5.0.0",
|
|
3
|
+
"version": "5.1.0-canary.1030.f3736ae.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"directory": "packages/create-plugin",
|
|
6
6
|
"url": "https://github.com/grafana/plugin-tools"
|
|
@@ -87,5 +87,5 @@
|
|
|
87
87
|
"engines": {
|
|
88
88
|
"node": ">=20"
|
|
89
89
|
},
|
|
90
|
-
"gitHead": "
|
|
90
|
+
"gitHead": "f3736aeabe55a97fee65d72e197e0cd8440b1a3e"
|
|
91
91
|
}
|
|
@@ -4,7 +4,7 @@ import chalk from 'chalk';
|
|
|
4
4
|
import { mkdir, readdir, writeFile } from 'node:fs/promises';
|
|
5
5
|
import path from 'node:path';
|
|
6
6
|
import { EXTRA_TEMPLATE_VARIABLES, IS_DEV, PLUGIN_TYPES, TEMPLATE_PATHS } from '../constants.js';
|
|
7
|
-
import { printError } from '../utils/utils.console.js';
|
|
7
|
+
import { printError, printWarning } from '../utils/utils.console.js';
|
|
8
8
|
import { directoryExists, getExportFileName, isFile } from '../utils/utils.files.js';
|
|
9
9
|
import { getExportPath } from '../utils/utils.path.js';
|
|
10
10
|
import { renderTemplateFromFile, getTemplateData } from '../utils/utils.templates.js';
|
|
@@ -26,6 +26,10 @@ export const generate = async (argv: minimist.ParsedArgs) => {
|
|
|
26
26
|
printError(`**Aborting plugin scaffold. '${exportPath}' exists and contains files.**`);
|
|
27
27
|
process.exit(1);
|
|
28
28
|
}
|
|
29
|
+
// This is only possible when a user passes both flags via the command line.
|
|
30
|
+
if (answers.hasBackend && answers.pluginType === PLUGIN_TYPES.panel) {
|
|
31
|
+
printWarning(`Backend ignored as incompatible with plugin type: ${PLUGIN_TYPES.panel}.`);
|
|
32
|
+
}
|
|
29
33
|
|
|
30
34
|
const actions = getTemplateActions({ templateData, exportPath });
|
|
31
35
|
const failures = await generateFiles({ actions });
|
package/src/utils/utils.cli.ts
CHANGED
|
@@ -1,7 +1,23 @@
|
|
|
1
1
|
import minimist from 'minimist';
|
|
2
|
+
import { printWarning } from './utils.console.js';
|
|
2
3
|
|
|
3
4
|
export const args = process.argv.slice(2);
|
|
4
5
|
|
|
5
|
-
export const argv = minimist(args, {
|
|
6
|
+
export const argv = minimist(args, {
|
|
7
|
+
alias: {
|
|
8
|
+
f: 'force',
|
|
9
|
+
// these are aliased to make it easier to use but internally we always use the object keys
|
|
10
|
+
pluginType: 'plugin-type',
|
|
11
|
+
hasBackend: 'backend',
|
|
12
|
+
pluginName: 'plugin-name',
|
|
13
|
+
orgName: 'org-name',
|
|
14
|
+
},
|
|
15
|
+
boolean: ['force', 'hasBackend'],
|
|
16
|
+
string: ['pluginType', 'pluginName', 'orgName', 'feature-flags'],
|
|
17
|
+
unknown: (arg) => {
|
|
18
|
+
printWarning(`Ignoring unknown option: ${arg}.`);
|
|
19
|
+
return false;
|
|
20
|
+
},
|
|
21
|
+
});
|
|
6
22
|
|
|
7
23
|
export const commandName = argv._[0] || 'generate';
|
|
@@ -32,6 +32,10 @@ export function printError(error: string) {
|
|
|
32
32
|
console.error(displayAsMarkdown(`\n❌ ${error}`));
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
+
export function printWarning(error: string) {
|
|
36
|
+
console.warn(displayAsMarkdown(`\n⚠️ ${error}`));
|
|
37
|
+
}
|
|
38
|
+
|
|
35
39
|
export async function confirmPrompt(message: string): Promise<boolean> {
|
|
36
40
|
const question: Record<string, boolean> = await prompt({
|
|
37
41
|
name: 'confirmPrompt',
|
|
@@ -118,7 +118,8 @@ export function getTemplateData(cliArgs?: GenerateCliArgs): TemplateData {
|
|
|
118
118
|
...EXTRA_TEMPLATE_VARIABLES,
|
|
119
119
|
pluginId: normalizeId(cliArgs.pluginName, cliArgs.orgName, cliArgs.pluginType),
|
|
120
120
|
pluginName: cliArgs.pluginName,
|
|
121
|
-
hasBackend
|
|
121
|
+
// check plugintype and hasBackend as they can both be passed via user input (cli args).
|
|
122
|
+
hasBackend: cliArgs.pluginType !== PLUGIN_TYPES.panel && cliArgs.hasBackend,
|
|
122
123
|
orgName: cliArgs.orgName,
|
|
123
124
|
pluginType: cliArgs.pluginType,
|
|
124
125
|
packageManagerName,
|