grafana/toolkit: Remove hack to expose plugin/e2e exports & types (#19467)

This commit is contained in:
Dominik Prokop
2019-09-27 17:07:20 +02:00
committed by Ryan McKinley
parent 00e7c7c4b7
commit 1b5e7ceee7
15 changed files with 15 additions and 37 deletions

View File

@@ -100,6 +100,5 @@
},
"_moduleAliases": {
"puppeteer": "node_modules/puppeteer-core"
},
"types": "src/index.ts"
}
}

View File

@@ -3,7 +3,6 @@ import * as fs from 'fs';
import chalk from 'chalk';
import { useSpinner } from '../utils/useSpinner';
import { Task, TaskRunner } from './task';
import escapeRegExp from 'lodash/escapeRegExp';
const path = require('path');
@@ -120,21 +119,6 @@ const toolkitBuildTaskRunner: TaskRunner<ToolkitBuildOptions> = async () => {
fs.mkdirSync('./dist/sass');
await copyFiles();
await copySassFiles();
// RYAN HACK HACK HACK
// when Dominik is back from vacation, we can find a better way
// This moves the index to the root so plugin e2e tests can import them
console.warn('hacking an index.js file for toolkit. Help!');
const index = `${distDir}/src/index.js`;
fs.readFile(index, 'utf8', (err, data) => {
const pattern = 'require("./';
const js = data.replace(new RegExp(escapeRegExp(pattern), 'g'), 'require("./src/');
fs.writeFile(`${distDir}/index.js`, js, err => {
if (err) {
throw new Error('Error writing index: ' + err);
}
});
});
};
export const toolkitBuildTask = new Task<ToolkitBuildOptions>('@grafana/toolkit build', toolkitBuildTaskRunner);

View File

@@ -1,6 +0,0 @@
export * from './e2e';
// Namespace for Plugins
import * as plugins from './plugins';
export { plugins };

View File

@@ -1,6 +1,7 @@
import { Browser, Page } from 'puppeteer-core';
import { e2eScenario, takeScreenShot, plugins, pages } from '@grafana/toolkit';
import { e2eScenario, takeScreenShot, pages } from '@grafana/toolkit/src/e2e';
import { getEndToEndSettings } from '@grafana/toolkit/src/plugins';
// ****************************************************************
// NOTE, This file is copied to plugins at runtime, it is not run locally
@@ -11,7 +12,7 @@ const sleep = (milliseconds: number) => {
};
e2eScenario('Common Plugin Test', 'should pass', async (browser: Browser, page: Page) => {
const settings = plugins.getEndToEndSettings();
const settings = getEndToEndSettings();
const pluginPage = pages.getPluginPage(settings.plugin.id);
await pluginPage.init(page);
await pluginPage.navigateTo();

View File

@@ -7,7 +7,7 @@
"rootDirs": ["."],
"outDir": "dist/src",
"declaration": true,
"declarationDir": "dist",
"declarationDir": "dist/src",
"typeRoots": ["./node_modules/@types"],
"esModuleInterop": true,
"lib": ["es2015", "es2017.string", "dom"]