diff options
author | Chocobozzz <me@florianbigard.com> | 2019-09-11 10:19:03 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2019-09-11 10:19:03 +0200 |
commit | 9157d5981f6840bfa06652ad8fd16754c6fd679d (patch) | |
tree | 36425bb2dd4fad33398f3caa73bca38c60cffdfd /server/helpers/custom-validators/plugins.ts | |
parent | 8d5e65349deebd499c0be10fe02d535a77d58ddb (diff) | |
download | PeerTube-9157d5981f6840bfa06652ad8fd16754c6fd679d.tar.gz PeerTube-9157d5981f6840bfa06652ad8fd16754c6fd679d.tar.zst PeerTube-9157d5981f6840bfa06652ad8fd16754c6fd679d.zip |
Improve plugin package.json error message
Diffstat (limited to 'server/helpers/custom-validators/plugins.ts')
-rw-r--r-- | server/helpers/custom-validators/plugins.ts | 70 |
1 files changed, 59 insertions, 11 deletions
diff --git a/server/helpers/custom-validators/plugins.ts b/server/helpers/custom-validators/plugins.ts index 63af91a44..2e3175742 100644 --- a/server/helpers/custom-validators/plugins.ts +++ b/server/helpers/custom-validators/plugins.ts | |||
@@ -84,17 +84,65 @@ function isThemeNameValid (name: string) { | |||
84 | } | 84 | } |
85 | 85 | ||
86 | function isPackageJSONValid (packageJSON: PluginPackageJson, pluginType: PluginType) { | 86 | function isPackageJSONValid (packageJSON: PluginPackageJson, pluginType: PluginType) { |
87 | return isNpmPluginNameValid(packageJSON.name) && | 87 | let result = true |
88 | isPluginDescriptionValid(packageJSON.description) && | 88 | const badFields: string[] = [] |
89 | isPluginEngineValid(packageJSON.engine) && | 89 | |
90 | isPluginHomepage(packageJSON.homepage) && | 90 | if (!isNpmPluginNameValid(packageJSON.name)) { |
91 | exists(packageJSON.author) && | 91 | result = false |
92 | isPluginBugs(packageJSON.bugs) && | 92 | badFields.push('name') |
93 | (pluginType === PluginType.THEME || isSafePath(packageJSON.library)) && | 93 | } |
94 | areStaticDirectoriesValid(packageJSON.staticDirs) && | 94 | |
95 | areCSSPathsValid(packageJSON.css) && | 95 | if (!isPluginDescriptionValid(packageJSON.description)) { |
96 | areClientScriptsValid(packageJSON.clientScripts) && | 96 | result = false |
97 | areTranslationPathsValid(packageJSON.translations) | 97 | badFields.push('description') |
98 | } | ||
99 | |||
100 | if (!isPluginEngineValid(packageJSON.engine)) { | ||
101 | result = false | ||
102 | badFields.push('engine') | ||
103 | } | ||
104 | |||
105 | if (!isPluginHomepage(packageJSON.homepage)) { | ||
106 | result = false | ||
107 | badFields.push('homepage') | ||
108 | } | ||
109 | |||
110 | if (!exists(packageJSON.author)) { | ||
111 | result = false | ||
112 | badFields.push('author') | ||
113 | } | ||
114 | |||
115 | if (!isPluginBugs(packageJSON.bugs)) { | ||
116 | result = false | ||
117 | badFields.push('bugs') | ||
118 | } | ||
119 | |||
120 | if (pluginType === PluginType.PLUGIN && !isSafePath(packageJSON.library)) { | ||
121 | result = false | ||
122 | badFields.push('library') | ||
123 | } | ||
124 | |||
125 | if (!areStaticDirectoriesValid(packageJSON.staticDirs)) { | ||
126 | result = false | ||
127 | badFields.push('staticDirs') | ||
128 | } | ||
129 | |||
130 | if (!areCSSPathsValid(packageJSON.css)) { | ||
131 | result = false | ||
132 | badFields.push('css') | ||
133 | } | ||
134 | |||
135 | if (!areClientScriptsValid(packageJSON.clientScripts)) { | ||
136 | result = false | ||
137 | badFields.push('clientScripts') | ||
138 | } | ||
139 | |||
140 | if (!areTranslationPathsValid(packageJSON.translations)) { | ||
141 | result = false | ||
142 | badFields.push('translations') | ||
143 | } | ||
144 | |||
145 | return { result, badFields } | ||
98 | } | 146 | } |
99 | 147 | ||
100 | function isLibraryCodeValid (library: any) { | 148 | function isLibraryCodeValid (library: any) { |