1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-06-24 23:26:50 +02:00

Tools: Various improvements on plugin-repo-cli

This commit is contained in:
Laurent Cozic
2021-01-21 00:12:59 +00:00
parent f37d37e613
commit f9b0e2f6df
13 changed files with 539 additions and 3286 deletions

View File

@ -4,11 +4,12 @@ describe('validatePluginId', () => {
test('should validate an ID', () => {
const okCases = [
'thatsok',
'that-s-ok',
'that_s_fine12',
'com.ok.too',
'Good',
'joplinapp.org.plugins.thatsok',
'joplinapp.org.plugins.that-s-ok',
'joplinapp.org.plugins.that_s_fine12',
'joplinapp.org.plugins.com.ok.too',
'joplinapp.org.plugins.Good',
'outline',
];
const errorCases = [
@ -16,8 +17,9 @@ describe('validatePluginId', () => {
'verylongidverylongidverylongidverylongidverylongidverylongidverylongidverylongidverylongidverylongidverylongidverylongidverylongidverylongidverylongidverylongidverylongidverylongidverylongidverylongidverylongidverylongidverylongidverylongidverylongidverylongidverylongidverylongidverylongid',
'-shouldstartwiththis',
'shouldntendwithit.',
' no space ',
'no space',
' no space no space no space no space ',
'no spaceno spaceno spaceno spaceno space',
'tooshort',
];
for (const t of okCases) {

View File

@ -1,5 +1,7 @@
export default function(id: string): void {
if (!id) throw new Error('ID cannot be empty');
// Allow a few exceptions that existed before the limit was added
if (id.length < 16 && !['Outline', 'outline', 'MyPlugin'].includes(id)) throw new Error('ID cannot be shorter than 16 characters');
if (id.length > 256) throw new Error('ID cannot be longer than 256 characters');
const whitelist = '0-9a-zA-Z._-';