Commit e3922c6e by Andreas Motl Committed by Ryan McKinley

grafana/toolkit: Fixup save artifacts in a zip id in the folder (#20071) (#20139)

parent f0b3dc22
...@@ -130,7 +130,7 @@ const packagePluginRunner: TaskRunner<PluginCIOptions> = async () => { ...@@ -130,7 +130,7 @@ const packagePluginRunner: TaskRunner<PluginCIOptions> = async () => {
const start = Date.now(); const start = Date.now();
const ciDir = getCiFolder(); const ciDir = getCiFolder();
const packagesDir = path.resolve(ciDir, 'packages'); const packagesDir = path.resolve(ciDir, 'packages');
let distDir = path.resolve(ciDir, 'dist'); const distDir = path.resolve(ciDir, 'dist');
const docsDir = path.resolve(ciDir, 'docs'); const docsDir = path.resolve(ciDir, 'docs');
const grafanaEnvDir = path.resolve(ciDir, 'grafana-test-env'); const grafanaEnvDir = path.resolve(ciDir, 'grafana-test-env');
await execa('rimraf', [packagesDir, distDir, grafanaEnvDir]); await execa('rimraf', [packagesDir, distDir, grafanaEnvDir]);
...@@ -139,7 +139,7 @@ const packagePluginRunner: TaskRunner<PluginCIOptions> = async () => { ...@@ -139,7 +139,7 @@ const packagePluginRunner: TaskRunner<PluginCIOptions> = async () => {
// Updating the dist dir to have a pluginId named directory in it // Updating the dist dir to have a pluginId named directory in it
// The zip needs to contain the plugin code wrapped in directory with a pluginId name // The zip needs to contain the plugin code wrapped in directory with a pluginId name
distDir = path.resolve(ciDir, `dist/${getPluginId()}`); const distContentDir = path.resolve(distDir, getPluginId());
fs.mkdirSync(grafanaEnvDir); fs.mkdirSync(grafanaEnvDir);
console.log('Build Dist Folder'); console.log('Build Dist Folder');
...@@ -147,7 +147,7 @@ const packagePluginRunner: TaskRunner<PluginCIOptions> = async () => { ...@@ -147,7 +147,7 @@ const packagePluginRunner: TaskRunner<PluginCIOptions> = async () => {
// 1. Check for a local 'dist' folder // 1. Check for a local 'dist' folder
const d = path.resolve(process.cwd(), 'dist'); const d = path.resolve(process.cwd(), 'dist');
if (fs.existsSync(d)) { if (fs.existsSync(d)) {
await execa('cp', ['-rn', d + '/.', distDir]); await execa('cp', ['-rn', d + '/.', distContentDir]);
} }
// 2. Look for any 'dist' folders under ci/job/XXX/dist // 2. Look for any 'dist' folders under ci/job/XXX/dist
...@@ -156,7 +156,7 @@ const packagePluginRunner: TaskRunner<PluginCIOptions> = async () => { ...@@ -156,7 +156,7 @@ const packagePluginRunner: TaskRunner<PluginCIOptions> = async () => {
const contents = path.resolve(ciDir, 'jobs', j, 'dist'); const contents = path.resolve(ciDir, 'jobs', j, 'dist');
if (fs.existsSync(contents)) { if (fs.existsSync(contents)) {
try { try {
await execa('cp', ['-rn', contents + '/.', distDir]); await execa('cp', ['-rn', contents + '/.', distContentDir]);
} catch (er) { } catch (er) {
throw new Error('Duplicate files found in dist folders'); throw new Error('Duplicate files found in dist folders');
} }
...@@ -164,7 +164,7 @@ const packagePluginRunner: TaskRunner<PluginCIOptions> = async () => { ...@@ -164,7 +164,7 @@ const packagePluginRunner: TaskRunner<PluginCIOptions> = async () => {
} }
console.log('Save the source info in plugin.json'); console.log('Save the source info in plugin.json');
const pluginJsonFile = path.resolve(distDir, 'plugin.json'); const pluginJsonFile = path.resolve(distContentDir, 'plugin.json');
const pluginInfo = getPluginJson(pluginJsonFile); const pluginInfo = getPluginJson(pluginJsonFile);
pluginInfo.info.build = await getPluginBuildInfo(); pluginInfo.info.build = await getPluginBuildInfo();
fs.writeFile(pluginJsonFile, JSON.stringify(pluginInfo, null, 2), err => { fs.writeFile(pluginJsonFile, JSON.stringify(pluginInfo, null, 2), err => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment