From aba38f8b21c7fa87ba014158653c3432f8a64d90 Mon Sep 17 00:00:00 2001 From: Magzhan Abdibayev Date: Tue, 16 Apr 2024 17:36:43 +0200 Subject: [PATCH 1/3] [DV-5681] Remove analysis push and pull --- src/commands/analysis.command.ts | 18 ----- src/content-cli-pull.ts | 17 ---- src/content-cli-push.ts | 16 ---- .../factory/analysis-manager.factory.ts | 25 ------ src/content/manager/analysis.manager.ts | 81 ------------------- 5 files changed, 157 deletions(-) delete mode 100644 src/commands/analysis.command.ts delete mode 100644 src/content/factory/analysis-manager.factory.ts delete mode 100644 src/content/manager/analysis.manager.ts diff --git a/src/commands/analysis.command.ts b/src/commands/analysis.command.ts deleted file mode 100644 index 35529bc..0000000 --- a/src/commands/analysis.command.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { ContentService } from "../services/content.service"; -import { AnalysisManagerFactory } from "../content/factory/analysis-manager.factory"; - -export class AnalysisCommand { - private contentService = new ContentService(); - private analysisManagerFactory = new AnalysisManagerFactory(); - - public async pullAnalysis(profile: string, id: string, packageManager: boolean): Promise { - await this.contentService.pull( - profile, - this.analysisManagerFactory.createManager(id, null, null, packageManager) - ); - } - - public async pushAnalysis(profile: string, workspaceId: string, filename: string): Promise { - await this.contentService.push(profile, this.analysisManagerFactory.createManager(null, workspaceId, filename)); - } -} diff --git a/src/content-cli-pull.ts b/src/content-cli-pull.ts index 41a081e..366df61 100644 --- a/src/content-cli-pull.ts +++ b/src/content-cli-pull.ts @@ -1,4 +1,3 @@ -import { AnalysisCommand } from "./commands/analysis.command"; import { SkillCommand } from "./commands/skill.command"; import { DataPoolCommand } from "./commands/data-pool.command"; import { AssetCommand } from "./commands/asset.command"; @@ -9,21 +8,6 @@ import commander = require("commander"); type CommanderStatic = commander.CommanderStatic; class Pull { - public static analysis(program: CommanderStatic): CommanderStatic { - program - .command("analysis") - .description("Command to pull an analysis") - .option("-p, --profile ", "Profile which you want to use to pull the analysis") - .requiredOption("--id ", "Id of the analysis you want to pull") - .option("--asset", "Pull workflow as an asset") - .action(async cmd => { - await new AnalysisCommand().pullAnalysis(cmd.profile, cmd.id, !!cmd.asset); - process.exit(); - }); - - return program; - } - public static analysisBookmarks(program: CommanderStatic): CommanderStatic { program .command("bookmarks") @@ -100,7 +84,6 @@ class Pull { } } -Pull.analysis(commander); Pull.analysisBookmarks(commander); Pull.skill(commander); Pull.dataPool(commander); diff --git a/src/content-cli-push.ts b/src/content-cli-push.ts index 0f2690b..c8d22e7 100644 --- a/src/content-cli-push.ts +++ b/src/content-cli-push.ts @@ -2,7 +2,6 @@ import * as commander from "commander"; import * as fs from "fs"; import * as path from "path"; -import { AnalysisCommand } from "./commands/analysis.command"; import { SkillCommand } from "./commands/skill.command"; import { WidgetCommand } from "./commands/widget.command"; import { DataPoolCommand } from "./commands/data-pool.command"; @@ -16,20 +15,6 @@ import { GracefulError, logger } from "./util/logger"; type CommanderStatic = commander.CommanderStatic; class Push { - public static analysis(program: CommanderStatic): CommanderStatic { - program - .command("analysis") - .description("Command to push an analysis to a workspace") - .option("-p, --profile ", "Profile which you want to use to push the analysis") - .requiredOption("--workspaceId ", "Id of the workspace to which you want to push the analysis") - .requiredOption("-f, --file ", "The file you want to push") - .action(async cmd => { - await new AnalysisCommand().pushAnalysis(cmd.profile, cmd.workspaceId, cmd.file); - process.exit(); - }); - - return program; - } public static analysisBookmarks(program: CommanderStatic): CommanderStatic { program @@ -220,7 +205,6 @@ class Push { } } -Push.analysis(commander); Push.analysisBookmarks(commander); Push.ctp(commander); Push.skill(commander); diff --git a/src/content/factory/analysis-manager.factory.ts b/src/content/factory/analysis-manager.factory.ts deleted file mode 100644 index 2a14f36..0000000 --- a/src/content/factory/analysis-manager.factory.ts +++ /dev/null @@ -1,25 +0,0 @@ -import * as fs from "fs"; -import * as path from "path"; -import { FatalError, logger } from "../../util/logger"; -import { AnalysisManager } from "../manager/analysis.manager"; - -export class AnalysisManagerFactory { - public createManager(id: string, processId: string, filename: string, packageManager?: boolean): AnalysisManager { - const analysisManager = new AnalysisManager(); - analysisManager.id = id; - analysisManager.processId = processId; - if (filename !== null) { - analysisManager.fileName = this.resolvePackageFilePath(filename); - } - analysisManager.packageManager = packageManager; - - return analysisManager; - } - - private resolvePackageFilePath(fileName: string): string { - if (!fs.existsSync(path.resolve(process.cwd(), fileName))) { - logger.error(new FatalError("The provided file does not exist")); - } - return path.resolve(process.cwd(), fileName); - } -} diff --git a/src/content/manager/analysis.manager.ts b/src/content/manager/analysis.manager.ts deleted file mode 100644 index 3869415..0000000 --- a/src/content/manager/analysis.manager.ts +++ /dev/null @@ -1,81 +0,0 @@ -import { BaseManager } from "./base.manager"; -import { ManagerConfig } from "../../interfaces/manager-config.interface"; -import { AssetManager } from "./asset.manager"; -import * as fs from "fs"; -import {stringify} from "../../util/yaml"; -import * as FormData from "form-data"; - -export class AnalysisManager extends BaseManager { - private static BASE_URL = "/process-mining/api/analysis/"; - private static PULL_URL = `${AnalysisManager.BASE_URL}/export?id=`; - private static ANALYSIS_FILE_PREFIX = "analysis_"; - - private _id: string; - private _processId: string; - private _fileName: string; - private _packageManager: boolean; - - public get fileName(): string { - return this._fileName; - } - - public set fileName(value: string) { - this._fileName = value; - } - - public get id(): string { - return this._id; - } - - public set id(value: string) { - this._id = value; - } - - public get processId(): string { - return this._processId; - } - - public set processId(value: string) { - this._processId = value; - } - - public get packageManager(): boolean { - return this._packageManager; - } - - public set packageManager(value: boolean) { - this._packageManager = value; - } - - public getConfig(): ManagerConfig { - const pullUrl = this.packageManager - ? `${AnalysisManager.BASE_URL}${this.id}/package/export` - : `${AnalysisManager.PULL_URL}${this.id}`; - return { - pushUrl: this.profile.team.replace( - /\/?$/, - `${AnalysisManager.BASE_URL}/import?processId=${this.processId}` - ), - pullUrl: this.profile.team.replace(/\/?$/, pullUrl), - exportFileName: `${ - this.packageManager ? AssetManager.ASSET_FILE_PREFIX : AnalysisManager.ANALYSIS_FILE_PREFIX - }${this.id}${this.packageManager ? ".yaml" : ".json"}`, - onPushSuccessMessage: (data: any): string => { - return "Analysis was pushed successfully. New ID: " + data.id; - }, - }; - } - - public getBody(): any { - const formData = new FormData(); - formData.append("file", fs.createReadStream(this.fileName)); - return formData; - } - - protected getSerializedFileContent(data: any): string { - if (this.packageManager) { - return stringify(data); - } - return JSON.stringify(data); - } -} From 4e1e0c8c8d2628eab799b7c7b5f0e0921e71cce2 Mon Sep 17 00:00:00 2001 From: Khushal Gupta Date: Fri, 17 Jan 2025 11:39:24 +0100 Subject: [PATCH 2/3] chore: bump version in package.json. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 716595e..8d47754 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@celonis/content-cli", - "version": "0.11.1", + "version": "0.12.0", "description": "CLI Tool to help manage content in Celonis EMS", "main": "content-cli.js", "bin": { From c3ddd0e8669316650b16e80ea2e3cca979a14ebf Mon Sep 17 00:00:00 2001 From: Khushal Gupta Date: Mon, 20 Jan 2025 14:50:33 +0100 Subject: [PATCH 3/3] fix: update DOCUMENTATION.md. --- DOCUMENTATION.md | 23 ----------------------- 1 file changed, 23 deletions(-) diff --git a/DOCUMENTATION.md b/DOCUMENTATION.md index 114dce4..c784d41 100644 --- a/DOCUMENTATION.md +++ b/DOCUMENTATION.md @@ -420,29 +420,6 @@ only the potential assignment values for connections with the appName 'Celonis' content-cli list assignments -p --variableType CONNECTION --params appName=Celonis ``` -### Asset options for Analysis - -For migration use cases, when pulling analysis from Process Analytics -you can use the --asset option to pull the content in a generic format -that Studio accepts. As an example command for pulling an analysis with -the  --asset option would be:  - -``` -// Pull analysis as an asset -content-cli pull analysis -p my-profile-name --id 73d39112-73ae-4bbe-8051-3c0f14e065ec --asset -``` - -After you have pulled your workflows/analysis with the --asset option, -it's time to push them inside Studio. You can do accomplish this using -the same command as with pushing other assets to Studio: - -``` -// Push analysis to Studio -content-cli push asset -p my-profile-name -f asset_73d39112-73ae-4bbe-8051-3c0f14e065ec.yaml --package my-package-key -``` - -| Note: Pushing analysis from Process Analytics to Studio will only work if you have used the ***--asset*** option when pulling. | - ### Pull and Push Analysis Bookmarks in Studio Enable users to pull and push bookmarks using content-cli. For pulling analysis bookmarks