Skip to content

Commit

Permalink
Merge branch 'development' into dx-1120-merge-conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
harshithad0703 committed Sep 23, 2024
2 parents b237191 + df28682 commit 4267369
Show file tree
Hide file tree
Showing 11 changed files with 84 additions and 60 deletions.
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`

Expand Down Expand Up @@ -109,7 +109,7 @@ EXAMPLES
$ csdx app:create --name App-4 --app-type organization --org <UID> --boilerplate <Ecommerce App 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`

Expand All @@ -134,7 +134,7 @@ EXAMPLES
$ csdx app:delete --app-uid <value> --org <value> -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`

Expand Down Expand Up @@ -172,7 +172,7 @@ EXAMPLES
$ csdx app:deploy --org <UID> --app-uid <APP-UID-1> --hosting-type <Hosting with Launch> --launch-project <new> --config <config-path>
```

_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`

Expand Down Expand Up @@ -202,7 +202,7 @@ EXAMPLES
$ csdx app:get --org <value> --app-uid <value> --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`

Expand All @@ -228,7 +228,7 @@ EXAMPLES
$ csdx app:install --org <UID> --app-uid <APP-UID-1> --stack-api-key <STACK-API-KEY-1>
```

_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`

Expand All @@ -254,7 +254,7 @@ EXAMPLES
$ csdx app:reinstall --org <UID> --app-uid <APP-UID-1> --stack-api-key <STACK-API-KEY-1>
```

_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`

Expand All @@ -281,7 +281,7 @@ EXAMPLES
$ csdx app:uninstall --org <UID> --app-uid <APP-UID-1> --installation-uid <INSTALLATION-UID-1>
```

_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`

Expand All @@ -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)_
<!-- commandsstop -->
34 changes: 17 additions & 17 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -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",
Expand Down
8 changes: 6 additions & 2 deletions src/base-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,12 @@ export abstract class BaseCommand<T extends typeof Command> 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();
}
Expand Down
7 changes: 5 additions & 2 deletions src/commands/app/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export default class Create extends BaseCommand<typeof Create> {
) {
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)) {
Expand Down Expand Up @@ -242,7 +242,10 @@ export default class Create extends BaseCommand<typeof Create> {
// 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 });
Expand Down
9 changes: 5 additions & 4 deletions src/commands/app/delete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,13 @@ export default class Delete extends AppCLIBaseCommand {
async run(): Promise<void> {
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"]) {
Expand Down
12 changes: 7 additions & 5 deletions src/commands/app/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,15 @@ export default class Deploy extends AppCLIBaseCommand {
* @returns A Promise that resolves to the organization UID.
*/
async getOrganization(): Promise<string> {
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;
}

/**
Expand Down
9 changes: 5 additions & 4 deletions src/commands/app/get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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, {
Expand Down
14 changes: 8 additions & 6 deletions src/commands/app/install.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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"]) {
Expand Down Expand Up @@ -128,8 +129,9 @@ export default class Install extends AppCLIBaseCommand {
error?.status === 400
) {
this.displayReInstallMsg();
} else {
this.exit(1);
}
this.exit(1);
}
}

Expand Down
17 changes: 11 additions & 6 deletions src/commands/app/reinstall.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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, {
Expand Down Expand Up @@ -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");
}
}
}

Expand Down
8 changes: 7 additions & 1 deletion src/commands/app/uninstall.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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']) {
Expand Down

0 comments on commit 4267369

Please sign in to comment.