@grafana/create-plugin 0.3.0 → 0.3.2

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 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: '**Done.**\nIf you have any questions please open an issue/discussion in https://github.com/grafana/plugin-tools.',
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]);
@@ -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
- packageJson.scripts = __assign(__assign({}, packageJson.scripts), latestPackageJson.scripts);
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@grafana/create-plugin",
3
- "version": "0.3.0",
3
+ "version": "0.3.2",
4
4
  "main": "index.js",
5
5
  "repository": {
6
6
  "directory": "packages/create-plugin",
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: '**Done.**\nIf you have any questions please open an issue/discussion in https://github.com/grafana/plugin-tools.',
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.',
@@ -37,6 +37,7 @@ export function registerHandlebarsHelpers() {
37
37
  properCase: changeCase.pascalCase,
38
38
  pascalCase: changeCase.pascalCase,
39
39
  if_eq: ifEq,
40
+ normalize_id: normalizeId,
40
41
  };
41
42
 
42
43
  Object.keys(helpers).forEach((helperName) =>
@@ -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
- packageJson.scripts = {
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
 
@@ -4,7 +4,7 @@ import { AppConfig } from './components/AppConfig';
4
4
 
5
5
  export const plugin = new AppPlugin<{}>().setRootPage(App).addConfigPage({
6
6
  title: 'Configuration',
7
- icon: 'fa fa-cog',
7
+ icon: 'cog',
8
8
  // @ts-ignore - Would expect a Class component, however works absolutely fine with a functional one
9
9
  // Implementation: https://github.com/grafana/grafana/blob/fd44c01675e54973370969dfb9e78f173aff7910/public/app/features/plugins/PluginPage.tsx#L157
10
10
  body: AppConfig,
@@ -32,4 +32,5 @@ module.exports = {
32
32
  },
33
33
  ],
34
34
  },
35
+ transformIgnorePatterns: [],
35
36
  };
@@ -2,7 +2,7 @@ version: '3.0'
2
2
 
3
3
  services:
4
4
  grafana:
5
- container_name: '{{ kebabCase pluginName }}'
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/{{ kebabCase pluginName }}
13
+ - ./dist:/var/lib/grafana/plugins/{{ normalize_id pluginName orgName pluginType }}
14
14
  - ./provisioning:/etc/grafana/provisioning