@caweb/cli 1.0.5 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/caweb +3 -17
- package/lib/caweb.js +20 -17
- package/lib/cli.js +194 -136
- package/lib/commands/destroy.js +66 -0
- package/lib/commands/index.js +29 -9
- package/lib/commands/shell.js +2 -3
- package/lib/commands/start.js +52 -68
- package/lib/commands/stop.js +41 -0
- package/lib/commands/tasks/update-plugins.js +15 -8
- package/lib/commands/test.js +16 -69
- package/lib/configs.js +9 -19
- package/lib/divi.js +28 -26
- package/lib/docker.js +24 -22
- package/lib/download-sources.js +14 -14
- package/lib/env.js +12 -7
- package/lib/options.js +1 -1
- package/lib/spinner.js +70 -0
- package/lib/wordpress.js +45 -27
- package/package.json +8 -3
- package/lib/commands/tasks/index.js +0 -13
package/bin/caweb
CHANGED
|
@@ -1,20 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
'use strict';
|
|
3
2
|
|
|
4
|
-
|
|
5
|
-
let command = process.argv.slice( 2 );
|
|
6
|
-
// Default to help text when they aren't running any commands.
|
|
7
|
-
if ( ! command.length ) {
|
|
8
|
-
command = [ '--help' ];
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
// Rather than just executing the current CLI we will attempt to find a local version
|
|
12
|
-
// and execute that one instead. This prevents users from accidentally using the
|
|
13
|
-
// global CLI when a potentially different local version is expected.
|
|
14
|
-
const localPath = require.resolve( '@caweb/cli/lib/cli.js', {
|
|
15
|
-
paths: [ process.cwd(), __dirname ],
|
|
16
|
-
} );
|
|
17
|
-
const cli = require( localPath )();
|
|
3
|
+
import cli from '../lib/cli.js';
|
|
18
4
|
|
|
19
|
-
//
|
|
20
|
-
cli.parse(
|
|
5
|
+
// Default to help text when they aren't running any commands.
|
|
6
|
+
cli().parse( ! process.argv.length ? [ '--help' ] : process.argv );
|
package/lib/caweb.js
CHANGED
|
@@ -1,29 +1,30 @@
|
|
|
1
|
-
'use strict';
|
|
2
1
|
/**
|
|
3
2
|
* External dependencies
|
|
4
3
|
*/
|
|
5
|
-
|
|
4
|
+
import retry from '@wordpress/env/lib/retry.js';
|
|
6
5
|
|
|
7
6
|
/**
|
|
8
7
|
* Internal dependencies
|
|
9
8
|
*/
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
import { CAWEB_OPTIONS } from'./options.js';
|
|
10
|
+
import { runCLICmds } from'./docker.js';
|
|
11
|
+
import { isMultisite } from'./wordpress.js';
|
|
12
|
+
import { configureDivi } from'./divi.js';
|
|
14
13
|
|
|
15
14
|
/**
|
|
16
15
|
* Activates the CAWeb Theme for the WordPress Environment if it's installed.
|
|
17
16
|
*
|
|
18
17
|
* @param {string} environment Which environment to activate the theme on.
|
|
19
18
|
* @param {WPConfig} config The wp-env config object.
|
|
19
|
+
* @param {Object} spinner A CLI spinner which indicates progress.
|
|
20
20
|
*/
|
|
21
21
|
async function activateCAWeb(
|
|
22
22
|
environment,
|
|
23
|
-
config
|
|
23
|
+
config,
|
|
24
|
+
spinner
|
|
24
25
|
){
|
|
25
26
|
|
|
26
|
-
const isMulti = await isMultisite( environment, config );
|
|
27
|
+
const isMulti = await isMultisite( environment, config , spinner);
|
|
27
28
|
|
|
28
29
|
let cmds = ['wp theme is-installed CAWeb'];
|
|
29
30
|
|
|
@@ -33,10 +34,11 @@ async function activateCAWeb(
|
|
|
33
34
|
cmds.push( 'wp theme activate CAWeb' );
|
|
34
35
|
}
|
|
35
36
|
|
|
36
|
-
return await
|
|
37
|
+
return await runCLICmds(
|
|
37
38
|
environment,
|
|
38
39
|
cmds,
|
|
39
|
-
config
|
|
40
|
+
config,
|
|
41
|
+
spinner
|
|
40
42
|
);
|
|
41
43
|
|
|
42
44
|
}
|
|
@@ -56,8 +58,7 @@ async function configureCAWeb( environment, config, spinner ) {
|
|
|
56
58
|
const isThemeActivated = await activateCAWeb( environment, config );
|
|
57
59
|
|
|
58
60
|
const {
|
|
59
|
-
DESIGN_SYSTEM_ENABLED
|
|
60
|
-
WP_PERMALINK
|
|
61
|
+
DESIGN_SYSTEM_ENABLED
|
|
61
62
|
} = config.env[ environment ].config
|
|
62
63
|
|
|
63
64
|
// if our theme is active.
|
|
@@ -87,10 +88,11 @@ async function configureCAWeb( environment, config, spinner ) {
|
|
|
87
88
|
}
|
|
88
89
|
|
|
89
90
|
// Execute theme option commands.
|
|
90
|
-
await
|
|
91
|
+
await runCLICmds(
|
|
91
92
|
environment,
|
|
92
93
|
themeOptions,
|
|
93
|
-
config
|
|
94
|
+
config,
|
|
95
|
+
spinner
|
|
94
96
|
);
|
|
95
97
|
|
|
96
98
|
// Make Divi WordPress Configurations.
|
|
@@ -106,20 +108,21 @@ async function configureCAWeb( environment, config, spinner ) {
|
|
|
106
108
|
|
|
107
109
|
// Activate Design System plugin
|
|
108
110
|
if( undefined !== DESIGN_SYSTEM_ENABLED && DESIGN_SYSTEM_ENABLED ){
|
|
109
|
-
await
|
|
111
|
+
await runCLICmds(
|
|
110
112
|
environment,
|
|
111
113
|
[
|
|
112
114
|
'wp plugin is-installed design-system-wordpress',
|
|
113
115
|
'wp plugin activate design-system-wordpress'
|
|
114
116
|
],
|
|
115
|
-
config
|
|
117
|
+
config,
|
|
118
|
+
spinner
|
|
116
119
|
)
|
|
117
120
|
}
|
|
118
121
|
|
|
119
122
|
|
|
120
123
|
}
|
|
121
124
|
|
|
122
|
-
|
|
125
|
+
export {
|
|
123
126
|
activateCAWeb,
|
|
124
127
|
configureCAWeb,
|
|
125
128
|
};
|
package/lib/cli.js
CHANGED
|
@@ -1,153 +1,211 @@
|
|
|
1
|
-
'use strict';
|
|
2
1
|
/**
|
|
3
2
|
* External dependencies
|
|
4
3
|
*/
|
|
5
|
-
const wpenv_cli = require('@wordpress/env/lib/cli');
|
|
4
|
+
//const wpenv_cli = require('@wordpress/env/lib/cli');
|
|
6
5
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
import path from 'node:path';
|
|
7
|
+
import chalk from 'chalk';
|
|
8
|
+
import parseXdebugMode from '@wordpress/env/lib/parse-xdebug-mode.js';
|
|
9
|
+
import fs from 'fs-extra';
|
|
10
|
+
import terminalLink from 'terminal-link';
|
|
11
|
+
import { Command, Argument, Option } from 'commander';
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* Internal dependencies
|
|
15
15
|
*/
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
import * as env from './commands/index.js';
|
|
17
|
+
import {
|
|
18
|
+
wpPrimary,
|
|
19
|
+
wpGreen,
|
|
20
|
+
wpYellow,
|
|
21
|
+
wpRed,
|
|
22
|
+
withSpinner
|
|
23
|
+
} from './spinner.js';
|
|
19
24
|
|
|
20
|
-
|
|
21
|
-
const
|
|
22
|
-
const
|
|
23
|
-
const wpGreen = boldWhite.bgHex( '#4ab866' );
|
|
24
|
-
const wpRed = boldWhite.bgHex( '#d94f4f' );
|
|
25
|
-
const wpYellow = boldWhite.bgHex( '#f0b849' );
|
|
25
|
+
const localPath = path.resolve( path.join(process.cwd(), 'node_modules/@caweb/cli/package.json') )
|
|
26
|
+
const pkg = JSON.parse( await fs.readFile(localPath) );
|
|
27
|
+
const program = new Command();
|
|
26
28
|
|
|
27
|
-
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
( message ) => {
|
|
36
|
-
time = process.hrtime( time );
|
|
37
|
-
spinner.succeed(
|
|
38
|
-
`${ message || spinner.text } (in ${ time[ 0 ] }s ${ (
|
|
39
|
-
time[ 1 ] / 1e6
|
|
40
|
-
).toFixed( 0 ) }ms)`
|
|
41
|
-
);
|
|
42
|
-
process.exit( 0 );
|
|
43
|
-
},
|
|
44
|
-
( error ) => {
|
|
45
|
-
if( error ){
|
|
46
|
-
// Error is an unknown error. That means there was a bug in our code.
|
|
47
|
-
spinner.fail(
|
|
48
|
-
typeof error === 'string' ? error : error.message
|
|
49
|
-
);
|
|
50
|
-
// Disable reason: Using console.error() means we get a stack trace.
|
|
51
|
-
console.error( error );
|
|
52
|
-
process.exit( 1 );
|
|
53
|
-
}else{
|
|
54
|
-
spinner.fail( 'An unknown error occurred.' );
|
|
55
|
-
process.exit( 1 );
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
);
|
|
59
|
-
};
|
|
29
|
+
export default function cli() {
|
|
30
|
+
const envArg = new Argument('[environment]', 'Which environment to use.')
|
|
31
|
+
.choices([
|
|
32
|
+
'development',
|
|
33
|
+
'tests',
|
|
34
|
+
'all'
|
|
35
|
+
])
|
|
36
|
+
.default('development');
|
|
60
37
|
|
|
61
|
-
|
|
62
|
-
|
|
38
|
+
const containerArg = new Argument('<container>', 'The underlying Docker service to run the command on.')
|
|
39
|
+
.choices([
|
|
40
|
+
'mysql',
|
|
41
|
+
'tests-mysql',
|
|
42
|
+
'wordpress',
|
|
43
|
+
'tests-wordpress',
|
|
44
|
+
'cli',
|
|
45
|
+
'tests-cli',
|
|
46
|
+
])
|
|
47
|
+
.default('development');
|
|
63
48
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
'
|
|
67
|
-
|
|
68
|
-
(
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
args.option( 'scripts', {
|
|
82
|
-
type: 'boolean',
|
|
83
|
-
describe: 'Execute any configured lifecycle scripts.',
|
|
84
|
-
default: true,
|
|
85
|
-
} );
|
|
86
|
-
args.option( 'bare', {
|
|
87
|
-
type: 'boolean',
|
|
88
|
-
describe: 'True if excluding any downloads from CAWeb, use this if you want to use a local version of the CAWeb Theme, Configurations will still be applied.',
|
|
89
|
-
default: false,
|
|
90
|
-
} );
|
|
91
|
-
args.option( 'multisite', {
|
|
92
|
-
alias: 'm',
|
|
93
|
-
type: 'boolean',
|
|
94
|
-
describe: 'True if converting to multisite.',
|
|
95
|
-
default: false,
|
|
96
|
-
} );
|
|
97
|
-
args.option( 'subdomain', {
|
|
98
|
-
type: 'boolean',
|
|
99
|
-
describe: "If passed, the network will use subdomains, instead of subdirectories. Doesn't work with 'localhost', make sure to set Port to 80.",
|
|
100
|
-
default: false,
|
|
101
|
-
} );
|
|
102
|
-
},
|
|
103
|
-
withSpinner( env.start )
|
|
104
|
-
);
|
|
49
|
+
program
|
|
50
|
+
.name(wpPrimary( 'caweb'))
|
|
51
|
+
.usage( wpYellow( '<command>' ) )
|
|
52
|
+
.description('Command Line Interface utilized by CAWebPublishing to accomplish several tasks.')
|
|
53
|
+
.version( pkg.version )
|
|
54
|
+
.option(
|
|
55
|
+
'--debug',
|
|
56
|
+
'Enable debug output.',
|
|
57
|
+
false
|
|
58
|
+
)
|
|
59
|
+
.allowUnknownOption(true)
|
|
60
|
+
.configureHelp({
|
|
61
|
+
sortSubcommands: true,
|
|
62
|
+
sortOptions: true,
|
|
63
|
+
showGlobalOptions: true,
|
|
64
|
+
})
|
|
65
|
+
.addHelpCommand(false)
|
|
105
66
|
|
|
106
|
-
//
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
67
|
+
// Start command.
|
|
68
|
+
program.command('start')
|
|
69
|
+
.description(
|
|
70
|
+
wpGreen(
|
|
71
|
+
chalk`Starts two CAWebPublishing WordPress instances\ndevelopment on port ${ terminalLink( '8888', 'http://localhost:8888' ) } (override with WP_ENV_PORT)\ntests on port {bold.underline ${ terminalLink( '8889', 'http://localhost:8889' ) }} (override with WP_ENV_TESTS_PORT).\nAfter first install, use the '--update' flag to download updates to mapped sources and to re-apply CAWeb configuration options.`
|
|
72
|
+
)
|
|
73
|
+
)
|
|
74
|
+
.option(
|
|
75
|
+
'--update',
|
|
76
|
+
'Download source updates and apply WordPress configuration.',
|
|
77
|
+
false
|
|
78
|
+
)
|
|
79
|
+
.option(
|
|
80
|
+
'--xdebug <mode>',
|
|
81
|
+
'Enables Xdebug. If not passed, Xdebug is turned off. If no modes are set, uses "debug". You may set multiple Xdebug modes by passing them in a comma-separated list: `--xdebug=develop,coverage`. See https://xdebug.org/docs/all_settings#mode for information about Xdebug modes.',
|
|
82
|
+
)
|
|
83
|
+
.option(
|
|
84
|
+
'--scripts',
|
|
85
|
+
'Execute any configured lifecycle scripts.',
|
|
86
|
+
true
|
|
87
|
+
)
|
|
88
|
+
.option(
|
|
89
|
+
'--bare',
|
|
90
|
+
'True if excluding any downloads from CAWeb, use this if you want to use a local version of the CAWeb Theme, Configurations will still be applied.',
|
|
91
|
+
false
|
|
92
|
+
)
|
|
93
|
+
.option(
|
|
94
|
+
'-m, --multisite',
|
|
95
|
+
'True if converting to multisite.',
|
|
96
|
+
false
|
|
97
|
+
)
|
|
98
|
+
.option(
|
|
99
|
+
'--subdomain',
|
|
100
|
+
"If passed, the network will use subdomains, instead of subdirectories. Doesn't work with 'localhost', make sure to set Port to 80.",
|
|
101
|
+
false
|
|
102
|
+
)
|
|
103
|
+
.allowUnknownOption(true)
|
|
104
|
+
.action( withSpinner(env.start) )
|
|
120
105
|
|
|
121
|
-
//
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
106
|
+
// Destroy Command.
|
|
107
|
+
program.command('destroy')
|
|
108
|
+
.description(
|
|
109
|
+
wpRed(
|
|
110
|
+
'Deletes docker containers, volumes, and networks associated with the CAWebPublishing instances and removes local files.'
|
|
111
|
+
)
|
|
112
|
+
)
|
|
113
|
+
.option(
|
|
114
|
+
'--scripts',
|
|
115
|
+
'Execute any configured lifecycle scripts.',
|
|
116
|
+
true
|
|
117
|
+
)
|
|
118
|
+
.allowUnknownOption(true)
|
|
119
|
+
.action( withSpinner(env.destroy) )
|
|
135
120
|
|
|
136
|
-
//
|
|
137
|
-
|
|
138
|
-
'
|
|
139
|
-
|
|
140
|
-
(
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
121
|
+
// Shell Command.
|
|
122
|
+
program.command('shell')
|
|
123
|
+
.description('Open shell terminal in WordPress environment.')
|
|
124
|
+
.addArgument(envArg)
|
|
125
|
+
.allowUnknownOption(true)
|
|
126
|
+
.action( withSpinner(env.shell) )
|
|
127
|
+
|
|
128
|
+
// Stop Command.
|
|
129
|
+
program.command('stop')
|
|
130
|
+
.description(
|
|
131
|
+
wpRed(
|
|
132
|
+
'Stops running WordPress for development and tests and frees the ports.'
|
|
133
|
+
)
|
|
134
|
+
)
|
|
135
|
+
.allowUnknownOption(true)
|
|
136
|
+
.action( withSpinner(env.stop) )
|
|
137
|
+
|
|
138
|
+
// Clean Command.
|
|
139
|
+
program.command('clean')
|
|
140
|
+
.description(
|
|
141
|
+
wpYellow( 'Cleans the WordPress databases.' )
|
|
142
|
+
)
|
|
143
|
+
.addArgument(envArg)
|
|
144
|
+
.option(
|
|
145
|
+
'--scripts',
|
|
146
|
+
'Execute any configured lifecycle scripts.',
|
|
147
|
+
true
|
|
148
|
+
)
|
|
149
|
+
.allowUnknownOption(true)
|
|
150
|
+
.action( withSpinner(env.clean) )
|
|
151
151
|
|
|
152
|
-
|
|
152
|
+
// Logs Command.
|
|
153
|
+
program.command('logs')
|
|
154
|
+
.description(
|
|
155
|
+
'Displays PHP and Docker logs for given WordPress environment.'
|
|
156
|
+
)
|
|
157
|
+
.addArgument(envArg)
|
|
158
|
+
.option(
|
|
159
|
+
'--no-watch',
|
|
160
|
+
'Stops watching for logs in realtime.',
|
|
161
|
+
true
|
|
162
|
+
)
|
|
163
|
+
.allowUnknownOption(true)
|
|
164
|
+
.action( withSpinner(env.logs) )
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
// Run Command.
|
|
168
|
+
program.command('run')
|
|
169
|
+
.description(
|
|
170
|
+
'Runs an arbitrary command in one of the underlying Docker containers. A double dash can be used to pass arguments to the container without parsing them. This is necessary if you are using an option that is defined below. You can use `bash` to open a shell session and both `composer` and `phpunit` are available in all WordPress and CLI containers. WP-CLI is also available in the CLI containers.'
|
|
171
|
+
)
|
|
172
|
+
.addArgument(containerArg)
|
|
173
|
+
.argument('[command...]', 'The command to run.')
|
|
174
|
+
.option(
|
|
175
|
+
'--env-cwd',
|
|
176
|
+
"The command's working directory inside of the container. Paths without a leading slash are relative to the WordPress root.",
|
|
177
|
+
'.'
|
|
178
|
+
)
|
|
179
|
+
.allowUnknownOption(true)
|
|
180
|
+
.action( withSpinner(env.run) )
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
// Install Path Command.
|
|
184
|
+
program.command('install-path')
|
|
185
|
+
.description('Get the path where all of the environment files are stored. This includes the Docker files, WordPress, PHPUnit files, and any sources that were downloaded.')
|
|
186
|
+
.allowUnknownOption(true)
|
|
187
|
+
.action( withSpinner(env.installPath) )
|
|
188
|
+
|
|
189
|
+
// Update Plugins Command.
|
|
190
|
+
program.command('update-plugins')
|
|
191
|
+
.description('Updates all plugins in the WordPress environment.')
|
|
192
|
+
.argument('[slug]', 'Plugin slug to update.', 'all')
|
|
193
|
+
.addOption(new Option('--environment <env>', 'Which environment to use.').choices(['development', 'tests']).default('development'))
|
|
194
|
+
.allowUnknownOption(true)
|
|
195
|
+
.action( withSpinner(env.updatePlugins) )
|
|
196
|
+
|
|
197
|
+
// Test Command.
|
|
198
|
+
// Ensure this is commented out.
|
|
199
|
+
program.command('test')
|
|
200
|
+
.description('Test commands on a WordPress environment')
|
|
201
|
+
.addArgument(envArg)
|
|
202
|
+
.option(
|
|
203
|
+
'--scripts',
|
|
204
|
+
'Execute any configured lifecycle scripts.',
|
|
205
|
+
true
|
|
206
|
+
)
|
|
207
|
+
.allowUnknownOption(true)
|
|
208
|
+
.action(withSpinner(env.test))
|
|
209
|
+
|
|
210
|
+
return program;
|
|
153
211
|
};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import loadConfig from '@wordpress/env/lib/config/load-config.js';
|
|
3
|
+
import { spawn } from 'node:child_process';
|
|
4
|
+
import { v2 as dockerCompose } from 'docker-compose';
|
|
5
|
+
|
|
6
|
+
import { default as wpEnvDestroy } from '@wordpress/env/lib/commands/destroy.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Internal dependencies
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Promisified dependencies
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Starts the development server.
|
|
18
|
+
*
|
|
19
|
+
* @param {Object} options
|
|
20
|
+
* @param {Object} options.spinner A CLI spinner which indicates progress.
|
|
21
|
+
* @param {boolean} options.scripts Indicates whether or not lifecycle scripts should be executed.
|
|
22
|
+
* @param {boolean} options.debug True if debug mode is enabled.
|
|
23
|
+
*
|
|
24
|
+
*/
|
|
25
|
+
export default async function destroy({
|
|
26
|
+
spinner,
|
|
27
|
+
scripts,
|
|
28
|
+
debug,
|
|
29
|
+
}) {
|
|
30
|
+
|
|
31
|
+
await wpEnvDestroy({spinner, scripts, debug });
|
|
32
|
+
|
|
33
|
+
// wp-env destroy completed successfully if spinner.text reads.
|
|
34
|
+
if( 'Removed WordPress environment.' === spinner.text ){
|
|
35
|
+
spinner.text = "Cleaning up...";
|
|
36
|
+
|
|
37
|
+
// Stop phpMyAdmin as well
|
|
38
|
+
// wp-env doesn't destroy the phpmyadmin image so we have to do it ourselves.
|
|
39
|
+
await new Promise( (resolve, reject) => {
|
|
40
|
+
const childProc = spawn(
|
|
41
|
+
'docker',
|
|
42
|
+
[
|
|
43
|
+
'image',
|
|
44
|
+
'rm',
|
|
45
|
+
'phpmyadmin'
|
|
46
|
+
],
|
|
47
|
+
{ stdio: 'ignore' },
|
|
48
|
+
spinner
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
childProc.on( 'error', reject );
|
|
52
|
+
childProc.on( 'exit', ( code ) => {
|
|
53
|
+
// Code 130 is set if the user tries to exit with ctrl-c before using
|
|
54
|
+
// ctrl-d (so it is not an error which should fail the script.)
|
|
55
|
+
if ( code === 0 || code === 130 ) {
|
|
56
|
+
resolve();
|
|
57
|
+
} else {
|
|
58
|
+
reject( `Command failed with exit code ${ code }` );
|
|
59
|
+
}
|
|
60
|
+
} );
|
|
61
|
+
});
|
|
62
|
+
spinner.text = "Removed WordPress environment.'";
|
|
63
|
+
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
}
|
package/lib/commands/index.js
CHANGED
|
@@ -1,20 +1,40 @@
|
|
|
1
|
-
'use strict';
|
|
2
1
|
/**
|
|
3
2
|
* External dependencies
|
|
4
3
|
*/
|
|
5
4
|
|
|
5
|
+
/**
|
|
6
|
+
* These are default wp-env commands. No need to overwrite these commands
|
|
7
|
+
*/
|
|
8
|
+
import clean from '@wordpress/env/lib/commands/clean.js';
|
|
9
|
+
import logs from '@wordpress/env/lib/commands/logs.js';
|
|
10
|
+
import run from '@wordpress/env/lib/commands/run.js';
|
|
11
|
+
import installPath from '@wordpress/env/lib/commands/install-path.js';
|
|
12
|
+
|
|
6
13
|
/**
|
|
7
14
|
* Internal dependencies
|
|
8
15
|
*/
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const test = require( './test' );
|
|
16
|
+
import shell from './shell.js';
|
|
17
|
+
import updatePlugins from './tasks/update-plugins.js'
|
|
12
18
|
|
|
13
|
-
|
|
19
|
+
import test from './test.js';
|
|
14
20
|
|
|
15
|
-
|
|
16
|
-
|
|
21
|
+
/**
|
|
22
|
+
* These are default wp-env commands, we overwrite these commands so we can run additional steps.
|
|
23
|
+
*/
|
|
24
|
+
import start from './start.js';
|
|
25
|
+
import destroy from './destroy.js';
|
|
26
|
+
import stop from './stop.js';
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
export {
|
|
30
|
+
clean,
|
|
31
|
+
logs,
|
|
32
|
+
run,
|
|
33
|
+
installPath,
|
|
17
34
|
start,
|
|
35
|
+
stop,
|
|
36
|
+
destroy,
|
|
18
37
|
test,
|
|
19
|
-
|
|
20
|
-
|
|
38
|
+
shell,
|
|
39
|
+
updatePlugins
|
|
40
|
+
}
|
package/lib/commands/shell.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
'use strict';
|
|
2
1
|
/**
|
|
3
2
|
* External dependencies
|
|
4
3
|
*/
|
|
5
|
-
|
|
4
|
+
import run from '@wordpress/env/lib/commands/run.js';
|
|
6
5
|
|
|
7
6
|
/**
|
|
8
7
|
* Internal dependencies
|
|
@@ -16,7 +15,7 @@ const run = require( '@wordpress/env/lib/commands/run' );
|
|
|
16
15
|
* @param {boolean} options.environment Which environment to open terminal in.
|
|
17
16
|
* @param {boolean} options.debug True if debug mode is enabled.
|
|
18
17
|
*/
|
|
19
|
-
|
|
18
|
+
export default async function shell({
|
|
20
19
|
spinner,
|
|
21
20
|
environment,
|
|
22
21
|
debug
|