Skip to content

Conversation

@sualko
Copy link
Member

@sualko sualko commented Jul 7, 2017

fix #1599

This new command downloads the specific app from the app store, but doesn't enable it.

*/
public function completeArgumentValues($argumentName, CompletionContext $context) {
if ($argumentName === 'app-id') {
$allApps = \OC_App::getAllApps();
Copy link
Member

Choose a reason for hiding this comment

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

Since the apps you want to install are not available locally, you can also not autocomplete them.

I'd just delete the complete* methods and the implements CompletionAwareInterface

@nickvergessen
Copy link
Member

But nice otherwise

$installer->downloadApp($appId);
$result = $installer->installApp($appId);
} catch(Exception $e) {
$output->writeln('Error: ' . $ex->getMessage());
Copy link
Member

Choose a reason for hiding this comment

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

Should be $e (see line above)

@codecov
Copy link

codecov bot commented Jul 7, 2017

Codecov Report

❗ No coverage uploaded for pull request base (master@174cd4f). Click here to learn what that means.
The diff coverage is 0%.

@@            Coverage Diff            @@
##             master    #5644   +/-   ##
=========================================
  Coverage          ?   54.49%           
  Complexity        ?    21309           
=========================================
  Files             ?     1309           
  Lines             ?    82358           
  Branches          ?     1327           
=========================================
  Hits              ?    44884           
  Misses            ?    37474           
  Partials          ?        0
Impacted Files Coverage Δ Complexity Δ
core/Command/App/Install.php 0% <0%> (ø) 5 <5> (?)
core/register_command.php 0% <0%> (ø) 0 <0> (?)


class Install extends Command {

public function __construct() {
Copy link
Member

Choose a reason for hiding this comment

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

unused and thus can be removed.

}

try {
$installer = new Installer(
Copy link
Member

Choose a reason for hiding this comment

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

@nickvergessen do we have DI for commands? I'd prefer injecting an object over building it manually. This approach could fail as soon as the constructor parameters of change. Or maybe we could at least query the class from the DI container and have it constructed automatically.

Copy link
Member

Choose a reason for hiding this comment

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

We have "semi-injection": https://github.com/nextcloud/server/blob/master/core/register_command.php#L63

So you can build it outside. Not sure if you can do \OC::$server->query(Installer::class) there thou.

@@ -0,0 +1,77 @@
<?php
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
Copy link
Member Author

Choose a reason for hiding this comment

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

What's about the copyright header? How should it look like?

Copy link
Member

Choose a reason for hiding this comment

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

If the logic is yours add yourself
If it code from oc leave as is

Copy link
Member Author

Choose a reason for hiding this comment

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

It's more or less from app.php#L363, so I leave it for now.

@enoch85
Copy link
Member

enoch85 commented Jul 7, 2017

Would it be possible to add a switch for enable like --enable?

@enoch85
Copy link
Member

enoch85 commented Jul 7, 2017

Tested and it gives me this:

root@nextcloud:/var/www/nextcloud# sudo -u www-data php occ app:install videocalls
An unhandled exception has been thrown:
Error: Class 'OC\Core\Command\Db\Migrations\StatusCommand' not found in /var/www/nextcloud/core/register_command.php:89
Stack trace:
#0 /var/www/nextcloud/lib/private/Console/Application.php(94): require_once()
#1 /var/www/nextcloud/console.php(91): OC\Console\Application->loadCommands(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#2 /var/www/nextcloud/occ(11): require_once('/var/www/nextcl...')

Used this file: https://raw.githubusercontent.com/nextcloud/server/add-occ-app-install/core/register_command.php

@enoch85
Copy link
Member

enoch85 commented Jul 7, 2017

OK, it works now (just patched the register_command.php instead), but it asks for app-id I think it should work with the name as well, not just app-id.

Sorry, it works. But still would be nice with --enable

@enoch85
Copy link
Member

enoch85 commented Jul 7, 2017

👍 from me.

@enoch85
Copy link
Member

enoch85 commented Jul 7, 2017

Also, would it be possible to backport to 12?

@nickvergessen
Copy link
Member

Also, would it be possible to backport to 12?

You know we don't backport features ;)

@enoch85
Copy link
Member

enoch85 commented Jul 10, 2017

You know we don't backport features ;)

Oh right, don't know why I forgot about that.

@sualko
Copy link
Member Author

sualko commented Jul 11, 2017

Would it be possible to add a switch for enable like --enable?

I think this would duplicate the code of the app:enable command. Anything else to do, or are we able to merge this?

@enoch85
Copy link
Member

enoch85 commented Jul 13, 2017

@nickvergessen @juliushaertl Does this look OK to you? I tested and it works in current state.

@nickvergessen
Copy link
Member

I think this would duplicate the code of the app:enable command. Anything else to do, or are we able to merge this?

I think a simple enable flag (yes|no) would be okay, if you want to enable it for a group the second call is fine I'd say...

Copy link
Member

@rullzer rullzer left a comment

Choose a reason for hiding this comment

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

Can probabaly use some polishing later on. But awesome stuff!

@rullzer rullzer force-pushed the add-occ-app-install branch from daa6d9d to ebb137b Compare July 21, 2017 11:13
@enoch85
Copy link
Member

enoch85 commented Jul 21, 2017

@juliushaertl And what about you? :)

@MorrisJobke
Copy link
Member

There is only one thing missing: the sign-off. See https://github.com/nextcloud/server/blob/master/CONTRIBUTING.md#sign-your-work how to do it. It's basically one line in the commit message of every commit.

@sualko
Copy link
Member Author

sualko commented Jul 21, 2017

That's right, I only signed-off the first commit. What's the best practice for such an case? Rebase and sign-off, or add sign-off to every commit?

@sualko sualko force-pushed the add-occ-app-install branch from 95953da to 9edfa93 Compare July 24, 2017 13:51
@sualko
Copy link
Member Author

sualko commented Jul 25, 2017

it should work ;)

It doesn't 😢

@MorrisJobke
Copy link
Member

It doesn't 😢

Because your master is 18 days old 😉 Also update master and then rebase again ;)

);
$installer->downloadApp($appId);
$result = $installer->installApp($appId);
} catch(Exception $e) {
Copy link
Member

Choose a reason for hiding this comment

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

Phan CI job says no:

core/Command/App/Install.php:63 PhanUndeclaredClassCatch Catching undeclared class \OC\Core\Command\App\Exception
core/Command/App/Install.php:64 PhanUndeclaredClassMethod Call to method getMessage from undeclared class \OC\Core\Command\App\Exception

https://drone.nextcloud.com/nextcloud/server/359/38

Copy link
Member

Choose a reason for hiding this comment

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

I guess adding a leading \ fixes it 😉

@sualko sualko force-pushed the add-occ-app-install branch 2 times, most recently from db76747 to 2cb7214 Compare July 25, 2017 14:33
@enoch85
Copy link
Member

enoch85 commented Jul 25, 2017

@sualko Still failing. :/

@sualko
Copy link
Member Author

sualko commented Jul 25, 2017

I know and it gets annoying, because those tests fail with messages like the following:

PHP Warning:  Redis::connect(): connect() failed:
Waiting for Selenium
Parse error: ./build/.phan/plugins/SqlInjectionCheckerPlugin.php:22
creating sqlite db
  [OCP\Files\NotFoundException] 

Those are not very helpful and for me it looks like there is a more general issue in the test setup, because if you look at the commit history of the master branch there are only ❌.

@enoch85
Copy link
Member

enoch85 commented Jul 25, 2017

@MorrisJobke Are tests broken?

@MorrisJobke
Copy link
Member

@MorrisJobke Are tests broken?

We are still struggling with the docker setup. Sorry for this. I try to get this resolved as soon as possible.

@nickvergessen
Copy link
Member

bash build/autoloaderchecker.sh
git add lib/composer/
git commit
git push

Still needs this, then more tests should pass ;)

