This repository has been archived by the owner on Jun 7, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
package.build.php
121 lines (98 loc) · 3.37 KB
/
package.build.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
<?php
use compress\ArchiveEntry;
use compress\Bzip2InputStream;
use compress\GzipInputStream;
use compress\Lz4InputStream;
use compress\TarArchive;
use compress\ZipArchive;
use packager\Event;
use packager\cli\Console;
use php\io\Stream;
use php\lib\arr;
use php\lib\fs;
use php\lib\str;
use php\util\Regex;
function task_publish(Event $e)
{
Tasks::runExternal('./designer', 'publish', [], ...$e->flags());
Tasks::runExternal('./dnd-gui-tabs-ext', 'publish', [], ...$e->flags());
}
/**
* @jppm-task prepare-ide
* @param Event $e
*/
function task_prepareIde(Event $e)
{
Tasks::run('publish', [], 'yes');
Tasks::runExternal("./ide", "update");
}
/**
* @jppm-task start-ide
* @jppm-description Start IDE (Nearde)
*/
function task_startIde(Event $e)
{
Tasks::runExternal('./ide', 'start', $e->args(), ...$e->flags());
}
/**
* @jppm-task fetch-messages
* @jppm-description Fetch all language messages from sources
*/
function task_fetchMessages($e)
{
$buildPath = $e->package()->getConfigBuildPath();
$regex = new Regex('(\\"|\\\')([a-z]+\\.[a-z0-9\\.]+)((\\:\\:)(.+?))?(\\\'|\\")');
$ignoreExts = [
'php', 'tmp', 'conf', 'ini', 'json', 'source', 'css', 'pid', 'log', 'lock', 'ws', 'gradle', 'xml',
'axml', 'behaviour', ''
];
$ignoreExts = arr::combine($ignoreExts, $ignoreExts);
$ignores = [
'app.hash' => 1, 'develnext.endpoint' => 1, 'os.name' => 1, 'os.user' => 1, 'os.version' => 1, 'java.version' => 1,
'user.home' => 1, 'hub.develnext.org' => 1, 'develnext.org' => 1, 'develnext.path' => 1, 'splash.avatar' => 1,
'splash.name' => 1, 'script.name' => 1, 'script.desc' => 1, 'script.author' => 1, 'user.language' => 1,
'ide.language' => 1,
];
$data = [];
$ruData = fs::parse("./ide/misc/languages/ru/messages.ini");
$dirs = ["./ide/src", "./ide/platforms", "./bundles"];
foreach ($dirs as $dir) {
fs::scan($dir, [
'excludeDirs' => true,
'extensions' => ['php', 'fxml', 'conf', 'xml'],
'callback' => function ($filename) use ($regex, $ignoreExts, $ignores, &$data, &$ruData) {
//echo "-> ", $filename, "\n";
$content = fs::get($filename);
$r = $regex->with($content); //->withFlags('');
foreach ($r->all() as $groups) {
$var = $groups[2];
if ($ignores[$var]) continue;
if (str::count($var, '.') === 1 && $ignoreExts[fs::ext($var)]) continue;
$data[$var] = '';
if (!$ruData[$var]) {
$ruData[$var] = $groups[5] ?? $var;
}
}
}
]);
}
Tasks::createFile("$buildPath/messages.ini");
//Tasks::createFile("$buildPath/messages.ru.ini");
ksort($data);
ksort($ruData);
//fs::format("$buildPath/messages.ini", $data);
fs::format("$buildPath/messages.ini", $ruData);
}
/**
* @jppm-task build-ide
*/
function task_buildIde(Event $e)
{
Tasks::runExternal("./ide", "install");
Tasks::copy("./ide/vendor", "./ide/build/vendor/");
Tasks::copy('./ide/misc', './ide/build/');
Tasks::deleteFile('./launcher/build');
Tasks::runExternal('./launcher', 'build');
Tasks::copy('./launcher/build/NeardeLauncher.jar', './ide/build');
Tasks::runExternal('./ide', 'copySourcesToBuild');
}