@grafana/sign-plugin 3.0.6 → 3.0.7

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/README.md CHANGED
@@ -48,7 +48,7 @@ In your plugin directory, run the following to create a MANIFEST.txt file in the
48
48
  npx @grafana/sign-plugin@latest --rootUrls https://example.com/grafana
49
49
  ```
50
50
 
51
- Alterntives:
51
+ Alternatives:
52
52
 
53
53
  #### [`npx`](https://github.com/npm/npx)
54
54
 
@@ -3,6 +3,7 @@ import path from 'node:path';
3
3
  import { getVersion } from '../utils/getVersion.js';
4
4
  import { buildManifest, saveManifest, signManifest } from '../utils/manifest.js';
5
5
  import { assertRootUrlIsValid } from '../utils/pluginValidation.js';
6
+ import { getCreatePluginVersion } from '../utils/getCreatePluginVersion.js';
6
7
  export const sign = async (argv) => {
7
8
  const distDir = argv.distDir ?? 'dist';
8
9
  const pluginDistDir = path.resolve(distDir);
@@ -23,6 +24,10 @@ export const sign = async (argv) => {
23
24
  manifest.rootUrls = rootUrls;
24
25
  }
25
26
  manifest.signPlugin = { version: getVersion() };
27
+ const createPluginVersion = getCreatePluginVersion();
28
+ if (createPluginVersion) {
29
+ manifest.createPlugin = { version: createPluginVersion };
30
+ }
26
31
  const signedManifest = await signManifest(manifest);
27
32
  console.log('Saving signed manifest...');
28
33
  saveManifest(pluginDistDir, signedManifest);
@@ -0,0 +1,18 @@
1
+ import { existsSync, readFileSync } from 'node:fs';
2
+ import { resolve } from 'node:path';
3
+ export const getCreatePluginVersion = () => {
4
+ try {
5
+ const currDir = process.cwd();
6
+ const crpcJSONPath = resolve(currDir, '.config', '.cprc.json');
7
+ if (!existsSync(crpcJSONPath)) {
8
+ return null;
9
+ }
10
+ const crpcJSON = readFileSync(crpcJSONPath, 'utf-8');
11
+ const { version } = JSON.parse(crpcJSON);
12
+ return version;
13
+ }
14
+ catch (err) {
15
+ console.log('(Optional) Not able to get create-plugin version - you can ignore this message.');
16
+ return null;
17
+ }
18
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@grafana/sign-plugin",
3
- "version": "3.0.6",
3
+ "version": "3.0.7",
4
4
  "repository": {
5
5
  "directory": "packages/sign-plugin",
6
6
  "url": "https://github.com/grafana/plugin-tools"
@@ -48,5 +48,5 @@
48
48
  "engines": {
49
49
  "node": ">=20"
50
50
  },
51
- "gitHead": "e01bf0d1680dd6b5dedb54a466399ac3bcef1edf"
51
+ "gitHead": "18cb53472ea21d1f6dd4740de2bf528eec9d291c"
52
52
  }
@@ -4,6 +4,7 @@ import path from 'node:path';
4
4
  import { getVersion } from '../utils/getVersion.js';
5
5
  import { buildManifest, saveManifest, signManifest } from '../utils/manifest.js';
6
6
  import { assertRootUrlIsValid } from '../utils/pluginValidation.js';
7
+ import { getCreatePluginVersion } from '../utils/getCreatePluginVersion.js';
7
8
 
8
9
  export const sign = async (argv: minimist.ParsedArgs) => {
9
10
  const distDir = argv.distDir ?? 'dist';
@@ -29,6 +30,11 @@ export const sign = async (argv: minimist.ParsedArgs) => {
29
30
  }
30
31
 
31
32
  manifest.signPlugin = { version: getVersion() };
33
+ const createPluginVersion = getCreatePluginVersion();
34
+ if (createPluginVersion) {
35
+ manifest.createPlugin = { version: createPluginVersion };
36
+ }
37
+
32
38
  const signedManifest = await signManifest(manifest);
33
39
 
34
40
  console.log('Saving signed manifest...');
@@ -0,0 +1,19 @@
1
+ import { existsSync, readFileSync } from 'node:fs';
2
+ import { resolve } from 'node:path';
3
+
4
+ export const getCreatePluginVersion = () => {
5
+ try {
6
+ const currDir = process.cwd();
7
+ const crpcJSONPath = resolve(currDir, '.config', '.cprc.json');
8
+ if (!existsSync(crpcJSONPath)) {
9
+ return null;
10
+ }
11
+
12
+ const crpcJSON = readFileSync(crpcJSONPath, 'utf-8');
13
+ const { version } = JSON.parse(crpcJSON);
14
+ return version as string;
15
+ } catch (err) {
16
+ console.log('(Optional) Not able to get create-plugin version - you can ignore this message.');
17
+ return null;
18
+ }
19
+ };
@@ -19,6 +19,9 @@ export interface ManifestInfo {
19
19
  signPlugin?: {
20
20
  version: string;
21
21
  };
22
+ createPlugin?: {
23
+ version: string;
24
+ };
22
25
  }
23
26
 
24
27
  type RecursiveWalk = AsyncGenerator<string, void | RecursiveWalk>;