@grafana/create-plugin 5.18.1 → 5.18.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/CONTRIBUTING.md CHANGED
@@ -49,28 +49,52 @@ npm install
49
49
 
50
50
  There are a collection of [commands](#commmands) to assist with developing `create-plugin`. Please read the main [contributing guide](../../CONTRIBUTING.md) before contributing any code changes to the project.
51
51
 
52
- ### Commmands
53
-
54
- Below are the main commands used for developing `create-plugin`. They can be run by either `npx nx run @grafana/create-plugin:<name_of_command>`, `npm run <name_of_command> -w @grafana/create-plugin` or navigating to `packages/create-plugin` and running the command directly as detailed below.
52
+ Development requires linking this application so you can run it in your terminal to see what effect your changes have.
55
53
 
56
54
  ```shell
57
- npm run build # used to build @grafana/create-plugin
55
+ npm run build -w @grafana/create-plugin
56
+ npm link -w @grafana/create-plugin
58
57
  ```
59
58
 
60
- ```shell
61
- npm run dev # watches for changes to files and rebuilds @grafana/create-plugin automatically
62
- ```
59
+ Run the following commands to confirm the above worked successfully:
63
60
 
64
61
  ```shell
65
- npm run dev-app # watches for changes and scaffolds an app plugin (in ./generated) for developing app configs
62
+ which create-plugin
63
+ # /Users/jackwestbrook/.nvm/versions/node/v22.13.0/bin/create-plugin
64
+ npx create-plugin version
65
+ # 5.18.0
66
66
  ```
67
67
 
68
+ You should now be able to run `npx create-plugin` or `npx create-plugin update` to test out changes locally.
69
+
70
+ If you see `create-plugin not found` try running `npm unlink -g @grafana/create-plugin` then run the build and link commands again.
71
+
72
+ ### Commmands
73
+
74
+ Below are the main commands used for developing `create-plugin`. They can be run using either `npx nx run`, `npm run` or navigating to `packages/create-plugin` and running the command directly.
75
+
76
+ #### Build
77
+
78
+ Creates a production build of @grafana/create-plugin.
79
+
68
80
  ```shell
69
- npm run dev-panel # watches for changes and scaffolds an app plugin (in ./generated) for developing panel configs
81
+ npm run build -w @grafana/create-plugin
82
+ # or with nx caching
83
+ npx nx run @grafana/create-plugin:build
84
+ # or from with packages/create-plugin directory
85
+ npm run build
70
86
  ```
71
87
 
88
+ #### Develop
89
+
90
+ Creates a development build of @grafana/create-plugin and watches for changes to files and rebuilds automatically.
91
+
72
92
  ```shell
73
- npm run dev-datasource # watches for changes and scaffolds an app plugin (in ./generated) for developing datasource configs
93
+ npm run dev -w @grafana/create-plugin
94
+ # or with nx
95
+ npx nx run @grafana/create-plugin:dev
96
+ # or from with packages/create-plugin directory
97
+ npm run dev
74
98
  ```
75
99
 
76
100
  ### Conventions
package/dist/constants.js CHANGED
@@ -2,8 +2,7 @@ import path from 'node:path';
2
2
  import { fileURLToPath } from 'node:url';
3
3
  const __dirname = fileURLToPath(new URL('.', import.meta.url));
4
4
  export const IS_DEV = process.env.CREATE_PLUGIN_DEV !== undefined;
5
- export const DEV_EXPORT_DIR = path.join(__dirname, '..', 'generated');
6
- export const EXPORT_PATH_PREFIX = IS_DEV ? DEV_EXPORT_DIR : process.cwd();
5
+ export const EXPORT_PATH_PREFIX = process.cwd();
7
6
  export const DIST_DIR = path.join(__dirname, 'dist');
8
7
  export const TEMPLATES_DIR = path.join(__dirname, '..', 'templates');
9
8
  export const PARTIALS_DIR = path.join(TEMPLATES_DIR, '_partials');
@@ -1,11 +1,5 @@
1
1
  import path from 'node:path';
2
- import { IS_DEV, DEV_EXPORT_DIR } from '../constants.js';
3
2
  import { normalizeId } from './utils.handlebars.js';
4
3
  export function getExportPath(pluginName, orgName, pluginType) {
5
- if (IS_DEV) {
6
- return DEV_EXPORT_DIR;
7
- }
8
- else {
9
- return path.join(process.cwd(), normalizeId(pluginName, orgName, pluginType));
10
- }
4
+ return path.join(process.cwd(), normalizeId(pluginName, orgName, pluginType));
11
5
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@grafana/create-plugin",
3
- "version": "5.18.1",
3
+ "version": "5.18.2",
4
4
  "repository": {
5
5
  "directory": "packages/create-plugin",
6
6
  "url": "https://github.com/grafana/plugin-tools"
@@ -25,16 +25,6 @@
25
25
  "clean-generated": "find ./generated -not -path \"./generated/node_modules*\" -not -path \"./generated\" -not -path \"./generated/package-lock.json\" -maxdepth 1 -print0 | xargs -0 -I {} rm -rf {}",
26
26
  "build": "npm run clean && tsc && chmod +x ./dist/bin/run.js",
27
27
  "dev": "nodemon --exec 'tsc'",
28
- "dev-app": "nodemon --exec 'npm run generate-app'",
29
- "dev-scenes-app": "nodemon --exec 'npm run generate-scenes-app'",
30
- "dev-panel": "nodemon --exec 'npm run generate-panel'",
31
- "dev-datasource": "nodemon --exec 'npm run generate-datasource'",
32
- "generate-app": "tsc && npm run clean-generated && CREATE_PLUGIN_DEV=true node ./dist/bin/run.js --pluginName='Sample app' --orgName='sample-org' --pluginType='app' --no-hasBackend",
33
- "generate-scenes-app": "tsc && npm run clean-generated && CREATE_PLUGIN_DEV=true node ./dist/bin/run.js --pluginName='Sample scenesapp' --orgName='sample-org' --pluginType='scenesapp' --no-hasBackend",
34
- "generate-app-backend": "tsc && npm run clean-generated && CREATE_PLUGIN_DEV=true node ./dist/bin/run.js --pluginName='Sample app' --orgName='sample-org' --pluginType='app' --hasBackend",
35
- "generate-panel": "tsc && npm run clean-generated && CREATE_PLUGIN_DEV=true node ./dist/bin/run.js --pluginName='Sample panel' --orgName='sample-org' --pluginType='panel'",
36
- "generate-datasource": "tsc && npm run clean-generated && CREATE_PLUGIN_DEV=true node ./dist/bin/run.js --pluginName='Sample datasource' --orgName='sample-org' --pluginType='datasource' --no-hasBackend",
37
- "generate-datasource-backend": "tsc && npm run clean-generated && CREATE_PLUGIN_DEV=true node ./dist/bin/run.js --pluginName='Sample datasource' --orgName='sample-org' --pluginType='datasource' --hasBackend",
38
28
  "lint": "eslint --cache ./src",
39
29
  "lint:fix": "npm run lint -- --fix",
40
30
  "test": "vitest --passWithNoTests",
@@ -88,5 +78,5 @@
88
78
  "engines": {
89
79
  "node": ">=20"
90
80
  },
91
- "gitHead": "9fb525b65ba89230f6f3d774d1f9e7d4bd88bab4"
81
+ "gitHead": "4396c62bff668d73e61e073c9e02e7326f47c826"
92
82
  }
package/src/constants.ts CHANGED
@@ -5,9 +5,7 @@ const __dirname = fileURLToPath(new URL('.', import.meta.url));
5
5
 
6
6
  export const IS_DEV = process.env.CREATE_PLUGIN_DEV !== undefined;
7
7
 
8
- export const DEV_EXPORT_DIR = path.join(__dirname, '..', 'generated');
9
-
10
- export const EXPORT_PATH_PREFIX = IS_DEV ? DEV_EXPORT_DIR : process.cwd();
8
+ export const EXPORT_PATH_PREFIX = process.cwd();
11
9
 
12
10
  export const DIST_DIR = path.join(__dirname, 'dist');
13
11
 
@@ -1,11 +1,7 @@
1
1
  import path from 'node:path';
2
- import { PLUGIN_TYPES, IS_DEV, DEV_EXPORT_DIR } from '../constants.js';
2
+ import { PLUGIN_TYPES } from '../constants.js';
3
3
  import { normalizeId } from './utils.handlebars.js';
4
4
 
5
- export function getExportPath(pluginName: string, orgName: string, pluginType: PLUGIN_TYPES): string {
6
- if (IS_DEV) {
7
- return DEV_EXPORT_DIR;
8
- } else {
9
- return path.join(process.cwd(), normalizeId(pluginName, orgName, pluginType));
10
- }
5
+ export function getExportPath(pluginName: string, orgName: string, pluginType: PLUGIN_TYPES) {
6
+ return path.join(process.cwd(), normalizeId(pluginName, orgName, pluginType));
11
7
  }