Continue to implement #2698: - Add `core/base-service/index.js` (but hold off on moving the things it imports) - Add shortcuts in `services/index.js` for Base*Service, errors, and deprecatedService. This file will be streamlined later to avoid cluttering it with rarely used bits. - Apply consistent ordering of imports and use of `module.exports` in testers. - Remove some renaming of imports. - Remove obsolete tests here and there.
37 lines
962 B
JavaScript
37 lines
962 B
JavaScript
'use strict'
|
|
|
|
const { BaseXmlService, NotFound } = require('..')
|
|
|
|
module.exports = class JetbrainsBase extends BaseXmlService {
|
|
static buildUrl(base) {
|
|
return {
|
|
base,
|
|
format: '(.+)',
|
|
capture: ['pluginId'],
|
|
}
|
|
}
|
|
|
|
static _validate(data, schema) {
|
|
if (data['plugin-repository'] === '') {
|
|
// Note the 'not found' response from JetBrains Plugins Repository is:
|
|
// status code = 200,
|
|
// body = <?xml version="1.0" encoding="UTF-8"?><plugin-repository></plugin-repository>
|
|
// which is parsed to object = { 'plugin-repository': '' }
|
|
throw new NotFound()
|
|
}
|
|
return super._validate(data, schema)
|
|
}
|
|
|
|
async fetchPackageData({ pluginId, schema }) {
|
|
const parserOptions = {
|
|
parseNodeValue: false,
|
|
ignoreAttributes: false,
|
|
}
|
|
return this._requestXml({
|
|
schema,
|
|
url: `https://plugins.jetbrains.com/plugins/list?pluginId=${pluginId}`,
|
|
parserOptions,
|
|
})
|
|
}
|
|
}
|