Skip to content

Commit ebd05bd

Browse files
committed
add portable option to new command
1 parent 0129bec commit ebd05bd

5 files changed

Lines changed: 32 additions & 5 deletions

File tree

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ This package implements the following commands:
1515
Create a new WordPress install -- fast
1616

1717
~~~
18-
wp valet new <name> [--project=<project>] [--version=<version>] [--locale=<locale>] [--db=<db>] [--dbname=<dbname>] [--dbuser=<dbuser>] [--dbpass=<dbpass>] [--dbprefix=<dbprefix>] [--admin_user=<username>] [--admin_password=<password>] [--admin_email=<email>] [--unsecure]
18+
wp valet new <name> [--project=<project>] [--version=<version>] [--locale=<locale>] [--db=<db>] [--dbname=<dbname>] [--dbuser=<dbuser>] [--dbpass=<dbpass>] [--dbprefix=<dbprefix>] [--admin_user=<username>] [--admin_password=<password>] [--admin_email=<email>] [--unsecure] [--portable]
1919
~~~
2020

2121
This command will spin up a new WordPress installation -- complete with database and https
@@ -92,7 +92,10 @@ _ready-to-use in your browser_ faster than you can put your pants on.
9292
The email to use for the WordPress admin user.
9393

9494
[--unsecure]
95-
Provisions the site for http rather than https.
95+
Provision the site for http rather than https.
96+
97+
[--portable]
98+
Provision the site to be portable. Implies --unsecure and --db=sqlite.
9699

97100

98101

features/valet-new.feature

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,15 @@ Feature: Create a new install.
3131
"""
3232
Success: {PROJECT} ready! https://{PROJECT}.dev
3333
"""
34+
35+
Scenario: It can create a new portable WordPress install.
36+
Given an empty directory
37+
And a random project name as {PROJECT}
38+
When I run `wp valet new {PROJECT} --portable`
39+
Then the {PROJECT}/wp-config.php file should exist
40+
And the {PROJECT}/wp-content/db.php file should exist
41+
And the wp_{PROJECT} database should not exist
42+
And STDOUT should contain:
43+
"""
44+
Success: {PROJECT} ready! http://{PROJECT}.dev
45+
"""

src/Installer/WordPressInstaller.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public function configure()
7474
*/
7575
public function createDatabase()
7676
{
77-
if ('sqlite' == $this->props->option('db')) {
77+
if ($this->props->usingSqlite()) {
7878
$this->createSqlite();
7979
} else {
8080
$this->createMySql();

src/Props.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,15 @@ public function populate()
3737
$this->domain = sprintf('%s.%s', $this->site_name, Valet::domain());
3838
}
3939

40+
/**
41+
* @return bool
42+
*/
43+
public function usingSqlite()
44+
{
45+
return 'sqlite' == $this->option('db')
46+
|| $this->option('portable');
47+
}
48+
4049
/**
4150
* Get the database name as specified by the user, or fallback to a sensible default.
4251
*
@@ -115,7 +124,7 @@ public function fullUrl()
115124
*/
116125
public function isSecure()
117126
{
118-
return ! $this->option('unsecure');
127+
return ! ($this->option('unsecure') || $this->option('portable'));
119128
}
120129

121130
/**

src/ValetCommand.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,10 @@ public static function boot()
130130
* : The email to use for the WordPress admin user.
131131
*
132132
* [--unsecure]
133-
* : Provisions the site for http rather than https.
133+
* : Provision the site for http rather than https.
134+
*
135+
* [--portable]
136+
* : Provision the site to be portable. Implies --unsecure and --db=sqlite.
134137
*
135138
* @subcommand new
136139
*

0 commit comments

Comments
 (0)