Skip to content

Commit 0c8b04d

Browse files
author
epriestley
committed
Add packaging to Celerity.
1 parent 7b9c4c5 commit 0c8b04d

File tree

6 files changed

+241
-39
lines changed

6 files changed

+241
-39
lines changed

scripts/celerity_mapper.php

Lines changed: 61 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,31 @@
11
#!/usr/bin/env php
22
<?php
33

4+
$package_spec = array(
5+
'core.pkg.css' => array(
6+
'phabricator-core-css',
7+
'phabricator-core-buttons-css',
8+
'phabricator-standard-page-view',
9+
'aphront-dialog-view-css',
10+
'aphront-form-view-css',
11+
'aphront-panel-view-css',
12+
'aphront-side-nav-view-css',
13+
'aphront-table-view-css',
14+
'aphront-tokenizer-control-css',
15+
'aphront-typeahead-control-css',
16+
17+
'phabricator-directory-css',
18+
),
19+
'differential.pkg.css' => array(
20+
'differential-core-view-css',
21+
'differential-changeset-view-css',
22+
'differential-revision-detail-css',
23+
'differential-revision-history-css',
24+
'differential-table-of-contents-css',
25+
),
26+
);
27+
28+
429
require_once dirname(__FILE__).'/__init_script__.php';
530

631
if ($argc != 2) {
@@ -39,6 +64,8 @@
3964

4065
$runtime_map = array();
4166

67+
$hash_map = array();
68+
4269
$parser = new PhutilDocblockParser();
4370
foreach ($file_map as $path => $info) {
4471
$data = Filesystem::readFile($info['disk']);
@@ -69,19 +96,50 @@
6996
$type = 'css';
7097
}
7198

72-
$path = '/res/'.substr($info['hash'], 0, 8).$path;
99+
$uri = '/res/'.substr($info['hash'], 0, 8).$path;
100+
101+
$hash_map[$provides] = $info['hash'];
73102

74103
$runtime_map[$provides] = array(
75-
'path' => $path,
104+
'uri' => $uri,
76105
'type' => $type,
77106
'requires' => $requires,
107+
'disk' => $path,
108+
);
109+
}
110+
111+
$package_map = array();
112+
foreach ($package_spec as $name => $package) {
113+
$hashes = array();
114+
foreach ($package as $symbol) {
115+
if (empty($hash_map[$symbol])) {
116+
throw new Exception(
117+
"Package specification for '{$name}' includes '{$symbol}', but that ".
118+
"symbol is not defined anywhere.");
119+
}
120+
$hashes[] = $symbol.':'.$hash_map[$symbol];
121+
}
122+
$key = substr(md5(implode("\n", $hashes)), 0, 8);
123+
$package_map['packages'][$key] = array(
124+
'name' => $name,
125+
'symbols' => $package,
126+
'uri' => '/res/pkg/'.$key.'/'.$name,
127+
'type' => 'css', // TODO LOL
78128
);
129+
foreach ($package as $symbol) {
130+
$package_map['reverse'][$symbol] = $key;
131+
}
79132
}
133+
80134

81135
$runtime_map = var_export($runtime_map, true);
82136
$runtime_map = preg_replace('/\s+$/m', '', $runtime_map);
83137
$runtime_map = preg_replace('/array \(/', 'array(', $runtime_map);
84138

139+
$package_map = var_export($package_map, true);
140+
$pacakge_map = preg_replace('/\s+$/m', '', $package_map);
141+
$package_map = preg_replace('/array \(/', 'array(', $package_map);
142+
85143
$resource_map = <<<EOFILE
86144
<?php
87145
@@ -91,7 +149,7 @@
91149
* @generated
92150
*/
93151
94-
celerity_register_resource_map({$runtime_map});
152+
celerity_register_resource_map({$runtime_map}, {$pacakge_map});
95153
96154
EOFILE;
97155

0 commit comments

Comments
 (0)