@sualko
Copy link
Member Author

sualko commented Jul 26, 2017

@nickvergessen I did this and some more tests succeeded, but the next test run failed with a message that I should run the command again. To my surprise the command removed the lines again. My conclusion is, that I will wait for Morris ok to rerun those tests.

@MorrisJobke
Copy link
Member

As of now it looks like the tests are actually broken. Somehow the class can't be loaded. Could you please run bash build/autoloaderchecker.sh and commit the result (it is needed anyways - another test failure will be fixed by this 😉)

Signed-off-by: Klaus Herberth <[email protected]>
@sualko
Copy link
Member Author

sualko commented Jul 26, 2017

There are no changes to commit after running bash build/autoloaderchecker.sh. I also rebased with git rebase -i master and tried again.

@sualko sualko force-pushed the add-occ-app-install branch from 2cb7214 to 3e62a25 Compare July 26, 2017 12:38
@sualko
Copy link
Member Author

sualko commented Jul 26, 2017

$ bash build/autoloaderchecker.sh
Global composer found: checking for update
You are already using composer version 1.4.2 (stable channel).

Regenerating autoloader
Generating optimized autoload files

Autoloader up to date. Carry on

sualko added 2 commits July 26, 2017 15:24
Signed-off-by: sualko <[email protected]>
Signed-off-by: sualko <[email protected]>
@MorrisJobke
Copy link
Member

There are no changes to commit after running bash build/autoloaderchecker.sh. I also rebased with git rebase -i master and tried again.

Okay ... then my diff was out of date, because now the changes to the composer files are shown. Sorry for the hassle then.

And sorry for the CI mess. We are currently recovering from the long backlog.

@sualko
Copy link
Member Author

sualko commented Jul 27, 2017

Okay ... then my diff was out of date

No, it was my fail. I don't know why, but the namespace was missing. After adding it, the autoloaderchecker did his job.

@MorrisJobke
Copy link
Member

Ignore the 3 drone timeouts ... those are due to a bit overload on that system as of now. Should be fixed soon.

@MorrisJobke MorrisJobke merged commit c7757b0 into master Jul 27, 2017
@MorrisJobke MorrisJobke deleted the add-occ-app-install branch July 27, 2017 13:36
@enoch85
Copy link
Member

enoch85 commented Jul 27, 2017

MorrisJobke merged commit c7757b0 into master 2 hours ago

Yaay!

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

Labels

3. to review Waiting for reviews enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Install app via command line - occ app:install

8 participants