contensis-cli 1.0.12-beta.5 → 1.0.12-beta.7
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/commands/get.js +12 -0
- package/dist/commands/get.js.map +2 -2
- package/dist/commands/import.js +10 -5
- package/dist/commands/import.js.map +2 -2
- package/dist/commands/list.js +9 -0
- package/dist/commands/list.js.map +2 -2
- package/dist/localisation/en-GB.js +6 -0
- package/dist/localisation/en-GB.js.map +2 -2
- package/dist/providers/file-provider.js +5 -1
- package/dist/providers/file-provider.js.map +2 -2
- package/dist/services/ContensisCliService.js +88 -11
- package/dist/services/ContensisCliService.js.map +2 -2
- package/dist/shell.js +2 -0
- package/dist/shell.js.map +2 -2
- package/dist/util/console.printer.js +49 -45
- package/dist/util/console.printer.js.map +3 -3
- package/dist/util/error.js +36 -0
- package/dist/util/error.js.map +7 -0
- package/dist/util/find.js +10 -2
- package/dist/util/find.js.map +2 -2
- package/dist/util/logger.js +48 -9
- package/dist/util/logger.js.map +3 -3
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/package.json +2 -2
- package/src/commands/get.ts +18 -0
- package/src/commands/import.ts +10 -4
- package/src/commands/list.ts +15 -0
- package/src/localisation/en-GB.ts +7 -0
- package/src/providers/file-provider.ts +5 -1
- package/src/services/ContensisCliService.ts +111 -11
- package/src/shell.ts +2 -0
- package/src/util/console.printer.ts +118 -54
- package/src/util/error.ts +7 -0
- package/src/util/find.ts +13 -2
- package/src/util/logger.ts +90 -17
- package/src/version.ts +1 -1
package/dist/shell.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/shell.ts"],
|
|
4
|
-
"sourcesContent": ["import figlet from 'figlet';\nimport inquirer from 'inquirer';\nimport inquirerPrompt from 'inquirer-command-prompt';\nimport commands from './commands';\nimport { LogMessages } from './localisation/en-GB';\nimport CredentialProvider from './providers/CredentialProvider';\nimport { appRootDir } from './providers/file-provider';\nimport ContensisCli, { cliCommand } from './services/ContensisCliService';\nimport { Logging } from './util';\nimport { logError, Logger } from './util/logger';\nimport { LIB_VERSION } from './version';\n\nclass ContensisShell {\n private currentEnvironment!: string;\n private emptyInputCounter: number = 0;\n private env!: EnvironmentCache;\n private firstStart = true;\n private userId: string = '';\n private log = Logger;\n private messages = LogMessages;\n\n private refreshEnvironment = () => {\n // Reload any persisted changes from the disk cache\n const {\n cache: { currentEnvironment = '', environments = {} },\n } = new ContensisCli([]);\n // console.log(`refreshing env w/${currentEnvironment}`);\n this.currentEnvironment = currentEnvironment;\n this.env = environments[currentEnvironment];\n\n // Reload logging here to support changing language\n Logging('en-GB').then(({ messages, Log }) => {\n this.log = Log;\n this.messages = messages;\n });\n };\n\n constructor() {\n this.refreshEnvironment();\n inquirerPrompt.setConfig({\n history: {\n save: true,\n folder: appRootDir,\n limit: 100,\n blacklist: ['quit'],\n },\n });\n\n const { log, messages } = this;\n\n figlet.text(\n messages.app.contensis(),\n {\n font: 'Block',\n horizontalLayout: 'default',\n verticalLayout: 'default',\n width: process.stdout.columns,\n whitespaceBreak: true,\n },\n (err, data) => {\n if (err) {\n log.error(messages.app.unknownError());\n console.dir(err);\n return;\n }\n console.log(log.successText(data));\n console.log(log.infoText(messages.app.startup(LIB_VERSION)));\n console.log(log.helpText(messages.app.help()));\n\n this.start().catch(ex => log.error(ex));\n }\n );\n }\n\n restart = async () => {\n this.firstStart = false;\n this.log.line(); // add a line so we can see where the shell has been restarted\n await this.start();\n };\n\n start = async () => {\n this.refreshEnvironment();\n this.userId = '';\n const { currentEnvironment, env, log, messages } = this;\n\n if (env?.lastUserId) {\n const [credsErr, credentials] = await new CredentialProvider(\n {\n userId: env.lastUserId,\n alias: currentEnvironment,\n },\n env.passwordFallback\n ).Init();\n if (credsErr && !credentials.current) {\n log.error(credsErr.message);\n }\n if (credentials.current) {\n if (this.firstStart) {\n const token = await cliCommand(['login', env.lastUserId]).Login(\n env.lastUserId,\n {\n promptPassword: false,\n silent: true,\n }\n );\n if (token) {\n this.userId = env.lastUserId;\n if (!env.currentProject) log.warning(messages.projects.tip());\n }\n this.firstStart = false;\n this.refreshEnvironment();\n } else {\n this.userId = env.lastUserId;\n }\n }\n }\n await this.contensisPrompt();\n };\n\n contensisPrompt = async (): Promise<any> => {\n const { currentEnvironment, env, log, messages, userId } = this;\n\n const availableCommands = [\n {\n filter: (str: string) => {\n return str.replace(/ \\[.*$/, '');\n },\n },\n 'connect',\n 'list envs',\n 'quit',\n ];\n\n if (currentEnvironment)\n availableCommands.push('login', 'list projects', 'set project');\n if (userId)\n availableCommands.push(\n 'create key',\n 'create project',\n 'create role',\n 'diff models',\n 'execute block action release',\n 'execute block action makelive',\n 'execute block action rollback',\n 'execute block action markasbroken',\n 'get assets',\n 'get block',\n 'get block logs',\n 'get contenttype',\n 'get component',\n 'get entries',\n 'get nodes',\n 'get model',\n 'get project',\n 'get role',\n 'get token',\n 'get version',\n 'get webhook',\n 'import contenttypes',\n 'import components',\n 'import entries',\n 'import models',\n 'import nodes',\n 'list blocks',\n 'list contenttypes',\n 'list components',\n 'list keys',\n 'list models',\n 'list proxies',\n 'list renderers',\n 'list roles',\n 'list webhooks',\n 'push block',\n 'remove components',\n 'remove contenttypes',\n 'remove key',\n 'remove entries',\n 'remove role',\n 'set project name',\n 'set project description',\n 'set role name',\n 'set role description',\n 'set role assignments',\n 'set role enabled',\n 'set role permissions'\n );\n\n const prompt = inquirer.createPromptModule();\n prompt.registerPrompt('command', inquirerPrompt);\n return prompt([\n {\n type: 'command',\n name: 'cmd',\n autoCompletion: availableCommands.sort(),\n autocompletePrompt: log.infoText(messages.app.autocomplete()),\n message: `${userId ? `${userId}@` : ''}${currentEnvironment || ''}>`,\n context: 0,\n validate: (val: string) => {\n if (!val) this.emptyInputCounter++;\n if (this.emptyInputCounter > 1)\n console.log(this.log.infoText(this.messages.app.suggestions()));\n if (val) {\n this.emptyInputCounter = 0;\n return true;\n }\n },\n prefix: `${env?.currentProject || log.infoText('contensis')}`,\n short: true,\n },\n ])\n .then(async (answers: { cmd: string }) => {\n if (answers.cmd === 'quit') {\n this.quit();\n } else {\n try {\n if (answers.cmd) {\n const program = commands();\n await program.parseAsync(\n answers.cmd\n .match(/\"[^\"]+\"|[^\\s]+/g)\n ?.map(e => e.replace(/\"(.+)\"/, '$1')),\n {\n from: 'user',\n }\n );\n }\n } catch (ex: any) {\n const str = ex.toString();\n if (!str.includes('CommanderError'))\n logError(\n ex,\n `Shell ${\n ex instanceof Error\n ? ex.toString()\n : JSON.stringify(ex, null, 2)\n }`\n );\n } finally {\n return this.contensisPrompt();\n }\n }\n })\n .catch((err: Error) => {\n log.error(err.message);\n this.quit();\n });\n };\n\n quit = (error?: Error) => {\n const { log, messages } = this;\n process.removeAllListeners('exit');\n\n if (error) {\n log.error(error.message);\n process.exit(1);\n } else {\n log.success(messages.app.quit());\n process.exitCode = 0;\n process.exit(0);\n }\n };\n}\n\nlet globalShell: ContensisShell;\n\nexport const shell = () => {\n // Return a benign function for shell().restart() when used in cli context\n // as some commands need to restart the shell to show an updated prompt\n // after successful connect / login / set project\n if (typeof process.argv?.[2] !== 'undefined')\n return {\n quit: ContensisCli.quit,\n restart() {},\n } as any;\n if (!globalShell) globalShell = new ContensisShell();\n return globalShell;\n};\n\nprocess.on('uncaughtException', function (err) {\n // Handle the error safely\n console.log(err);\n});\n\nprocess.on('SIGINT', () => {\n Logger.warning('received SIGINT');\n shell().quit();\n // setTimeout(() => {\n // }, 2000);\n});\n\nprocess.on('SIGTERM', () => {\n Logger.warning('received SIGTERM');\n shell().quit();\n});\n\nprocess.stdin.on('data', key => {\n if ((key as any) == '\\u0003') {\n console.log('');\n Logger.info(`[CTRL]+[C] detected, exiting shell...`);\n shell().quit();\n }\n});\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAmB;AACnB,sBAAqB;AACr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AAC;AAChE,cAAI,KAAK;AACP,iBAAK,oBAAoB;AACzB,mBAAO;AAAA,UACT;AAAA,QACF;AAAA,QACA,QAAQ,IAAG,2BAAK,mBAAkB,IAAI,SAAS,WAAW;AAAA,QAC1D,OAAO;AAAA,MACT;AAAA,IACF,CAAC,EACE,KAAK,OAAO,YAA6B;
|
|
4
|
+
"sourcesContent": ["import figlet from 'figlet';\nimport inquirer from 'inquirer';\nimport inquirerPrompt from 'inquirer-command-prompt';\nimport commands from './commands';\nimport { LogMessages } from './localisation/en-GB';\nimport CredentialProvider from './providers/CredentialProvider';\nimport { appRootDir } from './providers/file-provider';\nimport ContensisCli, { cliCommand } from './services/ContensisCliService';\nimport { Logging } from './util';\nimport { logError, Logger } from './util/logger';\nimport { LIB_VERSION } from './version';\n\nclass ContensisShell {\n private currentEnvironment!: string;\n private emptyInputCounter: number = 0;\n private env!: EnvironmentCache;\n private firstStart = true;\n private userId: string = '';\n private log = Logger;\n private messages = LogMessages;\n\n private refreshEnvironment = () => {\n // Reload any persisted changes from the disk cache\n const {\n cache: { currentEnvironment = '', environments = {} },\n } = new ContensisCli([]);\n // console.log(`refreshing env w/${currentEnvironment}`);\n this.currentEnvironment = currentEnvironment;\n this.env = environments[currentEnvironment];\n\n // Reload logging here to support changing language\n Logging('en-GB').then(({ messages, Log }) => {\n this.log = Log;\n this.messages = messages;\n });\n };\n\n constructor() {\n this.refreshEnvironment();\n inquirerPrompt.setConfig({\n history: {\n save: true,\n folder: appRootDir,\n limit: 100,\n blacklist: ['quit'],\n },\n });\n\n const { log, messages } = this;\n\n figlet.text(\n messages.app.contensis(),\n {\n font: 'Block',\n horizontalLayout: 'default',\n verticalLayout: 'default',\n width: process.stdout.columns,\n whitespaceBreak: true,\n },\n (err, data) => {\n if (err) {\n log.error(messages.app.unknownError());\n console.dir(err);\n return;\n }\n console.log(log.successText(data));\n console.log(log.infoText(messages.app.startup(LIB_VERSION)));\n console.log(log.helpText(messages.app.help()));\n\n this.start().catch(ex => log.error(ex));\n }\n );\n }\n\n restart = async () => {\n this.firstStart = false;\n this.log.line(); // add a line so we can see where the shell has been restarted\n await this.start();\n };\n\n start = async () => {\n this.refreshEnvironment();\n this.userId = '';\n const { currentEnvironment, env, log, messages } = this;\n\n if (env?.lastUserId) {\n const [credsErr, credentials] = await new CredentialProvider(\n {\n userId: env.lastUserId,\n alias: currentEnvironment,\n },\n env.passwordFallback\n ).Init();\n if (credsErr && !credentials.current) {\n log.error(credsErr.message);\n }\n if (credentials.current) {\n if (this.firstStart) {\n const token = await cliCommand(['login', env.lastUserId]).Login(\n env.lastUserId,\n {\n promptPassword: false,\n silent: true,\n }\n );\n if (token) {\n this.userId = env.lastUserId;\n if (!env.currentProject) log.warning(messages.projects.tip());\n }\n this.firstStart = false;\n this.refreshEnvironment();\n } else {\n this.userId = env.lastUserId;\n }\n }\n }\n await this.contensisPrompt();\n };\n\n contensisPrompt = async (): Promise<any> => {\n const { currentEnvironment, env, log, messages, userId } = this;\n\n const availableCommands = [\n {\n filter: (str: string) => {\n return str.replace(/ \\[.*$/, '');\n },\n },\n 'connect',\n 'list envs',\n 'quit',\n ];\n\n if (currentEnvironment)\n availableCommands.push('login', 'list projects', 'set project');\n if (userId)\n availableCommands.push(\n 'create key',\n 'create project',\n 'create role',\n 'diff models',\n 'execute block action release',\n 'execute block action makelive',\n 'execute block action rollback',\n 'execute block action markasbroken',\n 'get assets',\n 'get block',\n 'get block logs',\n 'get contenttype',\n 'get component',\n 'get entries',\n 'get nodes',\n 'get model',\n 'get project',\n 'get role',\n 'get token',\n 'get version',\n 'get webhook',\n 'get workflow',\n 'import contenttypes',\n 'import components',\n 'import entries',\n 'import models',\n 'import nodes',\n 'list blocks',\n 'list contenttypes',\n 'list components',\n 'list keys',\n 'list models',\n 'list proxies',\n 'list renderers',\n 'list roles',\n 'list webhooks',\n 'list workflows',\n 'push block',\n 'remove components',\n 'remove contenttypes',\n 'remove key',\n 'remove entries',\n 'remove role',\n 'set project name',\n 'set project description',\n 'set role name',\n 'set role description',\n 'set role assignments',\n 'set role enabled',\n 'set role permissions'\n );\n\n const prompt = inquirer.createPromptModule();\n prompt.registerPrompt('command', inquirerPrompt);\n return prompt([\n {\n type: 'command',\n name: 'cmd',\n autoCompletion: availableCommands.sort(),\n autocompletePrompt: log.infoText(messages.app.autocomplete()),\n message: `${userId ? `${userId}@` : ''}${currentEnvironment || ''}>`,\n context: 0,\n validate: (val: string) => {\n if (!val) this.emptyInputCounter++;\n if (this.emptyInputCounter > 1)\n console.log(this.log.infoText(this.messages.app.suggestions()));\n if (val) {\n this.emptyInputCounter = 0;\n return true;\n }\n },\n prefix: `${env?.currentProject || log.infoText('contensis')}`,\n short: true,\n },\n ])\n .then(async (answers: { cmd: string }) => {\n if (answers.cmd === 'quit') {\n this.quit();\n } else {\n try {\n if (answers.cmd) {\n const program = commands();\n await program.parseAsync(\n answers.cmd\n .match(/\"[^\"]+\"|[^\\s]+/g)\n ?.map(e => e.replace(/\"(.+)\"/, '$1')),\n {\n from: 'user',\n }\n );\n }\n } catch (ex: any) {\n const str = ex.toString();\n if (!str.includes('CommanderError'))\n logError(\n ex,\n `Shell ${\n ex instanceof Error\n ? ex.toString()\n : JSON.stringify(ex, null, 2)\n }`\n );\n } finally {\n return this.contensisPrompt();\n }\n }\n })\n .catch((err: Error) => {\n log.error(err.message);\n this.quit();\n });\n };\n\n quit = (error?: Error) => {\n const { log, messages } = this;\n process.removeAllListeners('exit');\n\n if (error) {\n log.error(error.message);\n process.exit(1);\n } else {\n log.success(messages.app.quit());\n process.exitCode = 0;\n process.exit(0);\n }\n };\n}\n\nlet globalShell: ContensisShell;\n\nexport const shell = () => {\n // Return a benign function for shell().restart() when used in cli context\n // as some commands need to restart the shell to show an updated prompt\n // after successful connect / login / set project\n if (typeof process.argv?.[2] !== 'undefined')\n return {\n quit: ContensisCli.quit,\n restart() {},\n } as any;\n if (!globalShell) globalShell = new ContensisShell();\n return globalShell;\n};\n\nprocess.on('uncaughtException', function (err) {\n // Handle the error safely\n console.log(err);\n});\n\nprocess.on('SIGINT', () => {\n Logger.warning('received SIGINT');\n shell().quit();\n // setTimeout(() => {\n // }, 2000);\n});\n\nprocess.on('SIGTERM', () => {\n Logger.warning('received SIGTERM');\n shell().quit();\n});\n\nprocess.stdin.on('data', key => {\n if ((key as any) == '\\u0003') {\n console.log('');\n Logger.info(`[CTRL]+[C] detected, exiting shell...`);\n shell().quit();\n }\n});\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAmB;AACnB,sBAAqB;AACrB,qCAA2B;AAC3B,sBAAqB;AACrB,mBAA4B;AAC5B,gCAA+B;AAC/B,2BAA2B;AAC3B,iCAAyC;AACzC,kBAAwB;AACxB,oBAAiC;AACjC,qBAA4B;AAE5B,MAAM,eAAe;AAAA,EACX;AAAA,EACA,oBAA4B;AAAA,EAC5B;AAAA,EACA,aAAa;AAAA,EACb,SAAiB;AAAA,EACjB,MAAM;AAAA,EACN,WAAW;AAAA,EAEX,qBAAqB,MAAM;AAEjC,UAAM;AAAA,MACJ,OAAO,EAAE,qBAAqB,IAAI,eAAe,CAAC,EAAE;AAAA,IACtD,IAAI,IAAI,2BAAAA,QAAa,CAAC,CAAC;AAEvB,SAAK,qBAAqB;AAC1B,SAAK,MAAM,aAAa;AAGxB,6BAAQ,OAAO,EAAE,KAAK,CAAC,EAAE,UAAU,IAAI,MAAM;AAC3C,WAAK,MAAM;AACX,WAAK,WAAW;AAAA,IAClB,CAAC;AAAA,EACH;AAAA,EAEA,cAAc;AACZ,SAAK,mBAAmB;AACxB,mCAAAC,QAAe,UAAU;AAAA,MACvB,SAAS;AAAA,QACP,MAAM;AAAA,QACN,QAAQ;AAAA,QACR,OAAO;AAAA,QACP,WAAW,CAAC,MAAM;AAAA,MACpB;AAAA,IACF,CAAC;AAED,UAAM,EAAE,KAAK,SAAS,IAAI;AAE1B,kBAAAC,QAAO;AAAA,MACL,SAAS,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;AACrB,UAAI,MAAM,IAAI,OAAO;AACrB,WAAK,KAAK;AAAA,IACZ,CAAC;AAAA,EACL;AAAA,EAEA,OAAO,CAAC,UAAkB;AACxB,UAAM,EAAE,KAAK,SAAS,IAAI;AAC1B,YAAQ,mBAAmB,MAAM;AAEjC,QAAI,OAAO;AACT,UAAI,MAAM,MAAM,OAAO;AACvB,cAAQ,KAAK,CAAC;AAAA,IAChB,OAAO;AACL,UAAI,QAAQ,SAAS,IAAI,KAAK,CAAC;AAC/B,cAAQ,WAAW;AACnB,cAAQ,KAAK,CAAC;AAAA,IAChB;AAAA,EACF;AACF;AAEA,IAAI;AAEG,MAAM,QAAQ,MAAM;AA3Q3B;AA+QE,MAAI,SAAO,aAAQ,SAAR,mBAAe,QAAO;AAC/B,WAAO;AAAA,MACL,MAAM,2BAAAL,QAAa;AAAA,MACnB,UAAU;AAAA,MAAC;AAAA,IACb;AACF,MAAI,CAAC;AAAa,kBAAc,IAAI,eAAe;AACnD,SAAO;AACT;AAEA,QAAQ,GAAG,qBAAqB,SAAU,KAAK;AAE7C,UAAQ,IAAI,GAAG;AACjB,CAAC;AAED,QAAQ,GAAG,UAAU,MAAM;AACzB,uBAAO,QAAQ,iBAAiB;AAChC,QAAM,EAAE,KAAK;AAGf,CAAC;AAED,QAAQ,GAAG,WAAW,MAAM;AAC1B,uBAAO,QAAQ,kBAAkB;AACjC,QAAM,EAAE,KAAK;AACf,CAAC;AAED,QAAQ,MAAM,GAAG,QAAQ,SAAO;AAC9B,MAAK,OAAe,KAAU;AAC5B,YAAQ,IAAI,EAAE;AACd,yBAAO,KAAK,uCAAuC;AACnD,UAAM,EAAE,KAAK;AAAA,EACf;AACF,CAAC;",
|
|
6
6
|
"names": ["ContensisCli", "inquirerPrompt", "figlet", "CredentialProvider", "inquirer", "commands"]
|
|
7
7
|
}
|
|
@@ -33,6 +33,7 @@ __export(console_printer_exports, {
|
|
|
33
33
|
});
|
|
34
34
|
module.exports = __toCommonJS(console_printer_exports);
|
|
35
35
|
var import_dayjs = __toESM(require("dayjs"));
|
|
36
|
+
var import_error = require("./error");
|
|
36
37
|
var import_logger = require("./logger");
|
|
37
38
|
const formatDate = (date, format = "DD/MM/YYYY HH:mm") => (0, import_dayjs.default)(date).format(format);
|
|
38
39
|
const printBlockVersion = ({ log, messages }, block, printOptions = {
|
|
@@ -209,36 +210,14 @@ const printEntriesMigrateResult = ({ log, messages, currentProject }, migrateRes
|
|
|
209
210
|
log.error(error.message, null, "");
|
|
210
211
|
}
|
|
211
212
|
};
|
|
212
|
-
const printNodesMigrateResult = ({ log,
|
|
213
|
+
const printNodesMigrateResult = ({ log, currentProject }, migrateResult, {
|
|
213
214
|
action = "import",
|
|
215
|
+
logLimit = 50,
|
|
214
216
|
showDiff = false,
|
|
215
217
|
showAll = false,
|
|
216
218
|
showChanged = false
|
|
217
219
|
} = {}) => {
|
|
218
|
-
var _a, _b, _c
|
|
219
|
-
console.log(``);
|
|
220
|
-
for (const [originalId, migrateNodeId] of Object.entries(
|
|
221
|
-
migrateResult.nodesToMigrate.nodeIds
|
|
222
|
-
)) {
|
|
223
|
-
if (showAll || showChanged && migrateNodeId.status !== "no change") {
|
|
224
|
-
console.log(
|
|
225
|
-
log.infoText(
|
|
226
|
-
`${originalId} ${`${messages.migrate.status(migrateNodeId.status)(
|
|
227
|
-
`${migrateNodeId.status}`
|
|
228
|
-
)}${migrateNodeId.id !== originalId ? `-> ${migrateNodeId.id}` : ""}`}`
|
|
229
|
-
) + ` ${log.helpText(migrateNodeId.path)} ${migrateNodeId.displayName}`
|
|
230
|
-
);
|
|
231
|
-
if (migrateNodeId.diff && showDiff)
|
|
232
|
-
console.log(
|
|
233
|
-
` ${log.highlightText(`diff:`)} ${log.infoText(
|
|
234
|
-
highlightDiffText(migrateNodeId.diff)
|
|
235
|
-
)}
|
|
236
|
-
`
|
|
237
|
-
);
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
if (showAll || showChanged)
|
|
241
|
-
console.log(``);
|
|
220
|
+
var _a, _b, _c;
|
|
242
221
|
for (const [projectId, counts] of Object.entries(migrateResult.nodes || {})) {
|
|
243
222
|
const importTitle = action === "delete" ? `Delete from project ${log.warningText(currentProject)}` : `Import ${projectId && projectId !== "null" ? `from project ${log.highlightText(projectId)} ` : ""}to ${log.boldText(log.warningText(currentProject))}`;
|
|
244
223
|
log.help(importTitle);
|
|
@@ -263,13 +242,12 @@ const printNodesMigrateResult = ({ log, messages, currentProject }, migrateResul
|
|
|
263
242
|
` - ${log.errorText(`errors: ${migrateResult.errors.length}`)}
|
|
264
243
|
`
|
|
265
244
|
);
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
}
|
|
245
|
+
log.limits(
|
|
246
|
+
migrateResult.errors.map((error) => {
|
|
247
|
+
return log.errorText((0, import_error.deconstructApiError)(error));
|
|
248
|
+
}).join("\n"),
|
|
249
|
+
logLimit
|
|
250
|
+
);
|
|
273
251
|
}
|
|
274
252
|
};
|
|
275
253
|
const highlightDiffText = (str) => {
|
|
@@ -365,31 +343,57 @@ const printModelMigrationResult = ({ log, messages }, result) => {
|
|
|
365
343
|
}
|
|
366
344
|
}
|
|
367
345
|
};
|
|
368
|
-
const printNodeTreeOutput = ({ log }, root) => {
|
|
369
|
-
log.object({ ...root, children: void 0 });
|
|
346
|
+
const printNodeTreeOutput = ({ log, messages }, root, logDetail = "errors", logLimit = 1e3) => {
|
|
370
347
|
log.raw("");
|
|
348
|
+
const statusColour = messages.migrate.status;
|
|
349
|
+
if (root && "status" in root)
|
|
350
|
+
log.info(
|
|
351
|
+
`Migrate status: ${statusColour("no change")(
|
|
352
|
+
"N"
|
|
353
|
+
)} [no change]; ${statusColour("create")("C")} [create]; ${statusColour(
|
|
354
|
+
"update"
|
|
355
|
+
)("U")} [update]; ${statusColour("error")("E")} [error];`
|
|
356
|
+
);
|
|
371
357
|
log.info(
|
|
372
|
-
|
|
373
|
-
"
|
|
374
|
-
)} =
|
|
358
|
+
`Node properties: ${log.highlightText(
|
|
359
|
+
"e"
|
|
360
|
+
)} = has entry; ${log.highlightText("c")} = canonical; ${log.highlightText(
|
|
361
|
+
"m"
|
|
362
|
+
)} = include in menu`
|
|
375
363
|
);
|
|
376
364
|
log.line();
|
|
377
|
-
const outputNode = (node, spaces
|
|
378
|
-
|
|
365
|
+
const outputNode = (node, spaces, isRoot = false) => {
|
|
366
|
+
var _a, _b;
|
|
367
|
+
const errorOutput = "error" in node && node.error && (0, import_error.deconstructApiError)(node.error);
|
|
368
|
+
const fullOutput = logDetail === "all";
|
|
369
|
+
const changesOutput = logDetail === "changes" && "status" in node && ["create", "update"].includes(node.status);
|
|
370
|
+
const diffOutput = (fullOutput || changesOutput || errorOutput) && "diff" in node && ((_a = node.diff) == null ? void 0 : _a.replaceAll("\n", ""));
|
|
371
|
+
return `${"status" in node ? `${statusColour(node.status)(
|
|
372
|
+
node.status.substring(0, 1).toUpperCase()
|
|
373
|
+
)} ` : ""}${node.entry ? log.highlightText("e") : log.infoText("-")}${"isCanonical" in node && node.isCanonical ? log.highlightText("c") : log.infoText("-")}${node.includeInMenu ? log.highlightText("m") : log.infoText("-")}${spaces}${log["status" in node && node.status === "no change" ? "infoText" : "standardText"](
|
|
374
|
+
"isCanonical" in node && node.isCanonical ? log.boldText(fullOutput || isRoot ? node.path : `/${node.slug}`) : fullOutput || isRoot ? node.path : `/${node.slug}`
|
|
375
|
+
)}${node.entry ? ` ${log.helpText(node.entry.sys.contentTypeId)}` : ""}${node.childCount ? ` +${node.childCount}` : ``} ${"displayName" in node ? log.infoText(node.displayName) : ""}${fullOutput || changesOutput && node.id !== node.originalId ? `~n ${log.infoText(`id:`)} ${node.id === node.originalId ? node.id : `${node.id} ${log.infoText(`<= ${node.originalId}`)}`}` : ""}${(fullOutput || changesOutput && node.parentId !== node.originalParentId) && node.parentId ? `~n ${log.infoText(
|
|
376
|
+
`parentId: ${node.parentId === node.originalParentId ? node.parentId : `${node.parentId} <= ${node.originalParentId}`}`
|
|
377
|
+
)}` : ""}${fullOutput && ((_b = node.entry) == null ? void 0 : _b.sys.id) ? `~n ${log.infoText(`entryId: ${node.entry.sys.id}`)}` : ""}${errorOutput ? `~n${(0, import_logger.addNewLines)(` ${log.errorText(errorOutput)}`, "~n")}` : ""}${diffOutput ? `~n${(0, import_logger.addNewLines)(
|
|
378
|
+
` ${log.infoText(`diff: ${highlightDiffText(diffOutput)}`)}`,
|
|
379
|
+
"~n"
|
|
380
|
+
)}` : ""}`;
|
|
381
|
+
};
|
|
382
|
+
const outputChildren = (node, depth = 2) => {
|
|
379
383
|
let str = "";
|
|
380
|
-
for (const
|
|
381
|
-
str += `${outputNode(
|
|
384
|
+
for (const child of (node == null ? void 0 : node.children) || []) {
|
|
385
|
+
str += `${outputNode(child, Array(depth + 1).join(" "))}
|
|
382
386
|
`;
|
|
383
|
-
if ("children" in
|
|
384
|
-
str += outputChildren(
|
|
387
|
+
if ("children" in child)
|
|
388
|
+
str += outputChildren(child, depth + 1);
|
|
385
389
|
}
|
|
386
390
|
return str;
|
|
387
391
|
};
|
|
388
392
|
const children = outputChildren(root);
|
|
389
393
|
log.limits(
|
|
390
|
-
`${outputNode(root, "
|
|
394
|
+
`${outputNode(root || {}, " ", true)}${children ? `
|
|
391
395
|
${children}` : ""}`,
|
|
392
|
-
|
|
396
|
+
logLimit
|
|
393
397
|
);
|
|
394
398
|
};
|
|
395
399
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/util/console.printer.ts"],
|
|
4
|
-
"sourcesContent": ["import { Node } from 'contensis-delivery-api/lib/models';\nimport dayjs from 'dayjs';\nimport {\n BlockVersion,\n EntriesResult,\n MigrateModelsResult,\n MigrateStatus,\n NodesResult,\n ProjectNodesToMigrate,\n} from 'migratortron';\nimport ContensisCli from '~/services/ContensisCliService';\nimport { Logger } from './logger';\n\nconst formatDate = (date: Date | string, format = 'DD/MM/YYYY HH:mm') =>\n dayjs(date).format(format);\n\nexport const printBlockVersion = (\n { log, messages }: ContensisCli,\n block: BlockVersion,\n printOptions = {\n showSource: true,\n showStatus: true,\n showStaticPaths: true,\n showImage: true,\n }\n) => {\n console.log(\n ` ${log.standardText(`v${block.version.versionNo}`)} ${block.id}`\n );\n console.log(\n ` state: ${messages.blocks.runningStatus(\n block.status.broken ? 'broken' : block.status.running.global\n )}`\n );\n console.log(\n ` released: ${log.infoText(\n block.version.released\n ? `[${formatDate(block.version.released)}] ${block.version.releasedBy}`\n : 'no'\n )}`\n );\n if (block.version.madeLive)\n console.log(\n ` live: ${log.infoText(\n `[${formatDate(block.version.madeLive)}] ${block.version.madeLiveBy}`\n )}`\n );\n if (printOptions.showStatus) {\n console.log(` status:`);\n console.log(` deployment: ${log.infoText(block.status.deployment)}`);\n console.log(` workflow: ${log.infoText(block.status.workflow)}`);\n console.log(\n ` running status: ${messages.blocks.runningStatus(\n block.status.running.global\n )}`\n );\n console.log(` datacentres:`);\n console.log(\n ` hq: ${messages.blocks.runningStatus(\n block.status.running.dataCenters.hq\n )}`\n );\n console.log(\n ` london: ${messages.blocks.runningStatus(\n block.status.running.dataCenters.london\n )}`\n );\n console.log(\n ` manchester: ${messages.blocks.runningStatus(\n block.status.running.dataCenters.manchester\n )}`\n );\n }\n if (printOptions.showSource) {\n console.log(` source:`);\n console.log(` commit: ${log.helpText(block.source.commit.id)}`);\n console.log(\n ` message: ${log.infoText(\n block.source.commit.message\n ?.replaceAll('\\n', '\\\\n')\n .replaceAll('\\\\n\\\\n', '\\\\n')\n .replaceAll('\\\\n', '; ')\n )}`\n );\n console.log(\n ` committed: ${log.infoText(\n `[${formatDate(block.source.commit.dateTime)}] ${\n block.source.commit.authorEmail\n }`\n )}`\n );\n console.log(\n ` pushed: ${log.infoText(\n `[${formatDate(block.version.pushed)}] ${block.version.pushedBy}`\n )}`\n );\n console.log(` ${log.infoText(block.source.commit.commitUrl)}`);\n }\n if (printOptions.showImage) {\n console.log(` image:`);\n console.log(` uri: ${log.infoText(block.image.uri)}`);\n console.log(` tag: ${log.helpText(block.image.tag)}`);\n }\n if (printOptions.showStaticPaths) {\n if (block.staticPaths?.length) {\n console.log(` static paths:`);\n for (const path of block.staticPaths) console.log(` - ${path}`);\n }\n }\n if (block.stagingUrl)\n console.log(` staging url: ${log.infoText(block.stagingUrl)}`);\n console.log('');\n};\n\nexport const printEntriesMigrateResult = (\n { log, messages, currentProject }: ContensisCli,\n migrateResult: EntriesResult,\n {\n action = 'import',\n showDiff = false,\n showAll = false,\n showChanged = false,\n }: {\n action?: 'import' | 'delete';\n showDiff?: boolean;\n showAll?: boolean;\n showChanged?: boolean;\n } = {}\n) => {\n console.log(``);\n\n for (const [contentTypeId, entryRes] of Object.entries(\n migrateResult.entriesToMigrate.entryIds\n ) as [string, any]) {\n for (const [originalId, entryStatus] of Object.entries(entryRes) as [\n string,\n any\n ][]) {\n if (\n showAll ||\n (showChanged &&\n (\n Object.entries(\n Object.entries(entryStatus[currentProject])[0]\n )[1][1] as any\n ).status !== 'no change')\n ) {\n console.log(\n log.infoText(\n `${originalId} ${Object.entries(entryStatus || {})\n .filter(x => x[0] !== 'entryTitle')\n .map(([projectId, projectStatus]) => {\n const [targetGuid, { status }] = (Object.entries(\n projectStatus || {}\n )?.[0] as [string, { status: MigrateStatus }]) || [\n '',\n { x: { status: undefined } },\n ];\n return `${messages.migrate.status(status)(`${status}`)}${\n targetGuid !== originalId ? `-> ${targetGuid}` : ''\n }`;\n })}`\n ) + ` ${log.helpText(contentTypeId)} ${entryStatus.entryTitle}`\n );\n\n for (const [projectId, projectStatus] of Object.entries(\n entryStatus\n ).filter(([key]) => key !== 'entryTitle') as [string, any][]) {\n const [targetGuid, { error, diff, status }] = Object.entries(\n projectStatus\n )[0] as [string, any];\n if (error) log.error(error);\n if (diff && showDiff) {\n console.log(\n ` ${log.highlightText(`diff:`)} ${log.infoText(\n highlightDiffText(diff)\n )}\\n`\n );\n }\n }\n }\n }\n }\n if (showAll || showChanged) console.log(``);\n\n for (const [projectId, contentTypeCounts] of Object.entries(\n migrateResult.entries || {}\n ) as [string, any][]) {\n log.help(\n `${action} from project ${\n action === 'delete'\n ? log.warningText(currentProject)\n : `${log.highlightText(projectId)} to ${log.boldText(\n log.warningText(currentProject)\n )}`\n }`\n );\n for (const [contentTypeId, count] of Object.entries(contentTypeCounts) as [\n string,\n number\n ][]) {\n const isTotalCountRow = contentTypeId === 'totalCount';\n const migrateStatusAndCount =\n migrateResult.entriesToMigrate[currentProject][contentTypeId];\n const existingCount =\n migrateResult.existing?.[currentProject]?.[contentTypeId] || 0;\n const existingPercent = ((existingCount / count) * 100).toFixed(0);\n const noChangeOrTotalEntriesCount =\n typeof migrateStatusAndCount !== 'number'\n ? migrateStatusAndCount?.['no change'] || 0\n : migrateStatusAndCount;\n\n const changedPercentage = (\n (noChangeOrTotalEntriesCount / count) *\n 100\n ).toFixed(0);\n\n const existingColor =\n existingPercent === '0' || action === 'delete'\n ? log.warningText\n : log.infoText;\n\n const changedColor = isTotalCountRow\n ? log.helpText\n : changedPercentage === '100'\n ? log.successText\n : log.warningText;\n\n console.log(\n ` - ${\n isTotalCountRow\n ? log.highlightText(\n `${contentTypeId}: ${noChangeOrTotalEntriesCount}`\n )\n : `${contentTypeId}: ${log.helpText(count)}`\n }${\n changedPercentage === '100' || isTotalCountRow\n ? ''\n : existingColor(` [existing: ${`${existingPercent}%`}]`)\n }${\n existingPercent === '0' || (action === 'import' && isTotalCountRow)\n ? ''\n : changedColor(\n ` ${\n isTotalCountRow\n ? `[to ${action}: ${noChangeOrTotalEntriesCount}]`\n : changedPercentage === '100'\n ? 'up to date'\n : `[needs update: ${100 - Number(changedPercentage)}%]`\n }`\n )\n }`\n );\n }\n }\n if (migrateResult.errors?.length) {\n console.log(\n ` - ${log.errorText(`errors: ${migrateResult.errors.length}`)}\\n`\n );\n for (const error of migrateResult.errors)\n log.error(error.message, null, '');\n }\n};\n\nexport const printNodesMigrateResult = (\n { log, messages, currentProject }: ContensisCli,\n migrateResult: NodesResult,\n {\n action = 'import',\n showDiff = false,\n showAll = false,\n showChanged = false,\n }: {\n action?: 'import' | 'delete';\n showDiff?: boolean;\n showAll?: boolean;\n showChanged?: boolean;\n } = {}\n) => {\n console.log(``);\n\n for (const [originalId, migrateNodeId] of Object.entries(\n migrateResult.nodesToMigrate.nodeIds\n )) {\n if (showAll || (showChanged && migrateNodeId.status !== 'no change')) {\n console.log(\n log.infoText(\n `${originalId} ${`${messages.migrate.status(migrateNodeId.status)(\n `${migrateNodeId.status}`\n )}${\n migrateNodeId.id !== originalId ? `-> ${migrateNodeId.id}` : ''\n }`}`\n ) + ` ${log.helpText(migrateNodeId.path)} ${migrateNodeId.displayName}`\n );\n\n if (migrateNodeId.diff && showDiff)\n console.log(\n ` ${log.highlightText(`diff:`)} ${log.infoText(\n highlightDiffText(migrateNodeId.diff)\n )}\\n`\n );\n }\n }\n if (showAll || showChanged) console.log(``);\n\n for (const [projectId, counts] of Object.entries(migrateResult.nodes || {})) {\n const importTitle =\n action === 'delete'\n ? `Delete from project ${log.warningText(currentProject)}`\n : `Import ${\n projectId && projectId !== 'null'\n ? `from project ${log.highlightText(projectId)} `\n : ''\n }to ${log.boldText(log.warningText(currentProject))}`;\n log.help(importTitle);\n\n const migrateStatusAndCount = migrateResult.nodesToMigrate[\n currentProject\n ] as ProjectNodesToMigrate;\n\n const existingCount =\n migrateResult.existing?.[currentProject]?.totalCount || 0;\n\n const totalCount = Object.keys(migrateResult.nodesToMigrate.nodeIds).length;\n const existingPercent = counts.totalCount\n ? ((existingCount / totalCount) * 100).toFixed(0)\n : '0';\n\n const noChangeCount = migrateStatusAndCount?.['no change'] || 0;\n\n const changedPercentage = counts.totalCount\n ? ((noChangeCount / totalCount) * 100).toFixed(0)\n : '0';\n\n const existingColor =\n existingPercent === '0' || action === 'delete'\n ? log.warningText\n : log.infoText;\n\n const changedColor =\n changedPercentage === '100' ? log.successText : log.warningText;\n\n console.log(\n ` - ${log.highlightText(\n `totalCount: ${migrateStatusAndCount.totalCount}`\n )}${\n changedPercentage === '100'\n ? ''\n : existingColor(` [existing: ${`${existingPercent}%`}]`)\n }${\n existingPercent === '0'\n ? ''\n : changedColor(\n ` ${\n changedPercentage === '100'\n ? 'up to date'\n : `[needs update: ${100 - Number(changedPercentage)}%]`\n }`\n )\n }`\n );\n }\n if (migrateResult.errors?.length) {\n console.log(\n ` - ${log.errorText(`errors: ${migrateResult.errors.length}`)}\\n`\n );\n for (const error of migrateResult.errors) {\n let inner = '';\n if (error.data?.[0]) {\n inner = `${error.data?.[0].Field}: ${error.data?.[0].Message}`;\n }\n log.error(`${error.message} ${inner}`, null, '');\n }\n }\n};\nconst highlightDiffText = (str: string) => {\n const addedRegex = new RegExp(/<<\\+>>(.*?)<<\\/\\+>>/, 'g');\n const removedRegex = new RegExp(/<<->>(.*?)<<\\/->>/, 'g');\n return str\n .replace(addedRegex, match => {\n return Logger.successText(\n match.replace(/<<\\+>>/g, '<+>').replace(/<<\\/\\+>>/g, '</+>')\n );\n })\n .replace(removedRegex, match => {\n return Logger.errorText(\n match.replace(/<<->>/g, '<->').replace(/<<\\/->>/g, '</->')\n );\n });\n};\n\nexport const printModelMigrationAnalysis = (\n { log, messages }: ContensisCli,\n result: any = {}\n) => {\n for (const [contentTypeId, model] of Object.entries(result) as [\n string,\n any\n ][]) {\n let mainOutput = log.standardText(` - ${contentTypeId}`);\n let extraOutput = '';\n let errorOutput = '';\n let diffOutput = '';\n for (const [key, details] of Object.entries(model) as [string, any][]) {\n if (key === 'dependencies') {\n extraOutput += log.infoText(\n ` references: [${details?.join(', ')}]\\n`\n );\n }\n if (key === 'dependencyOf') {\n extraOutput += log.infoText(\n ` required by: [${details?.join(', ')}]\\n`\n );\n }\n if (key === 'projects') {\n for (const [projectId, projectDetails] of Object.entries(details) as [\n string,\n any\n ][]) {\n mainOutput += log.infoText(\n ` [${messages.migrate.status(projectDetails.status)(\n `${projectId}: ${projectDetails.status}`\n )}] v${projectDetails.versionNo}`\n );\n if (projectDetails.diff)\n diffOutput += ` ${log.highlightText(`diff:`)} ${log.infoText(\n highlightDiffText(projectDetails.diff)\n )}\\n`;\n if (projectDetails.error)\n errorOutput += ` ${log.highlightText(\n `error::`\n )} ${log.errorText(projectDetails.error)}`;\n }\n }\n }\n console.log(mainOutput);\n if (extraOutput) {\n const search = '\\n';\n const replace = '';\n console.log(\n extraOutput.replace(\n new RegExp(search + '([^' + search + ']*)$'),\n replace + '$1'\n )\n );\n }\n if (diffOutput) console.log(diffOutput);\n if (errorOutput) console.log(errorOutput);\n }\n};\n\ntype MigrateResultSummary = MigrateModelsResult['']['contentTypes'];\ntype MigrateResultStatus = keyof MigrateResultSummary;\n\nexport const printModelMigrationResult = (\n { log, messages }: ContensisCli,\n result: MigrateResultSummary\n) => {\n for (const [status, ids] of Object.entries(result) as [\n MigrateResultStatus,\n string[]\n ][]) {\n if (ids?.length) {\n if (status === 'errors') {\n const errors: [string, MappedError][] = ids as any;\n log.raw(\n ` - ${status}: [ ${messages.migrate.models.result(status)(\n ids.map(id => id[0]).join(', ')\n )} ]\\n`\n );\n for (const [contentTypeId, error] of errors)\n log.error(\n `${log.highlightText(contentTypeId)}: ${error.message}`,\n error\n );\n } else\n log.raw(\n ` - ${status}: [ ${messages.migrate.models.result(status)(\n ids.join(', ')\n )} ]`\n );\n }\n }\n};\n\nexport const printNodeTreeOutput = (\n { log }: ContensisCli,\n root: Node | undefined\n) => {\n log.object({ ...root, children: undefined });\n log.raw('');\n log.info(\n `${log.highlightText('e')} = has entry; ${log.highlightText(\n 'c'\n )} = canonical; ${log.highlightText('m')} = include in menu`\n );\n log.line();\n\n const outputNode = (node: Node | any, spaces: string) =>\n `${node.entry ? log.highlightText('e') : log.infoText('-')}${\n node.isCanonical ? log.highlightText('c') : log.infoText('-')\n }${\n node.includeInMenu ? log.highlightText('m') : log.infoText('-')\n }${spaces}${\n node.isCanonical ? log.boldText(`/${node.slug}`) : `/${node.slug}`\n }${node.entry ? ` ${log.helpText(node.entry.sys.contentTypeId)}` : ''}${\n node.childCount ? ` +${node.childCount}` : ``\n } ${log.infoText(node.displayName)}`;\n\n const outputChildren = (root: Node | undefined, depth = 2) => {\n let str = '';\n for (const node of (root as any)?.children as Node[]) {\n str += `${outputNode(node, Array(depth + 1).join(' '))}\\n`;\n if ('children' in node) str += outputChildren(node, depth + 1);\n }\n return str;\n };\n\n const children = outputChildren(root);\n log.limits(\n `${outputNode(root, ' ')}${children ? `\\n${children}` : ''}`,\n 100\n );\n};\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAAkB;
|
|
6
|
-
"names": ["dayjs", "_a"
|
|
4
|
+
"sourcesContent": ["import { Node } from 'contensis-delivery-api/lib/models';\nimport dayjs from 'dayjs';\nimport { deconstructApiError } from './error';\nimport { Logger, addNewLines } from './logger';\nimport {\n BlockVersion,\n EntriesResult,\n MigrateModelsResult,\n MigrateNodesTree,\n MigrateStatus,\n NodesResult,\n ProjectNodesToMigrate,\n} from 'migratortron';\nimport ContensisCli from '~/services/ContensisCliService';\n\nconst formatDate = (date: Date | string, format = 'DD/MM/YYYY HH:mm') =>\n dayjs(date).format(format);\n\nexport const printBlockVersion = (\n { log, messages }: ContensisCli,\n block: BlockVersion,\n printOptions = {\n showSource: true,\n showStatus: true,\n showStaticPaths: true,\n showImage: true,\n }\n) => {\n console.log(\n ` ${log.standardText(`v${block.version.versionNo}`)} ${block.id}`\n );\n console.log(\n ` state: ${messages.blocks.runningStatus(\n block.status.broken ? 'broken' : block.status.running.global\n )}`\n );\n console.log(\n ` released: ${log.infoText(\n block.version.released\n ? `[${formatDate(block.version.released)}] ${block.version.releasedBy}`\n : 'no'\n )}`\n );\n if (block.version.madeLive)\n console.log(\n ` live: ${log.infoText(\n `[${formatDate(block.version.madeLive)}] ${block.version.madeLiveBy}`\n )}`\n );\n if (printOptions.showStatus) {\n console.log(` status:`);\n console.log(` deployment: ${log.infoText(block.status.deployment)}`);\n console.log(` workflow: ${log.infoText(block.status.workflow)}`);\n console.log(\n ` running status: ${messages.blocks.runningStatus(\n block.status.running.global\n )}`\n );\n console.log(` datacentres:`);\n console.log(\n ` hq: ${messages.blocks.runningStatus(\n block.status.running.dataCenters.hq\n )}`\n );\n console.log(\n ` london: ${messages.blocks.runningStatus(\n block.status.running.dataCenters.london\n )}`\n );\n console.log(\n ` manchester: ${messages.blocks.runningStatus(\n block.status.running.dataCenters.manchester\n )}`\n );\n }\n if (printOptions.showSource) {\n console.log(` source:`);\n console.log(` commit: ${log.helpText(block.source.commit.id)}`);\n console.log(\n ` message: ${log.infoText(\n block.source.commit.message\n ?.replaceAll('\\n', '\\\\n')\n .replaceAll('\\\\n\\\\n', '\\\\n')\n .replaceAll('\\\\n', '; ')\n )}`\n );\n console.log(\n ` committed: ${log.infoText(\n `[${formatDate(block.source.commit.dateTime)}] ${\n block.source.commit.authorEmail\n }`\n )}`\n );\n console.log(\n ` pushed: ${log.infoText(\n `[${formatDate(block.version.pushed)}] ${block.version.pushedBy}`\n )}`\n );\n console.log(` ${log.infoText(block.source.commit.commitUrl)}`);\n }\n if (printOptions.showImage) {\n console.log(` image:`);\n console.log(` uri: ${log.infoText(block.image.uri)}`);\n console.log(` tag: ${log.helpText(block.image.tag)}`);\n }\n if (printOptions.showStaticPaths) {\n if (block.staticPaths?.length) {\n console.log(` static paths:`);\n for (const path of block.staticPaths) console.log(` - ${path}`);\n }\n }\n if (block.stagingUrl)\n console.log(` staging url: ${log.infoText(block.stagingUrl)}`);\n console.log('');\n};\n\nexport const printEntriesMigrateResult = (\n { log, messages, currentProject }: ContensisCli,\n migrateResult: EntriesResult,\n {\n action = 'import',\n showDiff = false,\n showAll = false,\n showChanged = false,\n }: {\n action?: 'import' | 'delete';\n showDiff?: boolean;\n showAll?: boolean;\n showChanged?: boolean;\n } = {}\n) => {\n console.log(``);\n\n for (const [contentTypeId, entryRes] of Object.entries(\n migrateResult.entriesToMigrate.entryIds\n ) as [string, any]) {\n for (const [originalId, entryStatus] of Object.entries(entryRes) as [\n string,\n any\n ][]) {\n if (\n showAll ||\n (showChanged &&\n (\n Object.entries(\n Object.entries(entryStatus[currentProject])[0]\n )[1][1] as any\n ).status !== 'no change')\n ) {\n console.log(\n log.infoText(\n `${originalId} ${Object.entries(entryStatus || {})\n .filter(x => x[0] !== 'entryTitle')\n .map(([projectId, projectStatus]) => {\n const [targetGuid, { status }] = (Object.entries(\n projectStatus || {}\n )?.[0] as [string, { status: MigrateStatus }]) || [\n '',\n { x: { status: undefined } },\n ];\n return `${messages.migrate.status(status)(`${status}`)}${\n targetGuid !== originalId ? `-> ${targetGuid}` : ''\n }`;\n })}`\n ) + ` ${log.helpText(contentTypeId)} ${entryStatus.entryTitle}`\n );\n\n for (const [projectId, projectStatus] of Object.entries(\n entryStatus\n ).filter(([key]) => key !== 'entryTitle') as [string, any][]) {\n const [targetGuid, { error, diff, status }] = Object.entries(\n projectStatus\n )[0] as [string, any];\n if (error) log.error(error);\n if (diff && showDiff) {\n console.log(\n ` ${log.highlightText(`diff:`)} ${log.infoText(\n highlightDiffText(diff)\n )}\\n`\n );\n }\n }\n }\n }\n }\n if (showAll || showChanged) console.log(``);\n\n for (const [projectId, contentTypeCounts] of Object.entries(\n migrateResult.entries || {}\n ) as [string, any][]) {\n log.help(\n `${action} from project ${\n action === 'delete'\n ? log.warningText(currentProject)\n : `${log.highlightText(projectId)} to ${log.boldText(\n log.warningText(currentProject)\n )}`\n }`\n );\n for (const [contentTypeId, count] of Object.entries(contentTypeCounts) as [\n string,\n number\n ][]) {\n const isTotalCountRow = contentTypeId === 'totalCount';\n const migrateStatusAndCount =\n migrateResult.entriesToMigrate[currentProject][contentTypeId];\n const existingCount =\n migrateResult.existing?.[currentProject]?.[contentTypeId] || 0;\n const existingPercent = ((existingCount / count) * 100).toFixed(0);\n const noChangeOrTotalEntriesCount =\n typeof migrateStatusAndCount !== 'number'\n ? migrateStatusAndCount?.['no change'] || 0\n : migrateStatusAndCount;\n\n const changedPercentage = (\n (noChangeOrTotalEntriesCount / count) *\n 100\n ).toFixed(0);\n\n const existingColor =\n existingPercent === '0' || action === 'delete'\n ? log.warningText\n : log.infoText;\n\n const changedColor = isTotalCountRow\n ? log.helpText\n : changedPercentage === '100'\n ? log.successText\n : log.warningText;\n\n console.log(\n ` - ${\n isTotalCountRow\n ? log.highlightText(\n `${contentTypeId}: ${noChangeOrTotalEntriesCount}`\n )\n : `${contentTypeId}: ${log.helpText(count)}`\n }${\n changedPercentage === '100' || isTotalCountRow\n ? ''\n : existingColor(` [existing: ${`${existingPercent}%`}]`)\n }${\n existingPercent === '0' || (action === 'import' && isTotalCountRow)\n ? ''\n : changedColor(\n ` ${\n isTotalCountRow\n ? `[to ${action}: ${noChangeOrTotalEntriesCount}]`\n : changedPercentage === '100'\n ? 'up to date'\n : `[needs update: ${100 - Number(changedPercentage)}%]`\n }`\n )\n }`\n );\n }\n }\n if (migrateResult.errors?.length) {\n console.log(\n ` - ${log.errorText(`errors: ${migrateResult.errors.length}`)}\\n`\n );\n for (const error of migrateResult.errors)\n log.error(error.message, null, '');\n }\n};\n\nexport const printNodesMigrateResult = (\n { log, currentProject }: ContensisCli,\n migrateResult: NodesResult,\n {\n action = 'import',\n logLimit = 50,\n showDiff = false,\n showAll = false,\n showChanged = false,\n }: {\n action?: 'import' | 'delete';\n logLimit?: number;\n showDiff?: boolean;\n showAll?: boolean;\n showChanged?: boolean;\n } = {}\n) => {\n for (const [projectId, counts] of Object.entries(migrateResult.nodes || {})) {\n const importTitle =\n action === 'delete'\n ? `Delete from project ${log.warningText(currentProject)}`\n : `Import ${\n projectId && projectId !== 'null'\n ? `from project ${log.highlightText(projectId)} `\n : ''\n }to ${log.boldText(log.warningText(currentProject))}`;\n log.help(importTitle);\n\n const migrateStatusAndCount = migrateResult.nodesToMigrate[\n currentProject\n ] as ProjectNodesToMigrate;\n\n const existingCount =\n migrateResult.existing?.[currentProject]?.totalCount || 0;\n\n const totalCount = Object.keys(migrateResult.nodesToMigrate.nodeIds).length;\n const existingPercent = counts.totalCount\n ? ((existingCount / totalCount) * 100).toFixed(0)\n : '0';\n\n const noChangeCount = migrateStatusAndCount?.['no change'] || 0;\n\n const changedPercentage = counts.totalCount\n ? ((noChangeCount / totalCount) * 100).toFixed(0)\n : '0';\n\n const existingColor =\n existingPercent === '0' || action === 'delete'\n ? log.warningText\n : log.infoText;\n\n const changedColor =\n changedPercentage === '100' ? log.successText : log.warningText;\n\n console.log(\n ` - ${log.highlightText(\n `totalCount: ${migrateStatusAndCount.totalCount}`\n )}${\n changedPercentage === '100'\n ? ''\n : existingColor(` [existing: ${`${existingPercent}%`}]`)\n }${\n existingPercent === '0'\n ? ''\n : changedColor(\n ` ${\n changedPercentage === '100'\n ? 'up to date'\n : `[needs update: ${100 - Number(changedPercentage)}%]`\n }`\n )\n }`\n );\n }\n if (migrateResult.errors?.length) {\n console.log(\n ` - ${log.errorText(`errors: ${migrateResult.errors.length}`)}\\n`\n );\n\n log.limits(\n migrateResult.errors\n .map(error => {\n return log.errorText(deconstructApiError(error));\n })\n .join('\\n'),\n logLimit\n );\n }\n};\n\nconst highlightDiffText = (str: string) => {\n const addedRegex = new RegExp(/<<\\+>>(.*?)<<\\/\\+>>/, 'g');\n const removedRegex = new RegExp(/<<->>(.*?)<<\\/->>/, 'g');\n return str\n .replace(addedRegex, match => {\n return Logger.successText(\n match.replace(/<<\\+>>/g, '<+>').replace(/<<\\/\\+>>/g, '</+>')\n );\n })\n .replace(removedRegex, match => {\n return Logger.errorText(\n match.replace(/<<->>/g, '<->').replace(/<<\\/->>/g, '</->')\n );\n });\n};\n\nexport const printModelMigrationAnalysis = (\n { log, messages }: ContensisCli,\n result: any = {}\n) => {\n for (const [contentTypeId, model] of Object.entries(result) as [\n string,\n any\n ][]) {\n let mainOutput = log.standardText(` - ${contentTypeId}`);\n let extraOutput = '';\n let errorOutput = '';\n let diffOutput = '';\n for (const [key, details] of Object.entries(model) as [string, any][]) {\n if (key === 'dependencies') {\n extraOutput += log.infoText(\n ` references: [${details?.join(', ')}]\\n`\n );\n }\n if (key === 'dependencyOf') {\n extraOutput += log.infoText(\n ` required by: [${details?.join(', ')}]\\n`\n );\n }\n if (key === 'projects') {\n for (const [projectId, projectDetails] of Object.entries(details) as [\n string,\n any\n ][]) {\n mainOutput += log.infoText(\n ` [${messages.migrate.status(projectDetails.status)(\n `${projectId}: ${projectDetails.status}`\n )}] v${projectDetails.versionNo}`\n );\n if (projectDetails.diff)\n diffOutput += ` ${log.highlightText(`diff:`)} ${log.infoText(\n highlightDiffText(projectDetails.diff)\n )}\\n`;\n if (projectDetails.error)\n errorOutput += ` ${log.highlightText(\n `error::`\n )} ${log.errorText(projectDetails.error)}`;\n }\n }\n }\n console.log(mainOutput);\n if (extraOutput) {\n const search = '\\n';\n const replace = '';\n console.log(\n extraOutput.replace(\n new RegExp(search + '([^' + search + ']*)$'),\n replace + '$1'\n )\n );\n }\n if (diffOutput) console.log(diffOutput);\n if (errorOutput) console.log(errorOutput);\n }\n};\n\ntype MigrateResultSummary = MigrateModelsResult['']['contentTypes'];\ntype MigrateResultStatus = keyof MigrateResultSummary;\n\nexport const printModelMigrationResult = (\n { log, messages }: ContensisCli,\n result: MigrateResultSummary\n) => {\n for (const [status, ids] of Object.entries(result) as [\n MigrateResultStatus,\n string[]\n ][]) {\n if (ids?.length) {\n if (status === 'errors') {\n const errors: [string, MappedError][] = ids as any;\n log.raw(\n ` - ${status}: [ ${messages.migrate.models.result(status)(\n ids.map(id => id[0]).join(', ')\n )} ]\\n`\n );\n for (const [contentTypeId, error] of errors)\n log.error(\n `${log.highlightText(contentTypeId)}: ${error.message}`,\n error\n );\n } else\n log.raw(\n ` - ${status}: [ ${messages.migrate.models.result(status)(\n ids.join(', ')\n )} ]`\n );\n }\n }\n};\n\nexport const printNodeTreeOutput = (\n { log, messages }: ContensisCli,\n root: Node | MigrateNodesTree | undefined,\n logDetail = 'errors',\n logLimit = 1000\n) => {\n log.raw('');\n const statusColour = messages.migrate.status;\n\n if (root && 'status' in root)\n log.info(\n `Migrate status: ${statusColour('no change')(\n 'N'\n )} [no change]; ${statusColour('create')('C')} [create]; ${statusColour(\n 'update'\n )('U')} [update]; ${statusColour('error')('E')} [error];`\n );\n log.info(\n `Node properties: ${log.highlightText(\n 'e'\n )} = has entry; ${log.highlightText('c')} = canonical; ${log.highlightText(\n 'm'\n )} = include in menu`\n );\n\n log.line();\n\n const outputNode = (\n node: Node | MigrateNodesTree,\n spaces: string,\n isRoot = false\n ) => {\n const errorOutput =\n 'error' in node && node.error && deconstructApiError(node.error);\n const fullOutput = logDetail === 'all';\n const changesOutput =\n logDetail === 'changes' &&\n 'status' in node &&\n ['create', 'update'].includes(node.status);\n\n const diffOutput =\n (fullOutput || changesOutput || errorOutput) &&\n 'diff' in node &&\n node.diff?.replaceAll('\\n', '');\n\n return `${\n 'status' in node\n ? `${statusColour(node.status)(\n node.status.substring(0, 1).toUpperCase()\n )} `\n : ''\n }${node.entry ? log.highlightText('e') : log.infoText('-')}${\n 'isCanonical' in node && node.isCanonical\n ? log.highlightText('c')\n : log.infoText('-')\n }${\n node.includeInMenu ? log.highlightText('m') : log.infoText('-')\n }${spaces}${log[\n 'status' in node && node.status === 'no change'\n ? 'infoText'\n : 'standardText'\n ](\n 'isCanonical' in node && node.isCanonical\n ? log.boldText(fullOutput || isRoot ? node.path : `/${node.slug}`)\n : fullOutput || isRoot\n ? node.path\n : `/${node.slug}`\n )}${node.entry ? ` ${log.helpText(node.entry.sys.contentTypeId)}` : ''}${\n node.childCount ? ` +${node.childCount}` : ``\n } ${'displayName' in node ? log.infoText(node.displayName) : ''}${\n fullOutput || (changesOutput && node.id !== node.originalId)\n ? `~n ${log.infoText(`id:`)} ${\n node.id === node.originalId\n ? node.id\n : `${node.id} ${log.infoText(`<= ${node.originalId}`)}`\n }`\n : ''\n }${\n (fullOutput ||\n (changesOutput && node.parentId !== node.originalParentId)) &&\n node.parentId\n ? `~n ${log.infoText(\n `parentId: ${\n node.parentId === node.originalParentId\n ? node.parentId\n : `${node.parentId} <= ${node.originalParentId}`\n }`\n )}`\n : ''\n }${\n fullOutput && node.entry?.sys.id\n ? `~n ${log.infoText(`entryId: ${node.entry.sys.id}`)}`\n : ''\n }${\n errorOutput\n ? `~n${addNewLines(` ${log.errorText(errorOutput)}`, '~n')}`\n : ''\n }${\n diffOutput\n ? `~n${addNewLines(\n ` ${log.infoText(`diff: ${highlightDiffText(diffOutput)}`)}`,\n '~n'\n )}`\n : ''\n }`;\n };\n\n const outputChildren = (node: Node | undefined, depth = 2) => {\n let str = '';\n for (const child of ((node as any)?.children || []) as Node[]) {\n str += `${outputNode(child, Array(depth + 1).join(' '))}\\n`;\n if ('children' in child) str += outputChildren(child, depth + 1);\n }\n return str;\n };\n\n const children = outputChildren(root);\n log.limits(\n `${outputNode(root || {}, ' ', true)}${children ? `\\n${children}` : ''}`,\n logLimit\n );\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAAkB;AAClB,mBAAoC;AACpC,oBAAoC;AAYpC,MAAM,aAAa,CAAC,MAAqB,SAAS,2BAChD,aAAAA,SAAM,IAAI,EAAE,OAAO,MAAM;AAEpB,MAAM,oBAAoB,CAC/B,EAAE,KAAK,SAAS,GAChB,OACA,eAAe;AAAA,EACb,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,iBAAiB;AAAA,EACjB,WAAW;AACb,MACG;AA3BL;AA4BE,UAAQ;AAAA,IACN,KAAK,IAAI,aAAa,IAAI,MAAM,QAAQ,WAAW,KAAK,MAAM;AAAA,EAChE;AACA,UAAQ;AAAA,IACN,cAAc,SAAS,OAAO;AAAA,MAC5B,MAAM,OAAO,SAAS,WAAW,MAAM,OAAO,QAA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aAAa;AAAA,IACpE;AAAA,EACF;AACF;",
|
|
6
|
+
"names": ["dayjs", "_a"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var error_exports = {};
|
|
20
|
+
__export(error_exports, {
|
|
21
|
+
deconstructApiError: () => deconstructApiError
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(error_exports);
|
|
24
|
+
const deconstructApiError = (error) => {
|
|
25
|
+
var _a, _b, _c;
|
|
26
|
+
let inner = "";
|
|
27
|
+
if ((_a = error.data) == null ? void 0 : _a[0]) {
|
|
28
|
+
inner = `${(_b = error.data) == null ? void 0 : _b[0].Field}: ${(_c = error.data) == null ? void 0 : _c[0].Message}`;
|
|
29
|
+
}
|
|
30
|
+
return `${error.message} ${inner}`;
|
|
31
|
+
};
|
|
32
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
33
|
+
0 && (module.exports = {
|
|
34
|
+
deconstructApiError
|
|
35
|
+
});
|
|
36
|
+
//# sourceMappingURL=error.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/util/error.ts"],
|
|
4
|
+
"sourcesContent": ["export const deconstructApiError = (error: MappedError) => {\n let inner = '';\n if (error.data?.[0]) {\n inner = `${error.data?.[0].Field}: ${error.data?.[0].Message}`;\n }\n return `${error.message} ${inner}`;\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,MAAM,sBAAsB,CAAC,UAAuB;AAA3D;AACE,MAAI,QAAQ;AACZ,OAAI,WAAM,SAAN,mBAAa,IAAI;AACnB,YAAQ,IAAG,WAAM,SAAN,mBAAa,GAAG,WAAU,WAAM,SAAN,mBAAa,GAAG;AAAA,EACvD;AACA,SAAO,GAAG,MAAM,WAAW;AAC7B;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/dist/util/find.js
CHANGED
|
@@ -22,8 +22,16 @@ __export(find_exports, {
|
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(find_exports);
|
|
24
24
|
const findByIdOrName = (arr, idOrName, exact = false) => arr.find(
|
|
25
|
-
(r) =>
|
|
26
|
-
|
|
25
|
+
(r) => {
|
|
26
|
+
var _a;
|
|
27
|
+
return r.id === idOrName || typeof r.name === "string" && r.name.toLowerCase() === idOrName.toLowerCase() || typeof r.name === "object" && ((_a = Object.values(r.name || {})) == null ? void 0 : _a[0].toLowerCase()) === idOrName.toLowerCase();
|
|
28
|
+
}
|
|
29
|
+
) || !exact && arr.find(
|
|
30
|
+
(r) => {
|
|
31
|
+
var _a;
|
|
32
|
+
return typeof r.name === "string" && r.name.toLowerCase().includes(idOrName.toLowerCase()) || typeof r.name === "object" && ((_a = Object.values(r.name || {})) == null ? void 0 : _a[0].toLowerCase()) === idOrName.toLowerCase();
|
|
33
|
+
}
|
|
34
|
+
);
|
|
27
35
|
// Annotate the CommonJS export names for ESM import in node:
|
|
28
36
|
0 && (module.exports = {
|
|
29
37
|
findByIdOrName
|
package/dist/util/find.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/util/find.ts"],
|
|
4
|
-
"sourcesContent": ["export const findByIdOrName = (arr: any[], idOrName: string, exact = false) =>\n arr.find(\n r =>\n r.id === idOrName ||\n r.name.toLowerCase() === idOrName.toLowerCase()\n ) ||\n (!exact &&\n arr.find(r
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,MAAM,iBAAiB,CAAC,KAAY,UAAkB,QAAQ,UACnE,IAAI;AAAA,EACF,
|
|
4
|
+
"sourcesContent": ["export const findByIdOrName = (arr: any[], idOrName: string, exact = false) =>\n arr.find(\n r =>\n r.id === idOrName ||\n (typeof r.name === 'string' &&\n r.name.toLowerCase() === idOrName.toLowerCase()) ||\n (typeof r.name === 'object' &&\n Object.values<string>(r.name || {})?.[0].toLowerCase() ===\n idOrName.toLowerCase())\n ) ||\n (!exact &&\n arr.find(\n r =>\n (typeof r.name === 'string' &&\n r.name.toLowerCase().includes(idOrName.toLowerCase())) ||\n (typeof r.name === 'object' &&\n Object.values<string>(r.name || {})?.[0].toLowerCase() ===\n idOrName.toLowerCase())\n ));\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,MAAM,iBAAiB,CAAC,KAAY,UAAkB,QAAQ,UACnE,IAAI;AAAA,EACF,OAAE;AAFN;AAGM,aAAE,OAAO,YACR,OAAO,EAAE,SAAS,YACjB,EAAE,KAAK,YAAY,MAAM,SAAS,YAAY,KAC/C,OAAO,EAAE,SAAS,cACjB,YAAO,OAAe,EAAE,QAAQ,CAAC,CAAC,MAAlC,mBAAsC,GAAG,mBACvC,SAAS,YAAY;AAAA;AAC7B,KACC,CAAC,SACA,IAAI;AAAA,EACF,OAAE;AAZR;AAaS,kBAAO,EAAE,SAAS,YACjB,EAAE,KAAK,YAAY,EAAE,SAAS,SAAS,YAAY,CAAC,KACrD,OAAO,EAAE,SAAS,cACjB,YAAO,OAAe,EAAE,QAAQ,CAAC,CAAC,MAAlC,mBAAsC,GAAG,mBACvC,SAAS,YAAY;AAAA;AAC7B;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/util/logger.js
CHANGED
|
@@ -25,6 +25,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
25
25
|
var logger_exports = {};
|
|
26
26
|
__export(logger_exports, {
|
|
27
27
|
Logger: () => Logger,
|
|
28
|
+
addNewLines: () => addNewLines,
|
|
28
29
|
logError: () => logError,
|
|
29
30
|
progress: () => progress
|
|
30
31
|
});
|
|
@@ -200,17 +201,26 @@ ${Logger.standardText(content)}`;
|
|
|
200
201
|
else
|
|
201
202
|
console.log(content);
|
|
202
203
|
};
|
|
203
|
-
static limits = (content, displayLength = 30) => {
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
204
|
+
static limits = (content, displayLength = 30, consoleWidth = process.stdout.columns, logMethod = console.info) => {
|
|
205
|
+
if (consoleWidth) {
|
|
206
|
+
content.split("\n").slice(0, consoleWidth ? displayLength : void 0).map(
|
|
207
|
+
(line) => logMethod(
|
|
208
|
+
line.split("~n").map(
|
|
209
|
+
(l) => consoleWidth && (0, import_printable_characters.strlen)(l) > consoleWidth ? (0, import_printable_characters.first)(l, consoleWidth) : l
|
|
210
|
+
).join("\n")
|
|
211
|
+
)
|
|
212
|
+
).join("\n");
|
|
213
|
+
} else {
|
|
214
|
+
logMethod(content.replace(import_printable_characters.ansiEscapeCodes, ""));
|
|
215
|
+
}
|
|
210
216
|
const tableArray = content.split("\n");
|
|
211
217
|
if (consoleWidth && tableArray.length > displayLength)
|
|
212
|
-
console.info(
|
|
213
|
-
|
|
218
|
+
console.info(
|
|
219
|
+
`
|
|
220
|
+
`,
|
|
221
|
+
`- and ${tableArray.length - displayLength} more...
|
|
222
|
+
`
|
|
223
|
+
);
|
|
214
224
|
};
|
|
215
225
|
}
|
|
216
226
|
const logError = (err = new Error("Undefined error"), msg, level = "error") => {
|
|
@@ -231,6 +241,34 @@ const logError = (err = new Error("Undefined error"), msg, level = "error") => {
|
|
|
231
241
|
});
|
|
232
242
|
return null;
|
|
233
243
|
};
|
|
244
|
+
const addNewLines = (message = "", newLineSeparater = "\n", atPosition = process.stdout.columns) => {
|
|
245
|
+
if (message === "" || atPosition === 0) {
|
|
246
|
+
return "";
|
|
247
|
+
}
|
|
248
|
+
let result = "";
|
|
249
|
+
let lengthCounter = 0;
|
|
250
|
+
const partitioned = (0, import_printable_characters.partition)(message);
|
|
251
|
+
const addSeparater = () => {
|
|
252
|
+
if (lengthCounter >= atPosition) {
|
|
253
|
+
result += newLineSeparater;
|
|
254
|
+
lengthCounter = 0;
|
|
255
|
+
}
|
|
256
|
+
};
|
|
257
|
+
for (const [nonPrintable, printable] of partitioned) {
|
|
258
|
+
const textParts = Array.from(printable);
|
|
259
|
+
const text = textParts.splice(0, atPosition - lengthCounter);
|
|
260
|
+
result += nonPrintable + text.join("");
|
|
261
|
+
lengthCounter += text.length;
|
|
262
|
+
addSeparater();
|
|
263
|
+
while (textParts.length) {
|
|
264
|
+
const text2 = textParts.splice(0, atPosition - lengthCounter);
|
|
265
|
+
result += text2.join("");
|
|
266
|
+
lengthCounter += text2.length;
|
|
267
|
+
addSeparater();
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
return result;
|
|
271
|
+
};
|
|
234
272
|
const progress = {
|
|
235
273
|
current: { interrupt: (x) => {
|
|
236
274
|
} },
|
|
@@ -239,6 +277,7 @@ const progress = {
|
|
|
239
277
|
// Annotate the CommonJS export names for ESM import in node:
|
|
240
278
|
0 && (module.exports = {
|
|
241
279
|
Logger,
|
|
280
|
+
addNewLines,
|
|
242
281
|
logError,
|
|
243
282
|
progress
|
|
244
283
|
});
|