Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DX | 08-08-2024 | Release #297

Merged
merged 21 commits into from
Aug 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
515bb4a
updated reinstall and deploy with marketplace calls
harshithad0703 Jul 26, 2024
bf6314d
Merge pull request #282 from contentstack/fix/dx-668-replace-reinstal…
harshithad0703 Jul 29, 2024
80f1e2d
Merge branch 'staging' into fix/dx-683-fix-breaking-test-cases
harshithad0703 Jul 29, 2024
263ceb2
updated create test cases
harshithad0703 Jul 30, 2024
9b1acd2
Merge pull request #285 from contentstack/staging
harshithad0703 Jul 31, 2024
cab02f5
Merge pull request #288 from contentstack/staging
cs-raj Jul 31, 2024
517fb70
fix: handle undefined issue & org flag missing in help command
aman19K Aug 1, 2024
107d6b1
Merge pull request #289 from contentstack/fix/DX-1031
aman19K Aug 1, 2024
115b1b8
Merge branch 'development' into fix/dx-683-fix-breaking-test-cases
harshithad0703 Aug 2, 2024
3740eea
fix inquirer test cases
harshithad0703 Aug 2, 2024
1f838fa
updated create test cases
harshithad0703 Aug 2, 2024
509e1b2
update and reinstall test cases update
harshithad0703 Aug 5, 2024
3968bc6
fix: uninstall, update & reinstall test cases
aman19K Aug 5, 2024
b885a3e
version bump to 1.3.2
harshithad0703 Aug 6, 2024
615f847
revert: version bump to 1.3.2
harshithad0703 Aug 6, 2024
2e2c163
version bump to 1.3.2
harshithad0703 Aug 6, 2024
a4fb983
Merge pull request #293 from contentstack/fix/dx-683-fix-breaking-tes…
harshithad0703 Aug 6, 2024
8872060
Merge pull request #294 from contentstack/main
cs-raj Aug 6, 2024
debd437
Merge branch 'staging' into stage-to-dev
cs-raj Aug 6, 2024
845d2d7
Merge pull request #295 from contentstack/stage-to-dev
cs-raj Aug 6, 2024
3e81b2a
Merge pull request #296 from contentstack/development
cs-raj Aug 6, 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
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ $ npm install -g @contentstack/apps-cli
$ csdx COMMAND
running command...
$ csdx (--version|-v)
@contentstack/apps-cli/1.3.1 darwin-arm64 node-v18.20.2
@contentstack/apps-cli/1.3.2 darwin-arm64 node-v18.20.2
$ csdx --help [COMMAND]
USAGE
$ csdx COMMAND
Expand Down 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.1/src/commands/app/index.ts)_
_See code: [src/commands/app/index.ts](https://github.com/contentstack/apps-cli/blob/v1.3.2/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.1/src/commands/app/create.ts)_
_See code: [src/commands/app/create.ts](https://github.com/contentstack/apps-cli/blob/v1.3.2/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.1/src/commands/app/delete.ts)_
_See code: [src/commands/app/delete.ts](https://github.com/contentstack/apps-cli/blob/v1.3.2/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.1/src/commands/app/deploy.ts)_
_See code: [src/commands/app/deploy.ts](https://github.com/contentstack/apps-cli/blob/v1.3.2/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.1/src/commands/app/get.ts)_
_See code: [src/commands/app/get.ts](https://github.com/contentstack/apps-cli/blob/v1.3.2/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.1/src/commands/app/install.ts)_
_See code: [src/commands/app/install.ts](https://github.com/contentstack/apps-cli/blob/v1.3.2/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.1/src/commands/app/reinstall.ts)_
_See code: [src/commands/app/reinstall.ts](https://github.com/contentstack/apps-cli/blob/v1.3.2/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.1/src/commands/app/uninstall.ts)_
_See code: [src/commands/app/uninstall.ts](https://github.com/contentstack/apps-cli/blob/v1.3.2/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.1/src/commands/app/update.ts)_
_See code: [src/commands/app/update.ts](https://github.com/contentstack/apps-cli/blob/v1.3.2/src/commands/app/update.ts)_
<!-- commandsstop -->
4 changes: 2 additions & 2 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@contentstack/apps-cli",
"version": "1.3.1",
"version": "1.3.2",
"description": "App ClI",
"author": "Contentstack CLI",
"homepage": "https://github.com/contentstack/contentstack-apps-cli",
Expand Down
9 changes: 9 additions & 0 deletions src/commands/app/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,15 @@ export default class Create extends BaseCommand<typeof Create> {
) {
await this.boilerplateFlow();
} else {
if(this.sharedConfig.folderPath === undefined) {
const dataDir = this.flags["data-dir"] ?? process.cwd();
let targetPath = resolve(dataDir, this.sharedConfig.defaultAppName);
if (existsSync(targetPath)) {
this.log(this.messages.DIR_EXIST, "warn");
targetPath = await getDirName(targetPath);
}
this.sharedConfig.folderPath = targetPath;
}
this.manageManifestToggeling();
await this.registerTheAppOnDeveloperHub(false);
}
Expand Down
21 changes: 12 additions & 9 deletions src/commands/app/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export default class Deploy extends AppCLIBaseCommand {
const apolloClient = await this.getApolloClient();
const projects = await getProjects(apolloClient);
await this.handleAppDisconnect(projects);

flags["hosting-type"] = flags["hosting-type"] || (await getHostingType());
const updateHostingPayload: UpdateHostingParams = {
provider: "external",
Expand All @@ -90,14 +90,18 @@ export default class Deploy extends AppCLIBaseCommand {
config["name"] = config["name"] || app?.name;
this.flags["launch-project"] =
this.flags["launch-project"] || (await askProjectType());
await this.handleHostingWithLaunch(config, updateHostingPayload, projects);
await this.handleHostingWithLaunch(
config,
updateHostingPayload,
projects
);
break;
default:
this.log("Please provide a valid Hosting Type.", "error");
return;
}

if(this.flags["app-uid"]){
if (this.flags["app-uid"]) {
await updateApp(
flags,
this.sharedConfig.org,
Expand Down Expand Up @@ -285,11 +289,10 @@ export default class Deploy extends AppCLIBaseCommand {
if (!this.flags["yes"]) {
throw new Error(deployAppMsg.APP_UPDATE_TERMINATION_MSG);
}
await disconnectApp(
this.flags,
this.sharedConfig.org,
this.developerHubBaseUrl
);
await disconnectApp(this.flags, this.sharedConfig.org, {
marketplaceSdk: this.marketplaceAppSdk,
log: this.log,
});
}
}
}
}
11 changes: 4 additions & 7 deletions src/commands/app/reinstall.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,9 @@ export default class Reinstall extends AppCLIBaseCommand {
}),
"info"
);
await reinstallApp({
flags: this.flags,
type: appType,
developerHubBaseUrl: this.developerHubBaseUrl,
orgUid: this.sharedConfig.org,
manifestUid: this.flags["app-uid"],
await reinstallApp(this.flags, this.sharedConfig.org, appType, {
marketplaceSdk: this.marketplaceAppSdk,
log: this.log,
});
this.log(
$t(reinstallAppMsg.APP_REINSTALLED_SUCCESSFULLY, {
Expand All @@ -121,7 +118,7 @@ export default class Reinstall extends AppCLIBaseCommand {
this.displayStackUrl();
} catch (error: any) {
this.log(error?.errorMessage || error?.message || error, "error");
process.exit(1);
this.exit(1);
}
}

Expand Down
63 changes: 22 additions & 41 deletions src/util/common-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
HttpClient,
} from "@contentstack/cli-utilities";
import { projectsQuery } from "../graphql/queries";
import { apiRequestHandler } from "./api-request-handler";
import {
AppLocation,
Extension,
Expand Down Expand Up @@ -166,34 +165,23 @@ function installApp(
});
}

async function reinstallApp(params: {
flags: FlagInput;
type: string;
developerHubBaseUrl: string;
orgUid: string;
manifestUid: string;
}): Promise<void> {
const { type, developerHubBaseUrl, flags, orgUid, manifestUid } = params;
const payload = {
target_type: type,
target_uid: (flags["stack-api-key"] as any) || orgUid,
};

const url = `https://${developerHubBaseUrl}/manifests/${manifestUid}/reinstall`;
try {
const result = await apiRequestHandler({
orgUid,
payload,
url,
method: "PUT",
function reinstallApp(
flags: FlagInput,
orgUid: string,
type: string,
options: MarketPlaceOptions
) {
const { marketplaceSdk } = options;
return marketplaceSdk
.marketplace(orgUid)
.app(flags["app-uid"] as any)
.reinstall({
targetUid: (flags["stack-api-key"] as any) || orgUid,
targetType: type as any,
});
return result;
} catch (err) {
throw err;
}
}

function fetchStack(flags: FlagInput, options: CommonOptions) {
function fetchStack(flags: FlagInput, options: CommonOptions): Promise<any> {
const { managementSdk } = options;
return managementSdk
.stack({ api_key: flags["stack-api-key"] as any })
Expand Down Expand Up @@ -363,21 +351,14 @@ function setupConfig(configPath: string) {
async function disconnectApp(
flags: FlagInput,
orgUid: string,
developerHubBaseUrl: string
) {
const appUid: any = flags["app-uid"];
const url = `https://${developerHubBaseUrl}/manifests/${appUid}/hosting/disconnect`;
try {
const result = await apiRequestHandler({
orgUid,
payload: { provider: "launch" },
url,
method: "PATCH",
});
return result;
} catch (err) {
throw err;
}
options: MarketPlaceOptions
): Promise<any> {
const { marketplaceSdk } = options;
return marketplaceSdk
.marketplace(orgUid)
.app(flags["app-uid"] as any)
.hosting()
.disconnect({ provider: "launch" });
}

function formatUrl(url: string): string {
Expand Down
Loading
Loading