@@ -141,35 +141,44 @@ public function defineDeployementPath()
141
141
public function defineAdditionalHooks ()
142
142
{
143
143
$ npm = $ this ->choice (
144
- 'Do you want to compile your asset during deployment with NPM? ' ,
145
- ['No ' , 'Yes using `npm run production` ' , 'Yes using `npm run development` ' ], 1
144
+ 'Do you want to compile your asset during deployment with npm/yarn? ' ,
145
+ [
146
+ 'No ' ,
147
+ 'Yes using `npm run production` ' ,
148
+ 'Yes using `npm run development` ' ,
149
+ 'Yes using `yarn production` ' ,
150
+ 'Yes using `yarn development` ' ,
151
+ ], 1
146
152
);
147
153
148
- if ($ npm !== 'No ' ) {
149
- $ build = $ npm === 'Yes using `npm run production` ' ? 'production ' : 'development ' ;
150
- $ this ->builder ->add ('hooks.build ' , 'npm:install ' );
151
- $ this ->builder ->add ('hooks.build ' , "npm: $ build " );
154
+ if ($ npm === 'Yes using `npm run production` ' ) {
155
+ $ this ->addHooksCompileAssets ('npm ' , 'production ' );
152
156
}
153
157
154
- if ($ npm === 'No ' ) {
155
- $ yarn = $ this ->choice (
156
- 'Do you want to compile your asset during deployment with YARN? ' ,
157
- ['No ' , 'Yes using `yarn production` ' , 'Yes using `yarn development` ' ], 1
158
- );
158
+ if ($ npm === 'Yes using `npm run development` ' ) {
159
+ $ this ->addHooksCompileAssets ('npm ' , 'development ' );
160
+ }
159
161
160
- if ($ yarn !== 'No ' ) {
161
- $ build = $ yarn === 'Yes using `yarn production` ' ? 'production ' : 'development ' ;
162
- $ this ->builder ->add ('hooks.build ' , 'yarn:install ' );
163
- $ this ->builder ->add ('hooks.build ' , "yarn: $ build " );
164
- }
162
+ if ($ npm === 'Yes using `yarn production` ' ) {
163
+ $ this ->addHooksCompileAssets ('yarn ' , 'production ' );
165
164
}
166
-
165
+
166
+ if ($ npm === 'Yes using `yarn development` ' ) {
167
+ $ this ->addHooksCompileAssets ('yarn ' , 'development ' );
168
+ }
169
+
167
170
if ($ this ->confirm ('Do you want to migrate during deployment? ' , true )) {
168
171
$ this ->builder ->add ('hooks.ready ' , 'artisan:migrate ' );
169
172
}
170
-
173
+
171
174
if ($ this ->confirm ('Do you want to terminate horizon after each deployment? ' )) {
172
175
$ this ->builder ->add ('hooks.ready ' , 'artisan:horizon:terminate ' );
173
176
}
174
177
}
178
+
179
+ private function addHooksCompileAssets ($ manager , $ environment )
180
+ {
181
+ $ this ->builder ->add ('hooks.build ' , "$ manager:install " );
182
+ $ this ->builder ->add ('hooks.build ' , "$ manager: $ environment " );
183
+ }
175
184
}
0 commit comments