mirror of
https://github.com/grafana/grafana.git
synced 2025-09-17 16:42:57 +08:00
Alerting: Adds "testing" target to package (#107728)
This commit is contained in:
@ -54,11 +54,11 @@
|
||||
"scripts": {
|
||||
"build": "tsc -p ./tsconfig.build.json && rollup -c rollup.config.ts --configPlugin esbuild",
|
||||
"bundle": "rollup -c rollup.config.ts --configPlugin esbuild",
|
||||
"clean": "rimraf ./dist ./compiled ./unstable ./package.tgz",
|
||||
"clean": "rimraf ./dist ./compiled ./unstable ./testing ./package.tgz",
|
||||
"typecheck": "tsc --emitDeclarationOnly false --noEmit",
|
||||
"codegen": "rtk-query-codegen-openapi ./scripts/codegen.ts",
|
||||
"prepack": "cp package.json package.json.bak && ALIAS_PACKAGE_NAME=unstable node ../../scripts/prepare-npm-package.js",
|
||||
"postpack": "mv package.json.bak package.json && rimraf ./unstable"
|
||||
"prepack": "cp package.json package.json.bak && ALIAS_PACKAGE_NAME=testing,unstable node ../../scripts/prepare-npm-package.js",
|
||||
"postpack": "mv package.json.bak package.json && rimraf ./unstable ./testing"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@grafana/test-utils": "workspace:*",
|
||||
|
@ -18,4 +18,9 @@ export default [
|
||||
output: [cjsOutput(pkg), esmOutput(pkg, 'grafana-alerting')],
|
||||
treeshake: false,
|
||||
},
|
||||
{
|
||||
input: 'src/testing.ts',
|
||||
plugins,
|
||||
output: [cjsOutput(pkg), esmOutput(pkg, 'grafana-alerting')],
|
||||
},
|
||||
];
|
||||
|
@ -4,3 +4,6 @@ export * from './grafana/api/v0alpha1/mocks/handlers';
|
||||
// export mocks and factories
|
||||
export * from './grafana/api/v0alpha1/mocks/fakes/common';
|
||||
export * from './grafana/api/v0alpha1/mocks/fakes/Receivers';
|
||||
|
||||
// scenarios
|
||||
export * from './grafana/contactPoints/components/ContactPointSelector/ContactPointSelector.test.scenario';
|
||||
|
@ -52,26 +52,35 @@ try {
|
||||
// then generate an additional "nested" package.json for typescript resolution that
|
||||
// doesn't use the exports property in package.json.
|
||||
if (process.env.ALIAS_PACKAGE_NAME) {
|
||||
const aliasName = process.env.ALIAS_PACKAGE_NAME;
|
||||
const aliasNames = process.env.ALIAS_PACKAGE_NAME.split(',');
|
||||
|
||||
const additionalExports = aliasNames.reduce((acc, alias) => {
|
||||
acc[`./${alias}`] = {
|
||||
import: {
|
||||
types: typesIndex.replace('index', alias),
|
||||
default: esmIndex.replace('index', alias),
|
||||
},
|
||||
require: {
|
||||
types: typesIndex.replace('index', alias),
|
||||
default: cjsIndex.replace('index', alias),
|
||||
},
|
||||
};
|
||||
return acc;
|
||||
}, {});
|
||||
|
||||
pkgJson.update({
|
||||
exports: {
|
||||
...pkgJson.content.exports,
|
||||
[`./${aliasName}`]: {
|
||||
import: {
|
||||
types: typesIndex.replace('index', aliasName),
|
||||
default: esmIndex.replace('index', aliasName),
|
||||
...additionalExports,
|
||||
},
|
||||
require: {
|
||||
types: typesIndex.replace('index', aliasName),
|
||||
default: cjsIndex.replace('index', aliasName),
|
||||
},
|
||||
},
|
||||
},
|
||||
files: [...pkgJson.content.files, aliasName],
|
||||
files: [...pkgJson.content.files, ...aliasNames],
|
||||
});
|
||||
await pkgJson.save();
|
||||
|
||||
for await (const aliasName of aliasNames) {
|
||||
await createAliasPackageJsonFiles(pkgJson.content, aliasName);
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
process.exit(1);
|
||||
|
Reference in New Issue
Block a user