diff --git a/package-lock.json b/package-lock.json index e277ebb260..a78dc0469c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2790,6 +2790,16 @@ "integrity": "sha512-3zsplnP2djeps5P9OyarTxwRpMLoe5Ash8aL9iprw0JxB+FAHjY+ifn4yZUuW4/9hqtnmor6uvjSRzJhiVbrEQ==", "dev": true }, + "node_modules/@types/fs-extra": { + "version": "11.0.1", + "resolved": "https://registry.npmjs.org/@types/fs-extra/-/fs-extra-11.0.1.tgz", + "integrity": "sha512-MxObHvNl4A69ofaTRU8DFqvgzzv8s9yRtaPPm5gud9HDNvpB3GPQFvNuTWAI59B9huVGV5jXYJwbCsmBsOGYWA==", + "dev": true, + "dependencies": { + "@types/jsonfile": "*", + "@types/node": "*" + } + }, "node_modules/@types/glob": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/@types/glob/-/glob-7.2.0.tgz", @@ -2885,6 +2895,15 @@ "integrity": "sha512-Hr5Jfhc9eYOQNPYO5WLDq/n4jqijdHNlDXjuAQkkt+mWdQR+XJToOHrsD4cPaMXpn6KO7y2+wM8AZEs8VpBLVA==", "dev": true }, + "node_modules/@types/jsonfile": { + "version": "6.1.1", + "resolved": "https://registry.npmjs.org/@types/jsonfile/-/jsonfile-6.1.1.tgz", + "integrity": "sha512-GSgiRCVeapDN+3pqA35IkQwasaCh/0YFH5dEF6S88iDvEn901DjOeH3/QPY+XYP1DFzDZPvIvfeEgk+7br5png==", + "dev": true, + "dependencies": { + "@types/node": "*" + } + }, "node_modules/@types/keyv": { "version": "3.1.4", "resolved": "https://registry.npmjs.org/@types/keyv/-/keyv-3.1.4.tgz", @@ -2957,15 +2976,6 @@ "integrity": "sha512-ekGvFhFgrc2zYQoX4JeZPmVzZxw6Dtllga7iGHzfbYIYkAMUx/sAFP2GdFpLff+vdHXu5fl7WX9AT+TtqYcsyw==", "dev": true }, - "node_modules/@types/ncp": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/@types/ncp/-/ncp-2.0.5.tgz", - "integrity": "sha512-ocK0p8JuFmX7UkMabFPjY0F7apPvQyLWt5qtdvuvQEBz9i4m2dbzV+6L1zNaUp042RfnL6pHnxDE53OH6XQ9VQ==", - "dev": true, - "dependencies": { - "@types/node": "*" - } - }, "node_modules/@types/node": { "version": "14.18.53", "resolved": "https://registry.npmjs.org/@types/node/-/node-14.18.53.tgz", @@ -13361,14 +13371,6 @@ "node": "*" } }, - "node_modules/ncp": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ncp/-/ncp-2.0.0.tgz", - "integrity": "sha512-zIdGUrPRFTUELUvr3Gmc7KZ2Sw/h1PiVM0Af/oHB6zgnV1ikqSfRk+TOufi79aHYCW3NiOXmr1BP5nWbzojLaA==", - "bin": { - "ncp": "bin/ncp" - } - }, "node_modules/negotiator": { "version": "0.6.3", "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz", @@ -21335,11 +21337,11 @@ "bluebird": "^3.7.2", "chalk": "^4.1.2", "debug": "^4.1.0", + "fs-extra": "^11.1.1", "lodash": "^4.17.20", "marked": "^4.0.17", "merge": "^2.1.1", "mkdirp": "^1.0.4", - "ncp": "^2.0.0", "promise-limit": "^2.7.0", "tslib": "^2.4.1", "winston": "^3.7.2" @@ -21348,9 +21350,9 @@ "@oclif/test": "^1.2.6", "@types/bluebird": "^3.5.38", "@types/chai": "^4.2.18", + "@types/fs-extra": "^11.0.1", "@types/mkdirp": "^1.0.2", "@types/mocha": "^8.2.2", - "@types/ncp": "^2.0.5", "@types/node": "^14.14.32", "@types/sinon": "^10.0.2", "@types/tar": "^4.0.3", @@ -21423,6 +21425,19 @@ "@types/node": "*" } }, + "packages/contentstack-import/node_modules/fs-extra": { + "version": "11.1.1", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-11.1.1.tgz", + "integrity": "sha512-MGIE4HOvQCeUCzmlHs0vXpih4ysz4wg9qiSAu6cd42lVwPbTM1TjV7RusoyQqMmk/95gdQZX72u+YW+c3eEpFQ==", + "dependencies": { + "graceful-fs": "^4.2.0", + "jsonfile": "^6.0.1", + "universalify": "^2.0.0" + }, + "engines": { + "node": ">=14.14" + } + }, "packages/contentstack-import/node_modules/sinon": { "version": "11.1.2", "resolved": "https://registry.npmjs.org/sinon/-/sinon-11.1.2.tgz", @@ -24247,9 +24262,9 @@ "@oclif/test": "^1.2.6", "@types/bluebird": "^3.5.38", "@types/chai": "^4.2.18", + "@types/fs-extra": "^11.0.1", "@types/mkdirp": "^1.0.2", "@types/mocha": "^8.2.2", - "@types/ncp": "^2.0.5", "@types/node": "^14.14.32", "@types/sinon": "^10.0.2", "@types/tar": "^4.0.3", @@ -24261,13 +24276,13 @@ "debug": "^4.1.0", "eslint": "^8.18.0", "eslint-config-oclif": "^4.0.0", + "fs-extra": "^11.1.1", "globby": "^10.0.2", "lodash": "^4.17.20", "marked": "^4.0.17", "merge": "^2.1.1", "mkdirp": "^1.0.4", "mocha": "^10.0.0", - "ncp": "^2.0.0", "nyc": "^15.1.0", "oclif": "^3.8.1", "promise-limit": "^2.7.0", @@ -24328,6 +24343,16 @@ "@types/node": "*" } }, + "fs-extra": { + "version": "11.1.1", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-11.1.1.tgz", + "integrity": "sha512-MGIE4HOvQCeUCzmlHs0vXpih4ysz4wg9qiSAu6cd42lVwPbTM1TjV7RusoyQqMmk/95gdQZX72u+YW+c3eEpFQ==", + "requires": { + "graceful-fs": "^4.2.0", + "jsonfile": "^6.0.1", + "universalify": "^2.0.0" + } + }, "sinon": { "version": "11.1.2", "resolved": "https://registry.npmjs.org/sinon/-/sinon-11.1.2.tgz", @@ -27610,6 +27635,16 @@ "integrity": "sha512-3zsplnP2djeps5P9OyarTxwRpMLoe5Ash8aL9iprw0JxB+FAHjY+ifn4yZUuW4/9hqtnmor6uvjSRzJhiVbrEQ==", "dev": true }, + "@types/fs-extra": { + "version": "11.0.1", + "resolved": "https://registry.npmjs.org/@types/fs-extra/-/fs-extra-11.0.1.tgz", + "integrity": "sha512-MxObHvNl4A69ofaTRU8DFqvgzzv8s9yRtaPPm5gud9HDNvpB3GPQFvNuTWAI59B9huVGV5jXYJwbCsmBsOGYWA==", + "dev": true, + "requires": { + "@types/jsonfile": "*", + "@types/node": "*" + } + }, "@types/glob": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/@types/glob/-/glob-7.2.0.tgz", @@ -27707,6 +27742,15 @@ "integrity": "sha512-Hr5Jfhc9eYOQNPYO5WLDq/n4jqijdHNlDXjuAQkkt+mWdQR+XJToOHrsD4cPaMXpn6KO7y2+wM8AZEs8VpBLVA==", "dev": true }, + "@types/jsonfile": { + "version": "6.1.1", + "resolved": "https://registry.npmjs.org/@types/jsonfile/-/jsonfile-6.1.1.tgz", + "integrity": "sha512-GSgiRCVeapDN+3pqA35IkQwasaCh/0YFH5dEF6S88iDvEn901DjOeH3/QPY+XYP1DFzDZPvIvfeEgk+7br5png==", + "dev": true, + "requires": { + "@types/node": "*" + } + }, "@types/keyv": { "version": "3.1.4", "resolved": "https://registry.npmjs.org/@types/keyv/-/keyv-3.1.4.tgz", @@ -27778,15 +27822,6 @@ "integrity": "sha512-ekGvFhFgrc2zYQoX4JeZPmVzZxw6Dtllga7iGHzfbYIYkAMUx/sAFP2GdFpLff+vdHXu5fl7WX9AT+TtqYcsyw==", "dev": true }, - "@types/ncp": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/@types/ncp/-/ncp-2.0.5.tgz", - "integrity": "sha512-ocK0p8JuFmX7UkMabFPjY0F7apPvQyLWt5qtdvuvQEBz9i4m2dbzV+6L1zNaUp042RfnL6pHnxDE53OH6XQ9VQ==", - "dev": true, - "requires": { - "@types/node": "*" - } - }, "@types/node": { "version": "14.18.53", "resolved": "https://registry.npmjs.org/@types/node/-/node-14.18.53.tgz", @@ -35681,11 +35716,6 @@ "resolved": "https://registry.npmjs.org/natural-orderby/-/natural-orderby-2.0.3.tgz", "integrity": "sha512-p7KTHxU0CUrcOXe62Zfrb5Z13nLvPhSWR/so3kFulUQU0sgUll2Z0LwpsLN351eOOD+hRGu/F1g+6xDfPeD++Q==" }, - "ncp": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ncp/-/ncp-2.0.0.tgz", - "integrity": "sha512-zIdGUrPRFTUELUvr3Gmc7KZ2Sw/h1PiVM0Af/oHB6zgnV1ikqSfRk+TOufi79aHYCW3NiOXmr1BP5nWbzojLaA==" - }, "negotiator": { "version": "0.6.3", "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz", diff --git a/packages/contentstack-import/package.json b/packages/contentstack-import/package.json index 24b6dd6e5b..a3c1c6df57 100644 --- a/packages/contentstack-import/package.json +++ b/packages/contentstack-import/package.json @@ -14,11 +14,11 @@ "bluebird": "^3.7.2", "chalk": "^4.1.2", "debug": "^4.1.0", + "fs-extra": "^11.1.1", "lodash": "^4.17.20", "marked": "^4.0.17", "merge": "^2.1.1", "mkdirp": "^1.0.4", - "ncp": "^2.0.0", "promise-limit": "^2.7.0", "tslib": "^2.4.1", "winston": "^3.7.2" @@ -27,9 +27,9 @@ "@oclif/test": "^1.2.6", "@types/bluebird": "^3.5.38", "@types/chai": "^4.2.18", + "@types/fs-extra": "^11.0.1", "@types/mkdirp": "^1.0.2", "@types/mocha": "^8.2.2", - "@types/ncp": "^2.0.5", "@types/node": "^14.14.32", "@types/sinon": "^10.0.2", "@types/tar": "^4.0.3", @@ -96,4 +96,4 @@ } }, "repository": "https://github.com/contentstack/cli" -} \ No newline at end of file +} diff --git a/packages/contentstack-import/src/import/module-importer.ts b/packages/contentstack-import/src/import/module-importer.ts index 1ce2c624ca..df808bfbe0 100755 --- a/packages/contentstack-import/src/import/module-importer.ts +++ b/packages/contentstack-import/src/import/module-importer.ts @@ -48,6 +48,7 @@ class ModuleImporter { } const backupDir = await backupHandler(this.importConfig); if (backupDir) { + log(this.importConfig, `Backup directory path - '${backupDir}'`, 'info'); this.importConfig.backupDir = backupDir; // To support the old config this.importConfig.data = backupDir; diff --git a/packages/contentstack-import/src/utils/backup-handler.ts b/packages/contentstack-import/src/utils/backup-handler.ts index bc87f1b5bf..802a727896 100755 --- a/packages/contentstack-import/src/utils/backup-handler.ts +++ b/packages/contentstack-import/src/utils/backup-handler.ts @@ -1,8 +1,9 @@ import * as path from 'path'; -import ncp from 'ncp'; +import { copy } from 'fs-extra'; +import { cliux } from '@contentstack/cli-utilities'; -import { ImportConfig } from '../types'; import { fileHelper } from './index'; +import { ImportConfig } from '../types'; export default function setupBackupDir(importConfig: ImportConfig): Promise { return new Promise(async (resolve, reject) => { @@ -10,26 +11,30 @@ export default function setupBackupDir(importConfig: ImportConfig): Promise { - if (error) { - return reject(error); - } - return resolve(backupDirPath); - }); - } else { - ncp(importConfig.contentDir, backupDirPath, (error) => { + if (backupDirPath) { + return copy(importConfig.contentDir, backupDirPath, (error: any) => { if (error) { return reject(error); } @@ -38,3 +43,19 @@ export default function setupBackupDir(importConfig: ImportConfig): Promise=14.14'} + dependencies: + graceful-fs: 4.2.11 + jsonfile: 6.1.0 + universalify: 2.0.0 + dev: false + /fs-extra/8.1.0: resolution: {integrity: sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g==} engines: {node: '>=6 <7 || >=8'} @@ -9275,11 +9291,6 @@ packages: /natural-orderby/2.0.3: resolution: {integrity: sha512-p7KTHxU0CUrcOXe62Zfrb5Z13nLvPhSWR/so3kFulUQU0sgUll2Z0LwpsLN351eOOD+hRGu/F1g+6xDfPeD++Q==} - /ncp/2.0.0: - resolution: {integrity: sha512-zIdGUrPRFTUELUvr3Gmc7KZ2Sw/h1PiVM0Af/oHB6zgnV1ikqSfRk+TOufi79aHYCW3NiOXmr1BP5nWbzojLaA==} - hasBin: true - dev: false - /negotiator/0.6.3: resolution: {integrity: sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==} engines: {node: '>= 0.6'}