├── .codecov.yml
├── .github
└── FUNDING.yml
├── .gitignore
├── .phpunit.result.cache
├── .styleci.yml
├── .travis.yml
├── CHANGELOG.md
├── CONTRIBUTING.md
├── LICENSE.md
├── composer.json
├── composer.lock
├── phpunit.xml
├── readme.md
├── src
├── Commands
│ ├── AddPackage.php
│ ├── ClonePackage.php
│ ├── Database
│ │ ├── FactoryMakeCommand.php
│ │ ├── MigrationMakeCommand.php
│ │ └── SeederMakeCommand.php
│ ├── DeletePackageCredentials.php
│ ├── Foundation
│ │ ├── ChannelMakeCommand.php
│ │ ├── ConsoleMakeCommand.php
│ │ ├── EventMakeCommand.php
│ │ ├── ExceptionMakeCommand.php
│ │ ├── JobMakeCommand.php
│ │ ├── ListenerMakeCommand.php
│ │ ├── MailMakeCommand.php
│ │ ├── ModelMakeCommand.php
│ │ ├── NotificationMakeCommand.php
│ │ ├── ObserverMakeCommand.php
│ │ ├── PolicyMakeCommand.php
│ │ ├── ProviderMakeCommand.php
│ │ ├── RequestMakeCommand.php
│ │ ├── ResourceMakeCommand.php
│ │ ├── RuleMakeCommand.php
│ │ ├── TestMakeCommand.php
│ │ └── stubs
│ │ │ ├── test.stub
│ │ │ └── unit-test.stub
│ ├── GeneratorCommand.php
│ ├── NovaMakeCommand.php
│ ├── Package
│ │ ├── BaseTestMakeCommand.php
│ │ ├── CodecovMakeCommand.php
│ │ ├── ComposerMakeCommand.php
│ │ ├── ContributionMakeCommand.php
│ │ ├── GitignoreMakeCommand.php
│ │ ├── LicenseMakeCommand.php
│ │ ├── PhpunitMakeCommand.php
│ │ ├── ReadmeMakeCommand.php
│ │ ├── StyleciMakeCommand.php
│ │ ├── TravisMakeCommand.php
│ │ └── stubs
│ │ │ ├── .codecov.stub
│ │ │ ├── .gitignore.stub
│ │ │ ├── .styleci.stub
│ │ │ ├── .travis.stub
│ │ │ ├── CONTRIBUTING.stub
│ │ │ ├── LICENSE.stub
│ │ │ ├── base-test.stub
│ │ │ ├── composer.stub
│ │ │ ├── phpunit.stub
│ │ │ └── readme.stub
│ ├── PackageMakeCommand.php
│ ├── Replace.php
│ ├── Routing
│ │ ├── ControllerMakeCommand.php
│ │ └── MiddlewareMakeCommand.php
│ ├── SavePackageCredentials.php
│ └── Standard
│ │ ├── AnyMakeCommand.php
│ │ ├── ContractMakeCommand.php
│ │ ├── InterfaceMakeCommand.php
│ │ ├── TraitMakeCommand.php
│ │ └── stubs
│ │ └── dummy.stub
├── LaravelPackageMakerServiceProvider.php
└── Traits
│ ├── CreatesPackageStubs.php
│ ├── HasNameInput.php
│ └── InteractsWithTerminal.php
└── tests
├── Feature
├── ClonePackageTest.php
├── DeletePackageCredentialsTest.php
├── ReplaceTest.php
└── SavePackageCredentialsTest.php
├── Support
└── package
│ ├── .gitignore
│ ├── CONTRIBUTING.md
│ ├── LICENSE.md
│ ├── composer.json
│ ├── phpunit.xml
│ ├── readme.md
│ ├── src
│ └── PackageServiceProvider.php
│ └── tests
│ └── TestCase.php
└── TestCase.php
/.codecov.yml:
--------------------------------------------------------------------------------
1 | codecov:
2 | notify:
3 | require_ci_to_pass: yes
4 |
5 | coverage:
6 | precision: 2
7 | round: down
8 | range: “70…100”
9 |
10 | status:
11 | project: yes
12 | patch: yes
13 | changes: no
14 |
15 | comment:
16 | layout: “reach, diff, flags, files, footer”
17 | behavior: default
18 | require_changes: no
--------------------------------------------------------------------------------
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | # These are supported funding model platforms
2 |
3 | github: Naoray
4 | patreon: # Replace with a single Patreon username
5 | open_collective: # Replace with a single Open Collective username
6 | ko_fi: # Replace with a single Ko-fi username
7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
9 | liberapay: # Replace with a single Liberapay username
10 | issuehunt: # Replace with a single IssueHunt username
11 | otechie: # Replace with a single Otechie username
12 | custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
13 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .phpunit.result.cache
2 | /vendor
--------------------------------------------------------------------------------
/.phpunit.result.cache:
--------------------------------------------------------------------------------
1 | C:37:"PHPUnit\Runner\DefaultTestResultCache":871:{a:2:{s:7:"defects";a:0:{}s:5:"times";a:7:{s:86:"Naoray\LaravelPackageMaker\Tests\Feature\ClonePackageTest::it_can_clone_local_packages";d:0.184;s:88:"Naoray\LaravelPackageMaker\Tests\Feature\ClonePackageTest::it_can_clone_git_repositories";d:1.985;s:91:"Naoray\LaravelPackageMaker\Tests\Feature\ClonePackageTest::it_can_clone_remote_repositories";d:1.673;s:115:"Naoray\LaravelPackageMaker\Tests\Feature\DeletePackageCredentialsTest::it_can_delete_package_credentials_from_cache";d:0.053;s:101:"Naoray\LaravelPackageMaker\Tests\Feature\ReplaceTest::it_can_replace_a_files_old_string_with_new_ones";d:0.074;s:115:"Naoray\LaravelPackageMaker\Tests\Feature\ReplaceTest::it_can_replace_all_files_old_string_with_new_ones_in_a_folder";d:0.065;s:115:"Naoray\LaravelPackageMaker\Tests\Feature\SavePackageCredentialsTest::it_can_save_the_given_credentials_to_the_cache";d:0.039;}}}
--------------------------------------------------------------------------------
/.styleci.yml:
--------------------------------------------------------------------------------
1 | preset: laravel
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: php
2 |
3 | php:
4 | - 7.1
5 | - 7.2
6 |
7 | before_install:
8 | - sudo apt-get update
9 | - travis_retry composer self-update
10 |
11 | install:
12 | - travis_retry composer update --prefer-source
13 |
14 | script:
15 | - phpunit
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # Change Log
2 |
3 | ## [v4.0.0](https://github.com/naoray/laravel-package-maker/tree/v4.0.0) (2020-10-29)
4 | [Full Changelog](https://github.com/naoray/laravel-package-maker/compare/v3.1.0...v4.0.0)
5 |
6 | **Added**
7 | - support for laravel 8 (https://github.com/Naoray/laravel-package-maker/commit/58c1decf8899017f5df061bfc7f471244b28b0a1)
8 |
9 | ## [v3.1.0](https://github.com/naoray/laravel-package-maker/tree/v3.1.0) (2020-07-14)
10 | [Full Changelog](https://github.com/naoray/laravel-package-maker/compare/v3.0.2...v3.1.0)
11 |
12 | **Changed**
13 | - default package phpunit configuration (https://github.com/Naoray/laravel-package-maker/commit/78e3f0d7679990f5d9c59fbe485fabe68ca3587d)
14 |
15 | ## [v3.0.2](https://github.com/naoray/laravel-package-maker/tree/v3.0.2) (2020-06-13)
16 | [Full Changelog](https://github.com/naoray/laravel-package-maker/compare/v3.0.1...v3.0.2)
17 |
18 | **Fixes**
19 | - fix orchestra dependency version (https://github.com/Naoray/laravel-package-maker/commit/1cd058a60c6401d7cbdc92102074e17b8ae3b890)
20 |
21 | ## [v3.0.1](https://github.com/naoray/laravel-package-maker/tree/v3.0.1) (2020-06-13)
22 | [Full Changelog](https://github.com/naoray/laravel-package-maker/compare/v3.0.0...v3.0.1)
23 |
24 | **Fixes**
25 | - generate new package with requirement of `laravel/support:^7.0` (https://github.com/Naoray/laravel-package-maker/commit/f53c0bec5a970f0a66726b4bee9bc7ba3254d177)
26 |
27 | ## [v3.0.1](https://github.com/naoray/laravel-package-maker/tree/v3.0.1) (2020-06-13)
28 | [Full Changelog](https://github.com/naoray/laravel-package-maker/compare/v3.0.0...v3.0.1)
29 |
30 | **Fixes**
31 | - generate new package with requirement of `laravel/support:^7.0` (https://github.com/Naoray/laravel-package-maker/commit/f53c0bec5a970f0a66726b4bee9bc7ba3254d177)
32 |
33 |
34 | ## [v3.0.0](https://github.com/naoray/laravel-package-maker/tree/v3.0.0) (2020-05-15)
35 | [Full Changelog](https://github.com/naoray/laravel-package-maker/compare/2.0.0...v3.0.0)
36 |
37 | **Added**
38 | - Support for Laravel 7
39 |
40 | ## [2.0.0](https://github.com/naoray/laravel-package-maker/tree/2.0.0) (2019-10-21)
41 | [Full Changelog](https://github.com/naoray/laravel-package-maker/compare/v1.4.4...2.0.0)
42 |
43 | **Implemented enhancements:**
44 |
45 | - Add support for Laravel 6.0 [\#54](https://github.com/Naoray/laravel-package-maker/issues/54)
46 | - Add Credits to generate readme command [\#52](https://github.com/Naoray/laravel-package-maker/issues/52)
47 |
48 | **Closed issues:**
49 |
50 | - Exhausted allowed memory on Model Creation [\#55](https://github.com/Naoray/laravel-package-maker/issues/55)
51 |
52 | **Merged pull requests:**
53 |
54 | - Apply fixes from StyleCI [\#62](https://github.com/Naoray/laravel-package-maker/pull/62) ([Naoray](https://github.com/Naoray))
55 | - Laravel 6 support [\#61](https://github.com/Naoray/laravel-package-maker/pull/61) ([immeyti](https://github.com/immeyti))
56 | - Fix: test breaking due to incorrect string appended to the test output [\#60](https://github.com/Naoray/laravel-package-maker/pull/60) ([byjujohn](https://github.com/byjujohn))
57 | - add credits [\#59](https://github.com/Naoray/laravel-package-maker/pull/59) ([Naoray](https://github.com/Naoray))
58 |
59 | ## [v1.4.4](https://github.com/naoray/laravel-package-maker/tree/v1.4.4) (2019-08-28)
60 | [Full Changelog](https://github.com/naoray/laravel-package-maker/compare/v1.4.3...v1.4.4)
61 |
62 | **Merged pull requests:**
63 |
64 | - Fix model creation with flags [\#57](https://github.com/Naoray/laravel-package-maker/pull/57) ([Naoray](https://github.com/Naoray))
65 | - Apply fixes from StyleCI [\#56](https://github.com/Naoray/laravel-package-maker/pull/56) ([Naoray](https://github.com/Naoray))
66 |
67 | ## [v1.4.3](https://github.com/naoray/laravel-package-maker/tree/v1.4.3) (2019-04-29)
68 | [Full Changelog](https://github.com/naoray/laravel-package-maker/compare/v1.4.2...v1.4.3)
69 |
70 | ## [v1.4.2](https://github.com/naoray/laravel-package-maker/tree/v1.4.2) (2019-04-29)
71 | [Full Changelog](https://github.com/naoray/laravel-package-maker/compare/v1.4.1...v1.4.2)
72 |
73 | ## [v1.4.1](https://github.com/naoray/laravel-package-maker/tree/v1.4.1) (2019-04-29)
74 | [Full Changelog](https://github.com/naoray/laravel-package-maker/compare/v1.4.0...v1.4.1)
75 |
76 | ## [v1.4.0](https://github.com/naoray/laravel-package-maker/tree/v1.4.0) (2019-04-29)
77 | [Full Changelog](https://github.com/naoray/laravel-package-maker/compare/v1.3.4...v1.4.0)
78 |
79 | **Implemented enhancements:**
80 |
81 | - Update for Laravel 5.8 usage [\#53](https://github.com/Naoray/laravel-package-maker/issues/53)
82 |
83 | ## [v1.3.4](https://github.com/naoray/laravel-package-maker/tree/v1.3.4) (2019-01-04)
84 | [Full Changelog](https://github.com/naoray/laravel-package-maker/compare/v1.3.3...v1.3.4)
85 |
86 | **Merged pull requests:**
87 |
88 | - bump License [\#51](https://github.com/Naoray/laravel-package-maker/pull/51) ([Naoray](https://github.com/Naoray))
89 |
90 | ## [v1.3.3](https://github.com/naoray/laravel-package-maker/tree/v1.3.3) (2018-10-17)
91 | [Full Changelog](https://github.com/naoray/laravel-package-maker/compare/v1.2.9...v1.3.3)
92 |
93 | **Merged pull requests:**
94 |
95 | - Fix Base Controller Use [\#50](https://github.com/Naoray/laravel-package-maker/pull/50) ([Naoray](https://github.com/Naoray))
96 |
97 | ## [v1.2.9](https://github.com/naoray/laravel-package-maker/tree/v1.2.9) (2018-10-17)
98 | [Full Changelog](https://github.com/naoray/laravel-package-maker/compare/v1.3.2...v1.2.9)
99 |
100 | **Merged pull requests:**
101 |
102 | - Apply fixes from StyleCI [\#49](https://github.com/Naoray/laravel-package-maker/pull/49) ([Naoray](https://github.com/Naoray))
103 | - Apply fixes from StyleCI [\#48](https://github.com/Naoray/laravel-package-maker/pull/48) ([Naoray](https://github.com/Naoray))
104 |
105 | ## [v1.3.2](https://github.com/naoray/laravel-package-maker/tree/v1.3.2) (2018-10-17)
106 | [Full Changelog](https://github.com/naoray/laravel-package-maker/compare/v1.2.8...v1.3.2)
107 |
108 | **Merged pull requests:**
109 |
110 | - Version 1.3.2 [\#47](https://github.com/Naoray/laravel-package-maker/pull/47) ([Naoray](https://github.com/Naoray))
111 |
112 | ## [v1.2.8](https://github.com/naoray/laravel-package-maker/tree/v1.2.8) (2018-10-17)
113 | [Full Changelog](https://github.com/naoray/laravel-package-maker/compare/v1.3.1...v1.2.8)
114 |
115 | **Merged pull requests:**
116 |
117 | - Apply fixes from StyleCI [\#46](https://github.com/Naoray/laravel-package-maker/pull/46) ([Naoray](https://github.com/Naoray))
118 | - Apply fixes from StyleCI [\#45](https://github.com/Naoray/laravel-package-maker/pull/45) ([Naoray](https://github.com/Naoray))
119 |
120 | ## [v1.3.1](https://github.com/naoray/laravel-package-maker/tree/v1.3.1) (2018-10-17)
121 | [Full Changelog](https://github.com/naoray/laravel-package-maker/compare/v1.2.7...v1.3.1)
122 |
123 | **Merged pull requests:**
124 |
125 | - Version 1.3.1 [\#44](https://github.com/Naoray/laravel-package-maker/pull/44) ([Naoray](https://github.com/Naoray))
126 | - Apply fixes from StyleCI [\#43](https://github.com/Naoray/laravel-package-maker/pull/43) ([Naoray](https://github.com/Naoray))
127 |
128 | ## [v1.2.7](https://github.com/naoray/laravel-package-maker/tree/v1.2.7) (2018-10-17)
129 | [Full Changelog](https://github.com/naoray/laravel-package-maker/compare/v1.3...v1.2.7)
130 |
131 | **Merged pull requests:**
132 |
133 | - Apply fixes from StyleCI [\#42](https://github.com/Naoray/laravel-package-maker/pull/42) ([Naoray](https://github.com/Naoray))
134 | - Add first Tests [\#41](https://github.com/Naoray/laravel-package-maker/pull/41) ([Naoray](https://github.com/Naoray))
135 |
136 | ## [v1.3](https://github.com/naoray/laravel-package-maker/tree/v1.3) (2018-10-12)
137 | [Full Changelog](https://github.com/naoray/laravel-package-maker/compare/v1.2.6...v1.3)
138 |
139 | **Closed issues:**
140 |
141 | - Work with laravel new project [\#38](https://github.com/Naoray/laravel-package-maker/issues/38)
142 |
143 | **Merged pull requests:**
144 |
145 | - Feature/upgrade for laravel 5.7 usage [\#40](https://github.com/Naoray/laravel-package-maker/pull/40) ([Naoray](https://github.com/Naoray))
146 | - Apply fixes from StyleCI [\#37](https://github.com/Naoray/laravel-package-maker/pull/37) ([Naoray](https://github.com/Naoray))
147 | - Version 1.2.7 [\#36](https://github.com/Naoray/laravel-package-maker/pull/36) ([Naoray](https://github.com/Naoray))
148 |
149 | ## [v1.2.6](https://github.com/naoray/laravel-package-maker/tree/v1.2.6) (2018-08-28)
150 | [Full Changelog](https://github.com/naoray/laravel-package-maker/compare/v1.2.5...v1.2.6)
151 |
152 | **Merged pull requests:**
153 |
154 | - Version 1.2.6 [\#35](https://github.com/Naoray/laravel-package-maker/pull/35) ([Naoray](https://github.com/Naoray))
155 | - Apply fixes from StyleCI [\#34](https://github.com/Naoray/laravel-package-maker/pull/34) ([Naoray](https://github.com/Naoray))
156 | - Apply fixes from StyleCI [\#33](https://github.com/Naoray/laravel-package-maker/pull/33) ([Naoray](https://github.com/Naoray))
157 |
158 | ## [v1.2.5](https://github.com/naoray/laravel-package-maker/tree/v1.2.5) (2018-08-25)
159 | [Full Changelog](https://github.com/naoray/laravel-package-maker/compare/v1.2.4...v1.2.5)
160 |
161 | **Closed issues:**
162 |
163 | - Add Trait Support [\#30](https://github.com/Naoray/laravel-package-maker/issues/30)
164 |
165 | **Merged pull requests:**
166 |
167 | - Version 1.2.5 [\#32](https://github.com/Naoray/laravel-package-maker/pull/32) ([Naoray](https://github.com/Naoray))
168 | - Apply fixes from StyleCI [\#31](https://github.com/Naoray/laravel-package-maker/pull/31) ([Naoray](https://github.com/Naoray))
169 |
170 | ## [v1.2.4](https://github.com/naoray/laravel-package-maker/tree/v1.2.4) (2018-08-23)
171 | [Full Changelog](https://github.com/naoray/laravel-package-maker/compare/v1.2.3...v1.2.4)
172 |
173 | **Merged pull requests:**
174 |
175 | - final fix [\#29](https://github.com/Naoray/laravel-package-maker/pull/29) ([Naoray](https://github.com/Naoray))
176 |
177 | ## [v1.2.3](https://github.com/naoray/laravel-package-maker/tree/v1.2.3) (2018-08-23)
178 | [Full Changelog](https://github.com/naoray/laravel-package-maker/compare/v1.2.2...v1.2.3)
179 |
180 | **Merged pull requests:**
181 |
182 | - Dev [\#28](https://github.com/Naoray/laravel-package-maker/pull/28) ([Naoray](https://github.com/Naoray))
183 |
184 | ## [v1.2.2](https://github.com/naoray/laravel-package-maker/tree/v1.2.2) (2018-08-23)
185 | [Full Changelog](https://github.com/naoray/laravel-package-maker/compare/v1.2.1...v1.2.2)
186 |
187 | **Merged pull requests:**
188 |
189 | - Version 1.2.2 [\#27](https://github.com/Naoray/laravel-package-maker/pull/27) ([Naoray](https://github.com/Naoray))
190 | - Apply fixes from StyleCI [\#26](https://github.com/Naoray/laravel-package-maker/pull/26) ([Naoray](https://github.com/Naoray))
191 | - Apply fixes from StyleCI [\#25](https://github.com/Naoray/laravel-package-maker/pull/25) ([Naoray](https://github.com/Naoray))
192 |
193 | ## [v1.2.1](https://github.com/naoray/laravel-package-maker/tree/v1.2.1) (2018-08-21)
194 | [Full Changelog](https://github.com/naoray/laravel-package-maker/compare/v1.2...v1.2.1)
195 |
196 | **Merged pull requests:**
197 |
198 | - Dev [\#24](https://github.com/Naoray/laravel-package-maker/pull/24) ([Naoray](https://github.com/Naoray))
199 | - Formatting, mostly. [\#23](https://github.com/Naoray/laravel-package-maker/pull/23) ([rennokki](https://github.com/rennokki))
200 |
201 | ## [v1.2](https://github.com/naoray/laravel-package-maker/tree/v1.2) (2018-08-20)
202 | [Full Changelog](https://github.com/naoray/laravel-package-maker/compare/v.1.2...v1.2)
203 |
204 | ## [v.1.2](https://github.com/naoray/laravel-package-maker/tree/v.1.2) (2018-08-20)
205 | [Full Changelog](https://github.com/naoray/laravel-package-maker/compare/v1.1.4...v.1.2)
206 |
207 | **Merged pull requests:**
208 |
209 | - Apply fixes from StyleCI [\#22](https://github.com/Naoray/laravel-package-maker/pull/22) ([Naoray](https://github.com/Naoray))
210 |
211 | ## [v1.1.4](https://github.com/naoray/laravel-package-maker/tree/v1.1.4) (2018-08-19)
212 | [Full Changelog](https://github.com/naoray/laravel-package-maker/compare/v1.1.3...v1.1.4)
213 |
214 | ## [v1.1.3](https://github.com/naoray/laravel-package-maker/tree/v1.1.3) (2018-08-17)
215 | [Full Changelog](https://github.com/naoray/laravel-package-maker/compare/v1.1.2...v1.1.3)
216 |
217 | **Merged pull requests:**
218 |
219 | - Apply fixes from StyleCI [\#21](https://github.com/Naoray/laravel-package-maker/pull/21) ([Naoray](https://github.com/Naoray))
220 |
221 | ## [v1.1.2](https://github.com/naoray/laravel-package-maker/tree/v1.1.2) (2018-08-17)
222 | [Full Changelog](https://github.com/naoray/laravel-package-maker/compare/v.1.1.1...v1.1.2)
223 |
224 | **Merged pull requests:**
225 |
226 | - Apply fixes from StyleCI [\#20](https://github.com/Naoray/laravel-package-maker/pull/20) ([Naoray](https://github.com/Naoray))
227 | - Apply fixes from StyleCI [\#19](https://github.com/Naoray/laravel-package-maker/pull/19) ([Naoray](https://github.com/Naoray))
228 | - Apply fixes from StyleCI [\#18](https://github.com/Naoray/laravel-package-maker/pull/18) ([Naoray](https://github.com/Naoray))
229 | - Apply fixes from StyleCI [\#17](https://github.com/Naoray/laravel-package-maker/pull/17) ([Naoray](https://github.com/Naoray))
230 | - Apply fixes from StyleCI [\#16](https://github.com/Naoray/laravel-package-maker/pull/16) ([Naoray](https://github.com/Naoray))
231 |
232 | ## [v.1.1.1](https://github.com/naoray/laravel-package-maker/tree/v.1.1.1) (2018-08-16)
233 | [Full Changelog](https://github.com/naoray/laravel-package-maker/compare/v1.1...v.1.1.1)
234 |
235 | **Merged pull requests:**
236 |
237 | - Apply fixes from StyleCI [\#15](https://github.com/Naoray/laravel-package-maker/pull/15) ([Naoray](https://github.com/Naoray))
238 | - Apply fixes from StyleCI [\#14](https://github.com/Naoray/laravel-package-maker/pull/14) ([Naoray](https://github.com/Naoray))
239 | - Choices for CI/CD, Code Quality and Code Coverage. [\#13](https://github.com/Naoray/laravel-package-maker/pull/13) ([rennokki](https://github.com/rennokki))
240 |
241 | ## [v1.1](https://github.com/naoray/laravel-package-maker/tree/v1.1) (2018-08-15)
242 | [Full Changelog](https://github.com/naoray/laravel-package-maker/compare/v1.0...v1.1)
243 |
244 | **Merged pull requests:**
245 |
246 | - 1.1 [\#12](https://github.com/Naoray/laravel-package-maker/pull/12) ([Naoray](https://github.com/Naoray))
247 | - Apply fixes from StyleCI [\#11](https://github.com/Naoray/laravel-package-maker/pull/11) ([Naoray](https://github.com/Naoray))
248 | - Codecov & Formatting fixes [\#10](https://github.com/Naoray/laravel-package-maker/pull/10) ([rennokki](https://github.com/rennokki))
249 | - Apply fixes from StyleCI [\#9](https://github.com/Naoray/laravel-package-maker/pull/9) ([Naoray](https://github.com/Naoray))
250 | - Apply fixes from StyleCI [\#7](https://github.com/Naoray/laravel-package-maker/pull/7) ([Naoray](https://github.com/Naoray))
251 | - Apply fixes from StyleCI [\#6](https://github.com/Naoray/laravel-package-maker/pull/6) ([Naoray](https://github.com/Naoray))
252 | - Apply fixes from StyleCI [\#5](https://github.com/Naoray/laravel-package-maker/pull/5) ([Naoray](https://github.com/Naoray))
253 | - Fixes, support for TravisCI @php7.2 & Codecov [\#4](https://github.com/Naoray/laravel-package-maker/pull/4) ([rennokki](https://github.com/rennokki))
254 |
255 | ## [v1.0](https://github.com/naoray/laravel-package-maker/tree/v1.0) (2018-08-09)
256 | **Closed issues:**
257 |
258 | - Readme Assets [\#1](https://github.com/Naoray/laravel-package-maker/issues/1)
259 |
260 | **Merged pull requests:**
261 |
262 | - Apply fixes from StyleCI [\#3](https://github.com/Naoray/laravel-package-maker/pull/3) ([Naoray](https://github.com/Naoray))
263 | - Add Usage Description [\#2](https://github.com/Naoray/laravel-package-maker/pull/2) ([Naoray](https://github.com/Naoray))
264 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contributing
2 |
3 | Contributions are **welcome** and will be fully **credited**.
4 |
5 | We accept contributions via Pull Requests on [Github](https://github.com/naoray/laravel-package-maker).
6 |
7 |
8 | ## Pull Requests
9 |
10 | - **[PSR-2 Coding Standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)** - The easiest way to apply the conventions is to install [PHP Code Sniffer](http://pear.php.net/package/PHP_CodeSniffer).
11 |
12 | - **Add tests!** - Your patch won't be accepted if it doesn't have tests.
13 |
14 | - **Document any change in behaviour** - Make sure the `README.md` and any other relevant documentation are kept up-to-date.
15 |
16 | - **Consider our release cycle** - We try to follow [SemVer v2.0.0](http://semver.org/). Randomly breaking public APIs is not an option.
17 |
18 | - **Create feature branches** - Don't ask us to pull from your master branch.
19 |
20 | - **One pull request per feature** - If you want to do more than one thing, send multiple pull requests.
21 |
22 | - **Send coherent history** - Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please [squash them](http://www.git-scm.com/book/en/v2/Git-Tools-Rewriting-History#Changing-Multiple-Commit-Messages) before submitting.
23 |
24 |
25 | ## Running Tests
26 |
27 | ``` bash
28 | $ composer test
29 | ```
30 |
31 |
32 | **Happy coding**!
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2019 Krishan Koenig
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
--------------------------------------------------------------------------------
/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "naoray/laravel-package-maker",
3 | "description": "Get a package skeleton and all other `make` commands from laravel base for package development.",
4 | "type": "package",
5 | "license": "MIT",
6 | "keywords": [
7 | "laravel"
8 | ],
9 | "authors": [
10 | {
11 | "name": "Krishan Koenig",
12 | "email": "krishan.koenig@googlemail.com"
13 | }
14 | ],
15 | "require": {
16 | "illuminate/support": "^7.0|^8.0",
17 | "illuminate/console": "^7.0|^8.0",
18 | "illuminate/filesystem": "^7.0|^8.0"
19 | },
20 | "autoload": {
21 | "psr-4": {
22 | "Naoray\\LaravelPackageMaker\\": "./src"
23 | }
24 | },
25 | "minimum-stability": "dev",
26 | "autoload-dev": {
27 | "psr-4": {
28 | "Naoray\\LaravelPackageMaker\\Tests\\": "tests"
29 | }
30 | },
31 | "scripts": {
32 | "test": "vendor/bin/phpunit"
33 | },
34 | "extra": {
35 | "laravel": {
36 | "providers": [
37 | "Naoray\\LaravelPackageMaker\\LaravelPackageMakerServiceProvider"
38 | ]
39 | }
40 | },
41 | "require-dev": {
42 | "orchestra/testbench": "^5.0|^6.0",
43 | "mockery/mockery": "^1.4"
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/phpunit.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
13 |
14 | tests
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 | src/
24 |
25 |
26 |
--------------------------------------------------------------------------------
/readme.md:
--------------------------------------------------------------------------------
1 | # laravel-package-maker
2 |
3 | [](LICENSE.md)
4 | [](https://packagist.org/packages/naoray/laravel-package-maker)
5 |
6 | All the `make` commands you use in your daily Laravel app development workflow but for packages! This package was created solely for the purpose to make package development as fast and easy as possible. Creating a new package only takes one command (`make:package`) and you will end up with the following file structure:
7 |
8 | ```bash
9 | .
10 | └── package
11 | ├── .codecov.yml
12 | ├── composer.json
13 | ├── CONTRIBUTING.md
14 | ├── .gitignore
15 | ├── LICENSE.md
16 | ├── phpunit.xml
17 | ├── readme.md
18 | ├── src
19 | │ └── PackageServiceProvider.php
20 | ├── .styleci.yml
21 | ├── tests
22 | │ └── TestCase.php
23 | └── .travis.yml
24 | ```
25 |
26 | ## Install
27 | `composer require naoray/laravel-package-maker --dev`
28 |
29 | ## Usage
30 | - [laravel-package-maker](#laravel-package-maker)
31 | - [Install](#install)
32 | - [Usage](#usage)
33 | - [Create a package](#create-a-package)
34 | - [Create a nova tool](#create-a-nova-tool)
35 | - [Add a package](#add-a-package)
36 | - [Save package credentials](#save-package-credentials)
37 | - [Delete package credentials](#delete-package-credentials)
38 | - [Clone a package](#clone-a-package)
39 | - [Replace Content](#replace-content)
40 | - [Make Commands](#make-commands)
41 | - [Foundation](#foundation)
42 | - [Database](#database)
43 | - [Routing](#routing)
44 | - [Standard Php](#standard-php)
45 | - [Commands used for creating initial package stubs](#commands-used-for-creating-initial-package-stubs)
46 | - [Example Usage](#example-usage)
47 | - [Testing](#testing)
48 | - [Changelog](#changelog)
49 | - [Contributing](#contributing)
50 | - [Credits](#credits)
51 | - [Security](#security)
52 | - [License](#license)
53 |
54 |
55 |
56 | ### Create a package
57 | ```
58 | php artisan make:package
59 | ```
60 |
61 | 
62 |
63 |
64 |
65 | ### Create a nova tool
66 | ```
67 | php artisan make:nova
68 | ```
69 |
70 | Inspired by [Spatie's nova-skeleton-tool](https://github.com/spatie/skeleton-nova-tool) this command clones the repository, replaces all strings with your own and adds it to your own project.
71 |
72 | 
73 |
74 |
75 |
76 | ### Add a package
77 | ```
78 | php artisan package:add
79 | ```
80 | If you have already created a package or you want to add a modified version of a package which is currently only available locally, you can use the following command to add you package to your project. It does simply add your package to your project`s composer repositories and requires a local version of it.
81 |
82 | **This command is run by `make:package` automatically, so you have no need to execute it after creating a package!**
83 |
84 |
85 |
86 | ### Save package credentials
87 | ```
88 | php artisan package:save
89 | {namespace : Root namespace of the package (Vendor\Package_name)}
90 | {path : Relative path to the package's directory}
91 | ```
92 | Every `package:*` command needs to know the package's *namespace* and the relative *path* to the location your package is stored. Because of that every `package:*` command comes with those two options by default. To avoid entering those two options every time a `package:*` command executed this command saves the credentials of your package in the cache.
93 |
94 |
95 |
96 | ### Delete package credentials
97 | ```
98 | php artisan package:delete
99 | ```
100 | This one wipes all stored credentials from your cache.
101 |
102 |
103 |
104 | ### Clone a package
105 | ```
106 | php artisan package:clone
107 | {src : Source path of the package to clone}
108 | {target : Path where it should be cloned in}
109 | ```
110 | The clone command clones a given repository or directory into the given target.
111 |
112 |
113 |
114 | ### Replace Content
115 | ```
116 | php artisan package:replace
117 | {path : The path to a file or directory}
118 | {--O|old=* : Old strings which will be replaced}
119 | {--N|new=* : New strings which will be used as replacement}'
120 | ```
121 | The replace command takes a path of a file or a directory and an indefinite number of 'old' options which will be replaced by the 'new' options.
122 |
123 |
124 |
125 |
126 | ### Make Commands
127 | All of these commands do have all arguments & options to which you are used to in a normal laravel app! To execute any of these commands simply add the prefix `package:`.
128 |
129 |
130 |
131 | #### Foundation
132 | - `channel`
133 | - `console`
134 | - `event`
135 | - `exception`
136 | - `job`
137 | - `listener`
138 | - `mail`
139 | - `model`
140 | - `notification`
141 | - `observer`
142 | - `policy`
143 | - `provider`
144 | - `request`
145 | - `resource`
146 | - `rule`
147 | - `test`
148 |
149 |
150 |
151 | #### Database
152 | - `factory`
153 | - `migration`
154 | - `seeder`
155 |
156 |
157 |
158 | #### Routing
159 | - `controller`
160 | - `middleware`
161 |
162 |
163 |
164 | #### Standard Php
165 | All of the following routes only accept a `name` argument.
166 |
167 | - `contract`
168 | - `interface` (same as `contract`)
169 | - `trait`
170 |
171 |
172 |
173 | ### Commands used for creating initial package stubs
174 | - `package:basetest {provider : The package's provider name}` - creates `TestCase` in `tests` folder
175 | - `package:codecov` - creates a `.codecov.yml` file
176 | - `package:composer {--author : The author of the package.} {--email : The author's email.}` - creates `composer.json`
177 | - `package:contribution` - creates `CONTRIBUTING.md`
178 | - `package:gitignore` - creates `.gitignore` file
179 | - `package:license {--copyright : The company or vendor name to place it int the license file}` - creates `LICENSE.md` file
180 | - `package:phpunit` - creates `phpunit.xml`
181 | - `package:readme {--author : The author of the package.} {--email : The author's email.}` - creates `readme.md`
182 | - `package:styleci` - creates `.styleci.yml`
183 | - `package:travis` - creates `.travis.yml`
184 |
185 |
186 |
187 | ### Example Usage
188 | *Use a few `make` commands*
189 | 
190 |
191 | *All arguments & options you know from the standard `make` commands are available. Create a model with all option.*
192 | 
193 |
194 | ## Testing
195 | Run the tests with:
196 |
197 | ``` bash
198 | vendor/bin/phpunit
199 | ```
200 |
201 | ## Changelog
202 | Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.
203 |
204 | ## Contributing
205 | Please see [CONTRIBUTING](CONTRIBUTING.md) for details.
206 |
207 | ## Credits
208 | - [Krishan König](https://github.com/naoray)
209 | - [All Contributors](https://github.com/naoray/laravel-package-maker/contributors)
210 |
211 | ## Security
212 | If you discover any security-related issues, please email krishan.koenig@googlemail.com instead of using the issue tracker.
213 |
214 | ## License
215 | The MIT License (MIT). Please see [License File](/LICENSE.md) for more information.
216 |
--------------------------------------------------------------------------------
/src/Commands/AddPackage.php:
--------------------------------------------------------------------------------
1 | checkForInputs();
71 |
72 | $this->addPackageRepositoryToRootComposer();
73 | $this->addPackageToRootComposer();
74 | $this->updateComposer();
75 |
76 | $this->call('package:save', [
77 | 'namespace' => ucfirst($this->vendor).'\\'.ucfirst(Str::camel($this->packageName)),
78 | 'path' => $this->path,
79 | ]);
80 | }
81 |
82 | /**
83 | * Update composer dependencies.
84 | */
85 | public function updateComposer()
86 | {
87 | $this->runConsoleCommand('composer update', getcwd());
88 | }
89 |
90 | /**
91 | * Add a path repository for the tool to the application's composer.json file.
92 | */
93 | protected function addPackageRepositoryToRootComposer()
94 | {
95 | $composer = json_decode(file_get_contents(base_path('composer.json')), true);
96 |
97 | $composer['repositories'][$this->packageName] = [
98 | 'type' => 'path',
99 | 'url' => $this->path,
100 | ];
101 |
102 | file_put_contents(
103 | base_path('composer.json'),
104 | json_encode($composer, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)
105 | );
106 | }
107 |
108 | /**
109 | * Add a package entry for the tool to the application's composer.json file.
110 | */
111 | protected function addPackageToRootComposer()
112 | {
113 | $composer = json_decode(file_get_contents(base_path('composer.json')), true);
114 |
115 | $composer['require'][$this->vendor.'/'.$this->packageName] = '*';
116 |
117 | file_put_contents(
118 | base_path('composer.json'),
119 | json_encode($composer, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)
120 | );
121 | }
122 |
123 | /**
124 | * Checks for needed input and prints it out.
125 | */
126 | public function checkForInputs()
127 | {
128 | $name = $this->getNameInput();
129 |
130 | if ($name && Str::contains($name, '/')) {
131 | $this->vendor = Str::before($name, '/');
132 | $this->name = Str::after($name, '/');
133 | }
134 |
135 | $vendor = $this->getVendorInput();
136 | $path = $this->getPathInput();
137 | $branch = $this->getBranchInput();
138 |
139 | $this->table(['vendor', 'name', 'path', 'branch'], [[$vendor, $name, $path, $branch]]);
140 | if (! $this->option('no-interaction') && ! $this->confirm('Do you wish to continue?')) {
141 | return;
142 | }
143 | }
144 |
145 | /**
146 | * Get the package name from the input.
147 | *
148 | * @return string
149 | */
150 | public function getNameInput()
151 | {
152 | if ($this->packageName) {
153 | return $this->packageName;
154 | }
155 |
156 | if (! $this->packageName = trim($this->argument('name'))) {
157 | $this->packageName = $this->ask('What is your package\'s name?');
158 | }
159 |
160 | return $this->packageName;
161 | }
162 |
163 | /**
164 | * Get the vendor name from the input.
165 | *
166 | * @return string
167 | */
168 | public function getVendorInput()
169 | {
170 | if ($this->vendor) {
171 | return $this->vendor;
172 | }
173 |
174 | if (! $this->vendor = trim($this->argument('vendor'))) {
175 | $this->vendor = $this->ask('What is your package\'s vendor name?');
176 | }
177 |
178 | return $this->vendor;
179 | }
180 |
181 | /**
182 | * Get the path name from the input.
183 | *
184 | * @return string
185 | */
186 | public function getPathInput()
187 | {
188 | if ($this->path) {
189 | return $this->path;
190 | }
191 |
192 | if (! $this->path = trim($this->argument('path'))) {
193 | $this->path = $this->anticipate('What is your package\'s path?', [
194 | '../packages/'.$this->packageName, 'packages/'.$this->packageName,
195 | ]);
196 | }
197 |
198 | return $this->path;
199 | }
200 |
201 | /**
202 | * Get the branch name from the input.
203 | *
204 | * @return string
205 | */
206 | public function getBranchInput()
207 | {
208 | if ($this->branch) {
209 | return $this->branch;
210 | }
211 |
212 | if (! $this->branch = trim($this->argument('branch'))) {
213 | $this->branch = '*';
214 | }
215 |
216 | return $this->branch;
217 | }
218 | }
219 |
--------------------------------------------------------------------------------
/src/Commands/ClonePackage.php:
--------------------------------------------------------------------------------
1 | files = $files;
45 | }
46 |
47 | /**
48 | * Execute the console command.
49 | *
50 | * @return mixed
51 | */
52 | public function handle()
53 | {
54 | if ($this->files->isDirectory($target = $this->getTargetInput())) {
55 | $this->error($target.' directory already exists!');
56 | }
57 |
58 | if ($this->srcIsRemote()) {
59 | return $this->gitClone();
60 | }
61 |
62 | $this->localClone();
63 | }
64 |
65 | /**
66 | * Clone local package.
67 | */
68 | public function localClone()
69 | {
70 | $successfull = $this->files->copyDirectory($this->getSrcInput(), $this->getTargetInput());
71 |
72 | if (! $successfull) {
73 | $this->error('Copying was not successfull!');
74 | }
75 |
76 | if ($this->files->isDirectory($vendor = $this->getTargetInput().'/vendor')) {
77 | $this->files->deleteDirectory($vendor);
78 |
79 | $this->info('Removed vendor folder.');
80 | }
81 |
82 | $this->info('Cloning was successful!');
83 | }
84 |
85 | /**
86 | * Clone package via git.
87 | */
88 | public function gitClone()
89 | {
90 | $this->runConsoleCommand('git clone '.$this->argument('src').' '.$this->argument('target'), getcwd());
91 |
92 | if ($this->files->isDirectory($git = $this->getTargetInput().'/.git')) {
93 | $this->files->deleteDirectory($git);
94 |
95 | $this->info('Removed .git folder.');
96 | }
97 | }
98 |
99 | /**
100 | * Checks if source is remote.
101 | *
102 | * @return bool
103 | */
104 | public function srcIsRemote()
105 | {
106 | return Str::contains($this->getSrcInput(), ['https', 'git@']);
107 | }
108 |
109 | /**
110 | * Get the src path.
111 | *
112 | * @return string
113 | */
114 | public function getSrcInput()
115 | {
116 | return trim($this->argument('src'));
117 | }
118 |
119 | /**
120 | * Get the target path.
121 | *
122 | * @return string
123 | */
124 | public function getTargetInput()
125 | {
126 | return trim($this->argument('target'));
127 | }
128 | }
129 |
--------------------------------------------------------------------------------
/src/Commands/Database/FactoryMakeCommand.php:
--------------------------------------------------------------------------------
1 | getDirInput().'/database/factories/';
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/Commands/Database/MigrationMakeCommand.php:
--------------------------------------------------------------------------------
1 | files = $files;
43 | }
44 |
45 | /**
46 | * Get migration path (either specified by '--path' option or default location).
47 | *
48 | * @return string
49 | */
50 | protected function getMigrationPath()
51 | {
52 | $path = $this->basePath().'database/migrations';
53 |
54 | if (! is_null($targetPath = $this->input->getOption('path'))) {
55 | $path = ! $this->usingRealPath()
56 | ? $this->basePath().$targetPath
57 | : $targetPath;
58 | }
59 |
60 | return $path;
61 | }
62 |
63 | /**
64 | * Build the directory for the class if necessary.
65 | *
66 | * @param string $path
67 | *
68 | * @return string
69 | */
70 | protected function makeDirectory($path)
71 | {
72 | if (! $this->files->isDirectory(dirname($path))) {
73 | $this->files->makeDirectory(dirname($path), 0777, true, true);
74 | }
75 |
76 | return $path;
77 | }
78 |
79 | /**
80 | * Adds additional options to the command.
81 | *
82 | * @return array
83 | */
84 | protected function additionalOptions()
85 | {
86 | return [
87 | ['create', null, InputOption::VALUE_REQUIRED, 'The table to be created'],
88 | ['table', null, InputOption::VALUE_REQUIRED, 'The table to migrate'],
89 | ['path', null, InputOption::VALUE_REQUIRED, 'The location where the migration file should be created'],
90 | ['realpath', null, InputOption::VALUE_NONE, 'Indicate any provided migration file paths are pre - resolved absolute paths'],
91 | ['fullpath', null, InputOption::VALUE_NONE, 'Output the full path of the migration'],
92 | ];
93 | }
94 | }
95 |
--------------------------------------------------------------------------------
/src/Commands/Database/SeederMakeCommand.php:
--------------------------------------------------------------------------------
1 | getDirInput().'/database/seeds/';
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/Commands/DeletePackageCredentials.php:
--------------------------------------------------------------------------------
1 | forget('package:namespace');
41 | cache()->forget('package:path');
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/src/Commands/Foundation/ChannelMakeCommand.php:
--------------------------------------------------------------------------------
1 | getDirInput().'src';
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/Commands/Foundation/ConsoleMakeCommand.php:
--------------------------------------------------------------------------------
1 | getDirInput().'src';
28 | }
29 |
30 | /**
31 | * Get the default namespace for the class.
32 | *
33 | * @param string $rootNamespace
34 | * @return string
35 | */
36 | protected function getDefaultNamespace($rootNamespace)
37 | {
38 | return $rootNamespace.'\Commands';
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/src/Commands/Foundation/EventMakeCommand.php:
--------------------------------------------------------------------------------
1 | getDirInput().'src';
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/Commands/Foundation/ExceptionMakeCommand.php:
--------------------------------------------------------------------------------
1 | getDirInput().'src';
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/Commands/Foundation/JobMakeCommand.php:
--------------------------------------------------------------------------------
1 | getDirInput().'src';
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/Commands/Foundation/ListenerMakeCommand.php:
--------------------------------------------------------------------------------
1 | getDirInput().'src';
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/Commands/Foundation/MailMakeCommand.php:
--------------------------------------------------------------------------------
1 | getDirInput().'src';
28 | }
29 |
30 | /**
31 | * Write the Markdown template for the mailable.
32 | *
33 | * @return void
34 | */
35 | protected function writeMarkdownTemplate()
36 | {
37 | $path = base_path($this->getDirInput().'/resources/views/'.str_replace('.', '/', $this->option('markdown'))).'.blade.php';
38 |
39 | $this->files->ensureDirectoryExists($path);
40 |
41 | $this->files->put($path, $this->getStubViewPath());
42 | }
43 |
44 | /**
45 | * Get Markdown stub view from parent dir.
46 | *
47 | * @return string
48 | */
49 | protected function getStubViewPath()
50 | {
51 | $parentFileName = (new \ReflectionClass('Illuminate\Foundation\Console\MailMakeCommand'))->getFileName();
52 |
53 | return file_get_contents(
54 | dirname($parentFileName).'/stubs/markdown.stub'
55 | );
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/src/Commands/Foundation/ModelMakeCommand.php:
--------------------------------------------------------------------------------
1 | getDirInput().'src';
29 | }
30 |
31 | /**
32 | * Create a model factory for the model.
33 | */
34 | protected function createFactory()
35 | {
36 | $factory = Str::studly(class_basename($this->argument('name')));
37 |
38 | $this->call('package:factory', [
39 | 'name' => "{$factory}Factory",
40 | '--model' => $this->argument('name'),
41 | '--namespace' => $this->getNamespaceInput(),
42 | '--dir' => $this->getDirInput(),
43 | ]);
44 | }
45 |
46 | /**
47 | * Create a migration file for the model.
48 | */
49 | protected function createMigration()
50 | {
51 | $table = Str::snake(Str::pluralStudly(class_basename($this->argument('name'))));
52 |
53 | if ($this->option('pivot')) {
54 | $table = Str::singular($table);
55 | }
56 |
57 | $this->call('package:migration', [
58 | 'name' => "create_{$table}_table",
59 | '--create' => $table,
60 | '--namespace' => $this->getNamespaceInput(),
61 | '--dir' => $this->getDirInput(),
62 | ]);
63 | }
64 |
65 | /**
66 | * Create a seeder file for the model.
67 | *
68 | * @return void
69 | */
70 | protected function createSeeder()
71 | {
72 | $seeder = Str::studly(class_basename($this->argument('name')));
73 |
74 | $this->call('package:seeder', [
75 | 'name' => "{$seeder}Seeder",
76 | '--namespace' => $this->getNamespaceInput(),
77 | '--dir' => $this->getDirInput(),
78 | ]);
79 | }
80 |
81 | /**
82 | * Create a controller for the model.
83 | */
84 | protected function createController()
85 | {
86 | $controller = Str::studly(class_basename($this->argument('name')));
87 |
88 | $modelName = $this->qualifyClass($this->getNameInput());
89 |
90 | $this->call('package:controller', [
91 | 'name' => "{$controller}Controller",
92 | '--model' => $this->option('resource') || $this->option('api') ? $modelName : null,
93 | '--api' => $this->option('api'),
94 | '--namespace' => $this->getNamespaceInput(),
95 | '--dir' => $this->getDirInput(),
96 | ]);
97 | }
98 | }
99 |
--------------------------------------------------------------------------------
/src/Commands/Foundation/NotificationMakeCommand.php:
--------------------------------------------------------------------------------
1 | getDirInput().'src';
28 | }
29 |
30 | /**
31 | * Write the Markdown template for the mailable.
32 | *
33 | * @return void
34 | */
35 | protected function writeMarkdownTemplate()
36 | {
37 | $path = base_path($this->getDirInput().'/resources/views/'.str_replace('.', '/', $this->option('markdown'))).'.blade.php';
38 |
39 | $this->files->ensureDirectoryExists($path);
40 |
41 | $this->files->put($path, $this->getStubViewPath());
42 | }
43 |
44 | /**
45 | * Get Markdown stub view from parent dir.
46 | *
47 | * @return string
48 | */
49 | protected function getStubViewPath()
50 | {
51 | $parentFileName = (new \ReflectionClass('Illuminate\Foundation\Console\NotificationMakeCommand'))->getFileName();
52 |
53 | return file_get_contents(
54 | dirname($parentFileName).'/stubs/markdown.stub'
55 | );
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/src/Commands/Foundation/ObserverMakeCommand.php:
--------------------------------------------------------------------------------
1 | getDirInput().'src';
29 | }
30 |
31 | /**
32 | * Replace the model for the given stub.
33 | *
34 | * @param string $stub
35 | * @param string $model
36 | *
37 | * @return string
38 | */
39 | protected function replaceModel($stub, $model)
40 | {
41 | $model = str_replace('/', '\\', $model);
42 |
43 | $namespaceModel = $this->rootNamespace().'\\'.$model;
44 |
45 | if (Str::startsWith($model, '\\')) {
46 | $stub = str_replace('NamespacedDummyModel', trim($model, '\\'), $stub);
47 | } else {
48 | $stub = str_replace('NamespacedDummyModel', $namespaceModel, $stub);
49 | }
50 |
51 | $stub = str_replace(
52 | "use {$namespaceModel};\nuse {$namespaceModel};",
53 | "use {$namespaceModel};",
54 | $stub
55 | );
56 |
57 | $model = class_basename(trim($model, '\\'));
58 |
59 | $stub = str_replace('DocDummyModel', Str::snake($model, ' '), $stub);
60 |
61 | $stub = str_replace('DummyModel', $model, $stub);
62 |
63 | return str_replace('dummyModel', Str::camel($model), $stub);
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/src/Commands/Foundation/PolicyMakeCommand.php:
--------------------------------------------------------------------------------
1 | getDirInput().'src';
29 | }
30 |
31 | /**
32 | * Replace the model for the given stub.
33 | *
34 | * @param string $stub
35 | * @param string $model
36 | *
37 | * @return string
38 | */
39 | protected function replaceModel($stub, $model)
40 | {
41 | $model = str_replace('/', '\\', $model);
42 |
43 | if (Str::startsWith($model, '\\')) {
44 | $namespacedModel = trim($model, '\\');
45 | } else {
46 | $namespacedModel = $namespacedModel = $this->rootNamespace().'\\'.$model;
47 | }
48 |
49 | $model = class_basename(trim($model, '\\'));
50 |
51 | $dummyUser = class_basename(config('auth.providers.users.model'));
52 |
53 | $dummyModel = 'user' === Str::camel($model) ? 'model' : $model;
54 |
55 | $replace = [
56 | 'NamespacedDummyModel' => $namespacedModel,
57 | '{{ namespacedModel }}' => $namespacedModel,
58 | '{{namespacedModel}}' => $namespacedModel,
59 | 'DummyModel' => $model,
60 | '{{ model }}' => $model,
61 | '{{model}}' => $model,
62 | 'dummyModel' => Str::camel($dummyModel),
63 | '{{ modelVariable }}' => Str::camel($dummyModel),
64 | '{{modelVariable}}' => Str::camel($dummyModel),
65 | 'DummyUser' => $dummyUser,
66 | '{{ user }}' => $dummyUser,
67 | '{{user}}' => $dummyUser,
68 | ];
69 |
70 | $stub = str_replace(
71 | array_keys($replace), array_values($replace), $stub
72 | );
73 |
74 | return str_replace(
75 | "use {$namespacedModel};\nuse {$namespacedModel};",
76 | "use {$namespacedModel};",
77 | $stub
78 | );
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/src/Commands/Foundation/ProviderMakeCommand.php:
--------------------------------------------------------------------------------
1 | getDirInput().'src';
28 | }
29 |
30 | /**
31 | * Get the default namespace for the class.
32 | *
33 | * @param string $rootNamespace
34 | *
35 | * @return string
36 | */
37 | protected function getDefaultNamespace($rootNamespace)
38 | {
39 | return $rootNamespace;
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/src/Commands/Foundation/RequestMakeCommand.php:
--------------------------------------------------------------------------------
1 | getDirInput().'src';
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/Commands/Foundation/ResourceMakeCommand.php:
--------------------------------------------------------------------------------
1 | getDirInput().'src';
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/Commands/Foundation/RuleMakeCommand.php:
--------------------------------------------------------------------------------
1 | getDirInput().'src';
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/Commands/Foundation/TestMakeCommand.php:
--------------------------------------------------------------------------------
1 | option('unit')
36 | ? $this->resolveStubPath('/stubs/test.unit.stub')
37 | : $this->resolveStubPath('/stubs/test.stub');
38 | }
39 |
40 | /**
41 | * Resolve the fully-qualified path to the stub.
42 | *
43 | * @param string $stub
44 | * @return string
45 | */
46 | protected function resolveStubPath($stub)
47 | {
48 | return file_exists($customPath = base_path(trim($stub, '/')))
49 | ? $customPath
50 | : __DIR__.$stub;
51 | }
52 |
53 | /**
54 | * Get the root namespace for the class.
55 | *
56 | * @return string
57 | */
58 | protected function rootNamespace()
59 | {
60 | return $this->getNamespaceInput().'\Tests';
61 | }
62 |
63 | /**
64 | * Get the destination class path.
65 | *
66 | * @return string
67 | */
68 | protected function resolveDirectory()
69 | {
70 | return $this->getDirInput().'/tests';
71 | }
72 |
73 | /**
74 | * Adds additional options to the command.
75 | *
76 | * @return array
77 | */
78 | protected function additionalOptions()
79 | {
80 | return [
81 | ['unit', 'u', InputOption::VALUE_NONE, 'Create a unit test'],
82 | ];
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/src/Commands/Foundation/stubs/test.stub:
--------------------------------------------------------------------------------
1 | assertTrue(true);
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/Commands/Foundation/stubs/unit-test.stub:
--------------------------------------------------------------------------------
1 | get('/');
19 |
20 | $response->assertStatus(200);
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/src/Commands/GeneratorCommand.php:
--------------------------------------------------------------------------------
1 | ask('Name of the author? (e.g. Freek Van der Herten)');
38 | $authorUsername = $this->ask('Author\'s username! (e.g. freekmurze)');
39 | $authorEmail = $this->ask('Your email! (e.g. freek@spatie.be)');
40 | $name = $this->ask('Name your package! (e.g. nova-tail-tool)');
41 | $description = $this->ask('Package Description! (e.g. A tool to tail the log)');
42 | $vendor = $this->ask('Vendor Name! (e.g. spatie)');
43 | $vendorNamespace = $this->ask('Namespace Vendor Name! (e.g. Spatie)');
44 | $toolNamespace = $this->ask('Namespace Tool Name! (e.g. TailTool)');
45 |
46 | $target = $this->anticipate('Where to install your package?', ['../packages/'.$name, 'packages/'.$name]);
47 |
48 | $this->clone($target);
49 | $this->replaceOld(
50 | $target,
51 | $author,
52 | $authorUsername,
53 | $authorEmail,
54 | $name,
55 | $description,
56 | $vendor,
57 | $vendorNamespace,
58 | $toolNamespace
59 | );
60 |
61 | if ($this->confirm('Would you like to load your package via composer?')) {
62 | $this->callSilent('package:add', [
63 | 'name' => $name,
64 | 'path' => $target,
65 | 'vendor' => $vendor,
66 | 'branch' => 'master',
67 | '--without-interaction' => true,
68 | ]);
69 | }
70 | }
71 |
72 | /**
73 | * Clone skeleton-nova-tool.
74 | *
75 | * @param string $target
76 | * @return void
77 | */
78 | public function clone($target)
79 | {
80 | $this->call('package:clone', [
81 | 'src' => $this->skeletonSrc,
82 | 'target' => $target,
83 | ]);
84 | }
85 |
86 | /**
87 | * Replace old inputs with new ones.
88 | *
89 | * @param string $target
90 | * @param array ...$new
91 | * @return void
92 | */
93 | public function replaceOld($target, ...$new)
94 | {
95 | $this->callSilent('package:replace', [
96 | 'path' => $target,
97 | '--old' => [
98 | ':author_name',
99 | ':author_username',
100 | ':author_email',
101 | ':package_name',
102 | ':package_description',
103 | ':vendor',
104 | ':namespace_vendor',
105 | ':namespace_tool_name',
106 | ],
107 | '--new' => $new,
108 | ]);
109 | }
110 | }
111 |
--------------------------------------------------------------------------------
/src/Commands/Package/BaseTestMakeCommand.php:
--------------------------------------------------------------------------------
1 | qualifyClass($this->getNameInput());
41 |
42 | $path = $this->getPath($name);
43 |
44 | $this->callSilent('package:replace', [
45 | 'path' => $path,
46 | '--old' => ['{{ serviceProvider }}'],
47 | '--new' => [$this->getProviderInput()],
48 | ]);
49 | }
50 |
51 | /**
52 | * Get the stub file for the generator.
53 | *
54 | * @return string
55 | */
56 | protected function getStub()
57 | {
58 | return __DIR__.'/stubs/base-test.stub';
59 | }
60 |
61 | /**
62 | * Get the desired class name from the input.
63 | *
64 | * @return string
65 | */
66 | protected function getNameInput()
67 | {
68 | return 'TestCase';
69 | }
70 |
71 | /**
72 | * Get the destination class path.
73 | *
74 | * @return string
75 | */
76 | protected function resolveDirectory()
77 | {
78 | return $this->getDirInput().'tests';
79 | }
80 |
81 | /**
82 | * @return string
83 | */
84 | protected function getProviderInput()
85 | {
86 | return trim($this->argument('provider'));
87 | }
88 |
89 | /**
90 | * Get the console command arguments.
91 | *
92 | * @return array
93 | */
94 | protected function getArguments()
95 | {
96 | return [
97 | ['provider', InputArgument::REQUIRED, 'The package\'s provider name'],
98 | ];
99 | }
100 | }
101 |
--------------------------------------------------------------------------------
/src/Commands/Package/CodecovMakeCommand.php:
--------------------------------------------------------------------------------
1 | qualifyClass($this->getNameInput());
42 |
43 | $path = $this->getPath($name);
44 |
45 | $this->callSilent('package:replace', [
46 | 'path' => $path,
47 | '--old' => ['DummyAuthor', 'DummyEmail', 'DummyComposerNamespace', 'DummyComposerProviderNamespace'],
48 | '--new' => [$this->getAuthorInput(), $this->getEmailInput(), $this->composerNamespace(), $this->composerProviderNamespace()],
49 | ]);
50 | }
51 |
52 | /**
53 | * Get the stub file for the generator.
54 | *
55 | * @return string
56 | */
57 | protected function getStub()
58 | {
59 | return __DIR__.'/stubs/composer.stub';
60 | }
61 |
62 | /**
63 | * Get the stub file type for the generator.
64 | *
65 | * @return string
66 | */
67 | public function getFileType()
68 | {
69 | return '.json';
70 | }
71 |
72 | /**
73 | * Get the desired class name from the input.
74 | *
75 | * @return string
76 | */
77 | protected function getNameInput()
78 | {
79 | return 'composer';
80 | }
81 |
82 | /**
83 | * @return string
84 | */
85 | protected function composerNamespace()
86 | {
87 | return ucfirst($this->vendorName()).'\\\\'.Str::studly($this->packageName()).'\\\\';
88 | }
89 |
90 | /**
91 | * @return string
92 | */
93 | protected function composerProviderNamespace()
94 | {
95 | return $this->composerNamespace().Str::studly($this->packageName()).'ServiceProvider';
96 | }
97 |
98 | /**
99 | * Get the desired author from the input.
100 | *
101 | * @return string
102 | */
103 | protected function getAuthorInput()
104 | {
105 | return trim($this->option('author'));
106 | }
107 |
108 | /**
109 | * Get the desired email from the input.
110 | *
111 | * @return string
112 | */
113 | protected function getEmailInput()
114 | {
115 | return trim($this->option('email'));
116 | }
117 |
118 | /**
119 | * Get the console command options.
120 | *
121 | * @return array
122 | */
123 | protected function getOptions()
124 | {
125 | return array_merge(
126 | parent::getOptions(),
127 | [
128 | ['author', 'A', InputOption::VALUE_REQUIRED, 'The author of the package.'],
129 |
130 | ['email', 'E', InputOption::VALUE_REQUIRED, 'The author\'s email.'],
131 | ]
132 | );
133 | }
134 | }
135 |
--------------------------------------------------------------------------------
/src/Commands/Package/ContributionMakeCommand.php:
--------------------------------------------------------------------------------
1 | qualifyClass($this->getNameInput());
41 |
42 | $path = $this->getPath($name);
43 |
44 | $this->callSilent('package:replace', [
45 | 'path' => $path,
46 | '--old' => ['{{ year }}', '{{ companyOrVendor }}'],
47 | '--new' => [date('Y'), $this->getCopyrightInput()],
48 | ]);
49 | }
50 |
51 | /**
52 | * Get the stub file for the generator.
53 | *
54 | * @return string
55 | */
56 | protected function getStub()
57 | {
58 | return __DIR__.'/stubs/LICENSE.stub';
59 | }
60 |
61 | /**
62 | * Get the stub file type for the generator.
63 | *
64 | * @return string
65 | */
66 | public function getFileType()
67 | {
68 | return '.md';
69 | }
70 |
71 | /**
72 | * Get the desired class name from the input.
73 | *
74 | * @return string
75 | */
76 | protected function getNameInput()
77 | {
78 | return 'LICENSE';
79 | }
80 |
81 | /**
82 | * Get the desired copyright from the input.
83 | *
84 | * @return string
85 | */
86 | protected function getCopyrightInput()
87 | {
88 | return trim($this->option('copyright'));
89 | }
90 |
91 | /**
92 | * Get the console command options.
93 | *
94 | * @return array
95 | */
96 | protected function getOptions()
97 | {
98 | return array_merge(
99 | parent::getOptions(),
100 | [
101 | ['copyright', 'C', InputOption::VALUE_REQUIRED, 'The company or vendor name to place it int the license file'],
102 | ]
103 | );
104 | }
105 | }
106 |
--------------------------------------------------------------------------------
/src/Commands/Package/PhpunitMakeCommand.php:
--------------------------------------------------------------------------------
1 | qualifyClass($this->getNameInput());
41 |
42 | $path = $this->getPath($name);
43 |
44 | $this->callSilent('package:replace', [
45 | 'path' => $path,
46 | '--old' => ['DummyAuthorEmail', 'DummyAuthor'],
47 | '--new' => [$this->getEmailInput(), $this->getAuthorInput()],
48 | ]);
49 | }
50 |
51 | /**
52 | * Get the stub file for the generator.
53 | *
54 | * @return string
55 | */
56 | protected function getStub()
57 | {
58 | return __DIR__.'/stubs/readme.stub';
59 | }
60 |
61 | /**
62 | * Get the stub file type for the generator.
63 | *
64 | * @return string
65 | */
66 | public function getFileType()
67 | {
68 | return '.md';
69 | }
70 |
71 | /**
72 | * Get the desired class name from the input.
73 | *
74 | * @return string
75 | */
76 | protected function getNameInput()
77 | {
78 | return 'readme';
79 | }
80 |
81 | /**
82 | * Get the author name from the input.
83 | *
84 | * @return string
85 | */
86 | protected function getAuthorInput()
87 | {
88 | return trim($this->option('author'));
89 | }
90 |
91 | /**
92 | * Get the author name from the input.
93 | *
94 | * @return string
95 | */
96 | protected function getEmailInput()
97 | {
98 | return trim($this->option('email'));
99 | }
100 |
101 | /**
102 | * Get the console command options.
103 | *
104 | * @return array
105 | */
106 | protected function getOptions()
107 | {
108 | return array_merge(
109 | parent::getOptions(),
110 | [
111 | ['author', 'A', InputOption::VALUE_REQUIRED, 'The author of this package'],
112 | ['email', 'E', InputOption::VALUE_REQUIRED, 'The email of the package author'],
113 | ]
114 | );
115 | }
116 | }
117 |
--------------------------------------------------------------------------------
/src/Commands/Package/StyleciMakeCommand.php:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 | tests
9 |
10 |
11 |
12 |
13 | ./app
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/src/Commands/Package/stubs/readme.stub:
--------------------------------------------------------------------------------
1 | # DummyPackageName
2 |
3 | [](LICENSE.md)
4 | []()
5 | [](https://packagist.org/packages/DummyVendor/DummyPackageName)
6 |
7 | ## Install
8 | `composer require DummyVendor/DummyPackageName`
9 |
10 | ## Usage
11 | Write a few lines about the usage of this package.
12 |
13 | ## Testing
14 | Run the tests with:
15 |
16 | ``` bash
17 | vendor/bin/phpunit
18 | ```
19 |
20 | ## Changelog
21 | Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.
22 |
23 | ## Contributing
24 | Please see [CONTRIBUTING](CONTRIBUTING.md) for details.
25 |
26 | ## Credits
27 |
28 | - [DummyAuthor](https://github.com/DummyVendor)
29 | - [All Contributors](https://github.com/DummyVendor/DummyPackageName/contributors)
30 |
31 | ## Security
32 | If you discover any security-related issues, please email DummyAuthorEmail instead of using the issue tracker.
33 |
34 | ## License
35 | The MIT License (MIT). Please see [License File](/LICENSE.md) for more information.
--------------------------------------------------------------------------------
/src/Commands/PackageMakeCommand.php:
--------------------------------------------------------------------------------
1 | files = $files;
88 | }
89 |
90 | /**
91 | * Execute the console command.
92 | *
93 | * @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
94 | *
95 | * @return mixed
96 | */
97 | public function handle()
98 | {
99 | $this->checkForInputs();
100 |
101 | if (! $this->option('no-interaction') && ! $this->confirm('Do you wish to continue?')) {
102 | return $this->error('Canceled command!');
103 | }
104 |
105 | if ($this->alreadyExists($this->packagePath())) {
106 | return $this->error('The package already exists!');
107 | }
108 |
109 | $this->createCommonFiles();
110 | $this->createComposer();
111 | $this->createServiceProvider();
112 | $this->createBaseTestCase();
113 |
114 | $this->configureCICDService();
115 | $this->configureCodeQualityService();
116 | $this->configureCodeCoverageService();
117 |
118 | $this->info('Package successfully created!');
119 |
120 | $this->call('package:save', [
121 | 'namespace' => $this->rootNamespace(),
122 | 'path' => $this->dir.$this->packageName,
123 | ]);
124 |
125 | $this->callSilent('package:add', [
126 | 'name' => $this->packageName,
127 | 'path' => $this->dir.$this->packageName,
128 | 'vendor' => $this->vendor,
129 | 'branch' => 'master',
130 | '--no-interaction' => true,
131 | ]);
132 | }
133 |
134 | /**
135 | * Create common files.
136 | *
137 | * @param $path
138 | *
139 | * @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
140 | */
141 | protected function createCommonFiles()
142 | {
143 | $this->call('package:readme', array_merge(
144 | $this->packageOptions(),
145 | [
146 | '--author' => $this->author,
147 | '--email' => $this->email,
148 | ]
149 | ));
150 | $this->call('package:license', array_merge(
151 | $this->packageOptions(),
152 | ['--copyright' => $this->copyright]
153 | ));
154 | $this->call('package:contribution', $this->packageOptions());
155 | $this->call('package:phpunit', $this->packageOptions());
156 | $this->call('package:gitignore', $this->packageOptions());
157 | }
158 |
159 | /**
160 | * Configure service for CI/CD.
161 | *
162 | * @param $path
163 | *
164 | * @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
165 | */
166 | protected function configureCICDService()
167 | {
168 | $cicdServices = [
169 | 'None' => function () {
170 | },
171 | 'TravisCI' => function () {
172 | $this->call('package:travis', $this->packageOptions());
173 | },
174 | ];
175 |
176 | $cicd = $this->choice(
177 | 'What CI/CD service you want to configure?',
178 | array_keys($cicdServices),
179 | 0
180 | );
181 |
182 | $cicdServices[$cicd]();
183 | }
184 |
185 | /**
186 | * Configure service for Code Quality.
187 | *
188 | * @param $path
189 | *
190 | * @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
191 | */
192 | protected function configureCodeQualityService()
193 | {
194 | $codeQualityServices = [
195 | 'None' => function () {
196 | },
197 | 'StyleCI' => function () {
198 | $this->call('package:styleci', $this->packageOptions());
199 | },
200 | ];
201 |
202 | $codeQuality = $this->choice(
203 | 'What Code Quality service you want to configure?',
204 | array_keys($codeQualityServices),
205 | 0
206 | );
207 |
208 | $codeQualityServices[$codeQuality]();
209 | }
210 |
211 | /**
212 | * Configure service for Code Coverage.
213 | *
214 | * @param $path
215 | *
216 | * @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
217 | */
218 | protected function configureCodeCoverageService()
219 | {
220 | $codeCoverageServices = [
221 | 'None' => function () {
222 | },
223 | 'Codecov' => function () {
224 | $this->call('package:codecov', $this->packageOptions());
225 | },
226 | ];
227 |
228 | $codeCoverage = $this->choice(
229 | 'What Code Coverage service you want to configure?',
230 | array_keys($codeCoverageServices),
231 | 0
232 | );
233 |
234 | $codeCoverageServices[$codeCoverage]();
235 | }
236 |
237 | /**
238 | * Creates composer file.
239 | */
240 | protected function createComposer()
241 | {
242 | $this->call('package:composer', array_merge(
243 | $this->packageOptions(),
244 | [
245 | '--author' => $this->author,
246 | '--email' => $this->email,
247 | ]
248 | ));
249 | }
250 |
251 | /**
252 | * Creates package service provider.
253 | */
254 | protected function createServiceProvider()
255 | {
256 | $this->call('package:provider', array_merge(
257 | [
258 | 'name' => $this->packageName().'ServiceProvider',
259 | ],
260 | $this->packageOptions()
261 | ));
262 | }
263 |
264 | /**
265 | * Creates base test.
266 | */
267 | protected function createBaseTestCase()
268 | {
269 | $this->call('package:basetest', array_merge(
270 | [
271 | 'provider' => $this->packageName().'ServiceProvider',
272 | ],
273 | $this->packageOptions()
274 | ));
275 | }
276 |
277 | /**
278 | * Get package options.
279 | *
280 | * @return array
281 | */
282 | protected function packageOptions()
283 | {
284 | return [
285 | '--namespace' => $this->rootNamespace(),
286 | '--dir' => $this->packagePath(),
287 | ];
288 | }
289 |
290 | /**
291 | * @return string
292 | */
293 | protected function rootNamespace()
294 | {
295 | return ucfirst($this->vendor).'\\'.$this->packageName();
296 | }
297 |
298 | /**
299 | * @return string
300 | */
301 | protected function packageName()
302 | {
303 | return ucfirst(Str::camel($this->packageName));
304 | }
305 |
306 | /**
307 | * Determine if the class already exists.
308 | *
309 | * @param $path
310 | *
311 | * @return bool
312 | */
313 | protected function alreadyExists($path)
314 | {
315 | return $this->files->isDirectory($path);
316 | }
317 |
318 | /**
319 | * @return string
320 | */
321 | protected function packagePath()
322 | {
323 | return $this->getDirectoryInput().$this->packageName;
324 | }
325 |
326 | /**
327 | * Checks for needed input and prints it out.
328 | */
329 | public function checkForInputs()
330 | {
331 | $name = $this->getNameInput();
332 | $vendor = $this->getVendorInput();
333 | $dir = $this->getDirectoryInput();
334 | $author = $this->getAuthorInput();
335 | $email = $this->getEmailInput();
336 | $copyright = $this->getCopyrightInput();
337 |
338 | $this->table(
339 | ['Name', 'Vendor', 'Directory', 'Author', 'E-mail', 'Copyright'],
340 | [
341 | [$name, $vendor, $dir, $author, $email, $copyright],
342 | ]
343 | );
344 | }
345 |
346 | /**
347 | * Get the desired directory path from the input.
348 | *
349 | * @return string
350 | */
351 | protected function getDirectoryInput()
352 | {
353 | if ($this->dir) {
354 | return $this->dir;
355 | }
356 |
357 | if (! $this->dir = $this->argument('dir')) {
358 | $this->dir = $this->anticipate('Where should the package be installed?', ['../packages/', 'packages/']);
359 | }
360 |
361 | return $this->dir;
362 | }
363 |
364 | /**
365 | * Get copyright input.
366 | *
367 | * @return string
368 | */
369 | public function getCopyrightInput()
370 | {
371 | if ($this->copyright) {
372 | return $this->copyright;
373 | }
374 |
375 | if (! $this->copyright = $this->argument('copyright')) {
376 | $this->copyright = $this->ask('Who will hold the copyrights?');
377 | }
378 |
379 | return $this->copyright;
380 | }
381 |
382 | /**
383 | * Get the desired class name from the input.
384 | *
385 | * @return string
386 | */
387 | protected function getNameInput()
388 | {
389 | if ($this->packageName) {
390 | return $this->packageName;
391 | }
392 |
393 | if (! $this->packageName = trim($this->argument('name'))) {
394 | $this->packageName = $this->ask('What\'s your packages name?');
395 | }
396 |
397 | return $this->packageName;
398 | }
399 |
400 | /**
401 | * Get the desired vendor name from the input.
402 | *
403 | * @return string
404 | */
405 | protected function getVendorInput()
406 | {
407 | if ($this->vendor) {
408 | return $this->vendor;
409 | }
410 |
411 | if (! $this->vendor = trim($this->argument('vendor'))) {
412 | $this->vendor = $this->ask('What\'s the packages github name (vendor name of the package)?');
413 | }
414 |
415 | return $this->vendor;
416 | }
417 |
418 | /**
419 | * Get the author name input.
420 | *
421 | * @return string
422 | */
423 | public function getAuthorInput()
424 | {
425 | if ($this->author) {
426 | return $this->author;
427 | }
428 |
429 | if (! $this->author = $this->argument('author')) {
430 | $this->author = $this->ask('Who is the author of the package?');
431 | }
432 |
433 | return $this->author;
434 | }
435 |
436 | /**
437 | * Get mail input.
438 | *
439 | * @return string
440 | */
441 | public function getEmailInput()
442 | {
443 | if ($this->email) {
444 | return $this->email;
445 | }
446 |
447 | if (! $this->email = $this->argument('email')) {
448 | $this->email = $this->ask('What\'s the mantainer\'s e-mail?');
449 | }
450 |
451 | return $this->email;
452 | }
453 | }
454 |
--------------------------------------------------------------------------------
/src/Commands/Replace.php:
--------------------------------------------------------------------------------
1 | files = $files;
44 | }
45 |
46 | /**
47 | * Execute the console command.
48 | *
49 | * @return mixed
50 | */
51 | public function handle()
52 | {
53 | if ($this->getOldInput()->count() !== $this->getNewInput()->count()) {
54 | return $this->error('Old and new options need to have the same length!');
55 | }
56 |
57 | if ($this->files->isDirectory($path = $this->getPathInput())) {
58 | collect($this->files->allFiles($path))
59 | ->each(function ($file) {
60 | $this->buildFile($file->getPathName());
61 | }
62 | );
63 | }
64 |
65 | if ($this->files->isFile($path)) {
66 | $this->buildFile($path);
67 | }
68 |
69 | $this->info('All old inputs got replaced!');
70 | }
71 |
72 | /**
73 | * Builds the new file.
74 | *
75 | * @param string $path
76 | * @return void
77 | */
78 | public function buildFile($path)
79 | {
80 | $this->files->put($path, $this->replaceContents($path));
81 | $this->renameFile($path);
82 | }
83 |
84 | /**
85 | * Replace old contents.
86 | *
87 | * @param string $path
88 | * @return string
89 | */
90 | protected function replaceContents($path)
91 | {
92 | $stub = $this->files->get($path);
93 |
94 | return $this->replaceAll($stub);
95 | }
96 |
97 | /**
98 | * Rename file.
99 | *
100 | * @param string $path
101 | * @return void
102 | */
103 | protected function renameFile($path)
104 | {
105 | $newPath = $this->replaceAll($path);
106 |
107 | if ($newPath !== $path) {
108 | $this->files->move($path, $newPath);
109 | }
110 | }
111 |
112 | /**
113 | * Replace all occurrenes of old values with new ones.
114 | *
115 | * @param string $stub
116 | * @return string
117 | */
118 | protected function replaceAll($stub)
119 | {
120 | return str_replace(
121 | $this->getOldInput()->toArray(),
122 | $this->getNewInput()->toArray(),
123 | $stub
124 | );
125 | }
126 |
127 | /**
128 | * Get path directory.
129 | *
130 | * @return string
131 | */
132 | public function getPathInput()
133 | {
134 | return trim($this->argument('path'));
135 | }
136 |
137 | /**
138 | * Get old namespace.
139 | *
140 | * @return string
141 | */
142 | public function getOldInput()
143 | {
144 | return collect($this->option('old'));
145 | }
146 |
147 | /**
148 | * Get new namespace.
149 | *
150 | * @return string
151 | */
152 | public function getNewInput()
153 | {
154 | return collect($this->option('new'));
155 | }
156 | }
157 |
--------------------------------------------------------------------------------
/src/Commands/Routing/ControllerMakeCommand.php:
--------------------------------------------------------------------------------
1 | getDirInput().'src';
30 | }
31 |
32 | /**
33 | * Build the class with the given name.
34 | *
35 | * @param string $name
36 | *
37 | * @return string
38 | */
39 | protected function buildClass($name)
40 | {
41 | $class = parent::buildClass($name);
42 |
43 | if (Str::contains($class, $this->rootNamespace().'Http\Controllers\Controller')) {
44 | return str_replace(
45 | $this->rootNamespace().'Http\Controllers\Controller',
46 | 'Illuminate\Routing\Controller',
47 | $class
48 | );
49 | }
50 |
51 | return str_replace(
52 | 'use Illuminate\Http\Request;',
53 | "use Illuminate\Http\Request;\nuse Illuminate\Routing\Controller;",
54 | $class
55 | );
56 | }
57 |
58 | /**
59 | * Build the replacements for a parent controller.
60 | *
61 | * @return array
62 | */
63 | protected function buildParentReplacements()
64 | {
65 | $parentModelClass = $this->parseModel($this->option('parent'));
66 |
67 | if (! class_exists($parentModelClass)) {
68 | if ($this->confirm("A {$parentModelClass} model does not exist. Do you want to generate it?", true)) {
69 | $this->call('package:model', [
70 | 'name' => $parentModelClass,
71 | '--namespace' => $this->rootNamespace(),
72 | '--dir' => $this->basePath(),
73 | ]);
74 | }
75 | }
76 |
77 | return [
78 | 'ParentDummyFullModelClass' => $parentModelClass,
79 | 'ParentDummyModelClass' => class_basename($parentModelClass),
80 | 'ParentDummyModelVariable' => lcfirst(class_basename($parentModelClass)),
81 | ];
82 | }
83 |
84 | /**
85 | * Build the model replacement values.
86 | *
87 | * @param array $replace
88 | *
89 | * @return array
90 | */
91 | protected function buildModelReplacements(array $replace)
92 | {
93 | $modelClass = $this->parseModel($this->option('model'));
94 |
95 | if (! class_exists($modelClass)) {
96 | if ($this->confirm("A {$modelClass} model does not exist. Do you want to generate it?", true)) {
97 | $this->call('package:model', [
98 | 'name' => $modelClass,
99 | '--namespace' => $this->rootNamespace(),
100 | '--dir' => $this->basePath(),
101 | ]);
102 | }
103 | }
104 |
105 | array_merge($replace, [
106 | 'DummyFullModelClass' => $modelClass,
107 | '{{ namespacedModel }}' => $modelClass,
108 | '{{namespacedModel}}' => $modelClass,
109 | 'DummyModelClass' => class_basename($modelClass),
110 | '{{ model }}' => class_basename($modelClass),
111 | '{{model}}' => class_basename($modelClass),
112 | 'DummyModelVariable' => lcfirst(class_basename($modelClass)),
113 | '{{ modelVariable }}' => lcfirst(class_basename($modelClass)),
114 | '{{modelVariable}}' => lcfirst(class_basename($modelClass)),
115 | ]);
116 | }
117 |
118 | /**
119 | * Get the fully-qualified model class name.
120 | *
121 | * @param string $model
122 | *
123 | * @return string
124 | */
125 | protected function parseModel($model)
126 | {
127 | if (preg_match('([^A-Za-z0-9_/\\\\])', $model)) {
128 | throw new InvalidArgumentException('Model name contains invalid characters.');
129 | }
130 |
131 | $model = trim(str_replace('/', '\\', $model), '\\');
132 |
133 | if (! Str::startsWith($model, $rootNamespace = $this->rootNamespace()) && ! Str::startsWith($model, $this->laravel->getNamespace())) {
134 | $model = $rootNamespace.'\\'.$model;
135 | }
136 |
137 | return $model;
138 | }
139 | }
140 |
--------------------------------------------------------------------------------
/src/Commands/Routing/MiddlewareMakeCommand.php:
--------------------------------------------------------------------------------
1 | getDirInput().'src';
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/Commands/SavePackageCredentials.php:
--------------------------------------------------------------------------------
1 | forever('package:namespace', $this->argument('namespace'));
43 | cache()->forever('package:path', $this->argument('path'));
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/src/Commands/Standard/AnyMakeCommand.php:
--------------------------------------------------------------------------------
1 | type = ucfirst($this->getCategoryInput());
44 |
45 | parent::handle();
46 |
47 | $name = $this->qualifyClass($this->getNameInput());
48 |
49 | $path = $this->getPath($name);
50 |
51 | $this->callSilent('package:replace', [
52 | 'path' => $path,
53 | '--old' => ['{{ type }}'],
54 | '--new' => [$this->getTypeInput()],
55 | ]);
56 | }
57 |
58 | /**
59 | * Get the stub file for the generator.
60 | *
61 | * @return string
62 | */
63 | protected function getStub()
64 | {
65 | return __DIR__.'/stubs/dummy.stub';
66 | }
67 |
68 | /**
69 | * Get the destination class path.
70 | *
71 | * @return string
72 | */
73 | protected function resolveDirectory()
74 | {
75 | return $this->getDirInput().'src';
76 | }
77 |
78 | /**
79 | * Get the default namespace for the class.
80 | *
81 | * @param string $rootNamespace
82 | *
83 | * @return string
84 | */
85 | protected function getDefaultNamespace($rootNamespace)
86 | {
87 | return $rootNamespace.'\\'.Str::plural(ucfirst(Str::camel($this->getCategoryInput())));
88 | }
89 |
90 | /**
91 | * @return string
92 | */
93 | protected function getTypeInput()
94 | {
95 | return trim($this->option('type')) ?: 'class';
96 | }
97 |
98 | /**
99 | * @return string
100 | */
101 | protected function getCategoryInput()
102 | {
103 | return trim($this->option('category')) ?: 'service';
104 | }
105 |
106 | /**
107 | * Get the console command arguments.
108 | *
109 | * @return array
110 | */
111 | protected function additionalOptions()
112 | {
113 | return [
114 | ['category', 'c', InputOption::VALUE_OPTIONAL, 'The file\'s category/folder.'],
115 |
116 | ['type', 't', InputOption::VALUE_OPTIONAL, 'The file\'s type (interface, class, trait, abstract class)'],
117 | ];
118 | }
119 | }
120 |
--------------------------------------------------------------------------------
/src/Commands/Standard/ContractMakeCommand.php:
--------------------------------------------------------------------------------
1 | callSilent('package:any', [
41 | 'name' => $this->argument('name'),
42 | '--type' => 'interface',
43 | '--category' => $this->type,
44 | ]);
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/src/Commands/Standard/InterfaceMakeCommand.php:
--------------------------------------------------------------------------------
1 | call('package:contract', [
34 | 'name' => $this->argument('name'),
35 | ]);
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/src/Commands/Standard/TraitMakeCommand.php:
--------------------------------------------------------------------------------
1 | callSilent('package:any', [
41 | 'name' => $this->argument('name'),
42 | '--type' => 'trait',
43 | '--category' => $this->type,
44 | ]);
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/src/Commands/Standard/stubs/dummy.stub:
--------------------------------------------------------------------------------
1 | app->when(MigrationCreator::class)
60 | ->needs('$customStubPath')
61 | ->give(function ($app) {
62 | return $app->basePath('stubs');
63 | });
64 | }
65 |
66 | /**
67 | * Bootstrap the application services.
68 | *
69 | * @return void
70 | */
71 | public function boot()
72 | {
73 | $this->commands(
74 | array_merge(
75 | $this->routingCommands(),
76 | $this->packageCommands(),
77 | $this->databaseCommands(),
78 | $this->standardCommands(),
79 | $this->foundationCommands(),
80 | $this->packageInternalCommands()
81 | )
82 | );
83 | }
84 |
85 | /**
86 | * Get package database related commands.
87 | *
88 | * @return array
89 | */
90 | protected function databaseCommands()
91 | {
92 | return [
93 | SeederMakeCommand::class,
94 | FactoryMakeCommand::class,
95 | MigrationMakeCommand::class,
96 | ];
97 | }
98 |
99 | /**
100 | * Get package foundation related commands.
101 | *
102 | * @return array
103 | */
104 | protected function foundationCommands()
105 | {
106 | return [
107 | JobMakeCommand::class,
108 | MailMakeCommand::class,
109 | TestMakeCommand::class,
110 | RuleMakeCommand::class,
111 | EventMakeCommand::class,
112 | ModelMakeCommand::class,
113 | PolicyMakeCommand::class,
114 | ConsoleMakeCommand::class,
115 | RequestMakeCommand::class,
116 | ChannelMakeCommand::class,
117 | ProviderMakeCommand::class,
118 | ListenerMakeCommand::class,
119 | ObserverMakeCommand::class,
120 | ResourceMakeCommand::class,
121 | ExceptionMakeCommand::class,
122 | NotificationMakeCommand::class,
123 | ];
124 | }
125 |
126 | /**
127 | * Get package related commands.
128 | *
129 | * @return array
130 | */
131 | protected function packageCommands()
132 | {
133 | return [
134 | NovaMakeCommand::class,
135 | ReadmeMakeCommand::class,
136 | TravisMakeCommand::class,
137 | LicenseMakeCommand::class,
138 | PhpunitMakeCommand::class,
139 | StyleciMakeCommand::class,
140 | CodecovMakeCommand::class,
141 | ComposerMakeCommand::class,
142 | BaseTestMakeCommand::class,
143 | GitignoreMakeCommand::class,
144 | ContributionMakeCommand::class,
145 | ];
146 | }
147 |
148 | /**
149 | * Get package internal related commands.
150 | *
151 | * @return array
152 | */
153 | protected function packageInternalCommands()
154 | {
155 | return [
156 | Replace::class,
157 | AddPackage::class,
158 | ClonePackage::class,
159 | PackageMakeCommand::class,
160 | SavePackageCredentials::class,
161 | DeletePackageCredentials::class,
162 | ];
163 | }
164 |
165 | /**
166 | * Get package routing related commands.
167 | *
168 | * @return array
169 | */
170 | protected function routingCommands()
171 | {
172 | return [
173 | ControllerMakeCommand::class,
174 | MiddlewareMakeCommand::class,
175 | ];
176 | }
177 |
178 | /**
179 | * Get standard related commands.
180 | *
181 | * @return array
182 | */
183 | protected function standardCommands()
184 | {
185 | return [
186 | AnyMakeCommand::class,
187 | TraitMakeCommand::class,
188 | ContractMakeCommand::class,
189 | InterfaceMakeCommand::class,
190 | ];
191 | }
192 | }
193 |
--------------------------------------------------------------------------------
/src/Traits/CreatesPackageStubs.php:
--------------------------------------------------------------------------------
1 | rootNamespace(), '', $name);
30 |
31 | return $this->basePath().str_replace('\\', '/', $name).$this->getFileType();
32 | }
33 |
34 | /**
35 | * Get Packages base Path.
36 | *
37 | * @return string
38 | */
39 | protected function basePath()
40 | {
41 | return base_path().'/'.Str::finish($this->resolveDirectory(), '/');
42 | }
43 |
44 | /**
45 | * Build the class with the given name.
46 | *
47 | * @param string $name
48 | *
49 | * @return string
50 | */
51 | protected function buildClass($name)
52 | {
53 | $class = parent::buildClass($name);
54 |
55 | return $this->replacePackageName($class);
56 | }
57 |
58 | /**
59 | * Replace the dummy data with the package name for the given stub.
60 | *
61 | * @param string $stub
62 | *
63 | * @return string
64 | */
65 | protected function replacePackageName(&$stub)
66 | {
67 | return str_replace(
68 | ['DummyVendor', 'DummyPackageName'],
69 | [$this->vendorName(), $this->packageName()],
70 | $stub
71 | );
72 | }
73 |
74 | /**
75 | * Get the root namespace for the class.
76 | *
77 | * @return string
78 | */
79 | protected function rootNamespace()
80 | {
81 | return $this->getNamespaceInput().'\\';
82 | }
83 |
84 | /**
85 | * Get vendor name.
86 | *
87 | * @return string
88 | */
89 | protected function vendorName()
90 | {
91 | return lcfirst(Str::before($this->getNamespaceInput(), '\\'));
92 | }
93 |
94 | /**
95 | * Get Package name.
96 | *
97 | * @return string
98 | */
99 | protected function packageName()
100 | {
101 | return Str::slug(Str::snake(Str::after($this->getNamespaceInput(), '\\')));
102 | }
103 |
104 | /**
105 | * Get the desired class namespace from the input.
106 | *
107 | * @return string
108 | */
109 | protected function getNamespaceInput()
110 | {
111 | $namespace = trim($this->option('namespace'));
112 |
113 | if (! $namespace && ! $namespace = cache()->get('package:namespace')) {
114 | $namespace = $this->ask('What is the namespace of your package?');
115 | }
116 |
117 | if (Str::contains($namespace, '\\')) {
118 | return $namespace;
119 | }
120 |
121 | $namespace = explode(
122 | '_',
123 | Str::snake(trim($this->option('namespace')))
124 | );
125 |
126 | return implode('\\', array_map('ucfirst', $namespace));
127 | }
128 |
129 | /**
130 | * Get the desired directory from the input.
131 | *
132 | * @return string
133 | */
134 | protected function getDirInput()
135 | {
136 | $dir = trim($this->option('dir'));
137 |
138 | if (! $dir && ! $dir = cache()->get('package:path')) {
139 | $dir = $this->ask('Where is your package stored (relative path)?');
140 | }
141 |
142 | return Str::endsWith($dir, '/') ? $dir : $dir.'/';
143 | }
144 |
145 | /**
146 | * Resolve directory where stub will be created.
147 | *
148 | * @return string
149 | */
150 | protected function resolveDirectory()
151 | {
152 | return $this->getDirInput();
153 | }
154 |
155 | /**
156 | * Get the console command options.
157 | *
158 | * @return array
159 | */
160 | protected function getOptions()
161 | {
162 | return array_merge(
163 | parent::getOptions(),
164 | [
165 | ['namespace', 'N', InputOption::VALUE_REQUIRED, 'The namespace in which the file will be created'],
166 |
167 | ['dir', 'D', InputOption::VALUE_REQUIRED, 'Directory where the package will be stored'],
168 | ],
169 | $this->additionalOptions()
170 | );
171 | }
172 |
173 | /**
174 | * Adds additional options to the command.
175 | *
176 | * @return array
177 | */
178 | protected function additionalOptions()
179 | {
180 | return [];
181 | }
182 | }
183 |
--------------------------------------------------------------------------------
/src/Traits/HasNameInput.php:
--------------------------------------------------------------------------------
1 | setTimeout(null);
18 | $process->setTty($process->isTtySupported());
19 |
20 | $process->run(function ($type, $line) {
21 | $this->command->output->write($line);
22 | });
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/tests/Feature/ClonePackageTest.php:
--------------------------------------------------------------------------------
1 | artisan('package:clone', [
16 | 'src' => $src,
17 | 'target' => $target,
18 | ]);
19 |
20 | $this->assertTrue($this->files->isDirectory($target));
21 | $this->assertEquals(count($this->files->allFiles($target, true)), count($this->files->allFiles($src, true)));
22 |
23 | $this->files->deleteDirectory($target);
24 | }
25 |
26 | /** @test */
27 | public function it_can_clone_git_repositories()
28 | {
29 | $src = 'git@github.com:Naoray/laravel-package-maker.git';
30 | $target = './tests/Support/git-package-clone';
31 |
32 | $this->artisan('package:clone', [
33 | 'src' => $src,
34 | 'target' => $target,
35 | ]);
36 |
37 | $this->assertTrue($this->files->isDirectory($target));
38 | $this->assertEquals(
39 | count($this->files->allFiles($target.'/src', true)),
40 | count($this->files->allFiles('./src', true))
41 | );
42 |
43 | $this->files->deleteDirectory($target);
44 | }
45 |
46 | /** @test */
47 | public function it_can_clone_remote_repositories()
48 | {
49 | $src = 'https://github.com/naoray/laravel-package-maker';
50 | $target = './tests/Support/git-package-clone';
51 |
52 | $this->artisan('package:clone', [
53 | 'src' => $src,
54 | 'target' => $target,
55 | ]);
56 |
57 | $this->assertTrue($this->files->isDirectory($target));
58 | $this->assertEquals(
59 | count($this->files->allFiles($target.'/src', true)),
60 | count($this->files->allFiles('./src', true))
61 | );
62 |
63 | $this->files->deleteDirectory($target);
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/tests/Feature/DeletePackageCredentialsTest.php:
--------------------------------------------------------------------------------
1 | artisan('package:save', [
13 | 'namespace' => 'Test\Package',
14 | 'path' => './tests/Support/package',
15 | ]);
16 |
17 | $this->artisan('package:delete');
18 |
19 | $this->assertNull(cache()->get('package:namespace'));
20 | $this->assertNull(cache()->get('package:path'));
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/tests/Feature/ReplaceTest.php:
--------------------------------------------------------------------------------
1 | runConsoleCommand('/bin/echo -n \'# '.$old.'\' >> '.$fileName, $path);
21 |
22 | $this->runReplaceCommand($path, $old, $new);
23 |
24 | $this->assertEquals($this->files->get($path.$fileName), '# '.$new);
25 |
26 | $this->files->delete($path.$fileName);
27 | }
28 |
29 | /** @test */
30 | public function it_can_replace_all_files_old_string_with_new_ones_in_a_folder()
31 | {
32 | $path = './tests/Support/package/';
33 | $old = 'test/package';
34 | $new = 'test/other-package';
35 |
36 | $this->runReplaceCommand($path, $old, $new);
37 |
38 | $this->assertEquals(
39 | json_decode($this->files->get($path.'composer.json'), true)['name'],
40 | strtolower($new)
41 | );
42 |
43 | // revert replacement
44 | $this->runReplaceCommand($path, $new, $old);
45 | }
46 |
47 | /**
48 | * Run replace command.
49 | *
50 | * @param string $path
51 | * @param array $oldInput
52 | * @param array $newInput
53 | */
54 | public function runReplaceCommand($path, $oldInput, $newInput)
55 | {
56 | $oldInput = is_array($oldInput) ? $oldInput : [$oldInput];
57 | $newInput = is_array($newInput) ? $newInput : [$newInput];
58 |
59 | $this->artisan('package:replace', [
60 | 'path' => $path,
61 | '--old' => $oldInput,
62 | '--new' => $newInput,
63 | ]);
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/tests/Feature/SavePackageCredentialsTest.php:
--------------------------------------------------------------------------------
1 | artisan('package:save', [
16 | 'namespace' => $namespace,
17 | 'path' => $path,
18 | ]);
19 |
20 | $this->assertEquals($namespace, cache()->get('package:namespace'));
21 | $this->assertEquals($path, cache()->get('package:path'));
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/tests/Support/package/.gitignore:
--------------------------------------------------------------------------------
1 | /.idea/
2 | /vendor
--------------------------------------------------------------------------------
/tests/Support/package/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contributing
2 |
3 | Contributions are **welcome** and will be fully **credited**.
4 |
5 | We accept contributions via Pull Requests on [Github](https://github.com/test/package).
6 |
7 |
8 | ## Pull Requests
9 |
10 | - **[PSR-2 Coding Standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)** - The easiest way to apply the conventions is to install [PHP Code Sniffer](http://pear.php.net/package/PHP_CodeSniffer).
11 |
12 | - **Add tests!** - Your patch won't be accepted if it doesn't have tests.
13 |
14 | - **Document any change in behaviour** - Make sure the `README.md` and any other relevant documentation are kept up-to-date.
15 |
16 | - **Consider our release cycle** - We try to follow [SemVer v2.0.0](http://semver.org/). Randomly breaking public APIs is not an option.
17 |
18 | - **Create feature branches** - Don't ask us to pull from your master branch.
19 |
20 | - **One pull request per feature** - If you want to do more than one thing, send multiple pull requests.
21 |
22 | - **Send coherent history** - Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please [squash them](http://www.git-scm.com/book/en/v2/Git-Tools-Rewriting-History#Changing-Multiple-Commit-Messages) before submitting.
23 |
24 |
25 | ## Running Tests
26 |
27 | ``` bash
28 | $ composer test
29 | ```
30 |
31 |
32 | **Happy coding**!
--------------------------------------------------------------------------------
/tests/Support/package/LICENSE.md:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2017 Test Company
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
--------------------------------------------------------------------------------
/tests/Support/package/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "test/package",
3 | "description": "A description for package.",
4 | "type": "package",
5 | "license": "MIT",
6 | "keywords": [
7 | "laravel"
8 | ],
9 | "authors": [
10 | {
11 | "name": "test Author",
12 | "email": "author@test.com"
13 | }
14 | ],
15 | "require": {
16 | "illuminate/support": "5.6.*"
17 | },
18 | "autoload": {
19 | "psr-4": {
20 | "Test\\Package\\": "./src"
21 | }
22 | },
23 | "autoload-dev": {
24 | "psr-4": {
25 | "Test\\Package\\Tests\\": "tests"
26 | }
27 | },
28 | "scripts": {
29 | "test": "vendor/bin/phpunit"
30 | },
31 | "extra": {
32 | "laravel": {
33 | "providers": [
34 | "Test\\Package\\PackageServiceProvider"
35 | ]
36 | }
37 | },
38 | "require-dev": {
39 | "orchestra/testbench": "^3.6"
40 | }
41 | }
--------------------------------------------------------------------------------
/tests/Support/package/phpunit.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
13 |
14 | tests
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 | src/
24 |
25 |
26 |
--------------------------------------------------------------------------------
/tests/Support/package/readme.md:
--------------------------------------------------------------------------------
1 | # package
2 |
3 | [](LICENSE.md)
4 | []()
5 | [](https://packagist.org/packages/test/package)
6 |
7 | ## Install
8 | `composer require test/package`
9 |
10 | ## Usage
11 | Write a few lines about the usage of this package.
12 |
13 | ## Testing
14 | Run the tests with:
15 |
16 | ``` bash
17 | vendor/bin/phpunit
18 | ```
19 |
20 | ## Changelog
21 | Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.
22 |
23 | ## Contributing
24 | Please see [CONTRIBUTING](CONTRIBUTING.md) for details.
25 |
26 | ## Security
27 | If you discover any security-related issues, please email DummyAuthorEmail instead of using the issue tracker.
28 |
29 | ## License
30 | The MIT License (MIT). Please see [License File](/LICENSE.md) for more information.
--------------------------------------------------------------------------------
/tests/Support/package/src/PackageServiceProvider.php:
--------------------------------------------------------------------------------
1 | set('app.key', '6rE9Nz59bGRbeMATftriyQjrpF7DcOQm');
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/tests/TestCase.php:
--------------------------------------------------------------------------------
1 | files = new Filesystem();
23 | }
24 |
25 | /**
26 | * Get package providers.
27 | *
28 | * @param \Illuminate\Foundation\Application $app
29 | *
30 | * @return array
31 | */
32 | protected function getPackageProviders($app)
33 | {
34 | return [
35 | \Naoray\LaravelPackageMaker\LaravelPackageMakerServiceProvider::class,
36 | ];
37 | }
38 |
39 | /**
40 | * Define environment setup.
41 | *
42 | * @param \Illuminate\Foundation\Application $app
43 | */
44 | protected function getEnvironmentSetUp($app)
45 | {
46 | $app['config']->set('app.key', '6rE9Nz59bGRbeMATftriyQjrpF7DcOQm');
47 | }
48 | }
49 |
--------------------------------------------------------------------------------