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

dump configs in all plugins that have one #276

Open
wants to merge 21 commits into
base: v7-in-progress
Choose a base branch
from

Conversation

karenetheridge
Copy link
Contributor

..for the glory of [MetaConfig]

@rjbs
Copy link
Owner

rjbs commented Feb 8, 2014

test failures:

t/plugins/distmeta.t ......... 1/? no response for test prompt 'PAUSE username: ' at /Users/rjbs/code/cs/Dist-Zilla/lib/Dist/Zilla/Chrome/Test.pm line 60.

@rjbs
Copy link
Owner

rjbs commented Feb 8, 2014

So, the UploadToCPAN plugin now wants to dump the username, which means it has to compute the username even when it didn't before. Any step that builds distmeta now gets it, which means it tries loading stuff from the global config, etc.

This is failing for me, but not for you. I bet there's some bug where tests are not protecting against ~/.dzil/config.ini, and you have a pause stash, but I don't.

This exposes two general problems:

  • lazy options are going to be triggered, now, when they would not before; for some, this may mean a speed hit, and not be worth much — is it interesting that the username is RJBS? dubious
  • this dumps tons of things that will effectively be the default; is there some way to determine that we got non-default values? that would be really useful

@karenetheridge
Copy link
Contributor Author

this dumps tons of things that will effectively be the default; is there some way to determine that we got non-default values? that would be really useful

I've been vacillating on this a bit. What might be the default in one version may not be the default in another, and it might get annoying to have to consult the code to see what the default values are so we know what the configuration truly was -- but on the other hand, we really just care about what was in the user's dist.ini/pluginbundle that was passed to the plugin, so we can duplicate this configuration later.

We'd probably have to capture the constructor args (in BUILD probably) into a
separate attribute, for spitting back out into dump_config. But that's
something that ConfigDumper could do for us, for free, everywhere -- possibly
worth doing? e.g.:

package Dist::Zilla::Role::ConfigDumper;
has _user_configs => (
    is => 'rw', isa => 'HashRef',
    traits => ['SetOnce'],
);
after BUILD {
    my ($self, $args) = @_;

    delete @{$args}{qw(zilla plugin_name)};
    $self->_user_configs($args);
}
sub dump_config {
    my $self = shift;
    return $self->_user_configs;
}

@karenetheridge
Copy link
Contributor Author

lazy options are going to be triggered, now, when they would not before

True, for 'build' and 'test' operations, we would be calling these when we otherwise didn't need to until release time. and yeah, no terrible need to log those; might as well drop them.

Pushed new commits with 'username' dropped from UploadToCPAN, and your +PACKAGE change cherry-picked -- let's see what travis says.

@karenetheridge
Copy link
Contributor Author

So, in the comment above about method-modifying BUILD.. I'm now leaning towards still having dump_config return {}, but then individual plugins can choose to make use of %{$self->user_configs} thusly:

package Dist::Zilla::Plugin::Foo;
around dump_config => sub {
  my $orig = shift;
  my $self = shift;

  my $config = $self->$orig;

  $config->{+__PACKAGE__} = {
    map { $_ => $self->$_ }
        grep { exists $self->_user_configs->{$_} }
        qw(.. attr names in this plugin ..),
  };

  return $config;
};

(even better, use the native 'Hash' trait and add an _exists_user_config sub)

@karenetheridge
Copy link
Contributor Author

@kentfredric also suggests this in core: https://gist.github.com/kentfredric/8894533

@karenetheridge
Copy link
Contributor Author

fixed conflicts post-5.037

@rjbs
Copy link
Owner

rjbs commented Oct 22, 2015

I'll merge this or something very similar in v6, hopefully this fall/winter.

@rjbs rjbs added the v7 label Apr 21, 2018
@karenetheridge karenetheridge force-pushed the topic/dump_config branch 3 times, most recently from 16bd758 to 5cf9f6b Compare April 21, 2018 15:30
karenetheridge and others added 18 commits April 21, 2018 18:10
Dist::Zilla::Dialect is a multi-import pragma to set up v5.20
and the features used by Dist::Zilla code code:  the good stuff
from v5.20 and thereabouts.
...as inspired by File::HomeDir::Tiny

Note that all of this can be replaced by (glob('~'))[0] when perl 5.20
is required.
This will prevent discouraged formats from being used, even though CPAN::Meta
still lets some of them in (despite contradictory language in
CPAN::Meta::Spec).  Following the Lyon version roundtable, _ is no longer
interpreted as another dot in non-decimal versions, so the sort order can now
be different.
@karenetheridge karenetheridge changed the base branch from master to v7-in-progress December 16, 2018 01:45
@karenetheridge
Copy link
Contributor Author

rebased to new v7-in-progress

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.

3 participants