-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add github action, update packages and config.
- Loading branch information
Showing
24 changed files
with
2,281 additions
and
2,134 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,4 +13,4 @@ module.exports = { | |
"singleQuote": true, | ||
"useTabs": false, | ||
"tabWidth": 2 | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// Due to the grafana/ui Icon component making fetch requests to | ||
// `/public/img/icon/<icon_name>.svg` we need to mock react-inlinesvg to prevent | ||
// the failed fetch requests from displaying errors in console. | ||
|
||
import React from 'react'; | ||
|
||
type Callback = (...args: any[]) => void; | ||
|
||
export interface StorageItem { | ||
content: string; | ||
queue: Callback[]; | ||
status: string; | ||
} | ||
|
||
export const cacheStore: { [key: string]: StorageItem } = Object.create(null); | ||
|
||
const SVG_FILE_NAME_REGEX = /(.+)\/(.+)\.svg$/; | ||
|
||
const InlineSVG = ({ src }: { src: string }) => { | ||
// testId will be the file name without extension (e.g. `public/img/icons/angle-double-down.svg` -> `angle-double-down`) | ||
const testId = src.replace(SVG_FILE_NAME_REGEX, '$2'); | ||
return <svg xmlns="http://www.w3.org/2000/svg" data-testid={testId} viewBox="0 0 24 24" />; | ||
}; | ||
|
||
export default InlineSVG; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* ⚠️⚠️⚠️ THIS FILE WAS SCAFFOLDED BY `@grafana/create-plugin`. DO NOT EDIT THIS FILE DIRECTLY. ⚠️⚠️⚠️ | ||
* | ||
* In order to extend the configuration follow the steps in .config/README.md | ||
*/ | ||
|
||
/* | ||
* This utility function is useful in combination with jest `transformIgnorePatterns` config | ||
* to transform specific packages (e.g.ES modules) in a projects node_modules folder. | ||
*/ | ||
const nodeModulesToTransform = (moduleNames) => `node_modules\/(?!(${moduleNames.join('|')})\/)`; | ||
|
||
// Array of known nested grafana package dependencies that only bundle an ESM version | ||
const grafanaESModules = [ | ||
'.pnpm', // Support using pnpm symlinked packages | ||
'd3', | ||
'd3-color', | ||
'd3-force', | ||
'd3-interpolate', | ||
'd3-scale-chromatic', | ||
'ol', | ||
'react-colorful', | ||
'uuid', | ||
]; | ||
|
||
module.exports = { | ||
nodeModulesToTransform, | ||
grafanaESModules | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,40 @@ | ||
import fs from 'fs'; | ||
import path from 'path'; | ||
import util from 'util'; | ||
import glob from 'glob'; | ||
import { glob } from 'glob'; | ||
import { SOURCE_DIR } from './constants'; | ||
|
||
const globAsync = util.promisify(glob); | ||
|
||
export function getPackageJson() { | ||
return require(path.resolve(process.cwd(), 'package.json')); | ||
} | ||
|
||
export function getPluginId() { | ||
const { id } = require(path.resolve(process.cwd(), `${SOURCE_DIR}/plugin.json`)); | ||
|
||
return id; | ||
export function getPluginJson() { | ||
return require(path.resolve(process.cwd(), `${SOURCE_DIR}/plugin.json`)); | ||
} | ||
|
||
export function hasReadme() { | ||
return fs.existsSync(path.resolve(process.cwd(), SOURCE_DIR, 'README.md')); | ||
} | ||
|
||
// 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>> { | ||
const parent = '..'; | ||
const pluginsJson = await globAsync('**/src/**/plugin.json'); | ||
|
||
const plugins = await Promise.all(pluginsJson.map(pluginJson => { | ||
const folder = path.dirname(pluginJson); | ||
return globAsync(`${folder}/module.{ts,tsx,js}`); | ||
})); | ||
const pluginsJson = await glob('**/src/**/plugin.json', { absolute: true }); | ||
|
||
const plugins = await Promise.all(pluginsJson.map((pluginJson) => { | ||
const folder = path.dirname(pluginJson); | ||
return glob(`${folder}/module.{ts,tsx,js,jsx}`, { absolute: true }); | ||
}) | ||
); | ||
|
||
return plugins.reduce((result, modules) => { | ||
return modules.reduce((result, module) => { | ||
const pluginPath = path.resolve(path.dirname(module), parent); | ||
const pluginName = path.basename(pluginPath); | ||
const entryName = plugins.length > 1 ? `${pluginName}/module` : 'module'; | ||
result[entryName] = path.join(parent, 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; | ||
}, result); | ||
}, {}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.