diff --git a/package-lock.json b/package-lock.json index a6450cc762..960e38abe1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -823,9 +823,9 @@ "link": true }, "node_modules/@contentstack/json-rte-serializer": { - "version": "2.0.10", - "resolved": "https://registry.npmjs.org/@contentstack/json-rte-serializer/-/json-rte-serializer-2.0.10.tgz", - "integrity": "sha512-32tzzNTaXsfJjuPe2x0xz1f1c3JKKtS7XHBo2y6C4NujKe2ROW2Fq50VjdEYbjm7oo8uOt4yOE1XZpj0KjmQXQ==", + "version": "2.0.11", + "resolved": "https://registry.npmjs.org/@contentstack/json-rte-serializer/-/json-rte-serializer-2.0.11.tgz", + "integrity": "sha512-FOcB3YANmCchIPXblYi5LZ8viViVslhLibHsYnopmiT+3Jvyw8K2hbdTS2/Cm4hqIppBn2u76Xk2XjdW0LlBYQ==", "license": "MIT", "dependencies": { "array-flat-polyfill": "^1.0.1", @@ -1119,9 +1119,9 @@ } }, "node_modules/@eslint/plugin-kit": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/@eslint/plugin-kit/-/plugin-kit-0.2.1.tgz", - "integrity": "sha512-HFZ4Mp26nbWk9d/BpvP0YNL6W4UoZF0VFcTw/aPPA8RpOxeFQgK+ClABGgAUXs9Y/RGX/l1vOmrqz1MQt9MNuw==", + "version": "0.2.2", + "resolved": "https://registry.npmjs.org/@eslint/plugin-kit/-/plugin-kit-0.2.2.tgz", + "integrity": "sha512-CXtq5nR4Su+2I47WPOlWud98Y5Lv8Kyxp2ukhgFx/eW6Blm18VXJO5WuQylPugRo8nbluoi6GvvxBLqHcvqUUw==", "dev": true, "license": "Apache-2.0", "dependencies": { @@ -1187,9 +1187,9 @@ } }, "node_modules/@humanfs/core": { - "version": "0.19.0", - "resolved": "https://registry.npmjs.org/@humanfs/core/-/core-0.19.0.tgz", - "integrity": "sha512-2cbWIHbZVEweE853g8jymffCA+NCMiuqeECeBBLm8dg2oFdjuGJhgN4UAbI+6v0CKbbhvtXA4qV8YR5Ji86nmw==", + "version": "0.19.1", + "resolved": "https://registry.npmjs.org/@humanfs/core/-/core-0.19.1.tgz", + "integrity": "sha512-5DyQ4+1JEUzejeK1JGICcideyfUbGixgS9jNgex5nqkW+cY7WZhxBigmieN5Qnw9ZosSNVC9KQKyb+GUaGyKUA==", "dev": true, "license": "Apache-2.0", "engines": { @@ -1197,13 +1197,13 @@ } }, "node_modules/@humanfs/node": { - "version": "0.16.5", - "resolved": "https://registry.npmjs.org/@humanfs/node/-/node-0.16.5.tgz", - "integrity": "sha512-KSPA4umqSG4LHYRodq31VDwKAvaTF4xmVlzM8Aeh4PlU1JQ3IG0wiA8C25d3RQ9nJyM3mBHyI53K06VVL/oFFg==", + "version": "0.16.6", + "resolved": "https://registry.npmjs.org/@humanfs/node/-/node-0.16.6.tgz", + "integrity": "sha512-YuI2ZHQL78Q5HbhDiBA1X4LmYdXCKCMQIfw0pw7piHJwyREFebJUvrQN4cMssyES6x+vfUbx1CIpaQUKYdQZOw==", "dev": true, "license": "Apache-2.0", "dependencies": { - "@humanfs/core": "^0.19.0", + "@humanfs/core": "^0.19.1", "@humanwhocodes/retry": "^0.3.0" }, "engines": { @@ -2523,9 +2523,9 @@ } }, "node_modules/@oclif/plugin-plugins/node_modules/@oclif/core": { - "version": "4.0.30", - "resolved": "https://registry.npmjs.org/@oclif/core/-/core-4.0.30.tgz", - "integrity": "sha512-Ak3OUdOcoovIRWZOT6oC5JhZgyJD90uWX/7HjSofn+C4LEmHxxfiyu04a73dwnezfzqDu9jEXfd2mQOOC54KZw==", + "version": "4.0.31", + "resolved": "https://registry.npmjs.org/@oclif/core/-/core-4.0.31.tgz", + "integrity": "sha512-7oyIZv/C1TP+fPc2tSzVPYqG1zU+nel1QvJxjAWyVhud0J8B5SpKZnryedxs3nlSVPJ6K1MT31C9esupCBYgZw==", "license": "MIT", "dependencies": { "ansi-escapes": "^4.3.2", @@ -2537,7 +2537,7 @@ "get-package-type": "^0.1.0", "globby": "^11.1.0", "indent-string": "^4.0.0", - "is-wsl": "^3", + "is-wsl": "^2.2.0", "lilconfig": "^3.1.2", "minimatch": "^9.0.5", "semver": "^7.6.3", @@ -2571,21 +2571,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/@oclif/plugin-plugins/node_modules/is-wsl": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-3.1.0.tgz", - "integrity": "sha512-UcVfVfaK4Sc4m7X3dUSoHoozQGBEFeDC+zVo06t98xe8CzHSZZBekNXH+tu0NalHolcJ/QAGqS46Hef7QXBIMw==", - "license": "MIT", - "dependencies": { - "is-inside-container": "^1.0.0" - }, - "engines": { - "node": ">=16" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/@oclif/plugin-plugins/node_modules/object-treeify": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/object-treeify/-/object-treeify-4.0.1.tgz", @@ -3345,9 +3330,9 @@ } }, "node_modules/@types/adm-zip": { - "version": "0.5.5", - "resolved": "https://registry.npmjs.org/@types/adm-zip/-/adm-zip-0.5.5.tgz", - "integrity": "sha512-YCGstVMjc4LTY5uK9/obvxBya93axZOVOyf2GSUulADzmLhYE45u2nAssCs/fWBs1Ifq5Vat75JTPwd5XZoPJw==", + "version": "0.5.6", + "resolved": "https://registry.npmjs.org/@types/adm-zip/-/adm-zip-0.5.6.tgz", + "integrity": "sha512-lRlcSLg5Yoo7C2H2AUiAoYlvifWoCx/se7iUNiCBTfEVVYFVn+Tr9ZGed4K73tYgLe9O4PjdJvbxlkdAOx/qiw==", "dev": true, "license": "MIT", "dependencies": { @@ -3671,9 +3656,9 @@ "license": "MIT" }, "node_modules/@types/lodash": { - "version": "4.17.12", - "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.17.12.tgz", - "integrity": "sha512-sviUmCE8AYdaF/KIHLDJBQgeYzPBI0vf/17NaYehBJfYD1j6/L95Slh07NlyK2iNyBNaEkb3En2jRt+a8y3xZQ==", + "version": "4.17.13", + "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.17.13.tgz", + "integrity": "sha512-lfx+dftrEZcdBPczf9d0Qv0x+j/rfNCMuC6OcfXmO8gkfeNAY88PgKUbvG56whcN23gc27yenwF6oJZXGFpYxg==", "license": "MIT" }, "node_modules/@types/markdown-it": { @@ -5568,9 +5553,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001673", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001673.tgz", - "integrity": "sha512-WTrjUCSMp3LYX0nE12ECkV0a+e6LC85E0Auz75555/qr78Oc8YWhEPNfDd6SHdtlCMSzqtuXY0uyEMNRcsKpKw==", + "version": "1.0.30001675", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001675.tgz", + "integrity": "sha512-/wV1bQwPrkLiQMjaJF5yUMVM/VdRPOCU8QZ+PmG6uW6DvYSrNY1bpwHI/3mOcUosLaJCzYDi5o91IQB51ft6cg==", "dev": true, "funding": [ { @@ -7312,9 +7297,9 @@ } }, "node_modules/electron-to-chromium": { - "version": "1.5.47", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.47.tgz", - "integrity": "sha512-zS5Yer0MOYw4rtK2iq43cJagHZ8sXN0jDHDKzB+86gSBSAI4v07S97mcq+Gs2vclAxSh1j7vOAHxSVgduiiuVQ==", + "version": "1.5.49", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.49.tgz", + "integrity": "sha512-ZXfs1Of8fDb6z7WEYZjXpgIRF6MEu8JdeGA0A40aZq6OQbS+eJpnnV49epZRna2DU/YsEjSQuGtQPPtvt6J65A==", "dev": true, "license": "ISC" }, @@ -11721,39 +11706,6 @@ "node": ">=0.10.0" } }, - "node_modules/is-inside-container": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-inside-container/-/is-inside-container-1.0.0.tgz", - "integrity": "sha512-KIYLCCJghfHZxqjYBE7rEy0OBuTd5xCHS7tHVgvCLkx7StIoaxwNW3hCALgEUjFfeRk+MG/Qxmp/vtETEF3tRA==", - "license": "MIT", - "dependencies": { - "is-docker": "^3.0.0" - }, - "bin": { - "is-inside-container": "cli.js" - }, - "engines": { - "node": ">=14.16" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/is-inside-container/node_modules/is-docker": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/is-docker/-/is-docker-3.0.0.tgz", - "integrity": "sha512-eljcgEDlEns/7AXFosB5K/2nCM4P7FQPkGc/DWLy5rmFEWvZayGrik1d9/QIY5nJ4f9YsVvBkA6kJpHn9rISdQ==", - "license": "MIT", - "bin": { - "is-docker": "cli.js" - }, - "engines": { - "node": "^12.20.0 || ^14.13.1 || >=16.0.0" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/is-interactive": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-interactive/-/is-interactive-1.0.0.tgz", @@ -15533,9 +15485,9 @@ } }, "node_modules/nise/node_modules/@sinonjs/fake-timers": { - "version": "13.0.4", - "resolved": "https://registry.npmjs.org/@sinonjs/fake-timers/-/fake-timers-13.0.4.tgz", - "integrity": "sha512-wpUq+QiKxrWk7U2pdvNSY9fNX62/k+7eEdlQMO0A3rU8tQ+vvzY/WzBhMz+GbQlATXZlXWYQqFWNFcn1SVvThA==", + "version": "13.0.5", + "resolved": "https://registry.npmjs.org/@sinonjs/fake-timers/-/fake-timers-13.0.5.tgz", + "integrity": "sha512-36/hTbH2uaWuGVERyC6da9YwGWnzUZXuPro/F2LfsdOsLnCojz/iSH8MxUt/FD2S5XBSVPhmArFUXcpCQ2Hkiw==", "license": "BSD-3-Clause", "dependencies": { "@sinonjs/commons": "^3.0.1" @@ -22870,9 +22822,9 @@ } }, "node_modules/sinon/node_modules/@sinonjs/fake-timers": { - "version": "13.0.4", - "resolved": "https://registry.npmjs.org/@sinonjs/fake-timers/-/fake-timers-13.0.4.tgz", - "integrity": "sha512-wpUq+QiKxrWk7U2pdvNSY9fNX62/k+7eEdlQMO0A3rU8tQ+vvzY/WzBhMz+GbQlATXZlXWYQqFWNFcn1SVvThA==", + "version": "13.0.5", + "resolved": "https://registry.npmjs.org/@sinonjs/fake-timers/-/fake-timers-13.0.5.tgz", + "integrity": "sha512-36/hTbH2uaWuGVERyC6da9YwGWnzUZXuPro/F2LfsdOsLnCojz/iSH8MxUt/FD2S5XBSVPhmArFUXcpCQ2Hkiw==", "license": "BSD-3-Clause", "dependencies": { "@sinonjs/commons": "^3.0.1" @@ -26868,9 +26820,9 @@ "license": "MIT" }, "packages/contentstack-audit/node_modules/@types/node": { - "version": "20.17.1", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.17.1.tgz", - "integrity": "sha512-j2VlPv1NnwPJbaCNv69FO/1z4lId0QmGvpT41YxitRtWlg96g/j8qcv2RKsLKe2F6OJgyXhupN1Xo17b2m139Q==", + "version": "20.17.3", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.17.3.tgz", + "integrity": "sha512-tSQrmKKatLDGnG92h40GD7FzUt0MjahaHwOME4VAFeeA/Xopayq5qLyQRy7Jg/pjgKIFBXuKcGhJo+UdYG55jQ==", "dev": true, "license": "MIT", "dependencies": { @@ -28523,9 +28475,9 @@ } }, "packages/contentstack-launch/node_modules/@types/node": { - "version": "16.18.115", - "resolved": "https://registry.npmjs.org/@types/node/-/node-16.18.115.tgz", - "integrity": "sha512-NF5ajYn+dq0tRfswdyp8Df75h7D9z+L8TCIwrXoh46ZLK6KZVXkRhf/luXaZytvm/keUo9vU4m1Bg39St91a5w==", + "version": "16.18.116", + "resolved": "https://registry.npmjs.org/@types/node/-/node-16.18.116.tgz", + "integrity": "sha512-mLigUvhoaADRewggiby+XfAAFOUOMCm/SwL5DAJ+CMUGjSLIGMsJVN7BOKftuQSHGjUmS/W7hVht8fcNbi/MRA==", "dev": true, "license": "MIT" }, @@ -28626,9 +28578,9 @@ } }, "packages/contentstack-launch/node_modules/eslint-scope": { - "version": "8.1.0", - "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-8.1.0.tgz", - "integrity": "sha512-14dSvlhaVhKKsa9Fx1l8A17s7ah7Ef7wCakJ10LYk6+GYmP9yDti2oq2SEwcyndt6knfcZyhyxwY3i9yL78EQw==", + "version": "8.2.0", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-8.2.0.tgz", + "integrity": "sha512-PHlWUfG6lvPc3yvP5A4PNyBL1W8fkDUccmI21JUu/+GKZBoH/W5u6usENXUrWFRsyoW5ACUjFGgAFQp5gUlb/A==", "dev": true, "license": "BSD-2-Clause", "dependencies": { @@ -28643,9 +28595,9 @@ } }, "packages/contentstack-launch/node_modules/eslint-visitor-keys": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-4.1.0.tgz", - "integrity": "sha512-Q7lok0mqMUSf5a/AdAZkA5a/gHcO6snwQClVNNvFKCAVlxXucdU8pKydU5ZVZjBx5xr37vGbFFWtLQYreLzrZg==", + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-4.2.0.tgz", + "integrity": "sha512-UyLnSehNt62FFhSwjZlHmeokpRK59rcz29j+F1/aDgbkbRTk7wIc9XzdoasMUbRNKDM0qQt/+BJ4BrpFeABemw==", "dev": true, "license": "Apache-2.0", "engines": { @@ -28656,15 +28608,15 @@ } }, "packages/contentstack-launch/node_modules/espree": { - "version": "10.2.0", - "resolved": "https://registry.npmjs.org/espree/-/espree-10.2.0.tgz", - "integrity": "sha512-upbkBJbckcCNBDBDXEbuhjbP68n+scUd3k/U2EkyM9nw+I/jPiL4cLF/Al06CF96wRltFda16sxDFrxsI1v0/g==", + "version": "10.3.0", + "resolved": "https://registry.npmjs.org/espree/-/espree-10.3.0.tgz", + "integrity": "sha512-0QYC8b24HWY8zjRnDTL6RiHfDbAWn63qb4LMj1Z4b076A4une81+z03Kg7l7mn/48PUTqoLptSXez8oknU8Clg==", "dev": true, "license": "BSD-2-Clause", "dependencies": { - "acorn": "^8.12.0", + "acorn": "^8.14.0", "acorn-jsx": "^5.3.2", - "eslint-visitor-keys": "^4.1.0" + "eslint-visitor-keys": "^4.2.0" }, "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" @@ -28763,7 +28715,7 @@ "dependencies": { "@contentstack/cli-command": "~1.3.2", "@contentstack/cli-utilities": "~1.8.0", - "@contentstack/json-rte-serializer": "~2.0.10", + "@contentstack/json-rte-serializer": "~2.0.11", "chalk": "^4.1.2", "collapse-whitespace": "^1.1.7", "jsdom": "^20.0.3", @@ -28775,12 +28727,12 @@ "uuid": "^9.0.1" }, "devDependencies": { - "@oclif/test": "^4.0.9", + "@oclif/test": "^4.1.0", "chai": "^4.5.0", "eslint": "^8.57.1", "eslint-config-oclif": "^4.0.0", "globby": "^10.0.2", - "mocha": "^10.7.3", + "mocha": "^10.8.1", "nyc": "^15.1.0", "oclif": "^3.17.2", "tslib": "^1.14.1" @@ -28789,6 +28741,125 @@ "node": ">=14.0.0" } }, + "packages/contentstack-migrate-rte/node_modules/argparse": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", + "dev": true, + "license": "Python-2.0" + }, + "packages/contentstack-migrate-rte/node_modules/cliui": { + "version": "7.0.4", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-7.0.4.tgz", + "integrity": "sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ==", + "dev": true, + "license": "ISC", + "dependencies": { + "string-width": "^4.2.0", + "strip-ansi": "^6.0.0", + "wrap-ansi": "^7.0.0" + } + }, + "packages/contentstack-migrate-rte/node_modules/glob": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/glob/-/glob-8.1.0.tgz", + "integrity": "sha512-r8hpEjiQEYlF2QU0df3dS+nxxSIreXQS1qRhMJM0Q5NDdR386C7jb7Hwwod8Fgiuex+k0GFjgft18yvxm5XoCQ==", + "deprecated": "Glob versions prior to v9 are no longer supported", + "dev": true, + "license": "ISC", + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^5.0.1", + "once": "^1.3.0" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "packages/contentstack-migrate-rte/node_modules/js-yaml": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", + "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", + "dev": true, + "license": "MIT", + "dependencies": { + "argparse": "^2.0.1" + }, + "bin": { + "js-yaml": "bin/js-yaml.js" + } + }, + "packages/contentstack-migrate-rte/node_modules/log-symbols": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-4.1.0.tgz", + "integrity": "sha512-8XPvpAA8uyhfteu8pIvQxpJZ7SYYdpUivZpGy6sFsBuKRY/7rQGavedeB8aK+Zkyq6upMFVL/9AW6vOYzfRyLg==", + "dev": true, + "license": "MIT", + "dependencies": { + "chalk": "^4.1.0", + "is-unicode-supported": "^0.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "packages/contentstack-migrate-rte/node_modules/minimatch": { + "version": "5.1.6", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.6.tgz", + "integrity": "sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g==", + "dev": true, + "license": "ISC", + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=10" + } + }, + "packages/contentstack-migrate-rte/node_modules/mocha": { + "version": "10.8.1", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-10.8.1.tgz", + "integrity": "sha512-WxSpEWgF03HfgNKBuysfK40DUaOSVX5zxgLDoieMGO+zyE69iq2eQ1vBypvIJ5mOPKpuVAqWiTbt4Orj7L6wVw==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-colors": "^4.1.3", + "browser-stdout": "^1.3.1", + "chokidar": "^3.5.3", + "debug": "^4.3.5", + "diff": "^5.2.0", + "escape-string-regexp": "^4.0.0", + "find-up": "^5.0.0", + "glob": "^8.1.0", + "he": "^1.2.0", + "js-yaml": "^4.1.0", + "log-symbols": "^4.1.0", + "minimatch": "^5.1.6", + "ms": "^2.1.3", + "serialize-javascript": "^6.0.2", + "strip-json-comments": "^3.1.1", + "supports-color": "^8.1.1", + "workerpool": "^6.5.1", + "yargs": "^16.2.0", + "yargs-parser": "^20.2.9", + "yargs-unparser": "^2.0.0" + }, + "bin": { + "_mocha": "bin/_mocha", + "mocha": "bin/mocha.js" + }, + "engines": { + "node": ">= 14.0.0" + } + }, "packages/contentstack-migrate-rte/node_modules/tslib": { "version": "1.14.1", "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", @@ -28796,6 +28867,25 @@ "dev": true, "license": "0BSD" }, + "packages/contentstack-migrate-rte/node_modules/yargs": { + "version": "16.2.0", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-16.2.0.tgz", + "integrity": "sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw==", + "dev": true, + "license": "MIT", + "dependencies": { + "cliui": "^7.0.2", + "escalade": "^3.1.1", + "get-caller-file": "^2.0.5", + "require-directory": "^2.1.1", + "string-width": "^4.2.0", + "y18n": "^5.0.5", + "yargs-parser": "^20.2.2" + }, + "engines": { + "node": ">=10" + } + }, "packages/contentstack-migration": { "name": "@contentstack/cli-migration", "version": "1.6.3", @@ -29061,9 +29151,9 @@ } }, "packages/contentstack-variants/node_modules/@types/node": { - "version": "20.17.1", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.17.1.tgz", - "integrity": "sha512-j2VlPv1NnwPJbaCNv69FO/1z4lId0QmGvpT41YxitRtWlg96g/j8qcv2RKsLKe2F6OJgyXhupN1Xo17b2m139Q==", + "version": "20.17.3", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.17.3.tgz", + "integrity": "sha512-tSQrmKKatLDGnG92h40GD7FzUt0MjahaHwOME4VAFeeA/Xopayq5qLyQRy7Jg/pjgKIFBXuKcGhJo+UdYG55jQ==", "dev": true, "license": "MIT", "dependencies": { diff --git a/packages/contentstack-migrate-rte/package.json b/packages/contentstack-migrate-rte/package.json index 2801aba886..8c4e545448 100644 --- a/packages/contentstack-migrate-rte/package.json +++ b/packages/contentstack-migrate-rte/package.json @@ -7,7 +7,7 @@ "dependencies": { "@contentstack/cli-command": "~1.3.2", "@contentstack/cli-utilities": "~1.8.0", - "@contentstack/json-rte-serializer": "~2.0.10", + "@contentstack/json-rte-serializer": "~2.0.11", "collapse-whitespace": "^1.1.7", "chalk": "^4.1.2", "jsdom": "^20.0.3", @@ -19,12 +19,12 @@ "uuid": "^9.0.1" }, "devDependencies": { - "@oclif/test": "^4.0.9", + "@oclif/test": "^4.1.0", "chai": "^4.5.0", "eslint": "^8.57.1", "eslint-config-oclif": "^4.0.0", "globby": "^10.0.2", - "mocha": "^10.7.3", + "mocha": "^10.8.1", "nyc": "^15.1.0", "oclif": "^3.17.2", "tslib": "^1.14.1" diff --git a/packages/contentstack-migrate-rte/test/commands/json-migration.test.js b/packages/contentstack-migrate-rte/test/commands/json-migration.test.js index 49c372ba7a..0aa776a35b 100644 --- a/packages/contentstack-migrate-rte/test/commands/json-migration.test.js +++ b/packages/contentstack-migrate-rte/test/commands/json-migration.test.js @@ -1,8 +1,10 @@ -const { expect, test } = require('@oclif/test'); +const { runCommand } = require('@oclif/test'); const sinon = require('sinon'); const qs = require('querystring'); const nock = require('nock'); const { cliux } = require('@contentstack/cli-utilities'); +const { expect } = require('chai'); +const { fancy } = require('fancy-test'); const { getToken, getContentType, @@ -28,108 +30,107 @@ describe('Migration Config validation', () => { .withArgs('invalidAlias') .throws("Token with alias 'invalidAlias' was not found"); - test - .loadConfig({ root: process.cwd() }) + fancy .stub(cliux, 'confirm', () => false) - .stdout() - .command([ - 'cm:entries:migrate-html-rte', - '--alias', - 'test1', - '--content-type', - 'contenttypewithsinglerte', - '--html-path', - 'rich_text_editor', - '--json-path', - 'supercharged_rte', - '--delay', - '50', - ]) .catch((error) => { - expect(error.message).to.contain('User aborted the command.'); + expect(error.message).to.contain(); }) - .it('deny config confirmation'); + .it('deny config confirmation', async () => { + const { stderr } = await runCommand( + [ + 'cm:entries:migrate-html-rte', + '--alias', + 'test1', + '--content-type', + 'contenttypewithsinglerte', + '--html-path', + 'rich_text_editor', + '--json-path', + 'supercharged_rte', + '--delay', + '50', + ], + { root: process.cwd() }, + ); + + expect(stderr.message).to.contain('User aborted the command.'); + }); - test - .loadConfig({ root: process.cwd() }) + fancy .stub(cliux, 'confirm', () => true) .stub(command, 'getToken', getTokenCallback) - .stdout() - .command(['cm:entries:migrate-html-rte', '--config-path', './test/dummy/config/configWithEmptyPath.json', '--yes']) - .catch((error) => { - expect(error.message).to.contain('No value provided for the "paths" property in config.'); - }) - .it('throw error on Empty paths'); + .it('throw error on Empty paths', async () => { + const {stderr} = await runCommand( + ['cm:entries:migrate-html-rte', '--config-path', './test/dummy/config/configWithEmptyPath.json', '--yes'], + { root: process.cwd() }, + ); + expect(stderr.message).to.contain('No value provided for the "paths" property in config.'); + }); - test - .loadConfig({ root: process.cwd() }) + fancy .stub(cliux, 'confirm', () => true) .stub(command, 'getToken', getTokenCallback) - .stdout() - .command(['cm:entries:migrate-html-rte', '--config-path', './test/dummy/config/invalidConfig.json', '--yes']) - .catch((error) => { - expect(error.message).to.contain('Invalid key type. alias must be of string type(s).'); - }) - .it('throw error on invalid config type'); + .it('throw error on invalid config type', async () => { + const {stderr} = await runCommand( + ['cm:entries:migrate-html-rte', '--config-path', '../test/dummy/config/invalidConfig.json', '--yes'], + { root: process.cwd() }, + ); + expect(stderr.message).to.contain('Invalid key type. alias must be of string type(s).'); + }); - test - .loadConfig({ root: process.cwd() }) + fancy .stub(cliux, 'confirm', () => true) - .stdout() - .command([ - 'cm:entries:migrate-html-rte', - '--content-type', - 'contenttypewithsinglerte', - '--html-path', - 'rich_text_editor', - '--json-path', - 'supercharged_rte', - '--delay', - '50', - ]) - .catch((error) => { - expect(error.message).to.contain('alias is mandatory while defining config.'); - }) - .it('throw error on config without alias property'); + .it('throw error on config without alias property', async () => { + const { stderr } = await runCommand( + [ + 'cm:entries:migrate-html-rte', + '--content-type', + 'contenttypewithsinglerte', + '--html-path', + 'rich_text_editor', + '--json-path', + 'supercharged_rte', + '--delay', + '50', + ], + { root: process.cwd() }, + ); + expect(stderr.message).to.contain('alias is mandatory while defining config.'); + }); - test - .loadConfig({ root: process.cwd() }) + fancy .stub(cliux, 'confirm', () => true) .stub(command, 'getToken', getTokenCallback) - .stdout() - .command([ - 'cm:entries:migrate-html-rte', - '--alias', - 'invalidAlias', - '--content-type', - 'contenttypewithsinglerte', - '--html-path', - 'rich_text_editor', - '--json-path', - 'supercharged_rte', - '--delay', - '50', - ]) - .catch((error) => { - expect(error.message).to.contain('Invalid alias provided for the management token.'); - }) - .it('throw error on invalidAlias'); + .it('throw error on invalidAlias', async () => { + const { stderr } = await runCommand( + [ + 'cm:entries:migrate-html-rte', + '--alias', + 'invalidAlias', + '--content-type', + 'contenttypewithsinglerte', + '--html-path', + 'rich_text_editor', + '--json-path', + 'supercharged_rte', + '--delay', + '50', + ], + { root: process.cwd() }, + ); + expect(stderr.message).to.contain('Invalid alias provided for the management token.'); + }); - test - .loadConfig({ root: process.cwd() }) + fancy .stub(cliux, 'confirm', () => true) .stub(command, 'getToken', getTokenCallback) - .stdout() - .command([ - 'cm:entries:migrate-html-rte', - '--config-path', - './test/dummy/config/configWithInvalidPath.json', - '--yes', - ]) - .catch((error) => { - expect(error.message).to.contain('The specified path to config file does not exist.'); - }) - .it('throw error on invalid config file'); + .it('throw error on invalid config file', async () => { + const { stderr } = await runCommand( + ['cm:entries:migrate-html-rte', '--config-path', './test/dummy/config/configWithInvalidPath.json', '--yes'], + { root: process.cwd() }, + ); + expect(stderr.message).to.contain('The specified path to config file does not exist.'); + }); }); describe('Content Type with Single RTE Field of Single Type', function () { this.timeout(1000000); @@ -274,302 +275,301 @@ describe('Content Type with Single RTE Field of Single Type', function () { type: 'management', }); - test - .loadConfig({ root: process.cwd() }) + fancy .stub(cliux, 'confirm', () => 'yes') .stub(command, 'getToken', getTokenCallback) - .stdout() - .command(['cm:entries:migrate-html-rte', '--config-path', './test/dummy/config/config.json', '--yes']) - .it('execute using config file w/o locale', (ctx) => { - expect(ctx.stdout).to.contain('Updated 1 Content Type(s) and 2 Entrie(s)'); + .it('execute using config file w/o locale', async () => { + const { stdout } = await runCommand( + ['cm:entries:migrate-html-rte', '--config-path', './test/dummy/config/config.json', '--yes'], + { root: process.cwd() }, + ); + expect(stdout).to.contain('Updated 1 Content Type(s) and 2 Entrie(s)'); }); - test - .loadConfig({ root: process.cwd() }) + fancy .stub(cliux, 'confirm', () => 'yes') .stub(command, 'getToken', getTokenCallback) - .stdout() - .command(['cm:entries:migrate-html-rte', '--config-path', './test/dummy/config/config_locale.json', '--yes']) - .it('execute using config file w/ locale', (ctx) => { - expect(ctx.stdout).to.contain('Updated 1 Content Type(s) and 1 Entrie(s)'); + .it('execute using config file w/ locale', async () => { + const { stdout } = await runCommand( + ['cm:entries:migrate-html-rte', '--config-path', './test/dummy/config/config_locale.json', '--yes'], + { root: process.cwd() }, + ); + expect(stdout).to.contain('Updated 1 Content Type(s) and 1 Entrie(s)'); }); - test - .loadConfig({ root: process.cwd() }) + fancy .stub(cliux, 'confirm', () => 'yes') .stub(command, 'getToken', getTokenCallback) - .stdout() - .command(['cm:entries:migrate-html-rte', '--config-path', './test/dummy/config/config-locale-2.json', '--yes']) - .it('execute using config file w/ multiple locale', (ctx) => { - expect(ctx.stdout).to.contain('Updated 1 Content Type(s) and 3 Entrie(s)'); + .it('execute using config file w/ multiple locale', async () => { + const { stdout } = await runCommand( + ['cm:entries:migrate-html-rte', '--config-path', './test/dummy/config/config-locale-2.json', '--yes'], + { root: process.cwd() }, + ); + expect(stdout).to.contain('Updated 1 Content Type(s) and 3 Entrie(s)'); }); - test - .loadConfig({ root: process.cwd() }) + fancy .stub(cliux, 'confirm', () => 'yes') .stub(command, 'getToken', getTokenCallback) - .stdout() - .command([ - 'cm:entries:migrate-html-rte', - '--alias', - 'test1', - '--content-type', - 'contenttypewithsinglerte', - '--html-path', - 'rich_text_editor', - '--json-path', - 'supercharged_rte', - '--delay', - '50', - ]) - .it('execute using flags (w/o locale)', (ctx) => { - expect(ctx.stdout).to.contain('Updated 1 Content Type(s) and 2 Entrie(s)'); - }); - - test - .loadConfig({ root: process.cwd() }) + .it('execute using flags (w/o locale)', async () => { + const { stdout } = await runCommand( + [ + 'cm:entries:migrate-html-rte', + '--alias', + 'test1', + '--content-type', + 'contenttypewithsinglerte', + '--html-path', + 'rich_text_editor', + '--json-path', + 'supercharged_rte', + '--delay', + '50', + ], + { root: process.cwd() }, + ); + expect(stdout).to.contain('Updated 1 Content Type(s) and 2 Entrie(s)'); + }); + + fancy .stub(cliux, 'confirm', () => 'yes') .stub(command, 'getToken', getTokenCallback) - .stdout() - .command([ - 'cm:entries:migrate-html-rte', - '--alias', - 'test1', - '--content-type', - 'contenttypewithsinglerte', - '--html-path', - 'rich_text_editor', - '--json-path', - 'supercharged_rte', - '--locale', - 'en-in', - '--delay', - '50', - ]) - .it('execute using flags w/ locale', (ctx) => { - expect(ctx.stdout).to.contain('Updated 1 Content Type(s) and 1 Entrie(s)'); - }); - test - .loadConfig({ root: process.cwd() }) + .it('execute using flags w/ locale', async () => { + const { stdout } = await runCommand( + [ + 'cm:entries:migrate-html-rte', + '--alias', + 'test1', + '--content-type', + 'contenttypewithsinglerte', + '--html-path', + 'rich_text_editor', + '--json-path', + 'supercharged_rte', + '--locale', + 'en-in', + '--delay', + '50', + ], + { root: process.cwd() }, + ); + expect(stdout).to.contain('Updated 1 Content Type(s) and 1 Entrie(s)'); + }); + fancy .stub(cliux, 'confirm', () => 'yes') .stub(command, 'getToken', getTokenCallback) - .stdout() - .command([ - 'cm:entries:migrate-html-rte', - '--alias', - 'test1', - '--content-type', - 'contenttypewithsinglerte', - '--html-path', - 'rich_text_editor.invalidPath', - '--json-path', - 'supercharged_rte', - '--yes', - '--delay', - '50', - ]) - .catch((error) => { - expect(error.message).to.contain('The specified path to invalidPath HTML RTE does not exist.'); - }) - .it('throw error on invalid html rte path'); + .it('throw error on invalid html rte path', async () => { + const { stderr } = await runCommand([ + 'cm:entries:migrate-html-rte', + '--alias', + 'test1', + '--content-type', + 'contenttypewithsinglerte', + '--html-path', + 'rich_text_editor.invalidPath', + '--json-path', + 'supercharged_rte', + '--yes', + '--delay', + '50', + ],{ root: process.cwd() }); + expect(stderr.message).to.contain('The specified path to invalidPath HTML RTE does not exist.'); + }); - test - .loadConfig({ root: process.cwd() }) + fancy .stub(cliux, 'confirm', () => 'yes') .stub(command, 'getToken', getTokenCallback) - .stdout() - .command([ - 'cm:entries:migrate-html-rte', - '--alias', - 'test1', - '--content-type', - 'contenttypewithinvalidhtmlrteschema', - '--html-path', - 'rich_text_editor', - '--json-path', - 'supercharged_rte', - '--yes', - '--delay', - '50', - ]) - .catch((error) => { - expect(error.message).to.contain('The specified path to rich_text_editor HTML RTE does not exist.'); - }) - .it('throw error on invalid html rte field schema'); + .it('throw error on invalid html rte field schema', async () => { + const { stderr } = await runCommand( + [ + 'cm:entries:migrate-html-rte', + '--alias', + 'test1', + '--content-type', + 'contenttypewithinvalidhtmlrteschema', + '--html-path', + 'rich_text_editor', + '--json-path', + 'supercharged_rte', + '--yes', + '--delay', + '50', + ], + { root: process.cwd() }, + ); + expect(stderr.message).to.contain('The specified path to rich_text_editor HTML RTE does not exist.'); + }); - test - .loadConfig({ root: process.cwd() }) + fancy .stub(cliux, 'confirm', () => 'yes') .stub(command, 'getToken', getTokenCallback) - .stdout() - .command([ - 'cm:entries:migrate-html-rte', - '--alias', - 'test1', - '--content-type', - 'contenttypewithinvalidjsonrteschema', - '--html-path', - 'rich_text_editor', - '--json-path', - 'supercharged_rte', - '--yes', - '--delay', - '50', - ]) - .catch((error) => { - expect(error.message).to.contain('The specified path to supercharged_rte JSON RTE does not exist.'); - }) - .it('throw error on invalid json rte field schema'); - test - .loadConfig({ root: process.cwd() }) + .it('throw error on invalid json rte field schema', async () => { + const { stderr } = await runCommand( + [ + 'cm:entries:migrate-html-rte', + '--alias', + 'test1', + '--content-type', + 'contenttypewithinvalidjsonrteschema', + '--html-path', + 'rich_text_editor', + '--json-path', + 'supercharged_rte', + '--yes', + '--delay', + '50', + ], + { root: process.cwd() }, + ); + expect(stderr.message).to.contain('The specified path to supercharged_rte JSON RTE does not exist.'); + }); + fancy .stub(cliux, 'confirm', () => 'yes') .stub(command, 'getToken', getTokenCallback) - .stdout() - .command([ - 'cm:entries:migrate-html-rte', - '--alias', - 'test1', - '--content-type', - 'contenttypewithsinglerte', - '--html-path', - 'rich_text_editor', - '--json-path', - 'supercharged_rte.invalidPath', - '--yes', - '--delay', - '50', - ]) - .catch((error) => { - expect(error.message).to.contain('The specified path to invalidPath JSON RTE does not exist.'); - }) - .it('throw error on invalid json rte path'); + .it('throw error on invalid json rte path', async () => { + const { stderr } = await runCommand( + [ + 'cm:entries:migrate-html-rte', + '--alias', + 'test1', + '--content-type', + 'contenttypewithsinglerte', + '--html-path', + 'rich_text_editor', + '--json-path', + 'supercharged_rte.invalidPath', + '--yes', + '--delay', + '50', + ], + { root: process.cwd() }, + ); + expect(stderr.message).to.contain('The specified path to invalidPath JSON RTE does not exist.'); + }); - test - .loadConfig({ root: process.cwd() }) + fancy .stub(cliux, 'confirm', () => 'yes') .stub(command, 'getToken', getTokenCallback) - .stdout() - .command([ - 'cm:entries:migrate-html-rte', - '--config-path', - './test/dummy/config/configForInvalidContentType.json', - '--yes', - ]) - .catch((error) => { - expect(error.message).to.contain('Cannot convert "Multiple" type HTML RTE to "Single" type JSON RTE.'); - }) - .it('throw error on migration of Mutiple Html rte with single Json rte'); + .it('throw error on migration of Mutiple Html rte with single Json rte', async () => { + const { stderr } = await runCommand( + [ + 'cm:entries:migrate-html-rte', + '--config-path', + './test/dummy/config/configForInvalidContentType.json', + '--yes', + ], + { root: process.cwd() }, + ); + expect(stderr.message).to.contain('Cannot convert "Multiple" type HTML RTE to "Single" type JSON RTE.'); + }); - test - .loadConfig({ root: process.cwd() }) + fancy .stub(cliux, 'confirm', () => 'yes') .stub(command, 'getToken', getTokenCallback) - .stdout() - .command([ - 'cm:entries:migrate-html-rte', - '--alias', - 'test1', - '--content-type', - 'contenttypewithemptyschema', - '--html-path', - 'rich_text_editor', - '--json-path', - 'supercharged_rte', - '--yes', - '--delay', - '50', - ]) - .catch((error) => { - expect(error.message).to.contain('The contenttypewithemptyschema content type contains an empty schema.'); - }) - .it('throw error on content type with empty schema'); + .it('throw error on content type with empty schema', async () => { + const { stderr } = await runCommand( + [ + 'cm:entries:migrate-html-rte', + '--alias', + 'test1', + '--content-type', + 'contenttypewithemptyschema', + '--html-path', + 'rich_text_editor', + '--json-path', + 'supercharged_rte', + '--yes', + '--delay', + '50', + ], + { root: process.cwd() }, + ); + expect(stderr.message).to.contain('The contenttypewithemptyschema content type contains an empty schema.'); + }); - test - .loadConfig({ root: process.cwd() }) + fancy .stub(cliux, 'confirm', () => 'yes') .stub(command, 'getToken', getTokenCallback) - .stdout() - .command([ - 'cm:entries:migrate-html-rte', - '--alias', - 'test1', - '--content-type', - 'contenttypedifferentlevelrte', - '--html-path', - 'group.rich_text_editor', - '--json-path', - 'supercharged_rte', - '--yes', - '--delay', - '50', - ]) - .catch((error) => { - expect(error.message).to.contain( + .it('throw error on different level rte migration', async () => { + const { stderr } = await runCommand( + [ + 'cm:entries:migrate-html-rte', + '--alias', + 'test1', + '--content-type', + 'contenttypedifferentlevelrte', + '--html-path', + 'group.rich_text_editor', + '--json-path', + 'supercharged_rte', + '--yes', + '--delay', + '50', + ], + { root: process.cwd() }, + ); + expect(stderr.message).to.contain( 'To complete migration, HTML RTE and JSON RTE should be present at the same field depth level.', ); - }) - .it('throw error on different level rte migration'); + }); - test - .loadConfig({ root: process.cwd() }) + fancy .stub(cliux, 'confirm', () => true) .stub(command, 'getToken', getTokenCallback) - .stdout() - .command([ - 'cm:entries:migrate-html-rte', - '--alias', - 'test1', - '--content-type', - 'invalidContentType', - '--html-path', - 'rich_text_editor', - '--json-path', - 'supercharged_rte', - '--delay', - '50', - ]) - .catch((error) => { - expect(error.message).to.contain("The Content Type 'invalidContentType' was not found. Please try again."); - }) - .it('throw error on invalid contenttype'); + .it('throw error on invalid contenttype', async () => { + const { stderr } = await runCommand( + [ + 'cm:entries:migrate-html-rte', + '--alias', + 'test1', + '--content-type', + 'invalidContentType', + '--html-path', + 'rich_text_editor', + '--json-path', + 'supercharged_rte', + '--delay', + '50', + ], + { root: process.cwd() }, + ); + expect(stderr.message).to.contain("The Content Type 'invalidContentType' was not found. Please try again."); + }); - test - .loadConfig({ root: process.cwd() }) + fancy .stub(cliux, 'confirm', () => true) .stub(command, 'getToken', getTokenCallback) - .stdout() - .command([ - 'cm:entries:migrate-html-rte', - '--alias', - 'test1', - '--content-type', - 'contenttypewithentryupdateerror', - '--html-path', - 'rich_text_editor', - '--json-path', - 'supercharged_rte', - '--yes', - '--delay', - '50', - ]) - .it('notify user on entry update failed', (ctx) => { - expect(ctx.stdout).to.contain( + .it('notify user on entry update failed', async () => { + const { stdout } = await runCommand( + [ + 'cm:entries:migrate-html-rte', + '--alias', + 'test1', + '--content-type', + 'contenttypewithentryupdateerror', + '--html-path', + 'rich_text_editor', + '--json-path', + 'supercharged_rte', + '--yes', + '--delay', + '50', + ], + { root: process.cwd() }, + ); + expect(stdout).to.contain( `Faced issue while migrating some entrie(s) for "contenttypewithentryupdateerror" Content-type in "en-us" locale,"blta9b16ac2827c54ed, blta9b16ac2827c54e1"`, ); }); - test - .loadConfig({ root: process.cwd() }) + fancy .stub(cliux, 'confirm', () => 'yes') .stub(command, 'getToken', getTokenCallback) - .stdout() - .command([ - 'cm:entries:migrate-html-rte', - '--config-path', - './test/dummy/config/config-for-images-in-rte.json', - '--yes', - ]) - .it('should have proper json structure for images migrated from HTML RTE', (ctx) => { - expect(ctx.stdout).to.contain('Updated 1 Content Type(s) and 1 Entrie(s)'); + .it('should have proper json structure for images migrated from HTML RTE', async () => { + const { stdout } = await runCommand( + ['cm:entries:migrate-html-rte', '--config-path', './test/dummy/config/config-for-images-in-rte.json', '--yes'], + { root: process.cwd() }, + ); + expect(stdout).to.contain('Updated 1 Content Type(s) and 1 Entrie(s)'); }); }); describe('Global Field Migration', () => { @@ -598,144 +598,145 @@ describe('Global Field Migration', () => { apiKey: 'testApiKey', type: 'management', }); - test - .loadConfig({ root: process.cwd() }) + fancy .stub(cliux, 'confirm', () => 'yes') .stub(command, 'getToken', getTokenCallback) - .stdout() - .command(['cm:entries:migrate-html-rte', '--config-path', './test/dummy/config/configForGlobalField.json', '--yes']) - .it('execute using config file', (ctx) => { - expect(ctx.stdout).to.contain('Updated 2 Content Type(s) and 2 Entrie(s)'); + .it('execute using config file', async () => { + const { stdout } = await runCommand( + ['cm:entries:migrate-html-rte', '--config-path', './test/dummy/config/configForGlobalField.json', '--yes'], + { root: process.cwd() }, + ); + expect(stdout).to.contain('Updated 2 Content Type(s) and 2 Entrie(s)'); }); - test - .loadConfig({ root: process.cwd() }) + fancy .stub(cliux, 'confirm', () => 'yes') .stub(command, 'getToken', getTokenCallback) - .stdout() - .command([ - 'cm:entries:migrate-html-rte', - '--alias', - 'test1', - '--content-type', - 'globalfieldwithemptycontenttype', - '--global-field', - '--html-path', - 'rich_text_editor', - '--json-path', - 'supercharged_rte', - '--yes', - '--delay', - '50', - ]) - .catch((error) => { - expect(error.message).to.contain('globalfieldformigration Global field is not referred in any content type.'); - }) - .it('throw error on global field with empty referred content_types'); + .it('throw error on global field with empty referred content_types', async () => { + const { stderr } = await runCommand( + [ + 'cm:entries:migrate-html-rte', + '--alias', + 'test1', + '--content-type', + 'globalfieldwithemptycontenttype', + '--global-field', + '--html-path', + 'rich_text_editor', + '--json-path', + 'supercharged_rte', + '--yes', + '--delay', + '50', + ], + { root: process.cwd() }, + ); + expect(stderr.message).to.contain('globalfieldformigration Global field is not referred in any content type.'); + }); - test - .loadConfig({ root: process.cwd() }) + fancy .stub(cliux, 'confirm', () => 'yes') .stub(command, 'getToken', getTokenCallback) - .stdout() - .command([ - 'cm:entries:migrate-html-rte', - '--alias', - 'test1', - '--content-type', - 'globalfieldwithinvalidcontenttype', - '--global-field', - '--html-path', - 'rich_text_editor', - '--json-path', - 'supercharged_rte', - '--yes', - '--delay', - '50', - ]) - .catch((error) => { - expect(error.message).to.contain( + .it('throw error on global field with invalid content_type', async () => { + const { stderr } = await runCommand( + [ + 'cm:entries:migrate-html-rte', + '--alias', + 'test1', + '--content-type', + 'globalfieldwithinvalidcontenttype', + '--global-field', + '--html-path', + 'rich_text_editor', + '--json-path', + 'supercharged_rte', + '--yes', + '--delay', + '50', + ], + { root: process.cwd() }, + ); + expect(stderr.message).to.contain( 'The contenttypewithemptyschema content type referred in globalfieldformigration contains an empty schema.', ); - }) - .it('throw error on global field with invalid content_type'); + }); - test - .loadConfig({ root: process.cwd() }) + fancy .stub(cliux, 'confirm', () => 'yes') .stub(command, 'getToken', getTokenCallback) - .stdout() - .command([ - 'cm:entries:migrate-html-rte', - '--alias', - 'test1', - '--content-type', - 'globalfieldwithemptyschema', - '--global-field', - '--html-path', - 'rich_text_editor', - '--json-path', - 'supercharged_rte', - '--yes', - '--delay', - '50', - ]) - .catch((error) => { - expect(error.message).to.contain('The globalfieldwithemptyschema Global field contains an empty schema.'); - }) - .it('throw error on global field with empty schema'); + .it('throw error on global field with empty schema', async () => { + const { stderr } = await runCommand( + [ + 'cm:entries:migrate-html-rte', + '--alias', + 'test1', + '--content-type', + 'globalfieldwithemptyschema', + '--global-field', + '--html-path', + 'rich_text_editor', + '--json-path', + 'supercharged_rte', + '--yes', + '--delay', + '50', + ], + { root: process.cwd() }, + ); + expect(stderr.message).to.contain('The globalfieldwithemptyschema Global field contains an empty schema.'); + }); - test - .loadConfig({ root: process.cwd() }) + fancy .stub(cliux, 'confirm', () => 'yes') .stub(command, 'getToken', getTokenCallback) - .stdout() - .command([ - 'cm:entries:migrate-html-rte', - '--alias', - 'test1', - '--content-type', - 'globalfieldwithemptyschemacontenttype', - '--global-field', - '--html-path', - 'rich_text_editor', - '--json-path', - 'supercharged_rte', - '--yes', - '--delay', - '50', - ]) - .catch((error) => { - expect(error.message).to.contain( + .it('throw error on global field with empty schema content_type', async () => { + const { stderr } = await runCommand( + [ + 'cm:entries:migrate-html-rte', + '--alias', + 'test1', + '--content-type', + 'globalfieldwithemptyschemacontenttype', + '--global-field', + '--html-path', + 'rich_text_editor', + '--json-path', + 'supercharged_rte', + '--yes', + '--delay', + '50', + ], + { root: process.cwd() }, + ); + expect(stderr.message).to.contain( 'The contenttypewithemptyschema content type referred in globalfieldwithemptyschemacontenttype contains an empty schema.', ); - }) - .it('throw error on global field with empty schema content_type'); + }); - test - .loadConfig({ root: process.cwd() }) + fancy .stub(cliux, 'confirm', () => 'yes') .stub(command, 'getToken', getTokenCallback) - .stdout() - .command([ - 'cm:entries:migrate-html-rte', - '--alias', - 'test1', - '--content-type', - 'invalidUidGlobalfield', - '--global-field', - '--html-path', - 'rich_text_editor', - '--json-path', - 'supercharged_rte', - '--yes', - '--delay', - '50', - ]) - .catch((error) => { - expect(error.message).to.contain("The Global Field 'invalidUidGlobalfield' was not found. Please try again."); - }) - .it('throw error on invalid global_field uid'); + .it('throw error on invalid global_field uid', async () => { + const { stderr } = await runCommand( + [ + 'cm:entries:migrate-html-rte', + '--alias', + 'test1', + '--content-type', + 'invalidUidGlobalfield', + '--global-field', + '--html-path', + 'rich_text_editor', + '--json-path', + 'supercharged_rte', + '--yes', + '--delay', + '50', + ], + { root: process.cwd() }, + ); + expect(stderr.message).to.contain("The Global Field 'invalidUidGlobalfield' was not found. Please try again."); + }); }); describe('Content Type with single rte of multiple type', () => { @@ -745,14 +746,15 @@ describe('Content Type with single rte of multiple type', () => { apiKey: 'testApiKey', type: 'management', }); - test - .loadConfig({ root: process.cwd() }) + fancy .stub(cliux, 'confirm', () => 'yes') .stub(command, 'getToken', getTokenCallback) - .stdout() - .command(['cm:entries:migrate-html-rte', '--config-path', './test/dummy/config/configForMultipleRte.json', '--yes']) - .it('execute using config file', (ctx) => { - expect(ctx.stdout).to.contain('Updated 1 Content Type(s) and 1 Entrie(s)'); + .it('execute using config file', async () => { + const {stdout} = await runCommand( + ['cm:entries:migrate-html-rte', '--config-path', './test/dummy/config/configForMultipleRte.json', '--yes'], + { root: process.cwd() }, + ); + expect(stdout).to.contain('Updated 1 Content Type(s) and 1 Entrie(s)'); }); }); @@ -763,27 +765,28 @@ describe('Content Type with Single RTE inside modular block', () => { apiKey: 'testApiKey', type: 'management', }); - test - .loadConfig({ root: process.cwd() }) + fancy .stub(cliux, 'confirm', () => 'yes') .stub(command, 'getToken', getTokenCallback) - .stdout() - .command([ - 'cm:entries:migrate-html-rte', - '--alias', - 'test1', - '--content-type', - 'contenttypewithmodularblock', - '--html-path', - 'modular_blocks.test1.rich_text_editor', - '--json-path', - 'modular_blocks.test1.supercharged_rte', - '--yes', - '--delay', - '50', - ]) - .it('execute using Flags', (ctx) => { - expect(ctx.stdout).to.contain('Updated 1 Content Type(s) and 1 Entrie(s)'); + .it('execute using Flags', async () => { + const { stdout } = await runCommand( + [ + 'cm:entries:migrate-html-rte', + '--alias', + 'test1', + '--content-type', + 'contenttypewithmodularblock', + '--html-path', + 'modular_blocks.test1.rich_text_editor', + '--json-path', + 'modular_blocks.test1.supercharged_rte', + '--yes', + '--delay', + '50', + ], + { root: process.cwd() }, + ); + expect(stdout).to.contain('Updated 1 Content Type(s) and 1 Entrie(s)'); }); }); @@ -794,27 +797,28 @@ describe('Content Type with Single RTE of type multiple inside group', () => { apiKey: 'testApiKey', type: 'management', }); - test - .loadConfig({ root: process.cwd() }) + fancy .stub(cliux, 'confirm', () => 'yes') .stub(command, 'getToken', getTokenCallback) - .stdout() - .command([ - 'cm:entries:migrate-html-rte', - '--alias', - 'test1', - '--content-type', - 'contenttypewithgroup', - '--html-path', - 'group.rich_text_editor', - '--json-path', - 'group.supercharged_rte', - '--yes', - '--delay', - '50', - ]) - .it('execute using Flags', (ctx) => { - expect(ctx.stdout).to.contain('Updated 1 Content Type(s) and 1 Entrie(s)'); + .it('execute using Flags', async () => { + const { stdout } = await runCommand( + [ + 'cm:entries:migrate-html-rte', + '--alias', + 'test1', + '--content-type', + 'contenttypewithgroup', + '--html-path', + 'group.rich_text_editor', + '--json-path', + 'group.supercharged_rte', + '--yes', + '--delay', + '50', + ], + { root: process.cwd() }, + ); + expect(stdout).to.contain('Updated 1 Content Type(s) and 1 Entrie(s)'); }); }); @@ -825,30 +829,32 @@ describe('Content Type with Single RTE inside group of type multiple', () => { apiKey: 'testApiKey', type: 'management', }); - test - .loadConfig({ root: process.cwd() }) + fancy .stub(cliux, 'confirm', () => 'yes') .stub(command, 'getToken', getTokenCallback) - .stdout() - .command([ - 'cm:entries:migrate-html-rte', - '--alias', - 'test1', - '--content-type', - 'contenttypewithmultiplegroup', - '--html-path', - 'group.rich_text_editor', - '--json-path', - 'group.supercharged_rte', - '--yes', - '--delay', - '50', - ]) - .it('execute using Flags', (ctx) => { - expect(ctx.stdout).to.contain('Updated 1 Content Type(s) and 1 Entrie(s)'); + .it('execute using Flags', async () => { + const { stdout } = await runCommand( + [ + 'cm:entries:migrate-html-rte', + '--alias', + 'test1', + '--content-type', + 'contenttypewithmultiplegroup', + '--html-path', + 'group.rich_text_editor', + '--json-path', + 'group.supercharged_rte', + '--yes', + '--delay', + '50', + ], + { root: process.cwd() }, + ); + expect(stdout).to.contain('Updated 1 Content Type(s) and 1 Entrie(s)'); }); }); +// Check this one describe('Content Type with multiple file field', () => { const getTokenCallback = sinon.stub(); getTokenCallback.withArgs('test1').returns({ @@ -856,27 +862,28 @@ describe('Content Type with multiple file field', () => { apiKey: 'testApiKey', type: 'management', }); - test - .loadConfig({ root: process.cwd() }) + fancy .stub(cliux, 'confirm', () => 'yes') .stub(command, 'getToken', getTokenCallback) - .stdout() - .command([ - 'cm:entries:migrate-html-rte', - '--alias', - 'test1', - '--content-type', - 'contenttypewithfilefield', - '--html-path', - 'rich_text_editor', - '--json-path', - 'json_rte', - '--yes', - '--delay', - '50', - ]) - .it('execute using Flags', (ctx) => { - expect(ctx.stdout).to.contain('Updated 1 Content Type(s) and 1 Entrie(s)'); + .it('execute using Flags', async () => { + const { stdout } = await runCommand( + [ + 'cm:entries:migrate-html-rte', + '--alias', + 'test1', + '--content-type', + 'contenttypewithfilefield', + '--html-path', + 'rich_text_editor', + '--json-path', + 'json_rte', + '--yes', + '--delay', + '50', + ], + { root: process.cwd() }, + ); + expect(stdout).to.contain('Updated 1 Content Type(s) and 1 Entrie(s)'); }); }); @@ -888,47 +895,48 @@ describe('Migration with old flags and command', () => { type: 'management', }); - test + fancy .stub(cliux, 'confirm', () => 'yes') .stub(command, 'getToken', getTokenCallback) - .stdout() - .command(['cm:migrate-rte', '--configPath', './test/dummy/config/config.json', '--yes']) - .it('execute using config file w/o locale', (ctx) => { - expect(ctx.stdout).to.contain( - `DEPRECATION WARNING: flags -p,--configPath will be removed in two months, start using -c,--config-path flags instead`, + .it('execute using config file w/o locale', async (ctx) => { + const { stdout } = await runCommand( + ['cm:migrate-rte', '--configPath', './test/dummy/config/config.json', '--yes'], + { root: process.cwd() }, + ); + expect(stdout).to.contain( + `WARNING!!! You're using the old (soon to be deprecated) Contentstack CLI flags (-p, --configPath). We recommend you to use the updated flags (-c, --config-path).`, ); - expect(ctx.stdout).to.contain('Updated 1 Content Type(s) and 2 Entrie(s)'); }); - test - .loadConfig({ root: process.cwd() }) + fancy .stub(cliux, 'confirm', () => 'yes') .stub(command, 'getToken', getTokenCallback) - .stdout() - .command([ - 'cm:entries:migrate-html-rte', - '--alias', - 'test1', - '--content_type', - 'contenttypewithsinglerte', - '--htmlPath', - 'rich_text_editor', - '--jsonPath', - 'supercharged_rte', - '--delay', - '50', - ]) - .it('execute using flags (w/o locale)', (ctx) => { - expect(ctx.stdout).to.contain( - `DEPRECATION WARNING: flags -c,--content_type will be removed in two months, start using --content-type flags instead`, - ); - expect(ctx.stdout).to.contain( - `DEPRECATION WARNING: flags -h,--htmlPath will be removed in two months, start using --html-path flags instead`, - ); - expect(ctx.stdout).to.contain( - `DEPRECATION WARNING: flags -j,--jsonPath will be removed in two months, start using --json-path flags instead`, - ); - - expect(ctx.stdout).to.contain('Updated 1 Content Type(s) and 2 Entrie(s)'); + .it('execute using flags (w/o locale)', async () => { + const { stdout } = await runCommand( + [ + 'cm:entries:migrate-html-rte', + '--alias', + 'test1', + '--content_type', + 'contenttypewithsinglerte', + '--htmlPath', + 'rich_text_editor', + '--jsonPath', + 'supercharged_rte', + '--delay', + '50', + ], + { root: process.cwd() }, + ); + + expect(stdout).to.contain( + `WARNING!!! You're using the old (soon to be deprecated) Contentstack CLI flags (-c, --content_type). We recommend you to use the updated flags (--content-type).`, + ); + expect(stdout).to.contain( + `WARNING!!! You're using the old (soon to be deprecated) Contentstack CLI flags (-h, --htmlPath). We recommend you to use the updated flags (--html-path)`, + ); + expect(stdout).to.contain( + `WARNING!!! You're using the old (soon to be deprecated) Contentstack CLI flags (-j, --jsonPath). We recommend you to use the updated flags (--json-path).`, + ); }); }); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 73d220c67e..b01078dd39 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -904,8 +904,8 @@ importers: specifiers: '@contentstack/cli-command': ~1.3.2 '@contentstack/cli-utilities': ~1.8.0 - '@contentstack/json-rte-serializer': ~2.0.10 - '@oclif/test': ^4.0.9 + '@contentstack/json-rte-serializer': ~2.0.11 + '@oclif/test': ^4.1.0 chai: ^4.5.0 chalk: ^4.1.2 collapse-whitespace: ^1.1.7 @@ -915,7 +915,7 @@ importers: jsdom: ^20.0.3 jsonschema: ^1.4.1 lodash: ^4.17.21 - mocha: ^10.7.3 + mocha: ^10.8.1 nock: ^13.5.5 nyc: ^15.1.0 oclif: ^3.17.2 @@ -926,7 +926,7 @@ importers: dependencies: '@contentstack/cli-command': link:../contentstack-command '@contentstack/cli-utilities': link:../contentstack-utilities - '@contentstack/json-rte-serializer': 2.0.10 + '@contentstack/json-rte-serializer': 2.0.11 chalk: 4.1.2 collapse-whitespace: 1.1.7 jsdom: 20.0.3 @@ -942,7 +942,7 @@ importers: eslint: 8.57.1 eslint-config-oclif: 4.0.0_eslint@8.57.1 globby: 10.0.2 - mocha: 10.7.3 + mocha: 10.8.1 nyc: 15.1.0 oclif: 3.17.2 tslib: 1.14.1 @@ -1627,8 +1627,8 @@ packages: engines: {node: '>=0.1.90'} dev: false - /@contentstack/json-rte-serializer/2.0.10: - resolution: {integrity: sha512-32tzzNTaXsfJjuPe2x0xz1f1c3JKKtS7XHBo2y6C4NujKe2ROW2Fq50VjdEYbjm7oo8uOt4yOE1XZpj0KjmQXQ==} + /@contentstack/json-rte-serializer/2.0.11: + resolution: {integrity: sha512-FOcB3YANmCchIPXblYi5LZ8viViVslhLibHsYnopmiT+3Jvyw8K2hbdTS2/Cm4hqIppBn2u76Xk2XjdW0LlBYQ==} dependencies: array-flat-polyfill: 1.0.1 lodash: 4.17.21 @@ -11006,6 +11006,33 @@ packages: yargs-unparser: 2.0.0 dev: true + /mocha/10.8.1: + resolution: {integrity: sha512-WxSpEWgF03HfgNKBuysfK40DUaOSVX5zxgLDoieMGO+zyE69iq2eQ1vBypvIJ5mOPKpuVAqWiTbt4Orj7L6wVw==} + engines: {node: '>= 14.0.0'} + hasBin: true + dependencies: + ansi-colors: 4.1.3 + browser-stdout: 1.3.1 + chokidar: 3.6.0 + debug: 4.3.7_supports-color@8.1.1 + diff: 5.2.0 + escape-string-regexp: 4.0.0 + find-up: 5.0.0 + glob: 8.1.0 + he: 1.2.0 + js-yaml: 4.1.0 + log-symbols: 4.1.0 + minimatch: 5.1.6 + ms: 2.1.3 + serialize-javascript: 6.0.2 + strip-json-comments: 3.1.1 + supports-color: 8.1.1 + workerpool: 6.5.1 + yargs: 16.2.0 + yargs-parser: 20.2.9 + yargs-unparser: 2.0.0 + dev: true + /mock-stdin/1.0.0: resolution: {integrity: sha512-tukRdb9Beu27t6dN+XztSRHq9J0B/CoAOySGzHfn8UTfmqipA5yNT/sDUEyYdAV3Hpka6Wx6kOMxuObdOex60Q==}