@grafana/create-plugin 1.2.1 → 1.3.0-canary.226.0817df3.0

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.
@@ -12,12 +12,14 @@ exports.__esModule = true;
12
12
  exports.printGenerateSuccessMessage = void 0;
13
13
  var utils_console_1 = require("../../utils/utils.console");
14
14
  var utils_handlebars_1 = require("../../utils/utils.handlebars");
15
+ var utils_packageManager_1 = require("../../utils/utils.packageManager");
15
16
  function printGenerateSuccessMessage(answers) {
16
17
  var directory = (0, utils_handlebars_1.normalizeId)(answers.pluginName, answers.orgName, answers.pluginType);
18
+ var packageManager = (0, utils_packageManager_1.getPackageManagerFromUserAgent)().packageManager;
17
19
  var commands = __spreadArray(__spreadArray([
18
20
  "- `cd ./".concat(directory, "`"),
19
- '- `yarn install` to install frontend dependencies.',
20
- '- `yarn dev` to build (and watch) the plugin frontend code.'
21
+ "- `".concat(packageManager, " install` to install frontend dependencies."),
22
+ "- `".concat(packageManager, " run dev` to build (and watch) the plugin frontend code.")
21
23
  ], (answers.hasBackend
22
24
  ? [
23
25
  '- `mage -v build:linux` to build the plugin backend code. Rerun this command every time you edit your backend files.',
@@ -23,14 +23,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
23
23
  return (mod && mod.__esModule) ? mod : { "default": mod };
24
24
  };
25
25
  exports.__esModule = true;
26
+ var fs_1 = __importDefault(require("fs"));
26
27
  var glob_1 = __importDefault(require("glob"));
27
28
  var path_1 = __importDefault(require("path"));
28
- var fs_1 = __importDefault(require("fs"));
29
- var utils_handlebars_1 = require("../utils/utils.handlebars");
30
29
  var constants_1 = require("../constants");
30
+ var utils_handlebars_1 = require("../utils/utils.handlebars");
31
+ var utils_path_1 = require("../utils/utils.path");
32
+ var utils_packageManager_1 = require("../utils/utils.packageManager");
31
33
  var print_success_message_1 = require("./generate-actions/print-success-message");
32
34
  var update_go_sdk_and_packages_1 = require("./generate-actions/update-go-sdk-and-packages");
33
- var utils_path_1 = require("../utils/utils.path");
34
35
  function default_1(plop) {
35
36
  plop.setHelper('if_eq', utils_handlebars_1.ifEq);
36
37
  plop.setHelper('normalize_id', utils_handlebars_1.normalizeId);
@@ -97,10 +98,17 @@ function default_1(plop) {
97
98
  var pluginName = _a.pluginName, orgName = _a.orgName, pluginType = _a.pluginType, hasBackend = _a.hasBackend, hasGithubWorkflows = _a.hasGithubWorkflows, hasGithubLevitateWorkflow = _a.hasGithubLevitateWorkflow;
98
99
  var exportPath = (0, utils_path_1.getExportPath)(pluginName, orgName, pluginType);
99
100
  var pluginId = (0, utils_handlebars_1.normalizeId)(pluginName, orgName, pluginType);
101
+ var _b = (0, utils_packageManager_1.getPackageManagerFromUserAgent)(), packageManager = _b.packageManager, packageManagerVersion = _b.version;
102
+ var packageManagerInstallCmd = (0, utils_packageManager_1.getPackageManagerInstallCmd)(packageManager);
100
103
  var commonActions = getActionsForTemplateFolder({
101
104
  folderPath: constants_1.TEMPLATE_PATHS.common,
102
105
  exportPath: exportPath,
103
- templateData: { pluginId: pluginId }
106
+ templateData: {
107
+ pluginId: pluginId,
108
+ packageManager: packageManager,
109
+ packageManagerInstallCmd: packageManagerInstallCmd,
110
+ packageManagerVersion: packageManagerVersion
111
+ }
104
112
  });
105
113
  var pluginTypeSpecificActions = getActionsForTemplateFolder({
106
114
  folderPath: constants_1.TEMPLATE_PATHS[pluginType],
@@ -162,11 +170,17 @@ function getActionsForTemplateFolder(_a) {
162
170
  if (path_1["default"].basename(f) === 'gitignore') {
163
171
  return '.gitignore';
164
172
  }
173
+ if (path_1["default"].basename(f) === 'npmrc') {
174
+ return '.npmrc';
175
+ }
165
176
  return path_1["default"].extname(f) === '.hbs' ? path_1["default"].basename(f, '.hbs') : path_1["default"].basename(f);
166
177
  }
167
178
  function getExportPath(f) {
168
179
  return path_1["default"].relative(folderPath, path_1["default"].dirname(f));
169
180
  }
181
+ if (templateData.packageManager !== 'pnpm') {
182
+ files.filter(function (file) { return path_1["default"].basename(file) === 'npmrc'; });
183
+ }
170
184
  return files.filter(isFile).map(function (f) { return ({
171
185
  type: 'add',
172
186
  templateFile: f,
@@ -14,13 +14,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
14
14
  return (mod && mod.__esModule) ? mod : { "default": mod };
15
15
  };
16
16
  exports.__esModule = true;
17
- exports.cleanUpPackageJson = exports.updateNpmScripts = exports.removeNpmDependencies = exports.getRemovableNpmDependencies = exports.getUpdatableNpmDependencies = exports.getPackageJsonUpdates = exports.updateNpmDependencies = exports.updatePackageJson = exports.hasNpmDependenciesToUpdate = exports.getPackageJsonUpdatesAsText = exports.getNpmDependencyUpdatesAsText = exports.writePackageJson = exports.getLatestPackageJson = exports.getPackageJson = void 0;
17
+ exports.cleanUpPackageJson = exports.writePackageManager = exports.updateNpmScripts = exports.removeNpmDependencies = exports.getRemovableNpmDependencies = exports.getUpdatableNpmDependencies = exports.getPackageJsonUpdates = exports.updateNpmDependencies = exports.updatePackageJson = exports.hasNpmDependenciesToUpdate = exports.getPackageJsonUpdatesAsText = exports.getNpmDependencyUpdatesAsText = exports.writePackageJson = exports.getLatestPackageJson = exports.getPackageJson = void 0;
18
18
  var path_1 = __importDefault(require("path"));
19
19
  var fs_1 = __importDefault(require("fs"));
20
20
  var semver_1 = __importDefault(require("semver"));
21
21
  var utils_files_1 = require("./utils.files");
22
22
  var utils_templates_1 = require("./utils.templates");
23
23
  var constants_1 = require("../constants");
24
+ var utils_packageManager_1 = require("./utils.packageManager");
24
25
  function getPackageJson() {
25
26
  return (0, utils_files_1.readJsonFile)(path_1["default"].join(process.cwd(), 'package.json'));
26
27
  }
@@ -204,6 +205,14 @@ function updateNpmScripts() {
204
205
  writePackageJson(packageJson);
205
206
  }
206
207
  exports.updateNpmScripts = updateNpmScripts;
208
+ function writePackageManager() {
209
+ var packageJson = getPackageJson();
210
+ if (!packageJson.packageManager) {
211
+ var _a = (0, utils_packageManager_1.getPackageManagerFromLockFile)(), packageManager = _a.packageManager, version = _a.version;
212
+ packageJson.packageManager = "".concat(packageManager, "@").concat(version);
213
+ }
214
+ }
215
+ exports.writePackageManager = writePackageManager;
207
216
  function cleanUpPackageJson() {
208
217
  var packageJson = getPackageJson();
209
218
  packageJson.scripts = sortKeysAlphabetically(packageJson.scripts);
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+ exports.__esModule = true;
3
+ exports.getPackageManagerInstallCmd = exports.getPackageManagerFromLockFile = exports.getPackageManagerFromUserAgent = void 0;
4
+ var path_1 = require("path");
5
+ var child_process_1 = require("child_process");
6
+ var find_up_1 = require("find-up");
7
+ var NPM_LOCKFILE = 'package-lock.json';
8
+ var PNPM_LOCKFILE = 'pnpm-lock.yaml';
9
+ var YARN_LOCKFILE = 'yarn.lock';
10
+ var SUPPORTED_PACKAGE_MANAGERS = ['npm', 'yarn', 'pnpm'];
11
+ function getPackageManagerFromUserAgent() {
12
+ var agent = process.env.npm_config_user_agent;
13
+ var _a = agent.split('/'), packageManager = _a[0], versionWithText = _a[1];
14
+ var version = versionWithText.split(' ')[0];
15
+ if (SUPPORTED_PACKAGE_MANAGERS.includes(packageManager)) {
16
+ return { packageManager: packageManager, version: version };
17
+ }
18
+ return { packageManager: 'yarn', version: '1.22.19' };
19
+ }
20
+ exports.getPackageManagerFromUserAgent = getPackageManagerFromUserAgent;
21
+ function getPackageManagerFromLockFile() {
22
+ var closestLockfilePath = (0, find_up_1.sync)([YARN_LOCKFILE, PNPM_LOCKFILE, NPM_LOCKFILE]);
23
+ if (!Boolean(closestLockfilePath)) {
24
+ return undefined;
25
+ }
26
+ var closestLockfile = closestLockfilePath && (0, path_1.basename)(closestLockfilePath);
27
+ try {
28
+ if (closestLockfile === NPM_LOCKFILE) {
29
+ var npmVersionCommand = (0, child_process_1.spawnSync)('npm', ['--version'], {
30
+ shell: true
31
+ });
32
+ var version = npmVersionCommand.stdout;
33
+ return { packageManager: 'npm', version: version };
34
+ }
35
+ if (closestLockfile === PNPM_LOCKFILE) {
36
+ var npmVersionCommand = (0, child_process_1.spawnSync)('pnpm', ['--version'], {
37
+ shell: true
38
+ });
39
+ var version = npmVersionCommand.stdout;
40
+ return { packageManager: 'pnpm', version: version };
41
+ }
42
+ if (closestLockfile === YARN_LOCKFILE) {
43
+ var npmVersionCommand = (0, child_process_1.spawnSync)('yarn', ['--version'], {
44
+ shell: true
45
+ });
46
+ var version = npmVersionCommand.stdout;
47
+ return { packageManager: 'yarn', version: version };
48
+ }
49
+ return undefined;
50
+ }
51
+ catch (error) {
52
+ console.error('Failed to find package manager from lock file');
53
+ throw Error(error);
54
+ }
55
+ }
56
+ exports.getPackageManagerFromLockFile = getPackageManagerFromLockFile;
57
+ function getPackageManagerInstallCmd(packageManager) {
58
+ switch (packageManager) {
59
+ case 'yarn':
60
+ return 'yarn install --immutable --prefer-offline';
61
+ case 'pnpm':
62
+ return 'pnpm install --frozen-lockfile --prefer-offline';
63
+ default:
64
+ return 'npm ci';
65
+ }
66
+ }
67
+ exports.getPackageManagerInstallCmd = getPackageManagerInstallCmd;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@grafana/create-plugin",
3
- "version": "1.2.1",
3
+ "version": "1.3.0-canary.226.0817df3.0",
4
4
  "main": "index.js",
5
5
  "repository": {
6
6
  "directory": "packages/create-plugin",
@@ -37,6 +37,7 @@
37
37
  "@types/semver": "^7.3.9",
38
38
  "@types/which": "^2.0.2",
39
39
  "enquirer": "^2.3.6",
40
+ "find-up": "^5.0.0",
40
41
  "glob": "^7.1.7",
41
42
  "marked": "^4.0.12",
42
43
  "marked-terminal": "^5.1.1",
@@ -63,5 +64,5 @@
63
64
  "engines": {
64
65
  "node": ">=16"
65
66
  },
66
- "gitHead": "3f3864d4b4f3b1e19f16d580258999290c8c695b"
67
+ "gitHead": "0817df359a166014d2470d3043c79f62339bd4bb"
67
68
  }
@@ -1,14 +1,15 @@
1
1
  import { displayAsMarkdown } from '../../utils/utils.console';
2
2
  import { normalizeId } from '../../utils/utils.handlebars';
3
+ import { getPackageManagerFromUserAgent } from '../../utils/utils.packageManager';
3
4
  import { CliArgs } from '../types';
4
5
 
5
6
  export function printGenerateSuccessMessage(answers: CliArgs) {
6
7
  const directory = normalizeId(answers.pluginName, answers.orgName, answers.pluginType);
7
-
8
+ const { packageManager } = getPackageManagerFromUserAgent();
8
9
  const commands = [
9
10
  `- \`cd ./${directory}\``,
10
- '- `yarn install` to install frontend dependencies.',
11
- '- `yarn dev` to build (and watch) the plugin frontend code.',
11
+ `- \`${packageManager} install\` to install frontend dependencies.`,
12
+ `- \`${packageManager} run dev\` to build (and watch) the plugin frontend code.`,
12
13
  ...(answers.hasBackend
13
14
  ? [
14
15
  '- `mage -v build:linux` to build the plugin backend code. Rerun this command every time you edit your backend files.',
@@ -1,13 +1,14 @@
1
- import type { NodePlopAPI, ModifyActionConfig } from 'plop';
1
+ import fs from 'fs';
2
2
  import glob from 'glob';
3
3
  import path from 'path';
4
- import fs from 'fs';
4
+ import type { ModifyActionConfig, NodePlopAPI } from 'plop';
5
+ import { EXTRA_TEMPLATE_VARIABLES, IS_DEV, PARTIALS_DIR, PLUGIN_TYPES, TEMPLATE_PATHS } from '../constants';
5
6
  import { ifEq, normalizeId } from '../utils/utils.handlebars';
6
- import { IS_DEV, TEMPLATE_PATHS, PARTIALS_DIR, PLUGIN_TYPES, EXTRA_TEMPLATE_VARIABLES } from '../constants';
7
+ import { getExportPath } from '../utils/utils.path';
8
+ import { getPackageManagerInstallCmd, getPackageManagerFromUserAgent } from '../utils/utils.packageManager';
7
9
  import { printGenerateSuccessMessage } from './generate-actions/print-success-message';
8
10
  import { updateGoSdkAndModules } from './generate-actions/update-go-sdk-and-packages';
9
11
  import { CliArgs } from './types';
10
- import { getExportPath } from '../utils/utils.path';
11
12
 
12
13
  // Plopfile API documentation: https://plopjs.com/documentation/#plopfile-api
13
14
  export default function (plop: NodePlopAPI) {
@@ -84,11 +85,20 @@ export default function (plop: NodePlopAPI) {
84
85
  }: CliArgs) {
85
86
  const exportPath = getExportPath(pluginName, orgName, pluginType);
86
87
  const pluginId = normalizeId(pluginName, orgName, pluginType);
88
+ // Support the users package manager of choice.
89
+ const { packageManager, version: packageManagerVersion } = getPackageManagerFromUserAgent();
90
+ const packageManagerInstallCmd = getPackageManagerInstallCmd(packageManager);
91
+
87
92
  // Copy over files that are shared between plugins types
88
93
  const commonActions = getActionsForTemplateFolder({
89
94
  folderPath: TEMPLATE_PATHS.common,
90
95
  exportPath,
91
- templateData: { pluginId },
96
+ templateData: {
97
+ pluginId,
98
+ packageManager,
99
+ packageManagerInstallCmd,
100
+ packageManagerVersion,
101
+ },
92
102
  });
93
103
 
94
104
  // Copy over files from the plugin type specific folder, e.g. "templates/app" for "app" plugins ("app" | "panel" | "datasource").
@@ -198,12 +208,21 @@ function getActionsForTemplateFolder({
198
208
  if (path.basename(f) === 'gitignore') {
199
209
  return '.gitignore';
200
210
  }
211
+ if (path.basename(f) === 'npmrc') {
212
+ return '.npmrc';
213
+ }
214
+
201
215
  return path.extname(f) === '.hbs' ? path.basename(f, '.hbs') : path.basename(f);
202
216
  }
203
217
  function getExportPath(f: string) {
204
218
  return path.relative(folderPath, path.dirname(f));
205
219
  }
206
220
 
221
+ // Remove the npmrc file if not running `pnpm`.
222
+ if (templateData.packageManager !== 'pnpm') {
223
+ files.filter((file) => path.basename(file) === 'npmrc');
224
+ }
225
+
207
226
  return files.filter(isFile).map((f) => ({
208
227
  type: 'add',
209
228
  templateFile: f,
@@ -4,6 +4,7 @@ import semver from 'semver';
4
4
  import { readJsonFile } from './utils.files';
5
5
  import { renderTemplateFromFile, getTemplateData } from './utils.templates';
6
6
  import { GRAFANA_FE_PACKAGES, TEMPLATE_PATHS } from '../constants';
7
+ import { getPackageManagerFromLockFile } from './utils.packageManager';
7
8
 
8
9
  type UpdateSummary = Record<string, { prev: string | null; next: string | null }>;
9
10
 
@@ -236,6 +237,15 @@ export function updateNpmScripts() {
236
237
  writePackageJson(packageJson);
237
238
  }
238
239
 
240
+ export function writePackageManager() {
241
+ const packageJson = getPackageJson();
242
+ if (!packageJson.packageManager) {
243
+ const { packageManager, version } = getPackageManagerFromLockFile();
244
+
245
+ packageJson.packageManager = `${packageManager}@${version}`;
246
+ }
247
+ }
248
+
239
249
  export function cleanUpPackageJson() {
240
250
  const packageJson = getPackageJson();
241
251
  packageJson.scripts = sortKeysAlphabetically(packageJson.scripts);
@@ -0,0 +1,75 @@
1
+ import { basename } from 'path';
2
+ import { spawnSync } from 'child_process';
3
+ import { sync as findUpSync } from 'find-up';
4
+
5
+ const NPM_LOCKFILE = 'package-lock.json';
6
+ const PNPM_LOCKFILE = 'pnpm-lock.yaml';
7
+ const YARN_LOCKFILE = 'yarn.lock';
8
+ const SUPPORTED_PACKAGE_MANAGERS = ['npm', 'yarn', 'pnpm'];
9
+
10
+ export function getPackageManagerFromUserAgent() {
11
+ const agent = process.env.npm_config_user_agent;
12
+
13
+ const [packageManager, versionWithText] = agent.split('/');
14
+ const [version] = versionWithText.split(' ');
15
+
16
+ if (SUPPORTED_PACKAGE_MANAGERS.includes(packageManager)) {
17
+ return { packageManager, version };
18
+ }
19
+ // default to yarn 1 as legacy option.
20
+ return { packageManager: 'yarn', version: '1.22.19' };
21
+ }
22
+
23
+ export function getPackageManagerFromLockFile() {
24
+ const closestLockfilePath = findUpSync([YARN_LOCKFILE, PNPM_LOCKFILE, NPM_LOCKFILE]);
25
+ if (!Boolean(closestLockfilePath)) {
26
+ return undefined;
27
+ }
28
+
29
+ const closestLockfile = closestLockfilePath && basename(closestLockfilePath);
30
+
31
+ try {
32
+ if (closestLockfile === NPM_LOCKFILE) {
33
+ const npmVersionCommand = spawnSync('npm', ['--version'], {
34
+ shell: true,
35
+ });
36
+ const version = npmVersionCommand.stdout;
37
+ return { packageManager: 'npm', version };
38
+ }
39
+
40
+ if (closestLockfile === PNPM_LOCKFILE) {
41
+ const npmVersionCommand = spawnSync('pnpm', ['--version'], {
42
+ shell: true,
43
+ });
44
+ const version = npmVersionCommand.stdout;
45
+ return { packageManager: 'pnpm', version };
46
+ }
47
+
48
+ if (closestLockfile === YARN_LOCKFILE) {
49
+ const npmVersionCommand = spawnSync('yarn', ['--version'], {
50
+ shell: true,
51
+ });
52
+ const version = npmVersionCommand.stdout;
53
+ return { packageManager: 'yarn', version };
54
+ }
55
+
56
+ return undefined;
57
+ } catch (error) {
58
+ // DO SOMETHING SMART HERE.
59
+ console.error('Failed to find package manager from lock file');
60
+ throw Error(error);
61
+ }
62
+ }
63
+
64
+ export function getPackageManagerInstallCmd(packageManager: string) {
65
+ switch (packageManager) {
66
+ case 'yarn':
67
+ return 'yarn install --immutable --prefer-offline';
68
+
69
+ case 'pnpm':
70
+ return 'pnpm install --frozen-lockfile --prefer-offline';
71
+
72
+ default:
73
+ return 'npm ci';
74
+ }
75
+ }
@@ -60,7 +60,7 @@ A common issue found with the current jest config involves importing an npm pack
60
60
 
61
61
  ```javascript
62
62
  process.env.TZ = 'UTC';
63
- const { grafanaESModules, nodeModulesToTransform } = require('./jest/utils');
63
+ const { grafanaESModules, nodeModulesToTransform } = require('./config/jest/utils');
64
64
 
65
65
  module.exports = {
66
66
  // Jest configuration provided by Grafana
@@ -161,4 +161,4 @@ services:
161
161
 
162
162
  In this example we are assigning the environment variable `GRAFANA_IMAGE` to the build arg `grafana_image` with a default value of `grafana`. This will give you the possibility to set the value while running the docker-compose commands which might be convinent in some scenarios.
163
163
 
164
- ---
164
+ ---
@@ -4,6 +4,7 @@ logs
4
4
  npm-debug.log*
5
5
  yarn-debug.log*
6
6
  yarn-error.log*
7
+ .pnpm-debug.log*
7
8
 
8
9
  node_modules/
9
10
 
@@ -26,7 +27,7 @@ work/
26
27
  ci/
27
28
  e2e-results/
28
29
  **/cypress/videos
29
- **/cypress/report.json
30
+ **/cypress/report.json
30
31
 
31
32
  # Editor
32
33
  .idea
@@ -0,0 +1,3 @@
1
+ # @grafana/e2e expects cypress to exist in the root of the node_modules directory
2
+ # pnpm will put it in node_modules/.pnpm by default
3
+ public-hoist-pattern[]=*cypress*
@@ -9,9 +9,9 @@
9
9
  "test:ci": "jest --passWithNoTests --maxWorkers 4",
10
10
  "typecheck": "tsc --noEmit",
11
11
  "lint": "eslint --cache --ignore-path ./.gitignore --ext .js,.jsx,.ts,.tsx .",
12
- "lint:fix": "yarn lint --fix",
13
- "e2e": "yarn cypress install && yarn grafana-e2e run",
14
- "e2e:update": "yarn cypress install && yarn grafana-e2e run --update-screenshots",
12
+ "lint:fix": "{{ packageManager }} run lint --fix",
13
+ "e2e": "{{ packageManager }} exec cypress install && {{ packageManager }} exec grafana-e2e run",
14
+ "e2e:update": "{{ packageManager }} exec cypress install && {{ packageManager }} exec grafana-e2e run --update-screenshots",
15
15
  "server": "docker-compose up --build",
16
16
  "sign": "npx --yes @grafana/sign-plugin@latest"
17
17
  },
@@ -30,7 +30,9 @@
30
30
  "@testing-library/react": "^12.1.4",
31
31
  "@types/glob": "^8.0.0",
32
32
  "@types/jest": "^29.2.2",
33
- "@types/lodash": "^4.14.188",{{#if_eq pluginType "app"}}
33
+ "@types/lodash": "^4.14.188",
34
+ "@types/react": "17.0.42",
35
+ "@types/react-dom": "17.0.14",{{#if_eq pluginType "app"}}
34
36
  "@types/react-router-dom": "^5.3.3",{{/if_eq}}
35
37
  "@types/node": "^18.11.9",
36
38
  "copy-webpack-plugin": "^11.0.0",
@@ -63,7 +65,9 @@
63
65
  "@grafana/runtime": "{{ grafanaVersion }}",
64
66
  "@grafana/ui": "{{ grafanaVersion }}",
65
67
  "react": "17.0.2",
66
- "react-dom": "17.0.2"{{#if_eq pluginType "app"}},
67
- "react-router-dom": "^5.2.0"{{/if_eq}}
68
- }
68
+ "react-dom": "17.0.2",{{#if_eq pluginType "app"}}
69
+ "react-router-dom": "^5.2.0",{{/if_eq}}
70
+ "tslib": "2.5.0"
71
+ },
72
+ "packageManager": "{{ packageManager }}@{{ packageManagerVersion }}"
69
73
  }
@@ -15,30 +15,32 @@ jobs:
15
15
  build:
16
16
  runs-on: ubuntu-latest
17
17
  steps:
18
- - uses: actions/checkout@v3
19
-
18
+ - uses: actions/checkout@v3{{#if_eq packageManager "pnpm"}}
19
+ - uses: pnpm/action-setup@v2
20
+ with:
21
+ version: 7.x.x{{/if_eq}}
20
22
  - name: Setup Node.js environment
21
23
  uses: actions/setup-node@v3
22
24
  with:
23
25
  node-version: '16'
24
- cache: 'yarn'
26
+ cache: '{{ packageManager }}'
25
27
  - name: Install dependencies
26
- run: yarn install --immutable --prefer-offline
28
+ run: {{ packageManagerInstallCmd }}
27
29
 
28
30
  - name: Check types
29
- run: yarn typecheck
31
+ run: {{ packageManager }} run typecheck
30
32
  - name: Lint
31
- run: yarn lint
33
+ run: {{ packageManager }} run lint
32
34
  - name: Unit tests
33
- run: yarn test:ci
35
+ run: {{ packageManager }} run test:ci
34
36
  - name: Build frontend
35
- run: yarn build
37
+ run: {{ packageManager }} run build
36
38
 
37
39
  - name: Start grafana docker
38
- run: yarn server -d
40
+ run: docker-compose up -d
39
41
 
40
42
  - name: Run e2e tests
41
- run: yarn e2e
43
+ run: {{ packageManager }} run e2e
42
44
 
43
45
  - name: Stop grafana docker
44
46
  run: docker-compose down
@@ -12,13 +12,16 @@ jobs:
12
12
  env:
13
13
  GRAFANA_API_KEY: $\{{ secrets.GRAFANA_API_KEY }} # Requires a Grafana API key from Grafana.com.
14
14
  steps:
15
- - uses: actions/checkout@v3
15
+ - uses: actions/checkout@v3{{#if_eq packageManager "pnpm"}}
16
+ - uses: pnpm/action-setup@v2
17
+ with:
18
+ version: 7.x.x{{/if_eq}}
16
19
 
17
20
  - name: Setup Node.js environment
18
21
  uses: actions/setup-node@v3
19
22
  with:
20
23
  node-version: '16'
21
- cache: 'yarn'
24
+ cache: '{{ packageManager }}'
22
25
 
23
26
  - name: Setup Go environment
24
27
  uses: actions/setup-go@v3
@@ -26,10 +29,10 @@ jobs:
26
29
  go-version: '1.19'
27
30
 
28
31
  - name: Install dependencies
29
- run: yarn install --immutable --prefer-offline
32
+ run: {{ packageManagerInstallCmd }}
30
33
 
31
34
  - name: Build and test frontend
32
- run: yarn build
35
+ run: {{ packageManager }} run build
33
36
 
34
37
  - name: Check for backend
35
38
  id: check-for-backend
@@ -60,7 +63,7 @@ jobs:
60
63
  if: $\{{ env.GRAFANA_API_KEY == '' }}
61
64
 
62
65
  - name: Sign plugin
63
- run: yarn sign
66
+ run: {{ packageManager }} run sign
64
67
  if: $\{{ env.GRAFANA_API_KEY != '' }}
65
68
 
66
69
  - name: Get plugin metadata
@@ -9,10 +9,10 @@ jobs:
9
9
  - uses: actions/setup-node@v3
10
10
  with:
11
11
  node-version: '16'
12
- cache: 'yarn'
12
+ cache: '{{ packageManager }}'
13
13
  - name: Install dependencies
14
- run: yarn install --immutable --prefer-offline
14
+ run: {{ packageManagerInstallCmd }}
15
15
  - name: Build plugin
16
- run: yarn build
16
+ run: {{ packageManager }} run build
17
17
  - name: Compatibility check
18
18
  run: npx @grafana/levitate@latest is-compatible --path src/module.ts --target @grafana/data,@grafana/ui,@grafana/runtime