diff --git a/package.json b/package.json index 61dbfcd..607d138 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@celonis/content-cli", - "version": "0.9.0", + "version": "0.10.0", "description": "CLI Tool to help manage content in Celonis EMS", "main": "content-cli.js", "bin": { diff --git a/src/interfaces/batch-export-import-constants.ts b/src/interfaces/batch-export-import-constants.ts index 1407566..a0c815e 100644 --- a/src/interfaces/batch-export-import-constants.ts +++ b/src/interfaces/batch-export-import-constants.ts @@ -1,11 +1,11 @@ export enum BatchExportImportConstants { - STUDIO_FILE_NAME = "studio.yml", - VARIABLES_FILE_NAME = "variables.yml", - MANIFEST_FILE_NAME = "manifest.yml", + STUDIO_FILE_NAME = "studio.json", + VARIABLES_FILE_NAME = "variables.json", + MANIFEST_FILE_NAME = "manifest.json", STUDIO = "STUDIO", APP_MODE_VIEWER = "VIEWER", ZIP_EXTENSION = ".zip", - YAML_EXTENSION = ".yml", + JSON_EXTENSION = ".json", NODES_FOLDER_NAME = "nodes/", SCENARIO_NODE = "SCENARIO" } \ No newline at end of file diff --git a/src/interfaces/package-export-transport.ts b/src/interfaces/package-export-transport.ts index fb1ec7a..9f20c51 100644 --- a/src/interfaces/package-export-transport.ts +++ b/src/interfaces/package-export-transport.ts @@ -51,7 +51,7 @@ export interface NodeExportTransport { name: string; type: string; exportSerializationType: string; - configuration: string; + configuration: NodeConfiguration; schemaVersion: number; spaceId: string; @@ -60,8 +60,9 @@ export interface NodeExportTransport { serializedDocument?: Buffer; } -export interface NodeSerializedContent { - variables: VariableDefinition[] +export interface NodeConfiguration { + variables?: VariableDefinition[]; + [key: string]: any; } export interface StudioPackageManifest { diff --git a/src/services/package-manager/batch-import-export-service.ts b/src/services/package-manager/batch-import-export-service.ts index 6830c32..b304d8d 100644 --- a/src/services/package-manager/batch-import-export-service.ts +++ b/src/services/package-manager/batch-import-export-service.ts @@ -10,7 +10,7 @@ import { } from "../../interfaces/package-export-transport"; import {FileService, fileService} from "../file-service"; import {studioService} from "../studio/studio.service"; -import {parse, stringify} from "../../util/yaml" +import {parse, stringify} from "../../util/json" import * as FormData from "form-data"; import {BatchExportImportConstants} from "../../interfaces/batch-export-import-constants"; import {packageApi} from "../../api/package-api"; diff --git a/src/services/studio/studio.service.ts b/src/services/studio/studio.service.ts index 61a5458..83b659b 100644 --- a/src/services/studio/studio.service.ts +++ b/src/services/studio/studio.service.ts @@ -1,11 +1,11 @@ import { + NodeConfiguration, NodeExportTransport, - NodeSerializedContent, PackageExportTransport, PackageKeyAndVersionPair, StudioPackageManifest, VariableExportTransport, - VariableManifestTransport + VariableManifestTransport, } from "../../interfaces/package-export-transport"; import {packageApi} from "../../api/package-api"; @@ -17,7 +17,7 @@ import { } from "../../interfaces/package-manager.interfaces"; import {dataModelService} from "../package-manager/datamodel-service"; import {IZipEntry} from "adm-zip"; -import {parse, stringify} from "../../util/yaml"; +import {parse, stringify} from "../../util/json"; import {nodeApi} from "../../api/node-api"; import {variablesApi} from "../../api/variables-api"; import {spaceApi} from "../../api/space-api"; @@ -140,7 +140,7 @@ class StudioService { } private deleteScenarioAssets(packageZip: AdmZip): void { - packageZip.getEntries().filter(entry => entry.entryName.startsWith(BatchExportImportConstants.NODES_FOLDER_NAME) && entry.entryName.endsWith(BatchExportImportConstants.YAML_EXTENSION)) + packageZip.getEntries().filter(entry => entry.entryName.startsWith(BatchExportImportConstants.NODES_FOLDER_NAME) && entry.entryName.endsWith(BatchExportImportConstants.JSON_EXTENSION)) .forEach(entry => { const node: NodeExportTransport = parse(entry.getData().toString()); if (node.type === BatchExportImportConstants.SCENARIO_NODE) { @@ -157,10 +157,10 @@ class StudioService { return; } - const packageEntry = packageZip.getEntry("package.yml"); + const packageEntry = packageZip.getEntry("package.json"); const exportedNode: NodeExportTransport = parse(packageEntry.getData().toString()); - const nodeContent: NodeSerializedContent = parse(exportedNode.configuration); + const nodeContent: NodeConfiguration = exportedNode.configuration; nodeContent.variables = nodeContent.variables.map(variable => ({ ...variable, @@ -168,7 +168,6 @@ class StudioService { connectionVariablesByKey.get(variable.key).metadata : variable.metadata })); - exportedNode.configuration = stringify(nodeContent); packageZip.updateFile(packageEntry, Buffer.from(stringify(exportedNode))); } @@ -212,7 +211,7 @@ class StudioService { const packageZip = new AdmZip(file.getData()); packageZip.getEntries().forEach(nodeFile => { - if (nodeFile.entryName.endsWith(BatchExportImportConstants.YAML_EXTENSION)) { + if (nodeFile.entryName.endsWith(BatchExportImportConstants.JSON_EXTENSION)) { const updatedNodeFile = this.updateSpaceIdForNode(nodeFile.getData().toString(), spaceId); packageZip.updateFile(nodeFile, Buffer.from(updatedNodeFile)); } diff --git a/src/util/json.ts b/src/util/json.ts new file mode 100644 index 0000000..7f45a68 --- /dev/null +++ b/src/util/json.ts @@ -0,0 +1,15 @@ + +export function stringify(data: any): string { + return JSON.stringify(data, replacer, 2); +} + +export function parse(data: string): T { + return JSON.parse(data); +} + +const replacer = (key, value) => { + if (value instanceof Map) { + return Object.fromEntries(value); + } + return value; +}; diff --git a/tests/config/config-diff.spec.ts b/tests/config/config-diff.spec.ts index 3e9aec4..8504fe1 100644 --- a/tests/config/config-diff.spec.ts +++ b/tests/config/config-diff.spec.ts @@ -1,7 +1,6 @@ import {PackageManifestTransport} from "../../src/interfaces/package-export-transport"; import {ConfigUtils} from "../utls/config-utils"; import * as path from "path"; -import {stringify} from "../../src/util/yaml"; import {mockCreateReadStream, mockExistsSync, mockReadFileSync} from "../utls/fs-mock-utils"; import { PackageDiffMetadata, @@ -22,7 +21,7 @@ describe("Config diff", () => { const manifest: PackageManifestTransport[] = []; manifest.push(ConfigUtils.buildManifestForKeyAndFlavor("package-key", "STUDIO")); - const firstPackageNode = ConfigUtils.buildPackageNode("package-key", stringify({metadata: {description: "test"}, variables: [], dependencies: []})); + const firstPackageNode = ConfigUtils.buildPackageNode("package-key", {metadata: {description: "test"}, variables: [], dependencies: []}); const firstChildNode = ConfigUtils.buildChildNode("key-1", "package-key", "TEST"); const firstPackageZip = ConfigUtils.buildExportPackageZip(firstPackageNode, [firstChildNode], "1.0.0"); const exportedPackagesZip = ConfigUtils.buildBatchExportZip(manifest, [firstPackageZip]); @@ -49,7 +48,7 @@ describe("Config diff", () => { const manifest: PackageManifestTransport[] = []; manifest.push(ConfigUtils.buildManifestForKeyAndFlavor("package-key", "STUDIO")); - const firstPackageNode = ConfigUtils.buildPackageNode("package-key", stringify({metadata: {description: "test"}, variables: [], dependencies: []})); + const firstPackageNode = ConfigUtils.buildPackageNode("package-key", {metadata: {description: "test"}, variables: [], dependencies: []}); const firstChildNode = ConfigUtils.buildChildNode("key-1", "package-key", "TEST"); const firstPackageZip = ConfigUtils.buildExportPackageZip(firstPackageNode, [firstChildNode], "1.0.0"); const exportedPackagesZip = ConfigUtils.buildBatchExportZip(manifest, [firstPackageZip]); @@ -91,7 +90,7 @@ describe("Config diff", () => { const manifest: PackageManifestTransport[] = []; manifest.push(ConfigUtils.buildManifestForKeyAndFlavor("package-key", "STUDIO")); - const firstPackageNode = ConfigUtils.buildPackageNode("package-key", stringify({metadata: {description: "test"}, variables: [], dependencies: []})); + const firstPackageNode = ConfigUtils.buildPackageNode("package-key", {metadata: {description: "test"}, variables: [], dependencies: []}); const firstChildNode = ConfigUtils.buildChildNode("key-1", "package-key", "TEST"); const firstPackageZip = ConfigUtils.buildExportPackageZip(firstPackageNode, [firstChildNode], "1.0.0"); const exportedPackagesZip = ConfigUtils.buildBatchExportZip(manifest, [firstPackageZip]); @@ -137,7 +136,7 @@ describe("Config diff", () => { const manifest: PackageManifestTransport[] = []; manifest.push(ConfigUtils.buildManifestForKeyAndFlavor("package-key", "STUDIO")); - const firstPackageNode = ConfigUtils.buildPackageNode("package-key", stringify({metadata: {description: "test"}, variables: [], dependencies: []})); + const firstPackageNode = ConfigUtils.buildPackageNode("package-key", {metadata: {description: "test"}, variables: [], dependencies: []}); const firstChildNode = ConfigUtils.buildChildNode("key-1", "package-key", "TEST"); const firstPackageZip = ConfigUtils.buildExportPackageZip(firstPackageNode, [firstChildNode], "1.0.0"); const exportedPackagesZip = ConfigUtils.buildBatchExportZip(manifest, [firstPackageZip]); diff --git a/tests/config/config-export.spec.ts b/tests/config/config-export.spec.ts index 85612d5..a6d520a 100644 --- a/tests/config/config-export.spec.ts +++ b/tests/config/config-export.spec.ts @@ -1,9 +1,9 @@ import {ConfigUtils} from "../utls/config-utils"; import { - DependencyTransport, NodeExportTransport, NodeSerializedContent, + DependencyTransport, NodeConfiguration, NodeExportTransport, PackageManifestTransport, StudioPackageManifest, - VariableManifestTransport + VariableManifestTransport, } from "../../src/interfaces/package-export-transport"; import {mockAxiosGet, mockAxiosPost, mockedPostRequestBodyByUrl} from "../utls/http-requests-mock"; import {ConfigCommand} from "../../src/commands/config.command"; @@ -13,7 +13,7 @@ import {FileService} from "../../src/services/file-service"; import * as fs from "fs"; import AdmZip = require("adm-zip"); -import { parse, stringify } from "../../src/util/yaml"; +import { parse, stringify } from "../../src/util/json"; import { PackageManagerVariableType, VariableDefinition, @@ -109,7 +109,7 @@ describe("Config export", () => { } ]; - const firstPackageNode = ConfigUtils.buildPackageNode("key-1", stringify({variables: firstPackageVariableDefinition})); + const firstPackageNode = ConfigUtils.buildPackageNode("key-1", {variables: firstPackageVariableDefinition}); const firstPackageZip = ConfigUtils.buildExportPackageZip(firstPackageNode, [], "1.0.0"); const secondPackageVariableDefinition: VariableDefinition[] = [ @@ -125,7 +125,7 @@ describe("Config export", () => { } ]; - const secondPackageNode = ConfigUtils.buildPackageNode("key-2", stringify({variables: secondPackageVariableDefinition})); + const secondPackageNode = ConfigUtils.buildPackageNode("key-2", {variables: secondPackageVariableDefinition}); const secondPackageZip = ConfigUtils.buildExportPackageZip(secondPackageNode, [], "1.0.0"); const exportedPackagesZip = ConfigUtils.buildBatchExportZip(manifest, [firstPackageZip, secondPackageZip]); @@ -258,12 +258,12 @@ describe("Config export", () => { manifest.push(ConfigUtils.buildManifestForKeyAndFlavor("key-1", BatchExportImportConstants.STUDIO)); manifest.push(ConfigUtils.buildManifestForKeyAndFlavor("key-2", BatchExportImportConstants.STUDIO)); - const firstPackageNode = ConfigUtils.buildPackageNode("key-1", ""); + const firstPackageNode = ConfigUtils.buildPackageNode("key-1", {}); const firstPackageScenarioChild = ConfigUtils.buildChildNode("child-1-scenario", firstPackageNode.key, "SCENARIO"); const firstPackageTestChild = ConfigUtils.buildChildNode("child-2", firstPackageNode.key, "TEST"); const firstPackageZip = ConfigUtils.buildExportPackageZip(firstPackageNode, [firstPackageScenarioChild, firstPackageTestChild], "1.0.0"); - const secondPackageNode = ConfigUtils.buildPackageNode("key-2", ""); + const secondPackageNode = ConfigUtils.buildPackageNode("key-2", {}); const secondPackageScenarioChild = ConfigUtils.buildChildNode("child-3-scenario", secondPackageNode.key, "SCENARIO"); const secondPackageTestChild = ConfigUtils.buildChildNode("child-4", secondPackageNode.key, "TEST"); const secondPackageZip = ConfigUtils.buildExportPackageZip(secondPackageNode, [secondPackageScenarioChild, secondPackageTestChild], "1.0.0"); @@ -287,15 +287,15 @@ describe("Config export", () => { const actualZip = new AdmZip(fileBuffer); const firstPackageExportedZip = new AdmZip(actualZip.getEntry("key-1_1.0.0.zip").getData()); - expect(firstPackageExportedZip.getEntry("nodes/child-1-scenario.yml")).toBeNull(); - expect(firstPackageExportedZip.getEntry("nodes/child-2.yml").getData().toString()).toEqual(stringify(firstPackageTestChild)); + expect(firstPackageExportedZip.getEntry("nodes/child-1-scenario.json")).toBeNull(); + expect(firstPackageExportedZip.getEntry("nodes/child-2.json").getData().toString()).toEqual(stringify(firstPackageTestChild)); const secondPackageExportedZip = new AdmZip(actualZip.getEntry("key-2_1.0.0.zip").getData()); - expect(secondPackageExportedZip.getEntry("nodes/child-3-scenario.yml")).toBeNull(); - expect(secondPackageExportedZip.getEntry("nodes/child-4.yml").getData().toString()).toEqual(stringify(secondPackageTestChild)); + expect(secondPackageExportedZip.getEntry("nodes/child-3-scenario.json")).toBeNull(); + expect(secondPackageExportedZip.getEntry("nodes/child-4.json").getData().toString()).toEqual(stringify(secondPackageTestChild)); }) - it("Should add appName to metadata for CONNECTION variables of package.yml files", async () => { + it("Should add appName to metadata for CONNECTION variables of package.json files", async () => { const manifest: PackageManifestTransport[] = []; manifest.push(ConfigUtils.buildManifestForKeyAndFlavor("key-1", BatchExportImportConstants.STUDIO)); manifest.push(ConfigUtils.buildManifestForKeyAndFlavor("key-2", BatchExportImportConstants.STUDIO)); @@ -313,7 +313,7 @@ describe("Config export", () => { } ]; - const firstPackageNode = ConfigUtils.buildPackageNode("key-1", stringify({variables: firstPackageVariableDefinition})); + const firstPackageNode = ConfigUtils.buildPackageNode("key-1", {variables: firstPackageVariableDefinition}); const firstPackageZip = ConfigUtils.buildExportPackageZip(firstPackageNode, [], "1.0.0"); const secondPackageVariableDefinition: VariableDefinition[] = [ @@ -332,7 +332,7 @@ describe("Config export", () => { } ]; - const secondPackageNode = ConfigUtils.buildPackageNode("key-2", stringify({variables: secondPackageVariableDefinition})); + const secondPackageNode = ConfigUtils.buildPackageNode("key-2", {variables: secondPackageVariableDefinition}); const secondPackageZip = ConfigUtils.buildExportPackageZip(secondPackageNode, [], "1.0.0"); const exportedPackagesZip = ConfigUtils.buildBatchExportZip(manifest, [firstPackageZip, secondPackageZip]); @@ -403,9 +403,9 @@ describe("Config export", () => { const actualZip = new AdmZip(fileBuffer); const firstPackageExportedZip = new AdmZip(actualZip.getEntry("key-1_1.0.0.zip").getData()); - const firstPackageExportedNode: NodeExportTransport = parse(firstPackageExportedZip.getEntry("package.yml").getData().toString()); + const firstPackageExportedNode: NodeExportTransport = parse(firstPackageExportedZip.getEntry("package.json").getData().toString()); expect(firstPackageExportedNode).toBeTruthy(); - const firstPackageContent: NodeSerializedContent = parse(firstPackageExportedNode.configuration); + const firstPackageContent: NodeConfiguration = firstPackageExportedNode.configuration; expect(firstPackageContent.variables).toHaveLength(2); expect(firstPackageContent.variables).toEqual([ { @@ -420,9 +420,9 @@ describe("Config export", () => { ]); const secondPackageExportedZip = new AdmZip(actualZip.getEntry("key-2_1.0.0.zip").getData()); - const secondPackageExportedNode: NodeExportTransport = parse(secondPackageExportedZip.getEntry("package.yml").getData().toString()); + const secondPackageExportedNode: NodeExportTransport = parse(secondPackageExportedZip.getEntry("package.json").getData().toString()); expect(secondPackageExportedNode).toBeTruthy(); - const secondPackageContent: NodeSerializedContent = parse(secondPackageExportedNode.configuration); + const secondPackageContent: NodeConfiguration = secondPackageExportedNode.configuration; expect(secondPackageContent.variables).toHaveLength(2); expect(secondPackageContent.variables).toEqual([{ ...secondPackageVariableDefinition[0], @@ -458,7 +458,7 @@ describe("Config export", () => { } ]; - const firstPackageNode = ConfigUtils.buildPackageNode("key_with_underscores_1", stringify({variables: firstPackageVariableDefinition})); + const firstPackageNode = ConfigUtils.buildPackageNode("key_with_underscores_1", {variables: firstPackageVariableDefinition}); const firstPackageScenarioChild = ConfigUtils.buildChildNode("child-1-scenario", firstPackageNode.key, "SCENARIO"); const firstPackageZip = ConfigUtils.buildExportPackageZip(firstPackageNode, [firstPackageScenarioChild], "1.0.0"); @@ -511,9 +511,9 @@ describe("Config export", () => { const actualZip = new AdmZip(fileBuffer); const firstPackageExportedZip = new AdmZip(actualZip.getEntry("key_with_underscores_1_1.0.0.zip").getData()); - const firstPackageExportedNode: NodeExportTransport = parse(firstPackageExportedZip.getEntry("package.yml").getData().toString()); + const firstPackageExportedNode: NodeExportTransport = parse(firstPackageExportedZip.getEntry("package.json").getData().toString()); expect(firstPackageExportedNode).toBeTruthy(); - const firstPackageContent: NodeSerializedContent = parse(firstPackageExportedNode.configuration); + const firstPackageContent: NodeConfiguration = firstPackageExportedNode.configuration; expect(firstPackageContent.variables).toHaveLength(3); expect(firstPackageContent.variables).toEqual([ { @@ -532,7 +532,7 @@ describe("Config export", () => { } ]); - expect(firstPackageExportedZip.getEntry("nodes/child-1-scenario.yml")).toBeNull(); + expect(firstPackageExportedZip.getEntry("nodes/child-1-scenario.json")).toBeNull(); }) it("Should export by packageKeys without dependencies", async () => { diff --git a/tests/config/config-import.spec.ts b/tests/config/config-import.spec.ts index 2cde1bb..e16c964 100644 --- a/tests/config/config-import.spec.ts +++ b/tests/config/config-import.spec.ts @@ -12,7 +12,7 @@ import { import {ConfigUtils} from "../utls/config-utils"; import {mockWriteFileSync, testTransport} from "../jest.setup"; import * as path from "path"; -import {stringify} from "../../src/util/yaml"; +import {stringify} from "../../src/util/json"; import {SpaceTransport} from "../../src/interfaces/save-space.interface"; import {packageApi} from "../../src/api/package-api"; import { @@ -68,7 +68,7 @@ describe("Config import", () => { const studioManifest: StudioPackageManifest[] = []; studioManifest.push(ConfigUtils.buildStudioManifestForKeyWithSpace("key-2", "spaceName", "space-id")); - const firstPackageNode = ConfigUtils.buildPackageNode("key-2", stringify({variables: []})); + const firstPackageNode = ConfigUtils.buildPackageNode("key-2", {variables: []}); const firstPackageZip = ConfigUtils.buildExportPackageZip(firstPackageNode, [], "1.0.0"); const exportedPackagesZip = ConfigUtils.buildBatchExportZipWithStudioManifest(manifest, studioManifest,[firstPackageZip]); @@ -112,7 +112,7 @@ describe("Config import", () => { const studioManifest: StudioPackageManifest[] = []; studioManifest.push(ConfigUtils.buildStudioManifestForKeyWithSpace("key-2", "spaceName", "space")); - const firstPackageNode = ConfigUtils.buildPackageNode("key-2", stringify({variables: []})); + const firstPackageNode = ConfigUtils.buildPackageNode("key-2", {variables: []}); const firstPackageZip = ConfigUtils.buildExportPackageZip(firstPackageNode, [], "1.0.0"); const exportedPackagesZip = ConfigUtils.buildBatchExportZipWithStudioManifest(manifest, studioManifest,[firstPackageZip]); @@ -139,7 +139,7 @@ describe("Config import", () => { const studioManifest: StudioPackageManifest[] = []; studioManifest.push(ConfigUtils.buildStudioManifestForKeyWithSpace("key-2", "space", "spaceId")); - const firstPackageNode = ConfigUtils.buildPackageNode("key-2", stringify({variables: []})); + const firstPackageNode = ConfigUtils.buildPackageNode("key-2", {variables: []}); const firstPackageZip = ConfigUtils.buildExportPackageZip(firstPackageNode, [], "1.0.0"); const exportedPackagesZip = ConfigUtils.buildBatchExportZipWithStudioManifest(manifest, studioManifest,[firstPackageZip]); @@ -186,7 +186,7 @@ describe("Config import", () => { const studioManifest: StudioPackageManifest[] = []; studioManifest.push(ConfigUtils.buildStudioManifestForKeyWithSpace("key-2", "spaceName", null)); - const firstPackageNode = ConfigUtils.buildPackageNode("key-2", stringify({variables: []})); + const firstPackageNode = ConfigUtils.buildPackageNode("key-2", {variables: []}); const firstPackageZip = ConfigUtils.buildExportPackageZip(firstPackageNode, [], "1.0.0"); const exportedPackagesZip = ConfigUtils.buildBatchExportZipWithStudioManifest(manifest, studioManifest,[firstPackageZip]); @@ -225,7 +225,7 @@ describe("Config import", () => { const studioManifest: StudioPackageManifest[] = []; studioManifest.push(ConfigUtils.buildStudioManifestForKeyWithSpace("key-2", "otherName", null)); - const firstPackageNode = ConfigUtils.buildPackageNode("key-2", stringify({variables: []})); + const firstPackageNode = ConfigUtils.buildPackageNode("key-2", {variables: []}); const firstPackageZip = ConfigUtils.buildExportPackageZip(firstPackageNode, [], "1.0.0"); const exportedPackagesZip = ConfigUtils.buildBatchExportZipWithStudioManifest(manifest, studioManifest,[firstPackageZip]); diff --git a/tests/config/config-list-variables.spec.ts b/tests/config/config-list-variables.spec.ts index 45f479e..a63c87b 100644 --- a/tests/config/config-list-variables.spec.ts +++ b/tests/config/config-list-variables.spec.ts @@ -5,7 +5,7 @@ import * as path from "path"; import {PackageKeyAndVersionPair, VariableManifestTransport} from "../../src/interfaces/package-export-transport"; import {PackageManagerVariableType} from "../../src/interfaces/package-manager.interfaces"; import {mockAxiosPost, mockedPostRequestBodyByUrl} from "../utls/http-requests-mock"; -import {parse} from "../../src/util/yaml"; +import {parse} from "../../src/util/json"; import * as fs from "fs"; describe("Config listVariables", () => { diff --git a/tests/utls/config-utils.ts b/tests/utls/config-utils.ts index 0ab9683..e796278 100644 --- a/tests/utls/config-utils.ts +++ b/tests/utls/config-utils.ts @@ -1,10 +1,10 @@ import AdmZip = require("adm-zip"); import { - DependencyTransport, + DependencyTransport, NodeConfiguration, NodeExportTransport, - PackageManifestTransport, StudioPackageManifest + PackageManifestTransport, StudioPackageManifest, } from "../../src/interfaces/package-export-transport"; -import {stringify} from "../../src/util/yaml"; +import {stringify} from "../../src/util/json"; import {SpaceTransport} from "../../src/interfaces/save-space.interface"; export class ConfigUtils { @@ -12,8 +12,8 @@ export class ConfigUtils { public static buildBatchExportZipWithStudioManifest(manifest: PackageManifestTransport[], studioManifest: StudioPackageManifest[], packageZips: AdmZip[]): AdmZip { const zipExport = new AdmZip(); - zipExport.addFile("manifest.yml", Buffer.from(stringify(manifest))); - zipExport.addFile("studio.yml", Buffer.from(stringify(studioManifest))); + zipExport.addFile("manifest.json", Buffer.from(stringify(manifest))); + zipExport.addFile("studio.json", Buffer.from(stringify(studioManifest))); packageZips.forEach(packageZip => { const fileName = `${packageZip.getZipComment()}.zip` packageZip.addZipComment("") @@ -25,7 +25,7 @@ export class ConfigUtils { public static buildBatchExportZip(manifest: PackageManifestTransport[], packageZips: AdmZip[]): AdmZip { const zipExport = new AdmZip(); - zipExport.addFile("manifest.yml", Buffer.from(stringify(manifest))); + zipExport.addFile("manifest.json", Buffer.from(stringify(manifest))); packageZips.forEach(packageZip => { const fileName = `${packageZip.getZipComment()}.zip` packageZip.addZipComment("") @@ -38,11 +38,11 @@ export class ConfigUtils { public static buildExportPackageZip(packageNode: NodeExportTransport, childNodes: NodeExportTransport[], version: string): AdmZip { const zipExport = new AdmZip(); - zipExport.addFile("package.yml", Buffer.from(stringify(packageNode))); + zipExport.addFile("package.json", Buffer.from(stringify(packageNode))); zipExport.addFile("nodes/", Buffer.alloc(0)); childNodes.forEach(child => { - zipExport.addFile(`nodes/${child.key}.yml`, Buffer.from(stringify(child))); + zipExport.addFile(`nodes/${child.key}.json`, Buffer.from(stringify(child))); }); zipExport.addZipComment(`${packageNode.key}_${version}`); @@ -59,7 +59,7 @@ export class ConfigUtils { }; } - public static buildPackageNode(key: string, configuration: string): NodeExportTransport { + public static buildPackageNode(key: string, configuration: NodeConfiguration): NodeExportTransport { return { key, parentNodeKey: key, @@ -81,7 +81,7 @@ export class ConfigUtils { name: "name", type: type, exportSerializationType: "YAML", - configuration: "", + configuration: {}, schemaVersion: 1, invalidContent: false, serializedDocument: null,