contensis-cli 1.1.1-beta.1 → 1.1.1-beta.11

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/README.md CHANGED
@@ -1604,7 +1604,7 @@ Found 113 entries in leif
1604
1604
  - and 15 more...
1605
1605
 
1606
1606
  --------------------------------------------
1607
- [26/11 02:16:30] [OK] Done migrating entries
1607
+ [26/11 02:16:30] [OK] Entries migration preview done
1608
1608
 
1609
1609
  [cli] ⏩ import from project leif to website
1610
1610
 
@@ -32,8 +32,8 @@ const makeListCommand = () => {
32
32
  Example call:
33
33
  > list envs
34
34
  `
35
- ).action((opts) => {
36
- (0, import_ContensisCliService.cliCommand)(["list", "envs"], opts).PrintEnvironments();
35
+ ).action(async (opts) => {
36
+ await (0, import_ContensisCliService.cliCommand)(["list", "envs"], opts).PrintEnvironments();
37
37
  });
38
38
  list.command("projects").description("print list of projects").addHelpText(
39
39
  "after",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/commands/list.ts"],
4
- "sourcesContent": ["import { Command } from 'commander';\nimport { cliCommand } from '~/services/ContensisCliService';\n\nexport const makeListCommand = () => {\n const list = new Command()\n .command('list')\n .description('list command')\n .addHelpText('after', `\\n`)\n .showHelpAfterError(true)\n .exitOverride();\n\n list\n .command('envs')\n .description('List all previously connected environments')\n .addHelpText(\n 'after',\n `\nExample call:\n > list envs\n`\n )\n .action(opts => {\n cliCommand(['list', 'envs'], opts).PrintEnvironments();\n });\n\n list\n .command('projects')\n .description('print list of projects')\n .addHelpText(\n 'after',\n `\nExample call:\n > list projects\n`\n )\n .action(async opts => {\n await cliCommand(['list', 'projects'], opts).PrintProjects();\n });\n\n list\n .command('models')\n .description('print list of content models')\n .addHelpText(\n 'after',\n `\nExample call:\n > list models\n`\n )\n .action(async opts => {\n await cliCommand(['list', 'models'], opts).PrintContentModels();\n });\n\n list\n .command('contenttypes')\n .description('print list of content types')\n .addHelpText(\n 'after',\n `\nExample call:\n > list contenttypes -o ./output.json -f json\n`\n )\n .action(async opts => {\n await cliCommand(['list', 'contenttypes'], opts).PrintContentTypes();\n });\n\n list\n .command('components')\n .description('print list of components')\n .addHelpText(\n 'after',\n `\nExample call:\n > list components -o ./output.json -f json\n`\n )\n .action(async opts => {\n await cliCommand(['list', 'components'], opts).PrintComponents();\n });\n\n list\n .command('blocks')\n .description('print list of content blocks')\n .addHelpText(\n 'after',\n `\nExample call:\n > list blocks\n`\n )\n .action(async opts => {\n await cliCommand(['list', 'blocks'], opts).PrintBlocks();\n });\n\n list\n .command('keys')\n .description('print list of API keys')\n .addHelpText(\n 'after',\n `\nExample call:\n > list keys\n`\n )\n .action(async opts => {\n await cliCommand(['list', 'keys'], opts).PrintApiKeys();\n });\n\n list\n .command('proxies')\n .description('print list of proxies')\n .addHelpText(\n 'after',\n `\nExample call:\n > list proxies\n`\n )\n .action(async opts => {\n await cliCommand(['list', 'proxies'], opts).PrintProxies();\n });\n\n list\n .command('renderers')\n .description('print list of renderers')\n .addHelpText(\n 'after',\n `\nExample call:\n > list renderers\n`\n )\n .action(async opts => {\n await cliCommand(['list', 'renderers'], opts).PrintRenderers();\n });\n\n list\n .command('roles')\n .description('print list of roles')\n .addHelpText(\n 'after',\n `\nExample call:\n > list roles\n`\n )\n .action(async opts => {\n await cliCommand(['list', 'roles'], opts).PrintRoles();\n });\n\n list\n .command('webhooks')\n .description('print list of webhooks')\n .argument('[name]', 'find webhooks matching the supplied name')\n .option('-i --id <id...>', 'the subscription id(s) to get')\n .addHelpText('after', `\\n`)\n .action(async (name?: string, { id, ...opts }: any = {}) => {\n await cliCommand(['list', 'webhooks'], opts).PrintWebhookSubscriptions(\n name ? [name] : id\n );\n });\n\n list\n .command('workflows')\n .description('print list of workflow definitions')\n .addHelpText(\n 'after',\n `\nExample call:\n > list workflows\n`\n )\n .action(async opts => {\n await cliCommand(['list', 'workflows'], opts).PrintWorkflows();\n });\n\n return list;\n};\n"],
5
- "mappings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O,MAAe,EAAE,OAAO,KAAK,IAAS,CAAC,MAAM;AAC1D,cAAM,uCAAW,CAAC,QAAQ,UAAU,GAAG,IAAI,EAAE;AAAA,MAC3C,OAAO,CAAC,IAAI,IAAI;AAAA,IAClB;AAAA,EACF,CAAC;AAEH,OACG,QAAQ,WAAW,EACnB,YAAY,oCAAoC,EAChD;AAAA,IACC;AAAA,IACA;AAAA;AAAA;AAAA;AAAA,EAIF,EACC,OAAO,OAAM,SAAQ;AACpB,cAAM,uCAAW,CAAC,QAAQ,WAAW,GAAG,IAAI,EAAE,eAAe;AAAA,EAC/D,CAAC;AAEH,SAAO;AACT;",
4
+ "sourcesContent": ["import { Command } from 'commander';\nimport { cliCommand } from '~/services/ContensisCliService';\n\nexport const makeListCommand = () => {\n const list = new Command()\n .command('list')\n .description('list command')\n .addHelpText('after', `\\n`)\n .showHelpAfterError(true)\n .exitOverride();\n\n list\n .command('envs')\n .description('List all previously connected environments')\n .addHelpText(\n 'after',\n `\nExample call:\n > list envs\n`\n )\n .action(async opts => {\n await cliCommand(['list', 'envs'], opts).PrintEnvironments();\n });\n\n list\n .command('projects')\n .description('print list of projects')\n .addHelpText(\n 'after',\n `\nExample call:\n > list projects\n`\n )\n .action(async opts => {\n await cliCommand(['list', 'projects'], opts).PrintProjects();\n });\n\n list\n .command('models')\n .description('print list of content models')\n .addHelpText(\n 'after',\n `\nExample call:\n > list models\n`\n )\n .action(async opts => {\n await cliCommand(['list', 'models'], opts).PrintContentModels();\n });\n\n list\n .command('contenttypes')\n .description('print list of content types')\n .addHelpText(\n 'after',\n `\nExample call:\n > list contenttypes -o ./output.json -f json\n`\n )\n .action(async opts => {\n await cliCommand(['list', 'contenttypes'], opts).PrintContentTypes();\n });\n\n list\n .command('components')\n .description('print list of components')\n .addHelpText(\n 'after',\n `\nExample call:\n > list components -o ./output.json -f json\n`\n )\n .action(async opts => {\n await cliCommand(['list', 'components'], opts).PrintComponents();\n });\n\n list\n .command('blocks')\n .description('print list of content blocks')\n .addHelpText(\n 'after',\n `\nExample call:\n > list blocks\n`\n )\n .action(async opts => {\n await cliCommand(['list', 'blocks'], opts).PrintBlocks();\n });\n\n list\n .command('keys')\n .description('print list of API keys')\n .addHelpText(\n 'after',\n `\nExample call:\n > list keys\n`\n )\n .action(async opts => {\n await cliCommand(['list', 'keys'], opts).PrintApiKeys();\n });\n\n list\n .command('proxies')\n .description('print list of proxies')\n .addHelpText(\n 'after',\n `\nExample call:\n > list proxies\n`\n )\n .action(async opts => {\n await cliCommand(['list', 'proxies'], opts).PrintProxies();\n });\n\n list\n .command('renderers')\n .description('print list of renderers')\n .addHelpText(\n 'after',\n `\nExample call:\n > list renderers\n`\n )\n .action(async opts => {\n await cliCommand(['list', 'renderers'], opts).PrintRenderers();\n });\n\n list\n .command('roles')\n .description('print list of roles')\n .addHelpText(\n 'after',\n `\nExample call:\n > list roles\n`\n )\n .action(async opts => {\n await cliCommand(['list', 'roles'], opts).PrintRoles();\n });\n\n list\n .command('webhooks')\n .description('print list of webhooks')\n .argument('[name]', 'find webhooks matching the supplied name')\n .option('-i --id <id...>', 'the subscription id(s) to get')\n .addHelpText('after', `\\n`)\n .action(async (name?: string, { id, ...opts }: any = {}) => {\n await cliCommand(['list', 'webhooks'], opts).PrintWebhookSubscriptions(\n name ? [name] : id\n );\n });\n\n list\n .command('workflows')\n .description('print list of workflow definitions')\n .addHelpText(\n 'after',\n `\nExample call:\n > list workflows\n`\n )\n .action(async opts => {\n await cliCommand(['list', 'workflows'], opts).PrintWorkflows();\n });\n\n return list;\n};\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAAwB;AACxB,iCAA2B;AAEpB,MAAM,kBAAkB,MAAM;AACnC,QAAM,OAAO,IAAI,yBAAQ,EACtB,QAAQ,MAAM,EACd,YAAY,cAAc,EAC1B,YAAY,SAAS;AAAA,CAAI,EACzB,mBAAmB,IAAI,EACvB,aAAa;AAEhB,OACG,QAAQ,M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AA;AAAA;AAAA,EAIF,EACC,OAAO,OAAM,SAAQ;AACpB,cAAM,uCAAW,CAAC,QAAQ,WAAW,GAAG,IAAI,EAAE,eAAe;AAAA,EAC/D,CAAC;AAEH,SAAO;AACT;",
6
6
  "names": []
7
7
  }
@@ -105,18 +105,18 @@ const checkDir = (filePath) => {
105
105
  const appPath = (filePath) => import_path.default.isAbsolute(filePath) ? filePath : import_path.default.join(appRootDir, filePath);
106
106
  const cwdPath = (filePath) => import_path.default.isAbsolute(filePath) ? filePath : import_path.default.join(process.cwd(), filePath);
107
107
  const detectFileType = (fromFile) => {
108
+ const fileData = readFile(fromFile);
109
+ if (!fileData)
110
+ throw new Error(`Unable to read file at ${fromFile}`);
108
111
  try {
109
- const fileData = readFile(fromFile);
110
- if (fileData) {
111
- if (fileData.startsWith("<"))
112
- return { contents: fileData, type: "xml" };
113
- const jsonData = (0, import_util.tryParse)(fileData);
114
- if (jsonData)
115
- return { contents: jsonData, type: "json" };
116
- const csv = (0, import_csv.detectCsv)(fileData);
117
- if (csv)
118
- return { contents: fileData, type: "csv" };
119
- }
112
+ if (fileData.startsWith("<"))
113
+ return { contents: fileData, type: "xml" };
114
+ const jsonData = (0, import_util.tryParse)(fileData);
115
+ if (jsonData)
116
+ return { contents: jsonData, type: "json" };
117
+ const csv = (0, import_csv.detectCsv)(fileData);
118
+ if (csv)
119
+ return { contents: fileData, type: "csv" };
120
120
  } catch (ex) {
121
121
  import_logger.Logger.error(`Problem detecting file type ${fromFile}`, ex);
122
122
  }
@@ -128,7 +128,7 @@ const readFileAsJSON = async (fromFile) => {
128
128
  try {
129
129
  switch (detectedFile.type) {
130
130
  case "csv": {
131
- const flatJson = (0, import_csv.csvToJson)(detectedFile.contents);
131
+ const flatJson = await (0, import_csv.csvToJson)(detectedFile.contents);
132
132
  const unflattenedJson = flatJson.map((record) => (0, import_json.unflattenObject)(record));
133
133
  return unflattenedJson;
134
134
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/providers/file-provider.ts"],
4
- "sourcesContent": ["import fs from 'fs';\nimport { homedir } from 'os';\nimport path from 'path';\nimport { tryParse } from '~/util';\nimport { csvToJson, detectCsv } from '~/util/csv.formatter';\nimport { unflattenObject } from '~/util/json.formatter';\nimport { Logger } from '~/util/logger';\nimport { xmlToJson } from '~/util/xml.formatter';\n\nconst userHomeDir = homedir();\n\nexport const appRootDir =\n process.env.CONTAINER_CONTEXT === 'true'\n ? process.cwd()\n : path.join(userHomeDir, '.contensis/');\n\nexport const readFile = (filePath: string) => {\n const directoryPath = appPath(filePath);\n if (fs.existsSync(directoryPath)) {\n const file = fs.readFileSync(directoryPath, 'utf8');\n return file;\n } else {\n return undefined;\n }\n};\n\nexport const readFiles = (directory: string, createDirectory = true) => {\n const directoryPath = appPath(directory);\n if (fs.existsSync(directoryPath)) {\n const files = fs.readdirSync(directoryPath);\n return files;\n } else if (createDirectory) {\n fs.mkdirSync(directoryPath, { recursive: true });\n return [];\n } else {\n throw new Error(`ENOENT: Directory does not exist ${directoryPath}`);\n // return undefined;\n }\n};\n\nexport const writeFile = (filePath: string, content: string) => {\n const directoryPath = appPath(filePath);\n fs.writeFileSync(directoryPath, content, { encoding: 'utf-8' });\n};\n\nexport const removeFile = (filePath: string) => {\n const directoryPath = appPath(filePath);\n if (fs.existsSync(directoryPath)) {\n fs.rmSync(directoryPath);\n }\n};\n\nexport const moveFile = (file: string, fromPath: string, toPath: string) => {\n const from = path.join(appRootDir, `${fromPath}${file}`);\n const to = path.join(appRootDir, `${toPath}${file}`);\n if (fs.existsSync(from)) {\n checkDir(toPath);\n // if (!fs.existsSync(toPath)) fs.mkdirSync(toPath, { recursive: true });\n\n fs.rename(from, to, err => {\n if (err)\n console.error(\n `Could not rename file \"${file}\" from: ${fromPath} to: ${toPath}`,\n err\n );\n console.info(`Renamed file \"${file}\" from: ${fromPath} to: ${toPath}`);\n });\n } else {\n console.error(\n `Could not rename file \"${file}\" from: ${fromPath} to: ${toPath}\\nFile does not exist!`\n );\n }\n};\n\nexport const checkDir = (filePath: string) => {\n const directoryPath = path.dirname(appPath(filePath));\n if (!fs.existsSync(directoryPath))\n fs.mkdirSync(directoryPath, { recursive: true });\n};\n\nexport const appPath = (filePath: string) =>\n path.isAbsolute(filePath) ? filePath : path.join(appRootDir, filePath);\n\nexport const cwdPath = (filePath: string) =>\n path.isAbsolute(filePath) ? filePath : path.join(process.cwd(), filePath);\n\ntype DetectedFileType =\n | { type: 'json'; contents: any }\n | { type: 'xml' | 'csv'; contents: string };\n\nconst detectFileType = (\n fromFile: string\n): DetectedFileType | undefined => {\n try {\n const fileData = readFile(fromFile);\n if (fileData) {\n // if XML\n if (fileData.startsWith('<')) return { contents: fileData, type: 'xml' };\n\n // if JSON\n const jsonData = tryParse(fileData);\n if (jsonData) return { contents: jsonData, type: 'json' };\n\n // if CSV\n const csv = detectCsv(fileData);\n if (csv) return { contents: fileData, type: 'csv' };\n }\n } catch (ex) {\n Logger.error(`Problem detecting file type ${fromFile}`, ex);\n }\n};\n\nexport const readFileAsJSON = async <T = any>(\n fromFile: string\n): Promise<T | undefined> => {\n const detectedFile = detectFileType(cwdPath(fromFile));\n if (!detectedFile) return undefined;\n try {\n switch (detectedFile.type) {\n case 'csv': {\n const flatJson = csvToJson(detectedFile.contents);\n const unflattenedJson = flatJson.map(record => unflattenObject(record));\n return unflattenedJson as T;\n }\n case 'xml':\n return (await xmlToJson(detectedFile.contents)) as T;\n\n case 'json':\n default:\n return detectedFile.contents;\n }\n } catch (ex) {\n Logger.error(`Problem converting file from ${detectedFile.type}`, ex);\n }\n};\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gBAAe;AACf,gBAAwB;AACxB,kBAAiB;AACjB,kBAAyB;AACzB,iBAAqC;AACrC,kBAAgC;AAChC,oBAAuB;AACvB,iBAA0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AC;AAAc,WAAO;AAC1B,MAAI;AACF,YAAQ,aAAa;AAAA,WACd,OAAO;AACV,cAAM,eAAW,sBAAU,aAAa,QAAQ;AAChD,cAAM,kBAAkB,SAAS,IAAI,gBAAU,6BAAgB,MAAM,CAAC;AACtE,eAAO;AAAA,MACT;AAAA,WACK;AACH,eAAQ,UAAM,sBAAU,aAAa,QAAQ;AAAA,WAE1C;AAAA;AAEH,eAAO,aAAa;AAAA;AAAA,EAE1B,SAAS,IAAP;AACA,yBAAO,MAAM,gCAAgC,aAAa,QAAQ,EAAE;AAAA,EACtE;AACF;",
4
+ "sourcesContent": ["import fs from 'fs';\nimport { homedir } from 'os';\nimport path from 'path';\nimport { tryParse } from '~/util';\nimport { csvToJson, detectCsv } from '~/util/csv.formatter';\nimport { unflattenObject } from '~/util/json.formatter';\nimport { Logger } from '~/util/logger';\nimport { xmlToJson } from '~/util/xml.formatter';\n\nconst userHomeDir = homedir();\n\nexport const appRootDir =\n process.env.CONTAINER_CONTEXT === 'true'\n ? process.cwd()\n : path.join(userHomeDir, '.contensis/');\n\nexport const readFile = (filePath: string) => {\n const directoryPath = appPath(filePath);\n if (fs.existsSync(directoryPath)) {\n const file = fs.readFileSync(directoryPath, 'utf8');\n return file;\n } else {\n return undefined;\n }\n};\n\nexport const readFiles = (directory: string, createDirectory = true) => {\n const directoryPath = appPath(directory);\n if (fs.existsSync(directoryPath)) {\n const files = fs.readdirSync(directoryPath);\n return files;\n } else if (createDirectory) {\n fs.mkdirSync(directoryPath, { recursive: true });\n return [];\n } else {\n throw new Error(`ENOENT: Directory does not exist ${directoryPath}`);\n // return undefined;\n }\n};\n\nexport const writeFile = (filePath: string, content: string) => {\n const directoryPath = appPath(filePath);\n fs.writeFileSync(directoryPath, content, { encoding: 'utf-8' });\n};\n\nexport const removeFile = (filePath: string) => {\n const directoryPath = appPath(filePath);\n if (fs.existsSync(directoryPath)) {\n fs.rmSync(directoryPath);\n }\n};\n\nexport const moveFile = (file: string, fromPath: string, toPath: string) => {\n const from = path.join(appRootDir, `${fromPath}${file}`);\n const to = path.join(appRootDir, `${toPath}${file}`);\n if (fs.existsSync(from)) {\n checkDir(toPath);\n // if (!fs.existsSync(toPath)) fs.mkdirSync(toPath, { recursive: true });\n\n fs.rename(from, to, err => {\n if (err)\n console.error(\n `Could not rename file \"${file}\" from: ${fromPath} to: ${toPath}`,\n err\n );\n console.info(`Renamed file \"${file}\" from: ${fromPath} to: ${toPath}`);\n });\n } else {\n console.error(\n `Could not rename file \"${file}\" from: ${fromPath} to: ${toPath}\\nFile does not exist!`\n );\n }\n};\n\nexport const checkDir = (filePath: string) => {\n const directoryPath = path.dirname(appPath(filePath));\n if (!fs.existsSync(directoryPath))\n fs.mkdirSync(directoryPath, { recursive: true });\n};\n\nexport const appPath = (filePath: string) =>\n path.isAbsolute(filePath) ? filePath : path.join(appRootDir, filePath);\n\nexport const cwdPath = (filePath: string) =>\n path.isAbsolute(filePath) ? filePath : path.join(process.cwd(), filePath);\n\ntype DetectedFileType =\n | { type: 'json'; contents: any }\n | { type: 'xml' | 'csv'; contents: string };\n\nconst detectFileType = (fromFile: string): DetectedFileType | undefined => {\n const fileData = readFile(fromFile);\n if (!fileData) throw new Error(`Unable to read file at ${fromFile}`);\n try {\n // if XML\n if (fileData.startsWith('<')) return { contents: fileData, type: 'xml' };\n\n // if JSON\n const jsonData = tryParse(fileData);\n if (jsonData) return { contents: jsonData, type: 'json' };\n\n // if CSV\n const csv = detectCsv(fileData);\n if (csv) return { contents: fileData, type: 'csv' };\n } catch (ex) {\n Logger.error(`Problem detecting file type ${fromFile}`, ex);\n }\n};\n\nexport const readFileAsJSON = async <T = any>(\n fromFile: string\n): Promise<T | undefined> => {\n const detectedFile = detectFileType(cwdPath(fromFile));\n if (!detectedFile) return undefined;\n try {\n switch (detectedFile.type) {\n case 'csv': {\n const flatJson = await csvToJson(detectedFile.contents);\n const unflattenedJson = flatJson.map(record => unflattenObject(record));\n return unflattenedJson as T;\n }\n case 'xml':\n return (await xmlToJson(detectedFile.contents)) as T;\n\n case 'json':\n default:\n return detectedFile.contents;\n }\n } catch (ex) {\n Logger.error(`Problem converting file from ${detectedFile.type}`, ex);\n }\n};\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gBAAe;AACf,gBAAwB;AACxB,kBAAiB;AACjB,kBAAyB;AACzB,iBAAqC;AACrC,kBAAgC;AAChC,oBAAuB;AACvB,iBAA0B;AAE1B,MAAM,kBAAc,mBAAQ;AAErB,MAAM,aACX,QAAQ,IAAI,sBAAsB,SAC9B,QAAQ,IAAI,IACZ,YAAAA,QAAK,KAAK,aAAa,aAAa;AAEnC,MAAM,WAAW,CAAC,aAAqB;AAC5C,QAAM,gBAAgB,QAAQ,QAAQ;AACtC,MAAI,UAAAC,QAAG,WAAW,aAAa,GAAG;AAChC,UAAM,OAAO,UAAAA,QAAG,aAAa,eAAe,MAAM;AAClD,WAAO;AAAA,EACT,OAAO;AACL,WAAO;AAAA,EACT;AACF;AAEO,MAAM,YAAY,CAAC,WAAmB,kBAAkB,SAAS;AACtE,QAAM,gBAAgB,QAAQ,SAAS;AACvC,MAAI,UAAAA,QAAG,WAAW,aAAa,GAAG;AAChC,UAAM,QAAQ,UAAAA,QAAG,YAAY,aAAa;AAC1C,WAAO;AAAA,EACT,WAAW,iBAAiB;AAC1B,cAAAA,QAAG,UAAU,eAAe,EAAE,WAAW,KAAK,CAAC;AAC/C,WAAO,CAAC;AAAA,EACV,OAAO;AACL,UAAM,IAAI,MAAM,oCAAoC,eAAe;AAAA,EAErE;AACF;AAEO,MAAM,YAAY,CAAC,UAAkB,YAAoB;AAC9D,QAAM,gBAAgB,QAAQ,QAAQ;AACtC,YAAAA,QAAG,cAAc,eAAe,SAAS,EAAE,UAAU,QAAQ,CAAC;AAChE;AAEO,MAAM,aAAa,CAAC,aAAqB;AAC9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O,EAAE,UAAU,UAAU,MAAM,MAAM;AAGvE,UAAM,eAAW,sBAAS,QAAQ;AAClC,QAAI;AAAU,aAAO,EAAE,UAAU,UAAU,MAAM,OAAO;AAGxD,UAAM,UAAM,sBAAU,QAAQ;AAC9B,QAAI;AAAK,aAAO,EAAE,UAAU,UAAU,MAAM,MAAM;AAAA,EACpD,SAAS,IAAP;AACA,yBAAO,MAAM,+BAA+B,YAAY,EAAE;AAAA,EAC5D;AACF;AAEO,MAAM,iBAAiB,OAC5B,aAC2B;AAC3B,QAAM,eAAe,eAAe,QAAQ,QAAQ,CAAC;AACrD,MAAI,CAAC;AAAc,WAAO;AAC1B,MAAI;AACF,YAAQ,aAAa;AAAA,WACd,OAAO;AACV,cAAM,WAAW,UAAM,sBAAU,aAAa,QAAQ;AACtD,cAAM,kBAAkB,SAAS,IAAI,gBAAU,6BAAgB,MAAM,CAAC;AACtE,eAAO;AAAA,MACT;AAAA,WACK;AACH,eAAQ,UAAM,sBAAU,aAAa,QAAQ;AAAA,WAE1C;AAAA;AAEH,eAAO,aAAa;AAAA;AAAA,EAE1B,SAAS,IAAP;AACA,yBAAO,MAAM,gCAAgC,aAAa,QAAQ,EAAE;AAAA,EACtE;AACF;",
6
6
  "names": ["path", "fs"]
7
7
  }
@@ -149,12 +149,12 @@ class ContensisCli {
149
149
  }
150
150
  }
