From 6efe8c171a6b01d9c65bf2a6e467653629bfc6cd Mon Sep 17 00:00:00 2001 From: Retrove Date: Fri, 9 Sep 2022 10:05:08 -0400 Subject: [PATCH] Chore: Seperate allPossibleCategories to @joplin/lib (#6754) --- .../app/templates/package_TEMPLATE.json | 3 +- .../app/templates/webpack.config.js | 4 +-- packages/lib/pluginCategories.json | 35 +++++++++++++++++++ 3 files changed, 39 insertions(+), 3 deletions(-) create mode 100644 packages/lib/pluginCategories.json diff --git a/packages/generator-joplin/generators/app/templates/package_TEMPLATE.json b/packages/generator-joplin/generators/app/templates/package_TEMPLATE.json index 645c51981..c81c3e364 100644 --- a/packages/generator-joplin/generators/app/templates/package_TEMPLATE.json +++ b/packages/generator-joplin/generators/app/templates/package_TEMPLATE.json @@ -25,6 +25,7 @@ "typescript": "^3.9.3", "webpack": "^4.43.0", "webpack-cli": "^3.3.11", - "yargs": "^16.2.0" + "yargs": "^16.2.0", + "@joplin/lib": "~2.9" } } diff --git a/packages/generator-joplin/generators/app/templates/webpack.config.js b/packages/generator-joplin/generators/app/templates/webpack.config.js index 6d0272276..e9bf6de34 100644 --- a/packages/generator-joplin/generators/app/templates/webpack.config.js +++ b/packages/generator-joplin/generators/app/templates/webpack.config.js @@ -15,6 +15,7 @@ const WebpackOnBuildPlugin = require('on-build-webpack'); const tar = require('tar'); const glob = require('glob'); const execSync = require('child_process').execSync; +const allPossibleCategories = require('@joplin/lib/pluginCategories.json'); const rootDir = path.resolve(__dirname); const userConfigFilename = './plugin.config.json'; @@ -29,7 +30,6 @@ const userConfig = Object.assign({}, { const manifestPath = `${srcDir}/manifest.json`; const packageJsonPath = `${rootDir}/package.json`; -const allPossibleCategories = ['appearance', 'developer tools', 'productivity', 'themes', 'integrations', 'viewer', 'search', 'tags', 'editor', 'files', 'personal knowledge management']; const allPossibleScreenshotsType = ['jpg', 'jpeg', 'png', 'gif', 'webp']; const manifest = readManifest(manifestPath); const pluginArchiveFilePath = path.resolve(publishDir, `${manifest.id}.jpl`); @@ -73,7 +73,7 @@ function validateCategories(categories) { if (!categories) return null; if ((categories.length !== new Set(categories).size)) throw new Error('Repeated categories are not allowed'); categories.forEach(category => { - if (!allPossibleCategories.includes(category)) throw new Error(`${category} is not a valid category. Please make sure that the category name is lowercase. Valid Categories are: \n${allPossibleCategories}\n`); + if (!allPossibleCategories.map(category => { return category.name; }).includes(category)) throw new Error(`${category} is not a valid category. Please make sure that the category name is lowercase. Valid categories are: \n${allPossibleCategories.map(category => { return category.name; })}\n`); }); } diff --git a/packages/lib/pluginCategories.json b/packages/lib/pluginCategories.json new file mode 100644 index 000000000..bf6415318 --- /dev/null +++ b/packages/lib/pluginCategories.json @@ -0,0 +1,35 @@ +[ + { + "name": "appearance" + }, + { + "name": "developer tools" + }, + { + "name": "productivity" + }, + { + "name": "themes" + }, + { + "name": "integrations" + }, + { + "name": "viewer" + }, + { + "name": "search" + }, + { + "name": "tags" + }, + { + "name": "editor" + }, + { + "name": "files" + }, + { + "name": "personal knowledge management" + } +] \ No newline at end of file