chore: bump @grafana/create-plugin configuration to 5.26.4 (#2082)
Bumps [`@grafana/create-plugin`](https://github.com/grafana/plugin-tools/tree/main/packages/create-plugin) configuration from 4.2.1 to 5.26.4. **Notes for reviewer:** This is an auto-generated PR which ran `@grafana/create-plugin update`. Please consult the create-plugin [CHANGELOG.md](https://github.com/grafana/plugin-tools/blob/main/packages/create-plugin/CHANGELOG.md) to understand what may have changed. Please review the changes thoroughly before merging. --------- Co-authored-by: grafana-plugins-platform-bot[bot] <144369747+grafana-plugins-platform-bot[bot]@users.noreply.github.com> Co-authored-by: Zoltán Bedi <zoltan.bedi@gmail.com>
This commit is contained in:
committed by
GitHub
parent
e76741b453
commit
b13d567eee
@@ -3,7 +3,7 @@ import process from 'process';
|
||||
import os from 'os';
|
||||
import path from 'path';
|
||||
import { glob } from 'glob';
|
||||
import { SOURCE_DIR } from './constants';
|
||||
import { SOURCE_DIR } from './constants.ts';
|
||||
|
||||
export function isWSL() {
|
||||
if (process.platform !== 'linux') {
|
||||
@@ -21,12 +21,22 @@ export function isWSL() {
|
||||
}
|
||||
}
|
||||
|
||||
function loadJson(path: string) {
|
||||
const rawJson = fs.readFileSync(path, 'utf8');
|
||||
return JSON.parse(rawJson);
|
||||
}
|
||||
|
||||
export function getPackageJson() {
|
||||
return require(path.resolve(process.cwd(), 'package.json'));
|
||||
return loadJson(path.resolve(process.cwd(), 'package.json'));
|
||||
}
|
||||
|
||||
export function getPluginJson() {
|
||||
return require(path.resolve(process.cwd(), `${SOURCE_DIR}/plugin.json`));
|
||||
return loadJson(path.resolve(process.cwd(), `${SOURCE_DIR}/plugin.json`));
|
||||
}
|
||||
|
||||
export function getCPConfigVersion() {
|
||||
const cprcJson = path.resolve(process.cwd(), './.config', '.cprc.json');
|
||||
return fs.existsSync(cprcJson) ? loadJson(cprcJson).version : { version: 'unknown' };
|
||||
}
|
||||
|
||||
export function hasReadme() {
|
||||
@@ -35,7 +45,7 @@ export function hasReadme() {
|
||||
|
||||
// Support bundling nested plugins by finding all plugin.json files in src directory
|
||||
// then checking for a sibling module.[jt]sx? file.
|
||||
export async function getEntries(): Promise<Record<string, string>> {
|
||||
export async function getEntries() {
|
||||
const pluginsJson = await glob('**/src/**/plugin.json', { absolute: true });
|
||||
|
||||
const plugins = await Promise.all(
|
||||
@@ -45,14 +55,14 @@ export async function getEntries(): Promise<Record<string, string>> {
|
||||
})
|
||||
);
|
||||
|
||||
return plugins.reduce((result, modules) => {
|
||||
return modules.reduce((result, module) => {
|
||||
return plugins.reduce<Record<string, string>>((result, modules) => {
|
||||
return modules.reduce((innerResult, module) => {
|
||||
const pluginPath = path.dirname(module);
|
||||
const pluginName = path.relative(process.cwd(), pluginPath).replace(/src\/?/i, '');
|
||||
const entryName = pluginName === '' ? 'module' : `${pluginName}/module`;
|
||||
|
||||
result[entryName] = module;
|
||||
return result;
|
||||
innerResult[entryName] = module;
|
||||
return innerResult;
|
||||
}, result);
|
||||
}, {});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user