diff --git a/package-lock.json b/package-lock.json index 5bd8eeb..94c1e61 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,8 +9,8 @@ "version": "1.0.3", "license": "MIT", "dependencies": { - "@contentstack/cli-command": "^1.2.11", - "@contentstack/cli-utilities": "^1.5.1", + "@contentstack/cli-command": "^1.2.16", + "@contentstack/cli-utilities": "^1.5.8", "adm-zip": "^0.5.10", "chalk": "^4.1.2", "lodash": "^4.17.21", @@ -587,11 +587,11 @@ } }, "node_modules/@contentstack/cli-command": { - "version": "1.2.11", - "resolved": "https://registry.npmjs.org/@contentstack/cli-command/-/cli-command-1.2.11.tgz", - "integrity": "sha512-cd6b0ZZggUToLiBfOMeczANXhuPdbyYoyZi1JRxxvICWDble7hAV1PlYWr5eT7E14f0V0J2bsKVI96BxENWiyg==", + "version": "1.2.16", + "resolved": "https://registry.npmjs.org/@contentstack/cli-command/-/cli-command-1.2.16.tgz", + "integrity": "sha512-u8GecSKkRgMPAmsib1xtfcUF8T/+ZbHe4JKAibRLkVc7jIjwuToq36hPgGFMfUAK4HX/UZ09stS+f3dUN1maOA==", "dependencies": { - "@contentstack/cli-utilities": "^1.5.1", + "@contentstack/cli-utilities": "~1.5.7", "contentstack": "^3.10.1" }, "engines": { @@ -599,13 +599,13 @@ } }, "node_modules/@contentstack/cli-utilities": { - "version": "1.5.1", - "resolved": "https://registry.npmjs.org/@contentstack/cli-utilities/-/cli-utilities-1.5.1.tgz", - "integrity": "sha512-GQK/yduIrJ/ERA534aUf9gSjNO1BYv0jjRnpHRLPmzMJPOY9gkY9crp/84SlEkaghLuFwvao9sSX+NN/27HCeg==", + "version": "1.5.8", + "resolved": "https://registry.npmjs.org/@contentstack/cli-utilities/-/cli-utilities-1.5.8.tgz", + "integrity": "sha512-YrIXi8Nr0qlITODRUVpbW9sfdmKNHS2tY7O/y2AxvkzTFxBnRafT1HZTUm/RaLdxmnFudFD86rVzjxmojop/lA==", "dependencies": { - "@contentstack/management": "~1.10.0", + "@contentstack/management": "~1.12.0", "@oclif/core": "^2.9.3", - "axios": "1.3.4", + "axios": "^1.6.0", "chalk": "^4.0.0", "cli-cursor": "^3.1.0", "cli-table": "^0.3.11", @@ -615,27 +615,19 @@ "inquirer": "8.2.4", "inquirer-search-checkbox": "^1.0.0", "inquirer-search-list": "^1.2.6", + "klona": "^2.0.6", "lodash": "^4.17.15", "mkdirp": "^1.0.4", "open": "^8.4.2", "ora": "^5.4.0", "rxjs": "^6.6.7", + "traverse": "^0.6.7", "unique-string": "^2.0.0", "uuid": "^9.0.0", "winston": "^3.7.2", "xdg-basedir": "^4.0.0" } }, - "node_modules/@contentstack/cli-utilities/node_modules/axios": { - "version": "1.3.4", - "resolved": "https://registry.npmjs.org/axios/-/axios-1.3.4.tgz", - "integrity": "sha512-toYm+Bsyl6VC5wSkfkbbNB6ROv7KY93PEBBL6xyDczaIHasAiv4wPqQ/c4RjoQzipxRD2W5g21cOqQulZ7rHwQ==", - "dependencies": { - "follow-redirects": "^1.15.0", - "form-data": "^4.0.0", - "proxy-from-env": "^1.1.0" - } - }, "node_modules/@contentstack/cli-utilities/node_modules/define-lazy-prop": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/define-lazy-prop/-/define-lazy-prop-2.0.0.tgz", @@ -644,19 +636,6 @@ "node": ">=8" } }, - "node_modules/@contentstack/cli-utilities/node_modules/form-data": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", - "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", - "dependencies": { - "asynckit": "^0.4.0", - "combined-stream": "^1.0.8", - "mime-types": "^2.1.12" - }, - "engines": { - "node": ">= 6" - } - }, "node_modules/@contentstack/cli-utilities/node_modules/open": { "version": "8.4.2", "resolved": "https://registry.npmjs.org/open/-/open-8.4.2.tgz", @@ -674,11 +653,11 @@ } }, "node_modules/@contentstack/management": { - "version": "1.10.2", - "resolved": "https://registry.npmjs.org/@contentstack/management/-/management-1.10.2.tgz", - "integrity": "sha512-jO24EqcCJhOjqdsqw8y3T0SPPAd0DG4BByjUcV0S28W2yoa8aBbcjcbZioRPzRLYKTmZWsAZissl18cIJm5djQ==", + "version": "1.12.0", + "resolved": "https://registry.npmjs.org/@contentstack/management/-/management-1.12.0.tgz", + "integrity": "sha512-+L+WVhSYEtfdG9v794TjLT8Fd6fCB8meqoho666mg1kNufzXcsqr7hjubX5cSL7GcZFdKntkDpZ2RaOnTHReJg==", "dependencies": { - "axios": "^1.4.0", + "axios": "^1.5.1", "form-data": "^3.0.1", "lodash": "^4.17.21", "qs": "^6.11.2" @@ -2426,9 +2405,9 @@ } }, "node_modules/axios": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/axios/-/axios-1.4.0.tgz", - "integrity": "sha512-S4XCWMEmzvo64T9GfvQDOXgYRDJ/wsSZc7Jvdgx5u1sd0JwsuPLqb3SYmusag+edF6ziyMensPVqLTSc1PiSEA==", + "version": "1.6.2", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.6.2.tgz", + "integrity": "sha512-7i24Ri4pmDRfJTR7LDBhsOTtcm+9kjX5WiY1X3wIisx6G9So3pfMkEiU7emUBe46oceVImccTEM3k6C5dbVW8A==", "dependencies": { "follow-redirects": "^1.15.0", "form-data": "^4.0.0", @@ -7036,6 +7015,14 @@ "json-buffer": "3.0.1" } }, + "node_modules/klona": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/klona/-/klona-2.0.6.tgz", + "integrity": "sha512-dhG34DXATL5hSxJbIexCft8FChFXtmskoZYnoPWjXQuebWYCNkVeV3KkGegCK9CP1oswI/vQibS2GY7Em/sJJA==", + "engines": { + "node": ">= 8" + } + }, "node_modules/kuler": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/kuler/-/kuler-2.0.0.tgz", @@ -11024,6 +11011,14 @@ "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==" }, + "node_modules/traverse": { + "version": "0.6.7", + "resolved": "https://registry.npmjs.org/traverse/-/traverse-0.6.7.tgz", + "integrity": "sha512-/y956gpUo9ZNCb99YjxG7OaslxZWHfCHAUUfshwqOXmxUIvqLjVO581BT+gM59+QV9tFe6/CGG53tsA1Y7RSdg==", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/tree-kill": { "version": "1.2.2", "resolved": "https://registry.npmjs.org/tree-kill/-/tree-kill-1.2.2.tgz", @@ -13453,22 +13448,22 @@ "integrity": "sha512-ooWCrlZP11i8GImSjTHYHLkvFDP48nS4+204nGb1RiX/WXYHmJA2III9/e2DWVabCESdW7hBAEzHRqUn9OUVvQ==" }, "@contentstack/cli-command": { - "version": "1.2.11", - "resolved": "https://registry.npmjs.org/@contentstack/cli-command/-/cli-command-1.2.11.tgz", - "integrity": "sha512-cd6b0ZZggUToLiBfOMeczANXhuPdbyYoyZi1JRxxvICWDble7hAV1PlYWr5eT7E14f0V0J2bsKVI96BxENWiyg==", + "version": "1.2.16", + "resolved": "https://registry.npmjs.org/@contentstack/cli-command/-/cli-command-1.2.16.tgz", + "integrity": "sha512-u8GecSKkRgMPAmsib1xtfcUF8T/+ZbHe4JKAibRLkVc7jIjwuToq36hPgGFMfUAK4HX/UZ09stS+f3dUN1maOA==", "requires": { - "@contentstack/cli-utilities": "^1.5.1", + "@contentstack/cli-utilities": "~1.5.7", "contentstack": "^3.10.1" } }, "@contentstack/cli-utilities": { - "version": "1.5.1", - "resolved": "https://registry.npmjs.org/@contentstack/cli-utilities/-/cli-utilities-1.5.1.tgz", - "integrity": "sha512-GQK/yduIrJ/ERA534aUf9gSjNO1BYv0jjRnpHRLPmzMJPOY9gkY9crp/84SlEkaghLuFwvao9sSX+NN/27HCeg==", + "version": "1.5.8", + "resolved": "https://registry.npmjs.org/@contentstack/cli-utilities/-/cli-utilities-1.5.8.tgz", + "integrity": "sha512-YrIXi8Nr0qlITODRUVpbW9sfdmKNHS2tY7O/y2AxvkzTFxBnRafT1HZTUm/RaLdxmnFudFD86rVzjxmojop/lA==", "requires": { - "@contentstack/management": "~1.10.0", + "@contentstack/management": "~1.12.0", "@oclif/core": "^2.9.3", - "axios": "1.3.4", + "axios": "^1.6.0", "chalk": "^4.0.0", "cli-cursor": "^3.1.0", "cli-table": "^0.3.11", @@ -13478,42 +13473,24 @@ "inquirer": "8.2.4", "inquirer-search-checkbox": "^1.0.0", "inquirer-search-list": "^1.2.6", + "klona": "^2.0.6", "lodash": "^4.17.15", "mkdirp": "^1.0.4", "open": "^8.4.2", "ora": "^5.4.0", "rxjs": "^6.6.7", + "traverse": "^0.6.7", "unique-string": "^2.0.0", "uuid": "^9.0.0", "winston": "^3.7.2", "xdg-basedir": "^4.0.0" }, "dependencies": { - "axios": { - "version": "1.3.4", - "resolved": "https://registry.npmjs.org/axios/-/axios-1.3.4.tgz", - "integrity": "sha512-toYm+Bsyl6VC5wSkfkbbNB6ROv7KY93PEBBL6xyDczaIHasAiv4wPqQ/c4RjoQzipxRD2W5g21cOqQulZ7rHwQ==", - "requires": { - "follow-redirects": "^1.15.0", - "form-data": "^4.0.0", - "proxy-from-env": "^1.1.0" - } - }, "define-lazy-prop": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/define-lazy-prop/-/define-lazy-prop-2.0.0.tgz", "integrity": "sha512-Ds09qNh8yw3khSjiJjiUInaGX9xlqZDY7JVryGxdxV7NPeuqQfplOpQ66yJFZut3jLa5zOwkXw1g9EI2uKh4Og==" }, - "form-data": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", - "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", - "requires": { - "asynckit": "^0.4.0", - "combined-stream": "^1.0.8", - "mime-types": "^2.1.12" - } - }, "open": { "version": "8.4.2", "resolved": "https://registry.npmjs.org/open/-/open-8.4.2.tgz", @@ -13527,11 +13504,11 @@ } }, "@contentstack/management": { - "version": "1.10.2", - "resolved": "https://registry.npmjs.org/@contentstack/management/-/management-1.10.2.tgz", - "integrity": "sha512-jO24EqcCJhOjqdsqw8y3T0SPPAd0DG4BByjUcV0S28W2yoa8aBbcjcbZioRPzRLYKTmZWsAZissl18cIJm5djQ==", + "version": "1.12.0", + "resolved": "https://registry.npmjs.org/@contentstack/management/-/management-1.12.0.tgz", + "integrity": "sha512-+L+WVhSYEtfdG9v794TjLT8Fd6fCB8meqoho666mg1kNufzXcsqr7hjubX5cSL7GcZFdKntkDpZ2RaOnTHReJg==", "requires": { - "axios": "^1.4.0", + "axios": "^1.5.1", "form-data": "^3.0.1", "lodash": "^4.17.21", "qs": "^6.11.2" @@ -14934,9 +14911,9 @@ } }, "axios": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/axios/-/axios-1.4.0.tgz", - "integrity": "sha512-S4XCWMEmzvo64T9GfvQDOXgYRDJ/wsSZc7Jvdgx5u1sd0JwsuPLqb3SYmusag+edF6ziyMensPVqLTSc1PiSEA==", + "version": "1.6.2", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.6.2.tgz", + "integrity": "sha512-7i24Ri4pmDRfJTR7LDBhsOTtcm+9kjX5WiY1X3wIisx6G9So3pfMkEiU7emUBe46oceVImccTEM3k6C5dbVW8A==", "requires": { "follow-redirects": "^1.15.0", "form-data": "^4.0.0", @@ -18352,6 +18329,11 @@ "json-buffer": "3.0.1" } }, + "klona": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/klona/-/klona-2.0.6.tgz", + "integrity": "sha512-dhG34DXATL5hSxJbIexCft8FChFXtmskoZYnoPWjXQuebWYCNkVeV3KkGegCK9CP1oswI/vQibS2GY7Em/sJJA==" + }, "kuler": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/kuler/-/kuler-2.0.0.tgz", @@ -21366,6 +21348,11 @@ "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==" }, + "traverse": { + "version": "0.6.7", + "resolved": "https://registry.npmjs.org/traverse/-/traverse-0.6.7.tgz", + "integrity": "sha512-/y956gpUo9ZNCb99YjxG7OaslxZWHfCHAUUfshwqOXmxUIvqLjVO581BT+gM59+QV9tFe6/CGG53tsA1Y7RSdg==" + }, "tree-kill": { "version": "1.2.2", "resolved": "https://registry.npmjs.org/tree-kill/-/tree-kill-1.2.2.tgz", diff --git a/package.json b/package.json index c3340d5..b07b76e 100644 --- a/package.json +++ b/package.json @@ -17,8 +17,8 @@ "/oclif.manifest.json" ], "dependencies": { - "@contentstack/cli-command": "^1.2.11", - "@contentstack/cli-utilities": "^1.5.1", + "@contentstack/cli-command": "^1.2.16", + "@contentstack/cli-utilities": "^1.5.8", "adm-zip": "^0.5.10", "chalk": "^4.1.2", "lodash": "^4.17.21", diff --git a/src/commands/app/base-command.ts b/src/base-command.ts similarity index 94% rename from src/commands/app/base-command.ts rename to src/base-command.ts index c104d50..029324b 100644 --- a/src/commands/app/base-command.ts +++ b/src/base-command.ts @@ -14,10 +14,10 @@ import { cliux, } from "@contentstack/cli-utilities"; -import config from "../../config"; -import { ConfigType, LogFn } from "../../types"; -import { Logger, getDeveloperHubUrl } from "../../util"; -import messages, { $t, commonMsg } from "../../messages"; +import config from "./config"; +import { ConfigType, LogFn } from "./types"; +import { Logger, getDeveloperHubUrl } from "./util"; +import messages, { $t, commonMsg } from "./messages"; export type Flags = Interfaces.InferredFlags< (typeof BaseCommand)["baseFlags"] & T["flags"] @@ -42,8 +42,6 @@ export abstract class BaseCommand extends Command { protected flags!: Flags; protected args!: Args; - static hidden = true; - // NOTE define flags that can be inherited by any command that extends BaseCommand static baseFlags: FlagInput = { org: Flags.string({ diff --git a/src/commands/app/create.ts b/src/commands/app/create.ts index faabcbd..0b6ebf2 100644 --- a/src/commands/app/create.ts +++ b/src/commands/app/create.ts @@ -16,7 +16,7 @@ import { } from "fs"; import { ux, cliux, flags, HttpClient } from "@contentstack/cli-utilities"; -import { BaseCommand } from "./base-command"; +import { BaseCommand } from "../../base-command"; import { AppManifest, AppType } from "../../types"; import { appCreate, commonMsg } from "../../messages"; import { @@ -28,7 +28,6 @@ import { export default class Create extends BaseCommand { private appData!: AppManifest; - static hidden: boolean = false; static description = "Create a new app in Developer Hub and optionally clone a boilerplate locally."; diff --git a/src/commands/app/delete.ts b/src/commands/app/delete.ts index e69d853..695cd31 100644 --- a/src/commands/app/delete.ts +++ b/src/commands/app/delete.ts @@ -1,11 +1,9 @@ -import { BaseCommand } from "./base-command"; +import { BaseCommand } from "../../base-command"; import { cliux, flags } from "@contentstack/cli-utilities"; import { $t, commonMsg, deleteAppMsg } from "../../messages"; import { getOrg, fetchAppInstallations, deleteApp, getApp } from "../../util"; export default class Delete extends BaseCommand { - static hidden: boolean = false; - static description = "Delete app from marketplace"; static examples = [ diff --git a/src/commands/app/get.ts b/src/commands/app/get.ts index d657eba..9ee4002 100644 --- a/src/commands/app/get.ts +++ b/src/commands/app/get.ts @@ -1,11 +1,9 @@ -import { BaseCommand } from "./base-command"; +import { BaseCommand } from "../../base-command"; import { getOrg, getApp, writeFile, fetchApp } from "../../util"; import { flags } from "@contentstack/cli-utilities"; import { commonMsg } from "../../messages"; export default class Get extends BaseCommand { - static hidden: boolean = false; - static description = "Get details of an app in developer hub"; static examples = [ diff --git a/src/commands/app/index.ts b/src/commands/app/index.ts index 7d5c73c..a70bf4c 100644 --- a/src/commands/app/index.ts +++ b/src/commands/app/index.ts @@ -7,8 +7,6 @@ import { print } from "../../util/log"; export default class App extends Command { static description = "Apps CLI plugin"; - static hidden: boolean = true; - static examples = [ "$ <%= config.bin %> <%= command.id %>:create", "$ <%= config.bin %> <%= command.id %>:get", diff --git a/src/commands/app/install.ts b/src/commands/app/install.ts index 9201b3f..18fb164 100644 --- a/src/commands/app/install.ts +++ b/src/commands/app/install.ts @@ -1,82 +1,122 @@ -import { BaseCommand } from "./base-command"; +import { BaseCommand } from "../../base-command"; import { cliux, flags } from "@contentstack/cli-utilities"; import { $t, commonMsg, installAppMsg } from "../../messages"; -import { getOrg, getApp, getStack, installApp, fetchApp, fetchStack} from "../../util"; +import { + getOrg, + getApp, + getStack, + installApp, + fetchApp, + fetchStack, +} from "../../util"; export default class Install extends BaseCommand { - static description: string | undefined = "Install an app from the marketplace"; - static hidden: boolean = false; + static description: string | undefined = + "Install an app from the marketplace"; - static examples = [ - "$ <%= config.bin %> <%= command.id %>", - "$ <%= config.bin %> <%= command.id %> --org --app-uid ", - "$ <%= config.bin %> <%= command.id %> --org --app-uid --stack-api-key ", - ]; + static examples = [ + "$ <%= config.bin %> <%= command.id %>", + "$ <%= config.bin %> <%= command.id %> --org --app-uid ", + "$ <%= config.bin %> <%= command.id %> --org --app-uid --stack-api-key ", + ]; - static flags = { - 'app-uid': flags.string({ - description: commonMsg.APP_UID, - }), - 'stack-api-key': flags.string({ - description: commonMsg.STACK_API_KEY - }) - } + static flags = { + "app-uid": flags.string({ + description: commonMsg.APP_UID, + }), + "stack-api-key": flags.string({ + description: commonMsg.STACK_API_KEY, + }), + }; - async run(): Promise { - try { - let app, stack, appType; - - // validating user given stack, as installation API doesn't return appropriate errors if stack-api-key is invalid - // validating this first, as orgUid is not required for fetching stack - if (this.flags['stack-api-key']) { - stack = await fetchStack(this.flags, {managementSdk: this.managementSdk, log: this.log}) - } + async run(): Promise { + try { + let app, stack, appType; - // get organization to be used - this.sharedConfig.org = await getOrg(this.flags, {managementSdk: this.managementSdk, log: this.log}); - - // fetch app details - if (!this.flags['app-uid']) { - app = await getApp(this.flags, this.sharedConfig.org, {managementSdk: this.managementAppSdk, log: this.log}) - } else { - app = await fetchApp(this.flags, this.sharedConfig.org, {managementSdk: this.managementAppSdk, log: this.log}) - } - appType = app?.['target_type'] // get app-type from the fetched app - this.flags['app-uid'] = app?.uid; + // validating user given stack, as installation API doesn't return appropriate errors if stack-api-key is invalid + // validating this first, as orgUid is not required for fetching stack + if (this.flags["stack-api-key"]) { + stack = await fetchStack(this.flags, { + managementSdk: this.managementSdk, + log: this.log, + }); + } + + // get organization to be used + this.sharedConfig.org = await getOrg(this.flags, { + managementSdk: this.managementSdk, + log: this.log, + }); - // in case stack-api-key is provided and the selected app is an organization app - if (appType === 'organization' && this.flags['stack-api-key']) { - const confirmation = this.flags['yes'] || await cliux.inquire({ + // fetch app details + if (!this.flags["app-uid"]) { + app = await getApp(this.flags, this.sharedConfig.org, { + managementSdk: this.managementAppSdk, + log: this.log, + }); + } else { + app = await fetchApp(this.flags, this.sharedConfig.org, { + managementSdk: this.managementAppSdk, + log: this.log, + }); + } + appType = app?.["target_type"]; // get app-type from the fetched app + this.flags["app-uid"] = app?.uid; + + // in case stack-api-key is provided and the selected app is an organization app + if (appType === "organization" && this.flags["stack-api-key"]) { + const confirmation = + this.flags["yes"] || + (await cliux.inquire({ type: "confirm", - message: $t(installAppMsg.INSTALL_ORG_APP_TO_STACK, { app: app?.name || app?.uid }), - name: "confirmation" - }) - if (!confirmation) { - throw new Error(commonMsg.USER_TERMINATION) - } + message: $t(installAppMsg.INSTALL_ORG_APP_TO_STACK, { + app: app?.name || app?.uid, + }), + name: "confirmation", + })); + if (!confirmation) { + throw new Error(commonMsg.USER_TERMINATION); } + } - // in case a stack app is selected and no stack-api-key is provided - if (appType === 'stack' && !this.flags['stack-api-key']) { - this.log($t(installAppMsg.MISSING_STACK_API_KEY, { app: app?.name || app?.uid }), "warn") - stack = await getStack(this.sharedConfig.org, {managementSdk: this.managementSdk, log: this.log}) - this.flags['stack-api-key'] = stack?.['api_key'] - } + // in case a stack app is selected and no stack-api-key is provided + if (appType === "stack" && !this.flags["stack-api-key"]) { + this.log( + $t(installAppMsg.MISSING_STACK_API_KEY, { + app: app?.name || app?.uid, + }), + "warn" + ); + stack = await getStack(this.sharedConfig.org, { + managementSdk: this.managementSdk, + log: this.log, + }); + this.flags["stack-api-key"] = stack?.["api_key"]; + } - // install app - this.log($t(installAppMsg.INSTALLING_APP_NOTICE, { + // install app + this.log( + $t(installAppMsg.INSTALLING_APP_NOTICE, { app: app?.name || app?.uid, type: appType, - target: this.flags['stack-api-key'] || this.sharedConfig.org - }), "info") - await installApp(this.flags, this.sharedConfig.org, appType, {managementSdk: this.managementAppSdk, log: this.log}) - this.log($t(installAppMsg.APP_INSTALLED_SUCCESSFULLY, { - app: app?.name || this.flags['app-uid'] as string, - target: stack?.name || this.sharedConfig.org - }), "info"); - } catch(error: any) { - this.log(error?.errorMessage || error?.message || error, "error") - this.exit(1) - } + target: this.flags["stack-api-key"] || this.sharedConfig.org, + }), + "info" + ); + await installApp(this.flags, this.sharedConfig.org, appType, { + managementSdk: this.managementAppSdk, + log: this.log, + }); + this.log( + $t(installAppMsg.APP_INSTALLED_SUCCESSFULLY, { + app: app?.name || (this.flags["app-uid"] as string), + target: stack?.name || this.sharedConfig.org, + }), + "info" + ); + } catch (error: any) { + this.log(error?.errorMessage || error?.message || error, "error"); + this.exit(1); } -} \ No newline at end of file + } +} diff --git a/src/commands/app/uninstall.ts b/src/commands/app/uninstall.ts index 679c33b..1a40133 100644 --- a/src/commands/app/uninstall.ts +++ b/src/commands/app/uninstall.ts @@ -1,4 +1,4 @@ -import { BaseCommand } from "./base-command"; +import { BaseCommand } from "../../base-command"; import { flags } from "@contentstack/cli-utilities"; import { getOrg, fetchApp, getInstalledApps } from "../../util"; import { commonMsg, uninstallAppMsg } from "../../messages"; @@ -6,7 +6,6 @@ import { UninstallAppFactory } from "../../factories/uninstall-app-factory"; export default class Uninstall extends BaseCommand { static description = "Uninstall an app"; - static hidden: boolean = false; static examples = [ "$ <%= config.bin %> <%= command.id %>", diff --git a/src/commands/app/update.ts b/src/commands/app/update.ts index 033fb23..14cf3fb 100644 --- a/src/commands/app/update.ts +++ b/src/commands/app/update.ts @@ -6,7 +6,7 @@ import { App } from "@contentstack/management/types/app"; import { existsSync, readFileSync, writeFileSync } from "fs"; import { AppManifest } from "../../types"; -import { BaseCommand } from "./base-command"; +import { BaseCommand } from "../../base-command"; import { $t, appUpdate } from "../../messages"; import { fetchApp, getApp, getOrg } from "../../util"; @@ -15,8 +15,6 @@ export default class Update extends BaseCommand { private manifestPathRetry: number = 0; private manifestData!: AppManifest & Record; - static hidden: boolean = false; - static description = "Update the existing app in developer hub"; static examples = [