-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathBuild_Generate_Command.php
More file actions
62 lines (51 loc) · 1.51 KB
/
Build_Generate_Command.php
File metadata and controls
62 lines (51 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php namespace WP_CLI_Build;
use WP_CLI;
use WP_CLI_Build\Helper\Gitignore;
use WP_CLI_Build\Helper\Utils;
use WP_CLI_Build\Processor\Generate;
class Build_Generate_Command extends \WP_CLI_Command {
/**
* Generates build file with core and activated plugins/themes. Also generates .gitignore with custom plugins/themes.
*
* ## OPTIONS
*
* [--output=<file>]
* : Where to output build generation result (yml file)
*
* [--format]
* : Build file format: json or yml
*
* [--skip-git]
* : .gitignore will not be generated
*
* [--all]
* : Includes all plugins/themes whether they're activated or not
*
* [--yes]
* : Skip overwriting confirmation if the destination build file already exists
*
* ## EXAMPLES
*
* wp build-generate
* wp build-generate --output=production.yml
*
*/
public function __invoke( $args = null, $assoc_args = null ) {
// Build file.
$build_filename = Utils::get_build_filename( $assoc_args );
// If file exists, prompt if the user want to replace it.
if ( file_exists( Utils::wp_path( $build_filename ) ) ) {
if ( empty( $assoc_args['yes'] ) ) {
WP_CLI::confirm( WP_CLI::colorize( "%WFile %Y$build_filename%n%W exists, do you want to overwrite it?%n" ) );
}
}
// New generator class.
$generator = new Generate( $assoc_args, $build_filename );
// Attempt to create build file.
$generator->create_build_file();
// Attempt to gitignore.
if ( empty( $assoc_args['no-gitignore'] ) ) {
$generator->create_gitignore();
}
}
}