/
packer
102 lines (81 loc) · 3.14 KB
/
packer
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
#!/usr/bin/env php
<?php
/*
|--------------------------------------------------------------------------
| How to use
|--------------------------------------------------------------------------
|
| Fill config variables and execute `php packer`
|
*/
/*
|--------------------------------------------------------------------------
| Config
|--------------------------------------------------------------------------
|
| Declaring a package:
| 'mascame/artificer' => 'https://github.com/marcmascarell/laravel-artificer.git'
|
| Declaring a package with branch:
| 'mascame/artificer' => '-b dev https://github.com/marcmascarell/laravel-artificer.git'
|
*/
$packagesPath = 'workbench';
$packages = [
'mascame/artificer' => '-b dev https://github.com/marcmascarell/laravel-artificer.git',
'mascame/artificer-theme' => '-b l5-migration https://github.com/marcmascarell/artificer-default-theme.git',
'mascame/artificer-widgets' => '-b l5-migration https://github.com/marcmascarell/artificer-widgets.git',
'mascame/formality' => 'https://github.com/marcmascarell/formality.git',
'mascame/arrayer' => 'https://github.com/marcmascarell/arrayer.git',
'mascame/extender' => 'https://github.com/marcmascarell/extender.git',
'mascame/artificer-logreader-plugin' => '-b l5-migration https://github.com/marcmascarell/artificer-logreader-plugin.git',
'mascame/artificer-pagination-plugin' => '-b l5-migration https://github.com/marcmascarell/artificer-pagination-plugin.git',
// New since the l5 version (so no -b)
'mascame/artificer-login-plugin' => 'https://github.com/marcmascarell/artificer-login-plugin.git',
'mascame/hooky' => 'https://github.com/marcmascarell/hooky.git',
];
$mergerOptions = [
"include" => [
],
"require" => [
$packagesPath . "/*/*/composer.json"
],
"recurse" => true,
"replace" => true,
"merge-dev" => true,
"merge-extra" => false
];
/*
|--------------------------------------------------------------------------
| The script starts here
|--------------------------------------------------------------------------
*/
exec("php -r \"file_exists('.env') || copy('.env.example', '.env');\"");
$changes = false;
function getComposerData() {
$composer = file_get_contents("composer.json");
return json_decode($composer, true);
}
$composer = getComposerData();
// Does the merger plugin exist?
if (! isset($composer['extra']["merge-plugin"])) {
exec('composer require wikimedia/composer-merge-plugin --dev');
$composer = getComposerData();
if (! isset($composer['extra'])) {
$composer['extra'] = [];
}
$changes = true;
$composer['extra']["merge-plugin"] = $mergerOptions;
file_put_contents("composer.json", json_encode($composer, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES));
}
// Does the package exist?
foreach ($packages as $path => $repository) {
$packagePath = $packagesPath . DIRECTORY_SEPARATOR . $path;
if (file_exists($packagePath)) continue;
$changes = true;
exec("git clone {$repository} {$packagePath}");
}
if ($changes) {
exec("composer update");
}
print "\033[32mPacker: All done.\033[0m\n";