From 204dab9d76390ba71a784dbbfb1423ec5cc99497 Mon Sep 17 00:00:00 2001 From: Ash Date: Mon, 4 Mar 2019 16:57:12 -0500 Subject: [PATCH 1/9] Version formats for host and plugin. --- lib/validate.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/validate.js b/lib/validate.js index 15bab99..5b82c53 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -19,8 +19,10 @@ const PLUGIN_NAME_MAX_LEN = 45; const SUPPORTED_HOSTS = ["XD"]; const PLUGIN_VERSION_REGEX = /^\d{1,2}\.\d{1,2}.\d{1,2}$/; const HOST_VERSION_REGEX = /^\d{1,2}\.\d{1,2}$/; -const MIN_VERSION = "0.0.1"; -const MAX_VERSION = "99.99.99"; +const PLUGIN_MIN_VERSION = "0.0.1"; +const PLUGIN_MAX_VERSION = "99.99.99"; +const HOST_MIN_VERSION = "13.0"; +const HOST_MAX_VERSION = "99.99"; const fs = require("fs"); const path = require("path"); @@ -74,7 +76,7 @@ function validate(manifest, { root, id } = {}) { errors.push( `F1031: Version format is incorrect. Saw ${ manifest.version - }, expected ${MIN_VERSION} - ${MAX_VERSION}.` + }, expected ${PLUGIN_MIN_VERSION} - ${PLUGIN_MAX_VERSION}.` ); } } @@ -111,7 +113,7 @@ function validate(manifest, { root, id } = {}) { errors.push( `F1024: Host minimum version format is incorrect. Saw ${ manifest.host.minVersion - }, expected ${MIN_VERSION} - ${MAX_VERSION}.` + }, expected ${HOST_MIN_VERSION} - ${HOST_MAX_VERSION}.` ); } } @@ -122,7 +124,7 @@ function validate(manifest, { root, id } = {}) { errors.push( `F1025: Host maximum version format is incorrect. Saw ${ manifest.host.maxVersion - }, expected ${MIN_VERSION} - ${MAX_VERSION}.` + }, expected ${HOST_MIN_VERSION} - ${HOST_MAX_VERSION}.` ); } } From aa13d33ae8bc5b81f9cb0334b92188e749268861 Mon Sep 17 00:00:00 2001 From: Ash Date: Mon, 4 Mar 2019 17:07:03 -0500 Subject: [PATCH 2/9] Validate summary and description. --- lib/validate.js | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/lib/validate.js b/lib/validate.js index 5b82c53..b09cf87 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -16,6 +16,10 @@ const PLUGIN_NAME_MIN_LEN = 3; const PLUGIN_NAME_MAX_LEN = 45; +const PLUGIN_DESC_MIN_LEN = 3; +const PLUGIN_DESC_MAX_LEN = 1000; +const PLUGIN_SUMMARY_MIN_LEN = 3; +const PLUGIN_SUMMARY_MAX_LEN = 30; const SUPPORTED_HOSTS = ["XD"]; const PLUGIN_VERSION_REGEX = /^\d{1,2}\.\d{1,2}.\d{1,2}$/; const HOST_VERSION_REGEX = /^\d{1,2}\.\d{1,2}$/; @@ -164,6 +168,38 @@ function validate(manifest, { root, id } = {}) { } } + // validate description + if (!manifest.description) { + errors.push("F1050: Manifest must contain a plugin description."); + } else { + if ( + manifest.description.length < PLUGIN_DESC_MIN_LEN || + manifest.description.length > PLUGIN_DESC_MAX_LEN + ) { + errors.push( + `F1051: Manifest description is not an appropriate length (expected ${PLUGIN_DESC_MIN_LEN} - ${PLUGIN_DESC_MAX_LEN} chars, saw ${ + manifest.description.length + } chars).` + ); + } + } + + // validate summary + if (!manifest.summary) { + errors.push("F1060: Manifest must contain a plugin summary."); + } else { + if ( + manifest.summary.length < PLUGIN_SUMMARY_MIN_LEN || + manifest.summary.length > PLUGIN_SUMMARY_MAX_LEN + ) { + errors.push( + `F1051: Manifest description is not an appropriate length (expected ${PLUGIN_SUMMARY_MIN_LEN} - ${PLUGIN_SUMMARY_MAX_LEN} chars, saw ${ + manifest.summary.length + } chars).` + ); + } + } + return errors; } From 11298db1559ef8b6c3d6f05ffe28e4054c198fb0 Mon Sep 17 00:00:00 2001 From: Ash Date: Mon, 4 Mar 2019 17:27:29 -0500 Subject: [PATCH 3/9] Validate keywords. --- lib/validate.js | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/lib/validate.js b/lib/validate.js index b09cf87..ff6b7ce 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -20,6 +20,8 @@ const PLUGIN_DESC_MIN_LEN = 3; const PLUGIN_DESC_MAX_LEN = 1000; const PLUGIN_SUMMARY_MIN_LEN = 3; const PLUGIN_SUMMARY_MAX_LEN = 30; +const KEYWORD_MIN_LEN = 2; +const KEYWORD_CONCAT_MAX_LEN = 100; const SUPPORTED_HOSTS = ["XD"]; const PLUGIN_VERSION_REGEX = /^\d{1,2}\.\d{1,2}.\d{1,2}$/; const HOST_VERSION_REGEX = /^\d{1,2}\.\d{1,2}$/; @@ -200,6 +202,33 @@ function validate(manifest, { root, id } = {}) { } } + // validate keywords + if (manifest.keywords) { + if (!Array.isArray(manifest.keywords)) { + errors.push("W2010: Keywords should be an array."); + } else { + // check if each keyword meets length requirements + const concatKeywords = manifest.keywords.reduce((initVal, keyword) => + keyword.length >= KEYWORD_MIN_LEN + ? initVal + keyword + : errors.push( + `W2011: Keywords should be at least ${KEYWORD_MIN_LEN} chars. Found keyword ${keyword} with ${ + keyword.length + } chars.` + ) + ); + + // check if concatenated keywords meets length requirements + if (concatKeywords.length > KEYWORD_CONCAT_MAX_LEN) { + errors.push( + `W2012: Concatenated length of all keywords should be no more than ${KEYWORD_CONCAT_MAX_LEN} chars. Found ${ + concatKeywords.length + } chars.` + ); + } + } + } + return errors; } From 3cddceb5e26f9847b156ba49833b66b72b3cf20d Mon Sep 17 00:00:00 2001 From: Ash Date: Mon, 4 Mar 2019 17:32:11 -0500 Subject: [PATCH 4/9] Validate release notes. --- lib/validate.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lib/validate.js b/lib/validate.js index ff6b7ce..0b943bf 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -20,6 +20,8 @@ const PLUGIN_DESC_MIN_LEN = 3; const PLUGIN_DESC_MAX_LEN = 1000; const PLUGIN_SUMMARY_MIN_LEN = 3; const PLUGIN_SUMMARY_MAX_LEN = 30; +const RELEASE_NOTES_MIN_LEN = 3; +const RELEASE_NOTES_MAX_LEN = 1000; const KEYWORD_MIN_LEN = 2; const KEYWORD_CONCAT_MAX_LEN = 100; const SUPPORTED_HOSTS = ["XD"]; @@ -229,6 +231,20 @@ function validate(manifest, { root, id } = {}) { } } + // validate release notes + if (manifest.releaseNotes) { + if ( + manifest.releaseNotes.length < RELEASE_NOTES_MIN_LEN || + manifest.releaseNotes.length > RELEASE_NOTES_MAX_LEN + ) { + errors.push( + `W2020: Release notes are not an appropriate length (expected ${RELEASE_NOTES_MIN_LEN} - ${RELEASE_NOTES_MAX_LEN} chars, saw ${ + manifest.releaseNotes.length + } chars).` + ); + } + } + return errors; } From ed122559a2149712c6e4e62e4e7cd101c271937b Mon Sep 17 00:00:00 2001 From: Ash Date: Mon, 4 Mar 2019 17:45:35 -0500 Subject: [PATCH 5/9] Validate languages. --- lib/validate.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/lib/validate.js b/lib/validate.js index 0b943bf..141a015 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -25,6 +25,7 @@ const RELEASE_NOTES_MAX_LEN = 1000; const KEYWORD_MIN_LEN = 2; const KEYWORD_CONCAT_MAX_LEN = 100; const SUPPORTED_HOSTS = ["XD"]; +const SUPPORTED_LANGUAGES = ["en", "de", "fr", "ja", "ko", "zh", "es", "pt"]; const PLUGIN_VERSION_REGEX = /^\d{1,2}\.\d{1,2}.\d{1,2}$/; const HOST_VERSION_REGEX = /^\d{1,2}\.\d{1,2}$/; const PLUGIN_MIN_VERSION = "0.0.1"; @@ -245,6 +246,28 @@ function validate(manifest, { root, id } = {}) { } } + // validate keywords + if (!manifest.languages) { + errors.push("F1070: Manifest must contain supported languages."); + } else { + if (!Array.isArray(manifest.languages) || manifest.languages.length === 0) { + errors.push( + "F1071: Languages should be an array with at least one element." + ); + } else { + // check if each keyword meets length requirements + manifest.languages.map(lang => + SUPPORTED_LANGUAGES.includes(lang) + ? lang + : errors.push( + `Unsupported language code "${lang}" found. \nOnly these language codes are supported: ${SUPPORTED_LANGUAGES.join( + ", " + )}.` + ) + ); + } + } + return errors; } From 3b38f578b4dfb90d5ad0a893e0837539b7391b30 Mon Sep 17 00:00:00 2001 From: Ash Date: Mon, 4 Mar 2019 17:53:27 -0500 Subject: [PATCH 6/9] Validate author. --- lib/validate.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/lib/validate.js b/lib/validate.js index 141a015..19b7c4f 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -22,6 +22,8 @@ const PLUGIN_SUMMARY_MIN_LEN = 3; const PLUGIN_SUMMARY_MAX_LEN = 30; const RELEASE_NOTES_MIN_LEN = 3; const RELEASE_NOTES_MAX_LEN = 1000; +const AUTHOR_MIN_LEN = 3; +const AUTHOR_MAX_LEN = 40; const KEYWORD_MIN_LEN = 2; const KEYWORD_CONCAT_MAX_LEN = 100; const SUPPORTED_HOSTS = ["XD"]; @@ -268,6 +270,21 @@ function validate(manifest, { root, id } = {}) { } } + if (!manifest.author) { + errors.push("F1080: Manifest must contain author."); + } else { + if ( + manifest.author.length < AUTHOR_MIN_LEN || + manifest.author.length > AUTHOR_MAX_LEN + ) { + errors.push( + `F1081: Author is not an appropriate length (expected ${AUTHOR_MIN_LEN} - ${AUTHOR_MAX_LEN} chars, saw ${ + manifest.author.length + } chars).` + ); + } + } + return errors; } From d4d0cc667b7041ee21589b04b7e17fa594b6185a Mon Sep 17 00:00:00 2001 From: Ash Date: Mon, 4 Mar 2019 18:10:51 -0500 Subject: [PATCH 7/9] Updated icon validation. --- lib/validate.js | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/lib/validate.js b/lib/validate.js index 19b7c4f..2af185a 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -26,6 +26,8 @@ const AUTHOR_MIN_LEN = 3; const AUTHOR_MAX_LEN = 40; const KEYWORD_MIN_LEN = 2; const KEYWORD_CONCAT_MAX_LEN = 100; +const ICONS_LEN = 4; +const ICONS_SIZES = [48, 96, 144, 192]; const SUPPORTED_HOSTS = ["XD"]; const SUPPORTED_LANGUAGES = ["en", "de", "fr", "ja", "ko", "zh", "es", "pt"]; const PLUGIN_VERSION_REGEX = /^\d{1,2}\.\d{1,2}.\d{1,2}$/; @@ -147,9 +149,13 @@ function validate(manifest, { root, id } = {}) { } // validate icons - if (manifest.icons) { - if (!Array.isArray(manifest.icons)) { - errors.push("W2000: Icons should be an array."); + if (!manifest.icons) { + errors.push("W2010: Manifest must contain icons."); + } else { + if (!Array.isArray(manifest.icons) || manifest.icons.length !== ICONS_LEN) { + errors.push( + `W2000: Icons should be an array with ${ICONS_LEN} elements.` + ); } else { manifest.icons.forEach((icon, idx) => { if (!icon.width) { @@ -161,6 +167,16 @@ function validate(manifest, { root, id } = {}) { if (icon.width && icon.height && icon.width !== icon.height) { errors.push(`W2003: Icon ${idx} should be square.`); } + if ( + !ICONS_SIZES.includes(icon.width) || + !ICONS_SIZES.includes(icon.height) + ) { + errors.push( + `W2005: Icon ${idx} has at least one inaccurate dimension. Expected one of the following: ${ICONS_SIZES.join( + ", " + )}.` + ); + } if (!icon.path) { errors.push(`W2004: Icon ${idx} should specify a path.`); } From 20cef9fecb3bef60ea386ac84f9f0b1f8c1db451 Mon Sep 17 00:00:00 2001 From: Yoshiki Takeoka Date: Tue, 5 Mar 2019 20:45:52 +0900 Subject: [PATCH 8/9] Fix error message for `summary` property. --- lib/validate.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/validate.js b/lib/validate.js index 2af185a..eee6b3e 100644 --- a/lib/validate.js +++ b/lib/validate.js @@ -216,7 +216,7 @@ function validate(manifest, { root, id } = {}) { manifest.summary.length > PLUGIN_SUMMARY_MAX_LEN ) { errors.push( - `F1051: Manifest description is not an appropriate length (expected ${PLUGIN_SUMMARY_MIN_LEN} - ${PLUGIN_SUMMARY_MAX_LEN} chars, saw ${ + `F1051: Manifest summary is not an appropriate length (expected ${PLUGIN_SUMMARY_MIN_LEN} - ${PLUGIN_SUMMARY_MAX_LEN} chars, saw ${ manifest.summary.length } chars).` ); From 25f5fca85e6181bfe6d284443c215e0b89afeea9 Mon Sep 17 00:00:00 2001 From: Ash Date: Tue, 5 Mar 2019 11:44:04 -0500 Subject: [PATCH 9/9] Updated version number. --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 9036ace..0637aa8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@adobe/xdpm", - "version": "1.1.2", + "version": "2.0.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index c32b804..0137048 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@adobe/xdpm", - "version": "1.1.2", + "version": "2.0.0", "description": "Adobe XD CLI Plugin Manager Utility", "main": "index.js", "scripts": {