Skip to content

Commit

Permalink
Chore: Seperate allPossibleCategories to @joplin/lib (laurent22#6754)
Browse files Browse the repository at this point in the history
  • Loading branch information
Retr0ve committed Sep 9, 2022
1 parent a7cdcaf commit 6efe8c1
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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`);
Expand Down Expand Up @@ -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`);
});
}

Expand Down
35 changes: 35 additions & 0 deletions packages/lib/pluginCategories.json
Original file line number Diff line number Diff line change
@@ -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"
}
]

0 comments on commit 6efe8c1

Please sign in to comment.