@grafana/create-plugin 1.3.0-canary.226.fa1f5e2.0 → 1.3.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.
- package/CHANGELOG.md +22 -0
- package/dist/commands/generate.plopfile.js +20 -28
- package/dist/commands/migrate.command.js +1 -1
- package/dist/commands/update.command.js +1 -1
- package/dist/utils/utils.npm.js +3 -3
- package/dist/utils/utils.packageManager.js +3 -3
- package/package.json +2 -2
- package/src/commands/generate.plopfile.ts +36 -31
- package/src/commands/migrate.command.ts +2 -2
- package/src/commands/update.command.ts +2 -2
- package/src/utils/utils.npm.ts +1 -1
- package/src/utils/utils.packageManager.ts +3 -3
- package/templates/_partials/frontend-getting-started.md +14 -14
- package/templates/common/.config/webpack/utils.ts +3 -5
- package/templates/common/package.json +1 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,25 @@
|
|
|
1
|
+
# v1.3.0 (Fri Apr 28 2023)
|
|
2
|
+
|
|
3
|
+
#### 🚀 Enhancement
|
|
4
|
+
|
|
5
|
+
- Create Plugin: Support different Node package managers [#226](https://github.com/grafana/plugin-tools/pull/226) ([@jackw](https://github.com/jackw))
|
|
6
|
+
|
|
7
|
+
#### 🐛 Bug Fix
|
|
8
|
+
|
|
9
|
+
- Documentation: Fix path in for template README.md for jest customizations [#218](https://github.com/grafana/plugin-tools/pull/218) ([@briangann](https://github.com/briangann))
|
|
10
|
+
|
|
11
|
+
#### 🔩 Dependency Updates
|
|
12
|
+
|
|
13
|
+
- Chore: Update `glob` to v10 [#230](https://github.com/grafana/plugin-tools/pull/230) ([@leventebalogh](https://github.com/leventebalogh))
|
|
14
|
+
|
|
15
|
+
#### Authors: 3
|
|
16
|
+
|
|
17
|
+
- Brian Gann ([@briangann](https://github.com/briangann))
|
|
18
|
+
- Jack Westbrook ([@jackw](https://github.com/jackw))
|
|
19
|
+
- Levente Balogh ([@leventebalogh](https://github.com/leventebalogh))
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
1
23
|
# v1.2.1 (Thu Mar 30 2023)
|
|
2
24
|
|
|
3
25
|
#### 🐛 Bug Fix
|
|
@@ -100,15 +100,16 @@ function default_1(plop) {
|
|
|
100
100
|
var pluginId = (0, utils_handlebars_1.normalizeId)(pluginName, orgName, pluginType);
|
|
101
101
|
var _b = (0, utils_packageManager_1.getPackageManagerFromUserAgent)(), packageManagerName = _b.packageManagerName, packageManagerVersion = _b.packageManagerVersion;
|
|
102
102
|
var packageManagerInstallCmd = (0, utils_packageManager_1.getPackageManagerInstallCmd)(packageManagerName);
|
|
103
|
+
var templateData = {
|
|
104
|
+
pluginId: pluginId,
|
|
105
|
+
packageManagerName: packageManagerName,
|
|
106
|
+
packageManagerInstallCmd: packageManagerInstallCmd,
|
|
107
|
+
packageManagerVersion: packageManagerVersion
|
|
108
|
+
};
|
|
103
109
|
var commonActions = getActionsForTemplateFolder({
|
|
104
110
|
folderPath: constants_1.TEMPLATE_PATHS.common,
|
|
105
111
|
exportPath: exportPath,
|
|
106
|
-
templateData:
|
|
107
|
-
pluginId: pluginId,
|
|
108
|
-
packageManagerName: packageManagerName,
|
|
109
|
-
packageManagerInstallCmd: packageManagerInstallCmd,
|
|
110
|
-
packageManagerVersion: packageManagerVersion
|
|
111
|
-
}
|
|
112
|
+
templateData: templateData
|
|
112
113
|
});
|
|
113
114
|
var pluginTypeSpecificActions = getActionsForTemplateFolder({
|
|
114
115
|
folderPath: constants_1.TEMPLATE_PATHS[pluginType],
|
|
@@ -130,25 +131,17 @@ function default_1(plop) {
|
|
|
130
131
|
? getActionsForTemplateFolder({
|
|
131
132
|
folderPath: constants_1.TEMPLATE_PATHS.ciWorkflows,
|
|
132
133
|
exportPath: exportPath,
|
|
133
|
-
templateData:
|
|
134
|
-
packageManagerName: packageManagerName,
|
|
135
|
-
packageManagerInstallCmd: packageManagerInstallCmd,
|
|
136
|
-
packageManagerVersion: packageManagerVersion
|
|
137
|
-
}
|
|
134
|
+
templateData: templateData
|
|
138
135
|
})
|
|
139
136
|
: [];
|
|
140
137
|
var isCompatibleWorkflowActions = hasGithubLevitateWorkflow
|
|
141
138
|
? getActionsForTemplateFolder({
|
|
142
139
|
folderPath: constants_1.TEMPLATE_PATHS.isCompatibleWorkflow,
|
|
143
140
|
exportPath: exportPath,
|
|
144
|
-
templateData:
|
|
145
|
-
packageManagerName: packageManagerName,
|
|
146
|
-
packageManagerInstallCmd: packageManagerInstallCmd,
|
|
147
|
-
packageManagerVersion: packageManagerVersion
|
|
148
|
-
}
|
|
141
|
+
templateData: templateData
|
|
149
142
|
})
|
|
150
143
|
: [];
|
|
151
|
-
var readmeActions = getActionsForReadme({ exportPath: exportPath });
|
|
144
|
+
var readmeActions = getActionsForReadme({ exportPath: exportPath, templateData: templateData });
|
|
152
145
|
return __spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], pluginActions, true), ciWorkflowActions, true), readmeActions, true), isCompatibleWorkflowActions, true), [
|
|
153
146
|
{
|
|
154
147
|
type: 'updateGoSdkAndModules'
|
|
@@ -162,26 +155,30 @@ function default_1(plop) {
|
|
|
162
155
|
}
|
|
163
156
|
exports["default"] = default_1;
|
|
164
157
|
function getActionsForReadme(_a) {
|
|
165
|
-
var exportPath = _a.exportPath;
|
|
158
|
+
var exportPath = _a.exportPath, templateData = _a.templateData;
|
|
166
159
|
return [
|
|
167
|
-
replacePatternWithTemplateInReadme('-- INSERT FRONTEND GETTING STARTED --', 'frontend-getting-started.md', exportPath),
|
|
168
|
-
replacePatternWithTemplateInReadme('-- INSERT BACKEND GETTING STARTED --', 'backend-getting-started.md', exportPath),
|
|
169
|
-
replacePatternWithTemplateInReadme('-- INSERT DISTRIBUTING YOUR PLUGIN --', 'distributing-your-plugin.md', exportPath),
|
|
160
|
+
replacePatternWithTemplateInReadme('-- INSERT FRONTEND GETTING STARTED --', 'frontend-getting-started.md', exportPath, templateData),
|
|
161
|
+
replacePatternWithTemplateInReadme('-- INSERT BACKEND GETTING STARTED --', 'backend-getting-started.md', exportPath, templateData),
|
|
162
|
+
replacePatternWithTemplateInReadme('-- INSERT DISTRIBUTING YOUR PLUGIN --', 'distributing-your-plugin.md', exportPath, templateData),
|
|
170
163
|
];
|
|
171
164
|
}
|
|
172
|
-
function replacePatternWithTemplateInReadme(pattern, partialsFile, exportPath) {
|
|
165
|
+
function replacePatternWithTemplateInReadme(pattern, partialsFile, exportPath, templateData) {
|
|
166
|
+
if (templateData === void 0) { templateData = {}; }
|
|
173
167
|
return {
|
|
174
168
|
type: 'modify',
|
|
175
169
|
path: path_1["default"].join(exportPath, 'README.md'),
|
|
176
170
|
pattern: pattern,
|
|
177
171
|
template: undefined,
|
|
178
172
|
templateFile: path_1["default"].join(constants_1.PARTIALS_DIR, partialsFile),
|
|
179
|
-
data: constants_1.EXTRA_TEMPLATE_VARIABLES
|
|
173
|
+
data: __assign(__assign({}, constants_1.EXTRA_TEMPLATE_VARIABLES), templateData)
|
|
180
174
|
};
|
|
181
175
|
}
|
|
182
176
|
function getActionsForTemplateFolder(_a) {
|
|
183
177
|
var folderPath = _a.folderPath, exportPath = _a.exportPath, _b = _a.templateData, templateData = _b === void 0 ? {} : _b;
|
|
184
178
|
var files = glob_1["default"].sync("".concat(folderPath, "/**"), { dot: true });
|
|
179
|
+
if (templateData.packageManagerName !== 'pnpm') {
|
|
180
|
+
files = files.filter(function (file) { return path_1["default"].basename(file) !== 'npmrc'; });
|
|
181
|
+
}
|
|
185
182
|
function getExportFileName(f) {
|
|
186
183
|
if (path_1["default"].basename(f) === 'gitignore') {
|
|
187
184
|
return '.gitignore';
|
|
@@ -194,11 +191,6 @@ function getActionsForTemplateFolder(_a) {
|
|
|
194
191
|
function getExportPath(f) {
|
|
195
192
|
return path_1["default"].relative(folderPath, path_1["default"].dirname(f));
|
|
196
193
|
}
|
|
197
|
-
if (templateData.packageManagerName !== 'pnpm') {
|
|
198
|
-
files = files.filter(function (file) {
|
|
199
|
-
return path_1["default"].basename(file) !== 'npmrc';
|
|
200
|
-
});
|
|
201
|
-
}
|
|
202
194
|
return files.filter(isFile).map(function (f) { return ({
|
|
203
195
|
type: 'add',
|
|
204
196
|
templateFile: f,
|
|
@@ -122,7 +122,7 @@ var migrate = function () { return __awaiter(void 0, void 0, void 0, function ()
|
|
|
122
122
|
(0, utils_console_1.printMessage)(constants_1.TEXT.updateNpmScriptsAborted);
|
|
123
123
|
}
|
|
124
124
|
packageManager = (0, utils_packageManager_1.getPackageManagerWithFallback)();
|
|
125
|
-
(0, utils_npm_1.
|
|
125
|
+
(0, utils_npm_1.writePackageManagerInPackageJson)(packageManager);
|
|
126
126
|
(0, utils_npm_1.cleanUpPackageJson)();
|
|
127
127
|
(0, utils_console_1.printSuccessMessage)(constants_1.TEXT.migrationCommandSuccess);
|
|
128
128
|
return [3, 12];
|
|
@@ -95,7 +95,7 @@ var update = function () { return __awaiter(void 0, void 0, void 0, function ()
|
|
|
95
95
|
(0, utils_console_1.printMessage)(constants_1.TEXT.updateNpmScriptsAborted);
|
|
96
96
|
}
|
|
97
97
|
packageManager = (0, utils_packageManager_1.getPackageManagerWithFallback)();
|
|
98
|
-
(0, utils_npm_1.
|
|
98
|
+
(0, utils_npm_1.writePackageManagerInPackageJson)(packageManager);
|
|
99
99
|
(0, utils_console_1.printSuccessMessage)(constants_1.TEXT.updateCommandSuccess);
|
|
100
100
|
return [3, 6];
|
|
101
101
|
case 5:
|
package/dist/utils/utils.npm.js
CHANGED
|
@@ -14,7 +14,7 @@ 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.
|
|
17
|
+
exports.cleanUpPackageJson = exports.writePackageManagerInPackageJson = 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"));
|
|
@@ -204,7 +204,7 @@ function updateNpmScripts() {
|
|
|
204
204
|
writePackageJson(packageJson);
|
|
205
205
|
}
|
|
206
206
|
exports.updateNpmScripts = updateNpmScripts;
|
|
207
|
-
function
|
|
207
|
+
function writePackageManagerInPackageJson(_a) {
|
|
208
208
|
var packageManagerName = _a.packageManagerName, packageManagerVersion = _a.packageManagerVersion;
|
|
209
209
|
var packageJson = getPackageJson();
|
|
210
210
|
if (!packageJson.packageManager) {
|
|
@@ -212,7 +212,7 @@ function writePackageManager(_a) {
|
|
|
212
212
|
writePackageJson(packageJson);
|
|
213
213
|
}
|
|
214
214
|
}
|
|
215
|
-
exports.
|
|
215
|
+
exports.writePackageManagerInPackageJson = writePackageManagerInPackageJson;
|
|
216
216
|
function cleanUpPackageJson() {
|
|
217
217
|
var packageJson = getPackageJson();
|
|
218
218
|
packageJson.scripts = sortKeysAlphabetically(packageJson.scripts);
|
|
@@ -9,7 +9,7 @@ var NPM_LOCKFILE = 'package-lock.json';
|
|
|
9
9
|
var PNPM_LOCKFILE = 'pnpm-lock.yaml';
|
|
10
10
|
var YARN_LOCKFILE = 'yarn.lock';
|
|
11
11
|
var SUPPORTED_PACKAGE_MANAGERS = ['npm', 'yarn', 'pnpm'];
|
|
12
|
-
var
|
|
12
|
+
var DEFAULT_PACKAGE_MANAGER = { packageManagerName: 'yarn', packageManagerVersion: '1.22.19' };
|
|
13
13
|
function getPackageManagerFromUserAgent() {
|
|
14
14
|
var agent = process.env.npm_config_user_agent;
|
|
15
15
|
var _a = agent.split('/'), name = _a[0], versionWithText = _a[1];
|
|
@@ -17,7 +17,7 @@ function getPackageManagerFromUserAgent() {
|
|
|
17
17
|
if (SUPPORTED_PACKAGE_MANAGERS.includes(name)) {
|
|
18
18
|
return { packageManagerName: name, packageManagerVersion: version.trimEnd() };
|
|
19
19
|
}
|
|
20
|
-
return
|
|
20
|
+
return DEFAULT_PACKAGE_MANAGER;
|
|
21
21
|
}
|
|
22
22
|
exports.getPackageManagerFromUserAgent = getPackageManagerFromUserAgent;
|
|
23
23
|
function getPackageManagerWithFallback() {
|
|
@@ -29,7 +29,7 @@ function getPackageManagerWithFallback() {
|
|
|
29
29
|
if (packageManagerFromLockFile) {
|
|
30
30
|
return packageManagerFromLockFile;
|
|
31
31
|
}
|
|
32
|
-
return
|
|
32
|
+
return DEFAULT_PACKAGE_MANAGER;
|
|
33
33
|
}
|
|
34
34
|
exports.getPackageManagerWithFallback = getPackageManagerWithFallback;
|
|
35
35
|
function getPackageManagerInstallCmd(packageManagerName) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@grafana/create-plugin",
|
|
3
|
-
"version": "1.3.0
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"repository": {
|
|
6
6
|
"directory": "packages/create-plugin",
|
|
@@ -64,5 +64,5 @@
|
|
|
64
64
|
"engines": {
|
|
65
65
|
"node": ">=16"
|
|
66
66
|
},
|
|
67
|
-
"gitHead": "
|
|
67
|
+
"gitHead": "75bcdffdcffa1302a0ef270e149c58c4f921a7a7"
|
|
68
68
|
}
|
|
@@ -88,17 +88,17 @@ export default function (plop: NodePlopAPI) {
|
|
|
88
88
|
// Support the users package manager of choice.
|
|
89
89
|
const { packageManagerName, packageManagerVersion } = getPackageManagerFromUserAgent();
|
|
90
90
|
const packageManagerInstallCmd = getPackageManagerInstallCmd(packageManagerName);
|
|
91
|
-
|
|
91
|
+
const templateData = {
|
|
92
|
+
pluginId,
|
|
93
|
+
packageManagerName,
|
|
94
|
+
packageManagerInstallCmd,
|
|
95
|
+
packageManagerVersion,
|
|
96
|
+
};
|
|
92
97
|
// Copy over files that are shared between plugins types
|
|
93
98
|
const commonActions = getActionsForTemplateFolder({
|
|
94
99
|
folderPath: TEMPLATE_PATHS.common,
|
|
95
100
|
exportPath,
|
|
96
|
-
templateData
|
|
97
|
-
pluginId,
|
|
98
|
-
packageManagerName,
|
|
99
|
-
packageManagerInstallCmd,
|
|
100
|
-
packageManagerVersion,
|
|
101
|
-
},
|
|
101
|
+
templateData,
|
|
102
102
|
});
|
|
103
103
|
|
|
104
104
|
// Copy over files from the plugin type specific folder, e.g. "templates/app" for "app" plugins ("app" | "panel" | "datasource").
|
|
@@ -132,11 +132,7 @@ export default function (plop: NodePlopAPI) {
|
|
|
132
132
|
? getActionsForTemplateFolder({
|
|
133
133
|
folderPath: TEMPLATE_PATHS.ciWorkflows,
|
|
134
134
|
exportPath,
|
|
135
|
-
templateData
|
|
136
|
-
packageManagerName,
|
|
137
|
-
packageManagerInstallCmd,
|
|
138
|
-
packageManagerVersion,
|
|
139
|
-
},
|
|
135
|
+
templateData,
|
|
140
136
|
})
|
|
141
137
|
: [];
|
|
142
138
|
|
|
@@ -144,16 +140,12 @@ export default function (plop: NodePlopAPI) {
|
|
|
144
140
|
? getActionsForTemplateFolder({
|
|
145
141
|
folderPath: TEMPLATE_PATHS.isCompatibleWorkflow,
|
|
146
142
|
exportPath,
|
|
147
|
-
templateData
|
|
148
|
-
packageManagerName,
|
|
149
|
-
packageManagerInstallCmd,
|
|
150
|
-
packageManagerVersion,
|
|
151
|
-
},
|
|
143
|
+
templateData,
|
|
152
144
|
})
|
|
153
145
|
: [];
|
|
154
146
|
|
|
155
147
|
// Replace conditional bits in the Readme files
|
|
156
|
-
const readmeActions = getActionsForReadme({ exportPath });
|
|
148
|
+
const readmeActions = getActionsForReadme({ exportPath, templateData });
|
|
157
149
|
|
|
158
150
|
return [
|
|
159
151
|
...pluginActions,
|
|
@@ -171,22 +163,31 @@ export default function (plop: NodePlopAPI) {
|
|
|
171
163
|
});
|
|
172
164
|
}
|
|
173
165
|
|
|
174
|
-
function getActionsForReadme({
|
|
166
|
+
function getActionsForReadme({
|
|
167
|
+
exportPath,
|
|
168
|
+
templateData,
|
|
169
|
+
}: {
|
|
170
|
+
exportPath: string;
|
|
171
|
+
templateData: Record<string, string>;
|
|
172
|
+
}): ModifyActionConfig[] {
|
|
175
173
|
return [
|
|
176
174
|
replacePatternWithTemplateInReadme(
|
|
177
175
|
'-- INSERT FRONTEND GETTING STARTED --',
|
|
178
176
|
'frontend-getting-started.md',
|
|
179
|
-
exportPath
|
|
177
|
+
exportPath,
|
|
178
|
+
templateData
|
|
180
179
|
),
|
|
181
180
|
replacePatternWithTemplateInReadme(
|
|
182
181
|
'-- INSERT BACKEND GETTING STARTED --',
|
|
183
182
|
'backend-getting-started.md',
|
|
184
|
-
exportPath
|
|
183
|
+
exportPath,
|
|
184
|
+
templateData
|
|
185
185
|
),
|
|
186
186
|
replacePatternWithTemplateInReadme(
|
|
187
187
|
'-- INSERT DISTRIBUTING YOUR PLUGIN --',
|
|
188
188
|
'distributing-your-plugin.md',
|
|
189
|
-
exportPath
|
|
189
|
+
exportPath,
|
|
190
|
+
templateData
|
|
190
191
|
),
|
|
191
192
|
];
|
|
192
193
|
}
|
|
@@ -194,7 +195,8 @@ function getActionsForReadme({ exportPath }: { exportPath: string }): ModifyActi
|
|
|
194
195
|
function replacePatternWithTemplateInReadme(
|
|
195
196
|
pattern: string,
|
|
196
197
|
partialsFile: string,
|
|
197
|
-
exportPath: string
|
|
198
|
+
exportPath: string,
|
|
199
|
+
templateData: Record<string, string> = {}
|
|
198
200
|
): ModifyActionConfig {
|
|
199
201
|
return {
|
|
200
202
|
type: 'modify',
|
|
@@ -203,7 +205,10 @@ function replacePatternWithTemplateInReadme(
|
|
|
203
205
|
// @ts-ignore
|
|
204
206
|
template: undefined,
|
|
205
207
|
templateFile: path.join(PARTIALS_DIR, partialsFile),
|
|
206
|
-
data:
|
|
208
|
+
data: {
|
|
209
|
+
...EXTRA_TEMPLATE_VARIABLES,
|
|
210
|
+
...templateData,
|
|
211
|
+
},
|
|
207
212
|
};
|
|
208
213
|
}
|
|
209
214
|
|
|
@@ -218,6 +223,12 @@ function getActionsForTemplateFolder({
|
|
|
218
223
|
templateData?: Record<string, string>;
|
|
219
224
|
}) {
|
|
220
225
|
let files = glob.sync(`${folderPath}/**`, { dot: true });
|
|
226
|
+
|
|
227
|
+
// The npmrc file is only useful for `pnpm` settings. We can remove it for other package managers.
|
|
228
|
+
if (templateData.packageManagerName !== 'pnpm') {
|
|
229
|
+
files = files.filter((file) => path.basename(file) !== 'npmrc');
|
|
230
|
+
}
|
|
231
|
+
|
|
221
232
|
function getExportFileName(f: string) {
|
|
222
233
|
// yarn and npm packing will not include `.gitignore` files
|
|
223
234
|
// so we have to manually rename them to add the dot prefix
|
|
@@ -230,17 +241,11 @@ function getActionsForTemplateFolder({
|
|
|
230
241
|
|
|
231
242
|
return path.extname(f) === '.hbs' ? path.basename(f, '.hbs') : path.basename(f);
|
|
232
243
|
}
|
|
244
|
+
|
|
233
245
|
function getExportPath(f: string) {
|
|
234
246
|
return path.relative(folderPath, path.dirname(f));
|
|
235
247
|
}
|
|
236
248
|
|
|
237
|
-
// Remove the npmrc file if not running `pnpm`.
|
|
238
|
-
if (templateData.packageManagerName !== 'pnpm') {
|
|
239
|
-
files = files.filter((file) => {
|
|
240
|
-
return path.basename(file) !== 'npmrc';
|
|
241
|
-
});
|
|
242
|
-
}
|
|
243
|
-
|
|
244
249
|
return files.filter(isFile).map((f) => ({
|
|
245
250
|
type: 'add',
|
|
246
251
|
templateFile: f,
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
removeNpmDependencies,
|
|
11
11
|
updateNpmScripts,
|
|
12
12
|
cleanUpPackageJson,
|
|
13
|
-
|
|
13
|
+
writePackageManagerInPackageJson,
|
|
14
14
|
} from '../utils/utils.npm';
|
|
15
15
|
import { getPackageManagerWithFallback } from '../utils/utils.packageManager';
|
|
16
16
|
|
|
@@ -99,7 +99,7 @@ export const migrate = async () => {
|
|
|
99
99
|
|
|
100
100
|
// Guarantee that the package manager property is set in the package.json file if it is missing
|
|
101
101
|
const packageManager = getPackageManagerWithFallback();
|
|
102
|
-
|
|
102
|
+
writePackageManagerInPackageJson(packageManager);
|
|
103
103
|
|
|
104
104
|
// Tidy package.json file so any changed fields are sorted as a
|
|
105
105
|
// package manager would expect.
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
hasNpmDependenciesToUpdate,
|
|
7
7
|
getPackageJsonUpdatesAsText,
|
|
8
8
|
updateNpmScripts,
|
|
9
|
-
|
|
9
|
+
writePackageManagerInPackageJson,
|
|
10
10
|
} from '../utils/utils.npm';
|
|
11
11
|
import { getPackageManagerWithFallback } from '../utils/utils.packageManager';
|
|
12
12
|
|
|
@@ -69,7 +69,7 @@ export const update = async () => {
|
|
|
69
69
|
|
|
70
70
|
// Guarantee that the package manager property is set in the package.json file if it is missing
|
|
71
71
|
const packageManager = getPackageManagerWithFallback();
|
|
72
|
-
|
|
72
|
+
writePackageManagerInPackageJson(packageManager);
|
|
73
73
|
|
|
74
74
|
// 4. Summary
|
|
75
75
|
// -------------
|
package/src/utils/utils.npm.ts
CHANGED
|
@@ -238,7 +238,7 @@ export function updateNpmScripts() {
|
|
|
238
238
|
writePackageJson(packageJson);
|
|
239
239
|
}
|
|
240
240
|
|
|
241
|
-
export function
|
|
241
|
+
export function writePackageManagerInPackageJson({ packageManagerName, packageManagerVersion }: PackageManager) {
|
|
242
242
|
const packageJson = getPackageJson();
|
|
243
243
|
if (!packageJson.packageManager) {
|
|
244
244
|
packageJson.packageManager = `${packageManagerName}@${packageManagerVersion}`;
|
|
@@ -7,7 +7,7 @@ const NPM_LOCKFILE = 'package-lock.json';
|
|
|
7
7
|
const PNPM_LOCKFILE = 'pnpm-lock.yaml';
|
|
8
8
|
const YARN_LOCKFILE = 'yarn.lock';
|
|
9
9
|
const SUPPORTED_PACKAGE_MANAGERS = ['npm', 'yarn', 'pnpm'];
|
|
10
|
-
const
|
|
10
|
+
const DEFAULT_PACKAGE_MANAGER = { packageManagerName: 'yarn', packageManagerVersion: '1.22.19' };
|
|
11
11
|
|
|
12
12
|
export type PackageManager = {
|
|
13
13
|
packageManagerName: string;
|
|
@@ -24,7 +24,7 @@ export function getPackageManagerFromUserAgent(): PackageManager {
|
|
|
24
24
|
return { packageManagerName: name, packageManagerVersion: version.trimEnd() };
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
return
|
|
27
|
+
return DEFAULT_PACKAGE_MANAGER;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
export function getPackageManagerWithFallback() {
|
|
@@ -38,7 +38,7 @@ export function getPackageManagerWithFallback() {
|
|
|
38
38
|
return packageManagerFromLockFile;
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
return
|
|
41
|
+
return DEFAULT_PACKAGE_MANAGER;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
export function getPackageManagerInstallCmd(packageManagerName: string) {
|
|
@@ -3,53 +3,53 @@
|
|
|
3
3
|
1. Install dependencies
|
|
4
4
|
|
|
5
5
|
```bash
|
|
6
|
-
|
|
6
|
+
{{ packageManagerName }} run install
|
|
7
7
|
```
|
|
8
8
|
|
|
9
9
|
2. Build plugin in development mode and run in watch mode
|
|
10
10
|
|
|
11
11
|
```bash
|
|
12
|
-
|
|
12
|
+
{{ packageManagerName }} run dev
|
|
13
13
|
```
|
|
14
14
|
|
|
15
15
|
3. Build plugin in production mode
|
|
16
16
|
|
|
17
17
|
```bash
|
|
18
|
-
|
|
18
|
+
{{ packageManagerName }} run build
|
|
19
19
|
```
|
|
20
20
|
|
|
21
21
|
4. Run the tests (using Jest)
|
|
22
22
|
|
|
23
23
|
```bash
|
|
24
24
|
# Runs the tests and watches for changes, requires git init first
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
{{ packageManagerName }} run test
|
|
26
|
+
|
|
27
27
|
# Exits after running all the tests
|
|
28
|
-
|
|
28
|
+
{{ packageManagerName }} run test:ci
|
|
29
29
|
```
|
|
30
30
|
|
|
31
31
|
5. Spin up a Grafana instance and run the plugin inside it (using Docker)
|
|
32
32
|
|
|
33
33
|
```bash
|
|
34
|
-
|
|
34
|
+
{{ packageManagerName }} run server
|
|
35
35
|
```
|
|
36
36
|
|
|
37
37
|
6. Run the E2E tests (using Cypress)
|
|
38
38
|
|
|
39
39
|
```bash
|
|
40
|
-
# Spins up a Grafana instance first that we tests against
|
|
41
|
-
|
|
42
|
-
|
|
40
|
+
# Spins up a Grafana instance first that we tests against
|
|
41
|
+
{{ packageManagerName }} run server
|
|
42
|
+
|
|
43
43
|
# Starts the tests
|
|
44
|
-
|
|
44
|
+
{{ packageManagerName }} run e2e
|
|
45
45
|
```
|
|
46
46
|
|
|
47
47
|
7. Run the linter
|
|
48
48
|
|
|
49
49
|
```bash
|
|
50
|
-
|
|
51
|
-
|
|
50
|
+
{{ packageManagerName }} run lint
|
|
51
|
+
|
|
52
52
|
# or
|
|
53
53
|
|
|
54
|
-
|
|
54
|
+
{{ packageManagerName }} run lint:fix
|
|
55
55
|
```
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import util from 'util';
|
|
4
|
-
import glob from 'glob';
|
|
4
|
+
import { glob } from 'glob';
|
|
5
5
|
import { SOURCE_DIR } from './constants';
|
|
6
6
|
|
|
7
|
-
const globAsync = util.promisify(glob);
|
|
8
|
-
|
|
9
7
|
export function getPackageJson() {
|
|
10
8
|
return require(path.resolve(process.cwd(), 'package.json'));
|
|
11
9
|
}
|
|
@@ -21,11 +19,11 @@ export function hasReadme() {
|
|
|
21
19
|
// Support bundling nested plugins by finding all plugin.json files in src directory
|
|
22
20
|
// then checking for a sibling module.[jt]sx? file.
|
|
23
21
|
export async function getEntries(): Promise<Record<string, string>> {
|
|
24
|
-
const pluginsJson = await
|
|
22
|
+
const pluginsJson = await glob('**/src/**/plugin.json', { absolute: true });
|
|
25
23
|
|
|
26
24
|
const plugins = await Promise.all(pluginsJson.map((pluginJson) => {
|
|
27
25
|
const folder = path.dirname(pluginJson);
|
|
28
|
-
return
|
|
26
|
+
return glob(`${folder}/module.{ts,tsx,js,jsx}`, { absolute: true });
|
|
29
27
|
})
|
|
30
28
|
);
|
|
31
29
|
|
|
@@ -28,7 +28,6 @@
|
|
|
28
28
|
"@swc/jest": "^0.2.23",
|
|
29
29
|
"@testing-library/jest-dom": "^5.16.2",
|
|
30
30
|
"@testing-library/react": "^12.1.4",
|
|
31
|
-
"@types/glob": "^8.0.0",
|
|
32
31
|
"@types/jest": "^29.2.2",
|
|
33
32
|
"@types/lodash": "^4.14.188",
|
|
34
33
|
"@types/node": "^18.11.9",
|
|
@@ -39,7 +38,7 @@
|
|
|
39
38
|
"css-loader": "^6.7.1",
|
|
40
39
|
"eslint-webpack-plugin": "^3.1.1",
|
|
41
40
|
"fork-ts-checker-webpack-plugin": "^7.2.0",
|
|
42
|
-
"glob": "^
|
|
41
|
+
"glob": "^10.0.0",
|
|
43
42
|
"identity-obj-proxy": "3.0.0",
|
|
44
43
|
"jest": "^29.3.1",
|
|
45
44
|
"jest-environment-jsdom": "^29.3.1",
|