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

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.
@@ -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": ";;;;;;;;;;;;;;;;;;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,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C,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,MAAM,EACd,YAAY,4CAA4C,EACxD;AAAA,IACC;AAAA,IACA;AAAA;AAAA;AAAA;AAAA,EAIF,EACC,OAAO,OAAM,SAAQ;AACpB,cAAM,uCAAW,CAAC,QAAQ,MAAM,GAAG,IAAI,EAAE,kBAAkB;AAAA,EAC7D,CAAC;AAEH,OACG,QAAQ,UA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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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QAAQ;AAC9B,UAAI;AAAK,eAAO,EAAE,UAAU,UAAU,MAAM,MAAM;AAAA,IACpD;AAAA,EACF,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,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 = (\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 = 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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AI,WAAW,YAAAA,QAAK,KAAK,QAAQ,IAAI,GAAG,QAAQ;AAM1E,MAAM,iBAAiB,CACrB,aACiC;AACjC,MAAI;AACF,UAAM,WAAW,SAAS,QAAQ;AAClC,QAAI,UAAU;AAEZ,UAAI,SAAS,WAAW,GAAG;AAAG,eAAO,EAAE,UAAU,UAAU,MAAM,MAAM;AAGvE,YAAM,eAAW,sBAAS,QAAQ;AAClC,UAAI;AAAU,eAAO,EAAE,UAAU,UAAU,MAAM,OAAO;AAGxD,YAAM,UAAM,sBAAU,QAAQ;AAC9B,UAAI;AAAK,eAAO,EAAE,UAAU,UAAU,MAAM,MAAM;AAAA,IACpD;AAAA,EACF,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,7 +1379,7 @@ 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
1385
  showChanged: logOutput === "changes"
@@ -1419,7 +1419,7 @@ Components:`));
1419
1419
  }
1420
1420
  const root = contensis.nodes.sourceRepo.nodes.tree;
1421
1421
  log.success(messages.nodes.get(currentProject, rootPath, depth));
1422
- this.HandleFormattingAndOutput(nodes, () => {
1422
+ await this.HandleFormattingAndOutput(nodes, () => {
1423
1423
  log.object({ ...root, children: void 0, language: void 0 });
1424
1424
  (0, import_console.printNodeTreeOutput)(this, root);
1425
1425
  });
@@ -1453,7 +1453,7 @@ Components:`));
1453
1453
  if (err)
1454
1454
  log.raw(``);
1455
1455
  else
