-
-
Notifications
You must be signed in to change notification settings - Fork 44
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
Refactor storage layout and files #233
Comments
What I'm proposing is:
|
I took the choice to create a new file to store auth data, to be able to have personal auth access in the file that can be ignore be the VCS. For the |
As for the |
Already expected that reasoning.
In the case of the file being within the project directory, that makes perfect sense. |
Actually, this means we already have a "general" config file available - even though we currently do not use it from Still pondering what is best... |
It's the direction that Composer took (one local
It's used with the |
I'll be pondering about that for a bit :) |
I'm not a fan of cluttering a project's root directory with tool configuration files. And given planned features are going to require additional things to be configured that are best kept in individual files as well, the best choice is likely to adopt github's approach of having a configuration directory rather than a file. So my suggestion would be to create a Apart from the While we can keep support for the |
So, the directories structure should be something like this ? $HOME$ or $PROJECT$
└── .phive/
├── auth.xml # Credential data storage
├── phars.xml # List of installed phars (overall for $HOME$)
└── repositories.xml # Phar repository (downloaded from https://phar.io/ for $HOME$)
$HOME_ONLY$
└── .phive/
├── _tmp_wrk/ # Temporary working directory
├── gpg/
│ └── ... # GPG relative files ( Agent, pubrings, etc.)
├── http-cache/
│ └── ... # Cache of domains requested by Phive
├── local.xml # Global user defined phar repositories
└── phars/
└── ... # Every downloaded Phar (that don't have been purged)
$PROJECT_ONLY$
├── phive.xml # For BC
└── phive-auth.xml # For BC What should be the "fallback" mechanism ? For getting the list of phars to install
For resolving a phar alias
For getting authentication data
For directories in
But it's more a matter of preferences, and yet is not a universal solution either (like for Windows), but should be achievable for Unix-like OS. |
StructureYes, the structure as you listed it would probably be what I envisioned. Still pondering if I like the XDG directory concept. It kind of feels useless: Instead of having all the On top, it would make using phive in CI harder: Instead of keeping just Order of things
My current consideration is that we want to have a setup that uses either the Not sure if we'll introduce this before 0.14.0 gets released. If so, we could decide to not have a phive-auth.xml to begin with, so no BC break. |
Addition to the resolving part: There's no need to use So, I believe this should work best, use a chain of responsibility for alias resolving:
(CoR: Who ever finds something wins, otherwise forward to next.) |
I miss one file: the global What about its name?
|
- Read configuration from .phive and current working directory (phars + auth) - Update skel command - Add warning in output if both configuration exist - Add project level repositories - Copy phive.xml to .phive/phars.xml
Good point. We should probably not do either, because reusing a name for different purposes is going to be a pain to migrate / detect. We could rename the |
or |
I really would like to have this in the |
I'm working on it, see #250 😃
|
Already saw it. Thanks a lot! It looks very promising, let me know when/if you consider it done. |
I guess I'll also mess with the namespace of the auth file: I'm still pondering on the xml structure inside it, but so far nothing I can come up with is actually better - just different. I'm not fully happy with the format but i'll open another ticket for that so we can discuss that separately. Do we need a migrate command actually to get the files moved and converted? |
I'm writing a migration service to handle those kind of action With the idea that migration flagged as
<?php declare(strict_types = 1);
namespace PharIo\Phive;
interface Migration {
/**
* Indicate if the migration can be done.
* Return false if the migration is already done, or no doable
*/
public function canMigrate(): bool;
/**
* Indicate if we allow the state before and after at the same time (false).
* Return true if only the new state is allowed
*/
public function mustMigrate(): bool;
public function migrate(): void;
}
<?php declare(strict_types = 1);
namespace PharIo\Phive;
class HomePharsXml implements Migration {
/** @var Environment */
private $environment;
public function __construct(Environment $environment) {
$this->environment = $environment;
}
public function canMigrate(): bool {
return $this->environment->getHomeDirectory()->file('phars.xml')->exists()
&& !$this->environment->getHomeDirectory()->file('database.xml')->exists();
}
public function mustMigrate(): bool {
return true;
}
public function migrate(): void {
if (!$this->canMigrate()) {
throw new MigrationException();
}
$old = $this->environment->getHomeDirectory()->file('phars.xml');
$new = $this->environment->getHomeDirectory()->file('database.xml');
$new->putContent($old->read()->getContent());
$old->delete();
}
} |
- Change name of ~/.phive/phars.xml to ~/.phive/database.xml - Change name of ~/.phive/phive.xml to ~/.phive/global.xml - Add migration service - Add migrate command - Add auto migration of mandatory migration
Almost done, I just need to add a lot more tests to ensure that migration don't mess up everything. |
- Read configuration from .phive and current working directory (phars + auth) - Update skel command - Add warning in output if both configuration exist - Add project level repositories - Copy phive.xml to .phive/phars.xml
- Change name of ~/.phive/phars.xml to ~/.phive/database.xml - Change name of ~/.phive/phive.xml to ~/.phive/global.xml - Add migration service - Add migrate command - Add auto migration of mandatory migration
- Read configuration from .phive and current working directory (phars + auth) - Update skel command - Add warning in output if both configuration exist - Add project level repositories - Copy phive.xml to .phive/phars.xml
- Change name of ~/.phive/phars.xml to ~/.phive/database.xml - Change name of ~/.phive/phive.xml to ~/.phive/global.xml - Add migration service - Add migrate command - Add auto migration of mandatory migration
- Read configuration from .phive and current working directory (phars + auth) - Update skel command - Add warning in output if both configuration exist - Add project level repositories - Copy phive.xml to .phive/phars.xml
- Change name of ~/.phive/phars.xml to ~/.phive/database.xml - Change name of ~/.phive/phive.xml to ~/.phive/global.xml - Add migration service - Add migrate command - Add auto migration of mandatory migration
Thanks a lot @MacFJA ! |
Okay, ran some more tests and looked a things. Of course, we have a few issues left. Some of these I should have seen earlier, sorry about that. .phive project directoryThe MigrationsWe do run too many things optionally and expose them to the user. The migrations for the files in I'm not sure we do need the Auth migration, actually. Your first implementation was never released. I'd say, we can just remove it? In the command we should probably "only" move the Status outputThe 'Status' output is wrong. It claims 'Migrated' for stuff that doesn't exist. For instance, I don't have an auth.xml file in this project, so how could it be migrated? |
Additional thing: We probably should inform the user what we are migrating and ask for confirmation before doing it. :) |
Yeah, I have this issue too, that why I wrote test like $workingDirectory->hasChild('.phive') && $workingDirectory->child('.phive')->file('phars.xml')->exists(); But it had lots of code/logics.
I wasn't either sure if it was really needed or not
Make sense, and easy to correct
Hmm... maybe Nothing to do is a better status ? |
Yeah, I know. I'll take care of it will also solve issue #179.
Let's drop it then.
Okay, can yo do that?
How about simply |
Thanks to @MacFJA,
phive
now has support to generally download things from repositories requiring authentication.As of now, auth information is stored in a seperate file (
~/.phive/phive-auth.xml
or{$basedir}./phive-auth.xml
).This seems redundant, as we already have a
phive.xml
which could - should? - contain the required entries for the later.And, in case a second file should exist in the
~/.phive
directory, the prefixphive-
is redundant. Given we also plan to have a general config file, maybe we should move these things into it.@MacFJA What do you think?
The text was updated successfully, but these errors were encountered: