Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default to converting folder name for cli plugin to kebab-case #357

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/cli_plugin/install/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import { cleanPrevious, cleanArtifacts } from './cleanup';
import { extract, getPackData } from './pack';
import { renamePlugin } from './rename';
import { existingInstall, assertVersion } from './opensearch_dashboards';
import { kebabCase } from 'lodash';

const mkdir = promisify(Fs.mkdir);

Expand All @@ -62,7 +63,7 @@ export async function install(settings, logger) {

assertVersion(settings);

const targetDir = path.join(settings.pluginDir, settings.plugins[0].id);
const targetDir = path.join(settings.pluginDir, kebabCase(settings.plugins[0].id));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@VachaShah does this have any co-relation with removing plugin as well ? https://github.com/opensearch-project/OpenSearch-Dashboards/blob/main/src/cli_plugin/remove/remove.js

This would not affect the removing plugin logic as it does not take into consideration the plugin id.

await renamePlugin(settings.workingPath, targetDir);

logger.log('Plugin installation complete');
Expand Down
3 changes: 2 additions & 1 deletion src/cli_plugin/install/opensearch_dashboards.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,13 @@

import path from 'path';
import { statSync } from 'fs';
import { kebabCase } from 'lodash';

import { versionSatisfies, cleanVersion } from '../../legacy/utils/version';

export function existingInstall(settings, logger) {
try {
statSync(path.join(settings.pluginDir, settings.plugins[0].id));
statSync(path.join(settings.pluginDir, kebabCase(settings.plugins[0].id)));

logger.error(
`Plugin ${settings.plugins[0].id} already exists, please remove before installing a new version`
Expand Down