-
Notifications
You must be signed in to change notification settings - Fork 917
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
Allowing custom folder name for plugin installation #446
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,21 +30,15 @@ | |
* GitHub history for details. | ||
*/ | ||
|
||
import { statSync, readdirSync, readFileSync } from 'fs'; | ||
import { statSync, readdirSync } from 'fs'; | ||
import { join } from 'path'; | ||
|
||
export function list(pluginDir, logger) { | ||
readdirSync(pluginDir).forEach((name) => { | ||
const stat = statSync(join(pluginDir, name)); | ||
|
||
if (stat.isDirectory() && name[0] !== '.') { | ||
try { | ||
const packagePath = join(pluginDir, name, 'opensearch_dashboards.json'); | ||
const pkg = JSON.parse(readFileSync(packagePath, 'utf8')); | ||
logger.log(pkg.id + '@' + pkg.version); | ||
} catch (e) { | ||
throw new Error('Unable to read opensearch_dashboards.json file for plugin ' + name); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's the reason to remove this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For the list command, the output printed was |
||
logger.log(name); | ||
} | ||
}); | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You may have been right to worry that previous versions of plugins may have been installed into
settings.plugins[0].id
(1.1 installation on top of 1.0). Is that a valid concern. If so, make an array of all possible folder names, and do a foreach on them to check.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One of the cases I can think of now is the user first used the id of the plugin to install it, then added a folderName property to
opensearch_dashboards.json
and tried installing again. It should fail saying the plugin is already installed. I will add both the checks to be on the safer side.