Skip to content

Ember cli deploy plugin control - #407

Merged
achambers merged 0 commit into
ember-cli-deploy:plugin-controlfrom
achambers:ember-cli-deploy-plugin-control
Jul 7, 2016
Merged

achambers merged 0 commit into
ember-cli-deploy:plugin-controlfrom
achambers:ember-cli-deploy-plugin-control

Conversation

@achambers

Copy link
Copy Markdown
Member

What Changed & Why

Explain what changed and why.

Related issues

Link to related issues in this or other repositories (if any)

PR Checklist

  • Add tests
  • Add documentation
  • Prefix documentation-only commits with [DOC]

People

Mention people who would be interested in the changeset (if any)

@achambers achambers self-assigned this Jun 6, 2016
Comment thread lib/tasks/pipeline.js
return addon.name.match(pluginNameRegex)[2];
_plugins: function() {
var registry = new PluginRegistry(this.project, this.config, this.ui);
return registry.plugins();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@achambers for when you rebase, I think the call to the validation function might go here (?)

@achambers
achambers force-pushed the ember-cli-deploy-plugin-control branch from 24d62c1 to a17adad Compare June 27, 2016 19:58
Comment thread lib/models/plugin-registry.js Outdated
});

if (unknownAddons.length) {
var message = chalk.yellow('You have referenced the following uninstalled addons in `' + configKey + '`:\n');

@ghedamat ghedamat Jun 28, 2016 •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nitpick but

is uninstalled the right wording here? I assume this is replacing the old
plugins configuration references plugins which are not available. message right?

maybe should be You have referenced the following addons in ... and they're not installed or something similar

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yeh, I'm not precious about the copy. Happy to change it to whatever you feel describes things best

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

cool, luke approves so feel free to take what I have up there

@ghedamat

Copy link
Copy Markdown
Collaborator

@achambers had a first look, very nice! just a couple of tiny comments so far.
I guess I'd have to see the docs to be sure of the scope of this but I assume it's still what you outlined in #349 (comment) correct?

} else {
ui.writeError('Use of the `config.plugins` property has been deprecated.\n');
ui.writeError('Please use the new plugin controls\n');
ui.writeError('See https://some-url for more information\n');

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

TODO: update the URL here

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yep, the one failing test is reminding me of exactly that

@achambers
achambers force-pushed the ember-cli-deploy-plugin-control branch from a17adad to 6fb2f26 Compare July 5, 2016 23:21
@ghedamat

ghedamat commented Jul 6, 2016

Copy link
Copy Markdown
Collaborator

@achambers could you close and reopen to target master ?


_pluginNameFromAddonName: function(addon) {
var pluginNameRegex = /^(ember\-cli\-deploy\-)(.*)$/;
return addon.name.match(pluginNameRegex)[2];

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

on an initial test in a real project this ends up erroring badly

I think you need to guard this or maybe there's something else going on?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Thanks mate. Will have a look tonight

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@achambers I think you just need to move line 47 var name = self._pluginNameFromAddonName(currentAddon); to inside the following if block. Testing on one of my apps works with that change. I think we need to add a test simulating the presence of an ember-cli addon that is not an ember-cli-deploy plugin,

@achambers

Copy link
Copy Markdown
Member Author

@ghedamat, I'm thinking I'll just force push my branch to the original branch that the original PR was based off as I'd like to keep @ef4 's PR and the discussion that happened around it.

Cool with that?

@ghedamat

ghedamat commented Jul 6, 2016

Copy link
Copy Markdown
Collaborator

works for me,

if then you can also rebase that branch it would be golden

@achambers

Copy link
Copy Markdown
Member Author

Yep. Of course
On Wed, 6 Jul 2016 at 21:13, Mattia Gheda [email protected] wrote:

works for me,

if then you can also rebase that branch it would be golden

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#407 (comment),
or mute the thread
https://github.com/notifications/unsubscribe/AAZb1K4ZH5vPCsrbbbck_KTsee5iJ4xPks5qTAxygaJpZM4IvW7Y
.

@lukemelia

Copy link
Copy Markdown
Contributor

Code and test coverage look good. I find the the chained functional style in the plugin registry a little hard to follow as a reader, but I think it's fine when paired with the comprehensive test coverage.

@achambers

Copy link
Copy Markdown
Member Author

Hmm. Bummer. Because I did it they way to make it easier to understand. There is quite a lot of logic going on to get the list of plugins so that style was intended to be more intention revealing. To tell a story about how we get from a list of adding to a list of plugins.

Any thoughts on how I make it easier for the reader then? (Not something that's worth changing on this PR now but would like to follow up with it as this is there bulk of where the logic is so would like to make it easier to follow)

@achambers

Copy link
Copy Markdown
Member Author

PS - Thanks for reviewing. I'll fix up that error and at that test.

@lukemelia

Copy link
Copy Markdown
Contributor

@achambers not sure -- as you say, there is a lot of logic. The use of the intention-revealing method names is good. The names reveal "what" is happening. Perhaps code comments within the body of each of those methods could describe "how" it is happening?

@achambers

Copy link
Copy Markdown
Member Author

@lukemelia I guess I was trying to write it such that you don't really need to know how....The intention was that from this list:

 var allEmberCliAddons = this._project.addons || [];
 var validAddons       = this._validAddons(allEmberCliAddons);
 var aliasMap          = this._buildAliasMap(validAddons, this._aliasConfig);
 var disabledMap       = this._buildDisabledMap(aliasMap, this._disabledConfig);
 var installedPlugins  = this._installedPlugins(validAddons, aliasMap);
 var runOrderMap       = this._buildRunOrderMap(this._runOrderConfig, aliasMap, validAddons, installedPlugins);
 var enabledPlugins    = this._applyDisabledConfig(installedPlugins, disabledMap);
 var orderedPlugins    = this._applyRunOrderConfig(enabledPlugins, runOrderMap);

you can understand the following:

  1. We have a list of ember-cli addons that are installed
  2. We convert that to a list of valid ember-cli-deploy addons
  3. We generate the alias map
  4. We generate the disabled bap
  5. Based on the alias map we work out what the installed plugins are
  6. We generate the run order map
  7. We apply the disabled map to determine only the enabled plugins
  8. We apply the run order map to determine the ordered list of plugins

I was hoping, as a reader of the code, you wouldn't really need to know how each of those things worked.

HOWEVER, I have had a couple of things on my mind in regards to things.

  1. I tried to make a distinction between an installed addon (an ember-cli addon - whether it be an ecd one or not) and an installed plugin (the object returned from createDeployplugin for which there could be multiple instances for an addon based on aliases). I tried to make the distinction obvious but I'm not sure I quite got there. This still may not be obvious.

  2. The return values of the _build***Map functions is not immediately obvious. I constantly found myself getting confused about what the object I was working with looked like. This is partly just the nature of things but I did toy with the idea of commenting what those functions took and the structure of what they returned.

  3. The reasoning of why we need the map objects (aliasMap, disabledMap etc etc) isn't immediately obvious. It makes sense when you know but maybe this is the sort of thing that could also be documented in comments.

Are the 3 points described above more what you mean about the "how" it's working?

I'm certainly happy to make some changes to make it more understandable as this is where the bulk of the work goes and, before pulling the logic out in to this object, I continuously got confused about what was going on in the pipeline if I wasn't frequently in the code....The same could still happen with this so it's in our own interests to make it easy to understand for when we find ourselves back here.

@achambers

Copy link
Copy Markdown
Member Author

I'll add some comments to the functions and push and see how we get on

@achambers

Copy link
Copy Markdown
Member Author

PS - I just ran some tests with some real deploys and all seems good to me once that bug is fixed. Anyone else see any major broken things?

@lukemelia

Copy link
Copy Markdown
Contributor

@achambers you summarized the challenges I had very well. Comments describing return value structure could help a bunch. For naming, I would expect the things you mentioned to be called "addon", "plugin", and "pluginInstance".

@achambers

achambers commented Jul 7, 2016 •

Copy link
Copy Markdown
Member Author

Okie doke. Will apply the above and see what we come up with. Thanks Luke

@achambers

Copy link
Copy Markdown
Member Author

Not quite sure what the deal is with these failing tests....Can't seem to replicate on my local env.... Yu guys seen this? /cc @ghedamat @lukemelia

@achambers
achambers force-pushed the ember-cli-deploy-plugin-control branch 2 times, most recently from 0348197 to 9163752 Compare July 7, 2016 20:50
@achambers
achambers merged commit 9163752 into ember-cli-deploy:plugin-control Jul 7, 2016
@ef4

ef4 commented Jul 7, 2016

Copy link
Copy Markdown
Contributor

Thanks for pushing this over the finish line!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants