Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 1 addition & 4 deletions docs/command-graph.html
Original file line number Diff line number Diff line change
Expand Up @@ -438,9 +438,6 @@
options: ["-p, --profile <profile>", "--deployableType <deployableType>", "--packageKey <packageKey>", "--json", "-h, --help"] },

// sdk
{ id: "sdk_download", label: "download (beta)", group: "command", path: "sdk download",
description: "Download the latest Celonis SDK generated for a Codespace asset.",
options: ["-p, --profile <profile>", "--appId <appId>", "-h, --help"] },
{ id: "sdk_publish", label: "publish (beta)", group: "command", path: "sdk publish",
description: "Publish a build of a custom app as a new version of its Codespace asset.",
options: ["-p, --profile <profile>", "--appId <appId>", "--dist <dist>", "-h, --help"] },
Expand Down Expand Up @@ -552,7 +549,7 @@
["deployment_list_area","deployment_list_history"],["deployment_list_area","deployment_list_active"],
["deployment_list_area","deployment_list_deployables"],["deployment_list_area","deployment_list_targets"],

["area_sdk","sdk_download"],["area_sdk","sdk_publish"],["area_sdk","sdk_preview"],["area_sdk","sdk_token"],
["area_sdk","sdk_publish"],["area_sdk","sdk_preview"],["area_sdk","sdk_token"],

["area_git","git_profile_area"],["git_profile_area","git_profile_list"],
["git_profile_area","git_profile_create"],["git_profile_area","git_profile_default"],
Expand Down
16 changes: 0 additions & 16 deletions docs/user-guide/sdk-commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,6 @@

The **sdk** command group provides the commands to implement custom apps for Codespace assets using the Celonis SDK.

## Download SDK

Download the latest Celonis SDK generated for a Codespace asset into the hidden `.celonis-sdk` directory of the working directory.

```
content-cli sdk download --appId <appId>
```

The SDK is stored as an npm package tarball at `./.celonis-sdk/<appId>.tgz` and can be installed with:

```
npm install ./.celonis-sdk/<appId>.tgz
```

Running the command again replaces the previously downloaded SDK with the latest version.

## Publish App

