Skip to content
This repository has been archived by the owner on Jan 14, 2022. It is now read-only.

Commit

Permalink
Merge pull request #14 from manifoldjs/v0.1.2
Browse files Browse the repository at this point in the history
Release v0.1.2
  • Loading branch information
Esteban Lopez committed Jun 7, 2016
2 parents fac54be + fe7eff1 commit 89b46fd
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 17 deletions.
3 changes: 2 additions & 1 deletion lib/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ module.exports = {
BASE_MANIFEST_FORMAT: 'w3c',
CHROME_MANIFEST_FORMAT: 'chromeos',
FIREFOX_MANIFEST_FORMAT: 'firefox',
WINDOWS10_MANIFEST_FORMAT: 'windows10',
WINDOWS10_MANIFEST_FORMAT: 'windows10',
EDGE_EXTENSION_FORMAT: 'edgeextension',
validation: validationConstants
};
32 changes: 22 additions & 10 deletions lib/manifestTools/manifestValidator.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,15 +112,18 @@ function runValidationRules(w3cManifestInfo, rules, callback) {
function applyValidationRules(w3cManifestInfo, platformModules, platforms) {

var allResults = [];

// load and run validation rules for "all platforms"
var validationRulesDir = path.join(__dirname, 'validationRules');
return loadValidationRules(validationRulesDir).then(function (rules) {
return runValidationRules(w3cManifestInfo, rules).then(function (results) {
allResults.push.apply(allResults, results);

function validateAllPlatforms() {
// load and run validation rules for "all platforms"
var validationRulesDir = path.join(__dirname, 'validationRules');
return loadValidationRules(validationRulesDir).then(function (rules) {
return runValidationRules(w3cManifestInfo, rules).then(function (results) {
allResults.push.apply(allResults, results);
});
});
})
.then(function () {
}

function validatePlatform() {
// run platform-specific validation rules
var platformTasks = platformModules.map(function (platform) {
return platform.getValidationRules(platforms).then(function (rules) {
Expand All @@ -131,8 +134,17 @@ function applyValidationRules(w3cManifestInfo, platformModules, platforms) {
});

return Q.allSettled(platformTasks);
})
.thenResolve(allResults);
}

// Don't run the "All Platform" validattion for Edge Extensions since they are not w3c compliant
if (platforms.length === 1 && platforms[0] === constants.EDGE_EXTENSION_FORMAT) {
return validatePlatform()
.thenResolve(allResults);
} else {
return validateAllPlatforms()
.then(validatePlatform)
.thenResolve(allResults);
}
}

function validateManifest(w3cManifestInfo, platforms, callback) {
Expand Down
43 changes: 43 additions & 0 deletions lib/manifestTools/transformations/edgeextension.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
'use strict';

function convertToBase (manifestInfo, callback) {
if (!manifestInfo || !manifestInfo.content) {
return callback(new Error('Manifest content is empty or not initialized.'));
}

return callback(undefined, manifestInfo);
}

function convertFromBase (manifestInfo, callback) {
if (!manifestInfo || !manifestInfo.content) {
return callback(new Error('Manifest content is empty or not initialized.'));
}

return callback(undefined, manifestInfo);
}

var validRootProperties = ['name', 'author', 'version', 'default_locale', 'description', 'manifest_version', 'icons', 'content_security_policy',
'browser_action', 'page_action', 'background', 'commands', 'content_scripts', 'externally_connectable', 'homepage_url',
'addressbar', 'options_page', 'permissions', 'optional_permissions', 'web_accessible_resources', 'minimum_edge_version',
'key', '-ms-preload'];

function matchFormat (manifestObj) {
var lowercasePropName;

for (var prop in manifestObj) {
if (manifestObj.hasOwnProperty(prop)) {
lowercasePropName = prop.toLowerCase();
if (validRootProperties.indexOf(lowercasePropName) === -1 && lowercasePropName.indexOf('_') <= 0) {
return false;
}
}
}

return true;
}

module.exports = {
convertToBase: convertToBase,
convertFromBase: convertFromBase,
matchFormat: matchFormat
};
14 changes: 11 additions & 3 deletions lib/packageTools.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,22 @@ function downloadFile (inputUri, callback) {

// returns package information (package.json) given a package name
function getPackageInformation (packageName) {

try {
var packagePath = path.dirname(require.main.filename);
var modulesPath = path.join(packagePath, node_modules);

try { fs.statSync(modulesPath).isDirectory(); }
catch (er) {
modulesPath = path.resolve(packagePath, '..');
}

if (packageName) {
packagePath = path.join(packagePath, node_modules, packageName);
packagePath = path.join(modulesPath, packageName);
}

packagePath = path.join(packagePath, packageJson);

return require(packagePath);
}
catch (err) {
Expand Down
2 changes: 1 addition & 1 deletion lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ function sanitizeName (name) {
while (currentLength > sanitizedName.length);

if (sanitizedName.length === 0) {
sanitizedName = 'MyManifoldJSApp';
sanitizedName = 'myManifoldJSApp';
}

return sanitizedName;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "manifoldjs-lib",
"version": "0.1.1",
"version": "0.1.2",
"description": "ManifoldJS Core Library",
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion test/common/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ describe('utils', function () {
var inputValue = '111.222.333';
var result = utils.sanitizeName(inputValue);
/*jshint -W030 */
result.should.be.exactly('MyManifoldJSApp');
result.should.be.exactly('myManifoldJSApp');
});
});
});

0 comments on commit 89b46fd

Please sign in to comment.