1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* The file that defines to modify files after install the project. |
4
|
|
|
* |
5
|
|
|
* @link https://github.com/maab16 |
6
|
|
|
* @since 1.0.0 |
7
|
|
|
* |
8
|
|
|
* @package WPB |
9
|
|
|
* @subpackage WPB/src/Composer |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace CodexShaper\Composer; |
13
|
|
|
|
14
|
|
|
use Composer\Script\Event; |
15
|
|
|
use Symfony\Component\Process\Process; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* The composer script class. |
19
|
|
|
* |
20
|
|
|
* Here set all the logic that implement after install the project. |
21
|
|
|
* |
22
|
|
|
* @since 1.0.0 |
23
|
|
|
* @package WPB |
24
|
|
|
* @subpackage WPB/src/Composer |
25
|
|
|
* @author Md Abu Ahsan basir <[email protected]> |
26
|
|
|
*/ |
27
|
|
|
class ComposerScripts { |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* Handle the post-install Composer event. |
31
|
|
|
* |
32
|
|
|
* @param \Composer\Script\Event $event The composer event. |
|
|
|
|
33
|
|
|
* @return void |
34
|
|
|
*/ |
35
|
|
|
public static function post_install( Event $event ) { |
36
|
|
|
require_once $event->getComposer()->getConfig()->get( 'vendor-dir' ) . '/autoload.php'; |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* Handle the post-update Composer event. |
41
|
|
|
* |
42
|
|
|
* @param \Composer\Script\Event $event The composer event. |
43
|
|
|
* @return void |
44
|
|
|
*/ |
45
|
|
|
public static function post_update( Event $event ) { |
46
|
|
|
require_once $event->getComposer()->getConfig()->get( 'vendor-dir' ) . '/autoload.php'; |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* Handle the post-autoload-dump Composer event. |
51
|
|
|
* |
52
|
|
|
* @param \Composer\Script\Event $event The composer event. |
53
|
|
|
* @return void |
54
|
|
|
*/ |
55
|
|
|
public static function post_autoload_dump( Event $event ) { |
56
|
|
|
require_once $event->getComposer()->getConfig()->get( 'vendor-dir' ) . '/autoload.php'; |
57
|
|
|
|
58
|
|
|
$dir = $event->getComposer()->getConfig()->get( 'vendor-dir' ) . '/../'; |
|
|
|
|
59
|
|
|
$root = dirname( $event->getComposer()->getConfig()->get( 'vendor-dir' ) ); |
60
|
|
|
|
61
|
|
|
$vendor_name = strtolower( basename( $root ) ); |
62
|
|
|
$partials = explode( '-', $vendor_name ); |
63
|
|
|
$camel_case_partials = array(); |
64
|
|
|
foreach ( $partials as $partial ) { |
65
|
|
|
$camel_case_partials[] = ucfirst( strtolower( $partial ) ); |
66
|
|
|
} |
67
|
|
|
$camel_case = implode( '_', $camel_case_partials ); |
68
|
|
|
$snake_case = implode( '_', $partials ); |
69
|
|
|
|
70
|
|
|
$files = array( |
71
|
|
|
'/wpb.php', |
72
|
|
|
'/bootstrap/app.php', |
73
|
|
|
'/includes/class-wpb-activator.php', |
74
|
|
|
'/includes/class-wpb-deactivator.php', |
75
|
|
|
'/includes/class-wpb-i18n.php', |
76
|
|
|
'/includes/class-wpb-loader.php', |
77
|
|
|
'/includes/class-wpb.php', |
78
|
|
|
'/admin/class-wpb-admin.php', |
79
|
|
|
'/admin/class-wpb-admin-menu.php', |
80
|
|
|
'/admin/class-wpb-admin-submenu.php', |
81
|
|
|
'/admin/partials/wpb-admin-display.php', |
82
|
|
|
'/admin/css/wpb-admin.css', |
83
|
|
|
'/admin/js/wpb-admin.js', |
84
|
|
|
'/public/class-wpb-public.php', |
85
|
|
|
'/public/partials/wpb-public-display.php', |
86
|
|
|
'/public/css/wpb-public.css', |
87
|
|
|
'/public/js/wpb-public.js', |
88
|
|
|
'/routes/web.php', |
89
|
|
|
'/routes/api.php', |
90
|
|
|
'/resources/js/admin/main.js', |
91
|
|
|
'/resources/js/frontend/main.js', |
92
|
|
|
'/resources/js/spa/main.js', |
93
|
|
|
'/src/Application.php', |
94
|
|
|
'/src/helpers.php', |
95
|
|
|
'/src/Support/Facades/Config.php', |
96
|
|
|
'/src/Support/Facades/Route.php', |
97
|
|
|
'/src/Http/Kernel.php', |
98
|
|
|
'/src/Http/Events/RequestHandler.php', |
99
|
|
|
'/src/Exceptions/Handler.php', |
100
|
|
|
'/app/User.php', |
101
|
|
|
'/app/Post.php', |
102
|
|
|
'/app/Http/Controllers/ProductController.php', |
103
|
|
|
'/app/Http/Middleware/AuthMiddleware.php', |
104
|
|
|
'/app/Http/Middleware/VerifyCsrfToken.php', |
105
|
|
|
'/app/Http/Kernel.php', |
106
|
|
|
'/app/Exceptions/Handler.php', |
107
|
|
|
); |
108
|
|
|
|
109
|
|
|
foreach ( $files as $file ) { |
110
|
|
|
$file = $root . $file; |
111
|
|
|
if ( file_exists( $file ) ) { |
112
|
|
|
$contents = get_contents( $file ); |
|
|
|
|
113
|
|
|
$contents = str_replace( 'wpb_', $snake_case . '_', $contents ); |
114
|
|
|
$contents = str_replace( 'wpb', $vendor_name, $contents ); |
115
|
|
|
$contents = str_replace( 'WPB_APP_ROOT', strtoupper( $camel_case ) . '_APP_ROOT', $contents ); |
116
|
|
|
$contents = str_replace( 'WPB_FILE', strtoupper( $camel_case ) . '_FILE', $contents ); |
117
|
|
|
$contents = str_replace( 'WPB_PATH', strtoupper( $camel_case ) . '_PATH', $contents ); |
118
|
|
|
$contents = str_replace( 'WPB_INCLUDES', strtoupper( $camel_case ) . '_INCLUDES', $contents ); |
119
|
|
|
$contents = str_replace( 'WPB_URL', strtoupper( $camel_case ) . '_URL', $contents ); |
120
|
|
|
$contents = str_replace( 'WPB_ASSETS', strtoupper( $camel_case ) . '_ASSETS', $contents ); |
121
|
|
|
$contents = str_replace( 'WPB_VERSION', strtoupper( $camel_case ) . '_VERSION', $contents ); |
122
|
|
|
$contents = str_replace( 'WPB', $camel_case, $contents ); |
123
|
|
|
put_contents( |
|
|
|
|
124
|
|
|
$file, |
125
|
|
|
$contents |
126
|
|
|
); |
127
|
|
|
|
128
|
|
|
$dir = dirname( $file ); |
129
|
|
|
$file_name = basename( $file ); |
130
|
|
|
$new_file_name = str_replace( 'wpb', $vendor_name, $file_name ); |
131
|
|
|
|
132
|
|
|
if ( $file_name !== $new_file_name ) { |
133
|
|
|
rename( $file, $dir . '/' . $new_file_name ); |
134
|
|
|
} |
135
|
|
|
} |
136
|
|
|
} |
137
|
|
|
|
138
|
|
|
static::update_bootstrap( $root, $camel_case ); |
139
|
|
|
} |
140
|
|
|
|
141
|
|
|
/** |
142
|
|
|
* Replace bootstrap file. |
143
|
|
|
* |
144
|
|
|
* @since 1.0.0 |
145
|
|
|
* @access public |
146
|
|
|
* |
147
|
|
|
* @param string $root The string is unique root path for each plugin. |
148
|
|
|
* @param string $camel_case This string is camel case of project name. |
149
|
|
|
* |
150
|
|
|
* @return void |
151
|
|
|
*/ |
152
|
|
|
protected static function update_bootstrap( $root, $camel_case ) { |
153
|
|
|
$file = $root . '/bootstrap/app.php'; |
154
|
|
|
if ( file_exists( $file ) ) { |
155
|
|
|
$contents = get_contents( $file ); |
|
|
|
|
156
|
|
|
$contents = str_replace( 'WPB_APP_ROOT', strtoupper( $camel_case ) . '_APP_ROOT', $contents ); |
157
|
|
|
put_contents( |
|
|
|
|
158
|
|
|
$file, |
159
|
|
|
$contents |
160
|
|
|
); |
161
|
|
|
|
162
|
|
|
} |
163
|
|
|
} |
164
|
|
|
} |
165
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths