From a5a6cde8d6326d7df08fd594636c4fbe62e9ad34 Mon Sep 17 00:00:00 2001 From: shafeeqd959 Date: Wed, 24 Jan 2024 15:32:05 +0530 Subject: [PATCH 01/13] added external config --- package-lock.json | 62 ++-- packages/contentstack-audit/README.md | 16 +- packages/contentstack-clone/README.md | 4 +- packages/contentstack-clone/package.json | 5 +- .../src/commands/cm/stacks/clone.js | 14 +- .../src/lib/util/clone-handler.js | 6 +- packages/contentstack/README.md | 16 +- pnpm-lock.yaml | 314 +++++++++++++++++- 8 files changed, 382 insertions(+), 55 deletions(-) diff --git a/package-lock.json b/package-lock.json index c589e071da..b1cfb05b35 100644 --- a/package-lock.json +++ b/package-lock.json @@ -24244,7 +24244,7 @@ }, "packages/contentstack-clone": { "name": "@contentstack/cli-cm-clone", - "version": "1.9.0", + "version": "1.10.0", "license": "MIT", "dependencies": { "@colors/colors": "^1.5.0", @@ -24257,6 +24257,7 @@ "child_process": "^1.0.2", "fancy-test": "^1.4.10", "inquirer": "8.2.4", + "merge": "^2.1.1", "ora": "^5.1.0", "prompt": "^1.3.0", "rimraf": "^3.0.2", @@ -26064,38 +26065,52 @@ "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==", "dev": true }, - "packages/contentstack/node_modules/@contentstack/cli-cm-clone/node_modules/@contentstack/cli-cm-import": { - "version": "1.10.0", - "resolved": "https://registry.npmjs.org/@contentstack/cli-cm-import/-/cli-cm-import-1.10.0.tgz", - "integrity": "sha512-Jn9grDE2J1c4iGBcPv24Q8lj/ozgfD9QNbJcn+1a6oGjA6OE+a39agQwi04nByBw4xRtbLUmHa4nfFRaF7qkvQ==", - "extraneous": true, + "packages/contentstack/node_modules/@contentstack/cli-cm-clone": { + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/@contentstack/cli-cm-clone/-/cli-cm-clone-1.9.0.tgz", + "integrity": "sha512-WJ52SsvFUSTTWRCKgkIiCEse98+GrrOoq1nzwfBb8eXb6p7vckZGnO9YJr2GUYaNrWaFSz2aYEDsoyaRsK6NEQ==", "dependencies": { - "@contentstack/cli-command": "~1.2.14", - "@contentstack/cli-utilities": "~1.5.4", - "@contentstack/management": "~1.10.2", - "@oclif/core": "^2.9.3", - "big-json": "^3.2.0", - "bluebird": "^3.7.2", - "chalk": "^4.1.2", - "debug": "^4.1.0", - "fs-extra": "^11.1.1", - "lodash": "^4.17.20", - "marked": "^4.0.17", - "merge": "^2.1.1", - "mkdirp": "^1.0.4", - "promise-limit": "^2.7.0", - "tslib": "^2.4.1", + "@colors/colors": "^1.5.0", + "@contentstack/cli-cm-export": "~1.10.2", + "@contentstack/cli-cm-import": "~1.13.0", + "@contentstack/cli-command": "~1.2.16", + "@contentstack/cli-utilities": "~1.5.10", + "async": "^3.2.4", + "chalk": "^4.1.0", + "child_process": "^1.0.2", + "fancy-test": "^1.4.10", + "inquirer": "8.2.4", + "ora": "^5.1.0", + "prompt": "^1.3.0", + "rimraf": "^3.0.2", "winston": "^3.7.2" }, "engines": { "node": ">=14.0.0" } }, + "packages/contentstack/node_modules/@contentstack/cli-cm-clone/node_modules/fancy-test": { + "version": "1.4.10", + "resolved": "https://registry.npmjs.org/fancy-test/-/fancy-test-1.4.10.tgz", + "integrity": "sha512-AaUX6wKS7D5OP2YK2q5G7c8PGx2lgoyLUD7Bbg8z323sb9aebBqzb9UN6phzI73UgO/ViihmNfOxF3kdfZLhew==", + "dependencies": { + "@types/chai": "*", + "@types/lodash": "*", + "@types/node": "*", + "@types/sinon": "*", + "lodash": "^4.17.13", + "mock-stdin": "^1.0.0", + "nock": "^13.0.0", + "stdout-stderr": "^0.1.9" + }, + "engines": { + "node": ">=8.0.0" + } + }, "packages/contentstack/node_modules/@contentstack/cli-cm-clone/node_modules/rimraf": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", "integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==", - "extraneous": true, "dependencies": { "glob": "^7.1.3" }, @@ -26149,8 +26164,7 @@ "packages/contentstack/node_modules/@types/node": { "version": "14.18.63", "resolved": "https://registry.npmjs.org/@types/node/-/node-14.18.63.tgz", - "integrity": "sha512-fAtCfv4jJg+ExtXhvCkCqUKZ+4ok/JQk01qDKhL5BDDoS3AxKXhV5/MAVUZyQnSEd2GT92fkgZl0pz0Q0AzcIQ==", - "dev": true + "integrity": "sha512-fAtCfv4jJg+ExtXhvCkCqUKZ+4ok/JQk01qDKhL5BDDoS3AxKXhV5/MAVUZyQnSEd2GT92fkgZl0pz0Q0AzcIQ==" }, "packages/contentstack/node_modules/fancy-test": { "version": "2.0.42", diff --git a/packages/contentstack-audit/README.md b/packages/contentstack-audit/README.md index 9c5bdf04ac..7c34da8ce2 100644 --- a/packages/contentstack-audit/README.md +++ b/packages/contentstack-audit/README.md @@ -19,7 +19,7 @@ $ npm install -g @contentstack/cli-audit $ csdx COMMAND running command... $ csdx (--version|-v) -@contentstack/cli-audit/1.3.2 darwin-arm64 node-v20.8.0 +@contentstack/cli-audit/1.3.3 darwin-arm64 node-v20.8.0 $ csdx --help [COMMAND] USAGE $ csdx COMMAND @@ -285,7 +285,7 @@ EXAMPLES $ csdx plugins ``` -_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v4.1.10/src/commands/plugins/index.ts)_ +_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v4.1.17/src/commands/plugins/index.ts)_ ## `csdx plugins:install PLUGIN...` @@ -354,7 +354,7 @@ EXAMPLES $ csdx plugins:inspect myplugin ``` -_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v4.1.10/src/commands/plugins/inspect.ts)_ +_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v4.1.17/src/commands/plugins/inspect.ts)_ ## `csdx plugins:install PLUGIN...` @@ -398,7 +398,7 @@ EXAMPLES $ csdx plugins:install someuser/someplugin ``` -_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v4.1.10/src/commands/plugins/install.ts)_ +_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v4.1.17/src/commands/plugins/install.ts)_ ## `csdx plugins:link PLUGIN` @@ -428,7 +428,7 @@ EXAMPLES $ csdx plugins:link myplugin ``` -_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v4.1.10/src/commands/plugins/link.ts)_ +_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v4.1.17/src/commands/plugins/link.ts)_ ## `csdx plugins:uninstall PLUGIN...` @@ -465,7 +465,7 @@ USAGE $ csdx plugins:reset ``` -_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v4.1.10/src/commands/plugins/reset.ts)_ +_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v4.1.17/src/commands/plugins/reset.ts)_ ## `csdx plugins:uninstall PLUGIN...` @@ -493,7 +493,7 @@ EXAMPLES $ csdx plugins:uninstall myplugin ``` -_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v4.1.10/src/commands/plugins/uninstall.ts)_ +_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v4.1.17/src/commands/plugins/uninstall.ts)_ ## `csdx plugins:uninstall PLUGIN...` @@ -537,5 +537,5 @@ DESCRIPTION Update installed plugins. ``` -_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v4.1.10/src/commands/plugins/update.ts)_ +_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v4.1.17/src/commands/plugins/update.ts)_ diff --git a/packages/contentstack-clone/README.md b/packages/contentstack-clone/README.md index df030887f0..85de4211c1 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.9.0 darwin-arm64 node-v20.8.0 +@contentstack/cli-cm-clone/1.10.0 darwin-arm64 node-v20.8.0 $ csdx --help [COMMAND] USAGE $ csdx COMMAND @@ -51,6 +51,7 @@ USAGE [--destination-stack-api-key ] [--import-webhook-status disable|current] FLAGS + -c, --config= Path for the external configuration -n, --stack-name= Name for the new stack to store the cloned content. -y, --yes [Optional] Override marketplace prompts --destination-management-token-alias= Source API key of the target stack token alias. @@ -101,6 +102,7 @@ USAGE [--destination-stack-api-key ] [--import-webhook-status disable|current] FLAGS + -c, --config= Path for the external configuration -n, --stack-name= Name for the new stack to store the cloned content. -y, --yes [Optional] Override marketplace prompts --destination-management-token-alias= Source API key of the target stack token alias. diff --git a/packages/contentstack-clone/package.json b/packages/contentstack-clone/package.json index 46e1791133..cd474cd18e 100644 --- a/packages/contentstack-clone/package.json +++ b/packages/contentstack-clone/package.json @@ -1,7 +1,7 @@ { "name": "@contentstack/cli-cm-clone", "description": "Contentstack stack clone plugin", - "version": "1.9.0", + "version": "1.10.0", "author": "Contentstack", "bugs": "https://github.com/rohitmishra209/cli-cm-clone/issues", "dependencies": { @@ -18,7 +18,8 @@ "ora": "^5.1.0", "prompt": "^1.3.0", "rimraf": "^3.0.2", - "winston": "^3.7.2" + "winston": "^3.7.2", + "merge": "^2.1.1" }, "devDependencies": { "@oclif/test": "^1.2.7", diff --git a/packages/contentstack-clone/src/commands/cm/stacks/clone.js b/packages/contentstack-clone/src/commands/cm/stacks/clone.js index 6f0e1d8766..9f2e0bb919 100644 --- a/packages/contentstack-clone/src/commands/cm/stacks/clone.js +++ b/packages/contentstack-clone/src/commands/cm/stacks/clone.js @@ -3,8 +3,9 @@ const { configHandler, flags, isAuthenticated, managementSDKClient } = require(' const { CloneHandler } = require('../../../lib/util/clone-handler'); const path = require('path'); const rimraf = require('rimraf'); +const merge = require("merge") let pathdir = path.join(__dirname.split('src')[0], 'contents'); -const { readdirSync } = require('fs'); +const { readdirSync, readFileSync } = require('fs'); let config = {}; class StackCloneCommand extends Command { @@ -23,11 +24,17 @@ class StackCloneCommand extends Command { 'source-management-token-alias': sourceManagementTokenAlias, 'destination-management-token-alias': destinationManagementTokenAlias, 'import-webhook-status': importWebhookStatus, + 'config': externalConfigPath } = cloneCommandFlags; const handleClone = async () => { const listOfTokens = configHandler.get('tokens'); + if (externalConfigPath) { + let externalConfig = readFileSync(externalConfigPath, 'utf-8') + externalConfig = JSON.parse(externalConfig); + config = merge.recursive(config, externalConfig); + } config.forceStopMarketplaceAppsPrompt = yes; config.skipAudit = cloneCommandFlags['skip-audit']; @@ -249,6 +256,11 @@ b) Structure with content (all modules including entries & assets) 'skip-audit': flags.boolean({ description: 'Skips the audit fix.', }), + 'config': flags.string({ + char: 'c', + required: false, + description: 'Path for the external configuration', + }), }; StackCloneCommand.usage = diff --git a/packages/contentstack-clone/src/lib/util/clone-handler.js b/packages/contentstack-clone/src/lib/util/clone-handler.js index e471e29b26..e300925c31 100644 --- a/packages/contentstack-clone/src/lib/util/clone-handler.js +++ b/packages/contentstack-clone/src/lib/util/clone-handler.js @@ -619,8 +619,6 @@ class CloneHandler { const cmd = ['-k', config.source_stack, '-d', __dirname.split('src')[0] + 'contents']; if (config.cloneType === 'a') { config.filteredModules = ['stack'].concat(structureList); - cmd.push('-c'); - cmd.push(path.join(__dirname, 'dummyConfig.json')); } if (config.source_alias) { @@ -632,6 +630,9 @@ class CloneHandler { if (config.forceStopMarketplaceAppsPrompt) cmd.push('-y'); + cmd.push('-c'); + cmd.push(path.join(__dirname, 'dummyConfig.json')); + fs.writeFileSync(path.join(__dirname, 'dummyConfig.json'), JSON.stringify(config)); let exportData = exportCmd.run(cmd); exportData.then(() => resolve(true)).catch(reject); @@ -661,6 +662,7 @@ class CloneHandler { fs.writeFileSync(path.join(__dirname, 'dummyConfig.json'), JSON.stringify(config)); await importCmd.run(cmd); + fs.writeFileSync(path.join(__dirname, 'dummyConfig.json'), JSON.stringify({})) return resolve(); }); } diff --git a/packages/contentstack/README.md b/packages/contentstack/README.md index d89bc05d95..2a1de860aa 100644 --- a/packages/contentstack/README.md +++ b/packages/contentstack/README.md @@ -18,7 +18,7 @@ $ npm install -g @contentstack/cli $ csdx COMMAND running command... $ csdx (--version|-v) -@contentstack/cli/1.12.1 darwin-arm64 node-v20.8.0 +@contentstack/cli/1.12.2 darwin-arm64 node-v20.8.0 $ csdx --help [COMMAND] USAGE $ csdx COMMAND @@ -3515,7 +3515,7 @@ EXAMPLES $ csdx plugins ``` -_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v4.1.10/src/commands/plugins/index.ts)_ +_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v4.1.17/src/commands/plugins/index.ts)_ ## `csdx plugins:install PLUGIN...` @@ -3584,7 +3584,7 @@ EXAMPLES $ csdx plugins:inspect myplugin ``` -_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v4.1.10/src/commands/plugins/inspect.ts)_ +_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v4.1.17/src/commands/plugins/inspect.ts)_ ## `csdx plugins:install PLUGIN...` @@ -3628,7 +3628,7 @@ EXAMPLES $ csdx plugins:install someuser/someplugin ``` -_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v4.1.10/src/commands/plugins/install.ts)_ +_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v4.1.17/src/commands/plugins/install.ts)_ ## `csdx plugins:link PLUGIN` @@ -3658,7 +3658,7 @@ EXAMPLES $ csdx plugins:link myplugin ``` -_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v4.1.10/src/commands/plugins/link.ts)_ +_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v4.1.17/src/commands/plugins/link.ts)_ ## `csdx plugins:uninstall PLUGIN...` @@ -3695,7 +3695,7 @@ USAGE $ csdx plugins:reset ``` -_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v4.1.10/src/commands/plugins/reset.ts)_ +_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v4.1.17/src/commands/plugins/reset.ts)_ ## `csdx plugins:uninstall PLUGIN...` @@ -3723,7 +3723,7 @@ EXAMPLES $ csdx plugins:uninstall myplugin ``` -_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v4.1.10/src/commands/plugins/uninstall.ts)_ +_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v4.1.17/src/commands/plugins/uninstall.ts)_ ## `csdx plugins:uninstall PLUGIN...` @@ -3767,7 +3767,7 @@ DESCRIPTION Update installed plugins. ``` -_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v4.1.10/src/commands/plugins/update.ts)_ +_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v4.1.17/src/commands/plugins/update.ts)_ ## `csdx tokens` diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 8635038122..08bcbcb8fc 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -67,12 +67,12 @@ importers: '@contentstack/cli-audit': link:../contentstack-audit '@contentstack/cli-auth': link:../contentstack-auth '@contentstack/cli-cm-bootstrap': link:../contentstack-bootstrap - '@contentstack/cli-cm-branches': link:../contentstack-branches + '@contentstack/cli-cm-branches': 1.0.21_ogreqof3k35xezedraj6pnd45y '@contentstack/cli-cm-bulk-publish': link:../contentstack-bulk-publish - '@contentstack/cli-cm-clone': link:../contentstack-clone + '@contentstack/cli-cm-clone': 1.9.0_ogreqof3k35xezedraj6pnd45y '@contentstack/cli-cm-export': link:../contentstack-export '@contentstack/cli-cm-export-to-csv': link:../contentstack-export-to-csv - '@contentstack/cli-cm-import': link:../contentstack-import + '@contentstack/cli-cm-import': 1.13.1_ogreqof3k35xezedraj6pnd45y '@contentstack/cli-cm-migrate-rte': link:../contentstack-migrate-rte '@contentstack/cli-cm-seed': link:../contentstack-seed '@contentstack/cli-command': link:../contentstack-command @@ -438,6 +438,7 @@ importers: globby: ^10.0.2 inquirer: 8.2.4 jest: ^29.4.2 + merge: ^2.1.1 mocha: ^10.0.0 nyc: ^15.1.0 oclif: ^3.8.1 @@ -449,7 +450,7 @@ importers: dependencies: '@colors/colors': 1.6.0 '@contentstack/cli-cm-export': link:../contentstack-export - '@contentstack/cli-cm-import': link:../contentstack-import + '@contentstack/cli-cm-import': 1.13.1 '@contentstack/cli-command': link:../contentstack-command '@contentstack/cli-utilities': link:../contentstack-utilities async: 3.2.5 @@ -457,6 +458,7 @@ importers: child_process: 1.0.2 fancy-test: 1.4.10 inquirer: 8.2.4 + merge: 2.1.1 ora: 5.4.1 prompt: 1.3.0 rimraf: 3.0.2 @@ -1012,7 +1014,7 @@ importers: tslib: ^2.4.1 typescript: ^4.9.3 dependencies: - '@contentstack/cli-cm-import': link:../contentstack-import + '@contentstack/cli-cm-import': 1.13.1_ogreqof3k35xezedraj6pnd45y '@contentstack/cli-command': link:../contentstack-command '@contentstack/cli-utilities': link:../contentstack-utilities inquirer: 8.2.4 @@ -1567,6 +1569,234 @@ packages: resolution: {integrity: sha512-Ir+AOibqzrIsL6ajt3Rz3LskB7OiMVHqltZmspbW/TJuTVuyOMirVqAkjfY6JISiLHgyNqicAC8AyHHGzNd/dA==} engines: {node: '>=0.1.90'} + /@contentstack/cli-audit/1.3.3: + resolution: {integrity: sha512-DcCylHasQedl9GQ9lkQcb6yws2Pml0X/s3p+FiNwCjiNYkQHV3GnWxY76ZctUW+hmmRUzALJJaxRZiONQb1pJw==} + engines: {node: '>=16'} + hasBin: true + dependencies: + '@contentstack/cli-command': 1.2.17 + '@contentstack/cli-utilities': 1.5.10 + '@oclif/plugin-help': 5.2.20 + '@oclif/plugin-plugins': 4.1.10 + chalk: 4.1.2 + fast-csv: 4.3.6 + fs-extra: 11.2.0 + lodash: 4.17.21 + uuid: 9.0.1 + winston: 3.11.0 + transitivePeerDependencies: + - '@swc/core' + - '@swc/wasm' + - '@types/node' + - encoding + - supports-color + - typescript + dev: false + + /@contentstack/cli-audit/1.3.3_ogreqof3k35xezedraj6pnd45y: + resolution: {integrity: sha512-DcCylHasQedl9GQ9lkQcb6yws2Pml0X/s3p+FiNwCjiNYkQHV3GnWxY76ZctUW+hmmRUzALJJaxRZiONQb1pJw==} + engines: {node: '>=16'} + hasBin: true + dependencies: + '@contentstack/cli-command': 1.2.17_ogreqof3k35xezedraj6pnd45y + '@contentstack/cli-utilities': 1.5.10_ogreqof3k35xezedraj6pnd45y + '@oclif/plugin-help': 5.2.20_ogreqof3k35xezedraj6pnd45y + '@oclif/plugin-plugins': 4.1.10 + chalk: 4.1.2 + fast-csv: 4.3.6 + fs-extra: 11.2.0 + lodash: 4.17.21 + uuid: 9.0.1 + winston: 3.11.0 + transitivePeerDependencies: + - '@swc/core' + - '@swc/wasm' + - '@types/node' + - encoding + - supports-color + - typescript + dev: false + + /@contentstack/cli-cm-branches/1.0.21_ogreqof3k35xezedraj6pnd45y: + resolution: {integrity: sha512-r9YDanK65uAjXd1+6zR8ivL1w+1lzjVnVK0GQZ7fXxqvNCG3ZItf9lJwwtNmReaDVqs3LmFYIlYyplerJRIz5g==} + engines: {node: '>=14.0.0'} + dependencies: + '@contentstack/cli-command': 1.2.17_ogreqof3k35xezedraj6pnd45y + '@contentstack/cli-utilities': 1.5.10_ogreqof3k35xezedraj6pnd45y + '@oclif/core': 2.15.0_ogreqof3k35xezedraj6pnd45y + async: 3.2.5 + big-json: 3.2.0 + bluebird: 3.7.2 + chalk: 4.1.2 + is-valid-path: 0.1.1 + just-diff: 6.0.2 + lodash: 4.17.21 + merge: 2.1.1 + mkdirp: 1.0.4 + path: 0.12.7 + progress-stream: 2.0.0 + promise-limit: 2.7.0 + proxyquire: 2.1.3 + tslib: 2.6.2 + winston: 3.11.0 + transitivePeerDependencies: + - '@swc/core' + - '@swc/wasm' + - '@types/node' + - encoding + - supports-color + - typescript + dev: false + + /@contentstack/cli-cm-clone/1.9.0_ogreqof3k35xezedraj6pnd45y: + resolution: {integrity: sha512-WJ52SsvFUSTTWRCKgkIiCEse98+GrrOoq1nzwfBb8eXb6p7vckZGnO9YJr2GUYaNrWaFSz2aYEDsoyaRsK6NEQ==} + engines: {node: '>=14.0.0'} + dependencies: + '@colors/colors': 1.6.0 + '@contentstack/cli-cm-export': 1.10.3_ogreqof3k35xezedraj6pnd45y + '@contentstack/cli-cm-import': 1.13.1_ogreqof3k35xezedraj6pnd45y + '@contentstack/cli-command': 1.2.17_ogreqof3k35xezedraj6pnd45y + '@contentstack/cli-utilities': 1.5.10_ogreqof3k35xezedraj6pnd45y + async: 3.2.5 + chalk: 4.1.2 + child_process: 1.0.2 + fancy-test: 1.4.10 + inquirer: 8.2.4 + ora: 5.4.1 + prompt: 1.3.0 + rimraf: 3.0.2 + winston: 3.11.0 + transitivePeerDependencies: + - '@swc/core' + - '@swc/wasm' + - '@types/node' + - encoding + - supports-color + - typescript + dev: false + + /@contentstack/cli-cm-export/1.10.3_ogreqof3k35xezedraj6pnd45y: + resolution: {integrity: sha512-e3Ho7iW7UIW7fKx6ZBXhD1TsIxbaHfFugBb6vMY5C9Vf4j+ZXpCt8YufnbGAe2sJsFxTAlBcqs2E6MXMKAaqUg==} + engines: {node: '>=14.0.0'} + dependencies: + '@contentstack/cli-command': 1.2.17_ogreqof3k35xezedraj6pnd45y + '@contentstack/cli-utilities': 1.5.10_ogreqof3k35xezedraj6pnd45y + '@oclif/core': 2.15.0_ogreqof3k35xezedraj6pnd45y + async: 3.2.5 + big-json: 3.2.0 + bluebird: 3.7.2 + chalk: 4.1.2 + is-valid-path: 0.1.1 + lodash: 4.17.21 + merge: 2.1.1 + mkdirp: 1.0.4 + path: 0.12.7 + progress-stream: 2.0.0 + promise-limit: 2.7.0 + proxyquire: 2.1.3 + tslib: 2.6.2 + winston: 3.11.0 + transitivePeerDependencies: + - '@swc/core' + - '@swc/wasm' + - '@types/node' + - encoding + - supports-color + - typescript + dev: false + + /@contentstack/cli-cm-import/1.13.1: + resolution: {integrity: sha512-DIU3V1j28fe1IfmZc0vNC65nA/NPQ4a2fmPtQ6xTwywAMt3J/1BeVteO9sVT7kC7icWX2KpEe+KDmE6W4bWJGw==} + engines: {node: '>=14.0.0'} + dependencies: + '@contentstack/cli-audit': 1.3.3 + '@contentstack/cli-command': 1.2.17 + '@contentstack/cli-utilities': 1.5.10 + '@contentstack/management': 1.13.0_debug@4.3.4 + '@oclif/core': 2.15.0 + big-json: 3.2.0 + bluebird: 3.7.2 + chalk: 4.1.2 + debug: 4.3.4 + fs-extra: 11.2.0 + lodash: 4.17.21 + marked: 4.3.0 + merge: 2.1.1 + mkdirp: 1.0.4 + promise-limit: 2.7.0 + tslib: 2.6.2 + uuid: 9.0.1 + winston: 3.11.0 + transitivePeerDependencies: + - '@swc/core' + - '@swc/wasm' + - '@types/node' + - encoding + - supports-color + - typescript + dev: false + + /@contentstack/cli-cm-import/1.13.1_ogreqof3k35xezedraj6pnd45y: + resolution: {integrity: sha512-DIU3V1j28fe1IfmZc0vNC65nA/NPQ4a2fmPtQ6xTwywAMt3J/1BeVteO9sVT7kC7icWX2KpEe+KDmE6W4bWJGw==} + engines: {node: '>=14.0.0'} + dependencies: + '@contentstack/cli-audit': 1.3.3_ogreqof3k35xezedraj6pnd45y + '@contentstack/cli-command': 1.2.17_ogreqof3k35xezedraj6pnd45y + '@contentstack/cli-utilities': 1.5.10_ogreqof3k35xezedraj6pnd45y + '@contentstack/management': 1.13.0_debug@4.3.4 + '@oclif/core': 2.15.0_ogreqof3k35xezedraj6pnd45y + big-json: 3.2.0 + bluebird: 3.7.2 + chalk: 4.1.2 + debug: 4.3.4 + fs-extra: 11.2.0 + lodash: 4.17.21 + marked: 4.3.0 + merge: 2.1.1 + mkdirp: 1.0.4 + promise-limit: 2.7.0 + tslib: 2.6.2 + uuid: 9.0.1 + winston: 3.11.0 + transitivePeerDependencies: + - '@swc/core' + - '@swc/wasm' + - '@types/node' + - encoding + - supports-color + - typescript + dev: false + + /@contentstack/cli-command/1.2.17: + resolution: {integrity: sha512-z5DWK+S+fRAXIZc0eZH1aw/Vb84wqICzYlGi4nKtov56H7QMWHwb+dORmzQvBHCUjbT/5/cZc6wpBZkebAUc7Q==} + engines: {node: '>=14.0.0'} + dependencies: + '@contentstack/cli-utilities': 1.5.10 + contentstack: 3.17.2 + transitivePeerDependencies: + - '@swc/core' + - '@swc/wasm' + - '@types/node' + - encoding + - supports-color + - typescript + dev: false + + /@contentstack/cli-command/1.2.17_ogreqof3k35xezedraj6pnd45y: + resolution: {integrity: sha512-z5DWK+S+fRAXIZc0eZH1aw/Vb84wqICzYlGi4nKtov56H7QMWHwb+dORmzQvBHCUjbT/5/cZc6wpBZkebAUc7Q==} + engines: {node: '>=14.0.0'} + dependencies: + '@contentstack/cli-utilities': 1.5.10_ogreqof3k35xezedraj6pnd45y + contentstack: 3.17.2 + transitivePeerDependencies: + - '@swc/core' + - '@swc/wasm' + - '@types/node' + - encoding + - supports-color + - typescript + dev: false + /@contentstack/cli-command/1.2.17_typescript@4.9.5: resolution: {integrity: sha512-z5DWK+S+fRAXIZc0eZH1aw/Vb84wqICzYlGi4nKtov56H7QMWHwb+dORmzQvBHCUjbT/5/cZc6wpBZkebAUc7Q==} engines: {node: '>=14.0.0'} @@ -1603,6 +1833,76 @@ packages: - typescript dev: true + /@contentstack/cli-utilities/1.5.10: + resolution: {integrity: sha512-UMypT6q+XqgeKp3mETcZo6WmSl4IVkz/FDWAqm/agnbHturovSvmbxjFxtSNX/8iLNe9E1bQC3n6KPGmxeWtlQ==} + dependencies: + '@contentstack/management': 1.13.0_debug@4.3.4 + '@contentstack/marketplace-sdk': 1.0.1_debug@4.3.4 + '@oclif/core': 2.15.0 + axios: 1.6.5_debug@4.3.4 + chalk: 4.1.2 + cli-cursor: 3.1.0 + cli-table: 0.3.11 + conf: 10.2.0 + debug: 4.3.4 + figures: 3.2.0 + inquirer: 8.2.4 + inquirer-search-checkbox: 1.0.0 + inquirer-search-list: 1.2.6 + klona: 2.0.6 + lodash: 4.17.21 + mkdirp: 1.0.4 + open: 8.4.2 + ora: 5.4.1 + rxjs: 6.6.7 + traverse: 0.6.7 + unique-string: 2.0.0 + uuid: 9.0.1 + winston: 3.11.0 + xdg-basedir: 4.0.0 + transitivePeerDependencies: + - '@swc/core' + - '@swc/wasm' + - '@types/node' + - supports-color + - typescript + dev: false + + /@contentstack/cli-utilities/1.5.10_ogreqof3k35xezedraj6pnd45y: + resolution: {integrity: sha512-UMypT6q+XqgeKp3mETcZo6WmSl4IVkz/FDWAqm/agnbHturovSvmbxjFxtSNX/8iLNe9E1bQC3n6KPGmxeWtlQ==} + dependencies: + '@contentstack/management': 1.13.0_debug@4.3.4 + '@contentstack/marketplace-sdk': 1.0.1_debug@4.3.4 + '@oclif/core': 2.15.0_ogreqof3k35xezedraj6pnd45y + axios: 1.6.5_debug@4.3.4 + chalk: 4.1.2 + cli-cursor: 3.1.0 + cli-table: 0.3.11 + conf: 10.2.0 + debug: 4.3.4 + figures: 3.2.0 + inquirer: 8.2.4 + inquirer-search-checkbox: 1.0.0 + inquirer-search-list: 1.2.6 + klona: 2.0.6 + lodash: 4.17.21 + mkdirp: 1.0.4 + open: 8.4.2 + ora: 5.4.1 + rxjs: 6.6.7 + traverse: 0.6.7 + unique-string: 2.0.0 + uuid: 9.0.1 + winston: 3.11.0 + xdg-basedir: 4.0.0 + transitivePeerDependencies: + - '@swc/core' + - '@swc/wasm' + - '@types/node' + - supports-color + - typescript + dev: false + /@contentstack/cli-utilities/1.5.10_typescript@4.9.5: resolution: {integrity: sha512-UMypT6q+XqgeKp3mETcZo6WmSl4IVkz/FDWAqm/agnbHturovSvmbxjFxtSNX/8iLNe9E1bQC3n6KPGmxeWtlQ==} dependencies: @@ -2548,7 +2848,6 @@ packages: - '@swc/wasm' - '@types/node' - typescript - dev: true /@oclif/core/2.15.0_bk3wvsuof3vjc47yunkur62wp4: resolution: {integrity: sha512-fNEMG5DzJHhYmI3MgpByTvltBOMyFcnRIUMxbiz2ai8rhaYgaTHMG3Q38HcosfIvtw9nCjxpcQtC8MN8QtVCcA==} @@ -2810,7 +3109,6 @@ packages: - '@swc/wasm' - '@types/node' - typescript - dev: true /@oclif/plugin-help/5.2.20_bk3wvsuof3vjc47yunkur62wp4: resolution: {integrity: sha512-u+GXX/KAGL9S10LxAwNUaWdzbEBARJ92ogmM7g3gDVud2HioCmvWQCDohNRVZ9GYV9oKwZ/M8xwd6a1d95rEKQ==} @@ -2834,7 +3132,6 @@ packages: - '@swc/wasm' - '@types/node' - typescript - dev: true /@oclif/plugin-help/5.2.20_typescript@4.9.5: resolution: {integrity: sha512-u+GXX/KAGL9S10LxAwNUaWdzbEBARJ92ogmM7g3gDVud2HioCmvWQCDohNRVZ9GYV9oKwZ/M8xwd6a1d95rEKQ==} @@ -13178,7 +13475,6 @@ packages: make-error: 1.3.6 v8-compile-cache-lib: 3.0.1 yn: 3.1.1 - dev: true /ts-node/10.9.2_bk3wvsuof3vjc47yunkur62wp4: resolution: {integrity: sha512-f0FFpIdcHgn8zcPSbf1dRevwt047YMnaiJM3u2w2RewrB+fob/zePZcrOyQoLMMO7aBIddLcQIEK5dYjkLnGrQ==} From a5f8225a96c0dac672459d530258fc0b4cac2aab Mon Sep 17 00:00:00 2001 From: shafeeqd959 Date: Wed, 24 Jan 2024 15:35:56 +0530 Subject: [PATCH 02/13] bumped version in the core --- packages/contentstack/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/contentstack/package.json b/packages/contentstack/package.json index 7d99546675..d3ae30c1b0 100755 --- a/packages/contentstack/package.json +++ b/packages/contentstack/package.json @@ -27,7 +27,7 @@ "@contentstack/cli-cm-bootstrap": "~1.7.1", "@contentstack/cli-cm-branches": "~1.0.20", "@contentstack/cli-cm-bulk-publish": "~1.4.0", - "@contentstack/cli-cm-clone": "~1.9.0", + "@contentstack/cli-cm-clone": "~1.10.0", "@contentstack/cli-cm-export": "~1.10.2", "@contentstack/cli-cm-export-to-csv": "~1.6.2", "@contentstack/cli-cm-import": "~1.13.0", From 7723ceb9f44ae074fd3328bbd395b535c1f04183 Mon Sep 17 00:00:00 2001 From: shafeeqd959 Date: Wed, 24 Jan 2024 19:59:07 +0530 Subject: [PATCH 03/13] added separate config for export and import --- packages/contentstack-audit/README.md | 2 +- packages/contentstack-clone/package.json | 3 +- .../src/lib/util/clone-handler.js | 51 +++++++++++-------- 3 files changed, 34 insertions(+), 22 deletions(-) diff --git a/packages/contentstack-audit/README.md b/packages/contentstack-audit/README.md index 65dddb78a5..a9766ba649 100644 --- a/packages/contentstack-audit/README.md +++ b/packages/contentstack-audit/README.md @@ -19,7 +19,7 @@ $ npm install -g @contentstack/cli-audit $ csdx COMMAND running command... $ csdx (--version|-v) -@contentstack/cli-audit/1.3.4 darwin-arm64 node-v18.12.1 +@contentstack/cli-audit/1.3.4 darwin-arm64 node-v20.8.0 $ csdx --help [COMMAND] USAGE $ csdx COMMAND diff --git a/packages/contentstack-clone/package.json b/packages/contentstack-clone/package.json index c85baccfd4..6acd0631ac 100644 --- a/packages/contentstack-clone/package.json +++ b/packages/contentstack-clone/package.json @@ -19,7 +19,8 @@ "prompt": "^1.3.0", "rimraf": "^3.0.2", "winston": "^3.7.2", - "merge": "^2.1.1" + "merge": "^2.1.1", + "lodash": "^4.17.20" }, "devDependencies": { "@oclif/test": "^1.2.7", diff --git a/packages/contentstack-clone/src/lib/util/clone-handler.js b/packages/contentstack-clone/src/lib/util/clone-handler.js index e300925c31..adb0a10ffc 100644 --- a/packages/contentstack-clone/src/lib/util/clone-handler.js +++ b/packages/contentstack-clone/src/lib/util/clone-handler.js @@ -8,6 +8,7 @@ let { default: importCmd } = require('@contentstack/cli-cm-import'); const { CustomAbortController } = require('./abort-controller'); const prompt = require('prompt'); const colors = require('@colors/colors/safe'); +const cloneDeep = require("lodash/cloneDeep") const { HandleOrgCommand, @@ -616,24 +617,29 @@ class CloneHandler { async cmdExport() { return new Promise((resolve, reject) => { - const cmd = ['-k', config.source_stack, '-d', __dirname.split('src')[0] + 'contents']; - if (config.cloneType === 'a') { - config.filteredModules = ['stack'].concat(structureList); + // Creating export specific config by merging external configurations + let exportConfig = Object.assign({}, cloneDeep(config), {...config?.export}); + delete exportConfig.import; + delete exportConfig.export; + + const cmd = ['-k', exportConfig.source_stack, '-d', __dirname.split('src')[0] + 'contents']; + if (exportConfig.cloneType === 'a') { + exportConfig.filteredModules = ['stack'].concat(structureList); } - if (config.source_alias) { - cmd.push('-a', config.source_alias); + if (exportConfig.source_alias) { + cmd.push('-a', exportConfig.source_alias); } - if (config.sourceStackBranch) { - cmd.push('--branch', config.sourceStackBranch); + if (exportConfig.sourceStackBranch) { + cmd.push('--branch', exportConfig.sourceStackBranch); } - if (config.forceStopMarketplaceAppsPrompt) cmd.push('-y'); + if (exportConfig.forceStopMarketplaceAppsPrompt) cmd.push('-y'); cmd.push('-c'); cmd.push(path.join(__dirname, 'dummyConfig.json')); - fs.writeFileSync(path.join(__dirname, 'dummyConfig.json'), JSON.stringify(config)); + fs.writeFileSync(path.join(__dirname, 'dummyConfig.json'), JSON.stringify(exportConfig)); let exportData = exportCmd.run(cmd); exportData.then(() => resolve(true)).catch(reject); }); @@ -641,26 +647,31 @@ class CloneHandler { async cmdImport() { return new Promise(async (resolve, _reject) => { + // Creating export specific config by merging external configurations + let importConfig = Object.assign({}, cloneDeep(config), {...config?.import}); + delete importConfig.import; + delete importConfig.export; + const cmd = ['-c', path.join(__dirname, 'dummyConfig.json')]; - if (config.destination_alias) { - cmd.push('-a', config.destination_alias); + if (importConfig.destination_alias) { + cmd.push('-a', importConfig.destination_alias); } - if (!config.data && config.sourceStackBranch) { - cmd.push('-d', path.join(config.pathDir, config.sourceStackBranch)); + if (!importConfig.data && importConfig.sourceStackBranch) { + cmd.push('-d', path.join(importConfig.pathDir, importConfig.sourceStackBranch)); } - if (config.targetStackBranch) { - cmd.push('--branch', config.targetStackBranch); + if (importConfig.targetStackBranch) { + cmd.push('--branch', importConfig.targetStackBranch); } - if (config.importWebhookStatus) { - cmd.push('--import-webhook-status', config.importWebhookStatus); + if (importConfig.importWebhookStatus) { + cmd.push('--import-webhook-status', importConfig.importWebhookStatus); } - if (config.skipAudit) cmd.push('--skip-audit'); + if (importConfig.skipAudit) cmd.push('--skip-audit'); - if (config.forceStopMarketplaceAppsPrompt) cmd.push('-y'); + if (importConfig.forceStopMarketplaceAppsPrompt) cmd.push('-y'); - fs.writeFileSync(path.join(__dirname, 'dummyConfig.json'), JSON.stringify(config)); + fs.writeFileSync(path.join(__dirname, 'dummyConfig.json'), JSON.stringify(importConfig)); await importCmd.run(cmd); fs.writeFileSync(path.join(__dirname, 'dummyConfig.json'), JSON.stringify({})) return resolve(); From 5121c709aa2180a3f98009df553781cabbda9692 Mon Sep 17 00:00:00 2001 From: Antony Date: Mon, 29 Jan 2024 15:23:55 +0530 Subject: [PATCH 04/13] refactor: Launch base class refactor --- package-lock.json | 1 + packages/contentstack-launch/src/adapters/github.ts | 6 +++--- .../src/{commands/launch => }/base-command.ts | 12 +++++------- .../src/commands/launch/deployments.ts | 3 +-- .../src/commands/launch/environments.ts | 3 +-- .../src/commands/launch/functions.ts | 3 +-- .../contentstack-launch/src/commands/launch/index.ts | 5 ++--- .../contentstack-launch/src/commands/launch/logs.ts | 3 +-- .../contentstack-launch/src/commands/launch/open.ts | 3 +-- packages/contentstack-launch/src/config/index.ts | 1 + pnpm-lock.yaml | 8 +++++--- 11 files changed, 22 insertions(+), 26 deletions(-) rename packages/contentstack-launch/src/{commands/launch => }/base-command.ts (95%) diff --git a/package-lock.json b/package-lock.json index ca5dd8be5f..1516d9804c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -24238,6 +24238,7 @@ "child_process": "^1.0.2", "fancy-test": "^1.4.10", "inquirer": "8.2.4", + "lodash": "^4.17.20", "merge": "^2.1.1", "ora": "^5.1.0", "prompt": "^1.3.0", diff --git a/packages/contentstack-launch/src/adapters/github.ts b/packages/contentstack-launch/src/adapters/github.ts index d140932e2f..e6b049cf34 100755 --- a/packages/contentstack-launch/src/adapters/github.ts +++ b/packages/contentstack-launch/src/adapters/github.ts @@ -60,7 +60,6 @@ export default class GitHub extends BaseClass { async createNewProject(): Promise { const { branch, - provider, framework, repository, projectName, @@ -68,8 +67,9 @@ export default class GitHub extends BaseClass { selectedStack, outputDirectory, environmentName, + provider: gitProvider, } = this.config; - const username = split(repository?.fullName, "/")[0]; + const username = split(repository?.fullName, '/')[0]; await this.apolloClient .mutate({ @@ -80,9 +80,9 @@ export default class GitHub extends BaseClass { cmsStackApiKey: selectedStack?.api_key || '', repository: { username, - gitProvider: provider, repositoryUrl: repository?.url, repositoryName: repository?.fullName, + gitProviderMetadata: { gitProvider }, }, environment: { gitBranch: branch, diff --git a/packages/contentstack-launch/src/commands/launch/base-command.ts b/packages/contentstack-launch/src/base-command.ts similarity index 95% rename from packages/contentstack-launch/src/commands/launch/base-command.ts rename to packages/contentstack-launch/src/base-command.ts index 4fdb5551cb..018ef3ecde 100755 --- a/packages/contentstack-launch/src/commands/launch/base-command.ts +++ b/packages/contentstack-launch/src/base-command.ts @@ -17,9 +17,9 @@ import { managementSDKInitiator, } from '@contentstack/cli-utilities'; -import config from '../../config'; -import { GraphqlApiClient, Logger } from '../../util'; -import { ConfigType, LogFn, Providers } from '../../types'; +import config from './config'; +import { 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; @@ -36,8 +36,6 @@ export abstract class BaseCommand extends Command { protected flags!: Flags; protected args!: Args; - static hidden = true; - // define flags that can be inherited by any command that extends BaseCommand static baseFlags: FlagInput = { 'data-dir': Flags.string({ @@ -107,9 +105,9 @@ export abstract class BaseCommand extends Command { this.flags['data-dir'] || this.flags.config ? this.flags.config || resolve(this.flags['data-dir'], config.configName) : resolve(process.cwd(), config.configName); - const baseUrl = (config.launchHubUrls as Record)[this.cmaAPIUrl]; + const baseUrl = config.launchBaseUrl || (config.launchHubUrls as Record)[this.cmaAPIUrl]; this.sharedConfig = { - ...require('../../config').default, + ...require('./config').default, currentConfig: {}, ...this.flags, flags: this.flags, diff --git a/packages/contentstack-launch/src/commands/launch/deployments.ts b/packages/contentstack-launch/src/commands/launch/deployments.ts index ef22181647..07b85ecfb4 100755 --- a/packages/contentstack-launch/src/commands/launch/deployments.ts +++ b/packages/contentstack-launch/src/commands/launch/deployments.ts @@ -4,12 +4,11 @@ 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 { BaseCommand } from '../../base-command'; import { environmentsQuery } from '../../graphql'; import { Logger, selectOrg, selectProject } from '../../util'; export default class Deployments extends BaseCommand { - static hidden = false; static description = 'Show list of deployments for an environment'; static examples = [ diff --git a/packages/contentstack-launch/src/commands/launch/environments.ts b/packages/contentstack-launch/src/commands/launch/environments.ts index 45473d76ca..bbab7c9fdc 100755 --- a/packages/contentstack-launch/src/commands/launch/environments.ts +++ b/packages/contentstack-launch/src/commands/launch/environments.ts @@ -4,12 +4,11 @@ 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 { BaseCommand } from '../../base-command'; import { Logger, selectOrg, selectProject } from '../../util'; import { environmentsQuery, projectsQuery } from '../../graphql'; export default class Environments extends BaseCommand { - static hidden = false; static description = 'Show list of environments for a project'; static examples = [ diff --git a/packages/contentstack-launch/src/commands/launch/functions.ts b/packages/contentstack-launch/src/commands/launch/functions.ts index 76816b7f33..c5e3b78605 100755 --- a/packages/contentstack-launch/src/commands/launch/functions.ts +++ b/packages/contentstack-launch/src/commands/launch/functions.ts @@ -1,10 +1,9 @@ import { FlagInput, Flags } from '@contentstack/cli-utilities'; -import { BaseCommand } from './base-command'; +import { BaseCommand } from '../../base-command'; import Contentfly from '../../util/cloud-function'; export default class Functions extends BaseCommand { - static hidden = false; static description = 'Serve cloud functions'; static examples = [ diff --git a/packages/contentstack-launch/src/commands/launch/index.ts b/packages/contentstack-launch/src/commands/launch/index.ts index 8fd4cd1e76..06abde2cd4 100755 --- a/packages/contentstack-launch/src/commands/launch/index.ts +++ b/packages/contentstack-launch/src/commands/launch/index.ts @@ -2,15 +2,13 @@ import map from 'lodash/map'; import { FlagInput, Flags } from '@contentstack/cli-utilities'; import config from '../../config'; -import { BaseCommand } from './base-command'; +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 hidden = false; - static description = 'Launch related operations'; static examples = [ @@ -58,6 +56,7 @@ export default class Launch extends BaseCommand { description: '[Optional, Hidden] Show variable values on the UI', }), init: Flags.boolean({ + hidden: true, description: '[Optional, Hidden] Reinitialize the project if it is an existing launch project.', }), }; diff --git a/packages/contentstack-launch/src/commands/launch/logs.ts b/packages/contentstack-launch/src/commands/launch/logs.ts index 2be2025ea5..581d56ce66 100755 --- a/packages/contentstack-launch/src/commands/launch/logs.ts +++ b/packages/contentstack-launch/src/commands/launch/logs.ts @@ -5,13 +5,12 @@ import isArray from 'lodash/isArray'; import includes from 'lodash/includes'; import { Flags, FlagInput, cliux as ux } from '@contentstack/cli-utilities'; -import { BaseCommand } from './base-command'; +import { BaseCommand } from '../../base-command'; import { environmentsQuery } from '../../graphql'; import { Logger, LogPolling, selectOrg, selectProject } from '../../util'; import { EmitMessage, DeploymentLogResp, ServerLogResp } from '../../types'; export default class Logs extends BaseCommand { - static hidden = false; static description = 'Show deployment or server logs'; static examples = [ diff --git a/packages/contentstack-launch/src/commands/launch/open.ts b/packages/contentstack-launch/src/commands/launch/open.ts index b68b8ab83a..76a6c24464 100755 --- a/packages/contentstack-launch/src/commands/launch/open.ts +++ b/packages/contentstack-launch/src/commands/launch/open.ts @@ -4,12 +4,11 @@ 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 { BaseCommand } from '../../base-command'; import { environmentsQuery } from '../../graphql'; import { print, Logger, selectOrg, selectProject } from '../../util'; export default class Open extends BaseCommand { - static hidden = false; static description = 'Open a website for an environment'; static examples = [ diff --git a/packages/contentstack-launch/src/config/index.ts b/packages/contentstack-launch/src/config/index.ts index 7aab1b2fce..578444da76 100755 --- a/packages/contentstack-launch/src/config/index.ts +++ b/packages/contentstack-launch/src/config/index.ts @@ -28,6 +28,7 @@ const config = { 'https://azure-na-api.contentstack.com': '', 'https://azure-eu-api.contentstack.com': '', }, + launchBaseUrl: '', supportedAdapters: ['GitHub'], deploymentStatus: ['LIVE', 'FAILED', 'SKIPPED', 'DEPLOYED'], pollingInterval: 1000, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c89a21811a..79c0d9f9d9 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -438,6 +438,7 @@ importers: globby: ^10.0.2 inquirer: 8.2.4 jest: ^29.4.2 + lodash: ^4.17.20 merge: ^2.1.1 mocha: ^10.0.0 nyc: ^15.1.0 @@ -458,6 +459,7 @@ importers: child_process: 1.0.2 fancy-test: 1.4.10 inquirer: 8.2.4 + lodash: 4.17.21 merge: 2.1.1 ora: 5.4.1 prompt: 1.3.0 @@ -6446,7 +6448,7 @@ packages: eslint-import-resolver-webpack: optional: true dependencies: - '@typescript-eslint/parser': 6.13.2_7hj7rehet5x3fvq7nqub5sammm + '@typescript-eslint/parser': 6.13.2_sjjl3gun7puonkp27uqtyjm5b4 debug: 3.2.7 eslint: 8.55.0 eslint-import-resolver-node: 0.3.9 @@ -6476,7 +6478,7 @@ packages: eslint-import-resolver-webpack: optional: true dependencies: - '@typescript-eslint/parser': 6.13.2_7hj7rehet5x3fvq7nqub5sammm + '@typescript-eslint/parser': 6.13.2_sjjl3gun7puonkp27uqtyjm5b4 debug: 3.2.7 eslint: 8.55.0 eslint-import-resolver-typescript: 3.6.1_hdscurta55xxypqxbdhu44qa6e @@ -6581,7 +6583,7 @@ packages: '@typescript-eslint/parser': optional: true dependencies: - '@typescript-eslint/parser': 6.13.2_7hj7rehet5x3fvq7nqub5sammm + '@typescript-eslint/parser': 6.13.2_sjjl3gun7puonkp27uqtyjm5b4 array-includes: 3.1.7 array.prototype.findlastindex: 1.2.3 array.prototype.flat: 1.3.2 From 678764e783d4edd7903bd209ba130218dfd095d8 Mon Sep 17 00:00:00 2001 From: Antony Date: Mon, 29 Jan 2024 15:35:27 +0530 Subject: [PATCH 05/13] fix: Project query and mutation update --- package-lock.json | 4 ++-- packages/contentstack-launch/README.md | 2 +- packages/contentstack-launch/package.json | 2 +- packages/contentstack-launch/src/graphql/mutation.ts | 11 ++++++----- packages/contentstack-launch/src/graphql/queries.ts | 8 ++++++-- packages/contentstack/README.md | 5 ++--- packages/contentstack/package.json | 2 +- pnpm-lock.yaml | 2 +- 8 files changed, 20 insertions(+), 16 deletions(-) diff --git a/package-lock.json b/package-lock.json index 1516d9804c..65ae62eb89 100644 --- a/package-lock.json +++ b/package-lock.json @@ -23538,7 +23538,7 @@ "@contentstack/cli-cm-seed": "~1.7.1", "@contentstack/cli-command": "~1.2.17", "@contentstack/cli-config": "~1.6.0", - "@contentstack/cli-launch": "~1.0.15", + "@contentstack/cli-launch": "~1.0.16", "@contentstack/cli-migration": "~1.4.2", "@contentstack/cli-utilities": "~1.5.11", "@contentstack/management": "~1.13.0", @@ -25400,7 +25400,7 @@ }, "packages/contentstack-launch": { "name": "@contentstack/cli-launch", - "version": "1.0.15", + "version": "1.0.16", "license": "MIT", "dependencies": { "@apollo/client": "^3.7.9", diff --git a/packages/contentstack-launch/README.md b/packages/contentstack-launch/README.md index 3b86d121f0..acf6a6c9db 100755 --- a/packages/contentstack-launch/README.md +++ b/packages/contentstack-launch/README.md @@ -19,7 +19,7 @@ $ npm install -g @contentstack/cli-launch $ csdx COMMAND running command... $ csdx (--version|-v) -@contentstack/cli-launch/1.0.15 darwin-arm64 node-v20.8.0 +@contentstack/cli-launch/1.0.16 darwin-arm64 node-v20.10.0 $ csdx --help [COMMAND] USAGE $ csdx COMMAND diff --git a/packages/contentstack-launch/package.json b/packages/contentstack-launch/package.json index de9507fa4d..ab69f1b873 100755 --- a/packages/contentstack-launch/package.json +++ b/packages/contentstack-launch/package.json @@ -1,6 +1,6 @@ { "name": "@contentstack/cli-launch", - "version": "1.0.15", + "version": "1.0.16", "description": "Launch related operations", "author": "Contentstack CLI", "bin": { diff --git a/packages/contentstack-launch/src/graphql/mutation.ts b/packages/contentstack-launch/src/graphql/mutation.ts index 46c779fc5e..3edc731f62 100755 --- a/packages/contentstack-launch/src/graphql/mutation.ts +++ b/packages/contentstack-launch/src/graphql/mutation.ts @@ -33,10 +33,7 @@ const createSignedUploadUrlMutation: DocumentNode = gql` `; const importProjectMutation: DocumentNode = gql` - mutation importProject( - $project: ImportProjectInput! - $skipGitData: Boolean = false - ) { + mutation importProject($project: ImportProjectInput!, $skipGitData: Boolean = false) { project: importProject(project: $project) { uid name @@ -63,8 +60,12 @@ const importProjectMutation: DocumentNode = gql` } repository @skip(if: $skipGitData) { username - gitProvider repositoryName + gitProviderMetadata { + ... on GitHubMetadata { + gitProvider + } + } } } } diff --git a/packages/contentstack-launch/src/graphql/queries.ts b/packages/contentstack-launch/src/graphql/queries.ts index a5037b6c3a..6f3cfc3319 100755 --- a/packages/contentstack-launch/src/graphql/queries.ts +++ b/packages/contentstack-launch/src/graphql/queries.ts @@ -90,11 +90,15 @@ const projectsQuery: DocumentNode = gql` cmsStackApiKey organizationUid repository { - gitProvider - gitProviderConnectionUid repositoryName repositoryUrl username + gitProviderMetadata { + ... on GitHubMetadata { + connectionUid + gitProvider + } + } } } } diff --git a/packages/contentstack/README.md b/packages/contentstack/README.md index 0da4df967a..058af6fa94 100644 --- a/packages/contentstack/README.md +++ b/packages/contentstack/README.md @@ -18,7 +18,7 @@ $ npm install -g @contentstack/cli $ csdx COMMAND running command... $ csdx (--version|-v) -@contentstack/cli/1.13.0 darwin-arm64 node-v20.8.0 +@contentstack/cli/1.13.0 darwin-arm64 node-v20.10.0 $ csdx --help [COMMAND] USAGE $ csdx COMMAND @@ -3228,7 +3228,7 @@ Launch related operations ``` USAGE $ csdx launch [-d ] [-c ] [--type GitHub|FileUpload] [--framework Gatsby|NextJs|Other] - [--org ] [-n ] [-e ] [--branch ] [--build-command ] [--out-dir ] [--init] + [--org ] [-n ] [-e ] [--branch ] [--build-command ] [--out-dir ] FLAGS -c, --config= Path to the local '.cs-launch.json' file @@ -3239,7 +3239,6 @@ FLAGS --build-command= [Optional] Build Command --framework=