1456
- this.HandleFormattingAndOutput(result, () => {
1456
+ await this.HandleFormattingAndOutput(result, () => {
1457
1457
  (0, import_console.printNodeTreeOutput)(this, migrateTree, logOutput, logLimit);
1458
1458
  (0, import_console.printNodesMigrateResult)(this, result, {
1459
1459
  showAll: logOutput === "all",
@@ -1508,7 +1508,7 @@ Components:`));
1508
1508
  }
1509
1509
  const [err, result] = await contensis.DeleteNodes();
1510
1510
  if (result) {
1511
- this.HandleFormattingAndOutput(result, () => {
1511
+ await this.HandleFormattingAndOutput(result, () => {
1512
1512
  (0, import_console.printNodeTreeOutput)(
1513
1513
  this,
1514
1514
  contensis.nodes.targetRepos[currentProject].nodes.migrateNodesTreeView
@@ -1550,7 +1550,7 @@ Components:`));
1550
1550
  if (!(webhooks == null ? void 0 : webhooks.length))
1551
1551
  log.warning(messages.webhooks.noneExist());
1552
1552
  else {
1553
- this.HandleFormattingAndOutput(filteredResults, () => {
1553
+ await this.HandleFormattingAndOutput(filteredResults, () => {
1554
1554
  for (const {
1555
1555
  id,
1556
1556
  description,
@@ -1611,7 +1611,7 @@ Components:`));
1611
1611
  if (contensis) {
1612
1612
  const [err, blocks] = await contensis.blocks.GetBlocks();
1613
1613
  if (Array.isArray(blocks)) {
1614
- this.HandleFormattingAndOutput(blocks, () => {
1614
+ await this.HandleFormattingAndOutput(blocks, () => {
1615
1615
  log.success(messages.blocks.list(currentEnv, env.currentProject));
1616
1616
  for (const {
1617
1617
  id,
@@ -1648,7 +1648,7 @@ Components:`));
1648
1648
  version
1649
1649
  );
1650
1650
  if (blocks) {
1651
- this.HandleFormattingAndOutput(blocks, () => {
1651
+ await this.HandleFormattingAndOutput(blocks, () => {
1652
1652
  log.success(
1653
1653
  messages.blocks.get(blockId, currentEnv, env.currentProject)
1654
1654
  );
@@ -1699,7 +1699,7 @@ Components:`));
1699
1699
  );
1700
1700
  }
1701
1701
  if (blockVersion) {
1702
- this.HandleFormattingAndOutput(blockVersion, () => {
1702
+ await this.HandleFormattingAndOutput(blockVersion, () => {
1703
1703
  (0, import_console.printBlockVersion)(this, blockVersion);
1704
1704
  });
1705
1705
  }
@@ -1764,7 +1764,7 @@ Components:`));
1764
1764
  actionOnBlockVersion
1765
1765
  );
1766
1766
  if (blockVersion) {
1767
- this.HandleFormattingAndOutput(blockVersion, () => {
1767
+ await this.HandleFormattingAndOutput(blockVersion, () => {
1768
1768
  log.success(
1769
1769
  messages.blocks.actionComplete(
1770
1770
  action,
@@ -1810,7 +1810,7 @@ Components:`));
1810
1810
  } else if (blockLogs) {
1811
1811
  const removeTrailingNewline = (logs) => logs.endsWith("\n") ? logs.slice(0, logs.length - 1) : logs;
1812
1812
  const renderLogs = removeTrailingNewline(blockLogs);
1813
- this.HandleFormattingAndOutput(renderLogs, () => {
1813
+ await this.HandleFormattingAndOutput(renderLogs, () => {
1814
1814
  console.log(
1815
1815
  ` - ${blockId} ${branch} ${Number(version) ? `v${version}` : version} ${dataCenter ? `[${dataCenter}]` : ""}`
1816
1816
  );
@@ -1886,7 +1886,7 @@ Components:`));
1886
1886
  proxyId
1887
1887
  );
1888
1888
  if (Array.isArray(proxies)) {
1889
- this.HandleFormattingAndOutput(proxies, () => {
1889
+ await this.HandleFormattingAndOutput(proxies, () => {
1890
1890
  log.success(messages.proxies.list(currentEnv, env.currentProject));
1891
1891
  for (const { id, name, description, endpoints, version } of proxies) {
1892
1892
  console.log(
@@ -1918,7 +1918,7 @@ Components:`));
1918
1918
  rendererId
1919
1919
  );
1920
1920
  if (Array.isArray(renderers)) {
1921
- this.HandleFormattingAndOutput(renderers, () => {
1921
+ await this.HandleFormattingAndOutput(renderers, () => {
1922
1922
  log.success(messages.renderers.list(currentEnv, env.currentProject));
1923
1923
  for (const {
1924
1924
  id,
@@ -1950,7 +1950,7 @@ Components:`));
1950
1950
  }
1951
1951
  }
1952
1952
  };
1953
- HandleFormattingAndOutput = (obj, logFn) => {
1953
+ HandleFormattingAndOutput = async (obj, logFn) => {
1954
1954
  var _a, _b;
1955
1955
  const { format, log, messages, output } = this;
1956
1956
  const fields = (_b = (_a = this.contensis) == null ? void 0 : _a.payload.query) == null ? void 0 : _b.fields;
@@ -1958,7 +1958,7 @@ Components:`));
1958
1958
  logFn(obj);
1959
1959
  } else if (format === "csv") {
1960
1960
  log.raw("");
1961
- log.raw(log.infoText((0, import_csv.csvFormatter)((0, import_json.limitFields)(obj, fields))));
1961
+ log.raw(log.infoText(await (0, import_csv.csvFormatter)((0, import_json.limitFields)(obj, fields))));
1962
1962
  } else if (format === "xml") {
1963
1963
  log.raw("");
1964
1964
  log.raw(log.infoText((0, import_xml.xmlFormatter)((0, import_json.limitFields)(obj, fields))));
@@ -1971,7 +1971,7 @@ Components:`));
1971
1971
  let writeString = "";
1972
1972
  const isText = !(0, import_util.tryParse)(obj) && typeof obj === "string";
1973
1973
  if (format === "csv") {
1974
- writeString = (0, import_csv.csvFormatter)((0, import_json.limitFields)(obj, fields));
1974
+ writeString = await (0, import_csv.csvFormatter)((0, import_json.limitFields)(obj, fields));
1975
1975
  } else if (format === "xml") {
1976
1976
  writeString = (0, import_xml.xmlFormatter)((0, import_json.limitFields)(obj, fields));
1977
1977
  } else