This repository has been archived by the owner on Feb 2, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathbuild
executable file
·55 lines (48 loc) · 1.64 KB
/
build
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
#!/usr/bin/php
<?php
/*
* Updates various files with new version number from VERSION. Designed to be run from a hook before git commit.
*
* Requires ruby and the crxmake gem: gem source -a http://gemcutter.org; sudo gem install crxmake
*/
$version = trim(file_get_contents('VERSION'));
echo "This script builds the Chrome extension only.\n";
echo "Current VERSION is $version. Change? (blank to keep) ";
$stdin = fopen('php://stdin', 'r');
$new_version = trim(fgets($stdin, 100));
if ( !$new_version )
{
echo "Keeping version at $version.\n";
define('VERSION', $version);
}
else
{
define('VERSION', $new_version);
file_put_contents('VERSION', VERSION."\n");
$files = array(
'updates.xml' => "/(updatecheck.*version=')[\d.]*(')/",
'typetonavigate.safariextension/manifest.json' => '/("version": ")[\d.]*(",)/',
);
echo "Updating files to indicate version ".VERSION."...\n";
foreach ( $files as $file => $pattern )
{
$contents = preg_replace_callback($pattern, function($m) {
return $m[1].VERSION.$m[2];
}, file_get_contents($file));
echo " $file\n";
if ($contents) file_put_contents($file, $contents);
}
echo "...updated.\n";
}
echo "Removing old extension...";
system("rm typetonavigate.crx", $return);
echo ( !$return ) ? "removed.\n" : "FAILED!\n";
unset($return);
echo "Building extension...";
$params = array(
'extension' => 'typetonavigate.safariextension',
'output_crx' => 'typetonavigate.crx',
'key_file' => 'typetonavigate.pem',
);
system("crxmake --pack-extension={$params['extension']} --extension-output={$params['output_crx']} --pack-extension-key={$params['key_file']}", $return);
echo ( !$return ) ? "built.\n" : "FAILED!\n";