@grafana/create-plugin 1.1.2 → 1.1.3

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/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ # v1.1.3 (Mon Mar 13 2023)
2
+
3
+ #### 🐛 Bug Fix
4
+
5
+ - Run go mod tidy after generating with backend [#216](https://github.com/grafana/plugin-tools/pull/216) ([@academo](https://github.com/academo))
6
+
7
+ #### Authors: 1
8
+
9
+ - Esteban Beltran ([@academo](https://github.com/academo))
10
+
11
+ ---
12
+
1
13
  # v1.1.2 (Fri Mar 10 2023)
2
14
 
3
15
  #### 🐛 Bug Fix
@@ -46,34 +46,71 @@ var fs_1 = __importDefault(require("fs"));
46
46
  var child_process_1 = require("child_process");
47
47
  var SDK_GO_MODULE = 'github.com/grafana/grafana-plugin-sdk-go';
48
48
  function updateGoSdkAndModules(_a) {
49
- var _this = this;
50
49
  var pluginName = _a.pluginName, orgName = _a.orgName, pluginType = _a.pluginType;
51
- return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
52
- var exportPath, goModPath, goBinaryPath, command;
53
- return __generator(this, function (_a) {
54
- switch (_a.label) {
50
+ return __awaiter(this, void 0, void 0, function () {
51
+ var exportPath, goModPath, goBinaryPath, _b;
52
+ return __generator(this, function (_c) {
53
+ switch (_c.label) {
55
54
  case 0:
56
55
  exportPath = (0, utils_path_1.getExportPath)(pluginName, orgName, pluginType);
57
56
  goModPath = "".concat(exportPath, "/go.mod");
58
57
  if (!fs_1["default"].existsSync(goModPath)) {
59
- resolve('');
58
+ return [2, ''];
60
59
  }
61
60
  return [4, (0, which_1["default"])('go', { nothrow: true })];
62
61
  case 1:
63
- goBinaryPath = _a.sent();
62
+ goBinaryPath = _c.sent();
64
63
  if (!goBinaryPath) {
65
- resolve('');
64
+ return [2, ''];
66
65
  }
67
- command = "go get ".concat(SDK_GO_MODULE);
68
- (0, child_process_1.exec)(command, { cwd: exportPath }, function (error) {
69
- if (error) {
70
- reject('There was an error trying to update the grafana go sdk. Please run `go get github.com/grafana/grafana-plugin-sdk-go` manually in your plugin directory.');
71
- }
72
- resolve('Grafana go sdk updated successfully.');
73
- });
74
- return [2];
66
+ _c.label = 2;
67
+ case 2:
68
+ _c.trys.push([2, 5, , 6]);
69
+ return [4, updateSdk(exportPath)];
70
+ case 3:
71
+ _c.sent();
72
+ return [4, updateGoMod(exportPath)];
73
+ case 4:
74
+ _c.sent();
75
+ return [3, 6];
76
+ case 5:
77
+ _b = _c.sent();
78
+ throw new Error('There was an error trying to update the grafana go sdk. Please run `go get github.com/grafana/grafana-plugin-sdk-go` manually in your plugin directory.');
79
+ case 6: return [2, 'Grafana go sdk updated successfully.'];
75
80
  }
76
81
  });
77
- }); });
82
+ });
78
83
  }
79
84
  exports.updateGoSdkAndModules = updateGoSdkAndModules;
85
+ function updateSdk(exportPath) {
86
+ var _this = this;
87
+ return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
88
+ var command;
89
+ return __generator(this, function (_a) {
90
+ command = "go get ".concat(SDK_GO_MODULE);
91
+ (0, child_process_1.exec)(command, { cwd: exportPath }, function (error) {
92
+ if (error) {
93
+ reject();
94
+ }
95
+ resolve();
96
+ });
97
+ return [2];
98
+ });
99
+ }); });
100
+ }
101
+ function updateGoMod(exportPath) {
102
+ var _this = this;
103
+ return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
104
+ var command;
105
+ return __generator(this, function (_a) {
106
+ command = "go mod tidy";
107
+ (0, child_process_1.exec)(command, { cwd: exportPath }, function (error) {
108
+ if (error) {
109
+ reject();
110
+ }
111
+ resolve();
112
+ });
113
+ return [2];
114
+ });
115
+ }); });
116
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@grafana/create-plugin",
3
- "version": "1.1.2",
3
+ "version": "1.1.3",
4
4
  "main": "index.js",
