@@ -15,219 +15,219 @@ |
||
15 | 15 | |
16 | 16 | class Version |
17 | 17 | { |
18 | - /** |
|
19 | - * @var EntityManagerInterface |
|
20 | - */ |
|
21 | - private $em; |
|
22 | - |
|
23 | - /** |
|
24 | - * @var HttpClientInterface |
|
25 | - */ |
|
26 | - private $client; |
|
27 | - |
|
28 | - /** |
|
29 | - * @var ParameterBagInterface |
|
30 | - */ |
|
31 | - private $parameter; |
|
32 | - |
|
33 | - /** |
|
34 | - * @var PackagistApi |
|
35 | - */ |
|
36 | - private $packagist; |
|
37 | - |
|
38 | - /** |
|
39 | - * @var mixed |
|
40 | - */ |
|
41 | - private $local_token; |
|
42 | - |
|
43 | - /** |
|
44 | - * @var Package |
|
45 | - */ |
|
46 | - private $package; |
|
47 | - |
|
48 | - private $messages = []; |
|
49 | - |
|
50 | - /** |
|
51 | - * Version constructor. |
|
52 | - * @param EntityManagerInterface $em |
|
53 | - * @param HttpClientInterface $client |
|
54 | - * @param ParameterBagInterface $parameter |
|
55 | - * @param PackagistApi $packagist |
|
56 | - */ |
|
57 | - public function __construct(EntityManagerInterface $em, HttpClientInterface $client, ParameterBagInterface $parameter, PackagistApi $packagist) |
|
58 | - { |
|
59 | - $this->em = $em; |
|
60 | - $this->client = $client; |
|
61 | - $this->parameter = $parameter; |
|
62 | - $this->packagist = $packagist; |
|
63 | - $this->local_token = $parameter->get("ribs_admin.packages_token"); |
|
64 | - } |
|
65 | - |
|
66 | - /** |
|
67 | - * @return array |
|
68 | - */ |
|
69 | - public function getMessages(): array |
|
70 | - { |
|
71 | - return $this->messages; |
|
72 | - } |
|
73 | - |
|
74 | - /** |
|
75 | - * @param Package $package |
|
76 | - */ |
|
77 | - public function setPackageEntity(Package $package) |
|
78 | - { |
|
79 | - $this->package = $package; |
|
80 | - } |
|
81 | - |
|
82 | - /** |
|
83 | - * @return mixed|null |
|
84 | - * @throws ClientExceptionInterface |
|
85 | - * @throws RedirectionExceptionInterface |
|
86 | - * @throws ServerExceptionInterface |
|
87 | - * @throws TransportExceptionInterface |
|
88 | - */ |
|
89 | - private function getToken() |
|
90 | - { |
|
91 | - $token = null; |
|
92 | - $response = $this->client->request("GET", $this->package->getProjectUrl()."ribs-admin/packages/dist/send-token/"); |
|
93 | - $datas = $response->getStatusCode() == 200 ? $response->getContent() : null; |
|
94 | - |
|
95 | - if ($datas) { |
|
96 | - $token = json_decode($datas, true)["token"]; |
|
97 | - } |
|
98 | - |
|
99 | - return $token; |
|
100 | - } |
|
101 | - |
|
102 | - /** |
|
103 | - * @return mixed|null |
|
104 | - * @throws ClientExceptionInterface |
|
105 | - * @throws RedirectionExceptionInterface |
|
106 | - * @throws ServerExceptionInterface |
|
107 | - * @throws TransportExceptionInterface |
|
108 | - */ |
|
109 | - private function getComposerLockJson() |
|
110 | - { |
|
111 | - if ($this->package && !$this->package->isIsLocal()) { |
|
112 | - $response = $this->client->request("GET", $this->package->getProjectUrl().$this->package->getComposerLockUrl()); |
|
113 | - $composer_lock = $response->getStatusCode() == 200 ? $response->getContent() : null; |
|
114 | - } else { |
|
115 | - $composer_lock = file_get_contents('../composer.lock'); |
|
116 | - } |
|
117 | - |
|
118 | - if ($composer_lock) { |
|
119 | - return json_decode($composer_lock, true); |
|
120 | - } |
|
121 | - |
|
122 | - return null; |
|
123 | - } |
|
124 | - |
|
125 | - /** |
|
126 | - * @return mixed|null |
|
127 | - * @throws ClientExceptionInterface |
|
128 | - * @throws RedirectionExceptionInterface |
|
129 | - * @throws ServerExceptionInterface |
|
130 | - * @throws TransportExceptionInterface |
|
131 | - */ |
|
132 | - public function getPackage() |
|
133 | - { |
|
134 | - $composer_lock = $this->getComposerLockJson(); |
|
135 | - if ($composer_lock) { |
|
136 | - $packages = $composer_lock["packages"]; |
|
137 | - $key = array_search($this->package->getPackageName(), array_column($packages, 'name')); |
|
138 | - |
|
139 | - if ($key) { |
|
140 | - return $packages[$key]; |
|
141 | - } |
|
142 | - } |
|
143 | - |
|
144 | - $this->messages["composer_lock"] = "Composer lock not found at " . $this->package->getProjectUrl(); |
|
145 | - |
|
146 | - return null; |
|
147 | - } |
|
148 | - |
|
149 | - /** |
|
150 | - * @return mixed|null |
|
151 | - * @throws ClientExceptionInterface |
|
152 | - * @throws RedirectionExceptionInterface |
|
153 | - * @throws ServerExceptionInterface |
|
154 | - * @throws TransportExceptionInterface |
|
155 | - */ |
|
156 | - public function getVersion() |
|
157 | - { |
|
158 | - return $this->getPackage($this->package->getPackageName()) ? $this->getPackage($this->package->getPackageName())["version"] : null; |
|
159 | - } |
|
160 | - |
|
161 | - /** |
|
162 | - * @return DateTime|null |
|
163 | - * @throws Exception |
|
164 | - */ |
|
165 | - public function getVersionDate(): ?DateTime |
|
166 | - { |
|
167 | - $string_date = $this->getPackage($this->package->getPackageName()) ? explode("T", $this->getPackage($this->package->getPackageName())["time"])[0] : null; |
|
168 | - $version_date = null; |
|
169 | - |
|
170 | - if ($string_date) { |
|
171 | - $version_date = new DateTime($string_date); |
|
172 | - } |
|
173 | - |
|
174 | - return $version_date; |
|
175 | - } |
|
176 | - |
|
177 | - /** |
|
178 | - * @param string $guid |
|
179 | - * @param string $version |
|
180 | - * @return string|void|null |
|
181 | - * @throws ClientExceptionInterface |
|
182 | - * @throws RedirectionExceptionInterface |
|
183 | - * @throws ServerExceptionInterface |
|
184 | - * @throws TransportExceptionInterface |
|
185 | - */ |
|
186 | - public function updatePackage(string $guid, string $version) |
|
187 | - { |
|
188 | - $package = $this->em->getRepository(Package::class)->findOneBy(["guid" => $guid]); |
|
189 | - |
|
190 | - if ($package) { |
|
191 | - $this->setPackageEntity($package); |
|
192 | - |
|
193 | - if (!$this->getToken() || $this->getToken() !== $this->local_token) { |
|
194 | - $this->messages["token_error"] = "Token not matching on : " . $this->package->getProjectUrl(); |
|
195 | - return; |
|
196 | - } |
|
197 | - |
|
198 | - $response = $this->client->request("GET", $this->package->getProjectUrl().'ribs-admin/packages/dist/change-version/'.$package->getPackageName().':'.$version); |
|
199 | - $this->save($guid); |
|
200 | - |
|
201 | - return $response->getStatusCode() == 200 ? $response->getContent() : null; |
|
202 | - } |
|
203 | - } |
|
204 | - |
|
205 | - /** |
|
206 | - * @param string $package_guid |
|
207 | - * @throws ClientExceptionInterface |
|
208 | - * @throws RedirectionExceptionInterface |
|
209 | - * @throws ServerExceptionInterface |
|
210 | - * @throws TransportExceptionInterface |
|
211 | - */ |
|
212 | - public function save(string $package_guid) |
|
213 | - { |
|
214 | - $package = $this->em->getRepository(Package::class)->findOneBy(["guid" => $package_guid]); |
|
215 | - |
|
216 | - if ($package) { |
|
217 | - $this->setPackageEntity($package); |
|
218 | - |
|
219 | - if (!$this->getToken() || $this->getToken() !== $this->local_token) { |
|
220 | - $this->messages["token_error"] = "Token not matching on : " . $this->package->getProjectUrl(); |
|
221 | - return; |
|
222 | - } |
|
223 | - |
|
224 | - $package->setVersion($this->getVersion()); |
|
225 | - $package->setVersionDate($this->getVersionDate()); |
|
226 | - $package->setLastPackagistVersion($this->packagist->getLastPackagistVersion($package->getPackageName())); |
|
227 | - $package->setLastCheck(new DateTime()); |
|
228 | - |
|
229 | - $this->em->persist($package); |
|
230 | - $this->em->flush(); |
|
231 | - } |
|
232 | - } |
|
18 | + /** |
|
19 | + * @var EntityManagerInterface |
|
20 | + */ |
|
21 | + private $em; |
|
22 | + |
|
23 | + /** |
|
24 | + * @var HttpClientInterface |
|
25 | + */ |
|
26 | + private $client; |
|
27 | + |
|
28 | + /** |
|
29 | + * @var ParameterBagInterface |
|
30 | + */ |
|
31 | + private $parameter; |
|
32 | + |
|
33 | + /** |
|
34 | + * @var PackagistApi |
|
35 | + */ |
|
36 | + private $packagist; |
|
37 | + |
|
38 | + /** |
|
39 | + * @var mixed |
|
40 | + */ |
|
41 | + private $local_token; |
|
42 | + |
|
43 | + /** |
|
44 | + * @var Package |
|
45 | + */ |
|
46 | + private $package; |
|
47 | + |
|
48 | + private $messages = []; |
|
49 | + |
|
50 | + /** |
|
51 | + * Version constructor. |
|
52 | + * @param EntityManagerInterface $em |
|
53 | + * @param HttpClientInterface $client |
|
54 | + * @param ParameterBagInterface $parameter |
|
55 | + * @param PackagistApi $packagist |
|
56 | + */ |
|
57 | + public function __construct(EntityManagerInterface $em, HttpClientInterface $client, ParameterBagInterface $parameter, PackagistApi $packagist) |
|
58 | + { |
|
59 | + $this->em = $em; |
|
60 | + $this->client = $client; |
|
61 | + $this->parameter = $parameter; |
|
62 | + $this->packagist = $packagist; |
|
63 | + $this->local_token = $parameter->get("ribs_admin.packages_token"); |
|
64 | + } |
|
65 | + |
|
66 | + /** |
|
67 | + * @return array |
|
68 | + */ |
|
69 | + public function getMessages(): array |
|
70 | + { |
|
71 | + return $this->messages; |
|
72 | + } |
|
73 | + |
|
74 | + /** |
|
75 | + * @param Package $package |
|
76 | + */ |
|
77 | + public function setPackageEntity(Package $package) |
|
78 | + { |
|
79 | + $this->package = $package; |
|
80 | + } |
|
81 | + |
|
82 | + /** |
|
83 | + * @return mixed|null |
|
84 | + * @throws ClientExceptionInterface |
|
85 | + * @throws RedirectionExceptionInterface |
|
86 | + * @throws ServerExceptionInterface |
|
87 | + * @throws TransportExceptionInterface |
|
88 | + */ |
|
89 | + private function getToken() |
|
90 | + { |
|
91 | + $token = null; |
|
92 | + $response = $this->client->request("GET", $this->package->getProjectUrl()."ribs-admin/packages/dist/send-token/"); |
|
93 | + $datas = $response->getStatusCode() == 200 ? $response->getContent() : null; |
|
94 | + |
|
95 | + if ($datas) { |
|
96 | + $token = json_decode($datas, true)["token"]; |
|
97 | + } |
|
98 | + |
|
99 | + return $token; |
|
100 | + } |
|
101 | + |
|
102 | + /** |
|
103 | + * @return mixed|null |
|
104 | + * @throws ClientExceptionInterface |
|
105 | + * @throws RedirectionExceptionInterface |
|
106 | + * @throws ServerExceptionInterface |
|
107 | + * @throws TransportExceptionInterface |
|
108 | + */ |
|
109 | + private function getComposerLockJson() |
|
110 | + { |
|
111 | + if ($this->package && !$this->package->isIsLocal()) { |
|
112 | + $response = $this->client->request("GET", $this->package->getProjectUrl().$this->package->getComposerLockUrl()); |
|
113 | + $composer_lock = $response->getStatusCode() == 200 ? $response->getContent() : null; |
|
114 | + } else { |
|
115 | + $composer_lock = file_get_contents('../composer.lock'); |
|
116 | + } |
|
117 | + |
|
118 | + if ($composer_lock) { |
|
119 | + return json_decode($composer_lock, true); |
|
120 | + } |
|
121 | + |
|
122 | + return null; |
|
123 | + } |
|
124 | + |
|
125 | + /** |
|
126 | + * @return mixed|null |
|
127 | + * @throws ClientExceptionInterface |
|
128 | + * @throws RedirectionExceptionInterface |
|
129 | + * @throws ServerExceptionInterface |
|
130 | + * @throws TransportExceptionInterface |
|
131 | + */ |
|
132 | + public function getPackage() |
|
133 | + { |
|
134 | + $composer_lock = $this->getComposerLockJson(); |
|
135 | + if ($composer_lock) { |
|
136 | + $packages = $composer_lock["packages"]; |
|
137 | + $key = array_search($this->package->getPackageName(), array_column($packages, 'name')); |
|
138 | + |
|
139 | + if ($key) { |
|
140 | + return $packages[$key]; |
|
141 | + } |
|
142 | + } |
|
143 | + |
|
144 | + $this->messages["composer_lock"] = "Composer lock not found at " . $this->package->getProjectUrl(); |
|
145 | + |
|
146 | + return null; |
|
147 | + } |
|
148 | + |
|
149 | + /** |
|
150 | + * @return mixed|null |
|
151 | + * @throws ClientExceptionInterface |
|
152 | + * @throws RedirectionExceptionInterface |
|
153 | + * @throws ServerExceptionInterface |
|
154 | + * @throws TransportExceptionInterface |
|
155 | + */ |
|
156 | + public function getVersion() |
|
157 | + { |
|
158 | + return $this->getPackage($this->package->getPackageName()) ? $this->getPackage($this->package->getPackageName())["version"] : null; |
|
159 | + } |
|
160 | + |
|
161 | + /** |
|
162 | + * @return DateTime|null |
|
163 | + * @throws Exception |
|
164 | + */ |
|
165 | + public function getVersionDate(): ?DateTime |
|
166 | + { |
|
167 | + $string_date = $this->getPackage($this->package->getPackageName()) ? explode("T", $this->getPackage($this->package->getPackageName())["time"])[0] : null; |
|
168 | + $version_date = null; |
|
169 | + |
|
170 | + if ($string_date) { |
|
171 | + $version_date = new DateTime($string_date); |
|
172 | + } |
|
173 | + |
|
174 | + return $version_date; |
|
175 | + } |
|
176 | + |
|
177 | + /** |
|
178 | + * @param string $guid |
|
179 | + * @param string $version |
|
180 | + * @return string|void|null |
|
181 | + * @throws ClientExceptionInterface |
|
182 | + * @throws RedirectionExceptionInterface |
|
183 | + * @throws ServerExceptionInterface |
|
184 | + * @throws TransportExceptionInterface |
|
185 | + */ |
|
186 | + public function updatePackage(string $guid, string $version) |
|
187 | + { |
|
188 | + $package = $this->em->getRepository(Package::class)->findOneBy(["guid" => $guid]); |
|
189 | + |
|
190 | + if ($package) { |
|
191 | + $this->setPackageEntity($package); |
|
192 | + |
|
193 | + if (!$this->getToken() || $this->getToken() !== $this->local_token) { |
|
194 | + $this->messages["token_error"] = "Token not matching on : " . $this->package->getProjectUrl(); |
|
195 | + return; |
|
196 | + } |
|
197 | + |
|
198 | + $response = $this->client->request("GET", $this->package->getProjectUrl().'ribs-admin/packages/dist/change-version/'.$package->getPackageName().':'.$version); |
|
199 | + $this->save($guid); |
|
200 | + |
|
201 | + return $response->getStatusCode() == 200 ? $response->getContent() : null; |
|
202 | + } |
|
203 | + } |
|
204 | + |
|
205 | + /** |
|
206 | + * @param string $package_guid |
|
207 | + * @throws ClientExceptionInterface |
|
208 | + * @throws RedirectionExceptionInterface |
|
209 | + * @throws ServerExceptionInterface |
|
210 | + * @throws TransportExceptionInterface |
|
211 | + */ |
|
212 | + public function save(string $package_guid) |
|
213 | + { |
|
214 | + $package = $this->em->getRepository(Package::class)->findOneBy(["guid" => $package_guid]); |
|
215 | + |
|
216 | + if ($package) { |
|
217 | + $this->setPackageEntity($package); |
|
218 | + |
|
219 | + if (!$this->getToken() || $this->getToken() !== $this->local_token) { |
|
220 | + $this->messages["token_error"] = "Token not matching on : " . $this->package->getProjectUrl(); |
|
221 | + return; |
|
222 | + } |
|
223 | + |
|
224 | + $package->setVersion($this->getVersion()); |
|
225 | + $package->setVersionDate($this->getVersionDate()); |
|
226 | + $package->setLastPackagistVersion($this->packagist->getLastPackagistVersion($package->getPackageName())); |
|
227 | + $package->setLastCheck(new DateTime()); |
|
228 | + |
|
229 | + $this->em->persist($package); |
|
230 | + $this->em->flush(); |
|
231 | + } |
|
232 | + } |
|
233 | 233 | } |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | private function getToken() |
90 | 90 | { |
91 | 91 | $token = null; |
92 | - $response = $this->client->request("GET", $this->package->getProjectUrl()."ribs-admin/packages/dist/send-token/"); |
|
92 | + $response = $this->client->request("GET", $this->package->getProjectUrl() . "ribs-admin/packages/dist/send-token/"); |
|
93 | 93 | $datas = $response->getStatusCode() == 200 ? $response->getContent() : null; |
94 | 94 | |
95 | 95 | if ($datas) { |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | private function getComposerLockJson() |
110 | 110 | { |
111 | 111 | if ($this->package && !$this->package->isIsLocal()) { |
112 | - $response = $this->client->request("GET", $this->package->getProjectUrl().$this->package->getComposerLockUrl()); |
|
112 | + $response = $this->client->request("GET", $this->package->getProjectUrl() . $this->package->getComposerLockUrl()); |
|
113 | 113 | $composer_lock = $response->getStatusCode() == 200 ? $response->getContent() : null; |
114 | 114 | } else { |
115 | 115 | $composer_lock = file_get_contents('../composer.lock'); |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | return; |
196 | 196 | } |
197 | 197 | |
198 | - $response = $this->client->request("GET", $this->package->getProjectUrl().'ribs-admin/packages/dist/change-version/'.$package->getPackageName().':'.$version); |
|
198 | + $response = $this->client->request("GET", $this->package->getProjectUrl() . 'ribs-admin/packages/dist/change-version/' . $package->getPackageName() . ':' . $version); |
|
199 | 199 | $this->save($guid); |
200 | 200 | |
201 | 201 | return $response->getStatusCode() == 200 ? $response->getContent() : null; |
@@ -19,78 +19,78 @@ |
||
19 | 19 | |
20 | 20 | class PackagesDistController extends AbstractController |
21 | 21 | { |
22 | - /** |
|
23 | - * @Route("/packages/dist/send-package/{package_name}", name="ribsadmin_packages_dist_send", requirements={"package_name"=".+"}) |
|
24 | - * @param EntityManagerInterface $em |
|
25 | - * @param Version $version |
|
26 | - * @param string $package_name |
|
27 | - * @return mixed|null |
|
28 | - * @throws Exception |
|
29 | - */ |
|
30 | - public function sendPackageInformations(EntityManagerInterface $em, Version $version, string $package_name): JsonResponse |
|
31 | - { |
|
32 | - $package = $em->getRepository(Package::class)->findOneBy(["package_name" => $package_name]); |
|
22 | + /** |
|
23 | + * @Route("/packages/dist/send-package/{package_name}", name="ribsadmin_packages_dist_send", requirements={"package_name"=".+"}) |
|
24 | + * @param EntityManagerInterface $em |
|
25 | + * @param Version $version |
|
26 | + * @param string $package_name |
|
27 | + * @return mixed|null |
|
28 | + * @throws Exception |
|
29 | + */ |
|
30 | + public function sendPackageInformations(EntityManagerInterface $em, Version $version, string $package_name): JsonResponse |
|
31 | + { |
|
32 | + $package = $em->getRepository(Package::class)->findOneBy(["package_name" => $package_name]); |
|
33 | 33 | |
34 | - if ($package) { |
|
35 | - $version->setPackageEntity($package); |
|
36 | - } |
|
34 | + if ($package) { |
|
35 | + $version->setPackageEntity($package); |
|
36 | + } |
|
37 | 37 | |
38 | - return new JsonResponse([ |
|
39 | - "package" => $version->getPackage(), |
|
40 | - "package_date" => $version->getVersionDate() |
|
41 | - ]); |
|
42 | - } |
|
38 | + return new JsonResponse([ |
|
39 | + "package" => $version->getPackage(), |
|
40 | + "package_date" => $version->getVersionDate() |
|
41 | + ]); |
|
42 | + } |
|
43 | 43 | |
44 | - /** |
|
45 | - * @Route("/packages/dist/send-composer-lock/", name="ribsadmin_packages_dist_send_composer_lock") |
|
46 | - * @return JsonResponse |
|
47 | - */ |
|
48 | - public function sendComposerJson(): JsonResponse |
|
49 | - { |
|
50 | - $composer_lock = file_get_contents('../composer.lock'); |
|
44 | + /** |
|
45 | + * @Route("/packages/dist/send-composer-lock/", name="ribsadmin_packages_dist_send_composer_lock") |
|
46 | + * @return JsonResponse |
|
47 | + */ |
|
48 | + public function sendComposerJson(): JsonResponse |
|
49 | + { |
|
50 | + $composer_lock = file_get_contents('../composer.lock'); |
|
51 | 51 | |
52 | - if ($composer_lock) { |
|
53 | - $composer_lock = json_decode($composer_lock); |
|
54 | - } |
|
52 | + if ($composer_lock) { |
|
53 | + $composer_lock = json_decode($composer_lock); |
|
54 | + } |
|
55 | 55 | |
56 | - return new JsonResponse($composer_lock); |
|
57 | - } |
|
56 | + return new JsonResponse($composer_lock); |
|
57 | + } |
|
58 | 58 | |
59 | - /** |
|
60 | - * @Route("/packages/dist/send-token/", name="ribsadmin_packages_dist_send_token") |
|
61 | - * @param ParameterBagInterface $parameter |
|
62 | - * @return JsonResponse |
|
63 | - */ |
|
64 | - public function sendToken(ParameterBagInterface $parameter): JsonResponse |
|
65 | - { |
|
66 | - return new JsonResponse([ |
|
67 | - "token" => $parameter->get("ribs_admin.packages_token") |
|
68 | - ]); |
|
69 | - } |
|
59 | + /** |
|
60 | + * @Route("/packages/dist/send-token/", name="ribsadmin_packages_dist_send_token") |
|
61 | + * @param ParameterBagInterface $parameter |
|
62 | + * @return JsonResponse |
|
63 | + */ |
|
64 | + public function sendToken(ParameterBagInterface $parameter): JsonResponse |
|
65 | + { |
|
66 | + return new JsonResponse([ |
|
67 | + "token" => $parameter->get("ribs_admin.packages_token") |
|
68 | + ]); |
|
69 | + } |
|
70 | 70 | |
71 | - /** |
|
72 | - * @Route("/packages/dist/change-version/{package_name}", name="ribsadmin_packages_dist_change_version", requirements={"package_name"=".+"}) |
|
73 | - * @param KernelInterface $kernel |
|
74 | - * @param string $package_name |
|
75 | - * @return JsonResponse |
|
76 | - * @throws Exception |
|
77 | - */ |
|
78 | - public function changePackageVersion(KernelInterface $kernel, string $package_name): JsonResponse |
|
79 | - { |
|
80 | - $application = new Application($kernel); |
|
81 | - $application->setAutoExit(false); |
|
71 | + /** |
|
72 | + * @Route("/packages/dist/change-version/{package_name}", name="ribsadmin_packages_dist_change_version", requirements={"package_name"=".+"}) |
|
73 | + * @param KernelInterface $kernel |
|
74 | + * @param string $package_name |
|
75 | + * @return JsonResponse |
|
76 | + * @throws Exception |
|
77 | + */ |
|
78 | + public function changePackageVersion(KernelInterface $kernel, string $package_name): JsonResponse |
|
79 | + { |
|
80 | + $application = new Application($kernel); |
|
81 | + $application->setAutoExit(false); |
|
82 | 82 | |
83 | - $input = new ArrayInput([ |
|
84 | - 'command' => 'ribsadmin:change-package-version', |
|
85 | - 'package-name' => $package_name, |
|
86 | - ]); |
|
83 | + $input = new ArrayInput([ |
|
84 | + 'command' => 'ribsadmin:change-package-version', |
|
85 | + 'package-name' => $package_name, |
|
86 | + ]); |
|
87 | 87 | |
88 | - $output = new BufferedOutput(OutputInterface::VERBOSITY_NORMAL, true); |
|
89 | - $application->run($input, $output); |
|
88 | + $output = new BufferedOutput(OutputInterface::VERBOSITY_NORMAL, true); |
|
89 | + $application->run($input, $output); |
|
90 | 90 | |
91 | - $converter = new AnsiToHtmlConverter(); |
|
92 | - $content = $output->fetch(); |
|
91 | + $converter = new AnsiToHtmlConverter(); |
|
92 | + $content = $output->fetch(); |
|
93 | 93 | |
94 | - return new JsonResponse($converter->convert($content)); |
|
95 | - } |
|
94 | + return new JsonResponse($converter->convert($content)); |
|
95 | + } |
|
96 | 96 | } |
@@ -12,59 +12,59 @@ |
||
12 | 12 | |
13 | 13 | class ChangePackageVersionCommand extends Command |
14 | 14 | { |
15 | - protected function configure() |
|
16 | - { |
|
17 | - $this |
|
18 | - ->setName('ribsadmin:change-package-version') |
|
19 | - ->setDescription('Change a package version') |
|
20 | - ->addArgument( |
|
21 | - 'package-name', |
|
22 | - InputArgument::REQUIRED, |
|
23 | - 'Name of composer package to import with version (example : piou/piou/test-bundle:1.0.0)' |
|
24 | - ) |
|
25 | - ; |
|
26 | - } |
|
15 | + protected function configure() |
|
16 | + { |
|
17 | + $this |
|
18 | + ->setName('ribsadmin:change-package-version') |
|
19 | + ->setDescription('Change a package version') |
|
20 | + ->addArgument( |
|
21 | + 'package-name', |
|
22 | + InputArgument::REQUIRED, |
|
23 | + 'Name of composer package to import with version (example : piou/piou/test-bundle:1.0.0)' |
|
24 | + ) |
|
25 | + ; |
|
26 | + } |
|
27 | 27 | |
28 | - protected function execute(InputInterface $input, OutputInterface $output) |
|
29 | - { |
|
30 | - $fs = new Filesystem(); |
|
31 | - $cd = ""; |
|
28 | + protected function execute(InputInterface $input, OutputInterface $output) |
|
29 | + { |
|
30 | + $fs = new Filesystem(); |
|
31 | + $cd = ""; |
|
32 | 32 | |
33 | - if (!$fs->exists("composer.json") && $fs->exists("index.php")) { |
|
34 | - $cd = "cd .. && "; |
|
35 | - } |
|
33 | + if (!$fs->exists("composer.json") && $fs->exists("index.php")) { |
|
34 | + $cd = "cd .. && "; |
|
35 | + } |
|
36 | 36 | |
37 | - $package_name = $input->getArgument('package-name'); |
|
37 | + $package_name = $input->getArgument('package-name'); |
|
38 | 38 | |
39 | - $process = Process::fromShellCommandline("echo Start composer require " . $package_name); |
|
40 | - $process->run(function ($type, $buffer) { |
|
41 | - echo $buffer; |
|
42 | - }); |
|
39 | + $process = Process::fromShellCommandline("echo Start composer require " . $package_name); |
|
40 | + $process->run(function ($type, $buffer) { |
|
41 | + echo $buffer; |
|
42 | + }); |
|
43 | 43 | |
44 | - $process = Process::fromShellCommandline($cd . "chmod 777 composer.json"); |
|
45 | - $process->run(function ($type, $buffer) { |
|
46 | - echo $buffer; |
|
47 | - }); |
|
44 | + $process = Process::fromShellCommandline($cd . "chmod 777 composer.json"); |
|
45 | + $process->run(function ($type, $buffer) { |
|
46 | + echo $buffer; |
|
47 | + }); |
|
48 | 48 | |
49 | - $process = Process::fromShellCommandline($cd . "composer require " . $package_name); |
|
50 | - $process->run(function ($type, $buffer) { |
|
51 | - echo $buffer; |
|
52 | - }); |
|
49 | + $process = Process::fromShellCommandline($cd . "composer require " . $package_name); |
|
50 | + $process->run(function ($type, $buffer) { |
|
51 | + echo $buffer; |
|
52 | + }); |
|
53 | 53 | |
54 | - if (!$process->isSuccessful()) { |
|
55 | - throw new ProcessFailedException($process); |
|
56 | - } |
|
54 | + if (!$process->isSuccessful()) { |
|
55 | + throw new ProcessFailedException($process); |
|
56 | + } |
|
57 | 57 | |
58 | - $process = Process::fromShellCommandline($cd . "chmod 644 composer.json"); |
|
59 | - $process->run(function ($type, $buffer) { |
|
60 | - echo $buffer; |
|
61 | - }); |
|
58 | + $process = Process::fromShellCommandline($cd . "chmod 644 composer.json"); |
|
59 | + $process->run(function ($type, $buffer) { |
|
60 | + echo $buffer; |
|
61 | + }); |
|
62 | 62 | |
63 | - $process = Process::fromShellCommandline("echo Change version of " . $package_name . " is finished."); |
|
64 | - $process->run(function ($type, $buffer) { |
|
65 | - echo $buffer; |
|
66 | - }); |
|
63 | + $process = Process::fromShellCommandline("echo Change version of " . $package_name . " is finished."); |
|
64 | + $process->run(function ($type, $buffer) { |
|
65 | + echo $buffer; |
|
66 | + }); |
|
67 | 67 | |
68 | - return 0; |
|
69 | - } |
|
68 | + return 0; |
|
69 | + } |
|
70 | 70 | } |
@@ -37,17 +37,17 @@ discard block |
||
37 | 37 | $package_name = $input->getArgument('package-name'); |
38 | 38 | |
39 | 39 | $process = Process::fromShellCommandline("echo Start composer require " . $package_name); |
40 | - $process->run(function ($type, $buffer) { |
|
40 | + $process->run(function($type, $buffer) { |
|
41 | 41 | echo $buffer; |
42 | 42 | }); |
43 | 43 | |
44 | 44 | $process = Process::fromShellCommandline($cd . "chmod 777 composer.json"); |
45 | - $process->run(function ($type, $buffer) { |
|
45 | + $process->run(function($type, $buffer) { |
|
46 | 46 | echo $buffer; |
47 | 47 | }); |
48 | 48 | |
49 | 49 | $process = Process::fromShellCommandline($cd . "composer require " . $package_name); |
50 | - $process->run(function ($type, $buffer) { |
|
50 | + $process->run(function($type, $buffer) { |
|
51 | 51 | echo $buffer; |
52 | 52 | }); |
53 | 53 | |
@@ -56,12 +56,12 @@ discard block |
||
56 | 56 | } |
57 | 57 | |
58 | 58 | $process = Process::fromShellCommandline($cd . "chmod 644 composer.json"); |
59 | - $process->run(function ($type, $buffer) { |
|
59 | + $process->run(function($type, $buffer) { |
|
60 | 60 | echo $buffer; |
61 | 61 | }); |
62 | 62 | |
63 | 63 | $process = Process::fromShellCommandline("echo Change version of " . $package_name . " is finished."); |
64 | - $process->run(function ($type, $buffer) { |
|
64 | + $process->run(function($type, $buffer) { |
|
65 | 65 | echo $buffer; |
66 | 66 | }); |
67 | 67 |