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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add self-update command #84

Merged
merged 3 commits into from
May 17, 2016
Merged

Conversation

amansilla
Copy link

@amansilla amansilla commented May 3, 2016

This is a proposal for the self-update command #13 to be used as base although it needs probably some modifications.

Since the latest deptrac.phar is hosted in http://get.sensiolabs.de/deptrac.phar, I thought the following location can be used to indicate its version http://get.sensiolabs.de/deptrac.version (currently not existing and should be created by SensionLabs as they admin the continuous delivery process I guess), which will be used in the code to fetch the latest version and compare it with the running one.

@slde-flash Let me know, what do you think about this or if you need a more sophisticated solution 馃槂.

{
$this
->setName('self-update')
->setAliases(array('selfupdate'))
Copy link
Contributor

Choose a reason for hiding this comment

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

i don't think we need the alias

Copy link
Member

Choose a reason for hiding this comment

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

At least, having this alias would be inline what Composer and the Symfony Installer offer (thus people might be used to use selfupdate instead of self-update).

Copy link
Contributor

Choose a reason for hiding this comment

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

well, ok 馃憤

@slde-flash
Copy link
Contributor

thank you soo much, i added a bunch of small comments.
could you also update the docs for the new command?

@slde-flash
Copy link
Contributor

@amansilla i would like to have 100% coverage for the project. please let me know if you also want to work on the tests. i didn't tried it but i think it could be possible to use symfony's filesystem component in order to avoid mocking the filesytem.

rename($tmpFilename, $localFilename);
$output->writeln('<info>Deprac was successfully updated.</info>');
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

we should also make the phar file executable (chmod +x)

Copy link
Author

Choose a reason for hiding this comment

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

Do you think the phar file permissions being executed (so it already has execution permission) could be changed by the rename somehow? Otherwise I can't understand why that is necessary, just curiosity 馃槈.

Copy link
Contributor

Choose a reason for hiding this comment

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

you're right, no need for chmod +x

Copy link
Author

Choose a reason for hiding this comment

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

Maybe I wasn't right 馃槀.

After a try, I experienced that new/renamed files in linux system are never going to have execution right independently of the umask set for the directory. Adding +x for all users would be insecure so I'd propose to read the original file permissions before the rename for setting it later to the updated file. That way the original file permissions stay untouched.

@amansilla amansilla force-pushed the self-update-command branch 2 times, most recently from 9b96b8f to 23ef1fd Compare May 9, 2016 13:02
@amansilla
Copy link
Author

@slde-flash I've updated the command with your suggestions and added the documentation, so now it should be good enough.

About the tests, I've being already thinking about it but I guess current the code is not fully testable without a previous refactoring. I guess we could use the filesystem component for the file handling and maybe guzzle for fetching the remote phar.

$output->writeln('<error>Could not write deptrac.phar</error>');

return 1;
} else {
Copy link
Contributor

Choose a reason for hiding this comment

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

you can remove the else statement here

@slde-flash
Copy link
Contributor

i am 馃憤 using guzzle and the filesystem component.

@amansilla amansilla changed the title Add self-update command [WIP] Add self-update command May 12, 2016
@wouterj
Copy link

wouterj commented May 14, 2016

What about using https://github.com/padraic/phar-updater here?

@amansilla
Copy link
Author

I think it's a good option and simplifies the command, they only problem I see, this requires to maintain a new deptrac.version file in order to track the version. As I know, @slde-flash wanted to keep this as simple as possible.

@@ -3,18 +3,19 @@
"license": "MIT",
"require": {
"php": ">=5.5.9",
"graphp/graphviz": "0.2.*",
Copy link
Contributor

Choose a reason for hiding this comment

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

can you try to not reorder the dependencies?

Copy link
Author

Choose a reason for hiding this comment

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

For sure, it'll be fixed on next update. I just like and am used to order the dependencies, I find it more readeable.

Copy link
Contributor

Choose a reason for hiding this comment

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

feel free to create a PR that just reorders the dependencies =)

Copy link
Author

Choose a reason for hiding this comment

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

Ok, now I got your point of view. ;)

@slde-flash
Copy link
Contributor

@amansilla would you prefer moving to https://github.com/padraic/phar-updater if i would maintain the deptrac.version file?

@amansilla
Copy link
Author

@slde-flash I'll to refactor this again, for using the phar updater as it seems to be easy to use and it's integration will simplify the testing as well. In case I find any new problem with it, I'll let you know.

@slde-flash
Copy link
Contributor

@amansilla thank you sooo much :)

@amansilla
Copy link
Author

@slde-flash I refactored the code for using the phar updater. Before I try to add some tests, could you please review the code?


class DeptracStrategy extends ShaStrategy
{
const PHAR_URL = 'http://get.sensiolabs.de/deptrac.phar';
Copy link
Contributor

Choose a reason for hiding this comment

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

please dont use CONST (because const is "public"), i am fine with inlining this or private static :)

Copy link
Author

Choose a reason for hiding this comment

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

The URL was inline added for both ;).

@slde-flash
Copy link
Contributor

@amansilla looks awesome. i am going to play with this pr tonight, if something is missing, i'll take over :)
if you want you could work on a PR that adds Unittests (using prophecy) to this code.

@slde-flash slde-flash self-assigned this May 17, 2016
@slde-flash slde-flash changed the title [WIP] Add self-update command Add self-update command May 17, 2016
@slde-flash slde-flash merged commit 5c0b673 into qossmic:master May 17, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants