From 332c0876ac9d2e3c7882740ec6e7f83e5f12d4d7 Mon Sep 17 00:00:00 2001 From: Aman Kumar Date: Thu, 16 Jan 2025 15:23:58 +0530 Subject: [PATCH 1/2] feat: extract launch code and add external plugin installation for launch --- .github/workflows/release.yml | 16 - package-lock.json | 579 ++++--------- packages/contentstack-audit/README.md | 14 +- packages/contentstack-auth/README.md | 2 +- packages/contentstack-bootstrap/README.md | 2 +- packages/contentstack-branches/README.md | 2 +- packages/contentstack-bulk-publish/README.md | 2 +- packages/contentstack-clone/README.md | 2 +- packages/contentstack-config/README.md | 2 +- packages/contentstack-export/README.md | 2 +- packages/contentstack-import-setup/README.md | 2 +- packages/contentstack-import/README.md | 2 +- packages/contentstack-launch/.editorconfig | 11 - packages/contentstack-launch/.eslintignore | 1 - packages/contentstack-launch/.eslintrc | 6 - packages/contentstack-launch/.gitignore | 19 - packages/contentstack-launch/.mocharc.json | 12 - packages/contentstack-launch/.talismanrc | 4 - packages/contentstack-launch/LICENSE | 21 - packages/contentstack-launch/README.md | 57 -- packages/contentstack-launch/SECURITY.md | 27 - packages/contentstack-launch/bin/dev.cmd | 3 - packages/contentstack-launch/bin/dev.js | 6 - packages/contentstack-launch/bin/run.cmd | 3 - packages/contentstack-launch/bin/run.js | 7 - packages/contentstack-launch/example.env | 3 - packages/contentstack-launch/package.json | 108 --- .../src/adapters/base-class.ts | 794 ------------------ .../src/adapters/file-upload.ts | 343 -------- .../src/adapters/github.ts | 287 ------- .../contentstack-launch/src/adapters/index.ts | 6 - .../src/adapters/pre-check.ts | 156 ---- .../contentstack-launch/src/base-command.ts | 207 ----- .../src/commands/launch/deployments.ts | 145 ---- .../src/commands/launch/environments.ts | 157 ---- .../src/commands/launch/functions.ts | 33 - .../src/commands/launch/index.ts | 140 --- .../src/commands/launch/logs.ts | 243 ------ .../src/commands/launch/open.ts | 161 ---- .../contentstack-launch/src/config/index.ts | 45 - .../contentstack-launch/src/graphql/index.ts | 2 - .../src/graphql/mutation.ts | 83 -- .../src/graphql/queries.ts | 190 ----- packages/contentstack-launch/src/index.ts | 1 - .../contentstack-launch/src/types/index.ts | 2 - .../contentstack-launch/src/types/launch.ts | 76 -- .../contentstack-launch/src/types/utils.ts | 39 - .../src/util/apollo-client.ts | 230 ----- .../cloud-functions-validator.ts | 85 -- .../util/cloud-function/cloud-functions.ts | 194 ----- .../src/util/cloud-function/constants.ts | 3 - .../src/util/cloud-function/contentfly.ts | 22 - .../errors/cloud-function.errors.ts | 45 - .../src/util/cloud-function/index.ts | 2 - .../src/util/cloud-function/os-helper.ts | 23 - .../src/util/cloud-function/types.ts | 16 - .../src/util/common-utility.ts | 154 ---- .../src/util/create-git-meta.ts | 43 - packages/contentstack-launch/src/util/fs.ts | 30 - .../contentstack-launch/src/util/index.ts | 8 - packages/contentstack-launch/src/util/log.ts | 187 ----- .../src/util/logs-polling-utilities.ts | 242 ------ .../contentstack-launch/test/helpers/init.js | 6 - .../contentstack-launch/test/tsconfig.json | 9 - .../test/unit/adapters/file-upload.test.ts | 255 ------ .../test/unit/adapters/github.test.ts | 254 ------ .../test/unit/commands/deployments.test.ts | 74 -- .../test/unit/commands/environments.test.ts | 66 -- .../test/unit/commands/functions.test.ts | 48 -- .../test/unit/commands/launch.test.ts | 71 -- .../test/unit/commands/log.test.ts | 335 -------- .../test/unit/commands/open.test.ts | 86 -- .../test/unit/mock/index.ts | 55 -- .../test/unit/util/log.test.ts | 35 - .../unit/util/logs-polling-utilities.test.ts | 192 ----- .../test/unit/z-cleanup.test.ts | 3 - packages/contentstack-launch/tsconfig.json | 16 - .../contentstack-launch/tsconfig.tsbuildinfo | 1 - packages/contentstack-migrate-rte/README.md | 2 +- packages/contentstack-migration/README.md | 2 +- packages/contentstack/README.md | 26 +- packages/contentstack/package.json | 2 +- pnpm-lock.yaml | 634 +------------- 83 files changed, 225 insertions(+), 7256 deletions(-) delete mode 100755 packages/contentstack-launch/.editorconfig delete mode 100755 packages/contentstack-launch/.eslintignore delete mode 100755 packages/contentstack-launch/.eslintrc delete mode 100755 packages/contentstack-launch/.gitignore delete mode 100755 packages/contentstack-launch/.mocharc.json delete mode 100755 packages/contentstack-launch/.talismanrc delete mode 100755 packages/contentstack-launch/LICENSE delete mode 100755 packages/contentstack-launch/README.md delete mode 100755 packages/contentstack-launch/SECURITY.md delete mode 100755 packages/contentstack-launch/bin/dev.cmd delete mode 100755 packages/contentstack-launch/bin/dev.js delete mode 100755 packages/contentstack-launch/bin/run.cmd delete mode 100755 packages/contentstack-launch/bin/run.js delete mode 100644 packages/contentstack-launch/example.env delete mode 100755 packages/contentstack-launch/package.json delete mode 100755 packages/contentstack-launch/src/adapters/base-class.ts delete mode 100755 packages/contentstack-launch/src/adapters/file-upload.ts delete mode 100755 packages/contentstack-launch/src/adapters/github.ts delete mode 100755 packages/contentstack-launch/src/adapters/index.ts delete mode 100755 packages/contentstack-launch/src/adapters/pre-check.ts delete mode 100755 packages/contentstack-launch/src/base-command.ts delete mode 100755 packages/contentstack-launch/src/commands/launch/deployments.ts delete mode 100755 packages/contentstack-launch/src/commands/launch/environments.ts delete mode 100755 packages/contentstack-launch/src/commands/launch/functions.ts delete mode 100755 packages/contentstack-launch/src/commands/launch/index.ts delete mode 100755 packages/contentstack-launch/src/commands/launch/logs.ts delete mode 100755 packages/contentstack-launch/src/commands/launch/open.ts delete mode 100755 packages/contentstack-launch/src/config/index.ts delete mode 100755 packages/contentstack-launch/src/graphql/index.ts delete mode 100755 packages/contentstack-launch/src/graphql/mutation.ts delete mode 100755 packages/contentstack-launch/src/graphql/queries.ts delete mode 100755 packages/contentstack-launch/src/index.ts delete mode 100755 packages/contentstack-launch/src/types/index.ts delete mode 100755 packages/contentstack-launch/src/types/launch.ts delete mode 100755 packages/contentstack-launch/src/types/utils.ts delete mode 100755 packages/contentstack-launch/src/util/apollo-client.ts delete mode 100755 packages/contentstack-launch/src/util/cloud-function/cloud-functions-validator.ts delete mode 100755 packages/contentstack-launch/src/util/cloud-function/cloud-functions.ts delete mode 100755 packages/contentstack-launch/src/util/cloud-function/constants.ts delete mode 100755 packages/contentstack-launch/src/util/cloud-function/contentfly.ts delete mode 100755 packages/contentstack-launch/src/util/cloud-function/errors/cloud-function.errors.ts delete mode 100755 packages/contentstack-launch/src/util/cloud-function/index.ts delete mode 100755 packages/contentstack-launch/src/util/cloud-function/os-helper.ts delete mode 100755 packages/contentstack-launch/src/util/cloud-function/types.ts delete mode 100644 packages/contentstack-launch/src/util/common-utility.ts delete mode 100755 packages/contentstack-launch/src/util/create-git-meta.ts delete mode 100755 packages/contentstack-launch/src/util/fs.ts delete mode 100755 packages/contentstack-launch/src/util/index.ts delete mode 100755 packages/contentstack-launch/src/util/log.ts delete mode 100755 packages/contentstack-launch/src/util/logs-polling-utilities.ts delete mode 100755 packages/contentstack-launch/test/helpers/init.js delete mode 100755 packages/contentstack-launch/test/tsconfig.json delete mode 100644 packages/contentstack-launch/test/unit/adapters/file-upload.test.ts delete mode 100644 packages/contentstack-launch/test/unit/adapters/github.test.ts delete mode 100644 packages/contentstack-launch/test/unit/commands/deployments.test.ts delete mode 100644 packages/contentstack-launch/test/unit/commands/environments.test.ts delete mode 100644 packages/contentstack-launch/test/unit/commands/functions.test.ts delete mode 100644 packages/contentstack-launch/test/unit/commands/launch.test.ts delete mode 100644 packages/contentstack-launch/test/unit/commands/log.test.ts delete mode 100644 packages/contentstack-launch/test/unit/commands/open.test.ts delete mode 100644 packages/contentstack-launch/test/unit/mock/index.ts delete mode 100644 packages/contentstack-launch/test/unit/util/log.test.ts delete mode 100644 packages/contentstack-launch/test/unit/util/logs-polling-utilities.test.ts delete mode 100644 packages/contentstack-launch/test/unit/z-cleanup.test.ts delete mode 100755 packages/contentstack-launch/tsconfig.json delete mode 100755 packages/contentstack-launch/tsconfig.tsbuildinfo diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0551492efa..8ad7567420 100755 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -261,22 +261,6 @@ jobs: with: token: ${{ secrets.NPM_TOKEN }} package: ./packages/contentstack-bulk-publish/package.json - - name: Installing dependencies of launch - id: launch-installation - if: ${{env.release_releaseAll == 'true' || env.release_plugins_launch == 'true'}} - working-directory: ./packages/contentstack-launch - run: npm install - - name: Compiling launch - if: ${{ steps.launch-installation.conclusion == 'success' }} - working-directory: ./packages/contentstack-launch - run: npm run prepack - - name: Publishing launch - uses: JS-DevTools/npm-publish@v2.2.1 - if: ${{ steps.launch-installation.conclusion == 'success' }} - with: - token: ${{ secrets.NPM_TOKEN }} - package: ./packages/contentstack-launch/package.json - access: public - name: Installing dependencies of branches id: branches-installation if: ${{env.release_releaseAll == 'true' || env.release_plugins_branches == 'true'}} diff --git a/package-lock.json b/package-lock.json index 3b2d9e0f37..7a39e26210 100644 --- a/package-lock.json +++ b/package-lock.json @@ -33,9 +33,9 @@ } }, "node_modules/@apollo/client": { - "version": "3.12.5", - "resolved": "https://registry.npmjs.org/@apollo/client/-/client-3.12.5.tgz", - "integrity": "sha512-lOE2TlHx1el4rHs8vaTE4IroyIO9/PD2w598YYiDahF0XSMDdsXMrTpOVh+FuQ6tZ+DXT+hsaMlilZqcFRgu+A==", + "version": "3.12.6", + "resolved": "https://registry.npmjs.org/@apollo/client/-/client-3.12.6.tgz", + "integrity": "sha512-MOEtkojZagMKB7nxlwQ426eaBYwEs/Xfn+JeLOd81wv6j7toKo57eEGAbJdZwyXGRgtiqDkX5gx3EzE7qtarXA==", "license": "MIT", "dependencies": { "@graphql-typed-document-node/core": "^3.1.1", @@ -91,9 +91,9 @@ } }, "node_modules/@babel/compat-data": { - "version": "7.26.3", - "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.26.3.tgz", - "integrity": "sha512-nHIxvKPniQXpmQLb0vhY3VaFb3S0YrTAwpOWJZh1wn3oJPjJk9Asva204PsBdmAE8vpzfHudT8DB0scYvy9q0g==", + "version": "7.26.5", + "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.26.5.tgz", + "integrity": "sha512-XvcZi1KWf88RVbF9wn8MN6tYFloU5qX8KjuF3E1PVBmJ9eypXfs4GRiJwLuTZL0iSnJUKn1BFPa5BPZZJyFzPg==", "dev": true, "license": "MIT", "engines": { @@ -142,9 +142,9 @@ } }, "node_modules/@babel/eslint-parser": { - "version": "7.25.9", - "resolved": "https://registry.npmjs.org/@babel/eslint-parser/-/eslint-parser-7.25.9.tgz", - "integrity": "sha512-5UXfgpK0j0Xr/xIdgdLEhOFxaDZ0bRPWJJchRpqOSur/3rZoPbqqki5mm0p4NE2cs28krBEiSM2MB7//afRSQQ==", + "version": "7.26.5", + "resolved": "https://registry.npmjs.org/@babel/eslint-parser/-/eslint-parser-7.26.5.tgz", + "integrity": "sha512-Kkm8C8uxI842AwQADxl0GbcG1rupELYLShazYEZO/2DYjhyWXJIOUVOE3tBYm6JXzUCNJOZEzqc4rCW/jsEQYQ==", "dev": true, "license": "MIT", "dependencies": { @@ -181,14 +181,14 @@ } }, "node_modules/@babel/generator": { - "version": "7.26.3", - "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.26.3.tgz", - "integrity": "sha512-6FF/urZvD0sTeO7k6/B15pMLC4CHUv1426lzr3N01aHJTl046uCAh9LXW/fzeXXjPNCJ6iABW5XaWOsIZB93aQ==", + "version": "7.26.5", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.26.5.tgz", + "integrity": "sha512-2caSP6fN9I7HOe6nqhtft7V4g7/V/gfDsC3Ag4W7kEzzvRGKqiv0pu0HogPiZ3KaVSoNDhUws6IJjDjpfmYIXw==", "dev": true, "license": "MIT", "dependencies": { - "@babel/parser": "^7.26.3", - "@babel/types": "^7.26.3", + "@babel/parser": "^7.26.5", + "@babel/types": "^7.26.5", "@jridgewell/gen-mapping": "^0.3.5", "@jridgewell/trace-mapping": "^0.3.25", "jsesc": "^3.0.2" @@ -198,13 +198,13 @@ } }, "node_modules/@babel/helper-compilation-targets": { - "version": "7.25.9", - "resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.25.9.tgz", - "integrity": "sha512-j9Db8Suy6yV/VHa4qzrj9yZfZxhLWQdVnRlXxmKLYlhWUVB1sB2G5sxuWYXk/whHD9iW76PmNzxZ4UCnTQTVEQ==", + "version": "7.26.5", + "resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.26.5.tgz", + "integrity": "sha512-IXuyn5EkouFJscIDuFF5EsiSolseme1s0CZB+QxVugqJLYmKdxI1VfIBOst0SUu4rnk2Z7kqTwmoO1lp3HIfnA==", "dev": true, "license": "MIT", "dependencies": { - "@babel/compat-data": "^7.25.9", + "@babel/compat-data": "^7.26.5", "@babel/helper-validator-option": "^7.25.9", "browserslist": "^4.24.0", "lru-cache": "^5.1.1", @@ -257,9 +257,9 @@ } }, "node_modules/@babel/helper-plugin-utils": { - "version": "7.25.9", - "resolved": "https://registry.npmjs.org/@babel/helper-plugin-utils/-/helper-plugin-utils-7.25.9.tgz", - "integrity": "sha512-kSMlyUVdWe25rEsRGviIgOWnoT/nfABVWlqt9N19/dIPWViAOW2s9wznP5tURbs/IDuNk4gPy3YdYRgH3uxhBw==", + "version": "7.26.5", + "resolved": "https://registry.npmjs.org/@babel/helper-plugin-utils/-/helper-plugin-utils-7.26.5.tgz", + "integrity": "sha512-RS+jZcRdZdRFzMyr+wcsaqOmld1/EqTghfaBGQQd/WnRdzdlvSZ//kF7U8VQTxf1ynZ4cjUcYgjVGx13ewNPMg==", "dev": true, "license": "MIT", "engines": { @@ -405,13 +405,13 @@ } }, "node_modules/@babel/parser": { - "version": "7.26.3", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.26.3.tgz", - "integrity": "sha512-WJ/CvmY8Mea8iDXo6a7RK2wbmJITT5fN3BEkRuFlxVyNx8jOKIIhmC4fSkTcPcf8JyavbBwIe6OpiCOBXt/IcA==", + "version": "7.26.5", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.26.5.tgz", + "integrity": "sha512-SRJ4jYmXRqV1/Xc+TIVG84WjHBXKlxO9sHQnA2Pf12QQEAp1LOh6kDzNHXcUnbH1QI0FDoPPVOt+vyUDucxpaw==", "dev": true, "license": "MIT", "dependencies": { - "@babel/types": "^7.26.3" + "@babel/types": "^7.26.5" }, "bin": { "parser": "bin/babel-parser.js" @@ -688,17 +688,17 @@ } }, "node_modules/@babel/traverse": { - "version": "7.26.4", - "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.26.4.tgz", - "integrity": "sha512-fH+b7Y4p3yqvApJALCPJcwb0/XaOSgtK4pzV6WVjPR5GLFQBRI7pfoX2V2iM48NXvX07NUxxm1Vw98YjqTcU5w==", + "version": "7.26.5", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.26.5.tgz", + "integrity": "sha512-rkOSPOw+AXbgtwUga3U4u8RpoK9FEFWBNAlTpcnkLFjL5CT+oyHNuUUC/xx6XefEJ16r38r8Bc/lfp6rYuHeJQ==", "dev": true, "license": "MIT", "dependencies": { "@babel/code-frame": "^7.26.2", - "@babel/generator": "^7.26.3", - "@babel/parser": "^7.26.3", + "@babel/generator": "^7.26.5", + "@babel/parser": "^7.26.5", "@babel/template": "^7.25.9", - "@babel/types": "^7.26.3", + "@babel/types": "^7.26.5", "debug": "^4.3.1", "globals": "^11.1.0" }, @@ -717,9 +717,9 @@ } }, "node_modules/@babel/types": { - "version": "7.26.3", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.26.3.tgz", - "integrity": "sha512-vN5p+1kl59GVKMvTHt55NzzmYVxprfJD+ql7U9NFIfKCBkYE55LYtS+WtPlaYOyzydrKI8Nezd+aZextrd+FMA==", + "version": "7.26.5", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.26.5.tgz", + "integrity": "sha512-L6mZmwFDK6Cjh1nRCLXpa6no13ZIioJDz7mdkzHv399pThrTa/k0nUlNaenOeh2kWu/iaOQYElEpKPUswUa9Vg==", "dev": true, "license": "MIT", "dependencies": { @@ -811,8 +811,38 @@ "link": true }, "node_modules/@contentstack/cli-launch": { - "resolved": "packages/contentstack-launch", - "link": true + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/@contentstack/cli-launch/-/cli-launch-1.4.1.tgz", + "integrity": "sha512-aDwGcbNhKbIsydZ8368vP2csS7/VfrBv9Bt15CxLSD1m1ZAteHxSEBE1V1gKbK5nwNnaqPBK4w49nB55lZ0jZg==", + "license": "MIT", + "dependencies": { + "@apollo/client": "^3.11.8", + "@contentstack/cli-command": "~1.3.2", + "@contentstack/cli-utilities": "~1.8.0", + "@oclif/core": "^3.27.0", + "@oclif/plugin-help": "^5.2.20", + "@oclif/plugin-plugins": "^5.4.15", + "@types/express": "^4.17.21", + "@types/express-serve-static-core": "^4.17.34", + "adm-zip": "^0.5.16", + "chalk": "^4.1.2", + "cross-fetch": "^3.1.8", + "dotenv": "^16.4.7", + "esm": "^3.2.25", + "express": "^4.21.1", + "form-data": "^4.0.0", + "graphql": "^16.9.0", + "ini": "^3.0.1", + "lodash": "^4.17.21", + "open": "^8.4.2", + "winston": "^3.17.0" + }, + "bin": { + "launch": "bin/run.js" + }, + "engines": { + "node": ">=14.0.0" + } }, "node_modules/@contentstack/cli-migration": { "resolved": "packages/contentstack-migration", @@ -2428,12 +2458,12 @@ } }, "node_modules/@oclif/plugin-plugins": { - "version": "5.4.24", - "resolved": "https://registry.npmjs.org/@oclif/plugin-plugins/-/plugin-plugins-5.4.24.tgz", - "integrity": "sha512-Mzo0XNeD/5dshgLX9Ft7cpgSQKVQd7fw0PoaE/+58d7K/Lz00wxbo4zKjw19j65pqBfsKv7zVmg+jWxu3PZpgA==", + "version": "5.4.25", + "resolved": "https://registry.npmjs.org/@oclif/plugin-plugins/-/plugin-plugins-5.4.25.tgz", + "integrity": "sha512-44Yp532BuBoNrNYLf7wfp/2QkNY7ESdK3MgGi3GWCqW75apyX04+xC5RfRsz0KHOA9N7VFqn64PG+Ailo5TJyQ==", "license": "MIT", "dependencies": { - "@oclif/core": "^4.0.34", + "@oclif/core": "^4.2.2", "ansis": "^3.5.2", "debug": "^4.4.0", "npm": "^10.9.2", @@ -2450,13 +2480,13 @@ } }, "node_modules/@oclif/plugin-plugins/node_modules/@oclif/core": { - "version": "4.2.2", - "resolved": "https://registry.npmjs.org/@oclif/core/-/core-4.2.2.tgz", - "integrity": "sha512-5jGzLDu96jG67G2sF21A3u67FJwSRnOnjaJwobiI7sgSg5uuVAHn4j1DahhfC4K7UEcXqXBBH064JyZ9yS4xHg==", + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/@oclif/core/-/core-4.2.3.tgz", + "integrity": "sha512-JVEONwSZAfTNZCS81ah2u42Ya1mSeutCtHpoqMq/U+vP9Ka3Ni15/AqtcVtpH1afdUUn5RgtJYj+zlsrvMwksA==", "license": "MIT", "dependencies": { "ansi-escapes": "^4.3.2", - "ansis": "^3.6.0", + "ansis": "^3.8.1", "clean-stack": "^3.0.1", "cli-spinners": "^2.9.2", "debug": "^4.4.0", @@ -2587,12 +2617,12 @@ } }, "node_modules/@oclif/test": { - "version": "4.1.6", - "resolved": "https://registry.npmjs.org/@oclif/test/-/test-4.1.6.tgz", - "integrity": "sha512-1UcMu+5XXGsMgsIZmEbvGKjS6/Z8meu2VNh22Oop9s5dQAHX72Ds70dxwncVbRepFGhIIJ3xzyZbtBIy/sgt3Q==", + "version": "4.1.7", + "resolved": "https://registry.npmjs.org/@oclif/test/-/test-4.1.7.tgz", + "integrity": "sha512-KFfPfwCFKOUfqPkBk7Dl204fnQZQUpjib8kG/5RGDLa+IlV11e5d5DQQy3xfJdIGKJ8plg9fP0wjC57a1frt8g==", "license": "MIT", "dependencies": { - "ansis": "^3.6.0", + "ansis": "^3.8.1", "debug": "^4.4.0" }, "engines": { @@ -3255,16 +3285,6 @@ "node": "^14.17.0 || ^16.13.0 || >=18.0.0" } }, - "node_modules/@types/adm-zip": { - "version": "0.5.7", - "resolved": "https://registry.npmjs.org/@types/adm-zip/-/adm-zip-0.5.7.tgz", - "integrity": "sha512-DNEs/QvmyRLurdQPChqq0Md4zGvPwHerAJYWk9l2jCbD1VPpnzRJorOdiq4zsw09NFbYnhfsoEhWtxIzXpn2yw==", - "dev": true, - "license": "MIT", - "dependencies": { - "@types/node": "*" - } - }, "node_modules/@types/babel__core": { "version": "7.20.5", "resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.20.5.tgz", @@ -3374,16 +3394,6 @@ "@types/node": "*" } }, - "node_modules/@types/esm": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/@types/esm/-/esm-3.2.2.tgz", - "integrity": "sha512-l3IQQD2sChjNiQVNf28qq+sY9Sjvz7HrcOO3g4ZeSaiQRXQccBaR6cpqXPpzJ3QYCt6UF7+4ugabMRsQTPV+Eg==", - "dev": true, - "license": "MIT", - "dependencies": { - "@types/node": "*" - } - }, "node_modules/@types/expect": { "version": "1.20.4", "resolved": "https://registry.npmjs.org/@types/expect/-/expect-1.20.4.tgz", @@ -3473,13 +3483,6 @@ "integrity": "sha512-D0CFMMtydbJAegzOyHjtiKPLlvnm3iTZyZRSZoLq2mRhDdmLfIWOCYPfQJ4cu2erKghU++QvjcUjp/5h7hESpA==", "license": "MIT" }, - "node_modules/@types/ini": { - "version": "1.3.34", - "resolved": "https://registry.npmjs.org/@types/ini/-/ini-1.3.34.tgz", - "integrity": "sha512-FafeLhwmWucTi31ZYg/6aHBZNyrogQ35aDvSW7zMAz3HMhUqQ4G/NBya8c5pe2jwoYsDFwra8O9/yZotong76g==", - "dev": true, - "license": "MIT" - }, "node_modules/@types/inquirer": { "version": "9.0.7", "resolved": "https://registry.npmjs.org/@types/inquirer/-/inquirer-9.0.7.tgz", @@ -3658,9 +3661,9 @@ } }, "node_modules/@types/qs": { - "version": "6.9.17", - "resolved": "https://registry.npmjs.org/@types/qs/-/qs-6.9.17.tgz", - "integrity": "sha512-rX4/bPcfmvxHDv0XjfJELTTr+iB+tn032nPILqHm5wbthUUUuVtNGGqzhya9XUxjTP8Fpr0qYgSZZKxGY++svQ==", + "version": "6.9.18", + "resolved": "https://registry.npmjs.org/@types/qs/-/qs-6.9.18.tgz", + "integrity": "sha512-kK7dgTYDyGqS+e2Q4aK9X3D7q234CIZ1Bv0q/7Z5IwRDoADNU81xXJK/YVyLbLTZCoIwUoDoffFeF+p/eIklAA==", "license": "MIT" }, "node_modules/@types/range-parser": { @@ -4332,9 +4335,9 @@ "license": "MIT" }, "node_modules/ansis": { - "version": "3.8.0", - "resolved": "https://registry.npmjs.org/ansis/-/ansis-3.8.0.tgz", - "integrity": "sha512-9cvbRlXv2evXl/OEFrdLxvorgbL9shTjqXthKyD1Gm42ZhzWYVjOOEKujaqKWmk+hMzX8XYMIDcCarsqxEW8nw==", + "version": "3.9.0", + "resolved": "https://registry.npmjs.org/ansis/-/ansis-3.9.0.tgz", + "integrity": "sha512-PcDrVe15ldexeZMsVLBAzBwF2KhZgaU0R+CHxH+x5kqn/pO+UWVBZJ+NEXMPpEOLUFeNsnNdoWYc2gwO+MVkDg==", "license": "ISC", "engines": { "node": ">=16" @@ -7434,9 +7437,9 @@ } }, "node_modules/electron-to-chromium": { - "version": "1.5.80", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.80.tgz", - "integrity": "sha512-LTrKpW0AqIuHwmlVNV+cjFYTnXtM9K37OGhpe0ZI10ScPSxqVSryZHIY3WnCS5NSYbBODRTZyhRMS2h5FAEqAw==", + "version": "1.5.83", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.83.tgz", + "integrity": "sha512-LcUDPqSt+V0QmI47XLzZrz5OqILSMGsPFkDYus22rIbgorSvBYEFqq854ltTmUdHkY92FSdAAvsh4jWEULMdfQ==", "dev": true, "license": "ISC" }, @@ -7672,9 +7675,9 @@ } }, "node_modules/es-object-atoms": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.0.0.tgz", - "integrity": "sha512-MZ4iQ6JwHOBQjahnjwaC1ZtIBH+2ohjamzAO3oaHcXYup7qxjF2fixyH+Q71voWHeOkI2q/TnJao/KfXYIZWbw==", + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.1.1.tgz", + "integrity": "sha512-FGgH2h8zKNim9ljj7dankFPcICIK9Cp5bm+c2gQSYePhpaG5+esrLODihIorn+Pe6FGJzWhXQotPv73jTaldXA==", "license": "MIT", "dependencies": { "es-errors": "^1.3.0" @@ -9962,9 +9965,9 @@ "license": "MIT" }, "node_modules/fs-extra": { - "version": "11.2.0", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-11.2.0.tgz", - "integrity": "sha512-PmDi3uwK5nFuXh7XDTlVnS17xJS7vW36is2+w3xcv8SVxiB4NyATf4ctkVY5bkSjX0Y4nbvZCq1/EjtEyr9ktw==", + "version": "11.3.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-11.3.0.tgz", + "integrity": "sha512-Z4XaCL6dUDHfP/jT25jJKMmtxvuwbkrD1vNSMFlo9lNLY2c5FHYSQgHPRZUjAB26TpDEoW9HCOgplrdbaPV/ew==", "license": "MIT", "dependencies": { "graceful-fs": "^4.2.0", @@ -21132,12 +21135,12 @@ "license": "MIT" }, "node_modules/qs": { - "version": "6.13.1", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.13.1.tgz", - "integrity": "sha512-EJPeIn0CYrGu+hli1xilKAPXODtJ12T0sP63Ijx2/khC2JtuaN3JyNIpvmnkmaEtha9ocbG4A4cMcr+TvqvwQg==", + "version": "6.14.0", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.14.0.tgz", + "integrity": "sha512-YWWTjgABSKcvs/nWBi9PycY/JiPJqOD4JA6o9Sej2AtvSGarXxKC3OQSk4pAarbdQlKAh5D4FCQkJNkW+GAn3w==", "license": "BSD-3-Clause", "dependencies": { - "side-channel": "^1.0.6" + "side-channel": "^1.1.0" }, "engines": { "node": ">=0.6" @@ -22031,14 +22034,47 @@ } }, "node_modules/response-iterator": { - "version": "0.2.11", - "resolved": "https://registry.npmjs.org/response-iterator/-/response-iterator-0.2.11.tgz", - "integrity": "sha512-5tdhcAeGMSyM0/FoxAYjoOxQZ2tRR2H/S/t6kGRXu6iiWcGY5UnZgkVANbTwBVUSGqWu0ADctmoi6lOCIF8uKQ==", + "version": "0.2.16", + "resolved": "https://registry.npmjs.org/response-iterator/-/response-iterator-0.2.16.tgz", + "integrity": "sha512-QmLnoE4cJXjCoYjEtYu5zmBMs/1ytHU1RhbBm9/DUKTR641k46qCinzPiOzJJk9r71rxYbuMwM+dExPxlFTrzA==", "license": "MIT", + "dependencies": { + "readable-stream": "^2.3.8" + }, "engines": { "node": ">=0.8" } }, + "node_modules/response-iterator/node_modules/readable-stream": { + "version": "2.3.8", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.8.tgz", + "integrity": "sha512-8p0AUk4XODgIewSi0l8Epjs+EVnWiK7NoDIEGU0HhE7+ZyY8D1IMY7odu5lRrFXGg71L15KG8QrPmum45RTtdA==", + "license": "MIT", + "dependencies": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, + "node_modules/response-iterator/node_modules/safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", + "license": "MIT" + }, + "node_modules/response-iterator/node_modules/string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "license": "MIT", + "dependencies": { + "safe-buffer": "~5.1.0" + } + }, "node_modules/responselike": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/responselike/-/responselike-2.0.1.tgz", @@ -23265,9 +23301,9 @@ } }, "node_modules/spdx-license-ids": { - "version": "3.0.20", - "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.20.tgz", - "integrity": "sha512-jg25NiDV/1fLtSgEgyvVyDunvaNHbuwF9lfNV17gSmPFAlYzdfNBlLtLzXTevwkPj7DhGbmN9VnmJIgLnhvaBw==", + "version": "3.0.21", + "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.21.tgz", + "integrity": "sha512-Bvg/8F5XephndSK3JffaRqdT+gyhfqIPwDHpX80tJrF8QQRYMo8sNMeaZ2Dp5+jhwKnUmIOyFFQfHRkjJm5nXg==", "dev": true, "license": "CC0-1.0" }, @@ -23984,14 +24020,14 @@ } }, "node_modules/traverse": { - "version": "0.6.10", - "resolved": "https://registry.npmjs.org/traverse/-/traverse-0.6.10.tgz", - "integrity": "sha512-hN4uFRxbK+PX56DxYiGHsTn2dME3TVr9vbNqlQGcGcPhJAn+tdP126iA+TArMpI4YSgnTkMWyoLl5bf81Hi5TA==", + "version": "0.6.11", + "resolved": "https://registry.npmjs.org/traverse/-/traverse-0.6.11.tgz", + "integrity": "sha512-vxXDZg8/+p3gblxB6BhhG5yWVn1kGRlaL8O78UDXc3wRnPizB5g83dcvWV1jpDMIPnjZjOFuxlMmE82XJ4407w==", "license": "MIT", "dependencies": { - "gopd": "^1.0.1", - "typedarray.prototype.slice": "^1.0.3", - "which-typed-array": "^1.1.15" + "gopd": "^1.2.0", + "typedarray.prototype.slice": "^1.0.5", + "which-typed-array": "^1.1.18" }, "engines": { "node": ">= 0.4" @@ -26863,7 +26899,7 @@ "@contentstack/cli-cm-seed": "~1.10.0", "@contentstack/cli-command": "~1.3.2", "@contentstack/cli-config": "~1.9.0", - "@contentstack/cli-launch": "~1.3.1", + "@contentstack/cli-launch": "~1.4.1", "@contentstack/cli-migration": "~1.6.4", "@contentstack/cli-utilities": "~1.8.0", "@contentstack/cli-variants": "~1.1.4", @@ -26970,9 +27006,9 @@ "license": "MIT" }, "packages/contentstack-audit/node_modules/@types/node": { - "version": "20.17.12", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.17.12.tgz", - "integrity": "sha512-vo/wmBgMIiEA23A/knMfn/cf37VnuF52nZh5ZoW0GWt4e4sxNquibrMRJ7UQsA06+MBx9r/H1jsI9grYjQCQlw==", + "version": "20.17.14", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.17.14.tgz", + "integrity": "sha512-w6qdYetNL5KRBiSClK/KWai+2IMEJuAj+EujKCumalFOwXtvOXaEan9AuwcRID2IcOIAWSIfR495hBtgKlx2zg==", "dev": true, "license": "MIT", "dependencies": { @@ -28426,323 +28462,6 @@ "node": ">=4" } }, - "packages/contentstack-launch": { - "name": "@contentstack/cli-launch", - "version": "1.3.1", - "license": "MIT", - "dependencies": { - "@apollo/client": "^3.11.8", - "@contentstack/cli-command": "~1.3.2", - "@contentstack/cli-utilities": "~1.8.0", - "@oclif/core": "^3.27.0", - "@oclif/plugin-help": "^5.2.20", - "@oclif/plugin-plugins": "^5.4.15", - "@types/express": "^4.17.21", - "@types/express-serve-static-core": "^4.17.34", - "adm-zip": "^0.5.16", - "chalk": "^4.1.2", - "cross-fetch": "^3.1.8", - "dotenv": "^16.4.7", - "esm": "^3.2.25", - "express": "^4.21.1", - "form-data": "^4.0.0", - "graphql": "^16.9.0", - "ini": "^3.0.1", - "lodash": "^4.17.21", - "open": "^8.4.2", - "winston": "^3.17.0" - }, - "bin": { - "launch": "bin/run.js" - }, - "devDependencies": { - "@oclif/test": "^4.1.6", - "@types/adm-zip": "^0.5.7", - "@types/chai": "^4.3.20", - "@types/esm": "^3.2.2", - "@types/ini": "^1.3.34", - "@types/lodash": "^4.17.13", - "@types/node": "^16.18.121", - "chai": "^4.5.0", - "eslint": "^7.32.0", - "eslint-config-oclif": "^4", - "eslint-config-oclif-typescript": "^3.1.13", - "oclif": "^3.17.2", - "shx": "^0.3.4", - "ts-node": "^10.9.2", - "tslib": "^2.8.1", - "typescript": "^4.9.5" - }, - "engines": { - "node": ">=14.0.0" - } - }, - "packages/contentstack-launch/node_modules/@babel/code-frame": { - "version": "7.12.11", - "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.12.11.tgz", - "integrity": "sha512-Zt1yodBx1UcyiePMSkWnU4hPqhwq7hGi2nFL1LeA3EUl+q2LQx16MISgJ0+z7dnmgvP9QtIleuETGOiOH1RcIw==", - "dev": true, - "license": "MIT", - "dependencies": { - "@babel/highlight": "^7.10.4" - } - }, - "packages/contentstack-launch/node_modules/@eslint/eslintrc": { - "version": "0.4.3", - "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-0.4.3.tgz", - "integrity": "sha512-J6KFFz5QCYUJq3pf0mjEcCJVERbzv71PUIDczuh9JkwGEzced6CO5ADLHB1rbf/+oPBtoPfMYNOpGDzCANlbXw==", - "dev": true, - "license": "MIT", - "dependencies": { - "ajv": "^6.12.4", - "debug": "^4.1.1", - "espree": "^7.3.0", - "globals": "^13.9.0", - "ignore": "^4.0.6", - "import-fresh": "^3.2.1", - "js-yaml": "^3.13.1", - "minimatch": "^3.0.4", - "strip-json-comments": "^3.1.1" - }, - "engines": { - "node": "^10.12.0 || >=12.0.0" - } - }, - "packages/contentstack-launch/node_modules/@humanwhocodes/config-array": { - "version": "0.5.0", - "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.5.0.tgz", - "integrity": "sha512-FagtKFz74XrTl7y6HCzQpwDfXP0yhxe9lHLD1UZxjvZIcbyRz8zTFF/yYNfSfzU414eDwZ1SrO0Qvtyf+wFMQg==", - "deprecated": "Use @eslint/config-array instead", - "dev": true, - "license": "Apache-2.0", - "dependencies": { - "@humanwhocodes/object-schema": "^1.2.0", - "debug": "^4.1.1", - "minimatch": "^3.0.4" - }, - "engines": { - "node": ">=10.10.0" - } - }, - "packages/contentstack-launch/node_modules/@humanwhocodes/object-schema": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-1.2.1.tgz", - "integrity": "sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA==", - "deprecated": "Use @eslint/object-schema instead", - "dev": true, - "license": "BSD-3-Clause" - }, - "packages/contentstack-launch/node_modules/@types/node": { - "version": "16.18.123", - "resolved": "https://registry.npmjs.org/@types/node/-/node-16.18.123.tgz", - "integrity": "sha512-/n7I6V/4agSpJtFDKKFEa763Hc1z3hmvchobHS1TisCOTKD5nxq8NJ2iK7SRIMYL276Q9mgWOx2AWp5n2XI6eA==", - "dev": true, - "license": "MIT" - }, - "packages/contentstack-launch/node_modules/acorn": { - "version": "7.4.1", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.4.1.tgz", - "integrity": "sha512-nQyp0o1/mNdbTO1PO6kHkwSrmgZ0MT/jCCpNiwbUjGoRN4dlBhqJtoQuCnEOKzgTVwg0ZWiCoQy6SxMebQVh8A==", - "dev": true, - "license": "MIT", - "bin": { - "acorn": "bin/acorn" - }, - "engines": { - "node": ">=0.4.0" - } - }, - "packages/contentstack-launch/node_modules/ajv": { - "version": "6.12.6", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", - "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", - "dev": true, - "license": "MIT", - "dependencies": { - "fast-deep-equal": "^3.1.1", - "fast-json-stable-stringify": "^2.0.0", - "json-schema-traverse": "^0.4.1", - "uri-js": "^4.2.2" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/epoberezkin" - } - }, - "packages/contentstack-launch/node_modules/brace-expansion": { - "version": "1.1.11", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", - "dev": true, - "license": "MIT", - "dependencies": { - "balanced-match": "^1.0.0", - "concat-map": "0.0.1" - } - }, - "packages/contentstack-launch/node_modules/eslint": { - "version": "7.32.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-7.32.0.tgz", - "integrity": "sha512-VHZ8gX+EDfz+97jGcgyGCyRia/dPOd6Xh9yPv8Bl1+SoaIwD+a/vlrOmGRUyOYu7MwUhc7CxqeaDZU13S4+EpA==", - "deprecated": "This version is no longer supported. Please see https://eslint.org/version-support for other options.", - "dev": true, - "license": "MIT", - "dependencies": { - "@babel/code-frame": "7.12.11", - "@eslint/eslintrc": "^0.4.3", - "@humanwhocodes/config-array": "^0.5.0", - "ajv": "^6.10.0", - "chalk": "^4.0.0", - "cross-spawn": "^7.0.2", - "debug": "^4.0.1", - "doctrine": "^3.0.0", - "enquirer": "^2.3.5", - "escape-string-regexp": "^4.0.0", - "eslint-scope": "^5.1.1", - "eslint-utils": "^2.1.0", - "eslint-visitor-keys": "^2.0.0", - "espree": "^7.3.1", - "esquery": "^1.4.0", - "esutils": "^2.0.2", - "fast-deep-equal": "^3.1.3", - "file-entry-cache": "^6.0.1", - "functional-red-black-tree": "^1.0.1", - "glob-parent": "^5.1.2", - "globals": "^13.6.0", - "ignore": "^4.0.6", - "import-fresh": "^3.0.0", - "imurmurhash": "^0.1.4", - "is-glob": "^4.0.0", - "js-yaml": "^3.13.1", - "json-stable-stringify-without-jsonify": "^1.0.1", - "levn": "^0.4.1", - "lodash.merge": "^4.6.2", - "minimatch": "^3.0.4", - "natural-compare": "^1.4.0", - "optionator": "^0.9.1", - "progress": "^2.0.0", - "regexpp": "^3.1.0", - "semver": "^7.2.1", - "strip-ansi": "^6.0.0", - "strip-json-comments": "^3.1.0", - "table": "^6.0.9", - "text-table": "^0.2.0", - "v8-compile-cache": "^2.0.3" - }, - "bin": { - "eslint": "bin/eslint.js" - }, - "engines": { - "node": "^10.12.0 || >=12.0.0" - }, - "funding": { - "url": "https://opencollective.com/eslint" - } - }, - "packages/contentstack-launch/node_modules/eslint-utils": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-2.1.0.tgz", - "integrity": "sha512-w94dQYoauyvlDc43XnGB8lU3Zt713vNChgt4EWwhXAP2XkBvndfxF0AgIqKOOasjPIPzj9JqgwkwbCYD0/V3Zg==", - "dev": true, - "license": "MIT", - "dependencies": { - "eslint-visitor-keys": "^1.1.0" - }, - "engines": { - "node": ">=6" - }, - "funding": { - "url": "https://github.com/sponsors/mysticatea" - } - }, - "packages/contentstack-launch/node_modules/eslint-utils/node_modules/eslint-visitor-keys": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.3.0.tgz", - "integrity": "sha512-6J72N8UNa462wa/KFODt/PJ3IU60SDpC3QXC1Hjc1BXXpfL2C9R5+AU7jhe0F6GREqVMh4Juu+NY7xn+6dipUQ==", - "dev": true, - "license": "Apache-2.0", - "engines": { - "node": ">=4" - } - }, - "packages/contentstack-launch/node_modules/eslint-visitor-keys": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-2.1.0.tgz", - "integrity": "sha512-0rSmRBzXgDzIsD6mGdJgevzgezI534Cer5L/vyMX0kHzT/jiB43jRhd9YUlMGYLQy2zprNmoT8qasCGtY+QaKw==", - "dev": true, - "license": "Apache-2.0", - "engines": { - "node": ">=10" - } - }, - "packages/contentstack-launch/node_modules/espree": { - "version": "7.3.1", - "resolved": "https://registry.npmjs.org/espree/-/espree-7.3.1.tgz", - "integrity": "sha512-v3JCNCE64umkFpmkFGqzVKsOT0tN1Zr+ueqLZfpV1Ob8e+CEgPWa+OxCoGH3tnhimMKIaBm4m/vaRpJ/krRz2g==", - "dev": true, - "license": "BSD-2-Clause", - "dependencies": { - "acorn": "^7.4.0", - "acorn-jsx": "^5.3.1", - "eslint-visitor-keys": "^1.3.0" - }, - "engines": { - "node": "^10.12.0 || >=12.0.0" - } - }, - "packages/contentstack-launch/node_modules/espree/node_modules/eslint-visitor-keys": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.3.0.tgz", - "integrity": "sha512-6J72N8UNa462wa/KFODt/PJ3IU60SDpC3QXC1Hjc1BXXpfL2C9R5+AU7jhe0F6GREqVMh4Juu+NY7xn+6dipUQ==", - "dev": true, - "license": "Apache-2.0", - "engines": { - "node": ">=4" - } - }, - "packages/contentstack-launch/node_modules/glob-parent": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", - "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", - "dev": true, - "license": "ISC", - "dependencies": { - "is-glob": "^4.0.1" - }, - "engines": { - "node": ">= 6" - } - }, - "packages/contentstack-launch/node_modules/ignore": { - "version": "4.0.6", - "resolved": "https://registry.npmjs.org/ignore/-/ignore-4.0.6.tgz", - "integrity": "sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">= 4" - } - }, - "packages/contentstack-launch/node_modules/json-schema-traverse": { - "version": "0.4.1", - "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", - "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", - "dev": true, - "license": "MIT" - }, - "packages/contentstack-launch/node_modules/minimatch": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", - "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", - "dev": true, - "license": "ISC", - "dependencies": { - "brace-expansion": "^1.1.7" - }, - "engines": { - "node": "*" - } - }, "packages/contentstack-migrate-rte": { "name": "@contentstack/cli-cm-migrate-rte", "version": "1.4.20", @@ -29007,9 +28726,9 @@ } }, "packages/contentstack-variants/node_modules/@types/node": { - "version": "20.17.12", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.17.12.tgz", - "integrity": "sha512-vo/wmBgMIiEA23A/knMfn/cf37VnuF52nZh5ZoW0GWt4e4sxNquibrMRJ7UQsA06+MBx9r/H1jsI9grYjQCQlw==", + "version": "20.17.14", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.17.14.tgz", + "integrity": "sha512-w6qdYetNL5KRBiSClK/KWai+2IMEJuAj+EujKCumalFOwXtvOXaEan9AuwcRID2IcOIAWSIfR495hBtgKlx2zg==", "dev": true, "license": "MIT", "dependencies": { diff --git a/packages/contentstack-audit/README.md b/packages/contentstack-audit/README.md index bfb796ec00..d01457c536 100644 --- a/packages/contentstack-audit/README.md +++ b/packages/contentstack-audit/README.md @@ -269,7 +269,7 @@ EXAMPLES $ csdx plugins ``` -_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.22/src/commands/plugins/index.ts)_ +_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.25/src/commands/plugins/index.ts)_ ## `csdx plugins:add PLUGIN` @@ -343,7 +343,7 @@ EXAMPLES $ csdx plugins:inspect myplugin ``` -_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.22/src/commands/plugins/inspect.ts)_ +_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.25/src/commands/plugins/inspect.ts)_ ## `csdx plugins:install PLUGIN` @@ -392,7 +392,7 @@ EXAMPLES $ csdx plugins:install someuser/someplugin ``` -_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.22/src/commands/plugins/install.ts)_ +_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.25/src/commands/plugins/install.ts)_ ## `csdx plugins:link PATH` @@ -423,7 +423,7 @@ EXAMPLES $ csdx plugins:link myplugin ``` -_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.22/src/commands/plugins/link.ts)_ +_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.25/src/commands/plugins/link.ts)_ ## `csdx plugins:remove [PLUGIN]` @@ -464,7 +464,7 @@ FLAGS --reinstall Reinstall all plugins after uninstalling. ``` -_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.22/src/commands/plugins/reset.ts)_ +_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.25/src/commands/plugins/reset.ts)_ ## `csdx plugins:uninstall [PLUGIN]` @@ -492,7 +492,7 @@ EXAMPLES $ csdx plugins:uninstall myplugin ``` -_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.22/src/commands/plugins/uninstall.ts)_ +_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.25/src/commands/plugins/uninstall.ts)_ ## `csdx plugins:unlink [PLUGIN]` @@ -536,5 +536,5 @@ DESCRIPTION Update installed plugins. ``` -_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.22/src/commands/plugins/update.ts)_ +_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.25/src/commands/plugins/update.ts)_ diff --git a/packages/contentstack-auth/README.md b/packages/contentstack-auth/README.md index 8a3202f9f8..829a1a02be 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.22 darwin-arm64 node-v22.2.0 +@contentstack/cli-auth/1.3.22 darwin-arm64 node-v22.8.0 $ csdx --help [COMMAND] USAGE $ csdx COMMAND diff --git a/packages/contentstack-bootstrap/README.md b/packages/contentstack-bootstrap/README.md index 5da9638045..a0b60dfd28 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.13.0 darwin-arm64 node-v22.2.0 +@contentstack/cli-cm-bootstrap/1.13.0 darwin-arm64 node-v22.8.0 $ csdx --help [COMMAND] USAGE $ csdx COMMAND diff --git a/packages/contentstack-branches/README.md b/packages/contentstack-branches/README.md index 8f9394a973..3b88d50b8a 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.2.0 darwin-arm64 node-v22.2.0 +@contentstack/cli-cm-branches/1.2.0 darwin-arm64 node-v22.8.0 $ csdx --help [COMMAND] USAGE $ csdx COMMAND diff --git a/packages/contentstack-bulk-publish/README.md b/packages/contentstack-bulk-publish/README.md index 57111ad36b..593d218bb0 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.7.0 darwin-arm64 node-v22.2.0 +@contentstack/cli-cm-bulk-publish/1.7.1 darwin-arm64 node-v22.8.0 $ csdx --help [COMMAND] USAGE $ csdx COMMAND diff --git a/packages/contentstack-clone/README.md b/packages/contentstack-clone/README.md index ac32885ae9..a557fddcbc 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.13.0 darwin-arm64 node-v22.2.0 +@contentstack/cli-cm-clone/1.13.0 darwin-arm64 node-v22.8.0 $ csdx --help [COMMAND] USAGE $ csdx COMMAND diff --git a/packages/contentstack-config/README.md b/packages/contentstack-config/README.md index 9a2906ddc4..3896211a93 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.9.0 darwin-arm64 node-v22.2.0 +@contentstack/cli-config/1.9.0 darwin-arm64 node-v22.8.0 $ csdx --help [COMMAND] USAGE $ csdx COMMAND diff --git a/packages/contentstack-export/README.md b/packages/contentstack-export/README.md index 2f5f11db33..30aaac0996 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.14.1 darwin-arm64 node-v22.2.0 +@contentstack/cli-cm-export/1.14.1 darwin-arm64 node-v22.8.0 $ csdx --help [COMMAND] USAGE $ csdx COMMAND diff --git a/packages/contentstack-import-setup/README.md b/packages/contentstack-import-setup/README.md index a5ee7c575f..b93d8a1606 100644 --- a/packages/contentstack-import-setup/README.md +++ b/packages/contentstack-import-setup/README.md @@ -47,7 +47,7 @@ $ npm install -g @contentstack/cli-cm-import-setup $ csdx COMMAND running command... $ csdx (--version) -@contentstack/cli-cm-import-setup/1.0.0-beta.1 darwin-arm64 node-v22.2.0 +@contentstack/cli-cm-import-setup/1.0.0-beta.1 darwin-arm64 node-v22.8.0 $ csdx --help [COMMAND] USAGE $ csdx COMMAND diff --git a/packages/contentstack-import/README.md b/packages/contentstack-import/README.md index b976cd7126..ef1cf92d93 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.19.3 darwin-arm64 node-v22.2.0 +@contentstack/cli-cm-import/1.19.3 darwin-arm64 node-v22.8.0 $ csdx --help [COMMAND] USAGE $ csdx COMMAND diff --git a/packages/contentstack-launch/.editorconfig b/packages/contentstack-launch/.editorconfig deleted file mode 100755 index beffa3084e..0000000000 --- a/packages/contentstack-launch/.editorconfig +++ /dev/null @@ -1,11 +0,0 @@ -root = true - -[*] -indent_style = space -indent_size = 2 -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -[*.md] -trim_trailing_whitespace = false diff --git a/packages/contentstack-launch/.eslintignore b/packages/contentstack-launch/.eslintignore deleted file mode 100755 index 9b1c8b133c..0000000000 --- a/packages/contentstack-launch/.eslintignore +++ /dev/null @@ -1 +0,0 @@ -/dist diff --git a/packages/contentstack-launch/.eslintrc b/packages/contentstack-launch/.eslintrc deleted file mode 100755 index 7b846193cc..0000000000 --- a/packages/contentstack-launch/.eslintrc +++ /dev/null @@ -1,6 +0,0 @@ -{ - "extends": [ - "oclif", - "oclif-typescript" - ] -} diff --git a/packages/contentstack-launch/.gitignore b/packages/contentstack-launch/.gitignore deleted file mode 100755 index 968db68c60..0000000000 --- a/packages/contentstack-launch/.gitignore +++ /dev/null @@ -1,19 +0,0 @@ -*-debug.log -*-error.log -/.nyc_output -/dist -/lib -/package-lock.json -/tmp -/yarn.lock -node_modules -oclif.manifest.json -.env -*.log -tsconfig.tsbuildinfo -dependabot.yml -.vscode -*.todo -/bkp -.editorconfig -/functions diff --git a/packages/contentstack-launch/.mocharc.json b/packages/contentstack-launch/.mocharc.json deleted file mode 100755 index 4a09d14464..0000000000 --- a/packages/contentstack-launch/.mocharc.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "require": [ - "test/helpers/init.js", - "ts-node/register" - ], - "watch-extensions": [ - "ts" - ], - "recursive": true, - "reporter": "spec", - "timeout": 60000 -} diff --git a/packages/contentstack-launch/.talismanrc b/packages/contentstack-launch/.talismanrc deleted file mode 100755 index 5ffc3a0962..0000000000 --- a/packages/contentstack-launch/.talismanrc +++ /dev/null @@ -1,4 +0,0 @@ -fileignoreconfig: -- filename: package-lock.json - checksum: 4e2b66f30d0b1167b4f1613c6d655f544749c4ce75bba10d0ccc24714dc9ce7d -version: "" \ No newline at end of file diff --git a/packages/contentstack-launch/LICENSE b/packages/contentstack-launch/LICENSE deleted file mode 100755 index f99e9ee588..0000000000 --- a/packages/contentstack-launch/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2024 Contentstack - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. \ No newline at end of file diff --git a/packages/contentstack-launch/README.md b/packages/contentstack-launch/README.md deleted file mode 100755 index 89d23f1343..0000000000 --- a/packages/contentstack-launch/README.md +++ /dev/null @@ -1,57 +0,0 @@ -# Launch CLI plugin - -[![oclif](https://img.shields.io/badge/cli-oclif-brightgreen.svg)](https://oclif.io) - -With Launch CLI, you can interact with the Contentstack Launch platform using the terminal to create, manage and deploy Launch projects. - - -* [Launch CLI plugin](#launch-cli-plugin) -* [Usage](#usage) -* [Installation steps](#installation-steps) -* [Commands](#commands) - - -# Usage - - -```sh-session -$ npm install -g @contentstack/cli-launch -$ csdx COMMAND -running command... -$ csdx (--version|-v) -@contentstack/cli-launch/1.3.1 darwin-arm64 node-v22.8.0 -$ csdx --help [COMMAND] -USAGE - $ csdx COMMAND -... -``` - - -# Installation steps - -```sh-session -GitHub installation steps: -$ git clone clone -$ npm install -$ npm run build -$ csdx plugins:link - -NPM installation steps: -$ csdx plugins:install @contentstack/cli-launch -$ csdx launch -``` - -# Commands - -```sh-session -$ csdx launch -start with launch flow -$ csdx launch:logs -To see server logs -$ csdx launch:logs --type d -To see deployment logs -$ csdx launch:functions -Run cloud functions locally -``` - - diff --git a/packages/contentstack-launch/SECURITY.md b/packages/contentstack-launch/SECURITY.md deleted file mode 100755 index b33a46b7ba..0000000000 --- a/packages/contentstack-launch/SECURITY.md +++ /dev/null @@ -1,27 +0,0 @@ -## Security - -Contentstack takes the security of our software products and services seriously, which includes all source code repositories managed through our GitHub organizations. - -If you believe you have found a security vulnerability in any Contentstack-owned repository, please report it to us as described below. - -## Reporting Security Issues - -**Please do not report security vulnerabilities through public GitHub issues.** - -Send email to [security@contentstack.com](mailto:security@contentstack.com). - -You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. - -Please include the requested information listed below (as much as you can provide) to help us better understand the nature and scope of the possible issue: - -- Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.) -- Full paths of source file(s) related to the manifestation of the issue -- The location of the affected source code (tag/branch/commit or direct URL) -- Any special configuration required to reproduce the issue -- Step-by-step instructions to reproduce the issue -- Proof-of-concept or exploit code (if possible) -- Impact of the issue, including how an attacker might exploit the issue - -This information will help us triage your report more quickly. - -[https://www.contentstack.com/trust/](https://www.contentstack.com/trust/) \ No newline at end of file diff --git a/packages/contentstack-launch/bin/dev.cmd b/packages/contentstack-launch/bin/dev.cmd deleted file mode 100755 index 077b57ae75..0000000000 --- a/packages/contentstack-launch/bin/dev.cmd +++ /dev/null @@ -1,3 +0,0 @@ -@echo off - -node "%~dp0\dev" %* \ No newline at end of file diff --git a/packages/contentstack-launch/bin/dev.js b/packages/contentstack-launch/bin/dev.js deleted file mode 100755 index b2e3af8096..0000000000 --- a/packages/contentstack-launch/bin/dev.js +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env node_modules/.bin/ts-node -// eslint-disable-next-line node/shebang, unicorn/prefer-top-level-await -(async () => { - const oclif = await import('@oclif/core'); - await oclif.execute({ development: true, dir: __dirname }); -})(); diff --git a/packages/contentstack-launch/bin/run.cmd b/packages/contentstack-launch/bin/run.cmd deleted file mode 100755 index 968fc30758..0000000000 --- a/packages/contentstack-launch/bin/run.cmd +++ /dev/null @@ -1,3 +0,0 @@ -@echo off - -node "%~dp0\run" %* diff --git a/packages/contentstack-launch/bin/run.js b/packages/contentstack-launch/bin/run.js deleted file mode 100755 index 8baf302391..0000000000 --- a/packages/contentstack-launch/bin/run.js +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env node - -// eslint-disable-next-line unicorn/prefer-top-level-await -(async () => { - const oclif = await import('@oclif/core'); - await oclif.execute({ development: false, dir: __dirname }); -})(); diff --git a/packages/contentstack-launch/example.env b/packages/contentstack-launch/example.env deleted file mode 100644 index 7e4000d1b4..0000000000 --- a/packages/contentstack-launch/example.env +++ /dev/null @@ -1,3 +0,0 @@ -ENVIRONMENT= -ORG= -PROJECT= diff --git a/packages/contentstack-launch/package.json b/packages/contentstack-launch/package.json deleted file mode 100755 index c070a5ffe6..0000000000 --- a/packages/contentstack-launch/package.json +++ /dev/null @@ -1,108 +0,0 @@ -{ - "name": "@contentstack/cli-launch", - "version": "1.3.1", - "description": "Launch related operations", - "author": "Contentstack CLI", - "bin": { - "launch": "./bin/run.js" - }, - "homepage": "https://github.com/contentstack/cli", - "license": "MIT", - "main": "dist/index.js", - "repository": "contentstack/cli", - "files": [ - "/bin", - "/dist", - "/npm-shrinkwrap.json", - "/oclif.manifest.json" - ], - "dependencies": { - "@apollo/client": "^3.11.8", - "@contentstack/cli-command": "~1.3.2", - "@contentstack/cli-utilities": "~1.8.0", - "@oclif/core": "^3.27.0", - "@oclif/plugin-help": "^5.2.20", - "@oclif/plugin-plugins": "^5.4.15", - "@types/express": "^4.17.21", - "@types/express-serve-static-core": "^4.17.34", - "adm-zip": "^0.5.16", - "chalk": "^4.1.2", - "cross-fetch": "^3.1.8", - "dotenv": "^16.4.7", - "esm": "^3.2.25", - "express": "^4.21.1", - "form-data": "^4.0.0", - "graphql": "^16.9.0", - "ini": "^3.0.1", - "lodash": "^4.17.21", - "open": "^8.4.2", - "winston": "^3.17.0" - }, - "devDependencies": { - "@oclif/test": "^4.1.6", - "@types/adm-zip": "^0.5.7", - "@types/chai": "^4.3.20", - "@types/esm": "^3.2.2", - "@types/ini": "^1.3.34", - "@types/lodash": "^4.17.13", - "@types/node": "^16.18.121", - "chai": "^4.5.0", - "eslint": "^7.32.0", - "eslint-config-oclif": "^4", - "eslint-config-oclif-typescript": "^3.1.13", - "oclif": "^3.17.2", - "shx": "^0.3.4", - "ts-node": "^10.9.2", - "tslib": "^2.8.1", - "typescript": "^4.9.5" - }, - "oclif": { - "bin": "csdx", - "commands": "./dist/commands", - "plugins": [ - "@oclif/plugin-help", - "@oclif/plugin-plugins" - ], - "topicSeparator": ":", - "additionalHelpFlags": [ - "-h" - ], - "additionalVersionFlags": [ - "-v" - ], - "repositoryPrefix": "<%- repo %>/blob/main/packages/contentstack-launch/<%- commandPath %>" - }, - "scripts": { - "build-bkp": "shx rm -rf dist && tsc -b", - "lint": "eslint . --ext .ts --config .eslintrc", - "postpack": "shx rm -f oclif.manifest.json", - "posttest": "npm run lint", - "prepack-bkp": "npm run build && oclif manifest && oclif readme", - "test": "mocha --forbid-only \"test/**/*.test.ts\"", - "version": "oclif readme && git add README.md", - "build": "npm run clean && npm run compile", - "clean": "rm -rf ./dist ./node_modules tsconfig.build.tsbuildinfo", - "compile": "tsc -b tsconfig.json", - "prepack": "pnpm compile && oclif manifest && oclif readme", - "test:unit": "mocha --forbid-only \"test/unit/**/*.test.ts\"", - "test:unit:report": "nyc --extension .ts mocha --forbid-only \"test/unit/**/*.test.ts\"" - }, - "engines": { - "node": ">=14.0.0" - }, - "bugs": "https://github.com/contentstack/launch-cli/issues", - "keywords": [ - "oclif" - ], - "types": "dist/index.d.ts", - "csdxConfig": { - "shortCommandName": { - "launch": "LNCH", - "launch:logs": "LNCH-LGS", - "launch:open": "LNCH-OPN", - "launch:functions": "LNCH-FN", - "launch:environments": "LNCH-ENV", - "launch:deployments": "LNCH-DPLMNT" - } - } -} diff --git a/packages/contentstack-launch/src/adapters/base-class.ts b/packages/contentstack-launch/src/adapters/base-class.ts deleted file mode 100755 index b58f5712c8..0000000000 --- a/packages/contentstack-launch/src/adapters/base-class.ts +++ /dev/null @@ -1,794 +0,0 @@ -import open from 'open'; -import dotEnv from 'dotenv'; -import map from 'lodash/map'; -import keys from 'lodash/keys'; -import find from 'lodash/find'; -import last from 'lodash/last'; -import merge from 'lodash/merge'; -import first from 'lodash/first'; -import split from 'lodash/split'; -import EventEmitter from 'events'; -import filter from 'lodash/filter'; -import replace from 'lodash/replace'; -import forEach from 'lodash/forEach'; -import isEmpty from 'lodash/isEmpty'; -import includes from 'lodash/includes'; -import cloneDeep from 'lodash/cloneDeep'; -import { ApolloClient } from '@apollo/client/core'; -import { writeFileSync, existsSync, readFileSync } from 'fs'; -import { cliux as ux, ContentstackClient } from '@contentstack/cli-utilities'; - -import config from '../config'; -import { print, GraphqlApiClient, LogPolling, getOrganizations } from '../util'; -import { - branchesQuery, - frameworkQuery, - fileFrameworkQuery, - createDeploymentMutation, - cmsEnvironmentVariablesQuery, -} from '../graphql'; -import { - LogFn, - ExitFn, - Providers, - ConfigType, - AdapterConstructorInputs, - EmitMessage, - DeploymentLogResp, - ServerLogResp, -} from '../types'; - -export default class BaseClass { - public log: LogFn; - public exit: ExitFn; - public config: ConfigType; - public analyticsInfo: string; - public $event!: EventEmitter; - public framework!: Record; - public apolloClient: ApolloClient; - public projectCreationRetryCount: number = 0; - public apolloLogsClient: ApolloClient | undefined; - public envVariables: Array> = []; - public managementSdk: ContentstackClient | undefined; - - constructor(options: AdapterConstructorInputs) { - const { log, exit, config, $event, apolloClient, managementSdk, analyticsInfo, apolloLogsClient } = options; - this.config = config; - this.$event = $event; - this.log = log || console.log; - this.apolloClient = apolloClient; - this.analyticsInfo = analyticsInfo; - this.managementSdk = managementSdk; - this.apolloLogsClient = apolloLogsClient; - this.exit = exit || ((code: number = 0) => process.exit(code)); - } - - /** - * @method initApolloClient - initialize Apollo client - * - * @memberof BaseClass - */ - async initApolloClient(): Promise { - this.apolloClient = await new GraphqlApiClient({ - headers: { - 'X-CS-CLI': this.analyticsInfo, - 'x-project-uid': this.config.currentConfig.uid, - organization_uid: this.config.currentConfig.organizationUid, - }, - baseUrl: this.config.manageApiBaseUrl, - }).apolloClient; - } - - /** - * @method createNewDeployment - Create new deployment on existing launch project - * - * @return {*} {Promise} - * @memberof GitHub - */ - async createNewDeployment(skipGitData = false, uploadUid?: string): Promise { - const deployment: Record = { - environment: (first(this.config.currentConfig.environments) as Record)?.uid, - }; - - if (uploadUid) { - deployment.uploadUid = uploadUid; - } - - await this.apolloClient - .mutate({ - mutation: createDeploymentMutation, - variables: { deployment, skipGitData }, - }) - .then(({ data: { deployment } }) => { - this.log('Deployment process started.!', 'info'); - this.config.currentConfig.deployments.push(deployment); - }) - .catch((error) => { - this.log('Deployment process failed.!', 'error'); - this.log(error, 'error'); - this.exit(1); - }); - } - - /** - * @method selectOrg - select organization - * - * @return {*} {Promise} - * @memberof BaseClass - */ - async selectOrg(): Promise { - const organizations = - (await getOrganizations({ log: this.log, managementSdk: this.managementSdk as ContentstackClient })) || []; - - const selectedOrgUid = this.config.flags.org; - - if (selectedOrgUid) { - const orgExists = find(organizations, { uid: selectedOrgUid }); - if (orgExists) { - this.config.currentConfig.organizationUid = selectedOrgUid; - } else { - this.log('Organization UID not found!', 'error'); - this.exit(1); - } - } else { - this.config.currentConfig.organizationUid = await ux - .inquire({ - type: 'search-list', - name: 'Organization', - choices: organizations, - message: 'Choose an organization', - }) - .then((name) => (find(organizations, { name }) as Record)?.uid); - } - - // NOTE re initialize apollo client once org selected - await this.initApolloClient(); - } - - /** - * @method selectProjectType - select project type/provider/adapter - * - * @return {*} {Promise} - * @memberof BaseClass - */ - async selectProjectType(): Promise { - const choices = [ - ...map(config.supportedAdapters, (provider) => ({ - value: provider, - name: `Continue with ${provider}`, - })), - { value: 'FileUpload', name: 'Continue with FileUpload' }, - ]; - - const selectedProvider: Providers = await ux.inquire({ - choices: choices, - type: 'search-list', - name: 'projectType', - message: 'Choose a project type to proceed', - }); - - this.config.provider = selectedProvider; - } - - /** - * @method detectFramework - detect the project framework - * - * @return {*} {Promise} - * @memberof BaseClass - */ - async detectFramework(): Promise { - const { fullName, defaultBranch } = this.config.repository || {}; - const query = this.config.provider === 'FileUpload' ? fileFrameworkQuery : frameworkQuery; - const variables = - this.config.provider === 'FileUpload' - ? { - query: { uploadUid: this.config.uploadUid }, - } - : { - query: { - provider: this.config.provider, - repoName: fullName, - branchName: defaultBranch, - }, - }; - this.config.framework = (await this.apolloClient - .query({ query, variables }) - .then( - ({ - data: { - framework: { framework }, - }, - }) => framework, - ) - .catch((_error) => { - // this.log("Something went wrong. Please try again.", "warn"); - // this.log(error, "error"); - // this.exit(1); - })) || { - envVariables: '', - }; - - const choices = []; - const framework = find(this.config.listOfFrameWorks, ({ value }) => value === this.config.framework)?.name; - - if (framework) { - choices.push({ - name: framework, - value: this.config.framework, - }); - } - - choices.push(...filter(this.config.listOfFrameWorks, ({ value }) => value !== this.config.framework)); - - this.config.framework = await ux.inquire({ - choices, - type: 'search-list', - name: 'frameworkPreset', - message: 'Framework Preset', - default: this.config.framework, - }); - } - - /** - * @method getCmsEnvironmentVariables - get list of environment variables - * - * @return {*} {Promise} - * @memberof BaseClass - */ - async getCmsEnvironmentVariables(): Promise { - this.envVariables = (await this.apolloClient - .query({ query: cmsEnvironmentVariablesQuery }) - .then(({ data: { envVariables } }) => envVariables) - .catch((error) => this.log(error, 'error'))) || { - envVariables: undefined, - }; - } - - /** - * @method selectStack - Select stack to import variables, tokens - * - * @return {*} {Promise} - * @memberof BaseClass - */ - async selectStack(): Promise { - const listOfStacks = - (await this.managementSdk - ?.stack() - .query({ organization_uid: this.config.currentConfig.organizationUid }) - .find() - .then(({ items }) => map(items, ({ name, api_key }) => ({ name, value: name, api_key }))) - .catch((error) => { - this.log('Unable to fetch stacks.!', { color: 'yellow' }); - this.log(error, 'error'); - this.exit(1); - })) || []; - - if (this.config.selectedStack) { - this.config.selectedStack = find(listOfStacks, { api_key: this.config.selectedStack }); - } else { - this.config.selectedStack = await ux - .inquire({ - name: 'stack', - type: 'search-list', - choices: listOfStacks, - message: 'Stack', - }) - .then((name) => find(listOfStacks, { name })); - } - } - - /** - * @method selectDeliveryToken - Select delivery token from a stack - * - * @return {*} {Promise} - * @memberof BaseClass - */ - async selectDeliveryToken(): Promise { - const listOfDeliveryTokens = - (await this.managementSdk - ?.stack({ api_key: this.config.selectedStack.api_key }) - .deliveryToken() - .query() - .find() - .then(({ items }) => - map(items, ({ name, token, scope }) => ({ - name, - token, - scope, - value: name, - })), - ) - .catch((error) => { - this.log('Unable to fetch the delivery token!', 'warn'); - this.log(error, 'error'); - this.exit(1); - })) || []; - - if (this.config.deliveryToken) { - this.config.deliveryToken = find(listOfDeliveryTokens, { token: this.config.deliveryToken }); - } else { - this.config.deliveryToken = await ux - .inquire({ - type: 'search-list', - name: 'deliveryToken', - choices: listOfDeliveryTokens, - message: 'Delivery token', - }) - .then((name) => find(listOfDeliveryTokens, { name }) as Record); - } - this.config.environment = this.config.deliveryToken?.scope[0]?.environments[0]?.name; - } - - /** - * @method promptForEnvValues - Prompt and get manual entry of environment variables - * - * @return {*} {Promise} - * @memberof BaseClass - */ - async promptForEnvValues(): Promise { - let addNew = true; - const envVariables = []; - - if (!this.config.envVariables) { - do { - const variable = await ux - .inquire({ - type: 'input', - name: 'variable', - message: - 'Enter key and value with a colon between them, and use a comma(,) for the key-value pair. Format: :, : Ex: APP_ENV:prod, TEST_ENV:testVal', - }) - .then((variable) => { - return map(split(variable as string, ','), (variable) => { - let [key, value] = split(variable as string, ':'); - value = (value || '').trim(); - key = (key || '').trim(); - - return { key, value }; - }).filter(({ key }) => key); - }); - - envVariables.push(...variable); - - if ( - !(await ux.inquire({ - type: 'confirm', - name: 'canImportFromStack', - message: 'Would you like to add more variables?', - })) - ) { - addNew = false; - } - } while (addNew); - - this.envVariables.push(...envVariables); - } else { - if (typeof this.config.envVariables === 'string') { - const variable = map(split(this.config.envVariables as string, ','), (variable) => { - let [key, value] = split(variable as string, ':'); - value = (value || '').trim(); - key = (key || '').trim(); - - return { key, value }; - }); - this.envVariables.push(...variable); - } - } - } - - /** - * @method prepareLaunchConfig - prepare and write launch config in to dist. - * - * @memberof BaseClass - */ - prepareLaunchConfig(): void { - let data: Record = {}; - - if (this.config.config && existsSync(this.config.config)) { - data = require(this.config.config); - } - - if (this.config.branch) { - data[this.config.branch] = this.config.currentConfig; - } else { - data.project = this.config.currentConfig; - } - - writeFileSync(`${this.config.projectBasePath}/${this.config.configName}`, JSON.stringify(data), { - encoding: 'utf8', - flag: 'w', - }); - } - - /** - * @method connectToAdapterOnUi - Open browser to connect with adapter with launch (GitHub etc.,) - * - * @param {boolean} [emit=true] - * @return {*} {Promise} - * @memberof BaseClass - */ - async connectToAdapterOnUi(emit = true): Promise { - await this.selectProjectType(); - - if (includes(this.config.supportedAdapters, this.config.provider)) { - const baseUrl = this.config.host.startsWith('http') ? this.config.host : `https://${this.config.host}`; - - const gitHubConnectUrl = `${baseUrl.replace('api', 'app').replace('io', 'com')}/#!/launch`; - this.log(`You can connect your ${this.config.provider} account to the UI using the following URL:`, 'info'); - this.log(gitHubConnectUrl, { color: 'green' }); - open(gitHubConnectUrl); - this.exit(1); - } else if (emit) { - this.$event.emit('provider-changed'); - } - } - - /** - * @method queryBranches - Query all paginated branches - * - * @param {Record} variables - * @param {any[]} [branchesRes=[]] - * @return {*} {Promise} - * @memberof BaseClass - */ - async queryBranches(variables: Record, branchesRes: any[] = []): Promise { - const branches = await this.apolloClient - .query({ - query: branchesQuery, - variables, - }) - .then(({ data: { branches } }) => branches) - .catch((error) => { - this.log('Something went wrong. Please try again.', 'warn'); - this.log(error, 'error'); - this.exit(1); - }); - - if (branches) { - branchesRes.push(...map(branches.edges, 'node')); - - if (branches.pageInfo.hasNextPage) { - variables.page = branches.pageData.page + 1; - return await this.queryBranches(variables, branchesRes); - } - } - - return branchesRes; - } - - /** - * @method selectBranch - Select a branch for launch process - * - * @return {*} {Promise} - * @memberof BaseClass - */ - async selectBranch(): Promise { - const variables = { - page: 1, - first: 100, - query: { - provider: this.config.provider, - repoName: this.config.repository?.fullName, - }, - }; - - const branches: Record[] = await this.queryBranches(variables); - - if (branches && this.config.flags.branch && find(branches, { name: this.config.flags.branch })) { - this.config.branch = this.config.flags.branch as any; - } else { - if (this.config.flags.branch) { - this.log('Branch name not found!', 'warn'); - } - - this.config.branch = await ux.inquire({ - name: 'branch', - message: 'Branch', - type: 'search-list', - choices: map(branches, 'name'), - default: this.config.repository?.defaultBranch, - }); - } - } - - /** - * @method inquireRequireValidation - Required validation for prompt - * - * @param {*} input - * @return {*} {(string | boolean)} - * @memberof BaseClass - */ - inquireRequireValidation(input: any): string | boolean { - if (isEmpty(input)) { - return "This field can't be empty."; - } - - return true; - } - - /** - * @method handleEnvImportFlow - Manage variables flow whether to import or manual input. - * - * @return {*} {Promise} - * @memberof BaseClass - */ - async handleEnvImportFlow(): Promise { - const variablePreparationType = - this.config.variableType || - (await ux.inquire({ - type: 'checkbox', - name: 'variablePreparationType', - default: this.config.framework, - choices: this.config.variablePreparationTypeOptions, - message: 'Import variables from a stack and/or manually add custom variables to the list', - // validate: this.inquireRequireValidation, - })); - - if (includes(variablePreparationType, 'Import variables from a stack')) { - await this.importEnvFromStack(); - } - if (includes(variablePreparationType, 'Manually add custom variables to the list')) { - await this.promptForEnvValues(); - } - if (includes(variablePreparationType, 'Import variables from the local env file')) { - await this.importVariableFromLocalConfig(); - } - - if (this.envVariables.length) { - this.printAllVariables(); - } else { - this.log('Please provide env file!', 'error'); - this.exit(1); - } - } - - /** - * @method importVariableFromLocalConfig - Import environment variable from local config - * - * @return {*} {Promise} - * @memberof BaseClass - */ - async importVariableFromLocalConfig(): Promise { - const localEnv = - dotEnv.config({ - path: `${this.config.projectBasePath}/.env.local`, - }).parsed || - dotEnv.config({ - path: this.config.projectBasePath, - }).parsed; - - if (!isEmpty(localEnv)) { - let envKeys: Record = keys(localEnv); - const existingEnvKeys = map(this.envVariables, 'key'); - const localEnvData = map(envKeys, (key) => ({ - key, - value: localEnv[key], - })); - - if (find(existingEnvKeys, (key) => includes(envKeys, key))) { - this.log('Duplicate environment variable keys found.', 'warn'); - if ( - await ux.inquire({ - default: false, - type: 'confirm', - name: 'deployLatestSource', - message: 'Would you like to keep the local environment variables?', - }) - ) { - this.envVariables = merge(this.envVariables, localEnvData); - } else { - this.envVariables = merge(localEnvData, this.envVariables); - } - } else { - this.envVariables.push(...localEnvData); - } - } - } - - /** - * @method importEnvFromStack - Import environment variables from stack - * - * @return {*} {Promise} - * @memberof BaseClass - */ - async importEnvFromStack(): Promise { - await this.selectStack(); - await this.selectDeliveryToken(); - print([ - { message: '?', color: 'green' }, - { message: 'Stack Environment', bold: true }, - { message: this.config.environment || '', color: 'cyan' }, - ]); - await this.getCmsEnvironmentVariables(); - - this.envVariables = map(cloneDeep(this.envVariables), (variable) => { - switch (variable.key) { - case 'CONTENTSTACK_API_HOST': - case 'CONTENTSTACK_CDN': - if (variable.value.startsWith('http')) { - const url = new URL(variable.value); - variable.value = url?.host || this.config.host; - } - break; - case 'CONTENTSTACK_ENVIRONMENT': - variable.value = this.config.environment; - break; - case 'CONTENTSTACK_API_KEY': - variable.value = this.config.selectedStack.api_key; - break; - case 'CONTENTSTACK_DELIVERY_TOKEN': - variable.value = this.config.deliveryToken?.token; - break; - } - - return variable; - }); - } - - /** - * @method printAllVariables - Print/Display all variables on ui - * - * @memberof BaseClass - */ - printAllVariables(): void { - ux.table( - [ - ...(this.config.flags['show-variables'] - ? this.envVariables - : this.envVariables.map(({ key, value }) => ({ - key, - value: replace(value, /./g, '*'), - }))), - { key: '', value: '' }, - ], - { - key: { - minWidth: 7, - }, - value: { - minWidth: 7, - }, - }, - ); - } - - /** - * @method showLogs - show deployment logs on terminal/UI - * - * @return {*} {Promise} - * @memberof BaseClass - */ - async showLogs(): Promise { - this.apolloLogsClient = await new GraphqlApiClient({ - headers: { - 'X-CS-CLI': this.analyticsInfo, - 'x-project-uid': this.config.currentConfig.uid, - organization_uid: this.config.currentConfig.organizationUid, - }, - baseUrl: this.config.logsApiBaseUrl, - }).apolloClient; - this.apolloClient = await new GraphqlApiClient({ - headers: { - 'X-CS-CLI': this.analyticsInfo, - 'x-project-uid': this.config.currentConfig.uid, - organization_uid: this.config.currentConfig.organizationUid, - }, - baseUrl: this.config.manageApiBaseUrl, - }).apolloClient; - this.config.environment = (last(this.config.currentConfig.environments) as Record)?.uid; - this.config.deployment = (last(this.config.currentConfig.deployments) as Record)?.uid; - const logs = new LogPolling({ - config: this.config, - $event: this.$event, - apolloManageClient: this.apolloClient, - apolloLogsClient: this.apolloLogsClient, - }); - logs.deploymentLogs(); - return new Promise((resolve) => { - this.$event.on('deployment-logs', (event: EmitMessage) => { - const { message, msgType } = event; - if (message === 'DONE') return resolve(true); - - if (msgType === 'info') { - forEach(message, (log: DeploymentLogResp | ServerLogResp) => { - let formattedLogTimestamp = new Date(log.timestamp).toISOString()?.slice(0, 23)?.replace('T', ' '); - this.log(`${formattedLogTimestamp}: ${log.message}`, msgType); - }); - } else if (msgType === 'error') { - this.log(message, msgType); - resolve(true); - } - }); - }); - } - - /** - * @method handleNewProjectCreationError - * - * @param {*} error - * @return {*} {(Promise)} - * @memberof BaseClass - */ - async handleNewProjectCreationError(error: any): Promise { - this.log('New project creation failed!', 'error'); - - if (includes(error?.graphQLErrors?.[0]?.extensions?.exception?.messages, 'launch.PROJECTS.DUPLICATE_NAME')) { - this.log('Duplicate project name identified', 'error'); - - if (this.projectCreationRetryCount >= this.config.projectCreationRetryMaxCount) { - this.log('Reached max project creation retry limit', 'warn'); - } else if ( - await ux.inquire({ - type: 'confirm', - name: 'deployLatestSource', - message: "Would you like to change the project's name and try again?", - }) - ) { - this.config.projectName = await ux.inquire({ - type: 'input', - name: 'projectName', - message: 'Project Name', - default: this.config.repository?.name, - validate: this.inquireRequireValidation, - }); - - this.projectCreationRetryCount++; - - return true; - } - } else if (includes(error?.graphQLErrors?.[0]?.extensions?.exception?.messages, 'launch.PROJECTS.LIMIT_REACHED')) { - this.log('Launch project limit reached!', 'error'); - } else { - this.log(error, 'error'); - } - this.exit(1); - } - - /** - * @method showDeploymentUrl - show deployment URL and open it on browser - * - * @param {boolean} [openOnUi=true] - * @memberof BaseClass - */ - showDeploymentUrl(openOnUi = true): void { - const deployment = last(this.config.currentConfig.deployments) as Record; - - if (deployment) { - const deploymentUrl = deployment.deploymentUrl.startsWith('https') - ? deployment.deploymentUrl - : `https://${deployment.deploymentUrl}`; - print([ - { message: 'Deployment URL', bold: true }, - { message: deploymentUrl, color: 'cyan' }, - ]); - - if (openOnUi) { - // NOTE delaying to open the deployment url. If we open quickly it's showing site not reachable - setTimeout(() => { - open(deploymentUrl); - }, 6000); - } - } - } - - /** - * @method showSuggestion - Show suggestion to add config file to .gitignore - * - * @return {*} - * @memberof GitHub - */ - showSuggestion() { - const gitIgnoreFilePath = `${this.config.projectBasePath}/.gitignore`; - - if (existsSync(gitIgnoreFilePath)) { - const gitIgnoreFile = readFileSync(`${this.config.projectBasePath}/.gitignore`, 'utf-8'); - - if (includes(gitIgnoreFile, this.config.configName)) return; - - this.log(`You can add the ${this.config.configName} config file to the .gitignore file`, { - color: 'yellow', - bold: true, - }); - } - } -} diff --git a/packages/contentstack-launch/src/adapters/file-upload.ts b/packages/contentstack-launch/src/adapters/file-upload.ts deleted file mode 100755 index ba687da0d5..0000000000 --- a/packages/contentstack-launch/src/adapters/file-upload.ts +++ /dev/null @@ -1,343 +0,0 @@ -import AdmZip from 'adm-zip'; -import map from 'lodash/map'; -import omit from 'lodash/omit'; -import find from 'lodash/find'; -import FormData from 'form-data'; -import filter from 'lodash/filter'; -import includes from 'lodash/includes'; -import isEmpty from 'lodash/isEmpty'; -import { basename, resolve } from 'path'; -import { cliux, configHandler, HttpClient, ux } from '@contentstack/cli-utilities'; -import { createReadStream, existsSync, PathLike, statSync, readFileSync } from 'fs'; - -import { print } from '../util'; -import BaseClass from './base-class'; -import { getFileList } from '../util/fs'; -import { createSignedUploadUrlMutation, importProjectMutation } from '../graphql'; - -export default class FileUpload extends BaseClass { - private signedUploadUrlData!: Record; - - /** - * @method run - * - * @return {*} {Promise} - * @memberof FileUpload - */ - async run(): Promise { - if (this.config.isExistingProject) { - await this.initApolloClient(); - if ( - !(await cliux.inquire({ - type: 'confirm', - default: false, - name: 'uploadLastFile', - message: 'Redeploy with last file upload?', - })) - ) { - await this.createSignedUploadUrl(); - const { zipName, zipPath } = await this.archive(); - await this.uploadFile(zipName, zipPath); - } - - const { uploadUid } = this.signedUploadUrlData || { - uploadUid: undefined, - }; - await this.createNewDeployment(true, uploadUid); - } else { - await this.prepareForNewProjectCreation(); - await this.createNewProject(); - } - - this.prepareLaunchConfig(); - await this.showLogs(); - this.showDeploymentUrl(); - this.showSuggestion(); - } - - /** - * @method createNewProject - Create new launch project - * - * @return {*} {Promise} - * @memberof FileUpload - */ - async createNewProject(): Promise { - const { framework, projectName, buildCommand, outputDirectory, environmentName } = this.config; - await this.apolloClient - .mutate({ - mutation: importProjectMutation, - variables: { - project: { - projectType: 'FILEUPLOAD', - name: projectName, - fileUpload: { uploadUid: this.signedUploadUrlData.uploadUid }, - environment: { - frameworkPreset: framework, - outputDirectory: outputDirectory, - name: environmentName || 'Default', - environmentVariables: map(this.envVariables, ({ key, value }) => ({ key, value })), - buildCommand: buildCommand === undefined || buildCommand === null ? 'npm run build' : buildCommand, - }, - }, - skipGitData: true, - }, - }) - .then(({ data: { project } }) => { - this.log('New project created successfully', 'info'); - const [firstEnvironment] = project.environments; - this.config.currentConfig = project; - this.config.currentConfig.deployments = map(firstEnvironment.deployments.edges, 'node'); - this.config.currentConfig.environments[0] = omit(this.config.currentConfig.environments[0], ['deployments']); - }) - .catch(async (error) => { - const canRetry = await this.handleNewProjectCreationError(error); - - if (canRetry) { - return this.createNewProject(); - } - }); - } - - /** - * @method prepareForNewProjectCreation - prepare necessary data for new project creation - * - * @return {*} {Promise} - * @memberof FileUpload - */ - async prepareForNewProjectCreation(): Promise { - const { - name, - framework, - environment, - 'build-command': buildCommand, - 'out-dir': outputDirectory, - 'variable-type': variableType, - 'env-variables': envVariables, - alias, - } = this.config.flags; - const { token, apiKey } = configHandler.get(`tokens.${alias}`) ?? {}; - this.config.selectedStack = apiKey; - this.config.deliveryToken = token; - // this.fileValidation(); - await this.selectOrg(); - await this.createSignedUploadUrl(); - const { zipName, zipPath, projectName } = await this.archive(); - await this.uploadFile(zipName, zipPath); - this.config.projectName = - name || - (await cliux.inquire({ - type: 'input', - name: 'projectName', - message: 'Project Name', - default: projectName, - validate: this.inquireRequireValidation, - })); - this.config.environmentName = - environment || - (await cliux.inquire({ - type: 'input', - default: 'Default', - name: 'environmentName', - message: 'Environment Name', - validate: this.inquireRequireValidation, - })); - if (framework) { - this.config.framework = (( - find(this.config.listOfFrameWorks, { - name: framework, - }) as Record - ).value || '') as string; - print([ - { message: '?', color: 'green' }, - { message: 'Framework Preset', bold: true }, - { message: this.config.framework, color: 'cyan' }, - ]); - } else { - await this.detectFramework(); - } - this.config.buildCommand = - buildCommand || - (await cliux.inquire({ - type: 'input', - name: 'buildCommand', - message: 'Build Command', - default: this.config.framework === 'OTHER' ? null : 'npm run build', - })); - this.config.outputDirectory = - outputDirectory || - (await cliux.inquire({ - type: 'input', - name: 'outputDirectory', - message: 'Output Directory', - default: (this.config.outputDirectories as Record)[this.config?.framework || 'OTHER'], - })); - this.config.variableType = variableType as unknown as string; - this.config.envVariables = envVariables; - await this.handleEnvImportFlow(); - } - - /** - * @method fileValidation - validate the working directory - * - * @memberof FileUpload - */ - fileValidation() { - const basePath = this.config.projectBasePath; - const packageJsonPath = resolve(basePath, 'package.json'); - - if (!existsSync(packageJsonPath)) { - this.log('Package.json file not found.', 'info'); - this.exit(1); - } - } - - /** - * @method archive - Archive the files and directory to be uploaded for launch project - * - * @return {*} - * @memberof FileUpload - */ - async archive() { - ux.action.start('Preparing zip file'); - const projectName = basename(this.config.projectBasePath); - const zipName = `${Date.now()}_${projectName}.zip`; - const zipPath = resolve(this.config.projectBasePath, zipName); - const zip = new AdmZip(); - const zipEntries = filter( - await getFileList(this.config.projectBasePath, true, true), - (entry) => !includes(this.config.fileUploadConfig.exclude, entry) && !includes(entry, '.zip'), - ); - - for (const entry of zipEntries) { - const entryPath = `${this.config.projectBasePath}/${entry}`; - const state = statSync(entryPath); - - switch (true) { - case state.isDirectory(): // NOTE folder - zip.addLocalFolder(entryPath, entry); - break; - case state.isFile(): // NOTE check is file - zip.addLocalFile(entryPath); - break; - } - } - - const status = await zip.writeZipPromise(zipPath).catch(() => { - this.log('Zipping project process failed! Please try again.'); - this.exit(1); - }); - - if (!status) { - this.log('Zipping project process failed! Please try again.'); - this.exit(1); - } - - ux.action.stop(); - return { zipName, zipPath, projectName }; - } - - /** - * @method createSignedUploadUrl - create pre signed url for file upload - * - * @return {*} {Promise} - * @memberof FileUpload - */ - async createSignedUploadUrl(): Promise { - this.signedUploadUrlData = await this.apolloClient - .mutate({ mutation: createSignedUploadUrlMutation }) - .then(({ data: { signedUploadUrl } }) => signedUploadUrl) - .catch((error) => { - this.log('Something went wrong. Please try again.', 'warn'); - this.log(error, 'error'); - this.exit(1); - }); - this.config.uploadUid = this.signedUploadUrlData.uploadUid; - } - - /** - * @method uploadFile - Upload file in to s3 bucket - * - * @param {string} fileName - * @param {PathLike} filePath - * @return {*} {Promise} - * @memberof FileUpload - */ - async uploadFile(fileName: string, filePath: PathLike): Promise { - const { uploadUrl, fields, headers, method } = this.signedUploadUrlData; - const formData = new FormData(); - - if (!isEmpty(fields)) { - for (const { formFieldKey, formFieldValue } of fields) { - formData.append(formFieldKey, formFieldValue); - } - - formData.append('file', createReadStream(filePath), fileName); - await this.submitFormData(formData, uploadUrl); - } else if (method === 'PUT') { - await this.uploadWithHttpClient(filePath, uploadUrl, headers); - } - } - - private async submitFormData(formData: FormData, uploadUrl: string): Promise { - ux.action.start('Starting file upload...'); - try { - await new Promise((resolve, reject) => { - formData.submit(uploadUrl, (error, res) => { - if (error) { - reject(error); - } else { - resolve(); - } - }); - }); - - ux.action.stop(); - } catch (error) { - ux.action.stop('File upload failed!'); - this.log('File upload failed. Please try again.', 'error'); - if (error instanceof Error) { - this.log(error.message, 'error'); - } - this.exit(1); - } - } - - private async uploadWithHttpClient( - filePath: PathLike, - uploadUrl: string, - headers: Array<{ key: string; value: string }>, - ): Promise { - ux.action.start('Starting file upload...'); - const httpClient = new HttpClient(); - const file = readFileSync(filePath); - - // Convert headers array to a headers object - const headerObject = headers?.reduce((acc, { key, value }) => { - acc[key] = value; - return acc; - }, {} as Record); - - try { - httpClient.headers({ 'Content-Type': 'application/zip' }); - if (headerObject !== undefined) httpClient.headers(headerObject); - const response = (await httpClient.put(uploadUrl, file)) as any; - const { status } = response; - - if (status >= 200 && status < 300) { - ux.action.stop(); - } else { - ux.action.stop('File upload failed!'); - this.log('File upload failed. Please try again.', 'error'); - this.log(`Error: ${status}, ${response?.statusText}`, 'error'); - this.exit(1); - } - } catch (error) { - ux.action.stop('File upload failed!'); - this.log('File upload failed. Please try again.', 'error'); - if (error instanceof Error) { - this.log(`Error: ${error.message}`, 'error'); - } - this.exit(1); - } - } -} diff --git a/packages/contentstack-launch/src/adapters/github.ts b/packages/contentstack-launch/src/adapters/github.ts deleted file mode 100755 index 74946ac94b..0000000000 --- a/packages/contentstack-launch/src/adapters/github.ts +++ /dev/null @@ -1,287 +0,0 @@ -import map from 'lodash/map'; -import { resolve } from 'path'; -import omit from 'lodash/omit'; -import find from 'lodash/find'; -import split from 'lodash/split'; -import { exec } from 'child_process'; -import replace from 'lodash/replace'; -import includes from 'lodash/includes'; -import { configHandler, cliux as ux } from '@contentstack/cli-utilities'; - -import { print } from '../util'; -import BaseClass from './base-class'; -import { getRemoteUrls } from '../util/create-git-meta'; -import { repositoriesQuery, userConnectionsQuery, importProjectMutation } from '../graphql'; - -export default class GitHub extends BaseClass { - /** - * @method run - initialization function - * - * @return {*} {Promise} - * @memberof GitHub - */ - async run(): Promise { - // NOTE New project creation Flow - if (this.config.isExistingProject) { - await this.initApolloClient(); - await this.createNewDeployment(); - } else { - // NOTE Existing project flow - // NOTE Step 1: Check is Github connected - if (await this.checkGitHubConnected()) { - // NOTE Step 2: check is the git remote available in the user's repo list - if (await this.checkGitRemoteAvailableAndValid()) { - if (await this.checkUserGitHubAccess()) { - // NOTE Step 3: check is the user has proper git access - await this.prepareForNewProjectCreation(); - } - } - } - - await this.createNewProject(); - } - - this.prepareLaunchConfig(); - await this.showLogs(); - this.showDeploymentUrl(); - this.showSuggestion(); - } - - /** - * @method createNewProject - Create new launch project - * - * @return {*} {Promise} - * @memberof GitHub - */ - async createNewProject(): Promise { - const { - branch, - framework, - repository, - projectName, - buildCommand, - selectedStack, - outputDirectory, - environmentName, - provider: gitProvider, - } = this.config; - const username = split(repository?.fullName, '/')[0]; - - await this.apolloClient - .mutate({ - mutation: importProjectMutation, - variables: { - project: { - name: projectName, - cmsStackApiKey: selectedStack?.api_key || '', - repository: { - username, - repositoryUrl: repository?.url, - repositoryName: repository?.fullName, - gitProviderMetadata: { gitProvider }, - }, - environment: { - gitBranch: branch, - frameworkPreset: framework, - outputDirectory: outputDirectory, - name: environmentName || 'Default', - environmentVariables: map(this.envVariables, ({ key, value }) => ({ key, value })), - buildCommand: buildCommand === undefined || buildCommand === null ? 'npm run build' : buildCommand, - }, - }, - }, - }) - .then(({ data: { project } }) => { - this.log('New project created successfully', 'info'); - const [firstEnvironment] = project.environments; - this.config.currentConfig = project; - this.config.currentConfig.deployments = map(firstEnvironment.deployments.edges, 'node'); - this.config.currentConfig.environments[0] = omit(this.config.currentConfig.environments[0], ['deployments']); - }) - .catch(async (error) => { - const canRetry = await this.handleNewProjectCreationError(error); - - if (canRetry) { - return this.createNewProject(); - } - }); - } - - /** - * @method prepareForNewProjectCreation - Preparing all the data for new project creation - * - * @return {*} {Promise} - * @memberof BaseClass - */ - async prepareForNewProjectCreation(): Promise { - const { - name, - framework, - environment, - 'build-command': buildCommand, - 'out-dir': outputDirectory, - 'variable-type': variableType, - 'env-variables': envVariables, - alias, - } = this.config.flags; - const { token, apiKey } = configHandler.get(`tokens.${alias}`) ?? {}; - this.config.selectedStack = apiKey; - this.config.deliveryToken = token; - await this.selectOrg(); - print([ - { message: '?', color: 'green' }, - { message: 'Repository', bold: true }, - { message: this.config.repository?.fullName, color: 'cyan' }, - ]); - await this.selectBranch(); - this.config.projectName = - name || - (await ux.inquire({ - type: 'input', - name: 'projectName', - message: 'Project Name', - default: this.config.repository?.name, - validate: this.inquireRequireValidation, - })); - this.config.environmentName = - environment || - (await ux.inquire({ - type: 'input', - default: 'Default', - name: 'environmentName', - message: 'Environment Name', - validate: this.inquireRequireValidation, - })); - if (framework) { - this.config.framework = ( - find(this.config.listOfFrameWorks, { - name: framework, - }) as Record - ).value as string; - print([ - { message: '?', color: 'green' }, - { message: 'Framework Preset', bold: true }, - { message: this.config.framework, color: 'cyan' }, - ]); - } else { - await this.detectFramework(); - } - this.config.buildCommand = - buildCommand || - (await ux.inquire({ - type: 'input', - name: 'buildCommand', - message: 'Build Command', - default: this.config.framework === 'OTHER' ? '' : 'npm run build', - })); - this.config.outputDirectory = - outputDirectory || - (await ux.inquire({ - type: 'input', - name: 'outputDirectory', - message: 'Output Directory', - default: (this.config.outputDirectories as Record)[this.config?.framework || 'OTHER'], - })); - this.config.variableType = variableType as unknown as string; - this.config.envVariables = envVariables; - await this.handleEnvImportFlow(); - } - - /** - * @method checkGitHubConnected - GitHub connection validation - * - * @return {*} {(Promise<{ - * userUid: string; - * provider: string; - * } | void>)} - * @memberof GitHub - */ - async checkGitHubConnected(): Promise<{ - userUid: string; - provider: string; - } | void> { - const userConnections = await this.apolloClient - .query({ query: userConnectionsQuery }) - .then(({ data: { userConnections } }) => userConnections) - .catch((error) => this.log(error, 'error')); - - const userConnection = find(userConnections, { - provider: this.config.provider, - }); - - if (userConnection) { - this.log('GitHub connection identified!', 'info'); - this.config.userConnection = userConnection; - } else { - this.log('GitHub connection not found!', 'warn'); - await this.connectToAdapterOnUi(); - } - - return this.config.userConnection; - } - - /** - * @method checkGitRemoteAvailableAndValid - GitHub repository verification - * - * @return {*} {(Promise)} - * @memberof GitHub - */ - async checkGitRemoteAvailableAndValid(): Promise { - const localRemoteUrl = (await getRemoteUrls(resolve(this.config.projectBasePath, '.git/config')))?.origin || ''; - - if (!localRemoteUrl) { - this.log('GitHub project not identified!', 'error'); - await this.connectToAdapterOnUi(); - } - - const repositories = await this.apolloClient - .query({ query: repositoriesQuery }) - .then(({ data: { repositories } }) => repositories) - .catch((error) => this.log(error, 'error')); - - this.config.repository = find(repositories, { - url: replace(localRemoteUrl, '.git', ''), - }); - - if (!this.config.repository) { - this.log('Repository not found in the list!', 'error'); - this.exit(1); - } - - return true; - } - - /** - * @method checkUserGitHubAccess - GitHub user access validation - * - * @return {*} {Promise} - * @memberof GitHub - */ - async checkUserGitHubAccess(): Promise { - return new Promise((resolve, reject) => { - const self = this; - const defaultBranch = this.config.repository?.defaultBranch; - if (!defaultBranch) return reject('Branch not found'); - exec( - `git push -u origin ${defaultBranch} --dry-run`, - { cwd: this.config.projectBasePath }, - function (err, stdout, stderr) { - if (err) { - self.log(err, 'error'); - } - - if ( - includes(stderr, 'Everything up-to-date') && - includes(stdout, `Would set upstream of '${defaultBranch}' to '${defaultBranch}' of 'origin'`) - ) { - self.log('User access verified', 'info'); - return resolve(true); - } - - self.log('You do not have write access for the selected repo', 'error'); - self.exit(0); - }, - ); - }); - } -} diff --git a/packages/contentstack-launch/src/adapters/index.ts b/packages/contentstack-launch/src/adapters/index.ts deleted file mode 100755 index 9cf2cb4d5b..0000000000 --- a/packages/contentstack-launch/src/adapters/index.ts +++ /dev/null @@ -1,6 +0,0 @@ -import GitHub from './github'; -import PreCheck from './pre-check'; -import FileUpload from './file-upload'; -import BaseClass from "./base-class"; - -export { GitHub, PreCheck, FileUpload, BaseClass }; \ No newline at end of file diff --git a/packages/contentstack-launch/src/adapters/pre-check.ts b/packages/contentstack-launch/src/adapters/pre-check.ts deleted file mode 100755 index bccb069ed2..0000000000 --- a/packages/contentstack-launch/src/adapters/pre-check.ts +++ /dev/null @@ -1,156 +0,0 @@ -import find from "lodash/find"; -import { resolve } from "path"; -import { existsSync } from "fs"; -import isEmpty from "lodash/isEmpty"; -import includes from "lodash/includes"; -import { cliux as ux } from "@contentstack/cli-utilities"; - -import BaseClass from "./base-class"; -import { getRemoteUrls } from "../util"; - -export default class PreCheck extends BaseClass { - public projectBasePath: string = process.cwd(); - /** - * @method run - * - * @param {boolean} [identifyProject=true] - * @return {*} {Promise} - * @memberof PreCheck - */ - async run(identifyProject = true): Promise { - await this.performValidations(); - - if (identifyProject && !this.config.isExistingProject) { - await this.identifyWhatProjectItIs(); - } - } - - /** - * @method performValidations - Validate if the current project is an existing launch project - * - * @return {*} {(Promise)} - * @memberof PreCheck - */ - async performValidations(): Promise { - if (this.config.config && existsSync(this.config.config)) { - if (this.config.flags.init) { - // NOTE reinitialize the project - this.config.provider = undefined; - this.config.isExistingProject = false; - - if (this.config.flags.type) { - this.config.provider = this.config.flags.type as any; - } - } else { - this.validateLaunchConfig(); - - this.log("Existing launch project identified", "info"); - - await this.displayPreDeploymentDetails(); - - if ( - !(await ux.inquire({ - type: "confirm", - name: "deployLatestSource", - message: "Redeploy latest commit/code?", - })) - ) { - this.exit(1); - } - } - } - } - - /** - * @method displayPreDeploymentDetails - * - * @memberof GitHub - */ - async displayPreDeploymentDetails() { - if (this.config.config && !isEmpty(this.config.currentConfig)) { - this.log(""); // Empty line - this.log("Current Project details:", { bold: true, color: "green" }); - this.log(""); // Empty line - const { name, projectType, repository, environments } = - this.config.currentConfig; - const [environment] = environments; - - const detail: Record = { - "Project Name": name, - "Project Type": - (this.config.providerMapper as Record)[projectType] || - "", - Environment: environment.name, - "Framework Preset": - find(this.config.listOfFrameWorks, { - value: environment.frameworkPreset, - })?.name || "", - }; - - if (repository?.repositoryName) { - detail["Repository"] = repository.repositoryName; - } - - ux.table([detail, {}], { - "Project Name": { - minWidth: 7, - }, - "Project Type": { - minWidth: 7, - }, - Environment: { - minWidth: 7, - }, - Repository: { - minWidth: 7, - }, - "Framework Preset": { - minWidth: 7, - }, - }); - } - } - - /** - * @method validateLaunchConfig - * - * @memberof PreCheck - */ - validateLaunchConfig() { - try { - // NOTE Perform validations here - if (isEmpty(require(this.config.config as string))) { - this.log("Invalid Launch config!", "warn"); - this.exit(1); - } - } catch (error) {} - } - - /** - * @method identifyWhatProjectItIs - identify if the project type (is GitHub, BitBucket, FileUpload etc.,) - * - * @return {*} {Promise} - * @memberof PreCheck - */ - async identifyWhatProjectItIs(): Promise { - const localRemoteUrl = - (await getRemoteUrls(resolve(this.config.projectBasePath, ".git/config"))) - ?.origin || ""; - - switch (true) { - case includes(localRemoteUrl, 'github.'): - this.config.provider = 'GitHub'; - this.log('Git project identified', 'info'); - break; - default: - if (existsSync(resolve(this.config.projectBasePath, ".git"))) { - this.log("Git config found but remote URL not found in the config!", { - color: "yellow", - bold: true, - }); - } - await this.connectToAdapterOnUi(false); - break; - } - } -} diff --git a/packages/contentstack-launch/src/base-command.ts b/packages/contentstack-launch/src/base-command.ts deleted file mode 100755 index 8e9415bee7..0000000000 --- a/packages/contentstack-launch/src/base-command.ts +++ /dev/null @@ -1,207 +0,0 @@ -import keys from 'lodash/keys'; -import { existsSync } from 'fs'; -import EventEmitter from 'events'; -import { dirname, resolve } from 'path'; -import includes from 'lodash/includes'; -import { ApolloClient } from '@apollo/client/core'; -import { Command } from '@contentstack/cli-command'; -import { - Flags, - FlagInput, - Interfaces, - cliux as ux, - configHandler, - isAuthenticated, - ContentstackClient, - managementSDKClient, - managementSDKInitiator, -} from '@contentstack/cli-utilities'; - -import config from './config'; -import { getLaunchHubUrl, GraphqlApiClient, Logger } from './util'; -import { ConfigType, LogFn, Providers } from './types'; - -export type Flags = Interfaces.InferredFlags<(typeof BaseCommand)['baseFlags'] & T['flags']>; -export type Args = Interfaces.InferredArgs; - -export abstract class BaseCommand extends Command { - public log!: LogFn; - public logger!: Logger; - protected $event!: EventEmitter; - protected sharedConfig!: ConfigType; - protected apolloClient!: ApolloClient; - protected managementSdk!: ContentstackClient; - protected apolloLogsClient!: ApolloClient; - - protected flags!: Flags; - protected args!: Args; - - // define flags that can be inherited by any command that extends BaseCommand - static baseFlags: FlagInput = { - 'data-dir': Flags.string({ - char: 'd', - description: 'Current working directory', - }), - config: Flags.string({ - char: 'c', - description: `Path to the local '${config.configName}' file`, - }), - }; - - public async init(): Promise { - this.checkAuthenticated(); - await super.init(); - const { args, flags } = await this.parse({ - flags: this.ctor.flags, - baseFlags: (super.ctor as typeof BaseCommand).baseFlags, - args: this.ctor.args, - strict: this.ctor.strict, - }); - this.flags = flags as Flags; - this.args = args as Args; - - ux.registerSearchPlugin(); - this.$event = new EventEmitter(); - - await this.prepareConfig(); - await this.initCmaSDK(); - - // Init logger - const logger = new Logger(this.sharedConfig); - this.log = logger.log.bind(logger); - } - - public checkAuthenticated() { - const self = this; - if ((self as this & { id: string }).id === 'launch:functions') { - return; - } - const _isAuthenticated = isAuthenticated(); - if (!_isAuthenticated) { - ux.print('CLI_AUTH_WHOAMI_FAILED', { color: 'yellow' }); - ux.print('You are not logged in. Please login to execute this command, csdx auth:login', { color: 'red' }); - this.exit(1); - } - } - - protected async catch(err: Error & { exitCode?: number }): Promise { - // add any custom logic to handle errors from the command - // or simply return the parent class error handling - return super.catch(err); - } - - protected async finally(_: Error | undefined): Promise { - // called after run and catch regardless of whether or not the command errored - return super.finally(_); - } - - /** - * @method prepareConfig - init default Config data - * - * @memberof BaseCommand - */ - async prepareConfig(): Promise { - let configPath = - this.flags['data-dir'] || this.flags.config - ? this.flags.config || resolve(this.flags['data-dir'], config.configName) - : resolve(process.cwd(), config.configName); - let baseUrl = config.launchBaseUrl || this.launchHubUrl; - if (!baseUrl) { - baseUrl = getLaunchHubUrl(); - } - this.sharedConfig = { - ...require('./config').default, - currentConfig: {}, - ...this.flags, - flags: this.flags, - host: this.cmaHost, - config: configPath, - projectBasePath: dirname(configPath), - authtoken: configHandler.get('authtoken'), - authType: configHandler.get('authorisationType'), - authorization: configHandler.get('oauthAccessToken'), - logsApiBaseUrl: `${baseUrl}/${config.logsApiEndpoint}`, - manageApiBaseUrl: `${baseUrl}/${config.manageApiEndpoint}`, - }; - - if (this.flags.type) { - this.sharedConfig.provider = this.flags.type; - } - - if (existsSync(configPath)) { - this.sharedConfig.isExistingProject = true; - } - } - - /** - * @method getConfig - Get a config from list of existing .cs-launch.json file - * - * @return {*} {Promise} - * @memberof BaseCommand - */ - async getConfig(): Promise { - if (this.sharedConfig.config && existsSync(this.sharedConfig.config)) { - const config: Record = require(this.sharedConfig.config); - const configKeys = keys(config); - - if (this.flags.branch && includes(configKeys, this.flags.branch)) { - this.sharedConfig.currentConfig = config[this.flags.branch]; - } else if (configKeys?.length > 1) { - this.sharedConfig.currentConfig = await ux - .inquire({ - name: 'branch', - type: 'search-list', - choices: configKeys, - message: 'Choose a branch', - }) - .then((val: any) => config[val]) - .catch((err) => { - this.log(err, 'error'); - }); - } else { - this.sharedConfig.currentConfig = config[configKeys[0]]; - } - - this.sharedConfig.provider = (this.sharedConfig.providerMapper as Record)[ - this.sharedConfig.currentConfig.projectType - ] as Providers; - } - } - - /** - * @methods prepareApiClients - Prepare Api Clients (Management SDK and apollo client) - * - * @return {*} {Promise} - * @memberof BaseCommand - */ - async prepareApiClients(): Promise { - this.apolloClient = await new GraphqlApiClient({ - headers: { - 'X-CS-CLI': this.context.analyticsInfo, - 'x-project-uid': this.sharedConfig.currentConfig.uid, - organization_uid: this.sharedConfig.currentConfig.organizationUid, - }, - baseUrl: this.sharedConfig.manageApiBaseUrl, - }).apolloClient; - this.apolloLogsClient = await new GraphqlApiClient({ - headers: { - 'X-CS-CLI': this.context.analyticsInfo, - 'x-project-uid': this.sharedConfig.currentConfig.uid, - organization_uid: this.sharedConfig.currentConfig.organizationUid, - }, - baseUrl: this.sharedConfig.logsApiBaseUrl, - }).apolloClient; - } - - /** - * @method initCmaSDK - * - * @memberof BaseCommand - */ - async initCmaSDK() { - managementSDKInitiator.init(this.context); - this.managementSdk = await managementSDKClient({ - host: this.sharedConfig.host, - }); - } -} diff --git a/packages/contentstack-launch/src/commands/launch/deployments.ts b/packages/contentstack-launch/src/commands/launch/deployments.ts deleted file mode 100755 index 07b85ecfb4..0000000000 --- a/packages/contentstack-launch/src/commands/launch/deployments.ts +++ /dev/null @@ -1,145 +0,0 @@ -import chalk from 'chalk'; -import map from 'lodash/map'; -import find from 'lodash/find'; -import isEmpty from 'lodash/isEmpty'; -import { FlagInput, Flags, cliux as ux } from '@contentstack/cli-utilities'; - -import { BaseCommand } from '../../base-command'; -import { environmentsQuery } from '../../graphql'; -import { Logger, selectOrg, selectProject } from '../../util'; - -export default class Deployments extends BaseCommand { - static description = 'Show list of deployments for an environment'; - - static examples = [ - '$ <%= config.bin %> <%= command.id %>', - '$ <%= config.bin %> <%= command.id %> -d "current working directory"', - '$ <%= config.bin %> <%= command.id %> -c "path to the local config file"', - '$ <%= config.bin %> <%= command.id %> -e "environment number or uid" --org= --project=', - ]; - - static flags: FlagInput = { - org: Flags.string({ - description: '[Optional] Provide the organization UID', - }), - project: Flags.string({ - description: '[Optional] Provide the project UID', - }), - environment: Flags.string({ - char: 'e', - description: 'Environment name or UID', - }), - branch: Flags.string({ - hidden: true, - description: '[Optional] GitHub branch name', - }), - }; - - async run(): Promise { - this.logger = new Logger(this.sharedConfig); - this.log = this.logger.log.bind(this.logger); - - if (!this.flags.environment) { - await this.getConfig(); - } - - await this.prepareApiClients(); - - if (!this.sharedConfig.currentConfig?.uid) { - await selectOrg({ - log: this.log, - flags: this.flags, - config: this.sharedConfig, - managementSdk: this.managementSdk, - }); - await this.prepareApiClients(); // NOTE update org-id in header - await selectProject({ - log: this.log, - flags: this.flags, - config: this.sharedConfig, - apolloClient: this.apolloClient, - }); - await this.prepareApiClients(); // NOTE update project-id in header - } - - await this.showDeployments(); - } - - /** - * @method showDeployments - * - * @memberof Deployments - */ - async showDeployments() { - const environments = await this.getEnvironments(); - - ux.table(environments, { - environment: { - minWidth: 7, - }, - deploymentUrl: { - minWidth: 7, - header: 'Deployment Url', - }, - commitMessage: { - minWidth: 7, - header: 'Commit Message', - }, - createdAt: { - minWidth: 7, - header: 'Created At', - }, - }); - } - - /** - * @method validateAndSelectEnvironment - check whether environment is validate or not. If not then option to select environment - * - * @return {*} {Promise} - * @memberof Logs - */ - async getEnvironments(): Promise { - const environments = await this.apolloClient - .query({ query: environmentsQuery }) - .then(({ data: { Environments } }) => map(Environments.edges, 'node')) - .catch((error) => { - this.log(error?.message, 'error'); - process.exit(1); - }); - let environment = find( - environments, - ({ uid, name }) => - uid === this.flags.environment || - name === this.flags.environment || - uid === this.sharedConfig.currentConfig?.environments?.[0]?.uid, - ); - - if (isEmpty(environment) && (this.flags.environment || this.sharedConfig.currentConfig?.environments?.[0]?.uid)) { - this.log('Environment(s) not found!', 'error'); - process.exit(1); - } else if (isEmpty(environment)) { - environment = await ux - .inquire({ - type: 'search-list', - name: 'Environment', - choices: map(environments, (row) => ({ ...row, value: row.name })), - message: 'Choose an environment', - }) - .then((name: any) => find(environments, { name }) as Record); - this.sharedConfig.currentConfig.deployments = map(environments[0]?.deployments?.edges, 'node'); - } - - this.sharedConfig.environment = environment; - - return map(environment.deployments.edges, ({ node }) => { - const { deploymentUrl: url, createdAt, commitMessage } = node; - const deploymentUrl = chalk.cyan(url?.startsWith('https') ? url : `https://${url}`); - return { - deploymentUrl, - createdAt: chalk.green(createdAt), - commitMessage: chalk.green(commitMessage), - environment: chalk.green(environment.name), - }; - }); - } -} diff --git a/packages/contentstack-launch/src/commands/launch/environments.ts b/packages/contentstack-launch/src/commands/launch/environments.ts deleted file mode 100755 index bbab7c9fdc..0000000000 --- a/packages/contentstack-launch/src/commands/launch/environments.ts +++ /dev/null @@ -1,157 +0,0 @@ -import chalk from 'chalk'; -import map from 'lodash/map'; -import find from 'lodash/find'; -import isEmpty from 'lodash/isEmpty'; -import { FlagInput, Flags, cliux as ux } from '@contentstack/cli-utilities'; - -import { BaseCommand } from '../../base-command'; -import { Logger, selectOrg, selectProject } from '../../util'; -import { environmentsQuery, projectsQuery } from '../../graphql'; - -export default class Environments extends BaseCommand { - static description = 'Show list of environments for a project'; - - static examples = [ - '$ <%= config.bin %> <%= command.id %>', - '$ <%= config.bin %> <%= command.id %> -d "current working directory"', - '$ <%= config.bin %> <%= command.id %> -c "path to the local config file"', - '$ <%= config.bin %> <%= command.id %> --org= --project=', - ]; - - static flags: FlagInput = { - org: Flags.string({ - description: '[Optional] Provide the organization UID', - }), - project: Flags.string({ - description: '[Optional] Provide the project UID', - }), - branch: Flags.string({ - hidden: true, - description: '[Optional] GitHub branch name', - }), - }; - - async run(): Promise { - this.logger = new Logger(this.sharedConfig); - this.log = this.logger.log.bind(this.logger); - - await this.getConfig(); - await this.prepareApiClients(); - - if (!this.sharedConfig.currentConfig?.uid) { - await selectOrg({ - log: this.log, - flags: this.flags, - config: this.sharedConfig, - managementSdk: this.managementSdk, - }); - await this.prepareApiClients(); // NOTE update org-id in header - await selectProject({ - log: this.log, - flags: this.flags, - config: this.sharedConfig, - apolloClient: this.apolloClient, - }); - await this.prepareApiClients(); // NOTE update project-id in header - } - - await this.getEnvironments(); - } - - /** - * @method selectProject - select projects - * - * @return {*} {Promise} - * @memberof Logs - */ - async selectProject(): Promise { - const projects = await this.apolloClient - .query({ query: projectsQuery, variables: { query: {} } }) - .then(({ data: { projects } }) => projects) - .catch((error) => { - this.log('Unable to fetch projects.!', { color: 'yellow' }); - this.log(error, 'error'); - process.exit(1); - }); - - const listOfProjects = map(projects.edges, ({ node: { uid, name } }) => ({ - name, - value: name, - uid, - })); - - if (isEmpty(listOfProjects)) { - this.log('Project not found', 'info'); - this.exit(1); - } - - if (this.flags.project || this.sharedConfig.currentConfig.uid) { - this.sharedConfig.currentConfig.uid = - find(listOfProjects, { - uid: this.flags.project, - })?.uid || - find(listOfProjects, { - name: this.flags.project, - })?.uid || - find(listOfProjects, { - uid: this.sharedConfig.currentConfig.uid, - })?.uid; - } - - if (!this.sharedConfig.currentConfig.uid) { - this.sharedConfig.currentConfig.uid = await ux - .inquire({ - type: 'search-list', - name: 'Project', - choices: listOfProjects, - message: 'Choose a project', - }) - .then((name) => (find(listOfProjects, { name }) as Record)?.uid); - } - await this.prepareApiClients(); - } - - /** - * @method validateAndSelectEnvironment - check whether environment is validate or not. If not then option to select environment - * - * @return {*} {Promise} - * @memberof Logs - */ - async getEnvironments(): Promise { - const environments = await this.apolloClient - .query({ query: environmentsQuery }) - .then(({ data: { Environments } }) => map(Environments.edges, 'node')) - .catch((error) => { - this.log(error?.message, 'error'); - process.exit(1); - }); - - ux.table( - map(environments, ({ uid, name, frameworkPreset }) => { - return { - uid: chalk.green(uid), - name: chalk.green(name), - frameworkPreset: chalk.green( - find(this.sharedConfig.listOfFrameWorks, { - value: frameworkPreset, - })?.name || '', - ), - }; - }), - { - uid: { - minWidth: 7, - header: 'UID', - }, - name: { - minWidth: 7, - header: 'Name', - }, - frameworkPreset: { - minWidth: 7, - header: 'Framework', - }, - }, - ); - } -} diff --git a/packages/contentstack-launch/src/commands/launch/functions.ts b/packages/contentstack-launch/src/commands/launch/functions.ts deleted file mode 100755 index c5e3b78605..0000000000 --- a/packages/contentstack-launch/src/commands/launch/functions.ts +++ /dev/null @@ -1,33 +0,0 @@ -import { FlagInput, Flags } from '@contentstack/cli-utilities'; - -import { BaseCommand } from '../../base-command'; -import Contentfly from '../../util/cloud-function'; - -export default class Functions extends BaseCommand { - static description = 'Serve cloud functions'; - - static examples = [ - '$ csdx launch:functions', - '$ csdx launch:functions --port=port', - '$ csdx launch:functions --data-dir ', - '$ csdx launch:functions --config ', - '$ csdx launch:functions --data-dir -p "port number"', - '$ csdx launch:functions --config --port=port', - ]; - - static flags: FlagInput = { - port: Flags.string({ - char: 'p', - default: '3000', - description: 'Port number', - }), - }; - - async run(): Promise { - this.sharedConfig.config = - this.flags['data-dir'] || this.flags.config - ? this.flags.config?.split(`${this.sharedConfig.configName}`)[0] || this.flags['data-dir'] - : process.cwd(); - await new Contentfly(this.sharedConfig.config as string).serveCloudFunctions(+this.flags.port); - } -} diff --git a/packages/contentstack-launch/src/commands/launch/index.ts b/packages/contentstack-launch/src/commands/launch/index.ts deleted file mode 100755 index 8041461e12..0000000000 --- a/packages/contentstack-launch/src/commands/launch/index.ts +++ /dev/null @@ -1,140 +0,0 @@ -import map from 'lodash/map'; -import { FlagInput, Flags } from '@contentstack/cli-utilities'; - -import config from '../../config'; -import { BaseCommand } from '../../base-command'; -import { AdapterConstructorInputs } from '../../types'; -import { FileUpload, GitHub, PreCheck } from '../../adapters'; - -export default class Launch extends BaseCommand { - public preCheck!: PreCheck; - - static description = 'Launch related operations'; - - static examples = [ - '<%= config.bin %> <%= command.id %>', - '<%= config.bin %> <%= command.id %> --data-dir ', - '<%= config.bin %> <%= command.id %> --config ', - '<%= config.bin %> <%= command.id %> --type ', - '<%= config.bin %> <%= command.id %> --data-dir --type ', - '<%= config.bin %> <%= command.id %> --config --type ', - '<%= config.bin %> <%= command.id %> --config --type --name= --environment= --branch= --build-command= --framework=