Publish Vulpes Preview 15 sources for desktop, Android and Tundra
Share Gaia assets and adapters, keep private profiles and development documents local, and update both public READMEs.
This commit is contained in:
parent
93e3a48004
commit
b38dea0597
25901 changed files with 9982925 additions and 369 deletions
25
gaia/tests/jsmarionette/runner/mozilla-profile-builder/lib/options/apps.js
Executable file
25
gaia/tests/jsmarionette/runner/mozilla-profile-builder/lib/options/apps.js
Executable file
|
|
@ -0,0 +1,25 @@
|
|||
'use strict';
|
||||
var installApps = require('packaged-webapp').installApps;
|
||||
|
||||
function apps(profile, options, callback) {
|
||||
// abort if no apps are given
|
||||
if (
|
||||
// no options
|
||||
!options ||
|
||||
// no apps
|
||||
!options.apps ||
|
||||
// empty app object
|
||||
(Object.keys(options.apps).length === 0)
|
||||
) {
|
||||
return process.nextTick(callback.bind(null, null, profile));
|
||||
}
|
||||
|
||||
var list = [];
|
||||
for (var origin in options.apps) {
|
||||
list.push({ origin: origin, source: options.apps[origin] });
|
||||
}
|
||||
|
||||
installApps(profile, list, callback);
|
||||
}
|
||||
|
||||
module.exports = apps;
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
'use strict';
|
||||
var fse = require('fs-extra');
|
||||
|
||||
/**
|
||||
* Recursively copy a directory of prebuilt files into a profile. Used for
|
||||
* overwriting files in a clean profile for tests.
|
||||
*
|
||||
* Options:
|
||||
* - (Object) extract: Directory to copy into profile.
|
||||
*
|
||||
* @param {String} profile path to profile.
|
||||
* @param {Object} options for directory.
|
||||
* @param {Function} callback fires after successfully copying.
|
||||
*/
|
||||
function copyExtract(profile, options, callback) {
|
||||
// we userPrefs was used in the past
|
||||
var extractsDir = options.extracts;
|
||||
// don't do anything unless there is a directory to copy
|
||||
if (!extractsDir) {
|
||||
return process.nextTick(callback.bind(null, null, profile));
|
||||
}
|
||||
|
||||
fse.copy(extractsDir, profile, function(err) {
|
||||
if (err) return callback(err);
|
||||
return callback(null, profile);
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = copyExtract;
|
||||
32
gaia/tests/jsmarionette/runner/mozilla-profile-builder/lib/options/prefs.js
Executable file
32
gaia/tests/jsmarionette/runner/mozilla-profile-builder/lib/options/prefs.js
Executable file
|
|
@ -0,0 +1,32 @@
|
|||
'use strict';
|
||||
var fs = require('fs'),
|
||||
fsPath = require('path'),
|
||||
pref = require('../pref');
|
||||
|
||||
var USER_PREF = 'user.js';
|
||||
/**
|
||||
* Appends prefs to the given profile.
|
||||
*
|
||||
* Options:
|
||||
* - (Object) prefs: key/value pairs.
|
||||
*
|
||||
* @param {String} profile path to profile.
|
||||
* @param {Object} options for prefs.
|
||||
* @param {Function} callback fires after successfully saving.
|
||||
*/
|
||||
function appendPrefs(profile, options, callback) {
|
||||
// we userPrefs was used in the past
|
||||
var prefsConfig = options.prefs || options.userPrefs;
|
||||
// don't do anything unless there are some new prefs
|
||||
if (!prefsConfig || Object.keys(prefsConfig).length === 0) {
|
||||
return process.nextTick(callback.bind(null, null, profile));
|
||||
}
|
||||
|
||||
var filename = fsPath.join(profile, USER_PREF);
|
||||
fs.appendFile(filename, '\n' + pref(prefsConfig), function(err) {
|
||||
if (err) return callback(err);
|
||||
callback(null, profile);
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = appendPrefs;
|
||||
|
|
@ -0,0 +1,85 @@
|
|||
'use strict';
|
||||
/** handles mutation of settings.json */
|
||||
var SETTINGS = 'settings.json';
|
||||
var PERMISSIONS_DB = 'permissions.sqlite';
|
||||
|
||||
var fs = require('fs'),
|
||||
fsPath = require('path');
|
||||
|
||||
/**
|
||||
* Updates the settings.json file of a given profile
|
||||
*
|
||||
* @param {String} profile path.
|
||||
* @param {Options} options with .settings.
|
||||
* @param {Function} callback [Error err, profile].
|
||||
*/
|
||||
function settings(profile, options, callback) {
|
||||
if (!options || !options.settings) {
|
||||
return process.nextTick(callback.bind(null, null, profile));
|
||||
}
|
||||
|
||||
// location of settings.json
|
||||
var settingsPath = fsPath.join(profile, SETTINGS);
|
||||
// location of permissions
|
||||
var permissionsPath = fsPath.join(profile, PERMISSIONS_DB);
|
||||
|
||||
function readSettings() {
|
||||
fs.readFile(settingsPath, 'utf8', function(err, content) {
|
||||
var json;
|
||||
try {
|
||||
json = JSON.parse(content);
|
||||
} catch (e) {
|
||||
return callback(e);
|
||||
}
|
||||
|
||||
writeSettings(json);
|
||||
});
|
||||
}
|
||||
|
||||
function writeSettings(original) {
|
||||
// copy new settings over
|
||||
var newSettings = options.settings;
|
||||
for (var name in newSettings) {
|
||||
original[name] = newSettings[name];
|
||||
}
|
||||
|
||||
var pending = 2;
|
||||
function next(err) {
|
||||
if (err) {
|
||||
callback && callback(err);
|
||||
callback = null;
|
||||
}
|
||||
|
||||
if (--pending === 0)
|
||||
callback(null, profile);
|
||||
}
|
||||
|
||||
fs.exists(permissionsPath, function(itDoes) {
|
||||
if (!itDoes)
|
||||
return next();
|
||||
|
||||
fs.unlink(permissionsPath, next);
|
||||
});
|
||||
|
||||
// and finally write the file back out
|
||||
fs.writeFile(
|
||||
settingsPath,
|
||||
// slows it down a but but makes it readable!
|
||||
JSON.stringify(original, null, 2),
|
||||
next
|
||||
);
|
||||
}
|
||||
|
||||
// check if file exists
|
||||
fs.exists(settingsPath, function(fileExists) {
|
||||
if (fileExists) {
|
||||
// when file exists read it then write
|
||||
readSettings();
|
||||
} else {
|
||||
// otherwise simply write
|
||||
writeSettings({});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = settings;
|
||||
Loading…
Reference in a new issue