Merge pull request #14748 from strapi/deits/streams-cleanup

[DEITS] Cleanup (tooling & error handling)
This commit is contained in:
Ben Irvin 2022-11-02 11:05:29 +01:00 committed by GitHub
commit c4bf41916c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 4 deletions

View File

@ -132,8 +132,11 @@ class TransferEngine implements ITransferEngine {
const inStream = await this.sourceProvider.streamEntities?.(); const inStream = await this.sourceProvider.streamEntities?.();
const outStream = await this.destinationProvider.getEntitiesStream?.(); const outStream = await this.destinationProvider.getEntitiesStream?.();
if (!inStream || !outStream) { if (!inStream) {
throw new Error('Unable to transfer entities, one of the stream is missing'); throw new Error('Unable to transfer entities, source stream is missing');
}
if (!outStream) {
throw new Error('Unable to transfer entities, destination stream is missing');
} }
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
@ -159,8 +162,11 @@ class TransferEngine implements ITransferEngine {
const inStream = await this.sourceProvider.streamLinks?.(); const inStream = await this.sourceProvider.streamLinks?.();
const outStream = await this.destinationProvider.getLinksStream?.(); const outStream = await this.destinationProvider.getLinksStream?.();
if (!inStream || !outStream) { if (!inStream) {
throw new Error('Unable to transfer links, one of the stream is missing'); throw new Error('Unable to transfer links, source stream is missing');
}
if (!outStream) {
throw new Error('Unable to transfer links, destination stream is missing');
} }
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {

View File

@ -28,6 +28,8 @@
"types": "./dist/index.d.ts", "types": "./dist/index.d.ts",
"scripts": { "scripts": {
"build": "tsc -p tsconfig.json", "build": "tsc -p tsconfig.json",
"clean": "rimraf ./dist",
"build:clean": "yarn clean && yarn build",
"watch": "yarn build -w", "watch": "yarn build -w",
"test:unit": "jest --verbose" "test:unit": "jest --verbose"
}, },
@ -48,6 +50,7 @@
"@types/stream-chain": "2.0.1", "@types/stream-chain": "2.0.1",
"@types/stream-json": "1.7.2", "@types/stream-json": "1.7.2",
"@types/tar": "6.1.3", "@types/tar": "6.1.3",
"rimraf": "3.0.2",
"typescript": "4.8.4" "typescript": "4.8.4"
}, },
"engines": { "engines": {

View File

@ -7,6 +7,7 @@ const {
// TODO: we need to solve this issue with typescript modules // TODO: we need to solve this issue with typescript modules
// eslint-disable-next-line import/no-unresolved, node/no-missing-require // eslint-disable-next-line import/no-unresolved, node/no-missing-require
} = require('@strapi/data-transfer'); } = require('@strapi/data-transfer');
const strapi = require('../../Strapi'); const strapi = require('../../Strapi');
const getDefaultExportBackupName = () => `strapi-backup`; const getDefaultExportBackupName = () => `strapi-backup`;