-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlotgd-skeleton.php
171 lines (139 loc) · 4.89 KB
/
lotgd-skeleton.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
<?php
namespace LoTGD;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Finder\Finder;
class Skeleton
{
public static function skeleton(): void
{
echo "\n";
echo 'Coping files of LoTGD Core to Skeleton for active commands in local dev.';
echo "\n";
$fs = new FileSystem();
//-- ./bin folder with console app
$fs->mirror('vendor/idmarinas/lotgd/bin', './bin', null, ['delete' => true, 'override' => true]);
//-- src core files
$fs->remove('./src/core');
$fs->mirror('vendor/idmarinas/lotgd/src/core', './src/core', null, ['delete' => true, 'override' => true]);
echo "\n";
echo 'Finish copy files';
}
public static function core(): void
{
echo "\n";
echo 'Coping files of LoTGD Core to "_core_files/" folder';
echo "\n";
$fs = new FileSystem();
//-- Copy main files
$finder = (new Finder())->ignoreUnreadableDirs()
->directories()
->in('vendor/idmarinas/lotgd')
->exclude([
'assets',
'docs',
'gulp',
'release',
'vendor',
])
;
foreach ($finder as $dir)
{
$fs->mirror($dir, \str_replace('vendor/idmarinas/lotgd', './_core_files', $dir), null, ['delete' => true, 'override' => true]);
}
//-- Other files
$files = [
'.env',
'composer.json',
'lotgd-check-requeriments.php',
'symfony.lock',
];
foreach ($files as $file)
{
$fs->copy('vendor/idmarinas/lotgd/'.$file, './_core_files/'.$file, true);
}
//-- Copy Assets folders
$finder = (new Finder())->ignoreUnreadableDirs()
->directories()
->in('vendor/idmarinas/lotgd/assets')
;
foreach ($finder as $dir)
{
$fs->mirror($dir, \str_replace('vendor/idmarinas/lotgd/assets', './assets', $dir), null, ['delete' => true, 'override' => true]);
}
//-- Copy Assets files
$finder = (new Finder())->ignoreUnreadableDirs()
->in('vendor/idmarinas/lotgd/assets/')
->depth('== 0')
->files()
;
foreach ($finder as $file)
{
$fs->copy($file, \str_replace('vendor/idmarinas/lotgd/assets', './assets', $file), true);
}
//-- Copy config folder
$finder = (new Finder())->ignoreUnreadableDirs()
->directories()
->in('vendor/idmarinas/lotgd/config/')
;
foreach ($finder as $dir)
{
$fs->mirror($dir, \str_replace('vendor/idmarinas/lotgd/config', './config', $dir), null, ['delete' => true, 'override' => true]);
}
//-- Copy config files
$finder = (new Finder())->ignoreUnreadableDirs()
->in('vendor/idmarinas/lotgd/config/')
->depth('== 0')
->files()
;
foreach ($finder as $file)
{
$fs->copy($file, \str_replace('vendor/idmarinas/lotgd/config', './config', $file), true);
}
echo "\n";
echo 'Finish coping files of LoTGD Core to "_core_files/" folder';
}
public static function upgrade()
{
echo "\n";
echo 'Upgrading files of LoTGD Core Skeleton';
echo "\n";
$fs = new FileSystem();
$files = (new Finder())->ignoreUnreadableDirs()
->in('vendor/idmarinas/lotgd')
->files()
->name('package.json')
->name('CHANGELOG-*.md')
->name('lotgd-check-requeriments.php')
->notName('CHANGELOG-dev.md')
;
foreach ($files as $file)
{
$fs->copy($file, \str_replace('vendor/idmarinas/lotgd', './', $file));
}
$files = (new Finder())->ignoreUnreadableDirs()
->in('vendor/idmarinas/lotgd-skeleton')
->files()
->name('composer.json')
->name('README.md')
->name('lotgd-skeleton.php')
;
foreach ($files as $file)
{
$fs->copy($file, \str_replace('vendor/idmarinas/lotgd-skeleton', './', $file));
}
//-- Copy gulp folder
$finder = (new Finder())->ignoreUnreadableDirs()
->directories()
->in('vendor/idmarinas/lotgd-skeleton/gulp/')
;
foreach ($finder as $dir)
{
$fs->mirror($dir, \str_replace('vendor/idmarinas/lotgd-skeleton/gulp', './gulp', $dir), null, ['delete' => true, 'override' => true]);
}
//-- Update translations
//-- Need add translations for modules other time
$fs->mirror('vendor/idmarinas/lotgd/translations/en', './translations/en', null, ['delete' => true, 'override' => true]);
echo "\n";
echo 'Finish upgrading files';
}
}