@eventcatalog/sdk 2.3.3 → 2.3.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -246,7 +246,14 @@ var rmResourceById = async (catalogDir, id, version, options) => {
246
246
  var addFileToResource = async (catalogDir, id, file, version) => {
247
247
  const pathToResource = await findFileById(catalogDir, id, version);
248
248
  if (!pathToResource) throw new Error("Cannot find directory to write file to");
249
- fsSync2.writeFileSync(join2(dirname2(pathToResource), file.fileName), file.content);
249
+ let fileContent = file.content.trim();
250
+ try {
251
+ const json = JSON.parse(fileContent);
252
+ fileContent = JSON.stringify(json, null, 2);
253
+ } catch (error) {
254
+ console.error(error);
255
+ }
256
+ fsSync2.writeFileSync(join2(dirname2(pathToResource), file.fileName), fileContent);
250
257
  };
251
258
  var getFileFromResource = async (catalogDir, id, file, version) => {
252
259
  const pathToResource = await findFileById(catalogDir, id, version);
@@ -390,7 +397,7 @@ var writeVersionedService = (directory) => async (service) => {
390
397
  const path4 = getVersionedDirectory(service.id, service.version);
391
398
  return await writeService(directory)(resource, { path: path4 });
392
399
  };
393
- var writeServiceToDomain = (directory) => async (service, domain, options = { path: "", format: "mdx" }) => {
400
+ var writeServiceToDomain = (directory) => async (service, domain, options = { path: "", format: "mdx", override: false }) => {
394
401
  let pathForService = domain.version && domain.version !== "latest" ? `/${domain.id}/versioned/${domain.version}/services` : `/${domain.id}/services`;
395
402
  pathForService = join6(pathForService, service.id);
396
403
  await writeResource(directory, { ...service }, { ...options, path: pathForService, type: "service" });