mirror of
https://github.com/plankanban/planka.git
synced 2025-08-01 19:45:26 +02:00
Add an import feature for import Trello board as JSON to Planka
This commit is contained in:
parent
cf21bef9ee
commit
a128874e95
22 changed files with 752 additions and 34620 deletions
33
server/api/helpers/download-import-data.js
Normal file
33
server/api/helpers/download-import-data.js
Normal file
|
@ -0,0 +1,33 @@
|
|||
const util = require('util');
|
||||
const stream = require('stream');
|
||||
const streamToArray = require('stream-to-array');
|
||||
|
||||
module.exports = {
|
||||
sync: true,
|
||||
|
||||
fn(inputs, exits) {
|
||||
const receiver = stream.Writable({
|
||||
objectMode: true,
|
||||
});
|
||||
|
||||
let firstFileHandled = false;
|
||||
// eslint-disable-next-line no-underscore-dangle
|
||||
receiver._write = async (file, receiverEncoding, done) => {
|
||||
if (firstFileHandled) {
|
||||
file.pipe(new stream.Writable());
|
||||
|
||||
return done();
|
||||
}
|
||||
firstFileHandled = true;
|
||||
|
||||
const buffer = await streamToArray(file).then((parts) =>
|
||||
Buffer.concat(parts.map((part) => (util.isBuffer(part) ? part : Buffer.from(part)))),
|
||||
);
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
file.extra = buffer.toString('UTF-8');
|
||||
return done();
|
||||
};
|
||||
|
||||
return exits.success(receiver);
|
||||
},
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue