Grafana Toolkit: Prevent installation of outdated FE dependencies (#42663)

This commit is contained in:
Jack Westbrook 2021-12-07 09:56:56 +01:00 committed by GitHub
parent 0bd30c8256
commit 36b0cb64fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 3 deletions

View File

@ -11,6 +11,7 @@ import {
promptPluginType,
removeGitFiles,
verifyGitExists,
removeLockFile,
} from './plugin/create';
import { Task, TaskRunner } from './task';
@ -40,10 +41,14 @@ const pluginCreateRunner: TaskRunner<PluginCreateOptions> = async ({ name }) =>
// 5. Update json files (package.json, src/plugin.json)
await prepareJsonFiles({ type: type, pluginDetails, pluginPath: destPath });
// 6. Remove cloned repository .git dir
// 6. Starter templates include `yarn.lock` files which will rarely (if ever) be in sync with `latest` dist-tag
// so best to remove it after cloning.
removeLockFile({ pluginPath: destPath });
// 7. Remove cloned repository .git dir
await removeGitFiles(destPath);
// 7. Promote Grafana Tutorials :)
// 8. Promote Grafana Tutorials :)
printGrafanaTutorialsDetails(type);
};

View File

@ -1,6 +1,6 @@
import chalk from 'chalk';
import commandExists from 'command-exists';
import { promises as fs, readFileSync } from 'fs';
import { promises as fs, readFileSync, existsSync, unlinkSync } from 'fs';
import { prompt } from 'inquirer';
import { kebabCase } from 'lodash';
import path from 'path';
@ -177,6 +177,7 @@ export const printGrafanaTutorialsDetails = (type: PluginType) => {
console.group();
console.log();
console.log(chalk.bold.yellow(`Congrats! You have just created ${PluginNames[type]}.`));
console.log('Please run `yarn install` to install frontend dependencies.');
console.log();
if (type !== 'backend-datasource-plugin') {
console.log(`${PluginNames[type]} tutorial: ${TutorialPaths[type]}`);
@ -188,3 +189,10 @@ export const printGrafanaTutorialsDetails = (type: PluginType) => {
console.groupEnd();
};
/* eslint-enable no-console */
export const removeLockFile = ({ pluginPath }: { pluginPath: string }) => {
const lockFilePath = path.resolve(pluginPath, 'yarn.lock');
if (existsSync(lockFilePath)) {
unlinkSync(lockFilePath);
}
};