From 893906b627e98ff1b6001576a9bee7184877566c Mon Sep 17 00:00:00 2001 From: Vikram Kalta Date: Mon, 1 Jul 2024 22:20:05 +0100 Subject: [PATCH 01/22] fix: fixed missing plugin id in ct schema --- packages/contentstack-import/src/utils/extension-helper.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/contentstack-import/src/utils/extension-helper.ts b/packages/contentstack-import/src/utils/extension-helper.ts index 073fcc1551..fd5ca01f92 100644 --- a/packages/contentstack-import/src/utils/extension-helper.ts +++ b/packages/contentstack-import/src/utils/extension-helper.ts @@ -21,6 +21,7 @@ export const lookupExtension = function ( const fs = new FsUtility({ basePath: config.backupDir }); const extensionPath = join(config.backupDir, 'mapper/extensions', 'uid-mapping.json'); const globalfieldsPath = join(config.backupDir, 'mapper/globalfields', 'uid-mapping.json'); + const marketPlaceAppsPath = join(config.backupDir, 'mapper/marketplace_apps', 'uid-mapping.json'); for (let i in schema) { if (schema[i].data_type === 'group') { @@ -72,9 +73,12 @@ export const lookupExtension = function ( } else if (schema[i].data_type === 'json' && schema[i].hasOwnProperty('plugins') && schema[i].plugins.length > 0) { const newPluginUidsArray: any[] = []; const data = fs.readFile(extensionPath) as Record; + const marketPlaceAppsData = fs.readFile(marketPlaceAppsPath) as { extension_uid: Record }; schema[i].plugins.forEach((extension_key_value: string) => { if (data && data.hasOwnProperty(extension_key_value)) { newPluginUidsArray.push(data[extension_key_value]); + } else if (marketPlaceAppsData && marketPlaceAppsData.extension_uid && marketPlaceAppsData.extension_uid.hasOwnProperty(extension_key_value)) { + newPluginUidsArray.push(marketPlaceAppsData.extension_uid[extension_key_value]); } }); schema[i].plugins = newPluginUidsArray; From b1ecffad0ab0fd58052ba34defaf6b18ace88758 Mon Sep 17 00:00:00 2001 From: Aman Kumar Date: Tue, 2 Jul 2024 18:26:18 +0530 Subject: [PATCH 02/22] updated the config file to support other frameworks --- package-lock.json | 4 ++-- packages/contentstack-launch/README.md | 2 +- packages/contentstack-launch/package.json | 2 +- packages/contentstack-launch/src/config/index.ts | 12 ++++++++++-- packages/contentstack/package.json | 2 +- pnpm-lock.yaml | 2 +- 6 files changed, 16 insertions(+), 8 deletions(-) diff --git a/package-lock.json b/package-lock.json index f6f337e759..b2e0fa1573 100644 --- a/package-lock.json +++ b/package-lock.json @@ -24905,7 +24905,7 @@ "@contentstack/cli-cm-seed": "~1.7.6", "@contentstack/cli-command": "~1.2.18", "@contentstack/cli-config": "~1.6.4", - "@contentstack/cli-launch": "~1.0.18", + "@contentstack/cli-launch": "~1.0.19", "@contentstack/cli-migration": "~1.5.6", "@contentstack/cli-utilities": "~1.6.3", "@contentstack/management": "~1.15.3", @@ -26646,7 +26646,7 @@ }, "packages/contentstack-launch": { "name": "@contentstack/cli-launch", - "version": "1.0.18", + "version": "1.0.19", "license": "MIT", "dependencies": { "@apollo/client": "^3.7.9", diff --git a/packages/contentstack-launch/README.md b/packages/contentstack-launch/README.md index 0f8a34c107..cd0766f6b5 100755 --- a/packages/contentstack-launch/README.md +++ b/packages/contentstack-launch/README.md @@ -19,7 +19,7 @@ $ npm install -g @contentstack/cli-launch $ csdx COMMAND running command... $ csdx (--version|-v) -@contentstack/cli-launch/1.0.18 darwin-arm64 node-v22.2.0 +@contentstack/cli-launch/1.0.19 darwin-arm64 node-v18.20.2 $ csdx --help [COMMAND] USAGE $ csdx COMMAND diff --git a/packages/contentstack-launch/package.json b/packages/contentstack-launch/package.json index 470b6976ef..dead3d4eb9 100755 --- a/packages/contentstack-launch/package.json +++ b/packages/contentstack-launch/package.json @@ -1,6 +1,6 @@ { "name": "@contentstack/cli-launch", - "version": "1.0.18", + "version": "1.0.19", "description": "Launch related operations", "author": "Contentstack CLI", "bin": { diff --git a/packages/contentstack-launch/src/config/index.ts b/packages/contentstack-launch/src/config/index.ts index 578444da76..86f2ad2672 100755 --- a/packages/contentstack-launch/src/config/index.ts +++ b/packages/contentstack-launch/src/config/index.ts @@ -9,13 +9,21 @@ const config = { }, outputDirectories: { OTHER: './', - NEXTJS: './.next', GATSBY: './public', + NEXTJS: './.next', + CRA: './build', + CSR: './', + ANGULAR: './dist', + VUEJS: './dist', }, listOfFrameWorks: [ + { name: 'Other', value: 'OTHER' }, { name: 'Gatsby', value: 'GATSBY' }, { name: 'NextJs', value: 'NEXTJS' }, - { name: 'Other', value: 'OTHER' }, + { name: 'CRA (Create React App)', value: 'CRA' }, + { name: 'CSR (Client-Side Rendered)', value: 'CSR' }, + { name: 'Angular', value: 'ANGULAR' }, + { name: 'VueJs', value: 'VUEJS' }, ], providerMapper: { GITPROVIDER: 'GitHub', diff --git a/packages/contentstack/package.json b/packages/contentstack/package.json index b583ed6e4b..26fd8809c8 100755 --- a/packages/contentstack/package.json +++ b/packages/contentstack/package.json @@ -35,7 +35,7 @@ "@contentstack/cli-cm-seed": "~1.7.6", "@contentstack/cli-command": "~1.2.18", "@contentstack/cli-config": "~1.6.4", - "@contentstack/cli-launch": "~1.0.18", + "@contentstack/cli-launch": "~1.0.19", "@contentstack/cli-migration": "~1.5.6", "@contentstack/cli-utilities": "~1.6.3", "@contentstack/management": "~1.15.3", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 9e28e5d963..350e106753 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -23,7 +23,7 @@ importers: '@contentstack/cli-cm-seed': ~1.7.6 '@contentstack/cli-command': ~1.2.18 '@contentstack/cli-config': ~1.6.4 - '@contentstack/cli-launch': ~1.0.18 + '@contentstack/cli-launch': ~1.0.19 '@contentstack/cli-migration': ~1.5.6 '@contentstack/cli-utilities': ~1.6.3 '@contentstack/management': ~1.15.3 From 9653a5143c9310b991eb4485789b5110697f083f Mon Sep 17 00:00:00 2001 From: raj pandey Date: Wed, 3 Jul 2024 11:57:46 +0530 Subject: [PATCH 03/22] Added the missing modules handle function, upgraded uuid and version bump --- package-lock.json | 326 ++++++++++-------- packages/contentstack-import/package.json | 2 +- .../contentstack-migrate-rte/package.json | 4 +- packages/contentstack-migration/README.md | 2 +- packages/contentstack-migration/package.json | 4 +- .../src/commands/cm/stacks/migration.js | 8 +- .../contentstack-migration/src/utils/index.js | 1 + .../src/utils/modules.js | 172 +++++++++ packages/contentstack-utilities/package.json | 2 +- packages/contentstack/README.md | 16 +- packages/contentstack/package.json | 6 +- pnpm-lock.yaml | 10 +- 12 files changed, 389 insertions(+), 164 deletions(-) create mode 100644 packages/contentstack-migration/src/utils/modules.js diff --git a/package-lock.json b/package-lock.json index f6f337e759..718a10e3ef 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2256,9 +2256,9 @@ } }, "node_modules/@oclif/plugin-plugins/node_modules/@oclif/core": { - "version": "4.0.7", - "resolved": "https://registry.npmjs.org/@oclif/core/-/core-4.0.7.tgz", - "integrity": "sha512-sU4Dx+RXCWAkrMw8tQFYAL6VfcHYKLPxVC9iKfgTXr4aDhcCssDwrbgpx0Di1dnNxvQlDGUhuCEInZuIY/nNfw==", + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/@oclif/core/-/core-4.0.8.tgz", + "integrity": "sha512-9AzNoRlKfIeuqOin+HK9cyouELeup7sX+MGIFc5dR+bnG0sSzFnV1A/Z57E7KWrY5NdWULHYT5NhiL1YpEhG2w==", "dependencies": { "ansi-escapes": "^4.3.2", "ansis": "^3.1.1", @@ -2271,7 +2271,7 @@ "indent-string": "^4.0.0", "is-wsl": "^2.2.0", "lilconfig": "^3.1.2", - "minimatch": "^9.0.4", + "minimatch": "^9.0.5", "string-width": "^4.2.3", "supports-color": "^8", "widest-line": "^3.1.0", @@ -4610,9 +4610,9 @@ } }, "node_modules/aws-sdk": { - "version": "2.1651.0", - "resolved": "https://registry.npmjs.org/aws-sdk/-/aws-sdk-2.1651.0.tgz", - "integrity": "sha512-MZjQvvOPkKcx1N428ejUjqSfhm4TAIcgPIgpniiDMw1LjB1yA8JBZvrWer6J6MACAXQ99v0uKE4BSvtYn+AT3g==", + "version": "2.1653.0", + "resolved": "https://registry.npmjs.org/aws-sdk/-/aws-sdk-2.1653.0.tgz", + "integrity": "sha512-9f42kuLpMcL1EPZOsLM8u6wlnOMtFwED1b24SN0fBbi/N7N1xTLZ7vbEMt/haz06Lc3Vr3VMDyv0atfMmkboBw==", "dev": true, "hasInstallScript": true, "dependencies": { @@ -5357,9 +5357,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001639", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001639.tgz", - "integrity": "sha512-eFHflNTBIlFwP2AIKaYuBQN/apnUoKNhBdza8ZnW/h2di4LCZ4xFqYlxUxo+LQ76KFI1PGcC1QDxMbxTZpSCAg==", + "version": "1.0.30001640", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001640.tgz", + "integrity": "sha512-lA4VMpW0PSUrFnkmVuEKBUovSWKhj7puyCg8StBChgu298N1AtuF1sKWEvfDuimSEDbhlb/KqPKC3fs1HbuQUA==", "dev": true, "funding": [ { @@ -6910,9 +6910,9 @@ } }, "node_modules/electron-to-chromium": { - "version": "1.4.815", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.815.tgz", - "integrity": "sha512-OvpTT2ItpOXJL7IGcYakRjHCt8L5GrrN/wHCQsRB4PQa1X9fe+X9oen245mIId7s14xvArCGSTIq644yPUKKLg==", + "version": "1.4.816", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.816.tgz", + "integrity": "sha512-EKH5X5oqC6hLmiS7/vYtZHZFTNdhsYG5NVPRN6Yn0kQHNBlT59+xSM8HBy66P5fxWpKgZbPqb+diC64ng295Jw==", "dev": true }, "node_modules/elegant-spinner": { @@ -8065,13 +8065,13 @@ } }, "node_modules/eslint-plugin-perfectionist/node_modules/@typescript-eslint/scope-manager": { - "version": "7.14.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-7.14.1.tgz", - "integrity": "sha512-gPrFSsoYcsffYXTOZ+hT7fyJr95rdVe4kGVX1ps/dJ+DfmlnjFN/GcMxXcVkeHDKqsq6uAcVaQaIi3cFffmAbA==", + "version": "7.15.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-7.15.0.tgz", + "integrity": "sha512-Q/1yrF/XbxOTvttNVPihxh1b9fxamjEoz2Os/Pe38OHwxC24CyCqXxGTOdpb4lt6HYtqw9HetA/Rf6gDGaMPlw==", "dev": true, "dependencies": { - "@typescript-eslint/types": "7.14.1", - "@typescript-eslint/visitor-keys": "7.14.1" + "@typescript-eslint/types": "7.15.0", + "@typescript-eslint/visitor-keys": "7.15.0" }, "engines": { "node": "^18.18.0 || >=20.0.0" @@ -8082,9 +8082,9 @@ } }, "node_modules/eslint-plugin-perfectionist/node_modules/@typescript-eslint/types": { - "version": "7.14.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-7.14.1.tgz", - "integrity": "sha512-mL7zNEOQybo5R3AavY+Am7KLv8BorIv7HCYS5rKoNZKQD9tsfGUpO4KdAn3sSUvTiS4PQkr2+K0KJbxj8H9NDg==", + "version": "7.15.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-7.15.0.tgz", + "integrity": "sha512-aV1+B1+ySXbQH0pLK0rx66I3IkiZNidYobyfn0WFsdGhSXw+P3YOqeTq5GED458SfB24tg+ux3S+9g118hjlTw==", "dev": true, "engines": { "node": "^18.18.0 || >=20.0.0" @@ -8095,13 +8095,13 @@ } }, "node_modules/eslint-plugin-perfectionist/node_modules/@typescript-eslint/typescript-estree": { - "version": "7.14.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-7.14.1.tgz", - "integrity": "sha512-k5d0VuxViE2ulIO6FbxxSZaxqDVUyMbXcidC8rHvii0I56XZPv8cq+EhMns+d/EVIL41sMXqRbK3D10Oza1bbA==", + "version": "7.15.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-7.15.0.tgz", + "integrity": "sha512-gjyB/rHAopL/XxfmYThQbXbzRMGhZzGw6KpcMbfe8Q3nNQKStpxnUKeXb0KiN/fFDR42Z43szs6rY7eHk0zdGQ==", "dev": true, "dependencies": { - "@typescript-eslint/types": "7.14.1", - "@typescript-eslint/visitor-keys": "7.14.1", + "@typescript-eslint/types": "7.15.0", + "@typescript-eslint/visitor-keys": "7.15.0", "debug": "^4.3.4", "globby": "^11.1.0", "is-glob": "^4.0.3", @@ -8123,15 +8123,15 @@ } }, "node_modules/eslint-plugin-perfectionist/node_modules/@typescript-eslint/utils": { - "version": "7.14.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-7.14.1.tgz", - "integrity": "sha512-CMmVVELns3nak3cpJhZosDkm63n+DwBlDX8g0k4QUa9BMnF+lH2lr3d130M1Zt1xxmB3LLk3NV7KQCq86ZBBhQ==", + "version": "7.15.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-7.15.0.tgz", + "integrity": "sha512-hfDMDqaqOqsUVGiEPSMLR/AjTSCsmJwjpKkYQRo1FNbmW4tBwBspYDwO9eh7sKSTwMQgBw9/T4DHudPaqshRWA==", "dev": true, "dependencies": { "@eslint-community/eslint-utils": "^4.4.0", - "@typescript-eslint/scope-manager": "7.14.1", - "@typescript-eslint/types": "7.14.1", - "@typescript-eslint/typescript-estree": "7.14.1" + "@typescript-eslint/scope-manager": "7.15.0", + "@typescript-eslint/types": "7.15.0", + "@typescript-eslint/typescript-estree": "7.15.0" }, "engines": { "node": "^18.18.0 || >=20.0.0" @@ -8145,12 +8145,12 @@ } }, "node_modules/eslint-plugin-perfectionist/node_modules/@typescript-eslint/visitor-keys": { - "version": "7.14.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-7.14.1.tgz", - "integrity": "sha512-Crb+F75U1JAEtBeQGxSKwI60hZmmzaqA3z9sYsVm8X7W5cwLEm5bRe0/uXS6+MR/y8CVpKSR/ontIAIEPFcEkA==", + "version": "7.15.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-7.15.0.tgz", + "integrity": "sha512-Hqgy/ETgpt2L5xueA/zHHIl4fJI2O4XUE9l4+OIfbJIRSnTJb/QscncdqqZzofQegIJugRIF57OJea1khw2SDw==", "dev": true, "dependencies": { - "@typescript-eslint/types": "7.14.1", + "@typescript-eslint/types": "7.15.0", "eslint-visitor-keys": "^3.4.3" }, "engines": { @@ -15143,6 +15143,13 @@ "which", "write-file-atomic" ], + "workspaces": [ + "docs", + "smoke-tests", + "mock-globals", + "mock-registry", + "workspaces/*" + ], "dependencies": { "@isaacs/string-locale-compare": "^1.1.0", "@npmcli/arborist": "^7.5.3", @@ -19711,9 +19718,9 @@ ] }, "node_modules/qs": { - "version": "6.12.1", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.12.1.tgz", - "integrity": "sha512-zWmv4RSuB9r2mYQw3zxQuHWeU+42aKi1wWig/j4ele4ygELZ7PEO6MM7rim9oAQH2A5MWfsAVf/jPvTPgCbvUQ==", + "version": "6.12.2", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.12.2.tgz", + "integrity": "sha512-x+NLUpx9SYrcwXtX7ob1gnkSems4i/mGZX5SlYxwIau6RrUSODO89TR/XDGGpn5RPWSYIB+aSfuSlV5+CmbTBg==", "dependencies": { "side-channel": "^1.0.6" }, @@ -23014,9 +23021,9 @@ } }, "node_modules/update-browserslist-db": { - "version": "1.0.16", - "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.0.16.tgz", - "integrity": "sha512-KVbTxlBYlckhF5wgfyZXTWnMn7MMZjMu9XG8bPlliUOP9ThaF4QnhP8qrjrH7DRzHfSk0oQv1wToW+iA5GajEQ==", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.1.0.tgz", + "integrity": "sha512-EdRAaAyk2cUE1wOf2DkEhzxqOQvFOoRJFNS6NeyJ01Gp2beMRpBAINjM2iDXE3KCuKhwnvHIQCJm6ThL2Z+HzQ==", "dev": true, "funding": [ { @@ -24889,7 +24896,7 @@ }, "packages/contentstack": { "name": "@contentstack/cli", - "version": "1.20.0", + "version": "1.21.0", "license": "MIT", "dependencies": { "@contentstack/cli-audit": "~1.6.3", @@ -24906,7 +24913,7 @@ "@contentstack/cli-command": "~1.2.18", "@contentstack/cli-config": "~1.6.4", "@contentstack/cli-launch": "~1.0.18", - "@contentstack/cli-migration": "~1.5.6", + "@contentstack/cli-migration": "~1.6.0", "@contentstack/cli-utilities": "~1.6.3", "@contentstack/management": "~1.15.3", "@oclif/core": "^3.26.5", @@ -24920,7 +24927,7 @@ "node-machine-id": "^1.1.12", "open": "^8.4.2", "short-uuid": "^4.2.2", - "uuid": "^9.0.0", + "uuid": "^9.0.1", "winston": "^3.7.2" }, "bin": { @@ -25024,6 +25031,15 @@ "undici-types": "~5.26.4" } }, + "packages/contentstack-audit/node_modules/ansi-colors": { + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.3.tgz", + "integrity": "sha512-/6w/C21Pm1A7aZitlI5Ni/2J6FFQN8i1Cvz3kHABAAbw93v/NlvKdVOqz7CCWz/3iv/JplRSEEZ83XION15ovw==", + "dev": true, + "engines": { + "node": ">=6" + } + }, "packages/contentstack-audit/node_modules/argparse": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", @@ -25041,21 +25057,13 @@ "wrap-ansi": "^7.0.0" } }, - "packages/contentstack-audit/node_modules/debug": { - "version": "4.3.4", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", - "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "packages/contentstack-audit/node_modules/diff": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/diff/-/diff-5.2.0.tgz", + "integrity": "sha512-uIFDxqpRZGZ6ThOk84hEfqWoHx2devRFvpTZcTHur85vImfaxUbTW9Ryh4CpCuDnToOP1CEtXKIgytHBPVff5A==", "dev": true, - "dependencies": { - "ms": "2.1.2" - }, "engines": { - "node": ">=6.0" - }, - "peerDependenciesMeta": { - "supports-color": { - "optional": true - } + "node": ">=0.3.1" } }, "packages/contentstack-audit/node_modules/glob": { @@ -25107,9 +25115,9 @@ } }, "packages/contentstack-audit/node_modules/minimatch": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.0.1.tgz", - "integrity": "sha512-nLDxIFRyhDblz3qMuq+SoRZED4+miJ/G+tdDrjkkkRnjAsBexeGpgjLEQ0blJy7rHhR2b93rhQY4SvyWu9v03g==", + "version": "5.1.6", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.6.tgz", + "integrity": "sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g==", "dev": true, "dependencies": { "brace-expansion": "^2.0.1" @@ -25119,31 +25127,31 @@ } }, "packages/contentstack-audit/node_modules/mocha": { - "version": "10.5.2", - "resolved": "https://registry.npmjs.org/mocha/-/mocha-10.5.2.tgz", - "integrity": "sha512-9btlN3JKCefPf+vKd/kcKz2SXxi12z6JswkGfaAF0saQvnsqLJk504ZmbxhSoENge08E9dsymozKgFMTl5PQsA==", + "version": "10.6.0", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-10.6.0.tgz", + "integrity": "sha512-hxjt4+EEB0SA0ZDygSS015t65lJw/I2yRCS3Ae+SJ5FrbzrXgfYwJr96f0OvIXdj7h4lv/vLCrH3rkiuizFSvw==", "dev": true, "dependencies": { - "ansi-colors": "4.1.1", - "browser-stdout": "1.3.1", + "ansi-colors": "^4.1.3", + "browser-stdout": "^1.3.1", "chokidar": "^3.5.3", - "debug": "4.3.4", - "diff": "5.0.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.0.1", - "ms": "2.1.3", - "serialize-javascript": "6.0.0", - "strip-json-comments": "3.1.1", - "supports-color": "8.1.1", - "workerpool": "6.2.1", - "yargs": "16.2.0", - "yargs-parser": "20.2.4", - "yargs-unparser": "2.0.0" + "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", @@ -25153,12 +25161,21 @@ "node": ">= 14.0.0" } }, - "packages/contentstack-audit/node_modules/mocha/node_modules/ms": { + "packages/contentstack-audit/node_modules/ms": { "version": "2.1.3", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", "dev": true }, + "packages/contentstack-audit/node_modules/serialize-javascript": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-6.0.2.tgz", + "integrity": "sha512-Saa1xPByTTq2gdeFZYLLo+RFE35NHZkAbqZeWNd3BpzppeVisAqpDjcp8dyf6uIvEqJRd46jemmyA4iFIeVk8g==", + "dev": true, + "dependencies": { + "randombytes": "^2.1.0" + } + }, "packages/contentstack-audit/node_modules/sinon": { "version": "17.0.1", "resolved": "https://registry.npmjs.org/sinon/-/sinon-17.0.1.tgz", @@ -25177,15 +25194,6 @@ "url": "https://opencollective.com/sinon" } }, - "packages/contentstack-audit/node_modules/sinon/node_modules/diff": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/diff/-/diff-5.2.0.tgz", - "integrity": "sha512-uIFDxqpRZGZ6ThOk84hEfqWoHx2devRFvpTZcTHur85vImfaxUbTW9Ryh4CpCuDnToOP1CEtXKIgytHBPVff5A==", - "dev": true, - "engines": { - "node": ">=0.3.1" - } - }, "packages/contentstack-audit/node_modules/sinon/node_modules/supports-color": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", @@ -25199,9 +25207,9 @@ } }, "packages/contentstack-audit/node_modules/typescript": { - "version": "5.5.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.5.2.tgz", - "integrity": "sha512-NcRtPEOsPFFWjobJEtfihkLCZCXZt/os3zf8nTxjVH3RvTSxjrCamJpbExGvYOF+tFHc3pA65qpdwPbzjohhew==", + "version": "5.5.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.5.3.tgz", + "integrity": "sha512-/hreyEujaB0w76zKo6717l3L0o/qEUtRgdvUBvlkhoWeOVMjMuHNHk0BRBzikzuGDqNmPQbg5ifMEqsHLiIUcQ==", "dev": true, "bin": { "tsc": "bin/tsc", @@ -25211,6 +25219,12 @@ "node": ">=14.17" } }, + "packages/contentstack-audit/node_modules/workerpool": { + "version": "6.5.1", + "resolved": "https://registry.npmjs.org/workerpool/-/workerpool-6.5.1.tgz", + "integrity": "sha512-Fs4dNYcsdpYSAfVxhnl1L5zTksjvOJxtC5hzMNl+1t9B8hTJTdKDyZ5ju7ztgPy+ft9tBFXoOlDNiOT9WUXZlA==", + "dev": true + }, "packages/contentstack-audit/node_modules/yargs": { "version": "16.2.0", "resolved": "https://registry.npmjs.org/yargs/-/yargs-16.2.0.tgz", @@ -25229,6 +25243,15 @@ "node": ">=10" } }, + "packages/contentstack-audit/node_modules/yargs-parser": { + "version": "20.2.9", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-20.2.9.tgz", + "integrity": "sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w==", + "dev": true, + "engines": { + "node": ">=10" + } + }, "packages/contentstack-auth": { "name": "@contentstack/cli-auth", "version": "1.3.19", @@ -26171,6 +26194,15 @@ "url": "https://github.com/sponsors/epoberezkin" } }, + "packages/contentstack-export-to-csv/node_modules/ansi-colors": { + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.3.tgz", + "integrity": "sha512-/6w/C21Pm1A7aZitlI5Ni/2J6FFQN8i1Cvz3kHABAAbw93v/NlvKdVOqz7CCWz/3iv/JplRSEEZ83XION15ovw==", + "dev": true, + "engines": { + "node": ">=6" + } + }, "packages/contentstack-export-to-csv/node_modules/argparse": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", @@ -26198,21 +26230,13 @@ "wrap-ansi": "^7.0.0" } }, - "packages/contentstack-export-to-csv/node_modules/debug": { - "version": "4.3.4", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", - "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "packages/contentstack-export-to-csv/node_modules/diff": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/diff/-/diff-5.2.0.tgz", + "integrity": "sha512-uIFDxqpRZGZ6ThOk84hEfqWoHx2devRFvpTZcTHur85vImfaxUbTW9Ryh4CpCuDnToOP1CEtXKIgytHBPVff5A==", "dev": true, - "dependencies": { - "ms": "2.1.2" - }, "engines": { - "node": ">=6.0" - }, - "peerDependenciesMeta": { - "supports-color": { - "optional": true - } + "node": ">=0.3.1" } }, "packages/contentstack-export-to-csv/node_modules/eslint": { @@ -26439,31 +26463,31 @@ } }, "packages/contentstack-export-to-csv/node_modules/mocha": { - "version": "10.5.2", - "resolved": "https://registry.npmjs.org/mocha/-/mocha-10.5.2.tgz", - "integrity": "sha512-9btlN3JKCefPf+vKd/kcKz2SXxi12z6JswkGfaAF0saQvnsqLJk504ZmbxhSoENge08E9dsymozKgFMTl5PQsA==", + "version": "10.6.0", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-10.6.0.tgz", + "integrity": "sha512-hxjt4+EEB0SA0ZDygSS015t65lJw/I2yRCS3Ae+SJ5FrbzrXgfYwJr96f0OvIXdj7h4lv/vLCrH3rkiuizFSvw==", "dev": true, "dependencies": { - "ansi-colors": "4.1.1", - "browser-stdout": "1.3.1", + "ansi-colors": "^4.1.3", + "browser-stdout": "^1.3.1", "chokidar": "^3.5.3", - "debug": "4.3.4", - "diff": "5.0.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.0.1", - "ms": "2.1.3", - "serialize-javascript": "6.0.0", - "strip-json-comments": "3.1.1", - "supports-color": "8.1.1", - "workerpool": "6.2.1", - "yargs": "16.2.0", - "yargs-parser": "20.2.4", - "yargs-unparser": "2.0.0" + "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", @@ -26495,9 +26519,9 @@ } }, "packages/contentstack-export-to-csv/node_modules/mocha/node_modules/minimatch": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.0.1.tgz", - "integrity": "sha512-nLDxIFRyhDblz3qMuq+SoRZED4+miJ/G+tdDrjkkkRnjAsBexeGpgjLEQ0blJy7rHhR2b93rhQY4SvyWu9v03g==", + "version": "5.1.6", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.6.tgz", + "integrity": "sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g==", "dev": true, "dependencies": { "brace-expansion": "^2.0.1" @@ -26506,12 +26530,27 @@ "node": ">=10" } }, - "packages/contentstack-export-to-csv/node_modules/mocha/node_modules/ms": { + "packages/contentstack-export-to-csv/node_modules/ms": { "version": "2.1.3", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", "dev": true }, + "packages/contentstack-export-to-csv/node_modules/serialize-javascript": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-6.0.2.tgz", + "integrity": "sha512-Saa1xPByTTq2gdeFZYLLo+RFE35NHZkAbqZeWNd3BpzppeVisAqpDjcp8dyf6uIvEqJRd46jemmyA4iFIeVk8g==", + "dev": true, + "dependencies": { + "randombytes": "^2.1.0" + } + }, + "packages/contentstack-export-to-csv/node_modules/workerpool": { + "version": "6.5.1", + "resolved": "https://registry.npmjs.org/workerpool/-/workerpool-6.5.1.tgz", + "integrity": "sha512-Fs4dNYcsdpYSAfVxhnl1L5zTksjvOJxtC5hzMNl+1t9B8hTJTdKDyZ5ju7ztgPy+ft9tBFXoOlDNiOT9WUXZlA==", + "dev": true + }, "packages/contentstack-export-to-csv/node_modules/yargs": { "version": "16.2.0", "resolved": "https://registry.npmjs.org/yargs/-/yargs-16.2.0.tgz", @@ -26530,6 +26569,15 @@ "node": ">=10" } }, + "packages/contentstack-export-to-csv/node_modules/yargs-parser": { + "version": "20.2.9", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-20.2.9.tgz", + "integrity": "sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w==", + "dev": true, + "engines": { + "node": ">=10" + } + }, "packages/contentstack-import": { "name": "@contentstack/cli-cm-import", "version": "1.16.0", @@ -26551,7 +26599,7 @@ "mkdirp": "^1.0.4", "promise-limit": "^2.7.0", "tslib": "^2.4.1", - "uuid": "^9.0.0", + "uuid": "^9.0.1", "winston": "^3.7.2" }, "devDependencies": { @@ -26958,7 +27006,7 @@ "nock": "^13.1.0", "omit-deep-lodash": "^1.1.5", "sinon": "^15.0.1", - "uuid": "^9.0.0" + "uuid": "^9.0.1" }, "devDependencies": { "@oclif/test": "^2.5.6", @@ -26983,7 +27031,7 @@ }, "packages/contentstack-migration": { "name": "@contentstack/cli-migration", - "version": "1.5.6", + "version": "1.6.0", "license": "MIT", "dependencies": { "@contentstack/cli-command": "~1.2.18", @@ -27122,7 +27170,7 @@ "rxjs": "^6.6.7", "traverse": "^0.6.7", "unique-string": "^2.0.0", - "uuid": "^9.0.0", + "uuid": "^9.0.1", "winston": "^3.7.2", "xdg-basedir": "^4.0.0" }, diff --git a/packages/contentstack-import/package.json b/packages/contentstack-import/package.json index 153d530a3d..5b2133d6ef 100644 --- a/packages/contentstack-import/package.json +++ b/packages/contentstack-import/package.json @@ -21,7 +21,7 @@ "mkdirp": "^1.0.4", "promise-limit": "^2.7.0", "tslib": "^2.4.1", - "uuid": "^9.0.0", + "uuid": "^9.0.1", "winston": "^3.7.2" }, "devDependencies": { diff --git a/packages/contentstack-migrate-rte/package.json b/packages/contentstack-migrate-rte/package.json index f973245271..b831675508 100644 --- a/packages/contentstack-migrate-rte/package.json +++ b/packages/contentstack-migrate-rte/package.json @@ -16,7 +16,7 @@ "nock": "^13.1.0", "omit-deep-lodash": "^1.1.5", "sinon": "^15.0.1", - "uuid": "^9.0.0" + "uuid": "^9.0.1" }, "devDependencies": { "@oclif/test": "^2.5.6", @@ -67,4 +67,4 @@ "cm:migrate-rte": "O-MGRTRTE" } } -} \ No newline at end of file +} diff --git a/packages/contentstack-migration/README.md b/packages/contentstack-migration/README.md index b786623cf7..8d123bb97b 100644 --- a/packages/contentstack-migration/README.md +++ b/packages/contentstack-migration/README.md @@ -21,7 +21,7 @@ $ npm install -g @contentstack/cli-migration $ csdx COMMAND running command... $ csdx (--version) -@contentstack/cli-migration/1.5.6 darwin-arm64 node-v22.2.0 +@contentstack/cli-migration/1.6.0 darwin-arm64 node-v22.2.0 $ csdx --help [COMMAND] USAGE $ csdx COMMAND diff --git a/packages/contentstack-migration/package.json b/packages/contentstack-migration/package.json index 84c18f3c29..7e2da837a0 100644 --- a/packages/contentstack-migration/package.json +++ b/packages/contentstack-migration/package.json @@ -1,6 +1,6 @@ { "name": "@contentstack/cli-migration", - "version": "1.5.6", + "version": "1.6.0", "author": "@contentstack", "bugs": "https://github.com/contentstack/cli/issues", "dependencies": { @@ -66,4 +66,4 @@ "cm:migration": "O-MGRTN" } } -} \ No newline at end of file +} diff --git a/packages/contentstack-migration/src/commands/cm/stacks/migration.js b/packages/contentstack-migration/src/commands/cm/stacks/migration.js index 23b2c46257..ab71911089 100644 --- a/packages/contentstack-migration/src/commands/cm/stacks/migration.js +++ b/packages/contentstack-migration/src/commands/cm/stacks/migration.js @@ -25,7 +25,7 @@ const { const { ApiError, SchemaValidator, MigrationError, FieldValidator } = require('../../../validators'); // Utils -const { map: _map, constants, safePromise, errorHelper } = require('../../../utils'); +const { map: _map, constants, safePromise, errorHelper, installModules } = require('../../../utils'); // Properties const { get, set, getMapInstance, resetMapInstance } = _map; const { @@ -67,7 +67,7 @@ class MigrationCommand extends Command { this.exit(); } - if (!filePath) { + if (!filePath || !fs.existsSync(filePath)) { this.log('Please provide the migration script file path, use --file-path flag'); this.exit(); } @@ -129,6 +129,10 @@ class MigrationCommand extends Command { set(MANAGEMENT_SDK, mapInstance, stackSDKInstance); set(MANAGEMENT_CLIENT, mapInstance, APIClient); + if (!(await installModules(filePath, multi))) { + this.log(`Cannot proceed with migration as there will be module not found issue as package.json is not created`); + } + if (multi) { await this.execMultiFiles(filePath, mapInstance); } else { diff --git a/packages/contentstack-migration/src/utils/index.js b/packages/contentstack-migration/src/utils/index.js index 18553758e4..90aababe9b 100644 --- a/packages/contentstack-migration/src/utils/index.js +++ b/packages/contentstack-migration/src/utils/index.js @@ -17,4 +17,5 @@ module.exports = { getBatches: require('./get-batches'), autoRetry: require('./auto-retry'), contentstackSdk: require('./contentstack-sdk'), + installModules: require('./modules'), }; diff --git a/packages/contentstack-migration/src/utils/modules.js b/packages/contentstack-migration/src/utils/modules.js new file mode 100644 index 0000000000..692781dc94 --- /dev/null +++ b/packages/contentstack-migration/src/utils/modules.js @@ -0,0 +1,172 @@ +const fs = require('fs'); +const { execSync } = require('child_process'); +const path = require('path'); +const { sanitizePath } = require('@contentstack/cli-utilities'); +const os = require('os'); + +const internalModules = new Set([ + 'assert', + 'buffer', + 'child_process', + 'cluster', + 'console', + 'crypto', + 'dgram', + 'dns', + 'domain', + 'events', + 'fs', + 'http', + 'http2', + 'https', + 'inspector', + 'module', + 'net', + 'os', + 'path', + 'perf_hooks', + 'process', + 'punycode', + 'querystring', + 'readline', + 'repl', + 'stream', + 'string_decoder', + 'timers', + 'tls', + 'trace_events', + 'tty', + 'url', + 'util', + 'v8', + 'vm', + 'wasi', + 'worker_threads', + 'zlib', +]); + +function checkWritePermissionToDirectory(directory) { + try { + fs.accessSync(directory, fs.constants.W_OK); + return true; + } catch (err) { + console.log(`You don't have write access to directory`); + return false; + } +} + +function doesPackageJsonExist(directory) { + return fs.existsSync(path.join(sanitizePath(directory), 'package.json')); +} + +function scanDirectory(directory) { + return fs.readdirSync(directory); +} + +function scanFileForDependencies(directory, files) { + const dependencies = new Set(); + + files.forEach((file) => { + const filePath = path.join(sanitizePath(directory), sanitizePath(file)); + if (path.extname(filePath) === '.js') { + const fileContent = fs.readFileSync(filePath, 'utf-8'); + findModulesSync(fileContent).forEach((dep) => dependencies.add(dep)); + } + }); + + return [...dependencies]; +} + +function createPackageJson(directory) { + const templateString = `{ + "name": "MigrationPackage", + "version": "1.0.0", + "main": "1.js", + "scripts": {}, + "keywords": [], + "author": "", + "license": "ISC", + "description": "" + }`; + + fs.writeFileSync(path.join(sanitizePath(directory), 'package.json'), templateString); +} + +function installDependencies(dependencies, directory) { + const installedDependencies = new Set(); + + dependencies.forEach((dep) => { + if (!internalModules.has(dep)) { + const pkg = dep.startsWith('@') ? dep : dep.split('/')[0]; + if (!installedDependencies.has(pkg)) { + executeShellCommand(`npm i ${pkg}`, directory); + installedDependencies.add(pkg); + } + } + }); +} + +function executeShellCommand(command, directory = '') { + try { + execSync(command, { stdio: 'inherit', cwd: directory }); + console.log(`Command executed successfully: ${command}`); + } catch (error) { + console.error(`Error: ${error.message}`); + } +} + +async function installModules(filePath, multiple) { + const files = multiple ? [] : [path.basename(filePath)]; + const dirPath = multiple ? filePath : path.dirname(filePath); + + if (checkWritePermissionToDirectory(dirPath)) { + if (multiple) { + files.push(...scanDirectory(dirPath)); + } + + if (files.length === 0) { + console.log(`There are no files to create package.json for, exiting the code`); + return true; + } + + const dependencies = scanFileForDependencies(dirPath, files); + + if (!doesPackageJsonExist(dirPath)) { + console.log(`package.json doesn't exist, creating one`); + createPackageJson(dirPath); + } + + installDependencies(dependencies, dirPath); + } else { + console.log(`You don't have write permission to the directory`); + return false; + } + + console.log(`All modules installed successfully`); + return true; +} + +function findModulesSync(data) { + try { + const requireRegex = /require\(['"`](.*?)['"`]\)/g; + const importRegex = /import\s+(?:(?:[\w*\s{},]*)\s+from\s+)?['"`](.*?)['"`]/g; + + const modules = new Set(); + let match; + + while ((match = requireRegex.exec(data)) !== null) { + modules.add(match[1]); + } + + while ((match = importRegex.exec(data)) !== null) { + modules.add(match[1]); + } + + return [...modules]; + } catch (error) { + console.error(`Error reading file: ${error.message}`); + return []; + } +} + +module.exports = installModules; diff --git a/packages/contentstack-utilities/package.json b/packages/contentstack-utilities/package.json index 21ef56e09e..4ea191000a 100644 --- a/packages/contentstack-utilities/package.json +++ b/packages/contentstack-utilities/package.json @@ -54,7 +54,7 @@ "rxjs": "^6.6.7", "traverse": "^0.6.7", "unique-string": "^2.0.0", - "uuid": "^9.0.0", + "uuid": "^9.0.1", "winston": "^3.7.2", "xdg-basedir": "^4.0.0" }, diff --git a/packages/contentstack/README.md b/packages/contentstack/README.md index f3bbda8102..5c9156e863 100644 --- a/packages/contentstack/README.md +++ b/packages/contentstack/README.md @@ -18,7 +18,7 @@ $ npm install -g @contentstack/cli $ csdx COMMAND running command... $ csdx (--version|-v) -@contentstack/cli/1.20.0 darwin-arm64 node-v22.2.0 +@contentstack/cli/1.21.0 darwin-arm64 node-v22.2.0 $ csdx --help [COMMAND] USAGE $ csdx COMMAND @@ -3496,7 +3496,7 @@ EXAMPLES $ csdx plugins ``` -_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.3.3/src/commands/plugins/index.ts)_ +_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.2.4/src/commands/plugins/index.ts)_ ## `csdx plugins:add PLUGIN` @@ -3570,7 +3570,7 @@ EXAMPLES $ csdx plugins:inspect myplugin ``` -_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.3.3/src/commands/plugins/inspect.ts)_ +_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.2.4/src/commands/plugins/inspect.ts)_ ## `csdx plugins:install PLUGIN` @@ -3619,7 +3619,7 @@ EXAMPLES $ csdx plugins:install someuser/someplugin ``` -_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.3.3/src/commands/plugins/install.ts)_ +_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.2.4/src/commands/plugins/install.ts)_ ## `csdx plugins:link PATH` @@ -3649,7 +3649,7 @@ EXAMPLES $ csdx plugins:link myplugin ``` -_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.3.3/src/commands/plugins/link.ts)_ +_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.2.4/src/commands/plugins/link.ts)_ ## `csdx plugins:remove [PLUGIN]` @@ -3690,7 +3690,7 @@ FLAGS --reinstall Reinstall all plugins after uninstalling. ``` -_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.3.3/src/commands/plugins/reset.ts)_ +_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.2.4/src/commands/plugins/reset.ts)_ ## `csdx plugins:uninstall [PLUGIN]` @@ -3718,7 +3718,7 @@ EXAMPLES $ csdx plugins:uninstall myplugin ``` -_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.3.3/src/commands/plugins/uninstall.ts)_ +_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.2.4/src/commands/plugins/uninstall.ts)_ ## `csdx plugins:unlink [PLUGIN]` @@ -3762,7 +3762,7 @@ DESCRIPTION Update installed plugins. ``` -_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.3.3/src/commands/plugins/update.ts)_ +_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.2.4/src/commands/plugins/update.ts)_ ## `csdx tokens` diff --git a/packages/contentstack/package.json b/packages/contentstack/package.json index b583ed6e4b..66ba780cde 100755 --- a/packages/contentstack/package.json +++ b/packages/contentstack/package.json @@ -1,7 +1,7 @@ { "name": "@contentstack/cli", "description": "Command-line tool (CLI) to interact with Contentstack", - "version": "1.20.0", + "version": "1.21.0", "author": "Contentstack", "bin": { "csdx": "./bin/run.js" @@ -36,7 +36,7 @@ "@contentstack/cli-command": "~1.2.18", "@contentstack/cli-config": "~1.6.4", "@contentstack/cli-launch": "~1.0.18", - "@contentstack/cli-migration": "~1.5.6", + "@contentstack/cli-migration": "~1.6.0", "@contentstack/cli-utilities": "~1.6.3", "@contentstack/management": "~1.15.3", "@oclif/core": "^3.26.5", @@ -50,7 +50,7 @@ "node-machine-id": "^1.1.12", "open": "^8.4.2", "short-uuid": "^4.2.2", - "uuid": "^9.0.0", + "uuid": "^9.0.1", "winston": "^3.7.2" }, "devDependencies": { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 9e28e5d963..3d3708ade0 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -24,7 +24,7 @@ importers: '@contentstack/cli-command': ~1.2.18 '@contentstack/cli-config': ~1.6.4 '@contentstack/cli-launch': ~1.0.18 - '@contentstack/cli-migration': ~1.5.6 + '@contentstack/cli-migration': ~1.6.0 '@contentstack/cli-utilities': ~1.6.3 '@contentstack/management': ~1.15.3 '@oclif/core': ^3.26.5 @@ -61,7 +61,7 @@ importers: ts-node: ^10.9.1 tslib: ^2.4.1 typescript: ^4.9.3 - uuid: ^9.0.0 + uuid: ^9.0.1 winston: ^3.7.2 dependencies: '@contentstack/cli-audit': link:../contentstack-audit @@ -770,7 +770,7 @@ importers: ts-node: ^10.9.1 tslib: ^2.4.1 typescript: ^4.9.3 - uuid: ^9.0.0 + uuid: ^9.0.1 winston: ^3.7.2 dependencies: '@contentstack/cli-audit': link:../contentstack-audit @@ -916,7 +916,7 @@ importers: omit-deep-lodash: ^1.1.5 sinon: ^15.0.1 tslib: ^1.13.0 - uuid: ^9.0.0 + uuid: ^9.0.1 dependencies: '@contentstack/cli-command': link:../contentstack-command '@contentstack/cli-utilities': link:../contentstack-utilities @@ -1091,7 +1091,7 @@ importers: tslib: ^1.13.0 typescript: ^4.9.3 unique-string: ^2.0.0 - uuid: ^9.0.0 + uuid: ^9.0.1 winston: ^3.7.2 xdg-basedir: ^4.0.0 dependencies: From cda7812c9ee23b401a6214bb266765f52a92b5b6 Mon Sep 17 00:00:00 2001 From: raj pandey Date: Wed, 3 Jul 2024 13:19:38 +0530 Subject: [PATCH 04/22] PR fixes --- package-lock.json | 6 +-- .../src/utils/modules.js | 44 ++----------------- 2 files changed, 6 insertions(+), 44 deletions(-) diff --git a/package-lock.json b/package-lock.json index 718a10e3ef..c1ba30a35f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4052,9 +4052,9 @@ } }, "node_modules/acorn": { - "version": "8.12.0", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.12.0.tgz", - "integrity": "sha512-RTvkC4w+KNXrM39/lWCUaG0IbRkWdCv7W/IOW9oU6SawyxulvkQy5HQPVTKxEjczcUvapcrw3cFx/60VN/NRNw==", + "version": "8.12.1", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.12.1.tgz", + "integrity": "sha512-tcpGyI9zbizT9JbV6oYE477V6mTlXvvi0T0G3SNIYE2apm/G5huBa1+K89VGeovbg+jycCrfhl3ADxErOuO6Jg==", "bin": { "acorn": "bin/acorn" }, diff --git a/packages/contentstack-migration/src/utils/modules.js b/packages/contentstack-migration/src/utils/modules.js index 692781dc94..ec3d776c59 100644 --- a/packages/contentstack-migration/src/utils/modules.js +++ b/packages/contentstack-migration/src/utils/modules.js @@ -3,47 +3,9 @@ const { execSync } = require('child_process'); const path = require('path'); const { sanitizePath } = require('@contentstack/cli-utilities'); const os = require('os'); +const { builtinModules } = require('module'); -const internalModules = new Set([ - 'assert', - 'buffer', - 'child_process', - 'cluster', - 'console', - 'crypto', - 'dgram', - 'dns', - 'domain', - 'events', - 'fs', - 'http', - 'http2', - 'https', - 'inspector', - 'module', - 'net', - 'os', - 'path', - 'perf_hooks', - 'process', - 'punycode', - 'querystring', - 'readline', - 'repl', - 'stream', - 'string_decoder', - 'timers', - 'tls', - 'trace_events', - 'tty', - 'url', - 'util', - 'v8', - 'vm', - 'wasi', - 'worker_threads', - 'zlib', -]); +const internalModules = new Set(builtinModules); function checkWritePermissionToDirectory(directory) { try { @@ -81,7 +43,7 @@ function createPackageJson(directory) { const templateString = `{ "name": "MigrationPackage", "version": "1.0.0", - "main": "1.js", + "main": "", "scripts": {}, "keywords": [], "author": "", From 33340ad301f26894dac0a9b9e725adccab885831 Mon Sep 17 00:00:00 2001 From: Aravind Kumar Date: Wed, 3 Jul 2024 22:10:07 +0530 Subject: [PATCH 05/22] Create .snyk --- packages/contentstack-dev-dependencies/.snyk | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 packages/contentstack-dev-dependencies/.snyk diff --git a/packages/contentstack-dev-dependencies/.snyk b/packages/contentstack-dev-dependencies/.snyk new file mode 100644 index 0000000000..69b495d0ee --- /dev/null +++ b/packages/contentstack-dev-dependencies/.snyk @@ -0,0 +1,10 @@ +# Snyk (https://snyk.io) policy file, patches or ignores known vulnerabilities. +version: v1.25.0 +# ignores vulnerabilities until expiry date; change duration by modifying expiry date +ignore: + SNYK-JS-ASYNC-7414156: + - '*': + reason: 'https://contentstack.atlassian.net/browse/CLOUD-6762' + expires: 2024-08-02T13:54:17.307Z + created: 2024-07-03T13:54:17.314Z +patch: {} From 1116558104bb8663769286b3ca861846167c2542 Mon Sep 17 00:00:00 2001 From: raj pandey Date: Thu, 4 Jul 2024 18:02:56 +0530 Subject: [PATCH 06/22] back merge --- package-lock.json | 324 ++++++++++++++++++++++++++-------------------- 1 file changed, 186 insertions(+), 138 deletions(-) diff --git a/package-lock.json b/package-lock.json index b2e0fa1573..7bac0d5b24 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2256,9 +2256,9 @@ } }, "node_modules/@oclif/plugin-plugins/node_modules/@oclif/core": { - "version": "4.0.7", - "resolved": "https://registry.npmjs.org/@oclif/core/-/core-4.0.7.tgz", - "integrity": "sha512-sU4Dx+RXCWAkrMw8tQFYAL6VfcHYKLPxVC9iKfgTXr4aDhcCssDwrbgpx0Di1dnNxvQlDGUhuCEInZuIY/nNfw==", + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/@oclif/core/-/core-4.0.8.tgz", + "integrity": "sha512-9AzNoRlKfIeuqOin+HK9cyouELeup7sX+MGIFc5dR+bnG0sSzFnV1A/Z57E7KWrY5NdWULHYT5NhiL1YpEhG2w==", "dependencies": { "ansi-escapes": "^4.3.2", "ansis": "^3.1.1", @@ -2271,7 +2271,7 @@ "indent-string": "^4.0.0", "is-wsl": "^2.2.0", "lilconfig": "^3.1.2", - "minimatch": "^9.0.4", + "minimatch": "^9.0.5", "string-width": "^4.2.3", "supports-color": "^8", "widest-line": "^3.1.0", @@ -4052,9 +4052,9 @@ } }, "node_modules/acorn": { - "version": "8.12.0", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.12.0.tgz", - "integrity": "sha512-RTvkC4w+KNXrM39/lWCUaG0IbRkWdCv7W/IOW9oU6SawyxulvkQy5HQPVTKxEjczcUvapcrw3cFx/60VN/NRNw==", + "version": "8.12.1", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.12.1.tgz", + "integrity": "sha512-tcpGyI9zbizT9JbV6oYE477V6mTlXvvi0T0G3SNIYE2apm/G5huBa1+K89VGeovbg+jycCrfhl3ADxErOuO6Jg==", "bin": { "acorn": "bin/acorn" }, @@ -4610,9 +4610,9 @@ } }, "node_modules/aws-sdk": { - "version": "2.1651.0", - "resolved": "https://registry.npmjs.org/aws-sdk/-/aws-sdk-2.1651.0.tgz", - "integrity": "sha512-MZjQvvOPkKcx1N428ejUjqSfhm4TAIcgPIgpniiDMw1LjB1yA8JBZvrWer6J6MACAXQ99v0uKE4BSvtYn+AT3g==", + "version": "2.1654.0", + "resolved": "https://registry.npmjs.org/aws-sdk/-/aws-sdk-2.1654.0.tgz", + "integrity": "sha512-b5ryvXipBJod9Uh1GUfQNgi5tIIiluxJbyqr/hZ/mr5U8WxrrfjVq3nGnx5JjevFKYRqXIywhumsVyanfACzFA==", "dev": true, "hasInstallScript": true, "dependencies": { @@ -5357,9 +5357,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001639", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001639.tgz", - "integrity": "sha512-eFHflNTBIlFwP2AIKaYuBQN/apnUoKNhBdza8ZnW/h2di4LCZ4xFqYlxUxo+LQ76KFI1PGcC1QDxMbxTZpSCAg==", + "version": "1.0.30001640", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001640.tgz", + "integrity": "sha512-lA4VMpW0PSUrFnkmVuEKBUovSWKhj7puyCg8StBChgu298N1AtuF1sKWEvfDuimSEDbhlb/KqPKC3fs1HbuQUA==", "dev": true, "funding": [ { @@ -6910,9 +6910,9 @@ } }, "node_modules/electron-to-chromium": { - "version": "1.4.815", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.815.tgz", - "integrity": "sha512-OvpTT2ItpOXJL7IGcYakRjHCt8L5GrrN/wHCQsRB4PQa1X9fe+X9oen245mIId7s14xvArCGSTIq644yPUKKLg==", + "version": "1.4.816", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.816.tgz", + "integrity": "sha512-EKH5X5oqC6hLmiS7/vYtZHZFTNdhsYG5NVPRN6Yn0kQHNBlT59+xSM8HBy66P5fxWpKgZbPqb+diC64ng295Jw==", "dev": true }, "node_modules/elegant-spinner": { @@ -8065,13 +8065,13 @@ } }, "node_modules/eslint-plugin-perfectionist/node_modules/@typescript-eslint/scope-manager": { - "version": "7.14.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-7.14.1.tgz", - "integrity": "sha512-gPrFSsoYcsffYXTOZ+hT7fyJr95rdVe4kGVX1ps/dJ+DfmlnjFN/GcMxXcVkeHDKqsq6uAcVaQaIi3cFffmAbA==", + "version": "7.15.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-7.15.0.tgz", + "integrity": "sha512-Q/1yrF/XbxOTvttNVPihxh1b9fxamjEoz2Os/Pe38OHwxC24CyCqXxGTOdpb4lt6HYtqw9HetA/Rf6gDGaMPlw==", "dev": true, "dependencies": { - "@typescript-eslint/types": "7.14.1", - "@typescript-eslint/visitor-keys": "7.14.1" + "@typescript-eslint/types": "7.15.0", + "@typescript-eslint/visitor-keys": "7.15.0" }, "engines": { "node": "^18.18.0 || >=20.0.0" @@ -8082,9 +8082,9 @@ } }, "node_modules/eslint-plugin-perfectionist/node_modules/@typescript-eslint/types": { - "version": "7.14.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-7.14.1.tgz", - "integrity": "sha512-mL7zNEOQybo5R3AavY+Am7KLv8BorIv7HCYS5rKoNZKQD9tsfGUpO4KdAn3sSUvTiS4PQkr2+K0KJbxj8H9NDg==", + "version": "7.15.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-7.15.0.tgz", + "integrity": "sha512-aV1+B1+ySXbQH0pLK0rx66I3IkiZNidYobyfn0WFsdGhSXw+P3YOqeTq5GED458SfB24tg+ux3S+9g118hjlTw==", "dev": true, "engines": { "node": "^18.18.0 || >=20.0.0" @@ -8095,13 +8095,13 @@ } }, "node_modules/eslint-plugin-perfectionist/node_modules/@typescript-eslint/typescript-estree": { - "version": "7.14.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-7.14.1.tgz", - "integrity": "sha512-k5d0VuxViE2ulIO6FbxxSZaxqDVUyMbXcidC8rHvii0I56XZPv8cq+EhMns+d/EVIL41sMXqRbK3D10Oza1bbA==", + "version": "7.15.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-7.15.0.tgz", + "integrity": "sha512-gjyB/rHAopL/XxfmYThQbXbzRMGhZzGw6KpcMbfe8Q3nNQKStpxnUKeXb0KiN/fFDR42Z43szs6rY7eHk0zdGQ==", "dev": true, "dependencies": { - "@typescript-eslint/types": "7.14.1", - "@typescript-eslint/visitor-keys": "7.14.1", + "@typescript-eslint/types": "7.15.0", + "@typescript-eslint/visitor-keys": "7.15.0", "debug": "^4.3.4", "globby": "^11.1.0", "is-glob": "^4.0.3", @@ -8123,15 +8123,15 @@ } }, "node_modules/eslint-plugin-perfectionist/node_modules/@typescript-eslint/utils": { - "version": "7.14.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-7.14.1.tgz", - "integrity": "sha512-CMmVVELns3nak3cpJhZosDkm63n+DwBlDX8g0k4QUa9BMnF+lH2lr3d130M1Zt1xxmB3LLk3NV7KQCq86ZBBhQ==", + "version": "7.15.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-7.15.0.tgz", + "integrity": "sha512-hfDMDqaqOqsUVGiEPSMLR/AjTSCsmJwjpKkYQRo1FNbmW4tBwBspYDwO9eh7sKSTwMQgBw9/T4DHudPaqshRWA==", "dev": true, "dependencies": { "@eslint-community/eslint-utils": "^4.4.0", - "@typescript-eslint/scope-manager": "7.14.1", - "@typescript-eslint/types": "7.14.1", - "@typescript-eslint/typescript-estree": "7.14.1" + "@typescript-eslint/scope-manager": "7.15.0", + "@typescript-eslint/types": "7.15.0", + "@typescript-eslint/typescript-estree": "7.15.0" }, "engines": { "node": "^18.18.0 || >=20.0.0" @@ -8145,12 +8145,12 @@ } }, "node_modules/eslint-plugin-perfectionist/node_modules/@typescript-eslint/visitor-keys": { - "version": "7.14.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-7.14.1.tgz", - "integrity": "sha512-Crb+F75U1JAEtBeQGxSKwI60hZmmzaqA3z9sYsVm8X7W5cwLEm5bRe0/uXS6+MR/y8CVpKSR/ontIAIEPFcEkA==", + "version": "7.15.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-7.15.0.tgz", + "integrity": "sha512-Hqgy/ETgpt2L5xueA/zHHIl4fJI2O4XUE9l4+OIfbJIRSnTJb/QscncdqqZzofQegIJugRIF57OJea1khw2SDw==", "dev": true, "dependencies": { - "@typescript-eslint/types": "7.14.1", + "@typescript-eslint/types": "7.15.0", "eslint-visitor-keys": "^3.4.3" }, "engines": { @@ -12824,9 +12824,9 @@ } }, "node_modules/jsdom/node_modules/ws": { - "version": "8.17.1", - "resolved": "https://registry.npmjs.org/ws/-/ws-8.17.1.tgz", - "integrity": "sha512-6XQFvXTkbfUOZOKKILFG1PDK2NDQs4azKQl26T0YS5CxqWLgXajbPZ+h4gZekJyRqFU8pvnbAbbs/3TgRPy+GQ==", + "version": "8.18.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.18.0.tgz", + "integrity": "sha512-8VbfWfHLbbwu3+N6OKsOMpBdT4kXPDDB9cJk2bJ6mh9ucxdlnNvH1e+roYkKmN9Nxw2yjz7VzeO9oOz2zJ04Pw==", "engines": { "node": ">=10.0.0" }, @@ -15143,6 +15143,13 @@ "which", "write-file-atomic" ], + "workspaces": [ + "docs", + "smoke-tests", + "mock-globals", + "mock-registry", + "workspaces/*" + ], "dependencies": { "@isaacs/string-locale-compare": "^1.1.0", "@npmcli/arborist": "^7.5.3", @@ -19711,9 +19718,9 @@ ] }, "node_modules/qs": { - "version": "6.12.1", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.12.1.tgz", - "integrity": "sha512-zWmv4RSuB9r2mYQw3zxQuHWeU+42aKi1wWig/j4ele4ygELZ7PEO6MM7rim9oAQH2A5MWfsAVf/jPvTPgCbvUQ==", + "version": "6.12.2", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.12.2.tgz", + "integrity": "sha512-x+NLUpx9SYrcwXtX7ob1gnkSems4i/mGZX5SlYxwIau6RrUSODO89TR/XDGGpn5RPWSYIB+aSfuSlV5+CmbTBg==", "dependencies": { "side-channel": "^1.0.6" }, @@ -23014,9 +23021,9 @@ } }, "node_modules/update-browserslist-db": { - "version": "1.0.16", - "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.0.16.tgz", - "integrity": "sha512-KVbTxlBYlckhF5wgfyZXTWnMn7MMZjMu9XG8bPlliUOP9ThaF4QnhP8qrjrH7DRzHfSk0oQv1wToW+iA5GajEQ==", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.1.0.tgz", + "integrity": "sha512-EdRAaAyk2cUE1wOf2DkEhzxqOQvFOoRJFNS6NeyJ01Gp2beMRpBAINjM2iDXE3KCuKhwnvHIQCJm6ThL2Z+HzQ==", "dev": true, "funding": [ { @@ -25024,6 +25031,15 @@ "undici-types": "~5.26.4" } }, + "packages/contentstack-audit/node_modules/ansi-colors": { + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.3.tgz", + "integrity": "sha512-/6w/C21Pm1A7aZitlI5Ni/2J6FFQN8i1Cvz3kHABAAbw93v/NlvKdVOqz7CCWz/3iv/JplRSEEZ83XION15ovw==", + "dev": true, + "engines": { + "node": ">=6" + } + }, "packages/contentstack-audit/node_modules/argparse": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", @@ -25041,21 +25057,13 @@ "wrap-ansi": "^7.0.0" } }, - "packages/contentstack-audit/node_modules/debug": { - "version": "4.3.4", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", - "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "packages/contentstack-audit/node_modules/diff": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/diff/-/diff-5.2.0.tgz", + "integrity": "sha512-uIFDxqpRZGZ6ThOk84hEfqWoHx2devRFvpTZcTHur85vImfaxUbTW9Ryh4CpCuDnToOP1CEtXKIgytHBPVff5A==", "dev": true, - "dependencies": { - "ms": "2.1.2" - }, "engines": { - "node": ">=6.0" - }, - "peerDependenciesMeta": { - "supports-color": { - "optional": true - } + "node": ">=0.3.1" } }, "packages/contentstack-audit/node_modules/glob": { @@ -25107,9 +25115,9 @@ } }, "packages/contentstack-audit/node_modules/minimatch": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.0.1.tgz", - "integrity": "sha512-nLDxIFRyhDblz3qMuq+SoRZED4+miJ/G+tdDrjkkkRnjAsBexeGpgjLEQ0blJy7rHhR2b93rhQY4SvyWu9v03g==", + "version": "5.1.6", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.6.tgz", + "integrity": "sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g==", "dev": true, "dependencies": { "brace-expansion": "^2.0.1" @@ -25119,31 +25127,31 @@ } }, "packages/contentstack-audit/node_modules/mocha": { - "version": "10.5.2", - "resolved": "https://registry.npmjs.org/mocha/-/mocha-10.5.2.tgz", - "integrity": "sha512-9btlN3JKCefPf+vKd/kcKz2SXxi12z6JswkGfaAF0saQvnsqLJk504ZmbxhSoENge08E9dsymozKgFMTl5PQsA==", + "version": "10.6.0", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-10.6.0.tgz", + "integrity": "sha512-hxjt4+EEB0SA0ZDygSS015t65lJw/I2yRCS3Ae+SJ5FrbzrXgfYwJr96f0OvIXdj7h4lv/vLCrH3rkiuizFSvw==", "dev": true, "dependencies": { - "ansi-colors": "4.1.1", - "browser-stdout": "1.3.1", + "ansi-colors": "^4.1.3", + "browser-stdout": "^1.3.1", "chokidar": "^3.5.3", - "debug": "4.3.4", - "diff": "5.0.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.0.1", - "ms": "2.1.3", - "serialize-javascript": "6.0.0", - "strip-json-comments": "3.1.1", - "supports-color": "8.1.1", - "workerpool": "6.2.1", - "yargs": "16.2.0", - "yargs-parser": "20.2.4", - "yargs-unparser": "2.0.0" + "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", @@ -25153,12 +25161,21 @@ "node": ">= 14.0.0" } }, - "packages/contentstack-audit/node_modules/mocha/node_modules/ms": { + "packages/contentstack-audit/node_modules/ms": { "version": "2.1.3", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", "dev": true }, + "packages/contentstack-audit/node_modules/serialize-javascript": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-6.0.2.tgz", + "integrity": "sha512-Saa1xPByTTq2gdeFZYLLo+RFE35NHZkAbqZeWNd3BpzppeVisAqpDjcp8dyf6uIvEqJRd46jemmyA4iFIeVk8g==", + "dev": true, + "dependencies": { + "randombytes": "^2.1.0" + } + }, "packages/contentstack-audit/node_modules/sinon": { "version": "17.0.1", "resolved": "https://registry.npmjs.org/sinon/-/sinon-17.0.1.tgz", @@ -25177,15 +25194,6 @@ "url": "https://opencollective.com/sinon" } }, - "packages/contentstack-audit/node_modules/sinon/node_modules/diff": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/diff/-/diff-5.2.0.tgz", - "integrity": "sha512-uIFDxqpRZGZ6ThOk84hEfqWoHx2devRFvpTZcTHur85vImfaxUbTW9Ryh4CpCuDnToOP1CEtXKIgytHBPVff5A==", - "dev": true, - "engines": { - "node": ">=0.3.1" - } - }, "packages/contentstack-audit/node_modules/sinon/node_modules/supports-color": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", @@ -25199,9 +25207,9 @@ } }, "packages/contentstack-audit/node_modules/typescript": { - "version": "5.5.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.5.2.tgz", - "integrity": "sha512-NcRtPEOsPFFWjobJEtfihkLCZCXZt/os3zf8nTxjVH3RvTSxjrCamJpbExGvYOF+tFHc3pA65qpdwPbzjohhew==", + "version": "5.5.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.5.3.tgz", + "integrity": "sha512-/hreyEujaB0w76zKo6717l3L0o/qEUtRgdvUBvlkhoWeOVMjMuHNHk0BRBzikzuGDqNmPQbg5ifMEqsHLiIUcQ==", "dev": true, "bin": { "tsc": "bin/tsc", @@ -25211,6 +25219,12 @@ "node": ">=14.17" } }, + "packages/contentstack-audit/node_modules/workerpool": { + "version": "6.5.1", + "resolved": "https://registry.npmjs.org/workerpool/-/workerpool-6.5.1.tgz", + "integrity": "sha512-Fs4dNYcsdpYSAfVxhnl1L5zTksjvOJxtC5hzMNl+1t9B8hTJTdKDyZ5ju7ztgPy+ft9tBFXoOlDNiOT9WUXZlA==", + "dev": true + }, "packages/contentstack-audit/node_modules/yargs": { "version": "16.2.0", "resolved": "https://registry.npmjs.org/yargs/-/yargs-16.2.0.tgz", @@ -25229,6 +25243,15 @@ "node": ">=10" } }, + "packages/contentstack-audit/node_modules/yargs-parser": { + "version": "20.2.9", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-20.2.9.tgz", + "integrity": "sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w==", + "dev": true, + "engines": { + "node": ">=10" + } + }, "packages/contentstack-auth": { "name": "@contentstack/cli-auth", "version": "1.3.19", @@ -26171,6 +26194,15 @@ "url": "https://github.com/sponsors/epoberezkin" } }, + "packages/contentstack-export-to-csv/node_modules/ansi-colors": { + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.3.tgz", + "integrity": "sha512-/6w/C21Pm1A7aZitlI5Ni/2J6FFQN8i1Cvz3kHABAAbw93v/NlvKdVOqz7CCWz/3iv/JplRSEEZ83XION15ovw==", + "dev": true, + "engines": { + "node": ">=6" + } + }, "packages/contentstack-export-to-csv/node_modules/argparse": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", @@ -26198,21 +26230,13 @@ "wrap-ansi": "^7.0.0" } }, - "packages/contentstack-export-to-csv/node_modules/debug": { - "version": "4.3.4", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", - "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "packages/contentstack-export-to-csv/node_modules/diff": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/diff/-/diff-5.2.0.tgz", + "integrity": "sha512-uIFDxqpRZGZ6ThOk84hEfqWoHx2devRFvpTZcTHur85vImfaxUbTW9Ryh4CpCuDnToOP1CEtXKIgytHBPVff5A==", "dev": true, - "dependencies": { - "ms": "2.1.2" - }, "engines": { - "node": ">=6.0" - }, - "peerDependenciesMeta": { - "supports-color": { - "optional": true - } + "node": ">=0.3.1" } }, "packages/contentstack-export-to-csv/node_modules/eslint": { @@ -26439,31 +26463,31 @@ } }, "packages/contentstack-export-to-csv/node_modules/mocha": { - "version": "10.5.2", - "resolved": "https://registry.npmjs.org/mocha/-/mocha-10.5.2.tgz", - "integrity": "sha512-9btlN3JKCefPf+vKd/kcKz2SXxi12z6JswkGfaAF0saQvnsqLJk504ZmbxhSoENge08E9dsymozKgFMTl5PQsA==", + "version": "10.6.0", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-10.6.0.tgz", + "integrity": "sha512-hxjt4+EEB0SA0ZDygSS015t65lJw/I2yRCS3Ae+SJ5FrbzrXgfYwJr96f0OvIXdj7h4lv/vLCrH3rkiuizFSvw==", "dev": true, "dependencies": { - "ansi-colors": "4.1.1", - "browser-stdout": "1.3.1", + "ansi-colors": "^4.1.3", + "browser-stdout": "^1.3.1", "chokidar": "^3.5.3", - "debug": "4.3.4", - "diff": "5.0.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.0.1", - "ms": "2.1.3", - "serialize-javascript": "6.0.0", - "strip-json-comments": "3.1.1", - "supports-color": "8.1.1", - "workerpool": "6.2.1", - "yargs": "16.2.0", - "yargs-parser": "20.2.4", - "yargs-unparser": "2.0.0" + "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", @@ -26495,9 +26519,9 @@ } }, "packages/contentstack-export-to-csv/node_modules/mocha/node_modules/minimatch": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.0.1.tgz", - "integrity": "sha512-nLDxIFRyhDblz3qMuq+SoRZED4+miJ/G+tdDrjkkkRnjAsBexeGpgjLEQ0blJy7rHhR2b93rhQY4SvyWu9v03g==", + "version": "5.1.6", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.6.tgz", + "integrity": "sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g==", "dev": true, "dependencies": { "brace-expansion": "^2.0.1" @@ -26506,12 +26530,27 @@ "node": ">=10" } }, - "packages/contentstack-export-to-csv/node_modules/mocha/node_modules/ms": { + "packages/contentstack-export-to-csv/node_modules/ms": { "version": "2.1.3", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", "dev": true }, + "packages/contentstack-export-to-csv/node_modules/serialize-javascript": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-6.0.2.tgz", + "integrity": "sha512-Saa1xPByTTq2gdeFZYLLo+RFE35NHZkAbqZeWNd3BpzppeVisAqpDjcp8dyf6uIvEqJRd46jemmyA4iFIeVk8g==", + "dev": true, + "dependencies": { + "randombytes": "^2.1.0" + } + }, + "packages/contentstack-export-to-csv/node_modules/workerpool": { + "version": "6.5.1", + "resolved": "https://registry.npmjs.org/workerpool/-/workerpool-6.5.1.tgz", + "integrity": "sha512-Fs4dNYcsdpYSAfVxhnl1L5zTksjvOJxtC5hzMNl+1t9B8hTJTdKDyZ5ju7ztgPy+ft9tBFXoOlDNiOT9WUXZlA==", + "dev": true + }, "packages/contentstack-export-to-csv/node_modules/yargs": { "version": "16.2.0", "resolved": "https://registry.npmjs.org/yargs/-/yargs-16.2.0.tgz", @@ -26530,6 +26569,15 @@ "node": ">=10" } }, + "packages/contentstack-export-to-csv/node_modules/yargs-parser": { + "version": "20.2.9", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-20.2.9.tgz", + "integrity": "sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w==", + "dev": true, + "engines": { + "node": ">=10" + } + }, "packages/contentstack-import": { "name": "@contentstack/cli-cm-import", "version": "1.16.0", From 25ab23866b78af0a68c2e37cb094d5afc313a5c0 Mon Sep 17 00:00:00 2001 From: raj pandey Date: Thu, 4 Jul 2024 18:23:29 +0530 Subject: [PATCH 07/22] UI text updated --- .../contentstack-migration/src/commands/cm/stacks/migration.js | 2 +- packages/contentstack-migration/src/utils/modules.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/contentstack-migration/src/commands/cm/stacks/migration.js b/packages/contentstack-migration/src/commands/cm/stacks/migration.js index ab71911089..201621b389 100644 --- a/packages/contentstack-migration/src/commands/cm/stacks/migration.js +++ b/packages/contentstack-migration/src/commands/cm/stacks/migration.js @@ -130,7 +130,7 @@ class MigrationCommand extends Command { set(MANAGEMENT_CLIENT, mapInstance, APIClient); if (!(await installModules(filePath, multi))) { - this.log(`Cannot proceed with migration as there will be module not found issue as package.json is not created`); + this.log(`Failed to install the dependencies of the given scripts.`); } if (multi) { diff --git a/packages/contentstack-migration/src/utils/modules.js b/packages/contentstack-migration/src/utils/modules.js index ec3d776c59..b6fa55b76c 100644 --- a/packages/contentstack-migration/src/utils/modules.js +++ b/packages/contentstack-migration/src/utils/modules.js @@ -104,7 +104,7 @@ async function installModules(filePath, multiple) { return false; } - console.log(`All modules installed successfully`); + console.log(`All dependencies installed successfully`); return true; } From 6dc5d0a57967d426cc17bffb577dcaababe04fd9 Mon Sep 17 00:00:00 2001 From: raj pandey Date: Thu, 4 Jul 2024 18:24:16 +0530 Subject: [PATCH 08/22] added process.exit --- .../contentstack-migration/src/commands/cm/stacks/migration.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/contentstack-migration/src/commands/cm/stacks/migration.js b/packages/contentstack-migration/src/commands/cm/stacks/migration.js index 201621b389..2beef86c48 100644 --- a/packages/contentstack-migration/src/commands/cm/stacks/migration.js +++ b/packages/contentstack-migration/src/commands/cm/stacks/migration.js @@ -131,6 +131,7 @@ class MigrationCommand extends Command { if (!(await installModules(filePath, multi))) { this.log(`Failed to install the dependencies of the given scripts.`); + process.exit(1); } if (multi) { From ffd9a440386187400ca2c42fab26cf682ecc6aed Mon Sep 17 00:00:00 2001 From: Aman Kumar Date: Tue, 9 Jul 2024 15:17:51 +0530 Subject: [PATCH 09/22] refactor: launch framework preset order --- packages/contentstack-launch/src/config/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/contentstack-launch/src/config/index.ts b/packages/contentstack-launch/src/config/index.ts index 86f2ad2672..1b505de30a 100755 --- a/packages/contentstack-launch/src/config/index.ts +++ b/packages/contentstack-launch/src/config/index.ts @@ -8,22 +8,22 @@ const config = { exclude: ['logs', '.next', 'node_modules', '.cs-launch.json'], }, outputDirectories: { - OTHER: './', GATSBY: './public', NEXTJS: './.next', CRA: './build', CSR: './', ANGULAR: './dist', VUEJS: './dist', + OTHER: './', }, listOfFrameWorks: [ - { name: 'Other', value: 'OTHER' }, { name: 'Gatsby', value: 'GATSBY' }, { name: 'NextJs', value: 'NEXTJS' }, { name: 'CRA (Create React App)', value: 'CRA' }, { name: 'CSR (Client-Side Rendered)', value: 'CSR' }, { name: 'Angular', value: 'ANGULAR' }, { name: 'VueJs', value: 'VUEJS' }, + { name: 'Other', value: 'OTHER' }, ], providerMapper: { GITPROVIDER: 'GitHub', From f53305cab1c056c42b2bc306a37b6e2678506ffc Mon Sep 17 00:00:00 2001 From: Aman Kumar Date: Fri, 19 Jul 2024 15:10:10 +0530 Subject: [PATCH 10/22] feat: error log formatting in auth login --- package-lock.json | 34 ++++----- packages/contentstack-audit/README.md | 2 +- packages/contentstack-audit/package.json | 2 +- packages/contentstack-auth/README.md | 2 +- packages/contentstack-auth/package.json | 2 +- .../src/commands/auth/login.ts | 16 +--- .../src/commands/auth/logout.ts | 16 +--- .../src/commands/auth/tokens/add.ts | 6 +- .../src/commands/auth/tokens/index.ts | 7 +- .../src/commands/auth/tokens/remove.ts | 7 +- .../src/commands/auth/whoami.ts | 7 +- packages/contentstack-bootstrap/README.md | 2 +- packages/contentstack-bootstrap/package.json | 2 +- packages/contentstack-branches/README.md | 2 +- packages/contentstack-branches/package.json | 2 +- packages/contentstack-bulk-publish/README.md | 2 +- .../contentstack-bulk-publish/package.json | 2 +- packages/contentstack-clone/README.md | 2 +- packages/contentstack-clone/package.json | 2 +- packages/contentstack-command/package.json | 2 +- packages/contentstack-config/README.md | 2 +- packages/contentstack-config/package.json | 2 +- .../contentstack-export-to-csv/package.json | 2 +- packages/contentstack-export/README.md | 2 +- packages/contentstack-export/package.json | 2 +- packages/contentstack-import/README.md | 2 +- packages/contentstack-import/package.json | 2 +- packages/contentstack-launch/package.json | 2 +- packages/contentstack-migrate-rte/README.md | 2 +- .../contentstack-migrate-rte/package.json | 2 +- packages/contentstack-migration/README.md | 2 +- packages/contentstack-migration/package.json | 2 +- packages/contentstack-seed/package.json | 2 +- packages/contentstack-utilities/package.json | 2 +- .../contentstack-utilities/src/helpers.ts | 74 +++++++++++++++---- packages/contentstack/README.md | 10 ++- packages/contentstack/package.json | 2 +- pnpm-lock.yaml | 32 ++++---- 38 files changed, 150 insertions(+), 115 deletions(-) diff --git a/package-lock.json b/package-lock.json index 8a925b58a8..88ec7dfe2e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -24914,7 +24914,7 @@ "@contentstack/cli-config": "~1.6.4", "@contentstack/cli-launch": "~1.0.19", "@contentstack/cli-migration": "~1.6.0", - "@contentstack/cli-utilities": "~1.6.3", + "@contentstack/cli-utilities": "~1.7.0", "@contentstack/management": "~1.15.3", "@oclif/core": "^3.26.5", "@oclif/plugin-help": "^5", @@ -24968,7 +24968,7 @@ "license": "MIT", "dependencies": { "@contentstack/cli-command": "~1.2.18", - "@contentstack/cli-utilities": "~1.6.3", + "@contentstack/cli-utilities": "~1.7.0", "@oclif/plugin-help": "^5", "@oclif/plugin-plugins": "^5.0.0", "chalk": "^4.1.2", @@ -25258,7 +25258,7 @@ "license": "MIT", "dependencies": { "@contentstack/cli-command": "~1.2.18", - "@contentstack/cli-utilities": "~1.6.3", + "@contentstack/cli-utilities": "~1.7.0", "chalk": "^4.0.0", "debug": "^4.1.1", "inquirer": "8.2.4", @@ -25300,7 +25300,7 @@ "dependencies": { "@contentstack/cli-cm-seed": "~1.7.6", "@contentstack/cli-command": "~1.2.18", - "@contentstack/cli-utilities": "~1.6.3", + "@contentstack/cli-utilities": "~1.7.0", "inquirer": "8.2.4", "mkdirp": "^1.0.4", "tar": "^6.2.1 " @@ -25378,7 +25378,7 @@ "license": "MIT", "dependencies": { "@contentstack/cli-command": "~1.2.18", - "@contentstack/cli-utilities": "~1.6.3", + "@contentstack/cli-utilities": "~1.7.0", "@oclif/core": "^3.26.5", "async": "^3.2.4", "big-json": "^3.2.0", @@ -25427,7 +25427,7 @@ "license": "MIT", "dependencies": { "@contentstack/cli-command": "~1.2.18", - "@contentstack/cli-utilities": "~1.6.3", + "@contentstack/cli-utilities": "~1.7.0", "bluebird": "^3.7.2", "chalk": "^4.1.2", "dotenv": "^16.1.4", @@ -25467,7 +25467,7 @@ "@contentstack/cli-cm-export": "~1.11.5", "@contentstack/cli-cm-import": "~1.16.0", "@contentstack/cli-command": "~1.2.18", - "@contentstack/cli-utilities": "~1.6.3", + "@contentstack/cli-utilities": "~1.7.0", "async": "^3.2.4", "chalk": "^4.1.0", "child_process": "^1.0.2", @@ -25574,7 +25574,7 @@ "version": "1.2.18", "license": "MIT", "dependencies": { - "@contentstack/cli-utilities": "~1.6.3", + "@contentstack/cli-utilities": "~1.7.0", "contentstack": "^3.10.1" }, "devDependencies": { @@ -25649,7 +25649,7 @@ "license": "MIT", "dependencies": { "@contentstack/cli-command": "~1.2.18", - "@contentstack/cli-utilities": "~1.6.3", + "@contentstack/cli-utilities": "~1.7.0", "chalk": "^4.0.0", "debug": "^4.1.1", "inquirer": "8.2.4", @@ -26034,7 +26034,7 @@ "license": "MIT", "dependencies": { "@contentstack/cli-command": "~1.2.18", - "@contentstack/cli-utilities": "~1.6.3", + "@contentstack/cli-utilities": "~1.7.0", "@oclif/core": "^3.26.5", "async": "^3.2.4", "big-json": "^3.2.0", @@ -26084,7 +26084,7 @@ "license": "MIT", "dependencies": { "@contentstack/cli-command": "~1.2.18", - "@contentstack/cli-utilities": "~1.6.3", + "@contentstack/cli-utilities": "~1.7.0", "chalk": "^4.1.0", "fast-csv": "^4.3.6", "inquirer": "8.2.4", @@ -26585,7 +26585,7 @@ "dependencies": { "@contentstack/cli-audit": "~1.6.3", "@contentstack/cli-command": "~1.2.18", - "@contentstack/cli-utilities": "~1.6.3", + "@contentstack/cli-utilities": "~1.7.0", "@contentstack/management": "~1.15.3", "@oclif/core": "^3.26.5", "big-json": "^3.2.0", @@ -26699,7 +26699,7 @@ "dependencies": { "@apollo/client": "^3.7.9", "@contentstack/cli-command": "~1.2.18", - "@contentstack/cli-utilities": "~1.6.3", + "@contentstack/cli-utilities": "~1.7.0", "@oclif/core": "^3.26.5", "@oclif/plugin-help": "^5", "@oclif/plugin-plugins": "^5.0.0", @@ -26996,7 +26996,7 @@ "license": "MIT", "dependencies": { "@contentstack/cli-command": "~1.2.18", - "@contentstack/cli-utilities": "~1.6.3", + "@contentstack/cli-utilities": "~1.7.0", "@contentstack/json-rte-serializer": "~2.0.4", "chalk": "^4.1.2", "collapse-whitespace": "^1.1.7", @@ -27035,7 +27035,7 @@ "license": "MIT", "dependencies": { "@contentstack/cli-command": "~1.2.18", - "@contentstack/cli-utilities": "~1.6.3", + "@contentstack/cli-utilities": "~1.7.0", "async": "^3.2.4", "callsites": "^3.1.0", "cardinal": "^2.1.1", @@ -27069,7 +27069,7 @@ "dependencies": { "@contentstack/cli-cm-import": "~1.16.0", "@contentstack/cli-command": "~1.2.18", - "@contentstack/cli-utilities": "~1.6.3", + "@contentstack/cli-utilities": "~1.7.0", "inquirer": "8.2.4", "mkdirp": "^1.0.4", "tar": "^6.1.13", @@ -27145,7 +27145,7 @@ }, "packages/contentstack-utilities": { "name": "@contentstack/cli-utilities", - "version": "1.6.3", + "version": "1.7.0", "license": "MIT", "dependencies": { "@contentstack/management": "~1.15.3", diff --git a/packages/contentstack-audit/README.md b/packages/contentstack-audit/README.md index 4bf303665c..8c558bd449 100644 --- a/packages/contentstack-audit/README.md +++ b/packages/contentstack-audit/README.md @@ -19,7 +19,7 @@ $ npm install -g @contentstack/cli-audit $ csdx COMMAND running command... $ csdx (--version|-v) -@contentstack/cli-audit/1.6.3 darwin-arm64 node-v22.2.0 +@contentstack/cli-audit/1.6.3 darwin-arm64 node-v18.20.2 $ csdx --help [COMMAND] USAGE $ csdx COMMAND diff --git a/packages/contentstack-audit/package.json b/packages/contentstack-audit/package.json index a9efc50bb6..8d28d9a950 100644 --- a/packages/contentstack-audit/package.json +++ b/packages/contentstack-audit/package.json @@ -19,7 +19,7 @@ ], "dependencies": { "@contentstack/cli-command": "~1.2.18", - "@contentstack/cli-utilities": "~1.6.3", + "@contentstack/cli-utilities": "~1.7.0", "@oclif/plugin-help": "^5", "@oclif/plugin-plugins": "^5.0.0", "chalk": "^4.1.2", diff --git a/packages/contentstack-auth/README.md b/packages/contentstack-auth/README.md index e2a9630df0..0e2b53b7b6 100644 --- a/packages/contentstack-auth/README.md +++ b/packages/contentstack-auth/README.md @@ -18,7 +18,7 @@ $ npm install -g @contentstack/cli-auth $ csdx COMMAND running command... $ csdx (--version) -@contentstack/cli-auth/1.3.19 darwin-arm64 node-v22.2.0 +@contentstack/cli-auth/1.3.19 darwin-arm64 node-v18.20.2 $ csdx --help [COMMAND] USAGE $ csdx COMMAND diff --git a/packages/contentstack-auth/package.json b/packages/contentstack-auth/package.json index ae2d91c4f3..ea1f4529b1 100644 --- a/packages/contentstack-auth/package.json +++ b/packages/contentstack-auth/package.json @@ -23,7 +23,7 @@ }, "dependencies": { "@contentstack/cli-command": "~1.2.18", - "@contentstack/cli-utilities": "~1.6.3", + "@contentstack/cli-utilities": "~1.7.0", "chalk": "^4.0.0", "debug": "^4.1.1", "inquirer": "8.2.4", diff --git a/packages/contentstack-auth/src/commands/auth/login.ts b/packages/contentstack-auth/src/commands/auth/login.ts index f75de6439d..cae77fb6e6 100644 --- a/packages/contentstack-auth/src/commands/auth/login.ts +++ b/packages/contentstack-auth/src/commands/auth/login.ts @@ -5,7 +5,8 @@ import { authHandler as oauthHandler, flags, managementSDKClient, - FlagInput + FlagInput, + formatError } from '@contentstack/cli-utilities'; import { User } from '../../interfaces'; import { authHandler, interactive } from '../../utils'; @@ -64,18 +65,7 @@ export default class LoginCommand extends BaseCommand { await this.login(username, password); } } catch (error) { - let errorMessage = ''; - if (error) { - if (error.message) { - if (error.message.message) { - errorMessage = error.message.message; - } else { - errorMessage = error.message; - } - } else { - errorMessage = error; - } - } + let errorMessage = formatError(error) || 'Something went wrong while logging. Please try again.'; this.logger.error('login failed', errorMessage); cliux.error('CLI_AUTH_LOGIN_FAILED'); cliux.error(errorMessage); diff --git a/packages/contentstack-auth/src/commands/auth/logout.ts b/packages/contentstack-auth/src/commands/auth/logout.ts index e03bc45ce0..0978eaa522 100644 --- a/packages/contentstack-auth/src/commands/auth/logout.ts +++ b/packages/contentstack-auth/src/commands/auth/logout.ts @@ -7,6 +7,7 @@ import { authHandler as oauthHandler, managementSDKClient, FlagInput, + formatError, } from '@contentstack/cli-utilities'; import { authHandler } from '../../utils'; @@ -54,7 +55,7 @@ export default class LogoutCommand extends BaseCommand { if (await oauthHandler.isAuthorisationTypeBasic()) { await authHandler.logout(configHandler.get('authtoken')); } else if (await oauthHandler.isAuthorisationTypeOAuth()) { - await oauthHandler.oauthLogout() + await oauthHandler.oauthLogout(); } cliux.loader(''); this.logger.info('successfully logged out'); @@ -63,18 +64,7 @@ export default class LogoutCommand extends BaseCommand { cliux.success('CLI_AUTH_LOGOUT_ALREADY'); } } catch (error) { - let errorMessage = ''; - if (error) { - if (error.message) { - if (error.message.message) { - errorMessage = error.message.message; - } else { - errorMessage = error.message; - } - } else { - errorMessage = error; - } - } + let errorMessage = formatError(error) || 'Something went wrong while logging out. Please try again.'; this.logger.error('Logout failed', errorMessage); cliux.print('CLI_AUTH_LOGOUT_FAILED', { color: 'yellow' }); diff --git a/packages/contentstack-auth/src/commands/auth/tokens/add.ts b/packages/contentstack-auth/src/commands/auth/tokens/add.ts index e1a1e5db52..9eec9c464c 100644 --- a/packages/contentstack-auth/src/commands/auth/tokens/add.ts +++ b/packages/contentstack-auth/src/commands/auth/tokens/add.ts @@ -8,6 +8,7 @@ import { HttpClient, messageHandler, Flags, + formatError, } from '@contentstack/cli-utilities'; import { askTokenType } from '../../../utils/interactive'; import { BaseCommand } from '../../../base-command'; @@ -159,9 +160,10 @@ export default class TokensAddCommand extends BaseCommand { static aliases = ['tokens']; @@ -52,9 +52,10 @@ export default class TokensListCommand extends BaseCommand { @@ -58,9 +58,10 @@ export default class TokensRemoveCommand extends BaseCommand { @@ -19,9 +19,10 @@ export default class WhoamiCommand extends BaseCommand { cliux.error('CLI_AUTH_WHOAMI_FAILED'); } } catch (error) { - this.logger.error('whoami error', error.message); + let errorMessage = formatError(error) || 'Something went wrong. Please try again.'; + this.logger.error('whoami error', errorMessage); cliux.print('CLI_AUTH_WHOAMI_FAILED', { color: 'yellow' }); - cliux.print(error.message, { color: 'red' }); + cliux.print(errorMessage, { color: 'red' }); } } } diff --git a/packages/contentstack-bootstrap/README.md b/packages/contentstack-bootstrap/README.md index 0df151fa40..3625c82bc6 100644 --- a/packages/contentstack-bootstrap/README.md +++ b/packages/contentstack-bootstrap/README.md @@ -15,7 +15,7 @@ $ npm install -g @contentstack/cli-cm-bootstrap $ csdx COMMAND running command... $ csdx (--version) -@contentstack/cli-cm-bootstrap/1.9.3 darwin-arm64 node-v22.2.0 +@contentstack/cli-cm-bootstrap/1.9.3 darwin-arm64 node-v18.20.2 $ csdx --help [COMMAND] USAGE $ csdx COMMAND diff --git a/packages/contentstack-bootstrap/package.json b/packages/contentstack-bootstrap/package.json index 6062e11816..4f3da7c16b 100644 --- a/packages/contentstack-bootstrap/package.json +++ b/packages/contentstack-bootstrap/package.json @@ -19,7 +19,7 @@ "dependencies": { "@contentstack/cli-cm-seed": "~1.7.6", "@contentstack/cli-command": "~1.2.18", - "@contentstack/cli-utilities": "~1.6.3", + "@contentstack/cli-utilities": "~1.7.0", "inquirer": "8.2.4", "mkdirp": "^1.0.4", "tar": "^6.2.1 " diff --git a/packages/contentstack-branches/README.md b/packages/contentstack-branches/README.md index d03133d56f..04daaeb6c5 100755 --- a/packages/contentstack-branches/README.md +++ b/packages/contentstack-branches/README.md @@ -37,7 +37,7 @@ $ npm install -g @contentstack/cli-cm-branches $ csdx COMMAND running command... $ csdx (--version) -@contentstack/cli-cm-branches/1.1.1 darwin-arm64 node-v22.2.0 +@contentstack/cli-cm-branches/1.1.1 darwin-arm64 node-v18.20.2 $ csdx --help [COMMAND] USAGE $ csdx COMMAND diff --git a/packages/contentstack-branches/package.json b/packages/contentstack-branches/package.json index 108557efc5..0f89f48a24 100644 --- a/packages/contentstack-branches/package.json +++ b/packages/contentstack-branches/package.json @@ -6,7 +6,7 @@ "bugs": "https://github.com/contentstack/cli/issues", "dependencies": { "@contentstack/cli-command": "~1.2.18", - "@contentstack/cli-utilities": "~1.6.3", + "@contentstack/cli-utilities": "~1.7.0", "@oclif/core": "^3.26.5", "async": "^3.2.4", "big-json": "^3.2.0", diff --git a/packages/contentstack-bulk-publish/README.md b/packages/contentstack-bulk-publish/README.md index a178ed7202..518043d7fa 100644 --- a/packages/contentstack-bulk-publish/README.md +++ b/packages/contentstack-bulk-publish/README.md @@ -18,7 +18,7 @@ $ npm install -g @contentstack/cli-cm-bulk-publish $ csdx COMMAND running command... $ csdx (--version) -@contentstack/cli-cm-bulk-publish/1.4.7 darwin-arm64 node-v22.2.0 +@contentstack/cli-cm-bulk-publish/1.4.7 darwin-arm64 node-v18.20.2 $ csdx --help [COMMAND] USAGE $ csdx COMMAND diff --git a/packages/contentstack-bulk-publish/package.json b/packages/contentstack-bulk-publish/package.json index 16467001eb..8bf0a96ef6 100644 --- a/packages/contentstack-bulk-publish/package.json +++ b/packages/contentstack-bulk-publish/package.json @@ -6,7 +6,7 @@ "bugs": "https://github.com/contentstack/cli/issues", "dependencies": { "@contentstack/cli-command": "~1.2.18", - "@contentstack/cli-utilities": "~1.6.3", + "@contentstack/cli-utilities": "~1.7.0", "bluebird": "^3.7.2", "chalk": "^4.1.2", "dotenv": "^16.1.4", diff --git a/packages/contentstack-clone/README.md b/packages/contentstack-clone/README.md index 0cb79450e2..e62a3abdde 100644 --- a/packages/contentstack-clone/README.md +++ b/packages/contentstack-clone/README.md @@ -16,7 +16,7 @@ $ npm install -g @contentstack/cli-cm-clone $ csdx COMMAND running command... $ csdx (--version) -@contentstack/cli-cm-clone/1.10.6 darwin-arm64 node-v22.2.0 +@contentstack/cli-cm-clone/1.10.6 darwin-arm64 node-v18.20.2 $ csdx --help [COMMAND] USAGE $ csdx COMMAND diff --git a/packages/contentstack-clone/package.json b/packages/contentstack-clone/package.json index 5152a90b71..7180cc168b 100644 --- a/packages/contentstack-clone/package.json +++ b/packages/contentstack-clone/package.json @@ -9,7 +9,7 @@ "@contentstack/cli-cm-export": "~1.11.5", "@contentstack/cli-cm-import": "~1.16.0", "@contentstack/cli-command": "~1.2.18", - "@contentstack/cli-utilities": "~1.6.3", + "@contentstack/cli-utilities": "~1.7.0", "async": "^3.2.4", "chalk": "^4.1.0", "child_process": "^1.0.2", diff --git a/packages/contentstack-command/package.json b/packages/contentstack-command/package.json index bb2cdb4dac..15a29446cc 100644 --- a/packages/contentstack-command/package.json +++ b/packages/contentstack-command/package.json @@ -17,7 +17,7 @@ "format": "eslint src/**/*.ts --fix" }, "dependencies": { - "@contentstack/cli-utilities": "~1.6.3", + "@contentstack/cli-utilities": "~1.7.0", "contentstack": "^3.10.1" }, "devDependencies": { diff --git a/packages/contentstack-config/README.md b/packages/contentstack-config/README.md index ccb077eca8..5796815432 100644 --- a/packages/contentstack-config/README.md +++ b/packages/contentstack-config/README.md @@ -18,7 +18,7 @@ $ npm install -g @contentstack/cli-config $ csdx COMMAND running command... $ csdx (--version) -@contentstack/cli-config/1.6.4 darwin-arm64 node-v22.2.0 +@contentstack/cli-config/1.6.4 darwin-arm64 node-v18.20.2 $ csdx --help [COMMAND] USAGE $ csdx COMMAND diff --git a/packages/contentstack-config/package.json b/packages/contentstack-config/package.json index 5512e1c03d..8b611f9199 100644 --- a/packages/contentstack-config/package.json +++ b/packages/contentstack-config/package.json @@ -22,7 +22,7 @@ }, "dependencies": { "@contentstack/cli-command": "~1.2.18", - "@contentstack/cli-utilities": "~1.6.3", + "@contentstack/cli-utilities": "~1.7.0", "chalk": "^4.0.0", "debug": "^4.1.1", "inquirer": "8.2.4", diff --git a/packages/contentstack-export-to-csv/package.json b/packages/contentstack-export-to-csv/package.json index 5003086004..723e9a6b9d 100644 --- a/packages/contentstack-export-to-csv/package.json +++ b/packages/contentstack-export-to-csv/package.json @@ -6,7 +6,7 @@ "bugs": "https://github.com/contentstack/cli/issues", "dependencies": { "@contentstack/cli-command": "~1.2.18", - "@contentstack/cli-utilities": "~1.6.3", + "@contentstack/cli-utilities": "~1.7.0", "chalk": "^4.1.0", "fast-csv": "^4.3.6", "inquirer": "8.2.4", diff --git a/packages/contentstack-export/README.md b/packages/contentstack-export/README.md index 1e649d5e37..ca2b111382 100755 --- a/packages/contentstack-export/README.md +++ b/packages/contentstack-export/README.md @@ -48,7 +48,7 @@ $ npm install -g @contentstack/cli-cm-export $ csdx COMMAND running command... $ csdx (--version) -@contentstack/cli-cm-export/1.11.5 darwin-arm64 node-v22.2.0 +@contentstack/cli-cm-export/1.11.5 darwin-arm64 node-v18.20.2 $ csdx --help [COMMAND] USAGE $ csdx COMMAND diff --git a/packages/contentstack-export/package.json b/packages/contentstack-export/package.json index e5ff711403..d6e6ed13c8 100644 --- a/packages/contentstack-export/package.json +++ b/packages/contentstack-export/package.json @@ -6,7 +6,7 @@ "bugs": "https://github.com/contentstack/cli/issues", "dependencies": { "@contentstack/cli-command": "~1.2.18", - "@contentstack/cli-utilities": "~1.6.3", + "@contentstack/cli-utilities": "~1.7.0", "@oclif/core": "^3.26.5", "async": "^3.2.4", "big-json": "^3.2.0", diff --git a/packages/contentstack-import/README.md b/packages/contentstack-import/README.md index 8097e79d47..e0f8d7e639 100644 --- a/packages/contentstack-import/README.md +++ b/packages/contentstack-import/README.md @@ -47,7 +47,7 @@ $ npm install -g @contentstack/cli-cm-import $ csdx COMMAND running command... $ csdx (--version) -@contentstack/cli-cm-import/1.16.0 darwin-arm64 node-v22.2.0 +@contentstack/cli-cm-import/1.16.0 darwin-arm64 node-v18.20.2 $ csdx --help [COMMAND] USAGE $ csdx COMMAND diff --git a/packages/contentstack-import/package.json b/packages/contentstack-import/package.json index 5b2133d6ef..0ded33bab2 100644 --- a/packages/contentstack-import/package.json +++ b/packages/contentstack-import/package.json @@ -7,7 +7,7 @@ "dependencies": { "@contentstack/cli-audit": "~1.6.3", "@contentstack/cli-command": "~1.2.18", - "@contentstack/cli-utilities": "~1.6.3", + "@contentstack/cli-utilities": "~1.7.0", "@contentstack/management": "~1.15.3", "@oclif/core": "^3.26.5", "big-json": "^3.2.0", diff --git a/packages/contentstack-launch/package.json b/packages/contentstack-launch/package.json index dead3d4eb9..18fb209e97 100755 --- a/packages/contentstack-launch/package.json +++ b/packages/contentstack-launch/package.json @@ -19,7 +19,7 @@ "dependencies": { "@apollo/client": "^3.7.9", "@contentstack/cli-command": "~1.2.18", - "@contentstack/cli-utilities": "~1.6.3", + "@contentstack/cli-utilities": "~1.7.0", "@oclif/core": "^3.26.5", "@oclif/plugin-help": "^5", "@oclif/plugin-plugins": "^5.0.0", diff --git a/packages/contentstack-migrate-rte/README.md b/packages/contentstack-migrate-rte/README.md index ffba51323c..02f39351ca 100644 --- a/packages/contentstack-migrate-rte/README.md +++ b/packages/contentstack-migrate-rte/README.md @@ -16,7 +16,7 @@ $ npm install -g @contentstack/cli-cm-migrate-rte $ csdx COMMAND running command... $ csdx (--version) -@contentstack/cli-cm-migrate-rte/1.4.17 darwin-arm64 node-v22.2.0 +@contentstack/cli-cm-migrate-rte/1.4.17 darwin-arm64 node-v18.20.2 $ csdx --help [COMMAND] USAGE $ csdx COMMAND diff --git a/packages/contentstack-migrate-rte/package.json b/packages/contentstack-migrate-rte/package.json index b831675508..0bab9bbd49 100644 --- a/packages/contentstack-migrate-rte/package.json +++ b/packages/contentstack-migrate-rte/package.json @@ -6,7 +6,7 @@ "bugs": "https://github.com/contentstack/cli/issues", "dependencies": { "@contentstack/cli-command": "~1.2.18", - "@contentstack/cli-utilities": "~1.6.3", + "@contentstack/cli-utilities": "~1.7.0", "@contentstack/json-rte-serializer": "~2.0.4", "collapse-whitespace": "^1.1.7", "chalk": "^4.1.2", diff --git a/packages/contentstack-migration/README.md b/packages/contentstack-migration/README.md index 8d123bb97b..ac90017097 100644 --- a/packages/contentstack-migration/README.md +++ b/packages/contentstack-migration/README.md @@ -21,7 +21,7 @@ $ npm install -g @contentstack/cli-migration $ csdx COMMAND running command... $ csdx (--version) -@contentstack/cli-migration/1.6.0 darwin-arm64 node-v22.2.0 +@contentstack/cli-migration/1.6.0 darwin-arm64 node-v18.20.2 $ csdx --help [COMMAND] USAGE $ csdx COMMAND diff --git a/packages/contentstack-migration/package.json b/packages/contentstack-migration/package.json index 7e2da837a0..60d1a666fb 100644 --- a/packages/contentstack-migration/package.json +++ b/packages/contentstack-migration/package.json @@ -5,7 +5,7 @@ "bugs": "https://github.com/contentstack/cli/issues", "dependencies": { "@contentstack/cli-command": "~1.2.18", - "@contentstack/cli-utilities": "~1.6.3", + "@contentstack/cli-utilities": "~1.7.0", "async": "^3.2.4", "callsites": "^3.1.0", "cardinal": "^2.1.1", diff --git a/packages/contentstack-seed/package.json b/packages/contentstack-seed/package.json index 6ab898fbdc..9058a6a2d9 100644 --- a/packages/contentstack-seed/package.json +++ b/packages/contentstack-seed/package.json @@ -7,7 +7,7 @@ "dependencies": { "@contentstack/cli-cm-import": "~1.16.0", "@contentstack/cli-command": "~1.2.18", - "@contentstack/cli-utilities": "~1.6.3", + "@contentstack/cli-utilities": "~1.7.0", "inquirer": "8.2.4", "mkdirp": "^1.0.4", "tar": "^6.1.13", diff --git a/packages/contentstack-utilities/package.json b/packages/contentstack-utilities/package.json index 4ea191000a..ba45e8c120 100644 --- a/packages/contentstack-utilities/package.json +++ b/packages/contentstack-utilities/package.json @@ -1,6 +1,6 @@ { "name": "@contentstack/cli-utilities", - "version": "1.6.3", + "version": "1.7.0", "description": "Utilities for contentstack projects", "main": "lib/index.js", "types": "lib/index.d.ts", diff --git a/packages/contentstack-utilities/src/helpers.ts b/packages/contentstack-utilities/src/helpers.ts index 4fe9289138..656be1b44c 100644 --- a/packages/contentstack-utilities/src/helpers.ts +++ b/packages/contentstack-utilities/src/helpers.ts @@ -1,4 +1,4 @@ -import { checkSync } from "recheck"; +import { checkSync } from 'recheck'; import authHandler from './auth-handler'; import { HttpClient, cliux, configHandler } from '.'; export const isAuthenticated = () => authHandler.isAuthenticated(); @@ -16,16 +16,16 @@ export const isManagementTokenValid = async (stackAPIKey, managementToken) => { try { const response = (await httpClient.get(`${configHandler.get('region').cma}/v3/environments?limit=1`))?.data; if (response?.environments) { - return { valid: true } + return { valid: true }; } else if (response?.error_code) { return { valid: false, message: response.error_message }; } else { - throw typeof response === "string" ? response : ""; + throw typeof response === 'string' ? response : ''; } } catch (error) { return { valid: 'failedToCheck', message: `Failed to check the validity of the Management token. ${error}` }; } -} +}; export const createDeveloperHubUrl = (developerHubBaseUrl: string): string => { developerHubBaseUrl = developerHubBaseUrl?.replace('api', 'developerhub-api'); @@ -41,12 +41,9 @@ export const createDeveloperHubUrl = (developerHubBaseUrl: string): string => { export const validatePath = (input: string) => { const pattern = /[*$%#<>{}!&?]/g; if (pattern.test(input)) { - cliux.print( - `\nPlease add a directory path without any of the special characters: (*,&,{,},[,],$,%,<,>,?,!)`, - { - color: 'yellow', - }, - ); + cliux.print(`\nPlease add a directory path without any of the special characters: (*,&,{,},[,],$,%,<,>,?,!)`, { + color: 'yellow', + }); return false; } return true; @@ -55,14 +52,65 @@ export const validatePath = (input: string) => { // To escape special characters in a string export const escapeRegExp = (str: string) => str?.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); -// To remove the relative path +// To remove the relative path export const sanitizePath = (str: string) => str?.replace(/^(\.\.(\/|\\|$))+/, ''); -// To validate the UIDs of assets +// To validate the UIDs of assets export const validateUids = (uid) => /^[a-zA-Z0-9]+$/.test(uid); // Validate File name export const validateFileName = (fileName) => /^[a-zA-Z0-9-_\.]+$/.test(fileName); // Validate Regex for ReDDos -export const validateRegex = (str) => checkSync(str, ""); \ No newline at end of file +export const validateRegex = (str) => checkSync(str, ''); + +export const formatError = function (error: any) { + let parsedError: any; + + // Parse the error + try { + if (typeof error === 'string') { + parsedError = JSON.parse(error); + } else if (typeof error?.message === 'string') { + parsedError = JSON.parse(error.message); + } else { + parsedError = error; + } + } catch (e) { + parsedError = error; + } + + // Determine the error message + let message = parsedError.errorMessage || parsedError.error_message || parsedError.message || parsedError; + if (typeof message === 'object') { + message = JSON.stringify(message); + } + + // If message is in JSON format, parse it to extract the actual message string + try { + const parsedMessage = JSON.parse(message); + if (typeof parsedMessage === 'object') { + message = parsedMessage?.message || message; + } + } catch (e) { + // message is not in JSON format, no need to parse + } + + // Append detailed error information if available + if (parsedError.errors && Object.keys(parsedError.errors).length > 0) { + const entityNames: { [key: string]: string } = { + authorization: 'Management Token', + api_key: 'Stack API key', + uid: 'Content Type', + access_token: 'Delivery Token', + }; + + message += + ' ' + + Object.entries(parsedError.errors) + .map(([key, value]) => `${entityNames[key] || key} ${value}`) + .join(' '); + } + + return message; +}; diff --git a/packages/contentstack/README.md b/packages/contentstack/README.md index 5c9156e863..88d8fd3696 100644 --- a/packages/contentstack/README.md +++ b/packages/contentstack/README.md @@ -18,7 +18,7 @@ $ npm install -g @contentstack/cli $ csdx COMMAND running command... $ csdx (--version|-v) -@contentstack/cli/1.21.0 darwin-arm64 node-v22.2.0 +@contentstack/cli/1.21.0 darwin-arm64 node-v18.20.2 $ csdx --help [COMMAND] USAGE $ csdx COMMAND @@ -3220,8 +3220,9 @@ Launch related operations ``` USAGE - $ csdx launch [--type GitHub|FileUpload] [--framework Gatsby|NextJs|Other] [--org ] [-n ] - [-e ] [--branch ] [--build-command ] [--out-dir ] + $ csdx launch [--type GitHub|FileUpload] [--framework Gatsby|NextJs|CRA (Create React App)|CSR + (Client-Side Rendered)|Angular|VueJs|Other] [--org ] [-n ] [-e ] [--branch ] + [--build-command ] [--out-dir ] FLAGS -e, --environment= [Optional] Environment name for the Launch project @@ -3229,7 +3230,8 @@ FLAGS --branch= [Optional] GitHub branch name --build-command= [Optional] Build Command --framework=