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

Added whitelisting packages to suppress the inject questions #52

Merged
merged 6 commits into from Feb 8, 2018

Conversation

Projects
None yet
3 participants
@xtreamwayz
Member

xtreamwayz commented Feb 7, 2018

Add an option to read a list of whitelisted packages from the project composer file. Packages in that list are installed silently without the installation prompt. To prevent abuse, only a whitelist in the project composer file is allowed.

    "extra": {
        "zf": {
            "component-whitelist": [
                "zendframework/zend-expressive-router",
                "zendframework/zend-expressive-fastroute",
                "zendframework/zend-expressive-twigrenderer",
                "zendframework/zend-expressive-helpers"
            ]
        }
    },

See zendframework/zend-expressive-skeleton#207
See zendframework/zend-expressive-skeleton#204

Closes #48

@weierophinney

This comment has been minimized.

Show comment
Hide comment
@weierophinney

weierophinney Feb 7, 2018

Member

Well, that's ridiculously simple!

Write some tests, and I'd be happy to merge and release this! We can then do another release of the skeleton that adds appropriate packages to the whitelist.

Member

weierophinney commented Feb 7, 2018

Well, that's ridiculously simple!

Write some tests, and I'd be happy to merge and release this! We can then do another release of the skeleton that adds appropriate packages to the whitelist.

xtreamwayz added some commits Feb 8, 2018

@xtreamwayz xtreamwayz changed the title from [WIP] Added whitelisting packages to suppress the inject questions to Added whitelisting packages to suppress the inject questions Feb 8, 2018

@@ -186,13 +186,18 @@ public function onPostPackageInstall(PackageEvent $event)
$dependencies = $this->loadModuleClassesDependencies($package);
$applicationModules = $this->findApplicationModules();
$composer = $this->composer;

This comment has been minimized.

@webimpress

webimpress Feb 8, 2018

Contributor

We don't need to define this variable, see comment below

@webimpress

webimpress Feb 8, 2018

Contributor

We don't need to define this variable, see comment below

$this->marshalInstallableModules($extra, $options)
->each(function ($module) use ($name) {
})
// Create injectors
->reduce(function ($injectors, $module) use ($options, $packageTypes) {
$injectors[$module] = $this->promptForConfigOption($module, $options, $packageTypes[$module]);
->reduce(function ($injectors, $module) use ($options, $packageTypes, $name, $composer) {

This comment has been minimized.

@webimpress

webimpress Feb 8, 2018

Contributor

We don't need to pass $composer here, $this can be used in closure.

@webimpress

webimpress Feb 8, 2018

Contributor

We don't need to pass $composer here, $this can be used in closure.

$injectors[$module] = $this->promptForConfigOption($module, $options, $packageTypes[$module]);
->reduce(function ($injectors, $module) use ($options, $packageTypes, $name, $composer) {
// Get extra from root package
$rootExtra = $this->getExtraMetadata($composer->getPackage()->getExtra());

This comment has been minimized.

@webimpress

webimpress Feb 8, 2018

Contributor

We can use $this->composer here.

@webimpress

webimpress Feb 8, 2018

Contributor

We can use $this->composer here.

if ($cachedInjector = $this->getCachedInjector($packageType)) {
return $cachedInjector;
}
// If package is whitelisted, don't ask...
if (in_array($packageName, $whitelist, false)) {

This comment has been minimized.

@webimpress

webimpress Feb 8, 2018

Contributor

Why we have false here?

@webimpress

webimpress Feb 8, 2018

Contributor

Why we have false here?

@@ -39,6 +40,11 @@ class ComponentInstallerTest extends TestCase
*/
private $composer;
/**
* @var RootPackageInterface

This comment has been minimized.

@webimpress

webimpress Feb 8, 2018

Contributor

Should be RootPackageInterface|ObjectProphecy.

@webimpress

webimpress Feb 8, 2018

Contributor

Should be RootPackageInterface|ObjectProphecy.

]]);
$this->io->write(Argument::that(function ($argument) {
return strstr($argument, 'Installing Some\Component from package some/component');

This comment has been minimized.

@webimpress

webimpress Feb 8, 2018

Contributor

From PHP manual:

If you only want to determine if a particular needle occurs within haystack, use the faster and less memory intensive function strpos() instead.

http://php.net/strstr

@webimpress

webimpress Feb 8, 2018

Contributor

From PHP manual:

If you only want to determine if a particular needle occurs within haystack, use the faster and less memory intensive function strpos() instead.

http://php.net/strstr

@weierophinney

This comment has been minimized.

Show comment
Hide comment
@weierophinney

weierophinney Feb 8, 2018

Member

@xtreamwayz I've incorporated the feedback from @webimpress locally; all tests continue to pass.

Updating docs, and then will merge and release.

Thanks!

Member

weierophinney commented Feb 8, 2018

@xtreamwayz I've incorporated the feedback from @webimpress locally; all tests continue to pass.

Updating docs, and then will merge and release.

Thanks!

@weierophinney weierophinney merged commit cd407cd into zendframework:develop Feb 8, 2018

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
coverage/coveralls Coverage increased (+0.09%) to 92.688%
Details

weierophinney added a commit that referenced this pull request Feb 8, 2018

weierophinney added a commit that referenced this pull request Feb 8, 2018

Adds CHANGELOG for #52
- Removes empty 2.0.1 stub
- Adds date for 2.1.0

weierophinney added a commit that referenced this pull request Feb 8, 2018

@xtreamwayz xtreamwayz deleted the xtreamwayz:feature/whitelist branch Feb 8, 2018

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