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

Commit 89b46fd

Browse files
author
Esteban Lopez
committed
Merge pull request #14 from manifoldjs/v0.1.2
Release v0.1.2
2 parents fac54be + fe7eff1 commit 89b46fd

File tree

7 files changed

+81
-17
lines changed

7 files changed

+81
-17
lines changed

lib/constants.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ module.exports = {
4040
BASE_MANIFEST_FORMAT: 'w3c',
4141
CHROME_MANIFEST_FORMAT: 'chromeos',
4242
FIREFOX_MANIFEST_FORMAT: 'firefox',
43-
WINDOWS10_MANIFEST_FORMAT: 'windows10',
43+
WINDOWS10_MANIFEST_FORMAT: 'windows10',
44+
EDGE_EXTENSION_FORMAT: 'edgeextension',
4445
validation: validationConstants
4546
};

lib/manifestTools/manifestValidator.js

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -112,15 +112,18 @@ function runValidationRules(w3cManifestInfo, rules, callback) {
112112
function applyValidationRules(w3cManifestInfo, platformModules, platforms) {
113113

114114
var allResults = [];
115-
116-
// load and run validation rules for "all platforms"
117-
var validationRulesDir = path.join(__dirname, 'validationRules');
118-
return loadValidationRules(validationRulesDir).then(function (rules) {
119-
return runValidationRules(w3cManifestInfo, rules).then(function (results) {
120-
allResults.push.apply(allResults, results);
115+
116+
function validateAllPlatforms() {
117+
// load and run validation rules for "all platforms"
118+
var validationRulesDir = path.join(__dirname, 'validationRules');
119+
return loadValidationRules(validationRulesDir).then(function (rules) {
120+
return runValidationRules(w3cManifestInfo, rules).then(function (results) {
121+
allResults.push.apply(allResults, results);
122+
});
121123
});
122-
})
123-
.then(function () {
124+
}
125+
126+
function validatePlatform() {
124127
// run platform-specific validation rules
125128
var platformTasks = platformModules.map(function (platform) {
126129
return platform.getValidationRules(platforms).then(function (rules) {
@@ -131,8 +134,17 @@ function applyValidationRules(w3cManifestInfo, platformModules, platforms) {
131134
});
132135

133136
return Q.allSettled(platformTasks);
134-
})
135-
.thenResolve(allResults);
137+
}
138+
139+
// Don't run the "All Platform" validattion for Edge Extensions since they are not w3c compliant
140+
if (platforms.length === 1 && platforms[0] === constants.EDGE_EXTENSION_FORMAT) {
141+
return validatePlatform()
142+
.thenResolve(allResults);
143+
} else {
144+
return validateAllPlatforms()
145+
.then(validatePlatform)
146+
.thenResolve(allResults);
147+
}
136148
}
137149

138150
function validateManifest(w3cManifestInfo, platforms, callback) {
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
'use strict';
2+
3+
function convertToBase (manifestInfo, callback) {
4+
if (!manifestInfo || !manifestInfo.content) {
5+
return callback(new Error('Manifest content is empty or not initialized.'));
6+
}
7+
8+
return callback(undefined, manifestInfo);
9+
}
10+
11+
function convertFromBase (manifestInfo, callback) {
12+
if (!manifestInfo || !manifestInfo.content) {
13+
return callback(new Error('Manifest content is empty or not initialized.'));
14+
}
15+
16+
return callback(undefined, manifestInfo);
17+
}
18+
19+
var validRootProperties = ['name', 'author', 'version', 'default_locale', 'description', 'manifest_version', 'icons', 'content_security_policy',
20+
'browser_action', 'page_action', 'background', 'commands', 'content_scripts', 'externally_connectable', 'homepage_url',
21+
'addressbar', 'options_page', 'permissions', 'optional_permissions', 'web_accessible_resources', 'minimum_edge_version',
22+
'key', '-ms-preload'];
23+
24+
function matchFormat (manifestObj) {
25+
var lowercasePropName;
26+
27+
for (var prop in manifestObj) {
28+
if (manifestObj.hasOwnProperty(prop)) {
29+
lowercasePropName = prop.toLowerCase();
30+
if (validRootProperties.indexOf(lowercasePropName) === -1 && lowercasePropName.indexOf('_') <= 0) {
31+
return false;
32+
}
33+
}
34+
}
35+
36+
return true;
37+
}
38+
39+
module.exports = {
40+
convertToBase: convertToBase,
41+
convertFromBase: convertFromBase,
42+
matchFormat: matchFormat
43+
};

lib/packageTools.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,22 @@ function downloadFile (inputUri, callback) {
6363

6464
// returns package information (package.json) given a package name
6565
function getPackageInformation (packageName) {
66-
66+
6767
try {
6868
var packagePath = path.dirname(require.main.filename);
69+
var modulesPath = path.join(packagePath, node_modules);
70+
71+
try { fs.statSync(modulesPath).isDirectory(); }
72+
catch (er) {
73+
modulesPath = path.resolve(packagePath, '..');
74+
}
75+
6976
if (packageName) {
70-
packagePath = path.join(packagePath, node_modules, packageName);
77+
packagePath = path.join(modulesPath, packageName);
7178
}
72-
79+
7380
packagePath = path.join(packagePath, packageJson);
81+
7482
return require(packagePath);
7583
}
7684
catch (err) {

lib/utils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ function sanitizeName (name) {
6767
while (currentLength > sanitizedName.length);
6868

6969
if (sanitizedName.length === 0) {
70-
sanitizedName = 'MyManifoldJSApp';
70+
sanitizedName = 'myManifoldJSApp';
7171
}
7272

7373
return sanitizedName;

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "manifoldjs-lib",
3-
"version": "0.1.1",
3+
"version": "0.1.2",
44
"description": "ManifoldJS Core Library",
55
"repository": {
66
"type": "git",

test/common/utils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ describe('utils', function () {
214214
var inputValue = '111.222.333';
215215
var result = utils.sanitizeName(inputValue);
216216
/*jshint -W030 */
217-
result.should.be.exactly('MyManifoldJSApp');
217+
result.should.be.exactly('myManifoldJSApp');
218218
});
219219
});
220220
});

0 commit comments

Comments
 (0)