@grafana/create-plugin 3.1.0 → 3.1.1-canary.652.37122ce.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/utils/utils.handlebars.js +16 -18
- package/jest.config.js +3 -0
- package/package.json +5 -5
- package/src/utils/utils.handlebars.ts +25 -18
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import Handlebars from 'handlebars';
|
|
2
|
-
import
|
|
3
|
-
import titleCase from 'title-case';
|
|
4
|
-
import upperCase from 'upper-case';
|
|
5
|
-
import lowerCase from 'lower-case';
|
|
2
|
+
import { camelCase, snakeCase, dotCase, pathCase, sentenceCase, constantCase, kebabCase, pascalCase, } from 'change-case';
|
|
3
|
+
import { titleCase } from 'title-case';
|
|
6
4
|
import { PARTIALS_DIR } from '../constants.js';
|
|
7
5
|
import { readFileSync, readdirSync } from 'node:fs';
|
|
8
6
|
import { basename, join } from 'node:path';
|
|
@@ -14,26 +12,26 @@ export const normalizeId = (pluginName, orgName, type) => {
|
|
|
14
12
|
const nameRegex = new RegExp('[^0-9a-zA-Z]', 'g');
|
|
15
13
|
const newPluginName = pluginName.replace(re, '').replace(nameRegex, '');
|
|
16
14
|
const newOrgName = orgName.replace(nameRegex, '');
|
|
17
|
-
return
|
|
15
|
+
return newOrgName.toLowerCase() + '-' + newPluginName.toLowerCase() + `-${type}`;
|
|
18
16
|
};
|
|
19
17
|
registerHandlebarsHelpers();
|
|
20
18
|
registerHandlebarsPartials();
|
|
21
19
|
function registerHandlebarsHelpers() {
|
|
22
20
|
const helpers = {
|
|
23
|
-
camelCase:
|
|
24
|
-
snakeCase:
|
|
25
|
-
dotCase:
|
|
26
|
-
pathCase:
|
|
27
|
-
lowerCase:
|
|
28
|
-
upperCase:
|
|
29
|
-
sentenceCase:
|
|
30
|
-
constantCase:
|
|
21
|
+
camelCase: camelCase,
|
|
22
|
+
snakeCase: snakeCase,
|
|
23
|
+
dotCase: dotCase,
|
|
24
|
+
pathCase: pathCase,
|
|
25
|
+
lowerCase: (str) => str.toUpperCase(),
|
|
26
|
+
upperCase: (str) => str.toLowerCase(),
|
|
27
|
+
sentenceCase: sentenceCase,
|
|
28
|
+
constantCase: constantCase,
|
|
31
29
|
titleCase: titleCase,
|
|
32
|
-
dashCase:
|
|
33
|
-
kabobCase:
|
|
34
|
-
kebabCase:
|
|
35
|
-
properCase:
|
|
36
|
-
pascalCase:
|
|
30
|
+
dashCase: kebabCase,
|
|
31
|
+
kabobCase: kebabCase,
|
|
32
|
+
kebabCase: kebabCase,
|
|
33
|
+
properCase: pascalCase,
|
|
34
|
+
pascalCase: pascalCase,
|
|
37
35
|
if_eq: ifEq,
|
|
38
36
|
normalize_id: normalizeId,
|
|
39
37
|
};
|
package/jest.config.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
const sharedConfig = require('../../jest.config.base');
|
|
2
|
+
const esModules = ['change-case', 'title-case'].join('|');
|
|
3
|
+
|
|
2
4
|
module.exports = {
|
|
3
5
|
...sharedConfig,
|
|
4
6
|
modulePathIgnorePatterns: ['<rootDir>/templates/'],
|
|
7
|
+
transformIgnorePatterns: [`/node_modules/(?!${esModules})`],
|
|
5
8
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@grafana/create-plugin",
|
|
3
|
-
"version": "3.1.0",
|
|
3
|
+
"version": "3.1.1-canary.652.37122ce.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"directory": "packages/create-plugin",
|
|
6
6
|
"url": "https://github.com/grafana/plugin-tools"
|
|
@@ -45,8 +45,8 @@
|
|
|
45
45
|
"@types/mkdirp": "^1.0.2",
|
|
46
46
|
"@types/semver": "^7.3.9",
|
|
47
47
|
"@types/which": "^2.0.2",
|
|
48
|
-
"chalk": "^
|
|
49
|
-
"change-case": "^
|
|
48
|
+
"chalk": "^5.3.0",
|
|
49
|
+
"change-case": "^5.4.0",
|
|
50
50
|
"enquirer": "^2.4.1",
|
|
51
51
|
"find-up": "^5.0.0",
|
|
52
52
|
"glob": "^7.1.7",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"minimist": "^1.2.8",
|
|
57
57
|
"mkdirp": "^1.0.4",
|
|
58
58
|
"semver": "^7.3.5",
|
|
59
|
-
"title-case": "^
|
|
59
|
+
"title-case": "^4.3.0",
|
|
60
60
|
"which": "^3.0.0"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
@@ -86,5 +86,5 @@
|
|
|
86
86
|
"engines": {
|
|
87
87
|
"node": ">=20"
|
|
88
88
|
},
|
|
89
|
-
"gitHead": "
|
|
89
|
+
"gitHead": "37122ce6a92ca22a12785830a7491848162a8c90"
|
|
90
90
|
}
|
|
@@ -1,8 +1,15 @@
|
|
|
1
1
|
import Handlebars, { HelperOptions } from 'handlebars';
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
import {
|
|
3
|
+
camelCase,
|
|
4
|
+
snakeCase,
|
|
5
|
+
dotCase,
|
|
6
|
+
pathCase,
|
|
7
|
+
sentenceCase,
|
|
8
|
+
constantCase,
|
|
9
|
+
kebabCase,
|
|
10
|
+
pascalCase,
|
|
11
|
+
} from 'change-case';
|
|
12
|
+
import { titleCase } from 'title-case';
|
|
6
13
|
import { PARTIALS_DIR, PLUGIN_TYPES } from '../constants.js';
|
|
7
14
|
import { readFileSync, readdirSync } from 'node:fs';
|
|
8
15
|
import { basename, join } from 'node:path';
|
|
@@ -18,7 +25,7 @@ export const normalizeId = (pluginName: string, orgName: string, type: PLUGIN_TY
|
|
|
18
25
|
|
|
19
26
|
const newPluginName = pluginName.replace(re, '').replace(nameRegex, '');
|
|
20
27
|
const newOrgName = orgName.replace(nameRegex, '');
|
|
21
|
-
return
|
|
28
|
+
return newOrgName.toLowerCase() + '-' + newPluginName.toLowerCase() + `-${type}`;
|
|
22
29
|
};
|
|
23
30
|
|
|
24
31
|
// Register our helpers and partials with handlebars.
|
|
@@ -27,20 +34,20 @@ registerHandlebarsPartials();
|
|
|
27
34
|
|
|
28
35
|
function registerHandlebarsHelpers() {
|
|
29
36
|
const helpers = {
|
|
30
|
-
camelCase:
|
|
31
|
-
snakeCase:
|
|
32
|
-
dotCase:
|
|
33
|
-
pathCase:
|
|
34
|
-
lowerCase:
|
|
35
|
-
upperCase:
|
|
36
|
-
sentenceCase:
|
|
37
|
-
constantCase:
|
|
37
|
+
camelCase: camelCase,
|
|
38
|
+
snakeCase: snakeCase,
|
|
39
|
+
dotCase: dotCase,
|
|
40
|
+
pathCase: pathCase,
|
|
41
|
+
lowerCase: (str: string) => str.toUpperCase(),
|
|
42
|
+
upperCase: (str: string) => str.toLowerCase(),
|
|
43
|
+
sentenceCase: sentenceCase,
|
|
44
|
+
constantCase: constantCase,
|
|
38
45
|
titleCase: titleCase,
|
|
39
|
-
dashCase:
|
|
40
|
-
kabobCase:
|
|
41
|
-
kebabCase:
|
|
42
|
-
properCase:
|
|
43
|
-
pascalCase:
|
|
46
|
+
dashCase: kebabCase,
|
|
47
|
+
kabobCase: kebabCase,
|
|
48
|
+
kebabCase: kebabCase,
|
|
49
|
+
properCase: pascalCase,
|
|
50
|
+
pascalCase: pascalCase,
|
|
44
51
|
if_eq: ifEq,
|
|
45
52
|
normalize_id: normalizeId,
|
|
46
53
|
};
|