8362e41b0e
Left to do: - test out including commit hash, when ruben finishes implementing this in the API. - screenshot reconciliation.
34 lines
1006 B
JavaScript
34 lines
1006 B
JavaScript
'use strict';
|
|
|
|
const mylog = require('./mylog');
|
|
const config = require('./config');
|
|
const cdbfetch = require('./cdbfetch');
|
|
|
|
const sortser = obj => JSON.stringify(Array.isArray(obj) ? obj.sort() : obj);
|
|
|
|
module.exports = async () => {
|
|
const pkgurl = `/packages/${config.user}/${config.pkg}/`;
|
|
mylog('checking existing package metadata...');
|
|
const resp = await cdbfetch(pkgurl);
|
|
|
|
const edits = {};
|
|
Object.keys(resp.body)
|
|
.filter(k => k !== 'screenshots' && config[k] !== undefined)
|
|
.forEach(k => {
|
|
if(sortser(resp.body[k]) !== sortser(k === 'long_description' ?
|
|
config[k].replace(/\r/g, '')
|
|
.replace(/\n/g, '\r\n') : config[k]))
|
|
edits[k] = config[k];
|
|
});
|
|
if(!Object.keys(edits)
|
|
.length)
|
|
return mylog('package metadata already up to date');
|
|
|
|
if(config.dryrun)
|
|
return mylog(`DRY RUN: package metadata edits: ${JSON.stringify(edits)}`);
|
|
|
|
mylog('updating package metadata...');
|
|
await cdbfetch(pkgurl, 'post', edits, { json: true });
|
|
mylog('package metadata updated');
|
|
};
|