2011-01-25 18:59:31 +01:00
|
|
|
#!/usr/bin/env php
|
|
|
|
<?php
|
|
|
|
|
2011-11-28 20:03:00 +01:00
|
|
|
/*
|
2012-03-02 02:23:00 +01:00
|
|
|
* Copyright 2012 Facebook, Inc.
|
2011-11-28 20:03:00 +01:00
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2011-01-30 01:10:05 +01:00
|
|
|
$package_spec = array(
|
Bring Javelin into Phabricator via git submodule, not copy-and-paste
Summary:
Javelin is currently embedded in Phabricator via copy-and-paste of prebuilt
packages. This is not so great.
Pull it in as a submodule instead and make all the Phabriator resources declare
proper dependency trees. Add Javelin linting.
Test Plan:
I tried to run through pretty much all the JS functionality on the site. This is
still a high-risk change, but I did a pretty thorough test
Differential: inline comments, revealing diffs, list tokenizers, comment
preview, editing/deleting comments, add review action.
Maniphest: list tokenizer, comment actions
Herald: rule editing, tokenizers, add/remove rows
Reviewed By: tomo
Reviewers: aran, tomo, mroch, jungejason, tuomaspelkonen
CC: aran, tomo, epriestley
Differential Revision: 223
2011-05-04 00:11:55 +02:00
|
|
|
'javelin.pkg.js' => array(
|
|
|
|
'javelin-util',
|
|
|
|
'javelin-install',
|
|
|
|
'javelin-event',
|
|
|
|
'javelin-stratcom',
|
|
|
|
'javelin-behavior',
|
|
|
|
'javelin-request',
|
|
|
|
'javelin-vector',
|
|
|
|
'javelin-dom',
|
|
|
|
'javelin-json',
|
|
|
|
'javelin-uri',
|
|
|
|
),
|
|
|
|
'typeahead.pkg.js' => array(
|
|
|
|
'javelin-typeahead',
|
|
|
|
'javelin-typeahead-normalizer',
|
|
|
|
'javelin-typeahead-source',
|
|
|
|
'javelin-typeahead-preloaded-source',
|
|
|
|
'javelin-typeahead-ondemand-source',
|
|
|
|
'javelin-tokenizer',
|
|
|
|
'javelin-behavior-aphront-basic-tokenizer',
|
|
|
|
),
|
2011-12-19 18:06:09 +01:00
|
|
|
'core.pkg.js' => array(
|
Bring Javelin into Phabricator via git submodule, not copy-and-paste
Summary:
Javelin is currently embedded in Phabricator via copy-and-paste of prebuilt
packages. This is not so great.
Pull it in as a submodule instead and make all the Phabriator resources declare
proper dependency trees. Add Javelin linting.
Test Plan:
I tried to run through pretty much all the JS functionality on the site. This is
still a high-risk change, but I did a pretty thorough test
Differential: inline comments, revealing diffs, list tokenizers, comment
preview, editing/deleting comments, add review action.
Maniphest: list tokenizer, comment actions
Herald: rule editing, tokenizers, add/remove rows
Reviewed By: tomo
Reviewers: aran, tomo, mroch, jungejason, tuomaspelkonen
CC: aran, tomo, epriestley
Differential Revision: 223
2011-05-04 00:11:55 +02:00
|
|
|
'javelin-mask',
|
|
|
|
'javelin-workflow',
|
|
|
|
'javelin-behavior-workflow',
|
2011-05-28 20:36:00 +02:00
|
|
|
'javelin-behavior-aphront-form-disable-on-submit',
|
|
|
|
'phabricator-keyboard-shortcut-manager',
|
|
|
|
'phabricator-keyboard-shortcut',
|
|
|
|
'javelin-behavior-phabricator-keyboard-shortcuts',
|
2011-12-19 18:06:09 +01:00
|
|
|
'javelin-behavior-refresh-csrf',
|
|
|
|
'javelin-behavior-phabricator-watch-anchor',
|
2012-03-02 02:23:00 +01:00
|
|
|
'javelin-behavior-phabricator-autofocus',
|
|
|
|
'phabricator-paste-file-upload',
|
|
|
|
'phabricator-menu-item',
|
|
|
|
'phabricator-dropdown-menu',
|
Bring Javelin into Phabricator via git submodule, not copy-and-paste
Summary:
Javelin is currently embedded in Phabricator via copy-and-paste of prebuilt
packages. This is not so great.
Pull it in as a submodule instead and make all the Phabriator resources declare
proper dependency trees. Add Javelin linting.
Test Plan:
I tried to run through pretty much all the JS functionality on the site. This is
still a high-risk change, but I did a pretty thorough test
Differential: inline comments, revealing diffs, list tokenizers, comment
preview, editing/deleting comments, add review action.
Maniphest: list tokenizer, comment actions
Herald: rule editing, tokenizers, add/remove rows
Reviewed By: tomo
Reviewers: aran, tomo, mroch, jungejason, tuomaspelkonen
CC: aran, tomo, epriestley
Differential Revision: 223
2011-05-04 00:11:55 +02:00
|
|
|
),
|
2011-01-30 01:10:05 +01:00
|
|
|
'core.pkg.css' => array(
|
|
|
|
'phabricator-core-css',
|
|
|
|
'phabricator-core-buttons-css',
|
|
|
|
'phabricator-standard-page-view',
|
|
|
|
'aphront-dialog-view-css',
|
|
|
|
'aphront-form-view-css',
|
|
|
|
'aphront-panel-view-css',
|
|
|
|
'aphront-side-nav-view-css',
|
|
|
|
'aphront-table-view-css',
|
2011-03-14 04:15:24 +01:00
|
|
|
'aphront-crumbs-view-css',
|
2011-01-30 01:10:05 +01:00
|
|
|
'aphront-tokenizer-control-css',
|
|
|
|
'aphront-typeahead-control-css',
|
Bring Javelin into Phabricator via git submodule, not copy-and-paste
Summary:
Javelin is currently embedded in Phabricator via copy-and-paste of prebuilt
packages. This is not so great.
Pull it in as a submodule instead and make all the Phabriator resources declare
proper dependency trees. Add Javelin linting.
Test Plan:
I tried to run through pretty much all the JS functionality on the site. This is
still a high-risk change, but I did a pretty thorough test
Differential: inline comments, revealing diffs, list tokenizers, comment
preview, editing/deleting comments, add review action.
Maniphest: list tokenizer, comment actions
Herald: rule editing, tokenizers, add/remove rows
Reviewed By: tomo
Reviewers: aran, tomo, mroch, jungejason, tuomaspelkonen
CC: aran, tomo, epriestley
Differential Revision: 223
2011-05-04 00:11:55 +02:00
|
|
|
'aphront-list-filter-view-css',
|
2011-01-30 01:10:05 +01:00
|
|
|
|
|
|
|
'phabricator-directory-css',
|
2012-03-02 02:23:00 +01:00
|
|
|
'phabricator-jump-nav',
|
|
|
|
'phabricator-app-buttons-css',
|
2011-02-05 02:53:14 +01:00
|
|
|
|
|
|
|
'phabricator-remarkup-css',
|
|
|
|
'syntax-highlighting-css',
|
2012-03-02 02:23:00 +01:00
|
|
|
'aphront-pager-view-css',
|
|
|
|
'phabricator-transaction-view-css',
|
2011-01-30 01:10:05 +01:00
|
|
|
),
|
|
|
|
'differential.pkg.css' => array(
|
|
|
|
'differential-core-view-css',
|
|
|
|
'differential-changeset-view-css',
|
|
|
|
'differential-revision-detail-css',
|
|
|
|
'differential-revision-history-css',
|
|
|
|
'differential-table-of-contents-css',
|
2011-02-05 02:53:14 +01:00
|
|
|
'differential-revision-comment-css',
|
|
|
|
'differential-revision-add-comment-css',
|
|
|
|
'differential-revision-comment-list-css',
|
2011-12-19 18:06:09 +01:00
|
|
|
'phabricator-object-selector-css',
|
|
|
|
'aphront-headsup-action-list-view-css',
|
|
|
|
'phabricator-content-source-view-css',
|
|
|
|
'differential-local-commits-view-css',
|
2011-02-05 02:53:14 +01:00
|
|
|
),
|
|
|
|
'differential.pkg.js' => array(
|
2011-12-19 18:06:09 +01:00
|
|
|
'phabricator-drag-and-drop-file-upload',
|
|
|
|
'phabricator-shaped-request',
|
|
|
|
|
2011-02-05 02:53:14 +01:00
|
|
|
'javelin-behavior-differential-feedback-preview',
|
|
|
|
'javelin-behavior-differential-edit-inline-comments',
|
|
|
|
'javelin-behavior-differential-populate',
|
|
|
|
'javelin-behavior-differential-show-more',
|
|
|
|
'javelin-behavior-differential-diff-radios',
|
2011-12-19 18:06:09 +01:00
|
|
|
'javelin-behavior-differential-accept-with-errors',
|
|
|
|
'javelin-behavior-differential-comment-jump',
|
|
|
|
'javelin-behavior-differential-add-reviewers-and-ccs',
|
|
|
|
'javelin-behavior-differential-keyboard-navigation',
|
|
|
|
'javelin-behavior-aphront-drag-and-drop',
|
|
|
|
'javelin-behavior-aphront-drag-and-drop-textarea',
|
|
|
|
'javelin-behavior-phabricator-object-selector',
|
|
|
|
|
|
|
|
'differential-inline-comment-editor',
|
2012-03-02 02:23:00 +01:00
|
|
|
'javelin-behavior-differential-dropdown-menus',
|
|
|
|
'javelin-behavior-buoyant',
|
2011-01-30 01:10:05 +01:00
|
|
|
),
|
2011-03-14 04:15:24 +01:00
|
|
|
'diffusion.pkg.css' => array(
|
|
|
|
'diffusion-commit-view-css',
|
|
|
|
),
|
2012-03-02 02:23:00 +01:00
|
|
|
'maniphest.pkg.css' => array(
|
|
|
|
'maniphest-task-summary-css',
|
|
|
|
'maniphest-transaction-detail-css',
|
|
|
|
'maniphest-task-detail-css',
|
|
|
|
'aphront-attached-file-view-css',
|
|
|
|
),
|
|
|
|
'maniphest.pkg.js' => array(
|
|
|
|
'javelin-behavior-maniphest-batch-selector',
|
|
|
|
'javelin-behavior-maniphest-transaction-controls',
|
|
|
|
'javelin-behavior-maniphest-transaction-preview',
|
|
|
|
'javelin-behavior-maniphest-transaction-expand',
|
|
|
|
),
|
2011-01-30 01:10:05 +01:00
|
|
|
);
|
|
|
|
|
|
|
|
|
2011-01-25 18:59:31 +01:00
|
|
|
require_once dirname(__FILE__).'/__init_script__.php';
|
|
|
|
|
|
|
|
if ($argc != 2) {
|
|
|
|
$self = basename($argv[0]);
|
|
|
|
echo "usage: {$self} <webroot>\n";
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
phutil_require_module('phutil', 'filesystem');
|
|
|
|
phutil_require_module('phutil', 'filesystem/filefinder');
|
|
|
|
phutil_require_module('phutil', 'future/exec');
|
|
|
|
phutil_require_module('phutil', 'parser/docblock');
|
|
|
|
|
|
|
|
$root = Filesystem::resolvePath($argv[1]);
|
|
|
|
|
|
|
|
echo "Finding static resources...\n";
|
|
|
|
$files = id(new FileFinder($root))
|
|
|
|
->withType('f')
|
|
|
|
->withSuffix('js')
|
|
|
|
->withSuffix('css')
|
Bring Javelin into Phabricator via git submodule, not copy-and-paste
Summary:
Javelin is currently embedded in Phabricator via copy-and-paste of prebuilt
packages. This is not so great.
Pull it in as a submodule instead and make all the Phabriator resources declare
proper dependency trees. Add Javelin linting.
Test Plan:
I tried to run through pretty much all the JS functionality on the site. This is
still a high-risk change, but I did a pretty thorough test
Differential: inline comments, revealing diffs, list tokenizers, comment
preview, editing/deleting comments, add review action.
Maniphest: list tokenizer, comment actions
Herald: rule editing, tokenizers, add/remove rows
Reviewed By: tomo
Reviewers: aran, tomo, mroch, jungejason, tuomaspelkonen
CC: aran, tomo, epriestley
Differential Revision: 223
2011-05-04 00:11:55 +02:00
|
|
|
->withFollowSymlinks(true)
|
2011-01-25 18:59:31 +01:00
|
|
|
->setGenerateChecksums(true)
|
|
|
|
->find();
|
|
|
|
|
|
|
|
echo "Processing ".count($files)." files";
|
|
|
|
|
2011-05-09 10:10:40 +02:00
|
|
|
$resource_hash = PhabricatorEnv::getEnvConfig('celerity.resource-hash');
|
|
|
|
|
2011-01-25 18:59:31 +01:00
|
|
|
$file_map = array();
|
|
|
|
foreach ($files as $path => $hash) {
|
|
|
|
echo ".";
|
|
|
|
$name = '/'.Filesystem::readablePath($path, $root);
|
|
|
|
$file_map[$name] = array(
|
2011-05-09 10:10:40 +02:00
|
|
|
'hash' => md5($hash.$name.$resource_hash),
|
2011-01-25 18:59:31 +01:00
|
|
|
'disk' => $path,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
echo "\n";
|
|
|
|
|
|
|
|
$runtime_map = array();
|
2011-11-22 20:36:57 +01:00
|
|
|
$resource_graph = array();
|
2011-01-30 01:10:05 +01:00
|
|
|
$hash_map = array();
|
|
|
|
|
2011-01-25 18:59:31 +01:00
|
|
|
$parser = new PhutilDocblockParser();
|
|
|
|
foreach ($file_map as $path => $info) {
|
|
|
|
$data = Filesystem::readFile($info['disk']);
|
|
|
|
$matches = array();
|
|
|
|
$ok = preg_match('@/[*][*].*?[*]/@s', $data, $matches);
|
|
|
|
if (!$ok) {
|
|
|
|
throw new Exception(
|
|
|
|
"File {$path} does not have a header doc comment. Encode dependency ".
|
|
|
|
"data in a header docblock.");
|
|
|
|
}
|
2011-03-14 04:15:24 +01:00
|
|
|
|
2011-01-25 18:59:31 +01:00
|
|
|
list($description, $metadata) = $parser->parse($matches[0]);
|
2011-03-14 04:15:24 +01:00
|
|
|
|
2011-01-25 18:59:31 +01:00
|
|
|
$provides = preg_split('/\s+/', trim(idx($metadata, 'provides')));
|
|
|
|
$requires = preg_split('/\s+/', trim(idx($metadata, 'requires')));
|
|
|
|
$provides = array_filter($provides);
|
|
|
|
$requires = array_filter($requires);
|
2011-03-14 04:15:24 +01:00
|
|
|
|
2012-03-14 08:24:06 +01:00
|
|
|
if (!$provides) {
|
|
|
|
// Tests and documentation-only JS is permitted to @provide no targets.
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
Bring Javelin into Phabricator via git submodule, not copy-and-paste
Summary:
Javelin is currently embedded in Phabricator via copy-and-paste of prebuilt
packages. This is not so great.
Pull it in as a submodule instead and make all the Phabriator resources declare
proper dependency trees. Add Javelin linting.
Test Plan:
I tried to run through pretty much all the JS functionality on the site. This is
still a high-risk change, but I did a pretty thorough test
Differential: inline comments, revealing diffs, list tokenizers, comment
preview, editing/deleting comments, add review action.
Maniphest: list tokenizer, comment actions
Herald: rule editing, tokenizers, add/remove rows
Reviewed By: tomo
Reviewers: aran, tomo, mroch, jungejason, tuomaspelkonen
CC: aran, tomo, epriestley
Differential Revision: 223
2011-05-04 00:11:55 +02:00
|
|
|
if (count($provides) > 1) {
|
2011-01-25 18:59:31 +01:00
|
|
|
throw new Exception(
|
Bring Javelin into Phabricator via git submodule, not copy-and-paste
Summary:
Javelin is currently embedded in Phabricator via copy-and-paste of prebuilt
packages. This is not so great.
Pull it in as a submodule instead and make all the Phabriator resources declare
proper dependency trees. Add Javelin linting.
Test Plan:
I tried to run through pretty much all the JS functionality on the site. This is
still a high-risk change, but I did a pretty thorough test
Differential: inline comments, revealing diffs, list tokenizers, comment
preview, editing/deleting comments, add review action.
Maniphest: list tokenizer, comment actions
Herald: rule editing, tokenizers, add/remove rows
Reviewed By: tomo
Reviewers: aran, tomo, mroch, jungejason, tuomaspelkonen
CC: aran, tomo, epriestley
Differential Revision: 223
2011-05-04 00:11:55 +02:00
|
|
|
"File {$path} must @provide at most one Celerity target.");
|
2011-01-25 18:59:31 +01:00
|
|
|
}
|
2011-03-14 04:15:24 +01:00
|
|
|
|
2011-01-25 18:59:31 +01:00
|
|
|
$provides = reset($provides);
|
|
|
|
|
|
|
|
$type = 'js';
|
|
|
|
if (preg_match('/\.css$/', $path)) {
|
|
|
|
$type = 'css';
|
|
|
|
}
|
2011-03-14 04:15:24 +01:00
|
|
|
|
2011-01-30 01:10:05 +01:00
|
|
|
$uri = '/res/'.substr($info['hash'], 0, 8).$path;
|
2011-03-14 04:15:24 +01:00
|
|
|
|
2011-01-30 01:10:05 +01:00
|
|
|
$hash_map[$provides] = $info['hash'];
|
2011-03-14 04:15:24 +01:00
|
|
|
|
2011-11-22 20:36:57 +01:00
|
|
|
$resource_graph[$provides] = $requires;
|
|
|
|
|
2011-01-25 18:59:31 +01:00
|
|
|
$runtime_map[$provides] = array(
|
2011-01-30 01:10:05 +01:00
|
|
|
'uri' => $uri,
|
2011-01-25 18:59:31 +01:00
|
|
|
'type' => $type,
|
|
|
|
'requires' => $requires,
|
2011-01-30 01:10:05 +01:00
|
|
|
'disk' => $path,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2011-11-22 20:36:57 +01:00
|
|
|
$celerity_resource_graph = new CelerityResourceGraph();
|
|
|
|
$celerity_resource_graph->addNodes($resource_graph);
|
|
|
|
$celerity_resource_graph->setResourceGraph($resource_graph);
|
|
|
|
$celerity_resource_graph->loadGraph();
|
|
|
|
|
|
|
|
foreach ($resource_graph as $provides => $requires) {
|
|
|
|
$cycle = $celerity_resource_graph->detectCycles($provides);
|
|
|
|
if ($cycle) {
|
|
|
|
throw new Exception(
|
|
|
|
"Cycle detected in resource graph: ". implode($cycle, " => ")
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-30 01:10:05 +01:00
|
|
|
$package_map = array();
|
|
|
|
foreach ($package_spec as $name => $package) {
|
|
|
|
$hashes = array();
|
2011-01-30 01:16:09 +01:00
|
|
|
$type = null;
|
2011-01-30 01:10:05 +01:00
|
|
|
foreach ($package as $symbol) {
|
|
|
|
if (empty($hash_map[$symbol])) {
|
|
|
|
throw new Exception(
|
|
|
|
"Package specification for '{$name}' includes '{$symbol}', but that ".
|
|
|
|
"symbol is not defined anywhere.");
|
|
|
|
}
|
2011-01-30 01:16:09 +01:00
|
|
|
if ($type === null) {
|
|
|
|
$type = $runtime_map[$symbol]['type'];
|
|
|
|
} else {
|
|
|
|
$ntype = $runtime_map[$symbol]['type'];
|
|
|
|
if ($type !== $ntype) {
|
|
|
|
throw new Exception(
|
|
|
|
"Package specification for '{$name}' mixes resources of type ".
|
|
|
|
"'{$type}' with resources of type '{$ntype}'. Each package may only ".
|
|
|
|
"contain one type of resource.");
|
|
|
|
}
|
|
|
|
}
|
2011-01-30 01:10:05 +01:00
|
|
|
$hashes[] = $symbol.':'.$hash_map[$symbol];
|
|
|
|
}
|
|
|
|
$key = substr(md5(implode("\n", $hashes)), 0, 8);
|
|
|
|
$package_map['packages'][$key] = array(
|
|
|
|
'name' => $name,
|
|
|
|
'symbols' => $package,
|
|
|
|
'uri' => '/res/pkg/'.$key.'/'.$name,
|
2011-01-30 01:16:09 +01:00
|
|
|
'type' => $type,
|
2011-01-25 18:59:31 +01:00
|
|
|
);
|
2011-01-30 01:10:05 +01:00
|
|
|
foreach ($package as $symbol) {
|
|
|
|
$package_map['reverse'][$symbol] = $key;
|
|
|
|
}
|
2011-01-25 18:59:31 +01:00
|
|
|
}
|
2011-03-14 04:15:24 +01:00
|
|
|
|
2011-05-03 19:45:45 +02:00
|
|
|
ksort($runtime_map);
|
2011-01-25 18:59:31 +01:00
|
|
|
$runtime_map = var_export($runtime_map, true);
|
|
|
|
$runtime_map = preg_replace('/\s+$/m', '', $runtime_map);
|
|
|
|
$runtime_map = preg_replace('/array \(/', 'array(', $runtime_map);
|
|
|
|
|
2012-03-15 06:42:30 +01:00
|
|
|
$package_map['packages'] = isort($package_map['packages'], 'name');
|
2011-05-03 19:45:45 +02:00
|
|
|
ksort($package_map['reverse']);
|
2011-01-30 01:10:05 +01:00
|
|
|
$package_map = var_export($package_map, true);
|
2011-08-04 07:16:44 +02:00
|
|
|
$package_map = preg_replace('/\s+$/m', '', $package_map);
|
2011-01-30 01:10:05 +01:00
|
|
|
$package_map = preg_replace('/array \(/', 'array(', $package_map);
|
|
|
|
|
2011-11-28 20:03:00 +01:00
|
|
|
$generated = '@'.'generated';
|
2011-01-25 18:59:31 +01:00
|
|
|
$resource_map = <<<EOFILE
|
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This file is automatically generated. Use 'celerity_mapper.php' to rebuild
|
|
|
|
* it.
|
2011-11-28 20:03:00 +01:00
|
|
|
* {$generated}
|
2011-01-25 18:59:31 +01:00
|
|
|
*/
|
|
|
|
|
2011-08-04 07:16:44 +02:00
|
|
|
celerity_register_resource_map({$runtime_map}, {$package_map});
|
2011-01-25 18:59:31 +01:00
|
|
|
|
|
|
|
EOFILE;
|
|
|
|
|
|
|
|
echo "Writing map...\n";
|
|
|
|
Filesystem::writeFile(
|
|
|
|
$root.'/../src/__celerity_resource_map__.php',
|
|
|
|
$resource_map);
|
2011-03-14 04:15:24 +01:00
|
|
|
echo "Done.\n";
|