5
5
  "repository": {
6
6
  "directory": "packages/create-plugin",
@@ -63,5 +63,5 @@
63
63
  "engines": {
64
64
  "node": ">=16"
65
65
  },
66
- "gitHead": "348f19cac5e14cb409e4b2fa4fe6244a646dd48b"
66
+ "gitHead": "8d60d986d88f7a2fbfac2007f43d9b31438ad9e3"
67
67
  }
@@ -6,34 +6,57 @@ import { exec } from 'child_process';
6
6
 
7
7
  const SDK_GO_MODULE = 'github.com/grafana/grafana-plugin-sdk-go';
8
8
 
9
- export function updateGoSdkAndModules({ pluginName, orgName, pluginType }: CliArgs): Promise<string> {
10
- return new Promise(async (resolve, reject) => {
11
- // plugin directory
12
- const exportPath = getExportPath(pluginName, orgName, pluginType);
9
+ export async function updateGoSdkAndModules({ pluginName, orgName, pluginType }: CliArgs): Promise<string> {
10
+ // plugin directory
11
+ const exportPath = getExportPath(pluginName, orgName, pluginType);
12
+
13
+ // check if there is a go.mod file in exportPath
14
+ const goModPath = `${exportPath}/go.mod`;
15
+ if (!fs.existsSync(goModPath)) {
16
+ // skip if there is no go.mod file
17
+ return '';
18
+ }
13
19
 
14
- // check if there is a go.mod file in exportPath
15
- const goModPath = `${exportPath}/go.mod`;
16
- if (!fs.existsSync(goModPath)) {
17
- // skip if there is no go.mod file
18
- resolve('');
19
- }
20
+ const goBinaryPath = await which('go', { nothrow: true });
20
21
 
21
- const goBinaryPath = await which('go', { nothrow: true });
22
+ // if no go binary is found, skip
23
+ if (!goBinaryPath) {
24
+ return '';
25
+ }
22
26
 
23
- // if no go binary is found, skip
24
- if (!goBinaryPath) {
25
- resolve('');
26
- }
27
+ try {
28
+ await updateSdk(exportPath);
29
+ await updateGoMod(exportPath);
30
+ } catch {
31
+ throw new Error(
32
+ 'There was an error trying to update the grafana go sdk. Please run `go get github.com/grafana/grafana-plugin-sdk-go` manually in your plugin directory.'
33
+ );
34
+ }
35
+ return 'Grafana go sdk updated successfully.';
36
+ }
27
37
 
38
+ function updateSdk(exportPath: string): Promise<void> {
39
+ return new Promise(async (resolve, reject) => {
28
40
  // run go get SDK_GO_MODULE to update the go.mod file
29
41
  const command = `go get ${SDK_GO_MODULE}`;
30
42
  exec(command, { cwd: exportPath }, (error) => {
31
43
  if (error) {
32
- reject(
33
- 'There was an error trying to update the grafana go sdk. Please run `go get github.com/grafana/grafana-plugin-sdk-go` manually in your plugin directory.'
34
- );
44
+ reject();
45
+ }
46
+ resolve();
47
+ });
48
+ });
49
+ }
50
+
51
+ function updateGoMod(exportPath: string): Promise<void> {
52
+ return new Promise(async (resolve, reject) => {
53
+ // run go get SDK_GO_MODULE to update the go.mod file
54
+ const command = `go mod tidy`;
55
+ exec(command, { cwd: exportPath }, (error) => {
56
+ if (error) {
57
+ reject();
35
58
  }
36
- resolve('Grafana go sdk updated successfully.');
59
+ resolve();
37
60
  });
38
61
  });
39
62
  }
@@ -2,16 +2,16 @@ module github.com/{{ kebabCase orgName }}/{{ kebabCase pluginName }}
2
2
 
3
3
  go 1.19
4
4
 
5
- require github.com/grafana/grafana-plugin-sdk-go v0.143.0
5
+ require github.com/grafana/grafana-plugin-sdk-go v0.155.0
6
6
 
7
7
  require (
8
- github.com/BurntSushi/toml v0.3.1 // indirect
8
+ github.com/BurntSushi/toml v1.2.1 // indirect
9
9
  github.com/apache/arrow/go/arrow v0.0.0-20211112161151-bc219186db40 // indirect
10
10
  github.com/beorn7/perks v1.0.1 // indirect
11
11
  github.com/cespare/xxhash/v2 v2.1.2 // indirect
12
12
  github.com/cheekybits/genny v1.0.0 // indirect
13
13
  github.com/chromedp/cdproto v0.0.0-20220208224320-6efb837e6bc2 // indirect
14
- github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d // indirect
14
+ github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
15
15
  github.com/elazarl/goproxy v0.0.0-20220115173737-adb46da277ac // indirect
16
16
  github.com/fatih/color v1.7.0 // indirect
17
17
  github.com/getkin/kin-openapi v0.94.0 // indirect
@@ -21,7 +21,7 @@ require (
21
21
  github.com/golang/protobuf v1.5.2 // indirect
22
22
  github.com/golang/snappy v0.0.3 // indirect
23
23
  github.com/google/flatbuffers v2.0.0+incompatible // indirect
24
- github.com/google/go-cmp v0.5.7 // indirect
24
+ github.com/google/go-cmp v0.5.9 // indirect
25
25
  github.com/google/uuid v1.3.0 // indirect
26
26
  github.com/gorilla/mux v1.8.0 // indirect
27
27
  github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 // indirect
@@ -38,30 +38,29 @@ require (
38
38
  github.com/mattn/go-colorable v0.1.4 // indirect
39
39
  github.com/mattn/go-isatty v0.0.10 // indirect
40
40
  github.com/mattn/go-runewidth v0.0.9 // indirect
41
- github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
41
+ github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
42
42
  github.com/mitchellh/go-testing-interface v1.0.0 // indirect
43
43
  github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
44
44
  github.com/modern-go/reflect2 v1.0.2 // indirect
45
45
  github.com/oklog/run v1.0.0 // indirect
46
46
  github.com/olekukonko/tablewriter v0.0.5 // indirect
47
47
  github.com/pierrec/lz4/v4 v4.1.8 // indirect
48
- github.com/prometheus/client_golang v1.12.1 // indirect
49
- github.com/prometheus/client_model v0.2.0 // indirect
50
- github.com/prometheus/common v0.32.1 // indirect
51
- github.com/prometheus/procfs v0.7.3 // indirect
52
- github.com/russross/blackfriday/v2 v2.0.1 // indirect
53
- github.com/shurcooL/sanitized_anchor_name v1.0.0 // indirect
48
+ github.com/prometheus/client_golang v1.14.0 // indirect
49
+ github.com/prometheus/client_model v0.3.0 // indirect
50
+ github.com/prometheus/common v0.40.0 // indirect
51
+ github.com/prometheus/procfs v0.8.0 // indirect
52
+ github.com/russross/blackfriday/v2 v2.1.0 // indirect
54
53
  github.com/unknwon/bra v0.0.0-20200517080246-1e3013ecaff8 // indirect
55
54
  github.com/unknwon/com v1.0.1 // indirect
56
55
  github.com/unknwon/log v0.0.0-20150304194804-e617c87089d3 // indirect
57
- github.com/urfave/cli v1.22.1 // indirect
58
- golang.org/x/net v0.0.0-20210614182718-04defd469f4e // indirect
59
- golang.org/x/sys v0.0.0-20220114195835-da31bd327af9 // indirect
60
- golang.org/x/text v0.3.6 // indirect
56
+ github.com/urfave/cli v1.22.12 // indirect
57
+ golang.org/x/net v0.8.0 // indirect
58
+ golang.org/x/sys v0.6.0 // indirect
59
+ golang.org/x/text v0.8.0 // indirect
61
60
  golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
62
61
  google.golang.org/genproto v0.0.0-20210630183607-d20f26d13c79 // indirect
63
62
  google.golang.org/grpc v1.41.0 // indirect
64
- google.golang.org/protobuf v1.27.1 // indirect
63
+ google.golang.org/protobuf v1.28.1 // indirect
65
64
  gopkg.in/fsnotify/fsnotify.v1 v1.4.7 // indirect
66
65
  gopkg.in/yaml.v2 v2.4.0 // indirect
67
66
  )