Skip to content

Commit

Permalink
chore: refactor commands
Browse files Browse the repository at this point in the history
and move `metadata.jon` as a static variable
[EMA-4345]
  • Loading branch information
jetmirhalili11 committed Aug 23, 2024
1 parent 4a63c93 commit 179f174
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/content-cli-analyze.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class Analyze {
.command("action-flows")
.description("Analyze Action Flows dependencies for a certain package")
.option("-p, --profile <profile>", "Profile which you want to use to analyze Action Flows")
.requiredOption("-i, --packageId <packageId>", "ID of the package from which you want to export Action Flows")
.requiredOption("--packageId <packageId>", "ID of the package from which you want to export Action Flows")
.option("-o, --outputToJsonFile", "Output the analyze result in a JSON file")
.action(async cmd => {
await new ActionFlowCommand().analyzeActionFlows(cmd.packageId, cmd.outputToJsonFile);
Expand Down
2 changes: 1 addition & 1 deletion src/content-cli-export.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export class Export {
.command("action-flows")
.description("Command to export all Action Flows in a package with their objects and dependencies")
.option("-p, --profile <profile>", "Profile which you want to use to export Action Flows")
.requiredOption("-i, --packageId <packageId>", "ID of the package from which you want to export Action Flows")
.requiredOption("--packageId <packageId>", "ID of the package from which you want to export Action Flows")
.option("-f, --file <file>", "Action flows metadata file (relative path)")
.action(async cmd => {
await new ActionFlowCommand().exportActionFlows(cmd.packageId, cmd.file);
Expand Down
2 changes: 1 addition & 1 deletion src/content-cli-import.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export class Import {
.command("action-flows")
.description("Command to import all Action Flows in a package with their objects and dependencies")
.option("-p, --profile <profile>", "Profile which you want to use to import Action Flows")
.requiredOption("-i, --packageId <packageId>", "ID of the package to which you want to export Action Flows")
.requiredOption("--packageId <packageId>", "ID of the package to which you want to export Action Flows")
.requiredOption("-f, --file <file>", "Exported Action Flows file (relative path)")
.requiredOption("-d, --dryRun <dryRun>", "Execute the import on dry run mode")
.option("-o, --outputToJsonFile", "Output the import result in a JSON file")
Expand Down
4 changes: 3 additions & 1 deletion src/services/action-flow/action-flow-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import * as FormData from "form-data";
import * as fs from "fs";

class ActionFlowService {
private static readonly METADATA_FILE_NAME = "metadata.json";

public async exportActionFlows(packageId: string, metadataFilePath: string): Promise<void> {
const exportedActionFlowsData = await actionFlowApi.exportRawAssets(packageId);
const tmpZip: AdmZip = new AdmZip(exportedActionFlowsData);
Expand Down Expand Up @@ -65,7 +67,7 @@ class ActionFlowService {
fileName = fileName + (fileName.endsWith(".json") ? "" : ".json");
const metadata = fileService.readFile(fileName);

zip.addFile("metadata.json", Buffer.from(metadata));
zip.addFile(ActionFlowService.METADATA_FILE_NAME, Buffer.from(metadata));
}
}

Expand Down

0 comments on commit 179f174

Please sign in to comment.