Publish a build of a custom app as a new version of its Codespace asset.
Expand Down
11 changes: 0 additions & 11 deletions src/commands/sdk/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,6 @@ class Module extends IModule {
.beta()
.description("Implement custom apps for Codespace assets using the Celonis SDK");

sdkCommand
.command("download")
.beta()
.description("Download the latest Celonis SDK generated for a Codespace asset")
.requiredOption("--appId <appId>", "Identifier of the app to download the SDK for")
.action(this.downloadSdk);

sdkCommand
.command("publish")
.beta()
Expand All @@ -43,10 +36,6 @@ class Module extends IModule {
.action(this.printToken);
}

private async downloadSdk(context: Context, command: Command, options: OptionValues): Promise<void> {
await new SdkService(context).downloadSdk(options.appId);
}

private async publishApp(context: Context, command: Command, options: OptionValues): Promise<void> {
await new SdkService(context).publishApp(options.appId, options.dist);
}
Expand Down
9 changes: 0 additions & 9 deletions src/commands/sdk/sdk-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,6 @@ export class SdkApi {
this.httpClient = () => context.httpClient;
}

public async downloadSdk(appId: string): Promise<Buffer> {
return this.httpClient()
.getFile(`/pro-code-app-manager/api/npm/@celonis-sdk/${appId}/-/${appId}-latest.tgz`)
.catch((e) => {
const problem = `Problem downloading SDK for app ${appId}`;
throw new FatalError(e ? `${problem}: ${e}` : problem);
});
}

public async publishApp(appId: string, bundle: Buffer): Promise<SdkPublishResponse> {
return this.httpClient()
.postBinary(`/pro-code-app-manager/api/codespace/apps/${appId}/publish`, bundle, "application/zip")
Expand Down
15 changes: 0 additions & 15 deletions src/commands/sdk/sdk.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ import { ProfileService } from "../../core/profile/profile.service";
import { Profile } from "../../core/profile/profile.interface";

export class SdkService {
public static readonly SDK_DIRECTORY = ".celonis-sdk";

private readonly context: Context;
private readonly sdkApi: SdkApi;

Expand All @@ -18,19 +16,6 @@ export class SdkService {
this.sdkApi = new SdkApi(context);
}

public async downloadSdk(appId: string): Promise<void> {
const sdk = await this.sdkApi.downloadSdk(appId);

const sdkDirectory = path.resolve(process.cwd(), SdkService.SDK_DIRECTORY);
fs.rmSync(sdkDirectory, { recursive: true, force: true });
fs.mkdirSync(sdkDirectory, { recursive: true });

const sdkFile = path.join(SdkService.SDK_DIRECTORY, `${appId}.tgz`);
fs.writeFileSync(path.resolve(process.cwd(), sdkFile), sdk);

logger.info(`SDK downloaded successfully: ${sdkFile}`);
}

public async publishApp(appId: string, dist: string): Promise<void> {
const distDirectory = path.resolve(process.cwd(), dist);
this.requireDirectory(distDirectory);
Expand Down
24 changes: 6 additions & 18 deletions tests/commands/sdk/module.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,13 @@ import { SdkService } from "../../../src/commands/sdk/sdk.service";

describe("SDK Module", () => {
describe("register", () => {
it("registers the sdk download command as beta", () => {
it("registers the sdk commands as beta", () => {
const mockConfigurator = createMockConfigurator();

new Module().register(testContext, mockConfigurator);

expect(mockConfigurator.command).toHaveBeenCalledWith("sdk");
expect(mockConfigurator.command).toHaveBeenCalledWith("download");
expect(mockConfigurator.requiredOption).toHaveBeenCalledWith("--appId <appId>", expect.any(String));
expect(mockConfigurator.beta).toHaveBeenCalledTimes(5);
expect(mockConfigurator.beta).toHaveBeenCalledTimes(4);
});

it("registers the sdk publish command", () => {
Expand All @@ -25,26 +23,16 @@ describe("SDK Module", () => {
new Module().register(testContext, mockConfigurator);

expect(mockConfigurator.command).toHaveBeenCalledWith("publish");
expect(mockConfigurator.requiredOption).toHaveBeenCalledWith("--appId <appId>", expect.any(String));
expect(mockConfigurator.requiredOption).toHaveBeenCalledWith("--dist <dist>", expect.any(String));
});

it("downloads the SDK of the given app when the download command runs", async () => {
const downloadSdk = jest.spyOn(SdkService.prototype, "downloadSdk").mockResolvedValue();
const mockConfigurator = createMockConfigurator();
new Module().register(testContext, mockConfigurator);

const downloadAction = mockConfigurator.action.mock.calls[0][0];
await downloadAction(testContext, new Command(), { appId: "app-id" });

expect(downloadSdk).toHaveBeenCalledWith("app-id");
});

it("publishes the given dist directory when the publish command runs", async () => {
const publishApp = jest.spyOn(SdkService.prototype, "publishApp").mockResolvedValue();
const mockConfigurator = createMockConfigurator();
new Module().register(testContext, mockConfigurator);

const publishAction = mockConfigurator.action.mock.calls[1][0];
const publishAction = mockConfigurator.action.mock.calls[0][0];
await publishAction(testContext, new Command(), { appId: "app-id", dist: "dist" });

expect(publishApp).toHaveBeenCalledWith("app-id", "dist");
Expand All @@ -71,7 +59,7 @@ describe("SDK Module", () => {
const sigintListeners = process.listenerCount("SIGINT");
const sigtermListeners = process.listenerCount("SIGTERM");

const previewAction = mockConfigurator.action.mock.calls[2][0];
const previewAction = mockConfigurator.action.mock.calls[1][0];
const running = previewAction(testContext, new Command(), { target: "http://localhost:5173", port: "5173", allowInlineScripts: true });
await new Promise(resolve => setImmediate(resolve));
expect(close).not.toHaveBeenCalled();
Expand All @@ -97,7 +85,7 @@ describe("SDK Module", () => {
const mockConfigurator = createMockConfigurator();
new Module().register(testContext, mockConfigurator);

const tokenAction = mockConfigurator.action.mock.calls[3][0];
const tokenAction = mockConfigurator.action.mock.calls[2][0];
await tokenAction(testContext, new Command(), {});

expect(printToken).toHaveBeenCalled();
Expand Down
60 changes: 0 additions & 60 deletions tests/commands/sdk/sdk-download.spec.ts

This file was deleted.

Loading