mirror of https://gitee.com/bigwinds/arangodb
added dev
This commit is contained in:
parent
440170c144
commit
3ea5fbe121
|
@ -11,7 +11,7 @@
|
|||
COLOR_OUTPUT_RESET, COLOR_BRIGHT, COLOR_BLACK, COLOR_BOLD_BLACK, COLOR_BLINK, COLOR_BLUE,
|
||||
COLOR_BOLD_BLUE, COLOR_BOLD_GREEN, COLOR_RED, COLOR_BOLD_RED, COLOR_GREEN, COLOR_WHITE,
|
||||
COLOR_BOLD_WHITE, COLOR_YELLOW, COLOR_BOLD_YELLOW, COLOR_CYAN, COLOR_BOLD_CYAN, COLOR_MAGENTA,
|
||||
COLOR_BOLD_MAGENTA, PRETTY_PRINT, VALGRIND, VERSION, UPGRADE,
|
||||
COLOR_BOLD_MAGENTA, PRETTY_PRINT, VALGRIND, VERSION, UPGRADE, FS_LIST, DEV_APP_PATH,
|
||||
BYTES_SENT_DISTRIBUTION, BYTES_RECEIVED_DISTRIBUTION, CONNECTION_TIME_DISTRIBUTION,
|
||||
REQUEST_TIME_DISTRIBUTION, HOME, DEVELOPMENT_MODE, THREAD_NUMBER, PATH_SEPARATOR, APP_PATH */
|
||||
|
||||
|
|
|
@ -248,8 +248,8 @@ function stop_color_print () {
|
|||
/// @brief app constructor
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
function ArangoApp (name, version, manifest, path) {
|
||||
this._id = "app:" + name + ":" + version;
|
||||
function ArangoApp (id, name, version, manifest, path) {
|
||||
this._id = id;
|
||||
this._name = name;
|
||||
this._version = version;
|
||||
this._manifest = manifest;
|
||||
|
@ -673,12 +673,12 @@ function stop_color_print () {
|
|||
var re = /app:([^:]*):([^:]*)/;
|
||||
var m = re.exec(appId);
|
||||
|
||||
aal = internal.db._collection("_aal");
|
||||
|
||||
if (m === null) {
|
||||
throw "illegal app identifier '" + appId + "'";
|
||||
}
|
||||
|
||||
aal = internal.db._collection("_aal");
|
||||
|
||||
if (m[2] === "latest") {
|
||||
var docs = aal.byExample({ type: "app", name: m[1] }).toArray();
|
||||
|
||||
|
@ -696,7 +696,27 @@ function stop_color_print () {
|
|||
return null;
|
||||
}
|
||||
|
||||
return doc.path;
|
||||
return {
|
||||
appId: doc.app,
|
||||
path: doc.path
|
||||
};
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief loads a manifest file for development
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
function appManifestDev (appId) {
|
||||
'use strict';
|
||||
|
||||
var re = /dev:([^:]*):(.*)/;
|
||||
var m = re.exec(appId);
|
||||
|
||||
if (m === null) {
|
||||
throw "illegal app identifier '" + appId + "'";
|
||||
}
|
||||
|
||||
return m[2];
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -711,7 +731,13 @@ function stop_color_print () {
|
|||
var manifest;
|
||||
|
||||
if (appId.substr(0,4) === "app:") {
|
||||
path = appManifestAal(appId);
|
||||
var a = appManifestAal(appId);
|
||||
|
||||
path = a.path;
|
||||
appId = a.appId;
|
||||
}
|
||||
else if (appId.substr(0,4) === "dev:") {
|
||||
path = appManifestDev(appId);
|
||||
}
|
||||
else {
|
||||
console.error("cannot load application '%s', unknown type", appId);
|
||||
|
@ -752,6 +778,7 @@ function stop_color_print () {
|
|||
}
|
||||
|
||||
return {
|
||||
id: appId,
|
||||
path: path,
|
||||
manifest: manifest
|
||||
};
|
||||
|
@ -855,6 +882,7 @@ function stop_color_print () {
|
|||
}
|
||||
|
||||
return new ArangoApp(
|
||||
description.id,
|
||||
description.manifest.name,
|
||||
description.manifest.version,
|
||||
description.manifest,
|
||||
|
|
|
@ -119,17 +119,20 @@ function installAssets (app, routes) {
|
|||
for (path in desc.assets) {
|
||||
if (desc.assets.hasOwnProperty(path)) {
|
||||
var asset = desc.assets[path];
|
||||
var content = buildAssetContent(app, asset);
|
||||
|
||||
normalized = arangodb.normalizeURL("/" + path);
|
||||
type = arangodb.guessContentType(normalized);
|
||||
if (asset.hasOwnProperty('files')) {
|
||||
var content = buildAssetContent(app, asset.files);
|
||||
|
||||
route = {
|
||||
url: { match: normalized },
|
||||
content: { contentType: type, body: content }
|
||||
};
|
||||
normalized = arangodb.normalizeURL("/" + path);
|
||||
type = arangodb.guessContentType(normalized);
|
||||
|
||||
routes.routes.push(route);
|
||||
route = {
|
||||
url: { match: normalized },
|
||||
content: { contentType: type, body: content }
|
||||
};
|
||||
|
||||
routes.routes.push(route);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -583,6 +586,68 @@ exports.uninstallApp = function (key) {
|
|||
return true;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief installs a FOXX application in development
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
exports.installDevApp = function (name, mount, options) {
|
||||
'use strict';
|
||||
|
||||
var aal;
|
||||
var app;
|
||||
var appPath;
|
||||
var appId;
|
||||
var desc;
|
||||
var doc;
|
||||
var i;
|
||||
|
||||
aal = arangodb.db._collection("_aal");
|
||||
|
||||
// .............................................................................
|
||||
// locate the application
|
||||
// .............................................................................
|
||||
|
||||
appPath = internal.DEV_APP_PATH;
|
||||
appId = null;
|
||||
|
||||
for (i = 0; i < appPath.length; ++i) {
|
||||
var path = appPath[i];
|
||||
var filename = fs.join(path, name, "manifest.json");
|
||||
|
||||
if (fs.exists(filename)) {
|
||||
appId = "dev:" + name + ":" + fs.join(path, name);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
app = appId !== null && module.createApp(appId);
|
||||
|
||||
if (app === null) {
|
||||
throw "cannot find development application '" + name + "'";
|
||||
}
|
||||
|
||||
// .............................................................................
|
||||
// install the application
|
||||
// .............................................................................
|
||||
|
||||
try {
|
||||
doc = installAalApp(app, mount, options);
|
||||
}
|
||||
catch (err) {
|
||||
if (doc !== undefined) {
|
||||
aal.remove(doc._key);
|
||||
}
|
||||
|
||||
throw err;
|
||||
}
|
||||
|
||||
desc = aal.document(doc).shallowCopy;
|
||||
desc.active = true;
|
||||
doc = aal.replace(doc, desc);
|
||||
|
||||
return aal.document(doc);
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -812,6 +812,7 @@ FormatMiddleware = function (allowedFormats, defaultFormat) {
|
|||
/// Everything else will remain our secret.
|
||||
|
||||
exports.installApp = foxxManager.installApp;
|
||||
exports.installDevApp = foxxManager.installDevApp;
|
||||
exports.uninstallApp = foxxManager.uninstallApp;
|
||||
exports.scappAppDirectory = foxxManager.scanAppDirectory;
|
||||
exports.FoxxApplication = FoxxApplication;
|
||||
|
|
Loading…
Reference in New Issue