Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
102861b
Merge pull request #301 from contentstack/staging
cs-raj Aug 12, 2024
a6bb2ea
Axios version Bump (#305)
sunil-lakshman Aug 23, 2024
57acca2
Merge branch 'staging' into stage-to-dev
cs-raj Aug 26, 2024
dbcfd99
Merge pull request #309 from contentstack/stage-to-dev
cs-raj Aug 26, 2024
d7432ff
fixed receiving eexit after encountering error
harshithad0703 Aug 26, 2024
e53afcd
updated readme
harshithad0703 Aug 26, 2024
d0bcbcc
replaced getDeveloperHubUrl with getter method
harshithad0703 Aug 28, 2024
ac72dee
Merge pull request #311 from contentstack/fix/dx-1157-error-eexit
harshithad0703 Aug 28, 2024
aa20b56
Merge branch 'development' into feat/dx-1170-replace-getDeveloperHubU…
harshithad0703 Aug 28, 2024
c8ac464
Merge pull request #312 from contentstack/feat/dx-1170-replace-getDev…
harshithad0703 Aug 28, 2024
c3c57dc
Merge pull request #313 from contentstack/main
cs-raj Sep 2, 2024
0e77ffd
Merge pull request #314 from contentstack/staging
cs-raj Sep 2, 2024
a48ff02
handled case when organization_uid is empty
harshithad0703 Sep 17, 2024
246c162
upgraded cli plugin packages
harshithad0703 Sep 17, 2024
a274c69
to set only the host name
harshithad0703 Sep 17, 2024
41c242a
version bump to 1.3.4
harshithad0703 Sep 17, 2024
e99cd39
handled case when organization_uid is empty in all commands
harshithad0703 Sep 17, 2024
e4c2160
updated developerHubUrl to handle host
harshithad0703 Sep 18, 2024
55556f9
updated the mehtod of handling when organization_uid is empty and whe…
harshithad0703 Sep 18, 2024
8bd0656
refactor: deploy org prompt logic & formatting
aman19K Sep 18, 2024
df28682
Merge pull request #316 from contentstack/fix/dx-1302-handle-org-uid-…
harshithad0703 Sep 18, 2024
4267369
Merge branch 'development' into dx-1120-merge-conflicts
harshithad0703 Sep 23, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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