From e5743121d9f68e9cd961b57d2fb8558044e4dc8e Mon Sep 17 00:00:00 2001 From: Triangle717 Date: Fri, 3 Oct 2014 17:10:29 -0400 Subject: [PATCH] Remove main.js requirement for themes adobe/brackets#8626 --- src/extensibility/node/package-validator.js | 7 +++++-- src/extensibility/node/package.json | 2 +- .../node/spec/Installation.spec.js | 2 +- .../node/spec/Validation.spec.js | 10 +++++++++ .../basic-valid-theme-1.0.zip | Bin 0 -> 543 bytes .../basic-valid-theme-1.0/package.json | 19 ++++++++++++++++++ .../basic-valid-theme-1.0/theme.less | 0 7 files changed, 36 insertions(+), 4 deletions(-) create mode 100644 test/spec/extension-test-files/basic-valid-theme-1.0.zip create mode 100644 test/spec/extension-test-files/basic-valid-theme-1.0/package.json create mode 100644 test/spec/extension-test-files/basic-valid-theme-1.0/theme.less diff --git a/src/extensibility/node/package-validator.js b/src/extensibility/node/package-validator.js index a44d172e0da..9cf5f98afcc 100644 --- a/src/extensibility/node/package-validator.js +++ b/src/extensibility/node/package-validator.js @@ -287,8 +287,11 @@ function extractAndValidateFiles(zipPath, extractDir, options, callback) { callback(err, null); return; } - var mainJS = path.join(extractDir, commonPrefix, "main.js"); - if (!fs.existsSync(mainJS)) { + var mainJS = path.join(extractDir, commonPrefix, "main.js"), + isTheme = metadata && metadata.theme; + + // Throw missing main.js file only for non-theme extensions + if (!isTheme && !fs.existsSync(mainJS)) { errors.push([Errors.MISSING_MAIN, zipPath, mainJS]); } callback(null, { diff --git a/src/extensibility/node/package.json b/src/extensibility/node/package.json index e83a1edc617..87d31de2a9f 100644 --- a/src/extensibility/node/package.json +++ b/src/extensibility/node/package.json @@ -1,7 +1,7 @@ { "name": "brackets-extensibility", "description": "Used in the management of Brackets extensions", - "version": "0.32.0", + "version": "0.45.0", "dependencies": { "decompress-zip": "0.0.2", "semver": "2.x", diff --git a/src/extensibility/node/spec/Installation.spec.js b/src/extensibility/node/spec/Installation.spec.js index 9d24ba435cf..e65d7bef828 100644 --- a/src/extensibility/node/spec/Installation.spec.js +++ b/src/extensibility/node/spec/Installation.spec.js @@ -56,7 +56,7 @@ var basicValidExtension = path.join(testFilesDirectory, "basic-valid-exten missingPackageJSON = path.join(testFilesDirectory, "missing-package-json.zip"), missingPackageJSONUpdate = path.join(testFilesDirectory, "missing-package-json-update.zip"), missingPackageJSONRenamed = path.join(testFilesDirectory, "added-package-json-test", "missing-package-json.zip"), - withSymlink = path.join(testFilesDirectory, "with-symlink.zip"); + withSymlink = path.join(testFilesDirectory, "with-symlink.zip"); describe("Package Installation", function () { diff --git a/src/extensibility/node/spec/Validation.spec.js b/src/extensibility/node/spec/Validation.spec.js index 81cd35f7612..eb996e04086 100644 --- a/src/extensibility/node/spec/Validation.spec.js +++ b/src/extensibility/node/spec/Validation.spec.js @@ -44,6 +44,7 @@ var testFilesDirectory = path.join(path.dirname(module.filename), var basicValidExtension = path.join(testFilesDirectory, "basic-valid-extension.zip"), basicValidExtension2 = path.join(testFilesDirectory, "basic-valid-extension-2.0.zip"), + basicValidTheme = path.join(testFilesDirectory, "basic-valid-theme-1.0.zip"), missingPackageJSON = path.join(testFilesDirectory, "missing-package-json.zip"), invalidJSON = path.join(testFilesDirectory, "invalid-json.zip"), invalidZip = path.join(testFilesDirectory, "invalid-zip-file.zip"), @@ -167,6 +168,15 @@ describe("Package Validation", function () { }); }); + it("should NOT require a main.js in the zip file for a theme", function (done) { + packageValidator.validate(basicValidTheme, {}, function (err, result) { + expect(err).toBeNull(); + expect(result.errors.length).toEqual(0); + expect(result.metadata.theme).toBeDefined(); + done(); + }); + }); + it("should determine the common prefix if there is one", function (done) { packageValidator.validate(oneLevelDown, {}, function (err, result) { expect(err).toBeNull(); diff --git a/test/spec/extension-test-files/basic-valid-theme-1.0.zip b/test/spec/extension-test-files/basic-valid-theme-1.0.zip new file mode 100644 index 0000000000000000000000000000000000000000..fe1ab3625e3ac6b479e2104d1a244c74b50ca540 GIT binary patch literal 543 zcmWIWW@Zs#U|`^25UFx?727M2{ujs-WMW|80n!DD$=QkNsd`z(`FXVy5BeQ8;Awkb z+ohpCVOv>@c8i42^tpoKCcf`pP1>O2xY4|2*^QFo53*+QD}T8_|10nU#yoF7Ak+`lZD+k3`$?+S5oS-v%M`afObk*of= zLf0@$J5P~Q`gH~KGUxN(8C8$)1ibz8dhU*(Gw*XR|LHS*%zk}(P;~mu*Y6IT3)c8C z>553CC2QF#nV&U&m){y>70jKD3bUMJBl?~)9CLr7er2T;=FfafB D (http://thoseeinsteins.org/alfred)", + "contributors": [ + "Johan Einstein", + { + "name": "Albert Einstein Jr.", + "email": "not_that_albert@thoseeinsteins.org" + }, + "Jens Einstein " + ], + "theme": { + "file": "theme.less", + "dark": false + }, + "keywords": ["theme"] +} diff --git a/test/spec/extension-test-files/basic-valid-theme-1.0/theme.less b/test/spec/extension-test-files/basic-valid-theme-1.0/theme.less new file mode 100644 index 00000000000..e69de29bb2d