151
151
  }
152
- PrintEnvironments = () => {
152
+ PrintEnvironments = async () => {
153
153
  const { log, messages } = this;
154
154
  const { currentEnvironment, environments = {} } = this.cache;
155
155
  const envKeys = Object.keys(environments);
156
156
  log.success(messages.envs.found(envKeys.length));
157
- this.HandleFormattingAndOutput(envKeys, () => {
157
+ await this.HandleFormattingAndOutput(envKeys, () => {
158
158
  for (const env of envKeys) {
159
159
  console.log(` - ${currentEnvironment === env ? "* " : ""}${env}`);
160
160
  }
@@ -434,7 +434,7 @@ class ContensisCli {
434
434
  contensis.projects.GetSourceProjects()
435
435
  );
436
436
  if (Array.isArray(projects)) {
437
- this.HandleFormattingAndOutput(
437
+ await this.HandleFormattingAndOutput(
438
438
  contensis.contensisVersion,
439
439
  () => log.raw(log.highlightText(contensis.contensisVersion))
440
440
  );
@@ -453,7 +453,7 @@ class ContensisCli {
453
453
  contensis.content.sourceRepo.repo.BearerToken()
454
454
  );
455
455
  if (token) {
456
- this.HandleFormattingAndOutput(
456
+ await this.HandleFormattingAndOutput(
457
457
  token,
458
458
  () => log.raw(log.highlightText(token))
459
459
  );
@@ -479,7 +479,7 @@ class ContensisCli {
479
479
  });
480
480
  log.success(messages.projects.list());
481
481
  log.raw("");
482
- this.HandleFormattingAndOutput(projects, () => {
482
+ await this.HandleFormattingAndOutput(projects, () => {
483
483
  for (const project of projects.sort(
484
484
  (a, b) => a.id.localeCompare(b.id)
485
485
  )) {
@@ -519,7 +519,7 @@ class ContensisCli {
519
519
  );
520
520
  if (foundProject) {
521
521
  log.raw("");
522
- this.HandleFormattingAndOutput(foundProject, log.object);
522
+ await this.HandleFormattingAndOutput(foundProject, log.object);
523
523
  }
524
524
  if (projectsErr) {
525
525
  log.error(messages.projects.noList());
@@ -575,7 +575,7 @@ class ContensisCli {
575
575
  const [keysErr, apiKeys] = await contensis.apiKeys.GetKeys();
576
576
  if (Array.isArray(apiKeys)) {
577
577
  log.success(messages.keys.list(currentEnv));
578
- this.HandleFormattingAndOutput(apiKeys, () => {
578
+ await this.HandleFormattingAndOutput(apiKeys, () => {
579
579
  for (const {
580
580
  id,
581
581
  sharedSecret,
@@ -644,7 +644,7 @@ class ContensisCli {
644
644
  log.success(messages.roles.list(currentEnv));
645
645
  if (!roles.length)
646
646
  log.help(messages.roles.noneExist());
647
- this.HandleFormattingAndOutput(roles, () => {
647
+ await this.HandleFormattingAndOutput(roles, () => {
648
648
  var _a, _b, _c, _d, _e;
649
649
  for (const {
650
650
  id,
@@ -713,7 +713,7 @@ class ContensisCli {
713
713
  log.success(messages.roles.list(currentEnv));
714
714
  const role = (0, import_find.findByIdOrName)(roles, roleNameOrId);
715
715
  if (role)
716
- this.HandleFormattingAndOutput(role, log.object);
716
+ await this.HandleFormattingAndOutput(role, log.object);
717
717
  else
718
718
  log.error(messages.roles.failedGet(currentEnv, roleNameOrId));
719
719
  }
@@ -732,7 +732,7 @@ class ContensisCli {
732
732
  log.success(
733
733
  messages.roles.created(currentEnv, role.id || role.name || "")
734
734
  );
735
- this.HandleFormattingAndOutput(created, log.object);
735
+ await this.HandleFormattingAndOutput(created, log.object);
736
736
  log.help(messages.roles.tip());
737
737
  return role.id;
738
738
  }
@@ -764,7 +764,7 @@ class ContensisCli {
764
764
  log.error(messages.roles.failedSet(currentEnv, roleNameOrId));
765
765
  else {
766
766
  log.success(messages.roles.set());
767
- this.HandleFormattingAndOutput(updated, log.object);
767
+ await this.HandleFormattingAndOutput(updated, log.object);
768
768
  }
769
769
  } else {
770
770
  log.error(messages.roles.failedGet(currentEnv, roleNameOrId));
@@ -813,7 +813,7 @@ class ContensisCli {
813
813
  var _a;
814
814
  return (_a = Object.values(o || {})) == null ? void 0 : _a[0];
815
815
  };
816
- this.HandleFormattingAndOutput(workflows, () => {
816
+ await this.HandleFormattingAndOutput(workflows, () => {
817
817
  for (const {
818
818
  id,
819
819
  name,
@@ -862,7 +862,7 @@ class ContensisCli {
862
862
  log.success(messages.workflows.list(currentEnv));
863
863
  const workflow = (0, import_find.findByIdOrName)(workflows, workflowNameOrId);
864
864
  if (workflow)
865
- this.HandleFormattingAndOutput(workflow, log.object);
865
+ await this.HandleFormattingAndOutput(workflow, log.object);
866
866
  else
867
867
  log.error(messages.workflows.failedGet(currentEnv, workflowNameOrId));
868
868
  }
@@ -879,7 +879,7 @@ class ContensisCli {
879
879
  const [err, created] = await contensis.projects.CreateProject(project);
880
880
  if (created) {
881
881
  log.success(messages.projects.created(currentEnv, project.id));
882
- this.HandleFormattingAndOutput(created, () => {
882
+ await this.HandleFormattingAndOutput(created, () => {
883
883
  this.SetProject(project.id);
884
884
  this.PrintProjects();
885
885
  });
@@ -900,7 +900,7 @@ class ContensisCli {
900
900
  });
901
901
  if (updated) {
902
902
  log.success(messages.projects.updated(currentEnv, currentProject));
903
- this.HandleFormattingAndOutput(updated, log.object);
903
+ await this.HandleFormattingAndOutput(updated, log.object);
904
904
  return updated.id;
905
905
  }
906
906
  if (err) {
@@ -948,7 +948,7 @@ class ContensisCli {
948
948
  ];
949
949
  if (Array.isArray(returnModels)) {
950
950
  log.success(messages.models.list(currentProject));
951
- this.HandleFormattingAndOutput(contentModelBackup, () => {
951
+ await this.HandleFormattingAndOutput(contentModelBackup, () => {
952
952
  for (const model of returnModels) {
953
953
  log.raw("");
954
954
  log.object(model);
@@ -961,7 +961,7 @@ class ContensisCli {
961
961
  );
962
962
  log.raw("");
963
963
  if (models == null ? void 0 : models.length) {
964
- this.HandleFormattingAndOutput(contentModelBackup, () => {
964
+ await this.HandleFormattingAndOutput(contentModelBackup, () => {
965
965
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
966
966
  for (const model of models) {
967
967
  const components2 = ((_a = model.components) == null ? void 0 : _a.length) || 0;
@@ -1005,7 +1005,7 @@ class ContensisCli {
1005
1005
  if (migrateErr)
1006
1006
  (0, import_logger.logError)(migrateErr);
1007
1007
  else
1008
- this.HandleFormattingAndOutput(result, () => {
1008
+ await this.HandleFormattingAndOutput(result, () => {
1009
1009
  if (!commit) {
1010
1010
  log.raw(log.boldText(`
1011
1011
  Content types:`));
@@ -1049,7 +1049,7 @@ Components:`));
1049
1049
  const contentTypes = await contensis.models.contentTypes();
1050
1050
  if (Array.isArray(contentTypes)) {
1051
1051
  log.success(messages.contenttypes.list(currentProject));
1052
- this.HandleFormattingAndOutput(contentTypes, () => {
1052
+ await this.HandleFormattingAndOutput(contentTypes, () => {
1053
1053
  var _a;
1054
1054
  for (const contentType of contentTypes) {
1055
1055
  const fieldsLength = ((_a = contentType.fields) == null ? void 0 : _a.length) || 0;
@@ -1074,7 +1074,7 @@ Components:`));
1074
1074
  log.success(
1075
1075
  messages.contenttypes.get(currentProject, contentType.id)
1076
1076
  );
1077
- this.HandleFormattingAndOutput(contentType, log.object);
1077
+ await this.HandleFormattingAndOutput(contentType, log.object);
1078
1078
  } else {
1079
1079
  log.error(
1080
1080
  messages.contenttypes.failedGet(currentProject, contentTypeId)
@@ -1107,7 +1107,7 @@ Components:`));
1107
1107
  !contensis.isPreview
1108
1108
  )
1109
1109
  );
1110
- this.HandleFormattingAndOutput(
1110
+ await this.HandleFormattingAndOutput(
1111
1111
  result,
1112
1112
  () => log.object((0, import_json.jsonFormatter)(result))
1113
1113
  );
@@ -1143,7 +1143,7 @@ Components:`));
1143
1143
  createStatus
1144
1144
  )
1145
1145
  );
1146
- this.HandleFormattingAndOutput(contentType, () => {
1146
+ await this.HandleFormattingAndOutput(contentType, () => {
1147
1147
  });
1148
1148
  }
1149
1149
  }
@@ -1169,7 +1169,7 @@ Components:`));
1169
1169
  if (err)
1170
1170
  log.error(err.message, err);
1171
1171
  if (result)
1172
- this.HandleFormattingAndOutput(result, () => {
1172
+ await this.HandleFormattingAndOutput(result, () => {
1173
1173
  var _a;
1174
1174
  log.success(
1175
1175
  `Queried models ${log.infoText(
@@ -1199,7 +1199,7 @@ Components:`));
1199
1199
  const components = await contensis.models.components();
1200
1200
  if (Array.isArray(components)) {
1201
1201
  log.success(messages.components.list(currentProject));
1202
- this.HandleFormattingAndOutput(components, () => {
1202
+ await this.HandleFormattingAndOutput(components, () => {
1203
1203
  var _a;
1204
1204
  for (const component of components) {
1205
1205
  const fieldsLength = ((_a = component.fields) == null ? void 0 : _a.length) || 0;
@@ -1222,7 +1222,7 @@ Components:`));
1222
1222
  );
1223
1223
  if (component) {
1224
1224
  log.success(messages.components.get(currentProject, component.id));
1225
- this.HandleFormattingAndOutput(component, log.object);
1225
+ await this.HandleFormattingAndOutput(component, log.object);
1226
1226
  } else {
1227
1227
  log.error(messages.components.failedGet(currentProject, componentId));
1228
1228
  }
@@ -1256,7 +1256,7 @@ Components:`));
1256
1256
  !contensis.isPreview
1257
1257
  )
1258
1258
  );
1259
- this.HandleFormattingAndOutput(
1259
+ await this.HandleFormattingAndOutput(
1260
1260
  result,
1261
1261
  () => log.info((0, import_json.jsonFormatter)(result))
1262
1262
  );
@@ -1292,7 +1292,7 @@ Components:`));
1292
1292
  createStatus
1293
1293
  )
1294
1294
  );
1295
- this.HandleFormattingAndOutput(component, () => {
1295
+ await this.HandleFormattingAndOutput(component, () => {
1296
1296
  });
1297
1297
  }
1298
1298
  }
@@ -1313,7 +1313,7 @@ Components:`));
1313
1313
  }
1314
1314
  const [err, result] = await contensis.DeleteEntries();
1315
1315
  if (result)
1316
- this.HandleFormattingAndOutput(result, () => {
1316
+ await this.HandleFormattingAndOutput(result, () => {
1317
1317
  (0, import_console.printEntriesMigrateResult)(this, result, {
1318
1318
  action: "delete",
1319
1319
  showAll: true
@@ -1340,7 +1340,7 @@ Components:`));
1340
1340
  if (contensis) {
1341
1341
  log.line();
1342
1342
  const entries = await contensis.GetEntries({ withDependents });
1343
- this.HandleFormattingAndOutput(
1343
+ await this.HandleFormattingAndOutput(
1344
1344
  entries,
1345
1345
  () => {
1346
1346
  var _a;
@@ -1379,9 +1379,10 @@ Components:`));
1379
1379
  if (err)
1380
1380
  (0, import_logger.logError)(err);
1381
1381
  else
1382
- this.HandleFormattingAndOutput(result, () => {
1382
+ await this.HandleFormattingAndOutput(result, () => {
1383
1383
  (0, import_console.printEntriesMigrateResult)(this, result, {
1384
1384
  showAll: logOutput === "all",
1385
+ showDiff: logOutput === "all" || logOutput === "changes",
1385
1386
  showChanged: logOutput === "changes"
1386
1387
  });
1387
1388
  });
@@ -1419,7 +1420,7 @@ Components:`));
1419
1420
  }
1420
1421
  const root = contensis.nodes.sourceRepo.nodes.tree;
1421
1422
  log.success(messages.nodes.get(currentProject, rootPath, depth));
1422
- this.HandleFormattingAndOutput(nodes, () => {
1423
+ await this.HandleFormattingAndOutput(nodes, () => {
1423
1424
  log.object({ ...root, children: void 0, language: void 0 });
1424
1425
  (0, import_console.printNodeTreeOutput)(this, root);
1425
1426
  });
@@ -1453,7 +1454,7 @@ Components:`));
1453
1454
  if (err)
1454
1455
  log.raw(``);
1455
1456
  else
1456
- this.HandleFormattingAndOutput(result, () => {
1457
+ await this.HandleFormattingAndOutput(result, () => {
1457
1458
  (0, import_console.printNodeTreeOutput)(this, migrateTree, logOutput, logLimit);
1458
1459
  (0, import_console.printNodesMigrateResult)(this, result, {
1459
1460
  showAll: logOutput === "all",
@@ -1508,7 +1509,7 @@ Components:`));
1508
1509
  }
1509
1510
  const [err, result] = await contensis.DeleteNodes();
1510
1511
  if (result) {
1511
- this.HandleFormattingAndOutput(result, () => {
1512
+ await this.HandleFormattingAndOutput(result, () => {
1512
1513
  (0, import_console.printNodeTreeOutput)(
1513
1514
  this,
1514
1515
  contensis.nodes.targetRepos[currentProject].nodes.migrateNodesTreeView
@@ -1550,7 +1551,7 @@ Components:`));
1550
1551
  if (!(webhooks == null ? void 0 : webhooks.length))
1551
1552
  log.warning(messages.webhooks.noneExist());
1552
1553
  else {
1553
- this.HandleFormattingAndOutput(filteredResults, () => {
1554
+ await this.HandleFormattingAndOutput(filteredResults, () => {
1554
1555
  for (const {
1555
1556
  id,
1556
1557
  description,
@@ -1611,7 +1612,7 @@ Components:`));
1611
1612
  if (contensis) {
1612
1613
  const [err, blocks] = await contensis.blocks.GetBlocks();
1613
1614
  if (Array.isArray(blocks)) {
1614
- this.HandleFormattingAndOutput(blocks, () => {
1615
+ await this.HandleFormattingAndOutput(blocks, () => {
1615
1616
  log.success(messages.blocks.list(currentEnv, env.currentProject));
1616
1617
  for (const {
1617
1618
  id,
@@ -1648,7 +1649,7 @@ Components:`));
1648
1649
  version
1649
1650
  );
1650
1651
  if (blocks) {
1651
- this.HandleFormattingAndOutput(blocks, () => {
1652
+ await this.HandleFormattingAndOutput(blocks, () => {
1652
1653
  log.success(
1653
1654
  messages.blocks.get(blockId, currentEnv, env.currentProject)
1654
1655
  );
@@ -1699,7 +1700,7 @@ Components:`));
1699
1700
  );
1700
1701
  }
1701
1702
  if (blockVersion) {
1702
- this.HandleFormattingAndOutput(blockVersion, () => {
1703
+ await this.HandleFormattingAndOutput(blockVersion, () => {
1703
1704
  (0, import_console.printBlockVersion)(this, blockVersion);
1704
1705
  });
1705
1706
  }
@@ -1764,7 +1765,7 @@ Components:`));
1764
1765
  actionOnBlockVersion
1765
1766
  );
1766
1767
  if (blockVersion) {
1767
- this.HandleFormattingAndOutput(blockVersion, () => {
1768
+ await this.HandleFormattingAndOutput(blockVersion, () => {
1768
1769
  log.success(
1769
1770
  messages.blocks.actionComplete(
1770
1771
  action,
@@ -1810,7 +1811,7 @@ Components:`));
1810
1811
  } else if (blockLogs) {
1811
1812
  const removeTrailingNewline = (logs) => logs.endsWith("\n") ? logs.slice(0, logs.length - 1) : logs;
1812
1813
  const renderLogs = removeTrailingNewline(blockLogs);
1813
- this.HandleFormattingAndOutput(renderLogs, () => {
1814
+ await this.HandleFormattingAndOutput(renderLogs, () => {
1814
1815
  console.log(
1815
1816
  ` - ${blockId} ${branch} ${Number(version) ? `v${version}` : version} ${dataCenter ? `[${dataCenter}]` : ""}`
1816
1817
  );
@@ -1886,7 +1887,7 @@ Components:`));
1886
1887
  proxyId
1887
1888
  );
1888
1889
  if (Array.isArray(proxies)) {
1889
- this.HandleFormattingAndOutput(proxies, () => {
1890
+ await this.HandleFormattingAndOutput(proxies, () => {
1890
1891
  log.success(messages.proxies.list(currentEnv, env.currentProject));
1891
1892
  for (const { id, name, description, endpoints, version } of proxies) {
1892
1893
  console.log(
@@ -1918,7 +1919,7 @@ Components:`));
1918
1919
  rendererId
1919
1920
  );
1920
1921
  if (Array.isArray(renderers)) {
1921
- this.HandleFormattingAndOutput(renderers, () => {
1922
+ await this.HandleFormattingAndOutput(renderers, () => {
1922
1923
  log.success(messages.renderers.list(currentEnv, env.currentProject));
1923
1924
  for (const {
1924
1925
  id,
@@ -1950,7 +1951,7 @@ Components:`));
1950
1951
  }
1951
1952
  }
1952
1953
  };
1953
- HandleFormattingAndOutput = (obj, logFn) => {
1954
+ HandleFormattingAndOutput = async (obj, logFn) => {
1954
1955
  var _a, _b;
1955
1956
  const { format, log, messages, output } = this;
1956
1957
  const fields = (_b = (_a = this.contensis) == null ? void 0 : _a.payload.query) == null ? void 0 : _b.fields;
@@ -1958,7 +1959,7 @@ Components:`));
1958
1959
  logFn(obj);
1959
1960
  } else if (format === "csv") {
1960
1961
  log.raw("");
1961
- log.raw(log.infoText((0, import_csv.csvFormatter)((0, import_json.limitFields)(obj, fields))));
1962
+ log.raw(log.infoText(await (0, import_csv.csvFormatter)((0, import_json.limitFields)(obj, fields))));
1962
1963
  } else if (format === "xml") {
1963
1964
  log.raw("");
1964
1965
  log.raw(log.infoText((0, import_xml.xmlFormatter)((0, import_json.limitFields)(obj, fields))));
@@ -1971,7 +1972,7 @@ Components:`));
1971
1972
  let writeString = "";
1972
1973
  const isText = !(0, import_util.tryParse)(obj) && typeof obj === "string";
1973
1974
  if (format === "csv") {
1974
- writeString = (0, import_csv.csvFormatter)((0, import_json.limitFields)(obj, fields));
1975
+ writeString = await (0, import_csv.csvFormatter)((0, import_json.limitFields)(obj, fields));
1975
1976
  } else if (format === "xml") {
1976
1977
  writeString = (0, import_xml.xmlFormatter)((0, import_json.limitFields)(obj, fields));
1977
1978
  } else