@grafana/create-plugin 0.3.0 → 0.3.1
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/constants.js +2 -2
- package/dist/utils/utils.handlebars.js +2 -1
- package/dist/utils/utils.npm.js +9 -1
- package/package.json +1 -1
- package/src/constants.ts +11 -2
- package/src/utils/utils.handlebars.ts +1 -0
- package/src/utils/utils.npm.ts +12 -1
- package/templates/common/.config/jest.config.js +3 -0
- package/templates/common/docker-compose.yaml +2 -2
package/dist/constants.js
CHANGED
|
@@ -67,11 +67,11 @@ exports.TEXT = {
|
|
|
67
67
|
removeNpmDependenciesSuccess: 'Unnecessary NPM dependencies removed successfully.',
|
|
68
68
|
removeNpmDependenciesAborted: 'No NPM dependencies have been removed.',
|
|
69
69
|
updateConfigPrompt: "**Would you like to update the project's configuration?**",
|
|
70
|
-
updateNpmScriptsPrompt: '**Would you like to update the `{ scripts }` in your `package.json
|
|
70
|
+
updateNpmScriptsPrompt: '**Would you like to update the `{ scripts }` in your `package.json`?**\nAll scripts using grafana-toolkit will be replaced.',
|
|
71
71
|
updateNpmScriptsSuccess: 'NPM scripts updated successfully.',
|
|
72
72
|
updateNpmScriptsAborted: 'No NPM scripts have been added or updated.',
|
|
73
73
|
migrationCommandWarning: '**⚠️ Warning!**\nThis is going to change files in your current project to make it up-to-date with the latest plugin configuration.\nPlease make sure that you have backed up your changes.',
|
|
74
|
-
migrationCommandSuccess: '
|
|
74
|
+
migrationCommandSuccess: "\n## What's next?\n * Run `yarn install` to install the latest dependencies.\n * Check your tsconfig.json. You might need to update if you had a custom configuration.\n * If you have a custom webpack configuration you might need to update it too.\n * Run `yarn build` and observe the output for any errors.\n * Test your plugin in grafana and make sure everything works as expected.\n\nSee instructions on how to customize your configuration here https://github.com/grafana/plugin-tools/blob/main/packages/create-plugin/templates/common/.config/README.md\n ",
|
|
75
75
|
updateCommandWarning: '**⚠️ Warning!**\nThis is going to update files under the `.config/` folder.\nMake sure to commit your changes before running this script.',
|
|
76
76
|
updateCommandSuccess: '**Done.**\nIf you have any questions please open an issue/discussion in https://github.com/grafana/plugin-tools.'
|
|
77
77
|
};
|
|
@@ -61,7 +61,8 @@ function registerHandlebarsHelpers() {
|
|
|
61
61
|
kebabCase: changeCase.paramCase,
|
|
62
62
|
properCase: changeCase.pascalCase,
|
|
63
63
|
pascalCase: changeCase.pascalCase,
|
|
64
|
-
if_eq: exports.ifEq
|
|
64
|
+
if_eq: exports.ifEq,
|
|
65
|
+
normalize_id: exports.normalizeId
|
|
65
66
|
};
|
|
66
67
|
Object.keys(helpers).forEach(function (helperName) {
|
|
67
68
|
return handlebars_1["default"].registerHelper(helperName, helpers[helperName]);
|
package/dist/utils/utils.npm.js
CHANGED
|
@@ -154,9 +154,17 @@ function removeNpmDependencies(packageNames, _a) {
|
|
|
154
154
|
}
|
|
155
155
|
exports.removeNpmDependencies = removeNpmDependencies;
|
|
156
156
|
function updateNpmScripts() {
|
|
157
|
+
var toolkitScriptRe = /grafana-toolkit plugin:.*/;
|
|
157
158
|
var packageJson = getPackageJson();
|
|
158
159
|
var latestPackageJson = getLatestPackageJson();
|
|
159
|
-
|
|
160
|
+
var scripts = __assign(__assign({}, packageJson.scripts), latestPackageJson.scripts);
|
|
161
|
+
for (var _i = 0, _a = Object.keys(scripts); _i < _a.length; _i++) {
|
|
162
|
+
var key = _a[_i];
|
|
163
|
+
if (toolkitScriptRe.test(scripts[key])) {
|
|
164
|
+
delete scripts[key];
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
packageJson.scripts = scripts;
|
|
160
168
|
writePackageJson(packageJson);
|
|
161
169
|
}
|
|
162
170
|
exports.updateNpmScripts = updateNpmScripts;
|
package/package.json
CHANGED
package/src/constants.ts
CHANGED
|
@@ -92,12 +92,21 @@ export const TEXT = {
|
|
|
92
92
|
|
|
93
93
|
updateConfigPrompt: "**Would you like to update the project's configuration?**",
|
|
94
94
|
|
|
95
|
-
updateNpmScriptsPrompt: '**Would you like to update the `{ scripts }` in your `package.json
|
|
95
|
+
updateNpmScriptsPrompt: '**Would you like to update the `{ scripts }` in your `package.json`?**\nAll scripts using grafana-toolkit will be replaced.',
|
|
96
96
|
updateNpmScriptsSuccess: 'NPM scripts updated successfully.',
|
|
97
97
|
updateNpmScriptsAborted: 'No NPM scripts have been added or updated.',
|
|
98
98
|
|
|
99
99
|
migrationCommandWarning: '**⚠️ Warning!**\nThis is going to change files in your current project to make it up-to-date with the latest plugin configuration.\nPlease make sure that you have backed up your changes.',
|
|
100
|
-
migrationCommandSuccess:
|
|
100
|
+
migrationCommandSuccess: `
|
|
101
|
+
## What's next?
|
|
102
|
+
* Run \`yarn install\` to install the latest dependencies.
|
|
103
|
+
* Check your tsconfig.json. You might need to update if you had a custom configuration.
|
|
104
|
+
* If you have a custom webpack configuration you might need to update it too.
|
|
105
|
+
* Run \`yarn build\` and observe the output for any errors.
|
|
106
|
+
* Test your plugin in grafana and make sure everything works as expected.
|
|
107
|
+
|
|
108
|
+
See instructions on how to customize your configuration here https://github.com/grafana/plugin-tools/blob/main/packages/create-plugin/templates/common/.config/README.md
|
|
109
|
+
`,
|
|
101
110
|
|
|
102
111
|
updateCommandWarning: '**⚠️ Warning!**\nThis is going to update files under the `.config/` folder.\nMake sure to commit your changes before running this script.',
|
|
103
112
|
updateCommandSuccess: '**Done.**\nIf you have any questions please open an issue/discussion in https://github.com/grafana/plugin-tools.',
|
package/src/utils/utils.npm.ts
CHANGED
|
@@ -177,14 +177,25 @@ export function removeNpmDependencies(packageNames: string[], { devOnly = false
|
|
|
177
177
|
}
|
|
178
178
|
|
|
179
179
|
export function updateNpmScripts() {
|
|
180
|
+
const toolkitScriptRe = /grafana-toolkit plugin:.*/;
|
|
181
|
+
|
|
180
182
|
const packageJson = getPackageJson();
|
|
181
183
|
const latestPackageJson = getLatestPackageJson();
|
|
182
184
|
|
|
183
|
-
|
|
185
|
+
const scripts = {
|
|
184
186
|
...packageJson.scripts,
|
|
185
187
|
...latestPackageJson.scripts,
|
|
186
188
|
};
|
|
187
189
|
|
|
190
|
+
// loop script keys and remove toolkit scripts
|
|
191
|
+
for (const key of Object.keys(scripts)) {
|
|
192
|
+
if (toolkitScriptRe.test(scripts[key])) {
|
|
193
|
+
delete scripts[key];
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
packageJson.scripts = scripts;
|
|
198
|
+
|
|
188
199
|
writePackageJson(packageJson);
|
|
189
200
|
}
|
|
190
201
|
|
|
@@ -2,7 +2,7 @@ version: '3.0'
|
|
|
2
2
|
|
|
3
3
|
services:
|
|
4
4
|
grafana:
|
|
5
|
-
container_name: '{{
|
|
5
|
+
container_name: '{{ normalize_id pluginName orgName pluginType }}'
|
|
6
6
|
build:
|
|
7
7
|
context: ./.config
|
|
8
8
|
args:
|
|
@@ -10,5 +10,5 @@ services:
|
|
|
10
10
|
ports:
|
|
11
11
|
- 3000:3000/tcp
|
|
12
12
|
volumes:
|
|
13
|
-
- ./dist:/var/lib/grafana/plugins/{{
|
|
13
|
+
- ./dist:/var/lib/grafana/plugins/{{ normalize_id pluginName orgName pluginType }}
|
|
14
14
|
- ./provisioning:/etc/grafana/provisioning
|