diff --git a/package-lock.json b/package-lock.json index b9780bab..38934854 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,8 +9,8 @@ "version": "2.0.0-beta.0", "license": "MIT", "dependencies": { - "@contentstack/cli-command": "^1.8.7", - "@contentstack/cli-utilities": "^1.18.5", + "@contentstack/cli-command": "^2.0.2", + "@contentstack/cli-utilities": "^2.0.2", "@oclif/core": "^4.2.7", "@oclif/plugin-help": "^6.2.25", "@rollup/plugin-commonjs": "^28.0.9", @@ -810,71 +810,87 @@ } }, "node_modules/@contentstack/cli-command": { - "version": "1.8.7", - "resolved": "https://registry.npmjs.org/@contentstack/cli-command/-/cli-command-1.8.7.tgz", - "integrity": "sha512-j5DvrZG8nPFsaTBceoTogz7QzIifySTmgw28SjmcMcP/5qJphxXiDUSO9yGH0VXxolqpR17XL6I0RznBjsd6ZA==", + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/@contentstack/cli-command/-/cli-command-2.0.2.tgz", + "integrity": "sha512-Xp4WosPXRPs7PnI+xbpwMdevWFGyVco57ZXH/CwRZznKHiFZ9GI7FOlw2oJMQGGysUMPGS8NyRzHB98d3Y2OPA==", "license": "MIT", "dependencies": { - "@contentstack/cli-utilities": "~1.19.2", - "@oclif/core": "^4.11.4", - "contentstack": "^3.27.0" + "@contentstack/cli-utilities": "~2.0.2", + "@oclif/core": "^4.11.14", + "contentstack": "^3.27.0", + "tslib": "^2.8.1" }, "engines": { "node": ">=22.0.0" } }, "node_modules/@contentstack/cli-utilities": { - "version": "1.19.2", - "resolved": "https://registry.npmjs.org/@contentstack/cli-utilities/-/cli-utilities-1.19.2.tgz", - "integrity": "sha512-njkv8GFbZLaMm4j0RZLalnnb8dH58Sj+JjYQyBaSUplEzuLBy6rcOmLazBC/4zgxKwj+N/0SlmU2kgEc4negOw==", + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/@contentstack/cli-utilities/-/cli-utilities-2.0.2.tgz", + "integrity": "sha512-EacaD/8DQxtkKs6SEJ/0LOy1hxFbIcEP7Edi+eSOAkw0ln1gP2pYvpCqM33B8pPm5IWYx28UAdkC0nRnSPvs2w==", "license": "MIT", "dependencies": { - "@contentstack/management": "~1.30.1", - "@contentstack/marketplace-sdk": "^1.5.1", + "@contentstack/management": "~1.31.2", + "@contentstack/marketplace-sdk": "^1.5.4", "@contentstack/utils": "~1.9.1", - "@oclif/core": "^4.11.4", - "axios": "^1.19.0", - "chalk": "^4.1.2", + "@oclif/core": "^4.11.14", + "axios": "^1.20.0", + "chalk": "^5.6.2", "cli-cursor": "^3.1.0", "cli-progress": "^3.12.0", "cli-table": "^0.3.11", "conf": "^10.2.0", "dotenv": "^16.6.1", "figures": "^3.2.0", - "inquirer": "8.2.7", + "inquirer": "12.11.1", "inquirer-search-checkbox": "^1.0.0", "inquirer-search-list": "^1.2.6", - "js-yaml": "^4.3.1", + "js-yaml": "^4.3.2", "klona": "^2.0.6", "lodash": "^4.18.1", "mkdirp": "^1.0.4", "open": "^8.4.2", "ora": "^5.4.1", - "papaparse": "^5.5.3", - "recheck": "~4.4.5", + "papaparse": "^5.5.4", + "recheck": "~4.5.0", "rxjs": "^6.6.7", - "short-uuid": "^6.0.0", + "short-uuid": "^6.0.3", "traverse": "^0.6.11", + "tslib": "^2.8.1", "tty-table": "^4.2.3", "unique-string": "^2.0.0", - "uuid": "^14.0.0", + "uuid": "^14.0.1", "winston": "^3.19.0", "xdg-basedir": "^4.0.0" } }, + "node_modules/@contentstack/cli-utilities/node_modules/chalk": { + "version": "5.6.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-5.6.2.tgz", + "integrity": "sha512-7NzBL0rN6fMUW+f7A6Io4h40qQlG+xGmtMxfbnH/K7TAtt8JQWVQK+6g0UXKMeVJoyV5EkkNsErQ8pVD3bLHbA==", + "license": "MIT", + "engines": { + "node": "^12.17.0 || ^14.13 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, "node_modules/@contentstack/management": { - "version": "1.30.4", + "version": "1.31.3", + "resolved": "https://registry.npmjs.org/@contentstack/management/-/management-1.31.3.tgz", + "integrity": "sha512-YOe+q3Gp6cE3Olb3hqddxYpsPottVSZTZ9Xc/QHQL1l9pXHaGBPIg9zle7spLgzn24L2ug7EhHZ3FEUgxTyI1g==", "license": "MIT", "dependencies": { "@contentstack/utils": "^1.9.1", "assert": "^2.1.0", - "axios": "^1.18.1", + "axios": "^1.20.0", "buffer": "^6.0.3", "form-data": "^4.0.6", "husky": "^9.1.7", "lodash": "^4.18.1", "otplib": "^12.0.1", - "qs": "^6.15.2", + "qs": "~6.16.2", "stream-browserify": "^3.0.0" }, "engines": { @@ -1321,7 +1337,6 @@ }, "node_modules/@inquirer/ansi": { "version": "1.0.2", - "dev": true, "license": "MIT", "engines": { "node": ">=18" @@ -1329,7 +1344,6 @@ }, "node_modules/@inquirer/checkbox": { "version": "4.3.2", - "dev": true, "license": "MIT", "dependencies": { "@inquirer/ansi": "^1.0.2", @@ -1352,7 +1366,6 @@ }, "node_modules/@inquirer/checkbox/node_modules/@inquirer/core": { "version": "10.3.2", - "dev": true, "license": "MIT", "dependencies": { "@inquirer/ansi": "^1.0.2", @@ -1378,7 +1391,6 @@ }, "node_modules/@inquirer/checkbox/node_modules/@inquirer/type": { "version": "3.0.10", - "dev": true, "license": "MIT", "engines": { "node": ">=18" @@ -1394,23 +1406,13 @@ }, "node_modules/@inquirer/checkbox/node_modules/cli-width": { "version": "4.1.0", - "dev": true, "license": "ISC", "engines": { "node": ">= 12" } }, - "node_modules/@inquirer/checkbox/node_modules/mute-stream": { - "version": "2.0.0", - "dev": true, - "license": "ISC", - "engines": { - "node": "^18.17.0 || >=20.5.0" - } - }, "node_modules/@inquirer/checkbox/node_modules/signal-exit": { "version": "4.1.0", - "dev": true, "license": "ISC", "engines": { "node": ">=14" @@ -1421,7 +1423,6 @@ }, "node_modules/@inquirer/checkbox/node_modules/wrap-ansi": { "version": "6.2.0", - "dev": true, "license": "MIT", "dependencies": { "ansi-styles": "^4.0.0", @@ -1519,7 +1520,6 @@ }, "node_modules/@inquirer/editor": { "version": "4.2.23", - "dev": true, "license": "MIT", "dependencies": { "@inquirer/core": "^10.3.2", @@ -1540,7 +1540,6 @@ }, "node_modules/@inquirer/editor/node_modules/@inquirer/core": { "version": "10.3.2", - "dev": true, "license": "MIT", "dependencies": { "@inquirer/ansi": "^1.0.2", @@ -1566,7 +1565,6 @@ }, "node_modules/@inquirer/editor/node_modules/@inquirer/type": { "version": "3.0.10", - "dev": true, "license": "MIT", "engines": { "node": ">=18" @@ -1582,23 +1580,13 @@ }, "node_modules/@inquirer/editor/node_modules/cli-width": { "version": "4.1.0", - "dev": true, "license": "ISC", "engines": { "node": ">= 12" } }, - "node_modules/@inquirer/editor/node_modules/mute-stream": { - "version": "2.0.0", - "dev": true, - "license": "ISC", - "engines": { - "node": "^18.17.0 || >=20.5.0" - } - }, "node_modules/@inquirer/editor/node_modules/signal-exit": { "version": "4.1.0", - "dev": true, "license": "ISC", "engines": { "node": ">=14" @@ -1609,7 +1597,6 @@ }, "node_modules/@inquirer/editor/node_modules/wrap-ansi": { "version": "6.2.0", - "dev": true, "license": "MIT", "dependencies": { "ansi-styles": "^4.0.0", @@ -1622,7 +1609,6 @@ }, "node_modules/@inquirer/expand": { "version": "4.0.23", - "dev": true, "license": "MIT", "dependencies": { "@inquirer/core": "^10.3.2", @@ -1643,7 +1629,6 @@ }, "node_modules/@inquirer/expand/node_modules/@inquirer/core": { "version": "10.3.2", - "dev": true, "license": "MIT", "dependencies": { "@inquirer/ansi": "^1.0.2", @@ -1669,7 +1654,6 @@ }, "node_modules/@inquirer/expand/node_modules/@inquirer/type": { "version": "3.0.10", - "dev": true, "license": "MIT", "engines": { "node": ">=18" @@ -1685,23 +1669,13 @@ }, "node_modules/@inquirer/expand/node_modules/cli-width": { "version": "4.1.0", - "dev": true, "license": "ISC", "engines": { "node": ">= 12" } }, - "node_modules/@inquirer/expand/node_modules/mute-stream": { - "version": "2.0.0", - "dev": true, - "license": "ISC", - "engines": { - "node": "^18.17.0 || >=20.5.0" - } - }, "node_modules/@inquirer/expand/node_modules/signal-exit": { "version": "4.1.0", - "dev": true, "license": "ISC", "engines": { "node": ">=14" @@ -1712,7 +1686,6 @@ }, "node_modules/@inquirer/expand/node_modules/wrap-ansi": { "version": "6.2.0", - "dev": true, "license": "MIT", "dependencies": { "ansi-styles": "^4.0.0", @@ -1758,7 +1731,6 @@ }, "node_modules/@inquirer/figures": { "version": "1.0.15", - "dev": true, "license": "MIT", "engines": { "node": ">=18" @@ -1778,7 +1750,6 @@ }, "node_modules/@inquirer/number": { "version": "3.0.23", - "dev": true, "license": "MIT", "dependencies": { "@inquirer/core": "^10.3.2", @@ -1798,7 +1769,6 @@ }, "node_modules/@inquirer/number/node_modules/@inquirer/core": { "version": "10.3.2", - "dev": true, "license": "MIT", "dependencies": { "@inquirer/ansi": "^1.0.2", @@ -1824,7 +1794,6 @@ }, "node_modules/@inquirer/number/node_modules/@inquirer/type": { "version": "3.0.10", - "dev": true, "license": "MIT", "engines": { "node": ">=18" @@ -1840,23 +1809,13 @@ }, "node_modules/@inquirer/number/node_modules/cli-width": { "version": "4.1.0", - "dev": true, "license": "ISC", "engines": { "node": ">= 12" } }, - "node_modules/@inquirer/number/node_modules/mute-stream": { - "version": "2.0.0", - "dev": true, - "license": "ISC", - "engines": { - "node": "^18.17.0 || >=20.5.0" - } - }, "node_modules/@inquirer/number/node_modules/signal-exit": { "version": "4.1.0", - "dev": true, "license": "ISC", "engines": { "node": ">=14" @@ -1867,7 +1826,6 @@ }, "node_modules/@inquirer/number/node_modules/wrap-ansi": { "version": "6.2.0", - "dev": true, "license": "MIT", "dependencies": { "ansi-styles": "^4.0.0", @@ -1880,7 +1838,6 @@ }, "node_modules/@inquirer/password": { "version": "4.0.23", - "dev": true, "license": "MIT", "dependencies": { "@inquirer/ansi": "^1.0.2", @@ -1901,7 +1858,6 @@ }, "node_modules/@inquirer/password/node_modules/@inquirer/core": { "version": "10.3.2", - "dev": true, "license": "MIT", "dependencies": { "@inquirer/ansi": "^1.0.2", @@ -1927,7 +1883,6 @@ }, "node_modules/@inquirer/password/node_modules/@inquirer/type": { "version": "3.0.10", - "dev": true, "license": "MIT", "engines": { "node": ">=18" @@ -1943,23 +1898,13 @@ }, "node_modules/@inquirer/password/node_modules/cli-width": { "version": "4.1.0", - "dev": true, "license": "ISC", "engines": { "node": ">= 12" } }, - "node_modules/@inquirer/password/node_modules/mute-stream": { - "version": "2.0.0", - "dev": true, - "license": "ISC", - "engines": { - "node": "^18.17.0 || >=20.5.0" - } - }, "node_modules/@inquirer/password/node_modules/signal-exit": { "version": "4.1.0", - "dev": true, "license": "ISC", "engines": { "node": ">=14" @@ -1970,7 +1915,6 @@ }, "node_modules/@inquirer/password/node_modules/wrap-ansi": { "version": "6.2.0", - "dev": true, "license": "MIT", "dependencies": { "ansi-styles": "^4.0.0", @@ -1983,7 +1927,6 @@ }, "node_modules/@inquirer/prompts": { "version": "7.10.1", - "dev": true, "license": "MIT", "dependencies": { "@inquirer/checkbox": "^4.3.2", @@ -2011,7 +1954,6 @@ }, "node_modules/@inquirer/prompts/node_modules/@inquirer/confirm": { "version": "5.1.21", - "dev": true, "license": "MIT", "dependencies": { "@inquirer/core": "^10.3.2", @@ -2031,7 +1973,6 @@ }, "node_modules/@inquirer/prompts/node_modules/@inquirer/core": { "version": "10.3.2", - "dev": true, "license": "MIT", "dependencies": { "@inquirer/ansi": "^1.0.2", @@ -2057,7 +1998,6 @@ }, "node_modules/@inquirer/prompts/node_modules/@inquirer/input": { "version": "4.3.1", - "dev": true, "license": "MIT", "dependencies": { "@inquirer/core": "^10.3.2", @@ -2077,7 +2017,6 @@ }, "node_modules/@inquirer/prompts/node_modules/@inquirer/select": { "version": "4.4.2", - "dev": true, "license": "MIT", "dependencies": { "@inquirer/ansi": "^1.0.2", @@ -2100,7 +2039,6 @@ }, "node_modules/@inquirer/prompts/node_modules/@inquirer/type": { "version": "3.0.10", - "dev": true, "license": "MIT", "engines": { "node": ">=18" @@ -2116,23 +2054,13 @@ }, "node_modules/@inquirer/prompts/node_modules/cli-width": { "version": "4.1.0", - "dev": true, "license": "ISC", "engines": { "node": ">= 12" } }, - "node_modules/@inquirer/prompts/node_modules/mute-stream": { - "version": "2.0.0", - "dev": true, - "license": "ISC", - "engines": { - "node": "^18.17.0 || >=20.5.0" - } - }, "node_modules/@inquirer/prompts/node_modules/signal-exit": { "version": "4.1.0", - "dev": true, "license": "ISC", "engines": { "node": ">=14" @@ -2143,7 +2071,6 @@ }, "node_modules/@inquirer/prompts/node_modules/wrap-ansi": { "version": "6.2.0", - "dev": true, "license": "MIT", "dependencies": { "ansi-styles": "^4.0.0", @@ -2156,7 +2083,6 @@ }, "node_modules/@inquirer/rawlist": { "version": "4.1.11", - "dev": true, "license": "MIT", "dependencies": { "@inquirer/core": "^10.3.2", @@ -2177,7 +2103,6 @@ }, "node_modules/@inquirer/rawlist/node_modules/@inquirer/core": { "version": "10.3.2", - "dev": true, "license": "MIT", "dependencies": { "@inquirer/ansi": "^1.0.2", @@ -2203,7 +2128,6 @@ }, "node_modules/@inquirer/rawlist/node_modules/@inquirer/type": { "version": "3.0.10", - "dev": true, "license": "MIT", "engines": { "node": ">=18" @@ -2219,23 +2143,13 @@ }, "node_modules/@inquirer/rawlist/node_modules/cli-width": { "version": "4.1.0", - "dev": true, "license": "ISC", "engines": { "node": ">= 12" } }, - "node_modules/@inquirer/rawlist/node_modules/mute-stream": { - "version": "2.0.0", - "dev": true, - "license": "ISC", - "engines": { - "node": "^18.17.0 || >=20.5.0" - } - }, "node_modules/@inquirer/rawlist/node_modules/signal-exit": { "version": "4.1.0", - "dev": true, "license": "ISC", "engines": { "node": ">=14" @@ -2246,7 +2160,6 @@ }, "node_modules/@inquirer/rawlist/node_modules/wrap-ansi": { "version": "6.2.0", - "dev": true, "license": "MIT", "dependencies": { "ansi-styles": "^4.0.0", @@ -2259,7 +2172,6 @@ }, "node_modules/@inquirer/search": { "version": "3.2.2", - "dev": true, "license": "MIT", "dependencies": { "@inquirer/core": "^10.3.2", @@ -2281,7 +2193,6 @@ }, "node_modules/@inquirer/search/node_modules/@inquirer/core": { "version": "10.3.2", - "dev": true, "license": "MIT", "dependencies": { "@inquirer/ansi": "^1.0.2", @@ -2307,7 +2218,6 @@ }, "node_modules/@inquirer/search/node_modules/@inquirer/type": { "version": "3.0.10", - "dev": true, "license": "MIT", "engines": { "node": ">=18" @@ -2323,23 +2233,13 @@ }, "node_modules/@inquirer/search/node_modules/cli-width": { "version": "4.1.0", - "dev": true, "license": "ISC", "engines": { "node": ">= 12" } }, - "node_modules/@inquirer/search/node_modules/mute-stream": { - "version": "2.0.0", - "dev": true, - "license": "ISC", - "engines": { - "node": "^18.17.0 || >=20.5.0" - } - }, "node_modules/@inquirer/search/node_modules/signal-exit": { "version": "4.1.0", - "dev": true, "license": "ISC", "engines": { "node": ">=14" @@ -2350,7 +2250,6 @@ }, "node_modules/@inquirer/search/node_modules/wrap-ansi": { "version": "6.2.0", - "dev": true, "license": "MIT", "dependencies": { "ansi-styles": "^4.0.0", @@ -2985,10 +2884,15 @@ }, "node_modules/@otplib/core": { "version": "12.0.1", + "resolved": "https://registry.npmjs.org/@otplib/core/-/core-12.0.1.tgz", + "integrity": "sha512-4sGntwbA/AC+SbPhbsziRiD+jNDdIzsZ3JUyfZwjtKyc/wufl1pnSIaG4Uqx8ymPagujub0o92kgBnB89cuAMA==", "license": "MIT" }, "node_modules/@otplib/plugin-crypto": { "version": "12.0.1", + "resolved": "https://registry.npmjs.org/@otplib/plugin-crypto/-/plugin-crypto-12.0.1.tgz", + "integrity": "sha512-qPuhN3QrT7ZZLcLCyKOSNhuijUi9G5guMRVrxq63r9YNOxxQjPm59gVxLM+7xGnHnM6cimY57tuKsjK7y9LM1g==", + "deprecated": "Please upgrade to v13 of otplib. Refer to otplib docs for migration paths", "license": "MIT", "dependencies": { "@otplib/core": "^12.0.1" @@ -2996,6 +2900,9 @@ }, "node_modules/@otplib/plugin-thirty-two": { "version": "12.0.1", + "resolved": "https://registry.npmjs.org/@otplib/plugin-thirty-two/-/plugin-thirty-two-12.0.1.tgz", + "integrity": "sha512-MtT+uqRso909UkbrrYpJ6XFjj9D+x2Py7KjTO9JDPhL0bJUYVu5kFP4TFZW4NFAywrAtFRxOVY261u0qwb93gA==", + "deprecated": "Please upgrade to v13 of otplib. Refer to otplib docs for migration paths", "license": "MIT", "dependencies": { "@otplib/core": "^12.0.1", @@ -3004,6 +2911,9 @@ }, "node_modules/@otplib/preset-default": { "version": "12.0.1", + "resolved": "https://registry.npmjs.org/@otplib/preset-default/-/preset-default-12.0.1.tgz", + "integrity": "sha512-xf1v9oOJRyXfluBhMdpOkr+bsE+Irt+0D5uHtvg6x1eosfmHCsCC6ej/m7FXiWqdo0+ZUI6xSKDhJwc8yfiOPQ==", + "deprecated": "Please upgrade to v13 of otplib. Refer to otplib docs for migration paths", "license": "MIT", "dependencies": { "@otplib/core": "^12.0.1", @@ -3013,6 +2923,8 @@ }, "node_modules/@otplib/preset-v11": { "version": "12.0.1", + "resolved": "https://registry.npmjs.org/@otplib/preset-v11/-/preset-v11-12.0.1.tgz", + "integrity": "sha512-9hSetMI7ECqbFiKICrNa4w70deTUfArtwXykPUvSHWOdzOlfa9ajglu7mNCntlvxycTiOAXkQGwjQCzzDEMRMg==", "license": "MIT", "dependencies": { "@otplib/core": "^12.0.1", @@ -3020,6 +2932,18 @@ "@otplib/plugin-thirty-two": "^12.0.1" } }, + "node_modules/@pkgr/core": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/@pkgr/core/-/core-0.1.2.tgz", + "integrity": "sha512-fdDH1LSGfZdTH2sxdpVMw31BanV28K/Gry0cVFxaNP77neJSkd82mM8ErPNYs9e+0O7SdHBLTDzDgwUuy18RnQ==", + "license": "MIT", + "engines": { + "node": "^12.20.0 || ^14.18.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/unts" + } + }, "node_modules/@pnpm/config.env-replace": { "version": "1.1.0", "dev": true, @@ -4768,6 +4692,8 @@ }, "node_modules/assert": { "version": "2.1.0", + "resolved": "https://registry.npmjs.org/assert/-/assert-2.1.0.tgz", + "integrity": "sha512-eLHpSK/Y4nhMJ07gDaAzoX/XAKS8PSaojml3M0DM4JpV1LAi5JOJ/p6H/XWrl8L+DzVEvVCW1z3vWAaB9oTsQw==", "license": "MIT", "dependencies": { "call-bind": "^1.0.2", @@ -4953,6 +4879,8 @@ }, "node_modules/base64-js": { "version": "1.5.1", + "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", + "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==", "funding": [ { "type": "github", @@ -4984,6 +4912,8 @@ }, "node_modules/bl": { "version": "4.1.0", + "resolved": "https://registry.npmjs.org/bl/-/bl-4.1.0.tgz", + "integrity": "sha512-1W07cM9gS6DcLperZfFSj+bWLtaPGSOHWhPiGzXmvVJbRLdG82sH/Kn8EtW1VqWVA54AKf2h5k5BbnIbwF3h6w==", "license": "MIT", "dependencies": { "buffer": "^5.5.0", @@ -4993,6 +4923,8 @@ }, "node_modules/bl/node_modules/buffer": { "version": "5.7.1", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.7.1.tgz", + "integrity": "sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==", "funding": [ { "type": "github", @@ -5148,6 +5080,8 @@ }, "node_modules/buffer": { "version": "6.0.3", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-6.0.3.tgz", + "integrity": "sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==", "funding": [ { "type": "github", @@ -5422,6 +5356,8 @@ }, "node_modules/cli-cursor": { "version": "3.1.0", + "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-3.1.0.tgz", + "integrity": "sha512-I/zHAwsKf9FqGoXM4WWRACob9+SNukZTd94DWF57E4toouRulbCxcUh6RKUEOQlYTHJnzkPMySvPNaaSLNfLZw==", "license": "MIT", "dependencies": { "restore-cursor": "^3.1.0" @@ -5520,13 +5456,6 @@ "url": "https://github.com/chalk/strip-ansi?sponsor=1" } }, - "node_modules/cli-width": { - "version": "3.0.0", - "license": "ISC", - "engines": { - "node": ">= 10" - } - }, "node_modules/cliui": { "version": "8.0.1", "license": "ISC", @@ -7320,6 +7249,8 @@ }, "node_modules/figures": { "version": "3.2.0", + "resolved": "https://registry.npmjs.org/figures/-/figures-3.2.0.tgz", + "integrity": "sha512-yaduQFRKLXYOGgEn6AZau90j3ggSOyiqXU0F9JZfeXYhNa+Jk4X+s45A2zg5jns87GAFa34BBm2kXw4XpNcbdg==", "license": "MIT", "dependencies": { "escape-string-regexp": "^1.0.5" @@ -7333,6 +7264,8 @@ }, "node_modules/figures/node_modules/escape-string-regexp": { "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==", "license": "MIT", "engines": { "node": ">=0.8.0" @@ -8061,6 +7994,8 @@ }, "node_modules/ieee754": { "version": "1.2.1", + "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", + "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==", "funding": [ { "type": "github", @@ -8147,27 +8082,29 @@ "license": "ISC" }, "node_modules/inquirer": { - "version": "8.2.7", + "version": "12.11.1", + "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-12.11.1.tgz", + "integrity": "sha512-9VF7mrY+3OmsAfjH3yKz/pLbJ5z22E23hENKw3/LNSaA/sAt3v49bDRY+Ygct1xwuKT+U+cBfTzjCPySna69Qw==", "license": "MIT", "dependencies": { - "@inquirer/external-editor": "^1.0.0", - "ansi-escapes": "^4.2.1", - "chalk": "^4.1.1", - "cli-cursor": "^3.1.0", - "cli-width": "^3.0.0", - "figures": "^3.0.0", - "lodash": "^4.17.21", - "mute-stream": "0.0.8", - "ora": "^5.4.1", - "run-async": "^2.4.0", - "rxjs": "^7.5.5", - "string-width": "^4.1.0", - "strip-ansi": "^6.0.0", - "through": "^2.3.6", - "wrap-ansi": "^6.0.1" + "@inquirer/ansi": "^1.0.2", + "@inquirer/core": "^10.3.2", + "@inquirer/prompts": "^7.10.1", + "@inquirer/type": "^3.0.10", + "mute-stream": "^2.0.0", + "run-async": "^4.0.6", + "rxjs": "^7.8.2" }, "engines": { - "node": ">=12.0.0" + "node": ">=18" + }, + "peerDependencies": { + "@types/node": ">=18" + }, + "peerDependenciesMeta": { + "@types/node": { + "optional": true + } } }, "node_modules/inquirer-search-checkbox": { @@ -8540,15 +8477,93 @@ "node": ">=4" } }, + "node_modules/inquirer/node_modules/@inquirer/core": { + "version": "10.3.2", + "resolved": "https://registry.npmjs.org/@inquirer/core/-/core-10.3.2.tgz", + "integrity": "sha512-43RTuEbfP8MbKzedNqBrlhhNKVwoK//vUFNW3Q3vZ88BLcrs4kYpGg+B2mm5p2K/HfygoCxuKwJJiv8PbGmE0A==", + "license": "MIT", + "dependencies": { + "@inquirer/ansi": "^1.0.2", + "@inquirer/figures": "^1.0.15", + "@inquirer/type": "^3.0.10", + "cli-width": "^4.1.0", + "mute-stream": "^2.0.0", + "signal-exit": "^4.1.0", + "wrap-ansi": "^6.2.0", + "yoctocolors-cjs": "^2.1.3" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "@types/node": ">=18" + }, + "peerDependenciesMeta": { + "@types/node": { + "optional": true + } + } + }, + "node_modules/inquirer/node_modules/@inquirer/type": { + "version": "3.0.10", + "resolved": "https://registry.npmjs.org/@inquirer/type/-/type-3.0.10.tgz", + "integrity": "sha512-BvziSRxfz5Ov8ch0z/n3oijRSEcEsHnhggm4xFZe93DHcUCTlutlq9Ox4SVENAfcRD22UQq7T/atg9Wr3k09eA==", + "license": "MIT", + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "@types/node": ">=18" + }, + "peerDependenciesMeta": { + "@types/node": { + "optional": true + } + } + }, + "node_modules/inquirer/node_modules/cli-width": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/cli-width/-/cli-width-4.1.0.tgz", + "integrity": "sha512-ouuZd4/dm2Sw5Gmqy6bGyNNNe1qt9RpmxveLSO7KcgsTnU7RXfsw+/bukWGo1abgBiMAic068rclZsO4IWmmxQ==", + "license": "ISC", + "engines": { + "node": ">= 12" + } + }, + "node_modules/inquirer/node_modules/run-async": { + "version": "4.0.6", + "resolved": "https://registry.npmjs.org/run-async/-/run-async-4.0.6.tgz", + "integrity": "sha512-IoDlSLTs3Yq593mb3ZoKWKXMNu3UpObxhgA/Xuid5p4bbfi2jdY1Hj0m1K+0/tEuQTxIGMhQDqGjKb7RuxGpAQ==", + "license": "MIT", + "engines": { + "node": ">=0.12.0" + } + }, "node_modules/inquirer/node_modules/rxjs": { "version": "7.8.2", + "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-7.8.2.tgz", + "integrity": "sha512-dhKf903U/PQZY6boNNtAGdWbG85WAbjT/1xYoZIC7FAY0yWapOBQVsVrDl58W86//e1VpMNBtRV4MaXfdMySFA==", "license": "Apache-2.0", "dependencies": { "tslib": "^2.1.0" } }, + "node_modules/inquirer/node_modules/signal-exit": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz", + "integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==", + "license": "ISC", + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, "node_modules/inquirer/node_modules/wrap-ansi": { "version": "6.2.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-6.2.0.tgz", + "integrity": "sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA==", "license": "MIT", "dependencies": { "ansi-styles": "^4.0.0", @@ -8590,6 +8605,8 @@ }, "node_modules/is-arguments": { "version": "1.2.0", + "resolved": "https://registry.npmjs.org/is-arguments/-/is-arguments-1.2.0.tgz", + "integrity": "sha512-7bVbi0huj/wrIAOzb8U1aszg9kdi3KN/CyU19CTI7tAoZYEZoL9yCDXpbXN+uPsuWnP02cyug1gleqq+TU+YCA==", "license": "MIT", "dependencies": { "call-bound": "^1.0.2", @@ -8836,6 +8853,8 @@ }, "node_modules/is-interactive": { "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-interactive/-/is-interactive-1.0.0.tgz", + "integrity": "sha512-2HvIEKRoqS62guEC+qBjpvRubdX910WCMuJTZ+I9yvqKU2/12eSL549HMwtabb4oupdj2sMP50k+XJfB/8JE6w==", "license": "MIT", "engines": { "node": ">=8" @@ -8859,6 +8878,8 @@ }, "node_modules/is-nan": { "version": "1.3.2", + "resolved": "https://registry.npmjs.org/is-nan/-/is-nan-1.3.2.tgz", + "integrity": "sha512-E+zBKpQ2t6MEo1VsonYmluk9NxGrbzpeeLC2xIViuO2EjU2xsXsBPwTr3Ykv9l08UYEVEdWeRZNouaZqF6RN0w==", "license": "MIT", "dependencies": { "call-bind": "^1.0.0", @@ -9020,6 +9041,8 @@ }, "node_modules/is-unicode-supported": { "version": "0.1.0", + "resolved": "https://registry.npmjs.org/is-unicode-supported/-/is-unicode-supported-0.1.0.tgz", + "integrity": "sha512-knxG2q4UC3u8stRGyAVJCOdxFmv5DZiRcdlIaAQXAbSfJya+OhopNotLQrstBhququ4ZpuKbDc/8S6mgXgPFPw==", "license": "MIT", "engines": { "node": ">=10" @@ -10172,6 +10195,8 @@ }, "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==", "license": "MIT", "dependencies": { "chalk": "^4.1.0", @@ -10642,8 +10667,13 @@ "license": "MIT" }, "node_modules/mute-stream": { - "version": "0.0.8", - "license": "ISC" + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-2.0.0.tgz", + "integrity": "sha512-WWdIxpyjEn+FhQJQQv9aQAYlHoNVdzIzUySNV1gHUPDSdZJ3yZn7pAAbQcV7B56Mvu881q9FZV+0Vx2xC44VWA==", + "license": "ISC", + "engines": { + "node": "^18.17.0 || >=20.5.0" + } }, "node_modules/napi-postinstall": { "version": "0.3.4", @@ -10810,6 +10840,8 @@ }, "node_modules/object-is": { "version": "1.1.6", + "resolved": "https://registry.npmjs.org/object-is/-/object-is-1.1.6.tgz", + "integrity": "sha512-F8cZ+KfGlSGi09lJT7/Nd6KJZ9ygtvYC0/UYYLI9nmQKLMnydpB9yvbv9K1uSkEu7FU9vYPmVwLg328tX+ot3Q==", "license": "MIT", "dependencies": { "call-bind": "^1.0.7", @@ -11027,6 +11059,8 @@ }, "node_modules/ora": { "version": "5.4.1", + "resolved": "https://registry.npmjs.org/ora/-/ora-5.4.1.tgz", + "integrity": "sha512-5b6Y85tPxZZ7QytO+BQzysW31HJku27cRIlkbAXaNx+BdcVi+LlRFmVXzeF6a7JCwJpyw5c4b+YSVImQIrBpuQ==", "license": "MIT", "dependencies": { "bl": "^4.1.0", @@ -11048,6 +11082,8 @@ }, "node_modules/otplib": { "version": "12.0.1", + "resolved": "https://registry.npmjs.org/otplib/-/otplib-12.0.1.tgz", + "integrity": "sha512-xDGvUOQjop7RDgxTQ+o4pOol0/3xSZzawTiPKRrHnQWAy0WjhNs/5HdIDJCrqC4MBynmjXgULc6YfioaxZeFgg==", "license": "MIT", "dependencies": { "@otplib/core": "^12.0.1", @@ -11729,27 +11765,35 @@ } }, "node_modules/recheck": { - "version": "4.4.5", + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/recheck/-/recheck-4.5.0.tgz", + "integrity": "sha512-kPnbOV6Zfx9a25AZ++28fI1q78L/UVRQmmuazwVRPfiiqpMs+WbOU69Shx820XgfKWfak0JH75PUvZMFtRGSsw==", "license": "MIT", + "dependencies": { + "synckit": "0.9.2" + }, "engines": { - "node": ">=14" + "node": ">=20" }, "optionalDependencies": { - "recheck-jar": "4.4.5", - "recheck-linux-x64": "4.4.5", - "recheck-macos-x64": "4.4.5", - "recheck-windows-x64": "4.4.5" + "recheck-jar": "4.5.0", + "recheck-linux-x64": "4.5.0", + "recheck-macos-arm64": "4.5.0", + "recheck-macos-x64": "4.5.0", + "recheck-windows-x64": "4.5.0" } }, "node_modules/recheck-jar": { - "version": "4.4.5", + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/recheck-jar/-/recheck-jar-4.5.0.tgz", + "integrity": "sha512-Ad7oCQmY8cQLzd3QVNXjzZ+S6MbImGhR4AaW2yiGzteOfMV45522rt6nSzFyt8p3mCEaMcm/4MoZrMSxUcCbrA==", "license": "MIT", "optional": true }, "node_modules/recheck-linux-x64": { - "version": "4.4.5", - "resolved": "https://registry.npmjs.org/recheck-linux-x64/-/recheck-linux-x64-4.4.5.tgz", - "integrity": "sha512-s8OVPCpiSGw+tLCxH3eei7Zp2AoL22kXqLmEtWXi0AnYNwfuTjZmeLn2aQjW8qhs8ZPSkxS7uRIRTeZqR5Fv/Q==", + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/recheck-linux-x64/-/recheck-linux-x64-4.5.0.tgz", + "integrity": "sha512-52kXsR/v+IbGIKYYFZfSZcgse/Ci9IA2HnuzrtvRRcfODkcUGe4n72ESQ8nOPwrdHFg9i4j9/YyPh1HWWgpJ6A==", "cpu": [ "x64" ], @@ -11759,10 +11803,23 @@ "linux" ] }, + "node_modules/recheck-macos-arm64": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/recheck-macos-arm64/-/recheck-macos-arm64-4.5.0.tgz", + "integrity": "sha512-qIyK3dRuLkORQvv0b59fZZRXweSmjjWaoA4K8Kgifz0anMBH4pqsDV6plBlgjcRmW9yC12wErIRzifREaKnk2w==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ] + }, "node_modules/recheck-macos-x64": { - "version": "4.4.5", - "resolved": "https://registry.npmjs.org/recheck-macos-x64/-/recheck-macos-x64-4.4.5.tgz", - "integrity": "sha512-Ouup9JwwoKCDclt3Na8+/W2pVbt8FRpzjkDuyM32qTR2TOid1NI+P1GA6/VQAKEOjvaxgGjxhcP/WqAjN+EULA==", + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/recheck-macos-x64/-/recheck-macos-x64-4.5.0.tgz", + "integrity": "sha512-1wp/eiLxcjC/Ex4wurlrS/LGzt8IiF4TiK5sEjldu4HVAKdNCnnmsS9a5vFpfcikDz4ZuZlLlTi1VbQTxHlwZg==", "cpu": [ "x64" ], @@ -11773,9 +11830,9 @@ ] }, "node_modules/recheck-windows-x64": { - "version": "4.4.5", - "resolved": "https://registry.npmjs.org/recheck-windows-x64/-/recheck-windows-x64-4.4.5.tgz", - "integrity": "sha512-mkpzLHu9G9Ztjx8HssJh9k/Xm1d1d/4OoT7etHqFk+k1NGzISCRXBD22DqYF9w8+J4QEzTAoDf8icFt0IGhOEQ==", + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/recheck-windows-x64/-/recheck-windows-x64-4.5.0.tgz", + "integrity": "sha512-ekBKwAp0oKkMULn5zgmHEYLwSJfkfb95AbTtbDkQazNkqYw9PRD/mVyFUR6Ff2IeRyZI0gxy+N2AKBISWydhug==", "cpu": [ "x64" ], @@ -11973,6 +12030,8 @@ }, "node_modules/restore-cursor": { "version": "3.1.0", + "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-3.1.0.tgz", + "integrity": "sha512-l+sSefzHpj5qimhFSE5a8nufZYAM3sBSVMAPtYkmC+4EH2anSGaEMXSD0izRQbu9nfyQ9y5JrVmp7E8oZrUjvA==", "license": "MIT", "dependencies": { "onetime": "^5.1.0", @@ -12841,6 +12900,8 @@ }, "node_modules/stream-browserify": { "version": "3.0.0", + "resolved": "https://registry.npmjs.org/stream-browserify/-/stream-browserify-3.0.0.tgz", + "integrity": "sha512-H73RAHsVBapbim0tU2JwwOiXUj+fikfiaoYAKHF3VJfA0pe2BCzkhAHBlLG6REzE+2WNZcxOXjK7lkso+9euLA==", "license": "MIT", "dependencies": { "inherits": "~2.0.4", @@ -13032,6 +13093,22 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/synckit": { + "version": "0.9.2", + "resolved": "https://registry.npmjs.org/synckit/-/synckit-0.9.2.tgz", + "integrity": "sha512-vrozgXDQwYO72vHjUb/HnFbQx1exDjoKzqx23aXEg2a9VIg2TSFZ8FmeZpTjUCFMYw7mpX4BE2SFu8wI7asYsw==", + "license": "MIT", + "dependencies": { + "@pkgr/core": "^0.1.0", + "tslib": "^2.6.2" + }, + "engines": { + "node": "^14.18.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/unts" + } + }, "node_modules/tapable": { "version": "2.3.3", "dev": true, @@ -13074,6 +13151,8 @@ }, "node_modules/thirty-two": { "version": "1.0.2", + "resolved": "https://registry.npmjs.org/thirty-two/-/thirty-two-1.0.2.tgz", + "integrity": "sha512-OEI0IWCe+Dw46019YLl6V10Us5bi574EvlJEOcAkB29IzQ/mYD1A6RyNHLjZPiHCmuodxvgF6U+vZO1L15lxVA==", "engines": { "node": ">=0.2.6" } @@ -13674,6 +13753,8 @@ }, "node_modules/util": { "version": "0.12.5", + "resolved": "https://registry.npmjs.org/util/-/util-0.12.5.tgz", + "integrity": "sha512-kZf/K6hEIrWHI6XqOFUiiMa+79wE/D8Q+NCNAWclkyg3b4d2k7s0QGepNjiABc+aR3N1PAyHL7p6UcLY6LmrnA==", "license": "MIT", "dependencies": { "inherits": "^2.0.3", @@ -14035,7 +14116,6 @@ }, "node_modules/yoctocolors-cjs": { "version": "2.1.3", - "dev": true, "license": "MIT", "engines": { "node": ">=18" diff --git a/package.json b/package.json index a4cc6f31..8b34e068 100644 --- a/package.json +++ b/package.json @@ -20,8 +20,8 @@ "/oclif.manifest.json" ], "dependencies": { - "@contentstack/cli-command": "^1.8.7", - "@contentstack/cli-utilities": "^1.18.5", + "@contentstack/cli-command": "^2.0.2", + "@contentstack/cli-utilities": "^2.0.2", "@oclif/core": "^4.2.7", "@oclif/plugin-help": "^6.2.25", "@rollup/plugin-commonjs": "^28.0.9", diff --git a/src/core/failure.test.ts b/src/core/failure.test.ts index 934ba69a..359abea1 100644 --- a/src/core/failure.test.ts +++ b/src/core/failure.test.ts @@ -72,6 +72,23 @@ describe('reportFailure', () => { await expect(outcome).resolves.toBe(exit); expect(lines).toEqual([]); }); + + it('lets an exit request raised by another copy of oclif pass through untouched, as csdx 2 hands its own to plugins', async () => { + const exit = Object.assign(new Error('EEXIT: 3'), { code: 'EEXIT', oclif: { exit: 3 } }); + const { lines, outcome } = report(exit); + + expect(exit).not.toBeInstanceOf(Errors.ExitError); + await expect(outcome).resolves.toBe(exit); + expect(lines).toEqual([]); + }); + + it('keeps the exit code of an oclif error raised by another copy of oclif', async () => { + const { lines, outcome } = report(Object.assign(new Error('Unexpected argument: extra'), { oclif: { exit: 2 } })); + const thrown = await outcome; + + expect(lines).toEqual(['error: Unexpected argument: extra']); + expect(thrown.oclif.exit).toBe(2); + }); }); describe('handleStandaloneFailure', () => { diff --git a/src/core/failure.ts b/src/core/failure.ts index 375b92d2..0e638beb 100644 --- a/src/core/failure.ts +++ b/src/core/failure.ts @@ -40,12 +40,22 @@ function alreadyReported(err: Error): boolean { return (err as Error & { skipOclifErrorHandling?: boolean }).skipOclifErrorHandling === true; } +// csdx 2 makes plugins use its own @oclif/core through cli-utilities, so errors its Command throws are not +// instances of the Errors class imported here. Recognise them by the shape every oclif error carries. +export function isOclifError(err: unknown): err is Errors.CLIError { + return err instanceof Error && typeof (err as { oclif?: unknown }).oclif === 'object'; +} + +function isExitRequest(err: Error): boolean { + return isOclifError(err) && (err as { code?: unknown }).code === 'EEXIT'; +} + export async function reportFailure(err: Error, output: FailureOutput): Promise { - if (err instanceof Errors.ExitError || alreadyReported(err)) { + if (isExitRequest(err) || alreadyReported(err)) { throw err; } - if (err instanceof Errors.CLIError) { + if (isOclifError(err)) { return failWith(err.message, err.oclif.exit, output); } diff --git a/src/core/launch-command.test.ts b/src/core/launch-command.test.ts index 17c19ac7..3705dfca 100644 --- a/src/core/launch-command.test.ts +++ b/src/core/launch-command.test.ts @@ -16,7 +16,7 @@ import type { FlagKey } from '../resources'; import { LaunchCommand, projectConfigLoader, resolveLaunchContext } from './launch-command'; import * as serviceContext from './service-context'; import type { SearchListClass } from './search-list'; -import { utilitiesLoader } from './search-list'; +import { promptLibrary, utilitiesLoader } from './search-list'; import { pretendTerminal, stdinReportingTTY, stdoutReportingTTY } from '../../test/support/terminal'; class Probe extends LaunchCommand { @@ -336,8 +336,7 @@ describe('LaunchCommand.init', () => { }); it('registers the searchable picker on the inquirer cliux prompts with before anything can prompt', async () => { - const load = utilitiesLoader(); - const prompts = (load('inquirer') as { prompt: { prompts: Record } }).prompt.prompts; + const prompts = promptLibrary().prompt.prompts; delete prompts['search-list']; const instance = probe(); const authSpy = jest.spyOn(authHandler, 'isAuthenticated').mockReturnValue(true); @@ -352,7 +351,7 @@ describe('LaunchCommand.init', () => { await instance.init(); expect((registeredWhenParsed as SearchListClass).prototype).toBeInstanceOf( - load('inquirer-search-list') as SearchListClass, + utilitiesLoader()('inquirer-search-list') as SearchListClass, ); expect(prompts['search-list']).toBe(registeredWhenParsed); authSpy.mockRestore(); diff --git a/src/core/search-list.test.ts b/src/core/search-list.test.ts index e0f5d818..daf8a7f5 100644 --- a/src/core/search-list.test.ts +++ b/src/core/search-list.test.ts @@ -4,8 +4,8 @@ import { MORE_CHOICES_HINT, UnlistedAnswer, answerFor, - launchPaginated, launchSearchList, + promptLibrary, refuseUnlisted, registerSearchList, pageScroller, @@ -265,33 +265,6 @@ describe('pageScroller', () => { }); }); -describe('launchPaginated', () => { - interface Paginated { - paginator: { paginate(output: string, active: number, pageSize?: number): string }; - } - - class Upstream { - paginator = { paginate: (output: string) => output }; - } - - it('pages with its own scroller, which keeps the arrow moving and says how to see more', () => { - const Prompt = launchPaginated(Upstream as never) as unknown as new () => Paginated; - const prompt = new Prompt(); - const lines = Array.from({ length: 10 }, (_, index) => `c${index}`).join('\n'); - - expect(prompt.paginator.paginate(lines, 3, 7).split('\n')).toEqual([ - 'c0', 'c1', 'c2', 'c3', 'c4', 'c5', 'c6', `\u001b[2m${MORE_CHOICES_HINT}\u001b[22m`, - ]); - expect(MORE_CHOICES_HINT).toBe('(Use ↑/↓ to see more options)'); - }); - - it('gives each prompt a scroller of its own', () => { - const Prompt = launchPaginated(Upstream as never) as unknown as new () => Paginated; - - expect(new Prompt().paginator).not.toBe(new Prompt().paginator); - }); -}); - describe('answerFor', () => { it('answers with the value of the choice whose name was typed in full', () => { expect(answerFor(CHOICES, 'NextJs')).toBe('NextJs'); @@ -343,35 +316,43 @@ describe('refuseUnlisted', () => { }); }); +describe('promptLibrary', () => { + it('is the default export of the inquirer cli-utilities depends on, where inquirer 12 keeps its registry', () => { + const library = promptLibrary(); + + expect(library).toBe((load('inquirer') as { default: unknown }).default); + expect(typeof library.registerPrompt).toBe('function'); + expect(Object.keys(library.prompt.prompts)).toEqual(expect.arrayContaining(['list', 'checkbox', 'confirm', 'input'])); + }); +}); + describe('registerSearchList', () => { - it('registers the launch search list under search-list on the inquirer that cliux prompts with', () => { + it('registers the launch search list under search-list on the inquirer that cliux prompts with, and nothing else', () => { const registered: [string, unknown][] = []; const loaded: string[] = []; const fakeLoad = (id: string): unknown => { loaded.push(id); - return id === 'inquirer' ? { registerPrompt: (name: string, prompt: unknown) => registered.push([name, prompt]) } : SearchList; + return id === 'inquirer' + ? { default: { registerPrompt: (name: string, prompt: unknown) => registered.push([name, prompt]) } } + : SearchList; }; registerSearchList(fakeLoad); - expect(loaded).toEqual(['inquirer', 'inquirer-search-list', 'inquirer/lib/prompts/list', 'inquirer/lib/prompts/checkbox']); - expect(registered.map(([name]) => name)).toEqual(['search-list', 'list', 'checkbox']); - expect(registered[0][0]).toBe('search-list'); + expect(loaded).toEqual(['inquirer', 'inquirer-search-list']); + expect(registered.map(([name]) => name)).toEqual(['search-list']); expect((registered[0][1] as SearchListClass).prototype).toBeInstanceOf(SearchList); expect(registered[0][1]).not.toBe(SearchList); }); - it('registers on the real inquirer cli-utilities depends on when no loader is given', () => { - const inquirer = load('inquirer') as { prompt: { prompts: Record } }; + it('registers on the real inquirer cli-utilities depends on when no loader is given, leaving its list and checkbox as they are', () => { + const library = promptLibrary(); + const { list, checkbox } = library.prompt.prompts; registerSearchList(); - expect((inquirer.prompt.prompts['search-list'] as SearchListClass).prototype).toBeInstanceOf(SearchList); - for (const type of ['list', 'checkbox']) { - const Upstream = load(`inquirer/lib/prompts/${type}`) as SearchListClass; - - expect((inquirer.prompt.prompts[type] as SearchListClass).prototype).toBeInstanceOf(Upstream); - expect(inquirer.prompt.prompts[type]).not.toBe(Upstream); - } + expect((library.prompt.prompts['search-list'] as SearchListClass).prototype).toBeInstanceOf(SearchList); + expect(library.prompt.prompts.list).toBe(list); + expect(library.prompt.prompts.checkbox).toBe(checkbox); }); }); diff --git a/src/core/search-list.ts b/src/core/search-list.ts index b9b6d93d..b688150b 100644 --- a/src/core/search-list.ts +++ b/src/core/search-list.ts @@ -25,8 +25,10 @@ export type SearchListClass = new (...params: never[]) => SearchListPrompt; export type ModuleLoader = (id: string) => unknown; -interface PromptRegistry { +export interface PromptRegistry { + prompt: { prompts: Record }; registerPrompt(name: string, prompt: unknown): void; + restoreDefaultPrompts(): void; } export class UnlistedAnswer { @@ -62,8 +64,6 @@ interface Paginator { paginate(output: string, active: number, pageSize?: number): string; } -export type PaginatedClass = new (...params: never[]) => { paginator: Paginator }; - export function pageScroller(): Paginator { let top = 0; @@ -88,15 +88,6 @@ export function pageScroller(): Paginator { }; } -export function launchPaginated(Prompt: PaginatedClass): PaginatedClass { - return class LaunchPaginated extends Prompt { - constructor(...params: never[]) { - super(...params); - this.paginator = pageScroller(); - } - }; -} - export function launchSearchList(SearchList: SearchListClass): SearchListClass { return class LaunchSearchList extends SearchList { constructor(...params: never[]) { @@ -153,12 +144,11 @@ export function utilitiesLoader(): ModuleLoader { return createRequire(require.resolve('@contentstack/cli-utilities')); } -export function registerSearchList(load: ModuleLoader = utilitiesLoader()): void { - const inquirer = load('inquirer') as PromptRegistry; - - inquirer.registerPrompt('search-list', launchSearchList(load('inquirer-search-list') as SearchListClass)); +// cli-utilities 2 ships inquirer 12, which exposes the prompt registry cliux prompts with as its default export. +export function promptLibrary(load: ModuleLoader = utilitiesLoader()): PromptRegistry { + return (load('inquirer') as { default: PromptRegistry }).default; +} - for (const type of ['list', 'checkbox']) { - inquirer.registerPrompt(type, launchPaginated(load(`inquirer/lib/prompts/${type}`) as PaginatedClass)); - } +export function registerSearchList(load: ModuleLoader = utilitiesLoader()): void { + promptLibrary(load).registerPrompt('search-list', launchSearchList(load('inquirer-search-list') as SearchListClass)); } diff --git a/src/secrets/secret.rules.test.ts b/src/secrets/secret.rules.test.ts index bc0f3257..8e111463 100644 --- a/src/secrets/secret.rules.test.ts +++ b/src/secrets/secret.rules.test.ts @@ -130,6 +130,17 @@ describe('asSafeArgvFailure', () => { expect(asSafeArgvFailure('text')).toBe('text'); }); + it('replaces a parse error raised by another copy of oclif, as csdx 2 hands its own to plugins', () => { + const raw = Object.assign(new Error(`Unexpected argument: ${secret}`), { oclif: { exit: 2 }, parse: {} }); + + const safe = asSafeArgvFailure(raw) as UsageError; + + expect(raw).not.toBeInstanceOf(Errors.CLIError); + expect(safe).toBeInstanceOf(UsageError); + expect(safe.message).toBe(INVALID_ARGUMENTS_MESSAGE); + expect(safe.message).not.toContain(secret); + }); + it('words the replacement with the message it is given, never an argv token', async () => { const raw = await realParseFailure([`--value=${secret}`]); diff --git a/src/secrets/secret.rules.ts b/src/secrets/secret.rules.ts index fbae7892..0d8ae347 100644 --- a/src/secrets/secret.rules.ts +++ b/src/secrets/secret.rules.ts @@ -1,6 +1,5 @@ -import { Errors } from '@oclif/core'; - import { UsageError } from '../core/errors'; +import { isOclifError } from '../core/failure'; export const CLIENT_EXPOSED_PREFIXES = ['NEXT_PUBLIC_', 'NUXT_PUBLIC_', 'VITE_', 'GATSBY_', 'PUBLIC_'] as const; @@ -50,7 +49,7 @@ export function singleKeyError(count: number): UsageError { } export function asSafeArgvFailure(error: unknown, message: string = INVALID_ARGUMENTS_MESSAGE): unknown { - const isParseFailure = error instanceof Errors.CLIError && Object.prototype.hasOwnProperty.call(error, 'parse'); + const isParseFailure = isOclifError(error) && Object.prototype.hasOwnProperty.call(error, 'parse'); return isParseFailure ? new UsageError(message) : error; } diff --git a/test/guards/prompt-types.test.ts b/test/guards/prompt-types.test.ts index f3017640..2a2c1a08 100644 --- a/test/guards/prompt-types.test.ts +++ b/test/guards/prompt-types.test.ts @@ -1,15 +1,10 @@ import { authHandler } from '@contentstack/cli-utilities'; import { LaunchCommand } from '../../src/core/launch-command'; -import { utilitiesLoader } from '../../src/core/search-list'; +import { promptLibrary } from '../../src/core/search-list'; import type { SourceFile } from '../support/sources'; import { balancedCall, productionSources } from '../support/sources'; -interface PromptRegistry { - prompt: { prompts: Record }; - restoreDefaultPrompts(): void; -} - interface PromptCall { site: string; type: string | undefined; @@ -43,30 +38,22 @@ function promptCallsInSrc(): PromptCall[] { } async function registeredAfterAFreshLaunchCommandInit(): Promise { - const registry = utilitiesLoader()('inquirer') as PromptRegistry; - const prompts = registry.prompt.prompts; - const saved = { ...prompts }; + const registry = promptLibrary(); + const original = registry.prompt.prompts; const instance = new FreshCommand([], {} as never); jest.spyOn(authHandler, 'isAuthenticated').mockReturnValue(true); Object.defineProperty(instance, 'launchRegion', { value: { launchHubUrl: 'https://launch-api.test' } }); Object.defineProperty(instance, 'config', { value: { userAgent: 'cli/2.0.0' } }); (instance as unknown as { parse: () => Promise }).parse = async () => ({ flags: {} }); - for (const name of Object.keys(prompts)) { - delete prompts[name]; - } - + // inquirer 12 swaps in a fresh registry object rather than resetting the one it had. registry.restoreDefaultPrompts(); try { await instance.init(); - return Object.keys(prompts); + return Object.keys(registry.prompt.prompts); } finally { - for (const name of Object.keys(prompts)) { - delete prompts[name]; - } - - Object.assign(prompts, saved); + registry.prompt.prompts = original; } } @@ -101,7 +88,7 @@ describe('guard: every prompt type the CLI asks for is registered with the real }); it('starts the registration check from inquirer defaults, so a registration left behind by another test cannot satisfy it', async () => { - const registry = utilitiesLoader()('inquirer') as PromptRegistry; + const registry = promptLibrary(); const before = Object.keys(registry.prompt.prompts); const registered = await registeredAfterAFreshLaunchCommandInit();