-
-
Notifications
You must be signed in to change notification settings - Fork 8
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
Add new docs site #37
base: main
Are you sure you want to change the base?
Conversation
This mostly sounds good but I have a couple notes.
I currently have Side point: There's a difference between each platform's "full name" and its class name. We'd want the full name in a list like that for clarity, but then we'd need to map it in code somewhere. The current
The only reason it isn't keyed today is I believe it adds complexity for manually editing, so that part's fine if it's being generated. However, I'm not keying directly to Illuminate currently because I want to be able to use the same config to use an API connection as the source or target in the future. Today it's all database-driven but I didn't want to paint myself into a corner with the naming. That's why they are "connections" and not "databases". I suspected that creating a separate way to store API connections adds more complexity than a slug translation step for Illuminate. |
Good point! My suggestion would be to make use of Laravel Prompts, which allows you to select from a scrollable list. The options array's values are displayed and the key for the selected option is returned. $source = select(
label: 'Source package',
options: array_map(fn($package) => $package['name'], \Porter\Support::getInstance()->getSources()),
); I would also generally support using Laravel Prompts for other interactivity within the commands, it's really nice UX. Also happy to contribute this! With the config - future-proofing is a valid concern. But I think that for different types of connections (database, API, etc) you're going to end up with vastly different config options anyway, and any overlap is kind of coincidental so I don't think there's any need to aim for consistency, apart from where it makes sense. Think of it like this: 'foo' => [
'type' => 'database',
// database config options
],
'bar' => [
'type' => 'api',
// api config options
] and then: $type = $config['type'];
unset($config['type']);
$connection = match ($type) {
'database' => new DatabaseConnection($config),
'api' => new ApiConnection($config),
default => throw new Exception('unsupported connection type'),
}; Make it each connection type implementation's responsibility to handle whatever config it's expecting. In reality, the Illuminate database config actually supports a lot of other options that may be useful too, so now we can pass them directly in without needing to map to any arbitrary format: 'source' => [
'type' => 'database',
'driver' => 'mysql',
'url' => '',
'host' => '127.0.0.1',
'port' => '3306',
'database' => 'database',
'username' => 'root',
'password' => 'password',
'unix_socket' => '',
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_0900_ai_ci',
'prefix' => '',
'prefix_indexes' => true,
'strict' => true,
'engine' => null,
'options' => [
PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => false,
],
], And your API connection can take whatever shape makes sense, maybe something like: 'target' => [
'type' => 'api',
'host' => 'api.example.com',
'headers' => [
'Authorization' => 'Bearer a1b2c3',
],
// whatever else
] |
That all sounds good to me. I see |
|
🎂 This PR had a birthday this week! 😂 @tobyzerner Any plans to return to this? It was left as a Draft. |
This PR adds a new docs site powered by VitePress. The docs become part of the source repo, rather than in a separate repo, which is easier for users to find and keeps them versioned together with the library.
I've mostly copy/pasted from the existing site, with the most substantial change to the User Guide which is now titled Quick Start. The instructions on this page are currently hypothetical - some ideas for what the UX of Porter could look like - hence this PR is a draft and should not yet be merged. Specifically:
composer global require
is the recommended installation methodporter init
command to generate a new config fileconnections
a keyed array and use database config keys directly from Illuminate. (Not sure if the other config options are still needed?)run
command will allow you to select platforms from a list (rather than having to know the name to type)run
command will automatically use database connections namedsource
andtarget
if they are presentLet me know what you think about this, I'm keen to contribute these changes if they sound okay.
A GitHub action is included which will deploy the docs to GitHub Pages for the repo. See here for how to configure this to work.
Preview the docs locally by running: