diff --git a/README.md b/README.md index 3569fae..72d3f78 100644 --- a/README.md +++ b/README.md @@ -69,7 +69,7 @@ EXAMPLES $ csdx app:update ``` -_See code: [src/commands/app/index.ts](https://github.com/contentstack/apps-cli/blob/v1.3.3/src/commands/app/index.ts)_ +_See code: [src/commands/app/index.ts](https://github.com/contentstack/apps-cli/blob/v1.3.4/src/commands/app/index.ts)_ ## `csdx app:create` @@ -109,7 +109,7 @@ EXAMPLES $ csdx app:create --name App-4 --app-type organization --org --boilerplate ``` -_See code: [src/commands/app/create.ts](https://github.com/contentstack/apps-cli/blob/v1.3.3/src/commands/app/create.ts)_ +_See code: [src/commands/app/create.ts](https://github.com/contentstack/apps-cli/blob/v1.3.4/src/commands/app/create.ts)_ ## `csdx app:delete` @@ -134,7 +134,7 @@ EXAMPLES $ csdx app:delete --app-uid --org -d ./boilerplate ``` -_See code: [src/commands/app/delete.ts](https://github.com/contentstack/apps-cli/blob/v1.3.3/src/commands/app/delete.ts)_ +_See code: [src/commands/app/delete.ts](https://github.com/contentstack/apps-cli/blob/v1.3.4/src/commands/app/delete.ts)_ ## `csdx app:deploy` @@ -172,7 +172,7 @@ EXAMPLES $ csdx app:deploy --org --app-uid --hosting-type --launch-project --config ``` -_See code: [src/commands/app/deploy.ts](https://github.com/contentstack/apps-cli/blob/v1.3.3/src/commands/app/deploy.ts)_ +_See code: [src/commands/app/deploy.ts](https://github.com/contentstack/apps-cli/blob/v1.3.4/src/commands/app/deploy.ts)_ ## `csdx app:get` @@ -202,7 +202,7 @@ EXAMPLES $ csdx app:get --org --app-uid --app-type organization ``` -_See code: [src/commands/app/get.ts](https://github.com/contentstack/apps-cli/blob/v1.3.3/src/commands/app/get.ts)_ +_See code: [src/commands/app/get.ts](https://github.com/contentstack/apps-cli/blob/v1.3.4/src/commands/app/get.ts)_ ## `csdx app:install` @@ -228,7 +228,7 @@ EXAMPLES $ csdx app:install --org --app-uid --stack-api-key ``` -_See code: [src/commands/app/install.ts](https://github.com/contentstack/apps-cli/blob/v1.3.3/src/commands/app/install.ts)_ +_See code: [src/commands/app/install.ts](https://github.com/contentstack/apps-cli/blob/v1.3.4/src/commands/app/install.ts)_ ## `csdx app:reinstall` @@ -254,7 +254,7 @@ EXAMPLES $ csdx app:reinstall --org --app-uid --stack-api-key ``` -_See code: [src/commands/app/reinstall.ts](https://github.com/contentstack/apps-cli/blob/v1.3.3/src/commands/app/reinstall.ts)_ +_See code: [src/commands/app/reinstall.ts](https://github.com/contentstack/apps-cli/blob/v1.3.4/src/commands/app/reinstall.ts)_ ## `csdx app:uninstall` @@ -281,7 +281,7 @@ EXAMPLES $ csdx app:uninstall --org --app-uid --installation-uid ``` -_See code: [src/commands/app/uninstall.ts](https://github.com/contentstack/apps-cli/blob/v1.3.3/src/commands/app/uninstall.ts)_ +_See code: [src/commands/app/uninstall.ts](https://github.com/contentstack/apps-cli/blob/v1.3.4/src/commands/app/uninstall.ts)_ ## `csdx app:update` @@ -304,5 +304,5 @@ EXAMPLES $ csdx app:update --app-manifest ./boilerplate/manifest.json ``` -_See code: [src/commands/app/update.ts](https://github.com/contentstack/apps-cli/blob/v1.3.3/src/commands/app/update.ts)_ +_See code: [src/commands/app/update.ts](https://github.com/contentstack/apps-cli/blob/v1.3.4/src/commands/app/update.ts)_ diff --git a/package-lock.json b/package-lock.json index 52629c8..b4b0f76 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,18 +1,18 @@ { "name": "@contentstack/apps-cli", - "version": "1.3.3", + "version": "1.3.4", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@contentstack/apps-cli", - "version": "1.3.3", + "version": "1.3.4", "license": "MIT", "dependencies": { "@apollo/client": "^3.7.9", - "@contentstack/cli-command": "~1.2.19", - "@contentstack/cli-launch": "~1.2.0", - "@contentstack/cli-utilities": "~1.7.0", + "@contentstack/cli-command": "~1.3.0", + "@contentstack/cli-launch": "~1.2.1", + "@contentstack/cli-utilities": "~1.7.2", "adm-zip": "^0.5.15", "chai-as-promised": "^8.0.0", "chalk": "^4.1.2", @@ -503,11 +503,11 @@ } }, "node_modules/@contentstack/cli-command": { - "version": "1.2.19", - "resolved": "https://registry.npmjs.org/@contentstack/cli-command/-/cli-command-1.2.19.tgz", - "integrity": "sha512-/n1xmcYTkDxqAhc4gjPgVJxc6WpBQohG23IyminwP1ZG2JLTin1/0tWGaZl1LO9cCQlAbpgVLjOIwF39qXHL9g==", + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/@contentstack/cli-command/-/cli-command-1.3.0.tgz", + "integrity": "sha512-fyliMVwXZrow1VtfOknSMNuEqfYtG3K3JIWPSG/LT02Xa56LNCKnPrNO4Ap7noqypuDzvTkPbn0Znn54Jpbkjg==", "dependencies": { - "@contentstack/cli-utilities": "~1.7.0", + "@contentstack/cli-utilities": "~1.7.1", "contentstack": "^3.10.1" }, "engines": { @@ -515,12 +515,12 @@ } }, "node_modules/@contentstack/cli-launch": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/@contentstack/cli-launch/-/cli-launch-1.2.0.tgz", - "integrity": "sha512-KnAtRTyW1Em4u9mb3/sT5lq6cXUHVka+kpoyi7oHv4avi8u3Xw/qErV/oE6vIBnVvDTtQ6P7Crg4yix17zE8LA==", + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/@contentstack/cli-launch/-/cli-launch-1.2.1.tgz", + "integrity": "sha512-LizS9UHPM9YS+zwejNGwXfOxg0j0oOoc1kIi18DCqcoL/QeuFN3kbKANc7IC37N5kikLCzhRyj818I+MhlxA7w==", "dependencies": { "@apollo/client": "^3.7.9", - "@contentstack/cli-command": "~1.2.19", + "@contentstack/cli-command": "~1.3.0", "@contentstack/cli-utilities": "~1.7.1", "@oclif/core": "^3.26.5", "@oclif/plugin-help": "^5", @@ -572,14 +572,14 @@ } }, "node_modules/@contentstack/cli-utilities": { - "version": "1.7.1", - "resolved": "https://registry.npmjs.org/@contentstack/cli-utilities/-/cli-utilities-1.7.1.tgz", - "integrity": "sha512-n/Rf7h6t7qZxmiH0/OC2i7X0hrmh/HKc7iP3oCoSJ9sPetUcYS1BZUEDI8UKrlEjlmMNPAUai+4bG0dxxG9sbg==", + "version": "1.7.2", + "resolved": "https://registry.npmjs.org/@contentstack/cli-utilities/-/cli-utilities-1.7.2.tgz", + "integrity": "sha512-EpTKSXtUDhae/S0R4ltgwMsQ7k/f3kx+MrvdddtYH/1BNgn/juK/vlDG7FLAIgcO8/miyiPzrFnI5hpHxgfvIA==", "dependencies": { "@contentstack/management": "~1.17.0", "@contentstack/marketplace-sdk": "^1.2.1", "@oclif/core": "^3.26.5", - "axios": "^1.6.4", + "axios": "^1.7.4", "chalk": "^4.0.0", "cli-cursor": "^3.1.0", "cli-table": "^0.3.11", diff --git a/package.json b/package.json index 846357c..ec9f73e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@contentstack/apps-cli", - "version": "1.3.3", + "version": "1.3.4", "description": "App ClI", "author": "Contentstack CLI", "homepage": "https://github.com/contentstack/contentstack-apps-cli", @@ -21,9 +21,9 @@ ], "dependencies": { "@apollo/client": "^3.7.9", - "@contentstack/cli-command": "~1.2.19", - "@contentstack/cli-launch": "~1.2.0", - "@contentstack/cli-utilities": "~1.7.0", + "@contentstack/cli-command": "^1.3.0", + "@contentstack/cli-launch": "^1.2.1", + "@contentstack/cli-utilities": "^1.7.2", "adm-zip": "^0.5.15", "chai-as-promised": "^8.0.0", "chalk": "^4.1.2", diff --git a/src/base-command.ts b/src/base-command.ts index 4bc5fb6..9fe6b4a 100644 --- a/src/base-command.ts +++ b/src/base-command.ts @@ -78,8 +78,12 @@ export abstract class BaseCommand extends Command { this.validateRegionAndAuth(); - this.developerHubBaseUrl = - this.sharedConfig.developerHubBaseUrl || getDeveloperHubUrl(); + this.developerHubBaseUrl = this.sharedConfig.developerHubBaseUrl; + if (this.developerHubUrl?.startsWith("https")) { + this.developerHubBaseUrl = this.developerHubUrl?.split("//")[1]; + } + if (!this.developerHubBaseUrl) + this.developerHubBaseUrl = getDeveloperHubUrl(); await this.initCmaSDK(); await this.initMarketplaceSDK(); } diff --git a/src/commands/app/create.ts b/src/commands/app/create.ts index e361915..9d0348c 100644 --- a/src/commands/app/create.ts +++ b/src/commands/app/create.ts @@ -108,7 +108,7 @@ export default class Create extends BaseCommand { ) { await this.boilerplateFlow(); } else { - if(this.sharedConfig.folderPath === undefined) { + if (this.sharedConfig.folderPath === undefined) { const dataDir = this.flags["data-dir"] ?? process.cwd(); let targetPath = resolve(dataDir, this.sharedConfig.defaultAppName); if (existsSync(targetPath)) { @@ -242,7 +242,10 @@ export default class Create extends BaseCommand { // Get the directory inside the zip file const zipEntries = zip.getEntries(); const firstEntry = zipEntries[0]; - const sourcePath = resolve(sanitizePath(dataDir), sanitizePath(firstEntry.entryName.split("/")[0])); + const sourcePath = resolve( + sanitizePath(dataDir), + sanitizePath(firstEntry.entryName.split("/")[0]) + ); if (this.flags["data-dir"] && !existsSync(this.flags["data-dir"])) { mkdirSync(this.flags["data-dir"], { recursive: true }); diff --git a/src/commands/app/delete.ts b/src/commands/app/delete.ts index 9cc2b01..0c6f0c1 100644 --- a/src/commands/app/delete.ts +++ b/src/commands/app/delete.ts @@ -23,12 +23,13 @@ export default class Delete extends AppCLIBaseCommand { async run(): Promise { try { let app; - this.sharedConfig.org = - this.manifestData?.organization_uid ?? - (await getOrg(this.flags, { + this.sharedConfig.org = this.manifestData?.organization_uid; + if (!this.sharedConfig.org) { + this.sharedConfig.org = await getOrg(this.flags, { managementSdk: this.managementSdk, log: this.log, - })); + }); + } this.flags["app-uid"] = this.manifestData?.uid ?? this.flags["app-uid"]; if (!this.flags["app-uid"]) { diff --git a/src/commands/app/deploy.ts b/src/commands/app/deploy.ts index 7b7e785..115ff43 100644 --- a/src/commands/app/deploy.ts +++ b/src/commands/app/deploy.ts @@ -135,13 +135,15 @@ export default class Deploy extends AppCLIBaseCommand { * @returns A Promise that resolves to the organization UID. */ async getOrganization(): Promise { - return ( - this.manifestData?.organization_uid ?? - (await getOrg(this.flags, { + const organizationUid = this.manifestData?.organization_uid ?? ""; + if (!organizationUid) { + return await getOrg(this.flags, { managementSdk: this.managementSdk, log: this.log, - })) - ); + }); + } + + return organizationUid; } /** diff --git a/src/commands/app/get.ts b/src/commands/app/get.ts index ccabb67..7aaa297 100644 --- a/src/commands/app/get.ts +++ b/src/commands/app/get.ts @@ -35,12 +35,13 @@ export default class Get extends AppCLIBaseCommand { let appData; this.flags["app-uid"] = this.manifestData?.uid ?? this.flags["app-uid"]; - this.sharedConfig.org = - this.manifestData?.organization_uid ?? - (await getOrg(this.flags, { + this.sharedConfig.org = this.manifestData?.organization_uid; + if (!this.sharedConfig.org) { + this.sharedConfig.org = await getOrg(this.flags, { managementSdk: this.managementSdk, log: this.log, - })); + }); + } if (!this.flags["app-uid"]) { appData = await getApp(this.flags, this.sharedConfig.org, { diff --git a/src/commands/app/install.ts b/src/commands/app/install.ts index ae2d4fc..ec6916d 100644 --- a/src/commands/app/install.ts +++ b/src/commands/app/install.ts @@ -1,6 +1,6 @@ import { cliux, flags, FlagInput } from "@contentstack/cli-utilities"; -import {AppCLIBaseCommand} from "../../app-cli-base-command"; +import { AppCLIBaseCommand } from "../../app-cli-base-command"; import { $t, commonMsg, installAppMsg } from "../../messages"; import { getOrg, @@ -46,12 +46,13 @@ export default class Install extends AppCLIBaseCommand { } // get organization to be used - this.sharedConfig.org = - this.manifestData?.organization_uid ?? - (await getOrg(this.flags, { + this.sharedConfig.org = this.manifestData?.organization_uid; + if (!this.sharedConfig.org) { + this.sharedConfig.org = await getOrg(this.flags, { managementSdk: this.managementSdk, log: this.log, - })); + }); + } // fetch app details if (!this.flags["app-uid"]) { @@ -128,8 +129,9 @@ export default class Install extends AppCLIBaseCommand { error?.status === 400 ) { this.displayReInstallMsg(); + } else { + this.exit(1); } - this.exit(1); } } diff --git a/src/commands/app/reinstall.ts b/src/commands/app/reinstall.ts index f75d812..225e3ed 100644 --- a/src/commands/app/reinstall.ts +++ b/src/commands/app/reinstall.ts @@ -42,12 +42,13 @@ export default class Reinstall extends AppCLIBaseCommand { }); } - this.sharedConfig.org = - this.manifestData?.organization_uid ?? - (await getOrg(this.flags, { + this.sharedConfig.org = this.manifestData?.organization_uid; + if (!this.sharedConfig.org) { + this.sharedConfig.org = await getOrg(this.flags, { managementSdk: this.managementSdk, log: this.log, - })); + }); + } if (!this.flags["app-uid"]) { app = await getApp(this.flags, this.sharedConfig.org, { @@ -117,8 +118,12 @@ export default class Reinstall extends AppCLIBaseCommand { this.displayStackUrl(); } catch (error: any) { - this.log(error?.errorMessage || error?.message || error, "error"); - this.exit(1); + if (error?.errorMessage !== "You are already using the latest version.") { + this.log(error?.errorMessage || error?.message || error, "error"); + this.exit(1); + } else { + this.log(error?.errorMessage || error?.message || error, "error"); + } } } diff --git a/src/commands/app/uninstall.ts b/src/commands/app/uninstall.ts index 80972fb..15f30e7 100644 --- a/src/commands/app/uninstall.ts +++ b/src/commands/app/uninstall.ts @@ -33,7 +33,13 @@ export default class Uninstall extends AppCLIBaseCommand { this.flags["app-uid"] = this.manifestData?.uid ?? this.flags["app-uid"]; // get organization to be used - this.sharedConfig.org = this.manifestData?.organization_uid ?? (await getOrg(this.flags, {managementSdk: this.managementSdk, log: this.log})); + this.sharedConfig.org = this.manifestData?.organization_uid; + if (!this.sharedConfig.org) { + this.sharedConfig.org = await getOrg(this.flags, { + managementSdk: this.managementSdk, + log: this.log, + }); + } // fetch app details if (!this.flags['app-uid']) {