4 require_once dirname(dirname(__FILE__
)).'/__init_script__.php';
6 $args = new PhutilArgumentParser($argv);
7 $args->setTagline(pht('regenerate Emoji data sheets'));
8 $args->setSynopsis(<<<EOHELP
10 Rebuild Emoji data sheets.
14 $args->parseStandardArguments();
19 'help' => pht('Force regeneration even if sources have not changed.'),
23 $root = dirname(phutil_get_library_root('phabricator'));
24 // move this to an argument?
25 $path = $root.'/emoji_strategy.json';
26 $export_path = $root.'/resources/emoji/manifest.json';
28 if (Filesystem
::pathExists($path)) {
29 $json = Filesystem
::readFile($path);
31 $emojis = phutil_json_decode($json);
33 foreach ($emojis as $shortname => $emoji) {
34 $unicode = $emoji['unicode'];
35 $codes = explode('-', $unicode);
37 foreach ($codes as $code) {
38 $hex .= phutil_utf8_encode_codepoint(hexdec($code));
40 $data[$shortname] = $hex;
44 $json = new PhutilJSON();
45 $data = $json->encodeFormatted($data);
46 Filesystem
::writeFile($export_path, $data);
47 echo pht('Done.')."\n";
49 echo pht('Path %s not exist.', $path)."\n";