Skip to content

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

Merged
merged 1 commit into from
Oct 7, 2015
Merged

Plugin variables #981

merged 1 commit into from
Oct 7, 2015

Conversation

Fatme
Copy link
Contributor

@Fatme Fatme commented Sep 29, 2015

@Fatme Fatme added the feature label Sep 29, 2015
}

interface IPluginVariableData {
default?: string;
Copy link

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?

@Fatme Fatme force-pushed the fatme/plugin-vars branch 2 times, most recently from fd040ea to c9a1ec0 Compare September 29, 2015 11:30
@@ -9,7 +9,8 @@ interface IPluginsService {

interface IPluginData extends INodeModuleData {
platformsData: IPluginPlatformsData;
pluginPlatformsFolderPath(platform: string): string;
pluginVariables: IDictionary<IPluginVariableData>;
Copy link
Contributor

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?

@teobugslayer teobugslayer added this to the 1.5.0 milestone Sep 30, 2015
@Fatme Fatme force-pushed the fatme/plugin-vars branch 4 times, most recently from 3d73686 to 6c0ac6e Compare October 7, 2015 09:56
@teobugslayer teobugslayer modified the milestones: 1.4.1, 1.5.0 Oct 7, 2015
@Fatme Fatme force-pushed the fatme/plugin-vars branch from 6c0ac6e to 69a55ef Compare October 7, 2015 10:56
private static PLUGIN_VARIABLES_KEY = "variables";

constructor(private $errors: IErrors,
private $fs: IFileSystem,
Copy link
Contributor

Choose a reason for hiding this comment

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

Unused dependency?

@Fatme Fatme force-pushed the fatme/plugin-vars branch from 69a55ef to bc9dc86 Compare October 7, 2015 11:05
let promptSchema = {
name: pluginVariableName,
type: "input",
message: `Enter value for ${pluginVariableName} variable: `
Copy link
Contributor

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

Copy link
Contributor

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!'

@Fatme Fatme force-pushed the fatme/plugin-vars branch 2 times, most recently from cc325eb to 8e2d9b0 Compare October 7, 2015 12:52
@@ -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) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Unnecessary dependency

@Mitko-Kerezov
Copy link
Contributor

👍 After rebasing, getting a green build, merging pull request in common, updating SHA and squashing
😺

@Fatme Fatme force-pushed the fatme/plugin-vars branch 2 times, most recently from 0d0326a to 3bc89ae Compare October 7, 2015 14:20
@Fatme Fatme force-pushed the fatme/plugin-vars branch from 3bc89ae to 9111e59 Compare October 7, 2015 14:34
this.executeForAllPluginVariables(pluginData, (pluginVariableData: IPluginVariableData) =>
(() => {
let pluginVariableValue = this.getPluginVariableValue(pluginVariableData).wait();
if(!pluginVariableValue) {
Copy link
Contributor

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.

@Fatme Fatme force-pushed the fatme/plugin-vars branch from 9111e59 to 94cffd6 Compare October 7, 2015 14:41
value = value[pluginVariableName];
} else {
value = pluginVariableData.defaultValue;
if(!value && helpers.isInteractive()) {
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Why?

Copy link
Contributor

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

@Fatme Fatme force-pushed the fatme/plugin-vars branch from 94cffd6 to e9b26b3 Compare October 7, 2015 14:55
let future = new Future<void>();

pipeline.on('end', (err: Error, data: any) => {
if(err) {
Copy link
Contributor

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

@Fatme Fatme force-pushed the fatme/plugin-vars branch 2 times, most recently from 4049342 to 36d3d8e Compare October 7, 2015 15:14
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()));
Copy link
Contributor

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.

@Fatme Fatme force-pushed the fatme/plugin-vars branch from 36d3d8e to 8f2ffa0 Compare October 7, 2015 15:39
@ns-bot
Copy link

ns-bot commented Oct 7, 2015

Test FAILed.

@Fatme Fatme force-pushed the fatme/plugin-vars branch from 8f2ffa0 to 47716c3 Compare October 7, 2015 15:42
Fatme pushed a commit that referenced this pull request Oct 7, 2015
@Fatme Fatme merged commit 8d65522 into master Oct 7, 2015
@Fatme Fatme deleted the fatme/plugin-vars branch October 7, 2015 16:00
@ns-bot
Copy link

ns-bot commented Oct 7, 2015

Test FAILed.

@teobugslayer teobugslayer modified the milestones: 1.4.2, 1.4.1 Oct 14, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants