File tree Expand file tree Collapse file tree 5 files changed +169
-2
lines changed
Expand file tree Collapse file tree 5 files changed +169
-2
lines changed Original file line number Diff line number Diff line change 1+
2+ # Debugging
3+
4+ Not sure what's triggering a rebuild? You can use the ` airdrop:debug ` command to help you diagnose it.
5+
6+ The Debug command will simply print out the JSON object that will be hashed to calculate if a rebuild is needed.
7+
8+ For example, let's imagine your triggers are very, very simple:
9+
10+ ``` php
11+ ConfigTrigger::class => [
12+ 'env' => env('APP_ENV')
13+ ],
14+
15+ FileTrigger::class => [
16+ 'include' => [
17+ base_path('package-lock.json'),
18+ ],
19+ ]
20+ ```
21+
22+ When you call ` aidrop:debug ` , the following will be printed to your console:
23+
24+ ``` json
25+ {
26+ "Hammerstone\\ Airdrop\\ Triggers\\ ConfigTrigger" : {
27+ "env" : " production"
28+ },
29+ "Hammerstone\\ Airdrop\\ Triggers\\ FileTrigger" : {
30+ "package-lock.json" : " 62f6d1bfc836a1536c4869fe8f78249b"
31+ }
32+ }
33+ ```
34+
35+ If you want to narrow it down to a single trigger, you can pass that through with the ` --trigger ` option:
36+
37+ ``` bash
38+ php artisan airdrop:debug --trigger=Hammerstone\\ Airdrop\\ Triggers\\ ConfigTrigger
39+ ```
40+
41+ Then you'll _ only_ get output for the config trigger:
42+ ``` json
43+ {
44+ "Hammerstone\\ Airdrop\\ Triggers\\ ConfigTrigger" : {
45+ "env" : " production"
46+ }
47+ }
48+ ```
49+
50+ You can write this output to a file and store it somewhere for inspection
51+
52+ ``` bash
53+ php artisan airdrop:debug > airdrop.json
54+ ```
55+
56+ Or you can run it before and after a command you expect is modifying files (as was the case with [ this issue] ( https://github.com/hammerstonedev/airdrop/issues/2 ) ) to see what the difference is:
57+
58+ ``` bash
59+ php artisan aidrop:debug > before.json
60+
61+ npm run production
62+
63+ php artisan aidrop:debug > after.json
64+
65+ diff before.json after.json
66+ ```
Original file line number Diff line number Diff line change 1818 "Filesystem" : " /drivers/filesystem" ,
1919 "Custom" : " /drivers/custom"
2020 }
21- }
21+ },
22+ "Debugging" : " /debugging"
2223 }
2324}
Original file line number Diff line number Diff line change 55
66namespace Hammerstone \Airdrop ;
77
8+ use Hammerstone \Airdrop \Commands \Debug ;
89use Hammerstone \Airdrop \Commands \Install ;
910use Hammerstone \Airdrop \Commands \Download ;
1011use Hammerstone \Airdrop \Commands \Upload ;
@@ -18,7 +19,8 @@ public function boot()
1819 $ this ->commands ([
1920 Install::class,
2021 Download::class,
21- Upload::class
22+ Upload::class,
23+ Debug::class
2224 ]);
2325 }
2426
Original file line number Diff line number Diff line change 1+ <?php
2+ /**
3+ * @author Aaron Francis <aaron@hammerstone.dev>
4+ */
5+
6+ namespace Hammerstone \Airdrop \Commands ;
7+
8+ use Arr ;
9+ use Hammerstone \Airdrop \HashGenerator ;
10+ use Illuminate \Console \Command ;
11+
12+ class Debug extends Command
13+ {
14+ protected $ signature = 'airdrop:debug {--trigger=} ' ;
15+
16+ protected $ description = 'Output the array of all triggers, or a specific trigger. ' ;
17+
18+ public function handle ()
19+ {
20+ $ output = HashGenerator::make ()->asArray ();
21+
22+ if ($ trigger = $ this ->option ('trigger ' )) {
23+ $ output = Arr::only ($ output , $ trigger );
24+ }
25+
26+ // Pretty print it to make diffing easier.
27+ $ this ->line (
28+ json_encode ($ output , JSON_PRETTY_PRINT )
29+ );
30+ }
31+
32+ }
Original file line number Diff line number Diff line change 1+ <?php
2+ /**
3+ * @author Aaron Francis <aarondfrancis@gmail.com|https://twitter.com/aarondfrancis>
4+ */
5+
6+ namespace Hammerstone \Airdrop \Tests \Commands ;
7+
8+ use Hammerstone \Airdrop \Tests \BaseTest ;
9+ use Hammerstone \Airdrop \Triggers \ConfigTrigger ;
10+ use Hammerstone \Airdrop \Triggers \FileTrigger ;
11+
12+ class DebugCommandTest extends BaseTest
13+ {
14+ public function getEnvironmentSetUp ($ app )
15+ {
16+ config ()->set ('airdrop.triggers ' , [
17+ ConfigTrigger::class => [
18+ 'env ' => 'testing '
19+ ],
20+ FileTrigger::class => [
21+ 'trim ' => base_path (),
22+ 'include ' => [
23+ base_path ('tests/Support/primary-webpack.mix.example ' ),
24+ ]
25+ ]
26+ ]);
27+ }
28+
29+ /** @test */
30+ public function test_all_triggers_output ()
31+ {
32+ $ expected = <<<EOT
33+ {
34+ "Hammerstone\\\Airdrop\\\Triggers\\\ConfigTrigger": {
35+ "env": "testing"
36+ },
37+ "Hammerstone\\\Airdrop\\\Triggers\\\FileTrigger": {
38+ "\/tests\/Support\/primary-webpack.mix.example": "62f6d1bfc836a1536c4869fe8f78249b"
39+ }
40+ }
41+ EOT ;
42+
43+ $ this ->artisan ('airdrop:debug ' )
44+ ->expectsOutput ($ expected )
45+ ->assertExitCode (0 );
46+ }
47+
48+
49+ /** @test */
50+ public function test_single_trigger ()
51+ {
52+ $ expected = <<<EOT
53+ {
54+ "Hammerstone\\\Airdrop\\\Triggers\\\ConfigTrigger": {
55+ "env": "testing"
56+ }
57+ }
58+ EOT ;
59+
60+ $ this ->artisan ('airdrop:debug --trigger=Hammerstone \\\Airdrop \\\Triggers \\\ConfigTrigger ' )
61+ ->expectsOutput ($ expected )
62+ ->assertExitCode (0 );
63+ }
64+
65+
66+ }
You can’t perform that action at this time.
0 commit comments