From 2bd7f688ced9ab8e06212db32000915ebcb45aed Mon Sep 17 00:00:00 2001 From: Patrick Tamunjoh <38542007+patricktamunjoh@users.noreply.github.com> Date: Mon, 2 Nov 2026 11:55:28 +0100 Subject: [PATCH] chore: remove sdk download command --- docs/command-graph.html | 5 +-- docs/user-guide/sdk-commands.md | 16 ------- src/commands/sdk/module.ts | 11 ----- src/commands/sdk/sdk-api.ts | 9 ---- src/commands/sdk/sdk.service.ts | 15 ------- tests/commands/sdk/module.spec.ts | 24 +++------- tests/commands/sdk/sdk-download.spec.ts | 60 ------------------------- 7 files changed, 7 insertions(+), 133 deletions(-) delete mode 100644 tests/commands/sdk/sdk-download.spec.ts diff --git a/docs/command-graph.html b/docs/command-graph.html index 24dd3b6b..77bb30bb 100644 --- a/docs/command-graph.html +++ b/docs/command-graph.html @@ -438,9 +438,6 @@ options: ["-p, --profile ", "--deployableType ", "--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 ", "--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 ", "--appId ", "--dist ", "-h, --help"] }, @@ -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"], diff --git a/docs/user-guide/sdk-commands.md b/docs/user-guide/sdk-commands.md index 6396e50a..f3b5e677 100644 --- a/docs/user-guide/sdk-commands.md +++ b/docs/user-guide/sdk-commands.md @@ -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 -``` - -The SDK is stored as an npm package tarball at `./.celonis-sdk/.tgz` and can be installed with: - -``` -npm install ./.celonis-sdk/.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. diff --git a/src/commands/sdk/module.ts b/src/commands/sdk/module.ts index 67094dae..ba4704c8 100644 --- a/src/commands/sdk/module.ts +++ b/src/commands/sdk/module.ts @@ -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 ", "Identifier of the app to download the SDK for") - .action(this.downloadSdk); - sdkCommand .command("publish") .beta() @@ -43,10 +36,6 @@ class Module extends IModule { .action(this.printToken); } - private async downloadSdk(context: Context, command: Command, options: OptionValues): Promise { - await new SdkService(context).downloadSdk(options.appId); - } - private async publishApp(context: Context, command: Command, options: OptionValues): Promise { await new SdkService(context).publishApp(options.appId, options.dist); } diff --git a/src/commands/sdk/sdk-api.ts b/src/commands/sdk/sdk-api.ts index 77abcd2d..ce4a52a4 100644 --- a/src/commands/sdk/sdk-api.ts +++ b/src/commands/sdk/sdk-api.ts @@ -13,15 +13,6 @@ export class SdkApi { this.httpClient = () => context.httpClient; } - public async downloadSdk(appId: string): Promise { - 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 { return this.httpClient() .postBinary(`/pro-code-app-manager/api/codespace/apps/${appId}/publish`, bundle, "application/zip") diff --git a/src/commands/sdk/sdk.service.ts b/src/commands/sdk/sdk.service.ts index dbe9e653..a7a380dc 100644 --- a/src/commands/sdk/sdk.service.ts +++ b/src/commands/sdk/sdk.service.ts @@ -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; @@ -18,19 +16,6 @@ export class SdkService { this.sdkApi = new SdkApi(context); } - public async downloadSdk(appId: string): Promise { - 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 { const distDirectory = path.resolve(process.cwd(), dist); this.requireDirectory(distDirectory); diff --git a/tests/commands/sdk/module.spec.ts b/tests/commands/sdk/module.spec.ts index 84c80250..dae40a94 100644 --- a/tests/commands/sdk/module.spec.ts +++ b/tests/commands/sdk/module.spec.ts @@ -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 ", expect.any(String)); - expect(mockConfigurator.beta).toHaveBeenCalledTimes(5); + expect(mockConfigurator.beta).toHaveBeenCalledTimes(4); }); it("registers the sdk publish command", () => { @@ -25,26 +23,16 @@ describe("SDK Module", () => { new Module().register(testContext, mockConfigurator); expect(mockConfigurator.command).toHaveBeenCalledWith("publish"); + expect(mockConfigurator.requiredOption).toHaveBeenCalledWith("--appId ", expect.any(String)); expect(mockConfigurator.requiredOption).toHaveBeenCalledWith("--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"); @@ -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(); @@ -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(); diff --git a/tests/commands/sdk/sdk-download.spec.ts b/tests/commands/sdk/sdk-download.spec.ts deleted file mode 100644 index 60124169..00000000 --- a/tests/commands/sdk/sdk-download.spec.ts +++ /dev/null @@ -1,60 +0,0 @@ -import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs"; -import { join, resolve } from "node:path"; -import { Readable } from "stream"; -import { mockAxiosGet, mockedAxiosInstance } from "../../utls/http-requests-mock"; -import { SdkService } from "../../../src/commands/sdk/sdk.service"; -import { testContext } from "../../utls/test-context"; -import { loggingTestTransport } from "../../jest.setup"; -import { rmTempDir } from "../../utls/fs-utils"; - -describe("SDK download", () => { - const appId = "app-id"; - const sdkUrl = `https://myTeam.celonis.cloud/pro-code-app-manager/api/npm/@celonis-sdk/${appId}/-/${appId}-latest.tgz`; - const previousSdkFile = "previous-app-id.tgz"; - - let sdkDirectory: string; - - function mockFailedDownload(...body: string[]): void { - (mockedAxiosInstance.get as jest.Mock).mockResolvedValueOnce({ - status: 404, - data: Readable.from(body.map(chunk => Buffer.from(chunk))), - }); - } - - beforeEach(() => { - sdkDirectory = resolve(process.cwd(), ".celonis-sdk"); - mkdirSync(sdkDirectory, { recursive: true }); - writeFileSync(join(sdkDirectory, previousSdkFile), "previous-sdk"); - }); - - afterEach(() => { - rmTempDir(sdkDirectory); - }); - - it("Should replace the SDK directory with the downloaded SDK", async () => { - const sdk = Buffer.from("sdk-tarball"); - mockAxiosGet(sdkUrl, sdk); - - await new SdkService(testContext).downloadSdk(appId); - - expect(readFileSync(join(sdkDirectory, `${appId}.tgz`))).toEqual(sdk); - expect(existsSync(join(sdkDirectory, previousSdkFile))).toBe(false); - expect(loggingTestTransport.logMessages[0].message).toContain(`SDK downloaded successfully: ${join(".celonis-sdk", `${appId}.tgz`)}`); - }); - - it("Should keep the existing SDK when the download fails", async () => { - mockFailedDownload("Custom app 'app-id' not found"); - - await expect(new SdkService(testContext).downloadSdk(appId)) - .rejects.toThrow(`Problem downloading SDK for app ${appId}: Custom app 'app-id' not found`); - - expect(existsSync(join(sdkDirectory, previousSdkFile))).toBe(true); - }); - - it("Should omit the error details when the failed download has an empty response body", async () => { - mockFailedDownload(); - - await expect(new SdkService(testContext).downloadSdk(appId)) - .rejects.toThrow(new RegExp(`^Problem downloading SDK for app ${appId}$`)); - }); -});