Fix metadata editing
This commit is contained in:
parent
79f1b01506
commit
4e6a8ea05b
22
cdbedit.js
22
cdbedit.js
@ -12,22 +12,26 @@ module.exports = async () => {
|
||||
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];
|
||||
for(let k of Object.keys(resp.body)) {
|
||||
if(k === 'screenshots') continue;
|
||||
const o = resp.body[k];
|
||||
let n = config[k];
|
||||
if(n === undefined || sortser(o) === sortser(n)) continue;
|
||||
console.log({
|
||||
old: sortser(o),
|
||||
new: sortser(n)
|
||||
});
|
||||
edits[k] = config[k];
|
||||
}
|
||||
if(!Object.keys(edits)
|
||||
.length)
|
||||
return mylog('package metadata already up to date');
|
||||
|
||||
mylog(`metadata edits: ${Object.keys(edits).sort().join(', ')}`);
|
||||
if(config.dryrun)
|
||||
return mylog(`DRY RUN: package metadata edits: ${JSON.stringify(edits)}`);
|
||||
return mylog('metadata edit DRY RUN ABORT');
|
||||
|
||||
mylog('updating package metadata...');
|
||||
await cdbfetch(pkgurl, 'post', edits, { json: true });
|
||||
await cdbfetch(pkgurl, 'put', edits, { json: true });
|
||||
mylog('package metadata updated');
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user