Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

Commit

Permalink
Merge pull request #3168 from adobe/dangoor/install-extension-fixes
Browse files Browse the repository at this point in the history
Extension Install fixes based on feedback in 3158
  • Loading branch information
Narciso Jaramillo committed Mar 19, 2013
2 parents 0593092 + 17e9b6a commit a2a4f8e
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 8 deletions.
8 changes: 4 additions & 4 deletions src/extensibility/node/ExtensionManagerDomain.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ var pendingDownloads = {};
*/
function validateName(name) {
// "This must be a unique, lowercase alpha-numeric name without spaces. It may include "." or "_" or "-" characters."
if (/^[a-z._\-]+$/.exec(name)) {
if (/^[a-z0-9._\-]+$/.exec(name)) {
return true;
}
return false;
Expand Down Expand Up @@ -104,7 +104,7 @@ function _cmdValidate(path, callback) {
}
var callbackCalled = false;
var metadata;
var foundMain = false;
var foundMainIn = null;
var errors = [];
var commonPrefix = null;

Expand Down Expand Up @@ -183,7 +183,7 @@ function _cmdValidate(path, callback) {
}
});
} else if (fileName === "main.js") {
foundMain = true;
foundMainIn = commonPrefix;
}
})
.on("end", function () {
Expand All @@ -195,7 +195,7 @@ function _cmdValidate(path, callback) {
return;
}

if (!foundMain) {
if (foundMainIn === null || foundMainIn !== commonPrefix) {
errors.push([Errors.MISSING_MAIN, path]);
}

Expand Down
11 changes: 11 additions & 0 deletions src/extensibility/node/spec/Validation.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ var basicValidExtension = path.join(testFilesDirectory, "basic-valid-extension.z
oneLevelDown = path.join(testFilesDirectory, "one-level-extension-master.zip"),
bogusTopDir = path.join(testFilesDirectory, "bogus-top-dir.zip"),
badname = path.join(testFilesDirectory, "badname.zip"),
mainInDirectory = path.join(testFilesDirectory, "main-in-directory.zip"),
invalidVersion = path.join(testFilesDirectory, "invalid-version.zip");

describe("Package Validation", function () {
Expand Down Expand Up @@ -168,4 +169,14 @@ describe("Package Validation", function () {
done();
});
});

it("should complain about files that don't have main in the top dir", function (done) {
ExtensionsDomain._cmdValidate(mainInDirectory, function (err, result) {
expect(err).toBeNull();
var errors = result.errors;
expect(errors.length).toEqual(1);
expect(errors[0][0]).toEqual("MISSING_MAIN");
done();
});
});
});
10 changes: 6 additions & 4 deletions tasks/update-sprint-number.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
* DEALINGS IN THE SOFTWARE.
*
*/
/*global module, require*/
/*global module, require*/

module.exports = function (grunt) {
"use strict";

Expand All @@ -31,14 +32,15 @@ module.exports = function (grunt) {
grunt.registerTask('update-sprint-number', function () {
var path = "package.json",
packageJSON = grunt.file.readJSON(path),
sprint = grunt.option("sprint") || 0;
sprint = grunt.option("sprint") || 0,
versionNumberRegexp = /([0-9]+\.)([0-9]+)([\.\-a-zA-Z0-9]*)?/;

if (!sprint) {
grunt.fail.fatal("Please specify a sprint. e.g. grunt update-sprint-number --sprint=21");
}

packageJSON.version = packageJSON.version.replace(/([0-9]+\.)([0-9]+)([\.\-a-zA-Z0-9]*)?/, "$1" + sprint + "$3");
packageJSON.apiVersion = packageJSON.apiVersion.replace(/([0-9]+\.)([0-9]+)([\.\-a-zA-Z0-9]*)?/, "$1" + sprint + "$3");
packageJSON.version = packageJSON.version.replace(versionNumberRegexp, "$1" + sprint + "$3");
packageJSON.apiVersion = packageJSON.apiVersion.replace(versionNumberRegexp, "$1" + sprint + "$3");

common.writeJSON(grunt, path, packageJSON);
});
Expand Down
Binary file added test/spec/extension-test-files/main-in-directory.zip
Binary file not shown.

0 comments on commit a2a4f8e

Please sign in to comment.