-
-
Notifications
You must be signed in to change notification settings - Fork 197
Plugin variables #981
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
Plugin variables #981
Conversation
} | ||
|
||
interface IPluginVariableData { | ||
default?: string; |
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.
Should this be called defaultValue
?
fd040ea
to
c9a1ec0
Compare
@@ -9,7 +9,8 @@ interface IPluginsService { | |||
|
|||
interface IPluginData extends INodeModuleData { | |||
platformsData: IPluginPlatformsData; | |||
pluginPlatformsFolderPath(platform: string): string; | |||
pluginVariables: IDictionary<IPluginVariableData>; |
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.
Can we document these members with jsdoc?
3d73686
to
6c0ac6e
Compare
6c0ac6e
to
69a55ef
Compare
private static PLUGIN_VARIABLES_KEY = "variables"; | ||
|
||
constructor(private $errors: IErrors, | ||
private $fs: IFileSystem, |
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.
Unused dependency?
69a55ef
to
bc9dc86
Compare
let promptSchema = { | ||
name: pluginVariableName, | ||
type: "input", | ||
message: `Enter value for ${pluginVariableName} variable: ` |
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.
$prompter
adds a white space at the end of every prompt so the white space at the end here seems redundant
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.
As a side note, if the user presses sets a false-like value for a plugin variable we will fail in savePluginVariablesInProjectFile
function up above and the process will end which is no great UX.
Instead we can use $prompter
's validate
property like so
validate: (value: string) => !!value ? true : 'Please enter a value!'
cc325eb
to
8e2d9b0
Compare
@@ -11,7 +11,8 @@ export class ProjectDataService implements IProjectDataService { | |||
constructor(private $fs: IFileSystem, | |||
private $staticConfig: IStaticConfig, | |||
private $errors: IErrors, | |||
private $logger: ILogger) { | |||
private $logger: ILogger, | |||
private $injector: IInjector) { |
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.
Unnecessary dependency
👍 After rebasing, getting a green build, merging pull request in common, updating SHA and squashing |
0d0326a
to
3bc89ae
Compare
3bc89ae
to
9111e59
Compare
this.executeForAllPluginVariables(pluginData, (pluginVariableData: IPluginVariableData) => | ||
(() => { | ||
let pluginVariableValue = this.getPluginVariableValue(pluginVariableData).wait(); | ||
if(!pluginVariableValue) { |
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.
This could be extracted into a dedicated function ensurePluginVarValue
(the name is just a suggestion), the same code is used in other places as well.
9111e59
to
94cffd6
Compare
value = value[pluginVariableName]; | ||
} else { | ||
value = pluginVariableData.defaultValue; | ||
if(!value && helpers.isInteractive()) { |
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.
If not interactive, we should give at least a warning.
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.
Why?
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.
We talked in person and agreed that the code is correct
94cffd6
to
e9b26b3
Compare
let future = new Future<void>(); | ||
|
||
pipeline.on('end', (err: Error, data: any) => { | ||
if(err) { |
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.
This should be indented once on the right
4049342
to
36d3d8e
Compare
if(this.$fs.exists(pluginConfigurationFilePath).wait()) { | ||
let tnsModulesDestinationPath = path.join(platformData.appDestinationDirectoryPath, constants.APP_FOLDER_NAME, constants.TNS_MODULES_FOLDER_NAME); | ||
let nodeModules = this.$broccoliBuilder.getChangedNodeModules(tnsModulesDestinationPath, platform).wait(); | ||
let plugins = _.map(_.keys(nodeModules), nodeModule => this.convertToPluginData(this.getNodeModuleData(pluginName).wait())); |
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.
This is only a suggestion and not a merge stopper:
_.(nodeModules)
.map(nodeModule => this.getNodeModuleData(pluginName).wait())
.map(nodeModuleData => this.convertToPluginData(nodeModuleData))
.filter(data => data.isPlugin && this.$fs.exists(this.getPluginConfigurationFilePath(data, platformData)).wait())
.forEach((data, index) => {
executeUninstallCommand().wait();
if(index === 0) {
this.initializeConfigurationFileFromCache(platformData).wait();
}
if(data.name !== pluginName) {
this.merge(data, platformData).wait();
}
})
.value();
I find this code to be more linear but the original is correct and I do not insist on changing it.
36d3d8e
to
8f2ffa0
Compare
Test FAILed. |
8f2ffa0
to
47716c3
Compare
Test FAILed. |
#882