From bc39d2859a0156a5ce73180a0de7b818c683f808 Mon Sep 17 00:00:00 2001 From: raj pandey Date: Mon, 22 Apr 2024 17:38:56 +0530 Subject: [PATCH 1/3] added new script for update of references used in entries --- package-lock.json | 305 ++++++++++-------- .../05-Update-reference-entry-from-mapper.js | 138 ++++++++ packages/contentstack-migration/package.json | 2 +- packages/contentstack/package.json | 4 +- pnpm-lock.yaml | 2 +- 5 files changed, 311 insertions(+), 140 deletions(-) create mode 100644 packages/contentstack-migration/examples/05-Update-reference-entry-from-mapper.js diff --git a/package-lock.json b/package-lock.json index 2f5bb84bdb..7f8d89c242 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1998,15 +1998,15 @@ } }, "node_modules/@oclif/plugin-plugins": { - "version": "5.0.11", - "resolved": "https://registry.npmjs.org/@oclif/plugin-plugins/-/plugin-plugins-5.0.11.tgz", - "integrity": "sha512-es+IMNI97Jw+EX25r9ejrOph9R/8FbNXmWrH/NnhUJ3lNDpeMPM8njP4ovHYJi2+ta2VTHDxhQFNRDlNnUiyOw==", + "version": "5.0.13", + "resolved": "https://registry.npmjs.org/@oclif/plugin-plugins/-/plugin-plugins-5.0.13.tgz", + "integrity": "sha512-BNjT/O/50yw816qUIVZD0zmLklGhXqCnmxD2msGCrWJcsmylXkORe3BRF0ZJXAhf+fpO+kIJN/Tl42RUm/NX2Q==", "hasShrinkwrap": true, "dependencies": { - "@oclif/core": "^3.26.2", + "@oclif/core": "^3.26.4", "chalk": "^5.3.0", "debug": "^4.3.4", - "npm": "10.5.0", + "npm": "10.5.2", "npm-package-arg": "^11.0.2", "npm-run-path": "^5.3.0", "semver": "^7.6.0", @@ -2053,9 +2053,9 @@ } }, "node_modules/@oclif/plugin-plugins/node_modules/@oclif/core": { - "version": "3.26.2", - "resolved": "https://registry.npmjs.org/@oclif/core/-/core-3.26.2.tgz", - "integrity": "sha512-Gpn21jKjcOx0TecI1wLJrY/65jtgJx5f1GzTc81oKvEpKes1b3Li2SMZygRaWRpcQ3wjN0d7lTPi8WwLsmTBjA==", + "version": "3.26.4", + "resolved": "https://registry.npmjs.org/@oclif/core/-/core-3.26.4.tgz", + "integrity": "sha512-ntfo2ut7enNtAn/jB/dryMUPBM2Fh8Fydmi3k/Ybo6lCGU/hmsPFkBRjCEJAQMyNkK2yVZARaWogdOrcVgFz+w==", "license": "MIT", "dependencies": { "@types/cli-progress": "^3.11.5", @@ -2067,7 +2067,7 @@ "cli-progress": "^3.12.0", "color": "^4.2.3", "debug": "^4.3.4", - "ejs": "^3.1.9", + "ejs": "^3.1.10", "get-package-type": "^0.1.0", "globby": "^11.1.0", "hyperlinker": "^1.0.0", @@ -2461,9 +2461,9 @@ } }, "node_modules/@oclif/plugin-plugins/node_modules/ejs": { - "version": "3.1.9", - "resolved": "https://registry.npmjs.org/ejs/-/ejs-3.1.9.tgz", - "integrity": "sha512-rC+QVNMJWv+MtPgkt0y+0rVEIdbtxVADApW9JXrUVlzHetgcyczP/E7DJmWJ4fJCZF2cPcBk0laWO9ZHMG3DmQ==", + "version": "3.1.10", + "resolved": "https://registry.npmjs.org/ejs/-/ejs-3.1.10.tgz", + "integrity": "sha512-UeJmFfOrAQS8OJWPZ4qtgHyWExa088/MtK5UEyoJGFH67cDEXkZSviOiKRCZ4Xij0zxI3JECgYs3oKx+AizQBA==", "license": "Apache-2.0", "dependencies": { "jake": "^10.8.5" @@ -2819,9 +2819,9 @@ } }, "node_modules/@oclif/plugin-plugins/node_modules/npm": { - "version": "10.5.0", - "resolved": "https://registry.npmjs.org/npm/-/npm-10.5.0.tgz", - "integrity": "sha512-Ejxwvfh9YnWVU2yA5FzoYLTW52vxHCz+MHrOFg9Cc8IFgF/6f5AGPAvb5WTay5DIUP1NIfN3VBZ0cLlGO0Ys+A==", + "version": "10.5.2", + "resolved": "https://registry.npmjs.org/npm/-/npm-10.5.2.tgz", + "integrity": "sha512-cHVG7QEJwJdZyOrK0dKX5uf3R5Fd0E8AcmSES1jLtO52UT1enUKZ96Onw/xwq4CbrTZEnDuu2Vf9kCQh/Sd12w==", "bundleDependencies": [ "@isaacs/string-locale-compare", "@npmcli/arborist", @@ -2830,6 +2830,7 @@ "@npmcli/map-workspaces", "@npmcli/package-json", "@npmcli/promise-spawn", + "@npmcli/redact", "@npmcli/run-script", "@sigstore/tuf", "abbrev", @@ -2907,27 +2908,28 @@ "@npmcli/arborist": "^7.2.1", "@npmcli/config": "^8.0.2", "@npmcli/fs": "^3.1.0", - "@npmcli/map-workspaces": "^3.0.4", - "@npmcli/package-json": "^5.0.0", + "@npmcli/map-workspaces": "^3.0.6", + "@npmcli/package-json": "^5.0.2", "@npmcli/promise-spawn": "^7.0.1", + "@npmcli/redact": "^1.1.0", "@npmcli/run-script": "^7.0.4", - "@sigstore/tuf": "^2.3.1", + "@sigstore/tuf": "^2.3.2", "abbrev": "^2.0.0", "archy": "~1.0.0", "cacache": "^18.0.2", "chalk": "^5.3.0", "ci-info": "^4.0.0", "cli-columns": "^4.0.0", - "cli-table3": "^0.6.3", + "cli-table3": "^0.6.4", "columnify": "^1.6.0", "fastest-levenshtein": "^1.0.16", "fs-minipass": "^3.0.3", - "glob": "^10.3.10", + "glob": "^10.3.12", "graceful-fs": "^4.2.11", "hosted-git-info": "^7.0.1", - "ini": "^4.1.1", - "init-package-json": "^6.0.0", - "is-cidr": "^5.0.3", + "ini": "^4.1.2", + "init-package-json": "^6.0.2", + "is-cidr": "^5.0.5", "json-parse-even-better-errors": "^3.0.1", "libnpmaccess": "^8.0.1", "libnpmdiff": "^6.0.3", @@ -2941,11 +2943,11 @@ "libnpmteam": "^6.0.0", "libnpmversion": "^5.0.1", "make-fetch-happen": "^13.0.0", - "minimatch": "^9.0.3", + "minimatch": "^9.0.4", "minipass": "^7.0.4", "minipass-pipeline": "^1.2.4", "ms": "^2.1.2", - "node-gyp": "^10.0.1", + "node-gyp": "^10.1.0", "nopt": "^7.2.0", "normalize-package-data": "^6.0.0", "npm-audit-report": "^5.0.0", @@ -2953,7 +2955,7 @@ "npm-package-arg": "^11.0.1", "npm-pick-manifest": "^9.0.0", "npm-profile": "^9.0.0", - "npm-registry-fetch": "^16.1.0", + "npm-registry-fetch": "^16.2.0", "npm-user-validate": "^2.0.0", "npmlog": "^7.0.1", "p-map": "^4.0.0", @@ -2961,12 +2963,12 @@ "parse-conflict-json": "^3.0.1", "proc-log": "^3.0.0", "qrcode-terminal": "^0.12.0", - "read": "^2.1.0", + "read": "^3.0.1", "semver": "^7.6.0", - "spdx-expression-parse": "^3.0.1", + "spdx-expression-parse": "^4.0.0", "ssri": "^10.0.5", "supports-color": "^9.4.0", - "tar": "^6.2.0", + "tar": "^6.2.1", "text-table": "~0.2.0", "tiny-relative-date": "^1.3.0", "treeverse": "^3.0.0", @@ -3110,7 +3112,7 @@ "license": "ISC" }, "node_modules/@oclif/plugin-plugins/node_modules/npm/node_modules/@npmcli/agent": { - "version": "2.2.1", + "version": "2.2.2", "inBundle": true, "license": "ISC", "dependencies": { @@ -3118,14 +3120,14 @@ "http-proxy-agent": "^7.0.0", "https-proxy-agent": "^7.0.1", "lru-cache": "^10.0.1", - "socks-proxy-agent": "^8.0.1" + "socks-proxy-agent": "^8.0.3" }, "engines": { "node": "^16.14.0 || >=18.0.0" } }, "node_modules/@oclif/plugin-plugins/node_modules/npm/node_modules/@npmcli/arborist": { - "version": "7.4.0", + "version": "7.4.2", "inBundle": true, "license": "ISC", "dependencies": { @@ -3138,6 +3140,7 @@ "@npmcli/node-gyp": "^3.0.0", "@npmcli/package-json": "^5.0.0", "@npmcli/query": "^3.1.0", + "@npmcli/redact": "^1.1.0", "@npmcli/run-script": "^7.0.2", "bin-links": "^4.0.1", "cacache": "^18.0.0", @@ -3145,12 +3148,12 @@ "hosted-git-info": "^7.0.1", "json-parse-even-better-errors": "^3.0.0", "json-stringify-nice": "^1.1.4", - "minimatch": "^9.0.0", + "minimatch": "^9.0.4", "nopt": "^7.0.0", "npm-install-checks": "^6.2.0", "npm-package-arg": "^11.0.1", "npm-pick-manifest": "^9.0.0", - "npm-registry-fetch": "^16.0.0", + "npm-registry-fetch": "^16.2.0", "npmlog": "^7.0.1", "pacote": "^17.0.4", "parse-conflict-json": "^3.0.0", @@ -3171,13 +3174,13 @@ } }, "node_modules/@oclif/plugin-plugins/node_modules/npm/node_modules/@npmcli/config": { - "version": "8.2.0", + "version": "8.2.2", "inBundle": true, "license": "ISC", "dependencies": { "@npmcli/map-workspaces": "^3.0.2", "ci-info": "^4.0.0", - "ini": "^4.1.0", + "ini": "^4.1.2", "nopt": "^7.0.0", "proc-log": "^3.0.0", "read-package-json-fast": "^3.0.2", @@ -3225,7 +3228,7 @@ } }, "node_modules/@oclif/plugin-plugins/node_modules/npm/node_modules/@npmcli/git": { - "version": "5.0.4", + "version": "5.0.5", "inBundle": true, "license": "ISC", "dependencies": { @@ -3258,7 +3261,7 @@ } }, "node_modules/@oclif/plugin-plugins/node_modules/npm/node_modules/@npmcli/map-workspaces": { - "version": "3.0.4", + "version": "3.0.6", "inBundle": true, "license": "ISC", "dependencies": { @@ -3302,7 +3305,7 @@ } }, "node_modules/@oclif/plugin-plugins/node_modules/npm/node_modules/@npmcli/package-json": { - "version": "5.0.0", + "version": "5.0.2", "inBundle": true, "license": "ISC", "dependencies": { @@ -3340,6 +3343,14 @@ "node": "^14.17.0 || ^16.13.0 || >=18.0.0" } }, + "node_modules/@oclif/plugin-plugins/node_modules/npm/node_modules/@npmcli/redact": { + "version": "1.1.0", + "inBundle": true, + "license": "ISC", + "engines": { + "node": "^16.14.0 || >=18.0.0" + } + }, "node_modules/@oclif/plugin-plugins/node_modules/npm/node_modules/@npmcli/run-script": { "version": "7.0.4", "inBundle": true, @@ -3365,18 +3376,18 @@ } }, "node_modules/@oclif/plugin-plugins/node_modules/npm/node_modules/@sigstore/bundle": { - "version": "2.2.0", + "version": "2.3.1", "inBundle": true, "license": "Apache-2.0", "dependencies": { - "@sigstore/protobuf-specs": "^0.3.0" + "@sigstore/protobuf-specs": "^0.3.1" }, "engines": { "node": "^16.14.0 || >=18.0.0" } }, "node_modules/@oclif/plugin-plugins/node_modules/npm/node_modules/@sigstore/core": { - "version": "1.0.0", + "version": "1.1.0", "inBundle": true, "license": "Apache-2.0", "engines": { @@ -3384,21 +3395,21 @@ } }, "node_modules/@oclif/plugin-plugins/node_modules/npm/node_modules/@sigstore/protobuf-specs": { - "version": "0.3.0", + "version": "0.3.1", "inBundle": true, "license": "Apache-2.0", "engines": { - "node": "^14.17.0 || ^16.13.0 || >=18.0.0" + "node": "^16.14.0 || >=18.0.0" } }, "node_modules/@oclif/plugin-plugins/node_modules/npm/node_modules/@sigstore/sign": { - "version": "2.2.3", + "version": "2.3.0", "inBundle": true, "license": "Apache-2.0", "dependencies": { - "@sigstore/bundle": "^2.2.0", + "@sigstore/bundle": "^2.3.0", "@sigstore/core": "^1.0.0", - "@sigstore/protobuf-specs": "^0.3.0", + "@sigstore/protobuf-specs": "^0.3.1", "make-fetch-happen": "^13.0.0" }, "engines": { @@ -3406,7 +3417,7 @@ } }, "node_modules/@oclif/plugin-plugins/node_modules/npm/node_modules/@sigstore/tuf": { - "version": "2.3.1", + "version": "2.3.2", "inBundle": true, "license": "Apache-2.0", "dependencies": { @@ -3418,13 +3429,13 @@ } }, "node_modules/@oclif/plugin-plugins/node_modules/npm/node_modules/@sigstore/verify": { - "version": "1.1.0", + "version": "1.2.0", "inBundle": true, "license": "Apache-2.0", "dependencies": { - "@sigstore/bundle": "^2.2.0", - "@sigstore/core": "^1.0.0", - "@sigstore/protobuf-specs": "^0.3.0" + "@sigstore/bundle": "^2.3.1", + "@sigstore/core": "^1.1.0", + "@sigstore/protobuf-specs": "^0.3.1" }, "engines": { "node": "^16.14.0 || >=18.0.0" @@ -3459,7 +3470,7 @@ } }, "node_modules/@oclif/plugin-plugins/node_modules/npm/node_modules/agent-base": { - "version": "7.1.0", + "version": "7.1.1", "inBundle": true, "license": "MIT", "dependencies": { @@ -3538,11 +3549,14 @@ } }, "node_modules/@oclif/plugin-plugins/node_modules/npm/node_modules/binary-extensions": { - "version": "2.2.0", + "version": "2.3.0", "inBundle": true, "license": "MIT", "engines": { "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/@oclif/plugin-plugins/node_modules/npm/node_modules/brace-expansion": { @@ -3554,7 +3568,7 @@ } }, "node_modules/@oclif/plugin-plugins/node_modules/npm/node_modules/builtins": { - "version": "5.0.1", + "version": "5.1.0", "inBundle": true, "license": "MIT", "dependencies": { @@ -3617,7 +3631,7 @@ } }, "node_modules/@oclif/plugin-plugins/node_modules/npm/node_modules/cidr-regex": { - "version": "4.0.3", + "version": "4.0.5", "inBundle": true, "license": "BSD-2-Clause", "dependencies": { @@ -3648,7 +3662,7 @@ } }, "node_modules/@oclif/plugin-plugins/node_modules/npm/node_modules/cli-table3": { - "version": "0.6.3", + "version": "0.6.4", "inBundle": true, "license": "MIT", "dependencies": { @@ -3899,15 +3913,15 @@ } }, "node_modules/@oclif/plugin-plugins/node_modules/npm/node_modules/glob": { - "version": "10.3.10", + "version": "10.3.12", "inBundle": true, "license": "ISC", "dependencies": { "foreground-child": "^3.1.0", - "jackspeak": "^2.3.5", + "jackspeak": "^2.3.6", "minimatch": "^9.0.1", - "minipass": "^5.0.0 || ^6.0.2 || ^7.0.0", - "path-scurry": "^1.10.1" + "minipass": "^7.0.4", + "path-scurry": "^1.10.2" }, "bin": { "glob": "dist/esm/bin.mjs" @@ -3930,7 +3944,7 @@ "license": "ISC" }, "node_modules/@oclif/plugin-plugins/node_modules/npm/node_modules/hasown": { - "version": "2.0.1", + "version": "2.0.2", "inBundle": true, "license": "MIT", "dependencies": { @@ -4020,7 +4034,7 @@ } }, "node_modules/@oclif/plugin-plugins/node_modules/npm/node_modules/ini": { - "version": "4.1.1", + "version": "4.1.2", "inBundle": true, "license": "ISC", "engines": { @@ -4028,14 +4042,14 @@ } }, "node_modules/@oclif/plugin-plugins/node_modules/npm/node_modules/init-package-json": { - "version": "6.0.0", + "version": "6.0.2", "inBundle": true, "license": "ISC", "dependencies": { + "@npmcli/package-json": "^5.0.0", "npm-package-arg": "^11.0.0", "promzard": "^1.0.0", - "read": "^2.0.0", - "read-package-json": "^7.0.0", + "read": "^3.0.1", "semver": "^7.3.5", "validate-npm-package-license": "^3.0.4", "validate-npm-package-name": "^5.0.0" @@ -4073,11 +4087,11 @@ } }, "node_modules/@oclif/plugin-plugins/node_modules/npm/node_modules/is-cidr": { - "version": "5.0.3", + "version": "5.0.5", "inBundle": true, "license": "BSD-2-Clause", "dependencies": { - "cidr-regex": "4.0.3" + "cidr-regex": "^4.0.4" }, "engines": { "node": ">=14" @@ -4169,38 +4183,38 @@ "license": "MIT" }, "node_modules/@oclif/plugin-plugins/node_modules/npm/node_modules/libnpmaccess": { - "version": "8.0.2", + "version": "8.0.3", "inBundle": true, "license": "ISC", "dependencies": { "npm-package-arg": "^11.0.1", - "npm-registry-fetch": "^16.0.0" + "npm-registry-fetch": "^16.2.0" }, "engines": { "node": "^16.14.0 || >=18.0.0" } }, "node_modules/@oclif/plugin-plugins/node_modules/npm/node_modules/libnpmdiff": { - "version": "6.0.7", + "version": "6.0.9", "inBundle": true, "license": "ISC", "dependencies": { "@npmcli/arborist": "^7.2.1", "@npmcli/disparity-colors": "^3.0.0", "@npmcli/installed-package-contents": "^2.0.2", - "binary-extensions": "^2.2.0", + "binary-extensions": "^2.3.0", "diff": "^5.1.0", - "minimatch": "^9.0.0", + "minimatch": "^9.0.4", "npm-package-arg": "^11.0.1", "pacote": "^17.0.4", - "tar": "^6.2.0" + "tar": "^6.2.1" }, "engines": { "node": "^16.14.0 || >=18.0.0" } }, "node_modules/@oclif/plugin-plugins/node_modules/npm/node_modules/libnpmexec": { - "version": "7.0.8", + "version": "7.0.10", "inBundle": true, "license": "ISC", "dependencies": { @@ -4211,7 +4225,7 @@ "npmlog": "^7.0.1", "pacote": "^17.0.4", "proc-log": "^3.0.0", - "read": "^2.0.0", + "read": "^3.0.1", "read-package-json-fast": "^3.0.2", "semver": "^7.3.7", "walk-up-path": "^3.0.1" @@ -4221,7 +4235,7 @@ } }, "node_modules/@oclif/plugin-plugins/node_modules/npm/node_modules/libnpmfund": { - "version": "5.0.5", + "version": "5.0.7", "inBundle": true, "license": "ISC", "dependencies": { @@ -4232,31 +4246,31 @@ } }, "node_modules/@oclif/plugin-plugins/node_modules/npm/node_modules/libnpmhook": { - "version": "10.0.1", + "version": "10.0.2", "inBundle": true, "license": "ISC", "dependencies": { "aproba": "^2.0.0", - "npm-registry-fetch": "^16.0.0" + "npm-registry-fetch": "^16.2.0" }, "engines": { "node": "^16.14.0 || >=18.0.0" } }, "node_modules/@oclif/plugin-plugins/node_modules/npm/node_modules/libnpmorg": { - "version": "6.0.2", + "version": "6.0.3", "inBundle": true, "license": "ISC", "dependencies": { "aproba": "^2.0.0", - "npm-registry-fetch": "^16.0.0" + "npm-registry-fetch": "^16.2.0" }, "engines": { "node": "^16.14.0 || >=18.0.0" } }, "node_modules/@oclif/plugin-plugins/node_modules/npm/node_modules/libnpmpack": { - "version": "6.0.7", + "version": "6.0.9", "inBundle": true, "license": "ISC", "dependencies": { @@ -4270,14 +4284,14 @@ } }, "node_modules/@oclif/plugin-plugins/node_modules/npm/node_modules/libnpmpublish": { - "version": "9.0.4", + "version": "9.0.5", "inBundle": true, "license": "ISC", "dependencies": { "ci-info": "^4.0.0", "normalize-package-data": "^6.0.0", "npm-package-arg": "^11.0.1", - "npm-registry-fetch": "^16.0.0", + "npm-registry-fetch": "^16.2.0", "proc-log": "^3.0.0", "semver": "^7.3.7", "sigstore": "^2.2.0", @@ -4288,23 +4302,23 @@ } }, "node_modules/@oclif/plugin-plugins/node_modules/npm/node_modules/libnpmsearch": { - "version": "7.0.1", + "version": "7.0.2", "inBundle": true, "license": "ISC", "dependencies": { - "npm-registry-fetch": "^16.0.0" + "npm-registry-fetch": "^16.2.0" }, "engines": { "node": "^16.14.0 || >=18.0.0" } }, "node_modules/@oclif/plugin-plugins/node_modules/npm/node_modules/libnpmteam": { - "version": "6.0.1", + "version": "6.0.2", "inBundle": true, "license": "ISC", "dependencies": { "aproba": "^2.0.0", - "npm-registry-fetch": "^16.0.0" + "npm-registry-fetch": "^16.2.0" }, "engines": { "node": "^16.14.0 || >=18.0.0" @@ -4355,7 +4369,7 @@ } }, "node_modules/@oclif/plugin-plugins/node_modules/npm/node_modules/minimatch": { - "version": "9.0.3", + "version": "9.0.4", "inBundle": true, "license": "ISC", "dependencies": { @@ -4545,7 +4559,7 @@ } }, "node_modules/@oclif/plugin-plugins/node_modules/npm/node_modules/node-gyp": { - "version": "10.0.1", + "version": "10.1.0", "inBundle": true, "license": "MIT", "dependencies": { @@ -4685,10 +4699,11 @@ } }, "node_modules/@oclif/plugin-plugins/node_modules/npm/node_modules/npm-registry-fetch": { - "version": "16.1.0", + "version": "16.2.0", "inBundle": true, "license": "ISC", "dependencies": { + "@npmcli/redact": "^1.1.0", "make-fetch-happen": "^13.0.0", "minipass": "^7.0.2", "minipass-fetch": "^3.0.0", @@ -4790,11 +4805,11 @@ } }, "node_modules/@oclif/plugin-plugins/node_modules/npm/node_modules/path-scurry": { - "version": "1.10.1", + "version": "1.10.2", "inBundle": true, "license": "BlueOak-1.0.0", "dependencies": { - "lru-cache": "^9.1.1 || ^10.0.0", + "lru-cache": "^10.2.0", "minipass": "^5.0.0 || ^6.0.2 || ^7.0.0" }, "engines": { @@ -4805,7 +4820,7 @@ } }, "node_modules/@oclif/plugin-plugins/node_modules/npm/node_modules/postcss-selector-parser": { - "version": "6.0.15", + "version": "6.0.16", "inBundle": true, "license": "MIT", "dependencies": { @@ -4858,11 +4873,11 @@ } }, "node_modules/@oclif/plugin-plugins/node_modules/npm/node_modules/promzard": { - "version": "1.0.0", + "version": "1.0.1", "inBundle": true, "license": "ISC", "dependencies": { - "read": "^2.0.0" + "read": "^3.0.1" }, "engines": { "node": "^14.17.0 || ^16.13.0 || >=18.0.0" @@ -4876,11 +4891,11 @@ } }, "node_modules/@oclif/plugin-plugins/node_modules/npm/node_modules/read": { - "version": "2.1.0", + "version": "3.0.1", "inBundle": true, "license": "ISC", "dependencies": { - "mute-stream": "~1.0.0" + "mute-stream": "^1.0.0" }, "engines": { "node": "^14.17.0 || ^16.13.0 || >=18.0.0" @@ -4995,16 +5010,16 @@ } }, "node_modules/@oclif/plugin-plugins/node_modules/npm/node_modules/sigstore": { - "version": "2.2.2", + "version": "2.3.0", "inBundle": true, "license": "Apache-2.0", "dependencies": { - "@sigstore/bundle": "^2.2.0", + "@sigstore/bundle": "^2.3.1", "@sigstore/core": "^1.0.0", - "@sigstore/protobuf-specs": "^0.3.0", - "@sigstore/sign": "^2.2.3", + "@sigstore/protobuf-specs": "^0.3.1", + "@sigstore/sign": "^2.3.0", "@sigstore/tuf": "^2.3.1", - "@sigstore/verify": "^1.1.0" + "@sigstore/verify": "^1.2.0" }, "engines": { "node": "^16.14.0 || >=18.0.0" @@ -5020,7 +5035,7 @@ } }, "node_modules/@oclif/plugin-plugins/node_modules/npm/node_modules/socks": { - "version": "2.8.0", + "version": "2.8.3", "inBundle": true, "license": "MIT", "dependencies": { @@ -5028,16 +5043,16 @@ "smart-buffer": "^4.2.0" }, "engines": { - "node": ">= 16.0.0", + "node": ">= 10.0.0", "npm": ">= 3.0.0" } }, "node_modules/@oclif/plugin-plugins/node_modules/npm/node_modules/socks-proxy-agent": { - "version": "8.0.2", + "version": "8.0.3", "inBundle": true, "license": "MIT", "dependencies": { - "agent-base": "^7.0.2", + "agent-base": "^7.1.1", "debug": "^4.3.4", "socks": "^2.7.1" }, @@ -5054,13 +5069,22 @@ "spdx-license-ids": "^3.0.0" } }, + "node_modules/@oclif/plugin-plugins/node_modules/npm/node_modules/spdx-correct/node_modules/spdx-expression-parse": { + "version": "3.0.1", + "inBundle": true, + "license": "MIT", + "dependencies": { + "spdx-exceptions": "^2.1.0", + "spdx-license-ids": "^3.0.0" + } + }, "node_modules/@oclif/plugin-plugins/node_modules/npm/node_modules/spdx-exceptions": { "version": "2.5.0", "inBundle": true, "license": "CC-BY-3.0" }, "node_modules/@oclif/plugin-plugins/node_modules/npm/node_modules/spdx-expression-parse": { - "version": "3.0.1", + "version": "4.0.0", "inBundle": true, "license": "MIT", "dependencies": { @@ -5146,7 +5170,7 @@ } }, "node_modules/@oclif/plugin-plugins/node_modules/npm/node_modules/tar": { - "version": "6.2.0", + "version": "6.2.1", "inBundle": true, "license": "ISC", "dependencies": { @@ -5258,6 +5282,15 @@ "spdx-expression-parse": "^3.0.0" } }, + "node_modules/@oclif/plugin-plugins/node_modules/npm/node_modules/validate-npm-package-license/node_modules/spdx-expression-parse": { + "version": "3.0.1", + "inBundle": true, + "license": "MIT", + "dependencies": { + "spdx-exceptions": "^2.1.0", + "spdx-license-ids": "^3.0.0" + } + }, "node_modules/@oclif/plugin-plugins/node_modules/npm/node_modules/validate-npm-package-name": { "version": "5.0.0", "inBundle": true, @@ -8018,9 +8051,9 @@ } }, "node_modules/aws-sdk": { - "version": "2.1602.0", - "resolved": "https://registry.npmjs.org/aws-sdk/-/aws-sdk-2.1602.0.tgz", - "integrity": "sha512-DJ3JOqa8PHmwrZirIFbzpa4hlBvL/jz3RulNQL4FmzNX6IANiUKUTR4zw6tU9Sdt48YpsL0+xIyuBuxKmcLz7Q==", + "version": "2.1603.0", + "resolved": "https://registry.npmjs.org/aws-sdk/-/aws-sdk-2.1603.0.tgz", + "integrity": "sha512-AB54LyTODyiTKdtUzE0LzhnPbumYH3KhDstje8i4KfeBSGCeszTgq89YfOVpSy5twfu9WpsJ2cHOxlrlXn9cpg==", "dev": true, "hasInstallScript": true, "dependencies": { @@ -8764,9 +8797,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001611", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001611.tgz", - "integrity": "sha512-19NuN1/3PjA3QI8Eki55N8my4LzfkMCRLgCVfrl/slbSAchQfV0+GwjPrK3rq37As4UCLlM/DHajbKkAqbv92Q==", + "version": "1.0.30001612", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001612.tgz", + "integrity": "sha512-lFgnZ07UhaCcsSZgWW0K5j4e69dK1u/ltrL9lTUiFOwNHs12S3UMIEYgBV0Z6C6hRDev7iRnMzzYmKabYdXF9g==", "dev": true, "funding": [ { @@ -9427,9 +9460,9 @@ } }, "node_modules/commander": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/commander/-/commander-4.1.1.tgz", - "integrity": "sha512-NOKm8xhkzAjzFx8B2v5OAHT+u5pRQc2UCa2Vq9jYL/31o2wi9mxBA7LIFs3sV5VSC49z6pEhfbMULvShKj26WA==", + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/commander/-/commander-6.2.1.tgz", + "integrity": "sha512-U7VdrJFnJgo4xjrHpTzu0yrHPGImdsmD95ZlgYSEajAn2JKzDhDTPG9kBTefmObL2w/ngeZnilk+OV9CG3d7UA==", "engines": { "node": ">= 6" } @@ -10208,12 +10241,12 @@ } }, "node_modules/dot-object": { - "version": "2.1.4", - "resolved": "https://registry.npmjs.org/dot-object/-/dot-object-2.1.4.tgz", - "integrity": "sha512-7FXnyyCLFawNYJ+NhkqyP9Wd2yzuo+7n9pGiYpkmXCTYa8Ci2U0eUNDVg5OuO5Pm6aFXI2SWN8/N/w7SJWu1WA==", + "version": "2.1.5", + "resolved": "https://registry.npmjs.org/dot-object/-/dot-object-2.1.5.tgz", + "integrity": "sha512-xHF8EP4XH/Ba9fvAF2LDd5O3IITVolerVV6xvkxoM8zlGEiCUrggpAnHyOoKJKCrhvPcGATFAUwIujj7bRG5UA==", "dependencies": { - "commander": "^4.0.0", - "glob": "^7.1.5" + "commander": "^6.1.0", + "glob": "^7.1.6" }, "bin": { "dot-object": "bin/dot-object" @@ -10286,9 +10319,9 @@ } }, "node_modules/electron-to-chromium": { - "version": "1.4.744", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.744.tgz", - "integrity": "sha512-nAGcF0yeKKfrP13LMFr5U1eghfFSvFLg302VUFzWlcjPOnUYd52yU5x6PBYrujhNbc4jYmZFrGZFK+xasaEzVA==", + "version": "1.4.745", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.745.tgz", + "integrity": "sha512-tRbzkaRI5gbUn5DEvF0dV4TQbMZ5CLkWeTAXmpC9IrYT+GE+x76i9p+o3RJ5l9XmdQlI1pPhVtE9uNcJJ0G0EA==", "dev": true }, "node_modules/elegant-spinner": { @@ -10716,9 +10749,9 @@ } }, "node_modules/eslint-config-oclif-typescript": { - "version": "3.1.5", - "resolved": "https://registry.npmjs.org/eslint-config-oclif-typescript/-/eslint-config-oclif-typescript-3.1.5.tgz", - "integrity": "sha512-bw6HYbv5UQcfK5knAPemViB+CpbxmAOsnaxtvFAEeOvQM61eVaNKtPyCj1DRgUOBUN7knJ0NBXOqUny+0nwSkQ==", + "version": "3.1.6", + "resolved": "https://registry.npmjs.org/eslint-config-oclif-typescript/-/eslint-config-oclif-typescript-3.1.6.tgz", + "integrity": "sha512-K/Gv19vzTaeLQcs5syZ+Rup8RZfMclIuO2mV9YPG3GN64nSPA545+I7/uiaaxE4Ka+fKg2kZmMq3cFT0TOidpA==", "dev": true, "dependencies": { "@typescript-eslint/eslint-plugin": "^6.21.0", @@ -10726,7 +10759,7 @@ "eslint-config-xo-space": "^0.35.0", "eslint-import-resolver-typescript": "^3.6.1", "eslint-plugin-import": "^2.29.1", - "eslint-plugin-mocha": "^10.4.2", + "eslint-plugin-mocha": "^10.4.3", "eslint-plugin-n": "^15", "eslint-plugin-perfectionist": "^2.9.0" }, @@ -18663,9 +18696,9 @@ } }, "node_modules/nwsapi": { - "version": "2.2.7", - "resolved": "https://registry.npmjs.org/nwsapi/-/nwsapi-2.2.7.tgz", - "integrity": "sha512-ub5E4+FBPKwAZx0UwIQOjYWGHTEq5sPqHQNRN8Z9e4A7u3Tj1weLJsL59yH9vmvqEtBHaOmT6cYQKIZOxp35FQ==" + "version": "2.2.9", + "resolved": "https://registry.npmjs.org/nwsapi/-/nwsapi-2.2.9.tgz", + "integrity": "sha512-2f3F0SEEer8bBu0dsNCFF50N0cTThV1nWFYcEYFZttdW0lDAoybv9cQoK7X7/68Z89S7FoRrVjP1LPX4XRf9vg==" }, "node_modules/nyc": { "version": "15.1.0", @@ -25400,7 +25433,7 @@ }, "packages/contentstack": { "name": "@contentstack/cli", - "version": "1.17.3", + "version": "1.17.4", "license": "MIT", "dependencies": { "@contentstack/cli-audit": "~1.5.4", @@ -25417,7 +25450,7 @@ "@contentstack/cli-command": "~1.2.17", "@contentstack/cli-config": "~1.6.3", "@contentstack/cli-launch": "~1.0.17", - "@contentstack/cli-migration": "~1.5.3", + "@contentstack/cli-migration": "~1.5.4", "@contentstack/cli-utilities": "~1.6.0", "@contentstack/management": "~1.15.3", "@oclif/core": "^2.9.3", @@ -27340,7 +27373,7 @@ }, "packages/contentstack-migration": { "name": "@contentstack/cli-migration", - "version": "1.5.3", + "version": "1.5.4", "license": "MIT", "dependencies": { "@contentstack/cli-command": "~1.2.16", diff --git a/packages/contentstack-migration/examples/05-Update-reference-entry-from-mapper.js b/packages/contentstack-migration/examples/05-Update-reference-entry-from-mapper.js new file mode 100644 index 0000000000..3e07b72c2a --- /dev/null +++ b/packages/contentstack-migration/examples/05-Update-reference-entry-from-mapper.js @@ -0,0 +1,138 @@ +const fs = require('fs'); +const chalk = require('chalk'); +module.exports = async ({ migration, stackSDKInstance, managementAPIClient, config }) => { + const modules = ['entries', 'assets', 'extensions']; + + const readAllModulesUids = (filePath) => { + let uidMapping = []; + modules.forEach((module) => { + if (fs.existsSync(`${filePath}/mapper/${module}/uid-mapping.json`)) { + let mappedIds = fs.readFileSync(`${filePath}/mapper/${module}/uid-mapping.json`, 'utf-8'); + mappedIds = JSON.parse(mappedIds); + uidMapping = { ...uidMapping, ...mappedIds }; + } else { + console.log(chalk.red(`Mapper Does not exist for module '${module}'`)); + } + }); + + return uidMapping; + }; + + const getEntries = async (ct) => { + try { + let entries = []; + let skip = 0; + let limit = 1; + let count = 0; + while (skip <= count) { + const res = await stackSDKInstance.contentType(ct).entry().query({ include_count: true, skip, limit }).find(); + count = res.count; + skip += limit; + entries = [...entries, ...res.items]; + } + return entries; + } catch (err) { + console.log(err); + console.log(chalk.red(`No entry is found for Content-type ${ct}`)); + return []; + } + }; + + const getContentTypeSchema = async (ct) => { + try { + return await stackSDKInstance.contentType(ct).fetch(); + } catch (err) { + console.log(chalk.red(`Content-type '${ct}' is not present in stack`)); + return {}; + } + }; + + const updateEntryTask = () => { + return { + title: 'Update Reference Entries from Mapper', + successMessage: 'Reference Updated Successfully', + failedMessage: 'Failed to Update References in Entries', + task: async (params) => { + try { + const log = console.log; + + if ((!config.contentTypes && !Array.isArray(config.contentTypes)) || !config['mapper-path']) { + throw Error( + `Content-type or the Mapper Path is missing from the config. Please provide Content-type in Array and mapper path`, + ); + } + + for (let ct of config.contentTypes) { + let { schema: ctSchema } = await getContentTypeSchema(ct); + // console.log(ctSchema); + if (!ctSchema) { + continue; + } + + let keys = ctSchema?.map((schema) => { + return schema.uid; + }); + + let entry = await getEntries(ct); + + if (entry.length === 0) { + log(chalk.red(`No entry found for the CT Content-type '${ct}'`)); + continue; + } + let uidMapping = readAllModulesUids(config['mapper-path']); + + for (let e of entry) { + let isUpdated = false; + + let stringEntry = JSON.stringify(e); + let pattern = /\bblt\w*/g; + let matches = stringEntry.match(pattern); + + matches.forEach((m) => { + if (Object.keys(uidMapping).includes(m)) { + let regex = new RegExp(m, 'g'); + stringEntry = stringEntry.replace(regex, uidMapping[m]); + log(chalk.green(`Replacing UID '${m}' with '${uidMapping[m]}'`)); + isUpdated = true; + } + }); + + stringEntry = JSON.parse(stringEntry); + + keys.forEach((k) => { + if (stringEntry[k]) { + e[k] = stringEntry[k]; + } + }); + + if (isUpdated) { + await e.update(e.locale); + + log( + chalk.green( + `Updated the References in Entry with UID '${e.uid}' and title '${e.title}' in locale '${e.locale}' of content-type '${ct}'`, + ), + ); + } else { + log( + chalk.red( + `Not Updated the Entry with UID '${e.uid}' and title '${e.title}' in locale '${e.locale}' of content-type '${ct}'`, + ), + ); + } + } + log(chalk.green(`Updated the entries of CT '${ct}'`)); + } + } catch (err) { + if (err.request?.headers) { + delete err.request['headers']; + } + console.log(chalk.red(`References not updated`)); + throw err; + } + }, + }; + }; + + migration.addTask(updateEntryTask()); +}; diff --git a/packages/contentstack-migration/package.json b/packages/contentstack-migration/package.json index ffc15d535c..200d631a6e 100644 --- a/packages/contentstack-migration/package.json +++ b/packages/contentstack-migration/package.json @@ -1,6 +1,6 @@ { "name": "@contentstack/cli-migration", - "version": "1.5.3", + "version": "1.5.4", "author": "@contentstack", "bugs": "https://github.com/contentstack/cli/issues", "dependencies": { diff --git a/packages/contentstack/package.json b/packages/contentstack/package.json index 95d0670839..746b6c7369 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.17.3", + "version": "1.17.4", "author": "Contentstack", "bin": { "csdx": "./bin/run" @@ -36,7 +36,7 @@ "@contentstack/cli-command": "~1.2.17", "@contentstack/cli-config": "~1.6.3", "@contentstack/cli-launch": "~1.0.17", - "@contentstack/cli-migration": "~1.5.3", + "@contentstack/cli-migration": "~1.5.4", "@contentstack/cli-utilities": "~1.6.0", "@contentstack/management": "~1.15.3", "@oclif/core": "^2.9.3", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 7403790937..54c7f75d56 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -24,7 +24,7 @@ importers: '@contentstack/cli-command': ~1.2.17 '@contentstack/cli-config': ~1.6.3 '@contentstack/cli-launch': ~1.0.17 - '@contentstack/cli-migration': ~1.5.3 + '@contentstack/cli-migration': ~1.5.4 '@contentstack/cli-utilities': ~1.6.0 '@contentstack/management': ~1.15.3 '@oclif/core': ^2.9.3 From 0147869f708ce056da29f804b10757b3016fe27f Mon Sep 17 00:00:00 2001 From: raj pandey Date: Mon, 22 Apr 2024 22:51:47 +0530 Subject: [PATCH 2/3] PR fixes --- .../05-Update-reference-entry-from-mapper.js | 74 ++++++++++++------- 1 file changed, 46 insertions(+), 28 deletions(-) diff --git a/packages/contentstack-migration/examples/05-Update-reference-entry-from-mapper.js b/packages/contentstack-migration/examples/05-Update-reference-entry-from-mapper.js index 3e07b72c2a..f973f6eb85 100644 --- a/packages/contentstack-migration/examples/05-Update-reference-entry-from-mapper.js +++ b/packages/contentstack-migration/examples/05-Update-reference-entry-from-mapper.js @@ -1,17 +1,22 @@ const fs = require('fs'); const chalk = require('chalk'); +const path = require('path'); module.exports = async ({ migration, stackSDKInstance, managementAPIClient, config }) => { - const modules = ['entries', 'assets', 'extensions']; + const modules = ['entries', 'assets', 'extensions', 'marketplace_apps']; const readAllModulesUids = (filePath) => { - let uidMapping = []; + let uidMapping = {}; + modules.forEach((module) => { - if (fs.existsSync(`${filePath}/mapper/${module}/uid-mapping.json`)) { - let mappedIds = fs.readFileSync(`${filePath}/mapper/${module}/uid-mapping.json`, 'utf-8'); - mappedIds = JSON.parse(mappedIds); - uidMapping = { ...uidMapping, ...mappedIds }; - } else { - console.log(chalk.red(`Mapper Does not exist for module '${module}'`)); + const mappingFilePath = path.join(filePath, 'mapper', module, 'uid-mapping.json'); + if (fs.existsSync(mappingFilePath)) { + const mappedIds = JSON.parse(fs.readFileSync(mappingFilePath, 'utf-8')); + + if (module === 'marketplace_apps') { + Object.values(mappedIds).forEach((ids) => Object.assign(uidMapping, ids)); + } else { + Object.assign(uidMapping, mappedIds); + } } }); @@ -22,7 +27,7 @@ module.exports = async ({ migration, stackSDKInstance, managementAPIClient, conf try { let entries = []; let skip = 0; - let limit = 1; + let limit = 100; let count = 0; while (skip <= count) { const res = await stackSDKInstance.contentType(ct).entry().query({ include_count: true, skip, limit }).find(); @@ -32,9 +37,8 @@ module.exports = async ({ migration, stackSDKInstance, managementAPIClient, conf } return entries; } catch (err) { - console.log(err); - console.log(chalk.red(`No entry is found for Content-type ${ct}`)); - return []; + console.log(chalk.red(`Cannot Fetch Entries`)); + throw err; } }; @@ -42,11 +46,29 @@ module.exports = async ({ migration, stackSDKInstance, managementAPIClient, conf try { return await stackSDKInstance.contentType(ct).fetch(); } catch (err) { - console.log(chalk.red(`Content-type '${ct}' is not present in stack`)); - return {}; + console.log(chalk.red(`Error in Fetching the Content-type '${ct}' due to ${err.errorMessage}`)); } }; + const findAllEntriesUid = (stringifiedEntry) => { + let pattern = /\bblt\w*/g; + let matches = stringifiedEntry.match(pattern); + return matches; + }; + + const replaceEntriesWithUpdatedUids = (matches, uidMapping, stringifiedEntry) => { + let isUpdated = false; + matches.forEach((m) => { + if (Object.keys(uidMapping).includes(m)) { + let regex = new RegExp(m, 'g'); + stringifiedEntry = stringifiedEntry.replace(regex, uidMapping[m]); + console.log(chalk.green(`Replacing UID '${m}' with '${uidMapping[m]}'`)); + isUpdated = true; + } + }); + return { stringifiedEntry, isUpdated }; + }; + const updateEntryTask = () => { return { title: 'Update Reference Entries from Mapper', @@ -63,8 +85,8 @@ module.exports = async ({ migration, stackSDKInstance, managementAPIClient, conf } for (let ct of config.contentTypes) { - let { schema: ctSchema } = await getContentTypeSchema(ct); - // console.log(ctSchema); + let { schema: ctSchema } = (await getContentTypeSchema(ct)) ?? {}; + if (!ctSchema) { continue; } @@ -73,7 +95,7 @@ module.exports = async ({ migration, stackSDKInstance, managementAPIClient, conf return schema.uid; }); - let entry = await getEntries(ct); + let entry = (await getEntries(ct)) ?? []; if (entry.length === 0) { log(chalk.red(`No entry found for the CT Content-type '${ct}'`)); @@ -85,17 +107,13 @@ module.exports = async ({ migration, stackSDKInstance, managementAPIClient, conf let isUpdated = false; let stringEntry = JSON.stringify(e); - let pattern = /\bblt\w*/g; - let matches = stringEntry.match(pattern); - - matches.forEach((m) => { - if (Object.keys(uidMapping).includes(m)) { - let regex = new RegExp(m, 'g'); - stringEntry = stringEntry.replace(regex, uidMapping[m]); - log(chalk.green(`Replacing UID '${m}' with '${uidMapping[m]}'`)); - isUpdated = true; - } - }); + + let matches = findAllEntriesUid(stringEntry); + + let res = replaceEntriesWithUpdatedUids(matches, uidMapping, stringEntry); + + stringEntry = res.stringifiedEntry; + isUpdated = res.isUpdated; stringEntry = JSON.parse(stringEntry); From 6aaeb073bc2d209dcb6ae124d7cabac6f970ae57 Mon Sep 17 00:00:00 2001 From: raj pandey Date: Tue, 23 Apr 2024 18:52:18 +0530 Subject: [PATCH 3/3] PR fixes --- .../examples/05-Update-reference-entry-from-mapper.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/contentstack-migration/examples/05-Update-reference-entry-from-mapper.js b/packages/contentstack-migration/examples/05-Update-reference-entry-from-mapper.js index f973f6eb85..0124825f18 100644 --- a/packages/contentstack-migration/examples/05-Update-reference-entry-from-mapper.js +++ b/packages/contentstack-migration/examples/05-Update-reference-entry-from-mapper.js @@ -33,7 +33,7 @@ module.exports = async ({ migration, stackSDKInstance, managementAPIClient, conf const res = await stackSDKInstance.contentType(ct).entry().query({ include_count: true, skip, limit }).find(); count = res.count; skip += limit; - entries = [...entries, ...res.items]; + entries.push(...res.items); } return entries; } catch (err) { @@ -58,8 +58,9 @@ module.exports = async ({ migration, stackSDKInstance, managementAPIClient, conf const replaceEntriesWithUpdatedUids = (matches, uidMapping, stringifiedEntry) => { let isUpdated = false; + let oldUids = Object.keys(uidMapping); matches.forEach((m) => { - if (Object.keys(uidMapping).includes(m)) { + if (oldUids.includes(m)) { let regex = new RegExp(m, 'g'); stringifiedEntry = stringifiedEntry.replace(regex, uidMapping[m]); console.log(chalk.green(`Replacing UID '${m}' with '${uidMapping[m]}'`));