1 | <?php |
||
23 | class InitController extends \yii\console\Controller |
||
24 | { |
||
25 | /** |
||
26 | * @var string package full name like: vendor/package |
||
27 | */ |
||
28 | public $name; |
||
29 | |||
30 | /** |
||
31 | * @var string package type e.g.: package, yii2-extension |
||
32 | */ |
||
33 | public $type; |
||
34 | |||
35 | public $title; |
||
36 | public $package; |
||
37 | public $license; |
||
38 | public $headline; |
||
39 | public $keywords; |
||
40 | public $namespace; |
||
41 | public $description; |
||
42 | |||
43 | public $vendor; |
||
44 | public $nick; |
||
45 | public $author; |
||
46 | public $email; |
||
47 | |||
48 | public $vendorRequire; |
||
49 | |||
50 | /** |
||
51 | * @var bool don't put vendor config |
||
52 | */ |
||
53 | public $noVendor; |
||
54 | /** |
||
55 | * @var bool don't put requires |
||
56 | */ |
||
57 | public $noRequire; |
||
58 | |||
59 | /** |
||
60 | * @var bool don't generate `composer.json` file |
||
61 | */ |
||
62 | public $noComposer; |
||
63 | |||
64 | 3 | public function options($actionId) |
|
71 | |||
72 | 3 | public function prepareData($name) |
|
96 | |||
97 | /** |
||
98 | * Creates initial configuration for hidev: `hidev.yml` and `composer.json`. |
||
99 | * @param string $name package full name like: vendor/package |
||
100 | */ |
||
101 | 3 | public function actionIndex($name = null) |
|
110 | |||
111 | public function actionComposer() |
||
112 | { |
||
113 | return $this->writeComposer(); |
||
114 | } |
||
115 | |||
116 | 3 | public function writeConfig($path = 'hidev.yml') |
|
117 | { |
||
118 | 3 | $file = new File(['path' => $path]); |
|
119 | 3 | $file->save(array_filter([ |
|
120 | 3 | 'package' => array_filter([ |
|
121 | 3 | 'type' => $this->getType(), |
|
122 | 3 | 'name' => $this->package, |
|
123 | 3 | 'title' => $this->getTitle(), |
|
124 | 3 | 'license' => $this->license, |
|
125 | 3 | 'headline' => $this->headline, |
|
126 | 3 | 'keywords' => $this->getKeywords(), |
|
127 | 3 | 'namespace' => $this->namespace, |
|
128 | 3 | 'description' => $this->description, |
|
129 | 2 | ]), |
|
130 | 3 | 'vendor' => $this->noVendor ? null : array_filter([ |
|
131 | 1 | 'name' => $this->vendor, |
|
132 | 1 | 'authors' => array_filter([ |
|
133 | 1 | $this->getNick() => [ |
|
134 | 1 | 'name' => $this->getAuthor(), |
|
135 | 3 | 'email' => $this->getEmail(), |
|
136 | ], |
||
137 | ]), |
||
138 | ]), |
||
139 | ])); |
||
140 | 3 | } |
|
141 | |||
142 | 2 | public function writeComposer($path = 'composer.json') |
|
154 | |||
155 | 3 | public function getType() |
|
159 | |||
160 | 3 | public function getTitle() |
|
164 | |||
165 | 3 | public function getKeywords() |
|
169 | |||
170 | /// TODO think of better getting nick |
||
171 | 1 | public function getNick() |
|
175 | |||
176 | 1 | public function getAuthor() |
|
180 | |||
181 | 1 | public function getEmail() |
|
185 | |||
186 | /** |
||
187 | * Returns list of plugins in composer requirements format: name => version. |
||
188 | * @return array |
||
189 | */ |
||
190 | 2 | public function getPlugins() |
|
204 | } |
||
205 |