contensis-cli 1.0.0-beta.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.vscode/launch.json +15 -0
- package/README.md +631 -0
- package/cli.js +7 -0
- package/dist/commands/connect.js +44 -0
- package/dist/commands/connect.js.map +7 -0
- package/dist/commands/create.js +55 -0
- package/dist/commands/create.js.map +7 -0
- package/dist/commands/get.js +121 -0
- package/dist/commands/get.js.map +7 -0
- package/dist/commands/globalOptions.js +139 -0
- package/dist/commands/globalOptions.js.map +7 -0
- package/dist/commands/import.js +95 -0
- package/dist/commands/import.js.map +7 -0
- package/dist/commands/index.js +81 -0
- package/dist/commands/index.js.map +7 -0
- package/dist/commands/list.js +88 -0
- package/dist/commands/list.js.map +7 -0
- package/dist/commands/login.js +56 -0
- package/dist/commands/login.js.map +7 -0
- package/dist/commands/push.js +133 -0
- package/dist/commands/push.js.map +7 -0
- package/dist/commands/remove.js +77 -0
- package/dist/commands/remove.js.map +7 -0
- package/dist/commands/set.js +55 -0
- package/dist/commands/set.js.map +7 -0
- package/dist/index.js +32 -0
- package/dist/index.js.map +7 -0
- package/dist/localisation/en-GB.js +203 -0
- package/dist/localisation/en-GB.js.map +7 -0
- package/dist/models/AppError.d.js +2 -0
- package/dist/models/AppError.d.js.map +7 -0
- package/dist/models/Cache.d.js +2 -0
- package/dist/models/Cache.d.js.map +7 -0
- package/dist/models/JsModules.d.js +2 -0
- package/dist/models/JsModules.d.js.map +7 -0
- package/dist/providers/CredentialProvider.js +87 -0
- package/dist/providers/CredentialProvider.js.map +7 -0
- package/dist/providers/SessionCacheProvider.js +91 -0
- package/dist/providers/SessionCacheProvider.js.map +7 -0
- package/dist/providers/file-provider.js +113 -0
- package/dist/providers/file-provider.js.map +7 -0
- package/dist/services/ContensisAuthService.js +75 -0
- package/dist/services/ContensisAuthService.js.map +7 -0
- package/dist/services/ContensisCliService.js +1110 -0
- package/dist/services/ContensisCliService.js.map +7 -0
- package/dist/shell.js +261 -0
- package/dist/shell.js.map +7 -0
- package/dist/util/console.printer.js +194 -0
- package/dist/util/console.printer.js.map +7 -0
- package/dist/util/csv.formatter.js +50 -0
- package/dist/util/csv.formatter.js.map +7 -0
- package/dist/util/index.js +94 -0
- package/dist/util/index.js.map +7 -0
- package/dist/util/json.formatter.js +29 -0
- package/dist/util/json.formatter.js.map +7 -0
- package/dist/util/logger.js +184 -0
- package/dist/util/logger.js.map +7 -0
- package/dist/util/xml.formatter.js +51 -0
- package/dist/util/xml.formatter.js.map +7 -0
- package/dist/version.js +29 -0
- package/dist/version.js.map +7 -0
- package/esbuild.config.js +49 -0
- package/headless-setup.sh +7 -0
- package/package.json +59 -0
- package/patches/inquirer-command-prompt+0.1.0.patch +27 -0
- package/src/commands/connect.ts +23 -0
- package/src/commands/create.ts +41 -0
- package/src/commands/get.ts +139 -0
- package/src/commands/globalOptions.ts +126 -0
- package/src/commands/import.ts +89 -0
- package/src/commands/index.ts +72 -0
- package/src/commands/list.ts +90 -0
- package/src/commands/login.ts +33 -0
- package/src/commands/push.ts +120 -0
- package/src/commands/remove.ts +77 -0
- package/src/commands/set.ts +40 -0
- package/src/index.ts +19 -0
- package/src/localisation/en-GB.ts +211 -0
- package/src/models/AppError.d.ts +40 -0
- package/src/models/Cache.d.ts +25 -0
- package/src/models/JsModules.d.ts +1 -0
- package/src/providers/CredentialProvider.ts +88 -0
- package/src/providers/SessionCacheProvider.ts +74 -0
- package/src/providers/file-provider.ts +72 -0
- package/src/services/ContensisAuthService.ts +70 -0
- package/src/services/ContensisCliService.ts +1390 -0
- package/src/shell.ts +250 -0
- package/src/util/console.printer.ts +203 -0
- package/src/util/csv.formatter.ts +21 -0
- package/src/util/index.ts +67 -0
- package/src/util/json.formatter.ts +1 -0
- package/src/util/logger.ts +165 -0
- package/src/util/xml.formatter.ts +20 -0
- package/src/version.ts +1 -0
- package/tsconfig.json +22 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/services/ContensisCliService.ts"],
|
|
4
|
+
"sourcesContent": ["import fs from 'fs';\nimport path from 'path';\nimport fetch from 'node-fetch';\nimport inquirer from 'inquirer';\nimport to from 'await-to-js';\nimport { Component, ContentType } from 'contensis-core-api';\nimport { isPassword, isSharedSecret, isUuid, url } from '~/util';\nimport SessionCacheProvider from '../providers/SessionCacheProvider';\nimport ContensisAuthService from './ContensisAuthService';\nimport CredentialProvider from '~/providers/CredentialProvider';\nimport { logError, Logger } from '~/util/logger';\nimport { LogMessages } from '~/localisation/en-GB';\nimport {\n ContensisMigrationService,\n MigrateRequest,\n PushBlockParams,\n SourceCms,\n logEntriesTable,\n} from 'migratortron';\nimport { Entry } from 'contensis-management-api/lib/models';\n\nimport { csvFormatter } from '~/util/csv.formatter';\nimport { xmlFormatter } from '~/util/xml.formatter';\nimport { jsonFormatter } from '~/util/json.formatter';\nimport { printBlockVersion, printMigrateResult } from '~/util/console.printer';\nimport { readJsonFile } from '~/providers/file-provider';\n\ntype OutputFormat = 'json' | 'csv' | 'xml';\n\ntype OutputOptions = {\n format?: OutputFormat;\n output?: string;\n};\n\ninterface IConnectOptions extends IAuthOptions {\n alias?: string;\n projectId?: string;\n}\n\ninterface IAuthOptions {\n user?: string;\n password?: string;\n clientId?: string;\n sharedSecret?: string;\n}\n\ninterface IImportOptions {\n sourceEnv?: string;\n sourceProjectId?: string;\n}\n\nclass ContensisCli {\n static quit = (error?: Error) => {\n process.removeAllListeners('exit');\n const exitCode = error ? 1 : 0;\n\n console.info(`\\nExiting contensis-cli with exit code: ${exitCode}\\n`);\n process.exit(exitCode);\n };\n\n cache: SessionCache;\n contensis?: ContensisMigrationService;\n contensisOpts: Partial<MigrateRequest>;\n contentTypes?: ContentType[];\n components?: Component[];\n currentEnv: string;\n currentProject: string;\n env: EnvironmentCache;\n sourceEnv?: string;\n targetEnv?: string;\n urls:\n | {\n api: string;\n cms: string;\n liveWeb: string;\n previewWeb: string;\n iisWeb: string;\n iisPreviewWeb: string;\n }\n | undefined;\n private command: CliCommand;\n private format?: OutputFormat;\n private output?: string;\n log = Logger;\n messages = LogMessages;\n private session: SessionCacheProvider;\n\n verb: string;\n noun: string;\n thirdArg: string;\n\n constructor(\n args: string[],\n outputOpts?: OutputOptions & IConnectOptions & IImportOptions,\n contensisOpts: Partial<MigrateRequest> = {}\n ) {\n // console.log('args: ', JSON.stringify(args, null, 2));\n\n const [exe, script, verb = '', noun = '', ...restArgs] = args;\n this.verb = verb?.toLowerCase();\n this.noun = noun?.toLowerCase();\n this.thirdArg = restArgs?.[0];\n\n const commandText = `${this.verb} ${this.noun} ${\n restArgs ? restArgs.join(' ') : ''\n }`.trim();\n\n this.session = new SessionCacheProvider();\n this.cache = this.session.Get();\n this.contensisOpts = contensisOpts;\n this.format = outputOpts?.format;\n this.output =\n outputOpts?.output && path.join(process.cwd(), outputOpts.output);\n\n const currentEnvironment =\n outputOpts?.alias || this.cache.currentEnvironment || '';\n const environments = this.cache.environments || {};\n\n if (!currentEnvironment) this.env = {} as EnvironmentCache;\n else if (!!environments[currentEnvironment])\n this.env = environments[currentEnvironment];\n else {\n this.env = {\n history: [],\n lastUserId: '',\n projects: [],\n versionStatus: 'latest',\n };\n }\n\n const env = this.env;\n\n if (outputOpts?.projectId) env.currentProject = outputOpts.projectId;\n if (outputOpts?.user) env.lastUserId = outputOpts.user;\n if (outputOpts?.password) env.passwordFallback = outputOpts.password;\n if (outputOpts?.clientId) env.lastUserId = outputOpts.clientId;\n if (outputOpts?.sharedSecret)\n env.passwordFallback = outputOpts.sharedSecret;\n\n this.currentEnv = currentEnvironment;\n this.currentProject = env?.currentProject || 'null';\n this.sourceEnv = outputOpts?.sourceEnv || currentEnvironment;\n\n if (currentEnvironment) {\n this.urls = url(currentEnvironment, env?.currentProject || 'website');\n }\n\n this.command = {\n commandText,\n createdDate: new Date().toISOString(),\n createdUserId: env?.lastUserId,\n };\n\n if (currentEnvironment) {\n env.history = [this.command];\n if (commandText) {\n environments[currentEnvironment] = this.env;\n this.session.Update({\n currentEnvironment,\n environments,\n history: [commandText],\n });\n }\n }\n }\n\n PrintEnvironments = () => {\n const { log, messages } = this;\n const { currentEnvironment, environments = {} } = this.cache;\n const envKeys = Object.keys(environments);\n log.success(messages.envs.found(envKeys.length));\n this.HandleFormattingAndOutput(envKeys, () => {\n // print the envKeys to console\n for (const env of envKeys) {\n console.log(` - ${currentEnvironment === env ? '* ' : ''}${env}`);\n }\n });\n if (envKeys.length === 0 || !currentEnvironment) {\n log.help(messages.envs.tip());\n }\n };\n\n Connect = async (environment: string) => {\n const { cache, log, messages, session } = this;\n\n if (environment) {\n const envCache = cache.environments[environment];\n if (!envCache)\n cache.environments[environment] = {\n versionStatus: 'published',\n history: [],\n lastUserId: '',\n projects: [],\n ...(!this.currentEnv ? this.env : {}),\n };\n\n this.env = cache.environments[environment];\n this.currentEnv = environment;\n this.urls = url(environment, 'website');\n\n const [fetchErr, response] = await to(fetch(this.urls.cms));\n if (response && response?.status < 400) {\n log.success(messages.connect.connected(environment));\n\n if (this.env?.lastUserId) {\n await this.ConnectContensis();\n await this.PrintProjects();\n } else {\n log.warning(messages.projects.noList());\n log.help(messages.connect.tip());\n // cache.environments[environment] = {\n // versionStatus: 'published',\n // history: [],\n // lastUserId: '',\n // projects: [],\n // };\n }\n\n session.Update({\n currentEnvironment: environment,\n environments: cache.environments,\n });\n } else {\n // Cannot reach environment - status X\n log.error(\n messages.connect.unreachable(this.urls.cms, response?.status || 0)\n );\n }\n } else {\n // No environment alias specified\n log.error(messages.connect.noEnv());\n }\n };\n\n ConnectContensis = async ({ commit = false } = {}) => {\n const { contensisOpts, currentEnv, env, log, messages } = this;\n const userId = env?.lastUserId;\n const isGuidId = userId && isUuid(userId);\n\n if (currentEnv && userId) {\n const [credentialError, credentials] = await new CredentialProvider(\n {\n userId,\n alias: currentEnv,\n },\n env.passwordFallback\n ).Init();\n\n if (credentialError && !credentials.current) {\n // Log problem with Credential Provider\n log.error(credentialError as any);\n return;\n }\n const cachedPassword = credentials?.current?.password;\n\n if (cachedPassword) {\n this.contensis = new ContensisMigrationService(\n {\n ...contensisOpts,\n source: {\n url: this.urls?.cms || '',\n username: !isGuidId ? userId : undefined,\n password: !isGuidId ? cachedPassword : undefined,\n clientId: isGuidId ? userId : undefined,\n sharedSecret: isGuidId ? cachedPassword : undefined,\n project: env?.currentProject || '',\n assetHostname: this.urls?.previewWeb,\n },\n concurrency:\n typeof contensisOpts.concurrency !== 'undefined'\n ? contensisOpts.concurrency\n : 3,\n outputProgress: true,\n },\n !commit\n );\n }\n } else {\n if (!currentEnv) log.help(messages.connect.help());\n if (!userId) log.help(messages.connect.tip());\n }\n };\n\n ConnectContensisImport = async ({\n commit,\n source,\n fileData,\n fileDataType,\n }: {\n commit: boolean;\n source: 'contensis' | 'file' | 'input';\n fileData?: any[] | string;\n fileDataType?: 'entries' | 'contentTypes' | 'components';\n }) => {\n const { contensisOpts, currentEnv, env, log, messages, sourceEnv } = this;\n const environments = this.cache.environments || {};\n const sourceEnvironment = environments[sourceEnv || ''] || {};\n const sourceCms =\n ('source' in contensisOpts && contensisOpts.source) ||\n ({} as Partial<SourceCms>);\n const sourceUserId =\n sourceCms.clientId || sourceCms.username || sourceEnvironment.lastUserId;\n const sourceProjectId =\n sourceCms.project || sourceEnvironment.currentProject || 'website';\n const isSourceGuidId = sourceUserId && isUuid(sourceUserId);\n const sourceUrls = url(sourceEnv || '', sourceProjectId);\n\n const sourcePassword =\n sourceCms.sharedSecret ||\n sourceCms.password ||\n sourceEnvironment.passwordFallback;\n\n const targetUserId = env?.lastUserId;\n const isTargetGuidId = targetUserId && isUuid(targetUserId);\n\n if (sourceUserId && currentEnv && targetUserId) {\n const [sourceCredentialError, sourceCredentials] =\n await new CredentialProvider(\n {\n userId: sourceUserId,\n alias: currentEnv,\n },\n sourcePassword\n ).Init();\n\n if (sourceCredentialError && !sourceCredentials.current) {\n // Log problem with Credential Provider\n logError(sourceCredentialError);\n return;\n }\n const cachedSourcePassword = sourceCredentials?.current?.password;\n\n const [targetCredentialError, targetCredentials] =\n await new CredentialProvider(\n {\n userId: targetUserId,\n alias: currentEnv,\n },\n env.passwordFallback\n ).Init();\n\n if (targetCredentialError && !targetCredentials.current) {\n // Log problem with Credential Provider\n log.error(targetCredentialError as any);\n return;\n }\n const cachedTargetPassword = targetCredentials?.current?.password;\n\n if (cachedSourcePassword && cachedTargetPassword) {\n if (source === 'file' || source === 'input') {\n this.contensis = new ContensisMigrationService(\n {\n concurrency: 3,\n outputProgress: true,\n ...contensisOpts,\n target: {\n url: this.urls?.cms || '',\n username: !isTargetGuidId ? targetUserId : undefined,\n password: !isTargetGuidId ? cachedTargetPassword : undefined,\n clientId: isTargetGuidId ? targetUserId : undefined,\n sharedSecret: isTargetGuidId ? cachedTargetPassword : undefined,\n targetProjects: [env.currentProject || ''],\n assetHostname: this.urls?.previewWeb,\n },\n ...(fileDataType ? { [fileDataType]: fileData } : {}),\n },\n !commit\n );\n }\n if (source === 'contensis') {\n this.contensis = new ContensisMigrationService(\n {\n concurrency: 3,\n outputProgress: true,\n ...contensisOpts,\n source: {\n url: sourceUrls.cms || '',\n username: !isSourceGuidId ? sourceUserId : undefined,\n password: !isSourceGuidId ? cachedSourcePassword : undefined,\n clientId: isSourceGuidId ? sourceUserId : undefined,\n sharedSecret: isSourceGuidId ? cachedSourcePassword : undefined,\n project: sourceProjectId,\n assetHostname: sourceUrls.previewWeb,\n },\n target: {\n url: this.urls?.cms || '',\n username: !isTargetGuidId ? targetUserId : undefined,\n password: !isTargetGuidId ? cachedTargetPassword : undefined,\n clientId: isTargetGuidId ? targetUserId : undefined,\n sharedSecret: isTargetGuidId ? cachedTargetPassword : undefined,\n targetProjects: [env.currentProject || ''],\n assetHostname: this.urls?.previewWeb,\n },\n },\n !commit\n );\n }\n }\n } else {\n if (!currentEnv) log.help(messages.connect.help());\n if (!targetUserId) log.help(messages.connect.tip());\n }\n };\n\n Login = async (\n userId: string,\n {\n password = isPassword(this.env.passwordFallback),\n promptPassword = true,\n sharedSecret = isSharedSecret(this.env.passwordFallback),\n silent = false,\n }: {\n password?: string;\n promptPassword?: boolean;\n sharedSecret?: string;\n silent?: boolean;\n }\n ): Promise<string | undefined> => {\n let inputPassword = password;\n const { log, messages } = this;\n\n if (userId) {\n const { cache, currentEnv, env } = this;\n\n if (currentEnv) {\n const [credentialError, credentials] = await new CredentialProvider(\n { userId, alias: currentEnv },\n inputPassword || sharedSecret\n ).Init();\n\n if (credentialError && !credentials.current) {\n // Log problem with Credential Provider\n log.error(credentialError as any);\n return;\n }\n\n if (credentials.remarks.secure !== true)\n log.warning(messages.login.insecurePassword());\n\n const cachedPassword = isPassword(credentials?.current?.password);\n const cachedSecret = isSharedSecret(credentials?.current?.password);\n\n if (\n !sharedSecret &&\n !inputPassword &&\n !cachedPassword &&\n !cachedSecret &&\n promptPassword\n ) {\n // Password prompt\n ({ inputPassword } = await inquirer.prompt([\n {\n type: 'password',\n message: messages.login.passwordPrompt(currentEnv, userId),\n name: 'inputPassword',\n mask: '*',\n prefix: undefined,\n },\n ]));\n }\n\n if (sharedSecret || cachedSecret || inputPassword || cachedPassword) {\n const authService = new ContensisAuthService({\n username: userId,\n password: inputPassword || cachedPassword,\n projectId: env?.currentProject || 'website',\n rootUrl: this.urls?.cms || '',\n clientId: userId,\n clientSecret: sharedSecret || cachedSecret,\n });\n\n const [authError, bearerToken] = await to(authService.BearerToken());\n\n // Login successful\n if (bearerToken) {\n // Set env vars\n env.authToken = bearerToken;\n env.lastUserId = userId;\n env.passwordFallback =\n credentials.remarks.secure !== true\n ? credentials.current?.password\n : undefined;\n\n if (!silent) {\n Logger.success(messages.login.success(currentEnv, userId));\n await this.PrintProjects();\n }\n if (inputPassword) await credentials.Save(inputPassword);\n if (sharedSecret) await credentials.Save(sharedSecret);\n } else if (authError) {\n Logger.error(authError.toString());\n // Clear env vars\n env.authToken = '';\n env.lastUserId = '';\n env.passwordFallback = undefined;\n\n // If the auth error was raised using a cached password\n if (\n (cachedPassword || cachedSecret) &&\n credentials.remarks.secure\n ) {\n // Remove any bad stored credential and trigger login prompt again\n await credentials.Delete();\n return await this.Login(userId, { password, sharedSecret });\n } else {\n throw new Error(messages.login.failed(currentEnv, userId));\n }\n }\n\n // Persist env\n this.session.Update({\n environments: cache.environments,\n });\n return env.authToken;\n } else {\n Logger.error(messages.login.passwordPrompt(currentEnv, userId));\n }\n } else {\n // No environment set, use `contensis connect {alias}` first\n Logger.error(messages.login.noEnv());\n }\n } else {\n // No user id specified\n Logger.error(messages.login.noUserId());\n }\n };\n\n PrintProjects = async () => {\n const { cache, currentEnv, currentProject, log, messages, session } = this;\n if (!this.contensis) await this.ConnectContensis();\n\n if (this.contensis) {\n // Retrieve projects list for env\n const [projectsErr, projects] = await to(\n this.contensis.projects.GetSourceProjects()\n );\n\n if (Array.isArray(projects)) {\n // save these projects in cache\n const currentVals = cache.environments[currentEnv] || {};\n const nextCurrentProject =\n currentProject && currentProject !== 'null'\n ? currentProject\n : projects.some(p => p.id === 'website')\n ? 'website'\n : undefined;\n\n cache.environments[currentEnv] = {\n ...currentVals,\n projects: projects.map(p => p.id),\n currentProject: nextCurrentProject,\n };\n\n log.success(messages.projects.list());\n this.HandleFormattingAndOutput(projects, () => {\n // print the projects to console\n for (const project of projects) {\n console.log(\n ` - ${nextCurrentProject === project.id ? '* ' : ''}[${\n project.primaryLanguage\n }] ${project.id}`\n );\n }\n });\n\n session.Update({\n environments: cache.environments,\n });\n\n if (nextCurrentProject) {\n this.env = cache.environments[currentEnv];\n this.SetProject(nextCurrentProject);\n }\n }\n\n if (projectsErr) {\n log.error(messages.projects.noList());\n log.error(projectsErr.message);\n }\n // } else {\n // log.warning(messages.projects.noList());\n // log.help(messages.connect.tip());\n }\n };\n\n SetProject = async (projectId = '') => {\n const { cache, env, log, messages, session } = this;\n let nextProjectId: string | undefined;\n if (env?.projects.length > 0 && env?.lastUserId) {\n nextProjectId = env.projects.find(\n p => p.toLowerCase() === projectId.toLowerCase()\n );\n if (nextProjectId) {\n env.currentProject = nextProjectId;\n session.Update({\n environments: cache.environments,\n });\n log.success(messages.projects.set(projectId));\n } else {\n log.error(messages.projects.failedSet(projectId));\n }\n } else {\n // No projects for currentEnv, try logging in\n log.warning(messages.projects.noList());\n log.help(messages.connect.tip());\n }\n return nextProjectId;\n };\n\n SetVersion = async (versionStatus: 'latest' | 'published') => {\n const { cache, env, log, messages, session } = this;\n if (!['latest', 'published'].includes(versionStatus)) {\n log.error(messages.version.invalid(versionStatus));\n return false;\n }\n if (!env) {\n log.help(messages.version.noEnv());\n return false;\n }\n if (env?.projects.length > 0 && env?.lastUserId) {\n env.versionStatus = versionStatus;\n session.Update({\n environments: cache.environments,\n });\n log.success(messages.version.set(this.currentEnv, versionStatus));\n return true;\n } else {\n // No projects for currentEnv, try logging in\n log.warning(messages.projects.noList());\n log.help(messages.connect.tip());\n return false;\n }\n };\n\n HydrateContensis = async () => {\n const { log } = this;\n if (!this.contensis) await this.ConnectContensis();\n\n if (this.contensis) {\n // Retrieve content types list for env\n const [contensisErr, models] = await to(\n this.contensis.models.HydrateContensisRepositories()\n );\n\n if (contensisErr) {\n log.error(contensisErr.message);\n return contensisErr;\n }\n }\n };\n\n PrintApiKeys = async () => {\n const { currentEnv, log, messages } = this;\n if (!this.contensis) await this.ConnectContensis();\n\n if (this.contensis) {\n // Retrieve keys list for env\n const [keysErr, apiKeys] = await this.contensis.apiKeys.GetKeys();\n\n if (Array.isArray(apiKeys)) {\n log.success(messages.keys.list(currentEnv));\n this.HandleFormattingAndOutput(apiKeys, () => {\n // print the keys to console\n for (const {\n id,\n sharedSecret,\n name,\n description,\n dateModified,\n modifiedBy,\n } of apiKeys) {\n console.log(\n ` - ${name}${\n description ? ` (${description})` : ''\n } [${dateModified.toString().substring(0, 10)} ${modifiedBy}]`\n );\n console.log(` ${id}`);\n console.log(` ${sharedSecret}`);\n }\n });\n }\n\n if (keysErr) {\n log.error(messages.keys.noList(currentEnv));\n log.error(jsonFormatter(keysErr));\n }\n }\n };\n\n CreateApiKey = async (name: string, description?: string) => {\n const { currentEnv, log, messages } = this;\n if (!this.contensis) await this.ConnectContensis();\n\n if (this.contensis) {\n const [err, key] = await this.contensis.apiKeys.CreateKey(\n name,\n description\n );\n\n if (key) {\n log.success(messages.keys.created(currentEnv, name));\n\n // print the key details to console\n console.log(\n ` - ${key.name}${\n key.description ? ` (${key.description})` : ''\n } [${key.dateModified.toString().substring(0, 10)} ${key.modifiedBy}]`\n );\n console.log(` - id: ${key.id}`);\n console.log(` - sharedSecret: ${key.sharedSecret}`);\n }\n console.log('');\n\n if (err) {\n log.error(messages.keys.failedCreate(currentEnv, name), err);\n }\n }\n };\n\n RemoveApiKey = async (id: string) => {\n const { currentEnv, log, messages } = this;\n if (!this.contensis) await this.ConnectContensis({ commit: true });\n\n if (this.contensis) {\n const [err, key] = await this.contensis.apiKeys.RemoveKey(id);\n\n if (!err) {\n log.success(messages.keys.removed(currentEnv, id));\n console.log('');\n } else {\n log.error(messages.keys.failedRemove(currentEnv, id), err);\n }\n }\n };\n\n GetContentTypes = async () => {\n const { currentProject, log, messages } = this;\n let err;\n if (!this.contensis) err = await this.HydrateContensis();\n\n if (err) log.error(messages.contenttypes.noList(currentProject));\n if (this.contensis) {\n this.contentTypes = this.contensis.models.contentTypes();\n this.components = this.contensis.models.components();\n } else {\n log.warning(messages.contenttypes.noList(currentProject));\n }\n };\n\n PrintContentTypes = async () => {\n const { currentProject, log, messages } = this;\n await this.GetContentTypes();\n if (this.contensis) {\n // Retrieve content types list for env\n const { contentTypes } = this;\n\n if (Array.isArray(contentTypes)) {\n log.success(messages.contenttypes.list(currentProject));\n this.HandleFormattingAndOutput(contentTypes, () => {\n // print the content types to console\n for (const contentType of contentTypes) {\n const fieldsLength = contentType.fields?.length || 0;\n console.log(\n ` - ${contentType.id} [${fieldsLength} field${\n fieldsLength !== 1 ? 's' : ''\n }]`\n );\n }\n });\n }\n }\n };\n\n PrintContentType = async (contentTypeId: string) => {\n const { currentProject, log, messages } = this;\n await this.GetContentTypes();\n if (this.contensis) {\n // Retrieve content types list for env\n const { contentTypes } = this;\n\n if (Array.isArray(contentTypes)) {\n const contentType = contentTypes.find(\n c => c.id.toLowerCase() === contentTypeId.toLowerCase()\n );\n if (contentType) {\n log.success(\n messages.contenttypes.get(currentProject, contentType.id)\n );\n // print the content type to console\n this.HandleFormattingAndOutput(contentType, log.object);\n } else {\n log.error(\n messages.contenttypes.failedGet(currentProject, contentTypeId)\n );\n }\n }\n }\n };\n\n RemoveContentTypes = async (contentTypeIds: string[], commit = false) => {\n const { currentProject, log, messages } = this;\n if (!this.contensis)\n await this.ConnectContensisImport({\n source: 'input',\n commit,\n });\n if (this.contensis) {\n const [err, result] = await this.contensis.DeleteContentTypes(\n contentTypeIds\n );\n\n if (err) {\n log.error(\n messages.contenttypes.failedRemove(\n currentProject,\n contentTypeIds.join('\", \"')\n ),\n err\n );\n } else {\n log.success(\n messages.contenttypes.removed(\n currentProject,\n contentTypeIds.join('\", \"'),\n !this.contensis.isPreview\n )\n );\n // print the results to console\n this.HandleFormattingAndOutput(result, () =>\n log.object(jsonFormatter(result))\n );\n }\n }\n };\n\n ImportContentTypes = async (\n {\n commit,\n fromFile,\n }: {\n commit: boolean;\n fromFile: string;\n },\n contentTypeIds: string[] = []\n ) => {\n const { currentProject, log, messages } = this;\n\n let fileData = fromFile ? readJsonFile<ContentType[]>(fromFile) || [] : [];\n if (typeof fileData === 'string')\n throw new Error(`Import file format must be of type JSON`);\n\n if (!Array.isArray(fileData)) fileData = [fileData];\n\n await this.ConnectContensisImport({\n commit,\n source: fromFile ? 'file' : 'contensis',\n });\n\n if (this.contensis) {\n // Pass each content type to the target repo\n for (const contentType of fileData) {\n // Fix invalid data\n contentType.projectId = currentProject;\n delete contentType.uuid;\n\n const [err, created, createStatus] =\n await this.contensis.models.targetRepos[\n currentProject\n ].repo.UpsertContentType(false, contentType);\n\n if (err) log.error(err.message, err);\n if (createStatus) {\n log.success(\n messages.contenttypes.created(\n currentProject,\n contentType.id,\n createStatus\n )\n );\n // print the content type to console\n this.HandleFormattingAndOutput(contentType, () => {});\n }\n }\n }\n };\n\n PrintComponents = async () => {\n const { currentProject, log, messages } = this;\n await this.GetContentTypes();\n if (this.contensis) {\n // Retrieve components list for env\n const { components } = this;\n\n if (Array.isArray(components)) {\n log.success(messages.components.list(currentProject));\n\n this.HandleFormattingAndOutput(components, () => {\n // print the components to console\n for (const component of components) {\n const fieldsLength = component.fields?.length || 0;\n console.log(\n ` - ${component.id} [${fieldsLength} field${\n fieldsLength !== 1 ? 's' : ''\n }]`\n );\n }\n });\n }\n }\n };\n\n PrintComponent = async (componentId: string) => {\n const { currentProject, log, messages } = this;\n await this.GetContentTypes();\n if (this.contensis) {\n // Retrieve content types list for env\n const { components } = this;\n\n if (Array.isArray(components)) {\n const component = components.find(\n c => c.id.toLowerCase() === componentId.toLowerCase()\n );\n if (component) {\n log.success(messages.components.get(currentProject, component.id));\n // print the component to console\n this.HandleFormattingAndOutput(component, log.object);\n } else {\n log.error(messages.components.failedGet(currentProject, componentId));\n }\n }\n }\n };\n\n RemoveComponents = async (componentIds: string[], commit = false) => {\n const { currentProject, log, messages } = this;\n if (!this.contensis)\n await this.ConnectContensisImport({\n source: 'input',\n commit,\n });\n if (this.contensis) {\n const [err, result] = await this.contensis.DeleteContentTypes(\n undefined,\n componentIds\n );\n\n if (err) {\n log.error(\n messages.components.failedRemove(\n currentProject,\n componentIds.join('\", \"')\n ),\n err\n );\n } else {\n log.success(\n messages.components.removed(\n currentProject,\n componentIds.join('\", \"'),\n !this.contensis.isPreview\n )\n );\n // print the results to console\n this.HandleFormattingAndOutput(result, () =>\n log.info(jsonFormatter(result))\n );\n }\n }\n };\n\n ImportComponents = async (\n {\n commit,\n fromFile,\n }: {\n commit: boolean;\n fromFile: string;\n },\n componentIds: string[] = []\n ) => {\n const { currentProject, log, messages } = this;\n\n let fileData = fromFile ? readJsonFile<Component[]>(fromFile) || [] : [];\n if (typeof fileData === 'string')\n throw new Error(`Import file format must be of type JSON`);\n\n if (!Array.isArray(fileData)) fileData = [fileData];\n\n await this.ConnectContensisImport({\n commit,\n source: fromFile ? 'file' : 'contensis',\n });\n\n if (this.contensis) {\n // Pass each component to the target repo\n for (const component of fileData) {\n // Fix invalid data\n component.projectId = currentProject;\n delete component.uuid;\n\n const [err, created, createStatus] =\n await this.contensis.models.targetRepos[\n currentProject\n ].repo.UpsertComponent(false, component);\n\n if (err) log.error(err.message, err);\n if (createStatus) {\n log.success(\n messages.components.created(\n currentProject,\n component.id,\n createStatus\n )\n );\n // print the component to console\n this.HandleFormattingAndOutput(component, () => {});\n }\n }\n }\n };\n\n RemoveEntry = async (id: string, commit = false) => {\n const { currentEnv, log, messages } = this;\n if (!this.contensis)\n await this.ConnectContensisImport({\n source: 'input',\n commit,\n });\n\n if (this.contensis) {\n if (this.contensis.isPreview) {\n console.log(log.successText(` -- PREVIEW -- `));\n } else {\n console.log(log.warningText(` *** COMMITTING DELETE *** `));\n }\n const [err, result] = await this.contensis.DeleteEntries();\n if (result)\n this.HandleFormattingAndOutput(result, () => {\n // print the migrateResult to console\n printMigrateResult(this, result, { action: 'delete' });\n });\n if (\n !err &&\n ((!commit &&\n Object.values(result.entriesToMigrate)?.[0].totalCount > 0) ||\n (commit && result.migrateResult?.deleted))\n ) {\n log.success(messages.entries.removed(currentEnv, id, commit));\n if (!commit) log.help(messages.entries.commitTip());\n } else {\n log.error(messages.entries.failedRemove(currentEnv, id), err);\n if (!Object.values(result.entriesToMigrate)?.[0].totalCount)\n log.help(messages.entries.notFound(id));\n }\n }\n };\n\n GetEntries = async ({\n withDependents = false,\n }: {\n withDependents?: boolean;\n }) => {\n const { currentProject, log, messages } = this;\n await this.ConnectContensis();\n\n if (this.contensis) {\n log.line();\n const entries = await this.contensis.GetEntries({ withDependents });\n this.HandleFormattingAndOutput(entries, () =>\n // print the entries to console\n logEntriesTable(\n entries,\n currentProject,\n this.contensis?.payload.query?.fields\n )\n );\n } else {\n log.warning(messages.contenttypes.noList(currentProject));\n log.help(messages.connect.tip());\n }\n };\n\n ImportEntries = async ({\n commit,\n fromFile,\n }: {\n commit: boolean;\n fromFile: string;\n }) => {\n const { currentProject, log, messages } = this;\n\n const fileData = fromFile ? readJsonFile<Entry[]>(fromFile) || [] : [];\n if (typeof fileData === 'string')\n throw new Error(`Import file format must be of type JSON`);\n\n await this.ConnectContensisImport({\n commit,\n source: fromFile ? 'file' : 'contensis',\n fileData,\n fileDataType: 'entries',\n });\n\n if (this.contensis) {\n log.line();\n if (this.contensis.isPreview) {\n console.log(log.successText(` -- IMPORT PREVIEW -- `));\n } else {\n console.log(log.warningText(` *** COMMITTING IMPORT *** `));\n }\n\n const [migrateErr, migrateResult] = await this.contensis.MigrateEntries();\n\n if (migrateErr) logError(migrateErr);\n else\n this.HandleFormattingAndOutput(migrateResult, () => {\n // print the migrateResult to console\n printMigrateResult(this, migrateResult);\n });\n } else {\n log.warning(messages.contenttypes.noList(currentProject));\n log.help(messages.connect.tip());\n }\n };\n\n PrintWebhookSubscriptions = async (\n subscriptionIds?: string[],\n name?: string\n ) => {\n const { currentEnv, log, messages } = this;\n if (!this.contensis) await this.ConnectContensis();\n if (this.contensis) {\n // Retrieve webhooks list for env\n const [webhooksErr, webhooks] =\n await this.contensis.subscriptions.webhooks.GetSubscriptions();\n\n const filteredResults =\n typeof name === 'string'\n ? webhooks.filter(w =>\n w.name?.toLowerCase().includes(name.toLowerCase())\n )\n : Array.isArray(subscriptionIds)\n ? webhooks.filter(w => subscriptionIds?.some(id => id === w.id))\n : webhooks;\n\n if (Array.isArray(filteredResults)) {\n this.HandleFormattingAndOutput(filteredResults, () => {\n // print the keys to console\n log.success(messages.webhooks.list(currentEnv));\n for (const {\n id,\n description,\n method,\n name,\n version,\n url,\n } of filteredResults) {\n console.log(\n ` - ${name}${\n description ? ` (${description})` : ''\n } [${version.modified.toString().substring(0, 10)} ${\n version.modifiedBy\n }]`\n );\n console.log(` ${id}`);\n console.log(` [${method}] ${url}`);\n }\n console.log('');\n });\n }\n\n if (webhooksErr) {\n log.error(messages.webhooks.noList(currentEnv));\n log.error(jsonFormatter(webhooksErr));\n }\n }\n };\n\n PrintBlocks = async () => {\n const { currentEnv, log, messages } = this;\n if (!this.contensis) await this.ConnectContensis();\n if (this.contensis) {\n // Retrieve blocks list for env\n const [err, blocks] = await this.contensis.blocks.GetBlocks();\n\n if (Array.isArray(blocks)) {\n this.HandleFormattingAndOutput(blocks, () => {\n // print the blocks to console\n log.success(messages.blocks.list(currentEnv));\n for (const {\n id,\n description,\n branches,\n liveVersion,\n madeLive,\n versionsSinceLive,\n } of blocks) {\n console.log(\n ` - ${id}${description ? ` (${description})` : ''}${\n madeLive\n ? ` [${madeLive.toString().substring(0, 10)} v${liveVersion}]`\n : ''\n }${\n versionsSinceLive\n ? log.warningText(` +${versionsSinceLive}`)\n : ''\n }`\n );\n for (const branch of branches)\n console.log(\n log.infoText(` [${branch.id}]: ${branch.status}`)\n );\n }\n });\n }\n\n if (err) {\n log.error(messages.blocks.noList(currentEnv));\n log.error(jsonFormatter(err));\n }\n }\n };\n\n PrintBlockVersions = async (\n blockId: string,\n branch: string,\n version: string\n ) => {\n const { currentEnv, env, log, messages } = this;\n if (!this.contensis) await this.ConnectContensis();\n if (this.contensis) {\n // Retrieve block version\n const [err, blocks] = await this.contensis.blocks.GetBlockVersions(\n blockId,\n branch,\n version\n );\n\n if (blocks) {\n this.HandleFormattingAndOutput(blocks, () => {\n // print the version detail to console\n log.success(\n messages.blocks.get(`${currentEnv}:${env.currentProject}`)\n );\n for (const block of blocks)\n printBlockVersion(\n this,\n block,\n !version\n ? {\n showImage: false,\n showSource: true,\n showStaticPaths: false,\n showStatus: false,\n }\n : undefined\n );\n });\n }\n\n if (err) {\n log.error(messages.blocks.noList(currentEnv, env.currentProject));\n log.error(jsonFormatter(err));\n }\n }\n };\n\n PushBlock = async (block: PushBlockParams) => {\n const { currentEnv, env, log, messages } = this;\n\n // Output request to console\n messages.blocks.tryPush(\n block.id,\n block.source.branch,\n currentEnv,\n env.currentProject\n );\n console.log(jsonFormatter(block));\n\n if (!this.contensis) await this.ConnectContensis();\n if (this.contensis) {\n // Push new block version\n const [err, blockVersion] = await this.contensis.blocks.PushBlockVersion(\n block\n );\n if (!err) {\n log.success(\n messages.blocks.pushed(\n block.id,\n block.source.branch,\n currentEnv,\n env.currentProject\n )\n );\n console.log(jsonFormatter(blockVersion));\n }\n if (blockVersion) {\n this.HandleFormattingAndOutput(blockVersion, () => {\n // print the version detail to console\n printBlockVersion(this, blockVersion);\n });\n }\n if (err)\n throw new Error(\n messages.blocks.failedPush(block.id, currentEnv, env.currentProject)\n );\n }\n };\n\n PrintBlockLogs = async (\n blockId: string,\n branch: string,\n version: string,\n dataCenter: 'hq' | 'manchester' | 'london'\n ) => {\n const { currentEnv, log, messages } = this;\n if (!this.contensis) await this.ConnectContensis();\n if (this.contensis) {\n // Retrieve block logs\n const [err, blockLogs] = await this.contensis.blocks.GetBlockLogs({\n blockId,\n branchId: branch,\n version,\n dataCenter,\n });\n\n if (blockLogs) {\n this.HandleFormattingAndOutput(blockLogs, () => {\n // print the logs to console\n log.success(messages.blocks.list(currentEnv));\n console.log(\n ` - ${blockId} ${branch} ${\n Number(version) ? `v${version}` : version\n } [${dataCenter}]`\n );\n log.line();\n console.log(log.infoText(blockLogs));\n log.line();\n });\n }\n\n if (err) {\n log.error(messages.blocks.noList(currentEnv));\n log.error(jsonFormatter(err));\n }\n }\n };\n\n HandleFormattingAndOutput = <T>(obj: T, logFn: (obj: T) => void) => {\n const { format, log, messages, output } = this;\n if (output) {\n let writeString = '';\n if (format === 'csv') {\n writeString = csvFormatter(obj as any);\n } else if (format === 'xml') {\n writeString = xmlFormatter(obj as any);\n } else writeString = jsonFormatter(obj);\n // write output to file\n if (writeString) {\n fs.writeFileSync(output, writeString);\n log.success(messages.app.fileOutput(format, output));\n } else {\n log.info(messages.app.noFileOutput());\n }\n } else {\n if (!format) {\n // print the object to console\n logFn(obj);\n } else if (format === 'csv') {\n log.raw('');\n log.raw(log.infoText(csvFormatter(obj)));\n } else if (format === 'xml') {\n log.raw('');\n log.raw(log.infoText(xmlFormatter(obj)));\n } else if (format === 'json') {\n log.raw('');\n log.raw(log.infoText(jsonFormatter(obj)));\n }\n log.raw('');\n }\n };\n}\n\nexport const cliCommand = (\n commandArgs: string[],\n outputOpts: OutputOptions & IConnectOptions = {},\n contensisOpts: Partial<MigrateRequest> = {}\n) => {\n return new ContensisCli(['', '', ...commandArgs], outputOpts, contensisOpts);\n};\nexport default ContensisCli;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gBAAe;AACf,kBAAiB;AACjB,wBAAkB;AAClB,sBAAqB;AACrB,yBAAe;AAEf,kBAAwD;AACxD,kCAAiC;AACjC,kCAAiC;AACjC,gCAA+B;AAC/B,oBAAiC;AACjC,mBAA4B;AAC5B,0BAMO;AAGP,iBAA6B;AAC7B,iBAA6B;AAC7B,kBAA8B;AAC9B,qBAAsD;AACtD,2BAA6B;AA0B7B,MAAM,aAAa;AAAA,EACjB,OAAO,OAAO,CAAC,UAAkB;AAC/B,YAAQ,mBAAmB,MAAM;AACjC,UAAM,WAAW,QAAQ,IAAI;AAE7B,YAAQ,KAAK;AAAA,wCAA2C;AAAA,CAAY;AACpE,YAAQ,KAAK,QAAQ;AAAA,EACvB;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAUQ;AAAA,EACA;AAAA,EACA;AAAA,EACR,MAAM;AAAA,EACN,WAAW;AAAA,EACH;AAAA,EAER;AAAA,EACA;AAAA,EACA;AAAA,EAEA,YACE,MACA,YACA,gBAAyC,CAAC,GAC1C;AAGA,UAAM,CAAC,KAAK,QAAQ,OAAO,IAAI,OAAO,OAAO,QAAQ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;AAAA,EACF;AACF;AAEO,MAAM,aAAa,CACxB,aACA,aAA8C,CAAC,GAC/C,gBAAyC,CAAC,MACvC;AACH,SAAO,IAAI,aAAa,CAAC,IAAI,IAAI,GAAG,WAAW,GAAG,YAAY,aAAa;AAC7E;AACA,IAAO,8BAAQ;",
|
|
6
|
+
"names": ["SessionCacheProvider", "path", "to", "fetch", "CredentialProvider", "inquirer", "ContensisAuthService", "name", "url", "fs"]
|
|
7
|
+
}
|
package/dist/shell.js
ADDED
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
+
mod
|
|
23
|
+
));
|
|
24
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
|
+
var shell_exports = {};
|
|
26
|
+
__export(shell_exports, {
|
|
27
|
+
shell: () => shell
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(shell_exports);
|
|
30
|
+
var import_path = __toESM(require("path"));
|
|
31
|
+
var import_figlet = __toESM(require("figlet"));
|
|
32
|
+
var import_inquirer = __toESM(require("inquirer"));
|
|
33
|
+
var import_inquirer_command_prompt = __toESM(require("inquirer-command-prompt"));
|
|
34
|
+
var import_commands = __toESM(require("./commands"));
|
|
35
|
+
var import_en_GB = require("./localisation/en-GB");
|
|
36
|
+
var import_logger = require("./util/logger");
|
|
37
|
+
var import_CredentialProvider = __toESM(require("./providers/CredentialProvider"));
|
|
38
|
+
var import_ContensisCliService = __toESM(require("./services/ContensisCliService"));
|
|
39
|
+
var import_util = require("./util");
|
|
40
|
+
class ContensisShell {
|
|
41
|
+
currentEnvironment;
|
|
42
|
+
emptyInputCounter = 0;
|
|
43
|
+
env;
|
|
44
|
+
firstStart = true;
|
|
45
|
+
userId = "";
|
|
46
|
+
log = import_logger.Logger;
|
|
47
|
+
messages = import_en_GB.LogMessages;
|
|
48
|
+
refreshEnvironment = () => {
|
|
49
|
+
const {
|
|
50
|
+
cache: { currentEnvironment = "", environments = {} }
|
|
51
|
+
} = new import_ContensisCliService.default([]);
|
|
52
|
+
this.currentEnvironment = currentEnvironment;
|
|
53
|
+
this.env = environments[currentEnvironment];
|
|
54
|
+
(0, import_util.Logging)("en-GB").then(({ messages, Log }) => {
|
|
55
|
+
this.log = Log;
|
|
56
|
+
this.messages = messages;
|
|
57
|
+
});
|
|
58
|
+
};
|
|
59
|
+
constructor() {
|
|
60
|
+
this.refreshEnvironment();
|
|
61
|
+
import_inquirer_command_prompt.default.setConfig({
|
|
62
|
+
history: {
|
|
63
|
+
save: true,
|
|
64
|
+
folder: import_path.default.join(__dirname, "../"),
|
|
65
|
+
limit: 100,
|
|
66
|
+
blacklist: ["quit"]
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
const { log, messages } = this;
|
|
70
|
+
import_figlet.default.text(
|
|
71
|
+
messages.app.contensis(),
|
|
72
|
+
{
|
|
73
|
+
font: "Block",
|
|
74
|
+
horizontalLayout: "default",
|
|
75
|
+
verticalLayout: "default",
|
|
76
|
+
width: process.stdout.columns,
|
|
77
|
+
whitespaceBreak: true
|
|
78
|
+
},
|
|
79
|
+
(err, data) => {
|
|
80
|
+
if (err) {
|
|
81
|
+
log.error(messages.app.unknownError());
|
|
82
|
+
console.dir(err);
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
console.log(log.successText(data));
|
|
86
|
+
console.log(log.infoText(messages.app.startup()));
|
|
87
|
+
console.log(log.helpText(messages.app.help()));
|
|
88
|
+
this.start().catch((ex) => log.error(ex));
|
|
89
|
+
}
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
start = async () => {
|
|
93
|
+
this.log.line();
|
|
94
|
+
this.refreshEnvironment();
|
|
95
|
+
this.userId = "";
|
|
96
|
+
const { currentEnvironment, env, log, messages } = this;
|
|
97
|
+
if (env == null ? void 0 : env.lastUserId) {
|
|
98
|
+
const [credsErr, credentials] = await new import_CredentialProvider.default(
|
|
99
|
+
{
|
|
100
|
+
userId: env.lastUserId,
|
|
101
|
+
alias: currentEnvironment
|
|
102
|
+
},
|
|
103
|
+
env.passwordFallback
|
|
104
|
+
).Init();
|
|
105
|
+
if (credsErr && !credentials.current) {
|
|
106
|
+
log.error(credsErr.message);
|
|
107
|
+
}
|
|
108
|
+
if (credentials.current) {
|
|
109
|
+
if (this.firstStart) {
|
|
110
|
+
const token = await (0, import_ContensisCliService.cliCommand)(["login", env.lastUserId]).Login(
|
|
111
|
+
env.lastUserId,
|
|
112
|
+
{
|
|
113
|
+
promptPassword: false,
|
|
114
|
+
silent: true
|
|
115
|
+
}
|
|
116
|
+
);
|
|
117
|
+
if (token)
|
|
118
|
+
this.userId = env.lastUserId;
|
|
119
|
+
this.firstStart = false;
|
|
120
|
+
this.refreshEnvironment();
|
|
121
|
+
} else {
|
|
122
|
+
this.userId = env.lastUserId;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
await this.contensisPrompt();
|
|
127
|
+
};
|
|
128
|
+
contensisPrompt = async () => {
|
|
129
|
+
const { currentEnvironment, env, log, messages, userId } = this;
|
|
130
|
+
const availableCommands = [
|
|
131
|
+
{
|
|
132
|
+
filter: (str) => {
|
|
133
|
+
return str.replace(/ \[.*$/, "");
|
|
134
|
+
}
|
|
135
|
+
},
|
|
136
|
+
"connect",
|
|
137
|
+
"list envs",
|
|
138
|
+
"quit"
|
|
139
|
+
];
|
|
140
|
+
if (currentEnvironment)
|
|
141
|
+
availableCommands.push("login", "list projects", "set project");
|
|
142
|
+
if (userId)
|
|
143
|
+
availableCommands.push(
|
|
144
|
+
"get block",
|
|
145
|
+
"get block logs",
|
|
146
|
+
"get contenttype",
|
|
147
|
+
"get component",
|
|
148
|
+
"get entries",
|
|
149
|
+
"import contenttypes",
|
|
150
|
+
"import components",
|
|
151
|
+
"import entries",
|
|
152
|
+
"list blocks",
|
|
153
|
+
"list contenttypes",
|
|
154
|
+
"list components",
|
|
155
|
+
"list models",
|
|
156
|
+
"list keys",
|
|
157
|
+
"list webhooks",
|
|
158
|
+
"create key",
|
|
159
|
+
"push block",
|
|
160
|
+
"remove key",
|
|
161
|
+
"remove entry",
|
|
162
|
+
"remove contenttypes",
|
|
163
|
+
"remove components"
|
|
164
|
+
);
|
|
165
|
+
const prompt = import_inquirer.default.createPromptModule();
|
|
166
|
+
prompt.registerPrompt("command", import_inquirer_command_prompt.default);
|
|
167
|
+
return prompt([
|
|
168
|
+
{
|
|
169
|
+
type: "command",
|
|
170
|
+
name: "cmd",
|
|
171
|
+
autoCompletion: availableCommands,
|
|
172
|
+
autocompletePrompt: log.infoText(messages.app.autocomplete()),
|
|
173
|
+
message: `${userId ? `${userId}@` : ""}${currentEnvironment || ""}>`,
|
|
174
|
+
context: 0,
|
|
175
|
+
validate: (val) => {
|
|
176
|
+
if (!val)
|
|
177
|
+
this.emptyInputCounter++;
|
|
178
|
+
if (this.emptyInputCounter > 1)
|
|
179
|
+
console.log(this.log.infoText(this.messages.app.suggestions()));
|
|
180
|
+
if (val) {
|
|
181
|
+
this.emptyInputCounter = 0;
|
|
182
|
+
return true;
|
|
183
|
+
}
|
|
184
|
+
},
|
|
185
|
+
prefix: `${(env == null ? void 0 : env.currentProject) || "contensis"}`,
|
|
186
|
+
short: true
|
|
187
|
+
}
|
|
188
|
+
]).then(async (answers) => {
|
|
189
|
+
var _a;
|
|
190
|
+
if (answers.cmd === "quit") {
|
|
191
|
+
this.quit();
|
|
192
|
+
} else {
|
|
193
|
+
try {
|
|
194
|
+
if (answers.cmd) {
|
|
195
|
+
const program = (0, import_commands.default)();
|
|
196
|
+
await program.parseAsync(
|
|
197
|
+
(_a = answers.cmd.match(/"[^"]+"|[^\s]+/g)) == null ? void 0 : _a.map((e) => e.replace(/"(.+)"/, "$1")),
|
|
198
|
+
{
|
|
199
|
+
from: "user"
|
|
200
|
+
}
|
|
201
|
+
);
|
|
202
|
+
}
|
|
203
|
+
} catch (ex) {
|
|
204
|
+
const str = ex.toString();
|
|
205
|
+
if (!str.includes("CommanderError"))
|
|
206
|
+
(0, import_logger.logError)(ex, `Shell ${ex.toString()}`);
|
|
207
|
+
} finally {
|
|
208
|
+
return this.contensisPrompt();
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
}).catch((err) => {
|
|
212
|
+
log.error(err.message);
|
|
213
|
+
this.quit();
|
|
214
|
+
});
|
|
215
|
+
};
|
|
216
|
+
quit = (error) => {
|
|
217
|
+
const { log, messages } = this;
|
|
218
|
+
process.removeAllListeners("exit");
|
|
219
|
+
if (error) {
|
|
220
|
+
log.error(error.message);
|
|
221
|
+
process.exit(1);
|
|
222
|
+
} else {
|
|
223
|
+
log.success(messages.app.quit());
|
|
224
|
+
process.exitCode = 0;
|
|
225
|
+
process.exit(0);
|
|
226
|
+
}
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
let globalShell;
|
|
230
|
+
const shell = () => {
|
|
231
|
+
var _a;
|
|
232
|
+
if (typeof ((_a = process.argv) == null ? void 0 : _a[2]) !== "undefined")
|
|
233
|
+
return { start() {
|
|
234
|
+
} };
|
|
235
|
+
if (!globalShell)
|
|
236
|
+
globalShell = new ContensisShell();
|
|
237
|
+
return globalShell;
|
|
238
|
+
};
|
|
239
|
+
process.on("uncaughtException", function(err) {
|
|
240
|
+
console.log(err);
|
|
241
|
+
});
|
|
242
|
+
process.on("SIGINT", () => {
|
|
243
|
+
console.log("catching SIGINT");
|
|
244
|
+
shell().quit();
|
|
245
|
+
});
|
|
246
|
+
process.on("SIGTERM", () => {
|
|
247
|
+
console.log("catching SIGTERM");
|
|
248
|
+
shell().quit();
|
|
249
|
+
});
|
|
250
|
+
process.stdin.on("data", (key) => {
|
|
251
|
+
if (key == "") {
|
|
252
|
+
console.log("");
|
|
253
|
+
import_logger.Logger.info(`[CTRL]+[C] detected, exiting shell...`);
|
|
254
|
+
shell().quit();
|
|
255
|
+
}
|
|
256
|
+
});
|
|
257
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
258
|
+
0 && (module.exports = {
|
|
259
|
+
shell
|
|
260
|
+
});
|
|
261
|
+
//# sourceMappingURL=shell.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/shell.ts"],
|
|
4
|
+
"sourcesContent": ["import path from 'path';\nimport figlet from 'figlet';\nimport inquirer from 'inquirer';\nimport inquirerPrompt from 'inquirer-command-prompt';\nimport commands from './commands';\nimport { LogMessages } from './localisation/en-GB';\nimport { logError, Logger } from './util/logger';\nimport CredentialProvider from './providers/CredentialProvider';\nimport ContensisCli, { cliCommand } from './services/ContensisCliService';\nimport { Logging } from './util';\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: path.join(__dirname, '../'),\n limit: 100,\n blacklist: ['quit'],\n },\n });\n // inquirer.registerPrompt('command', inquirerPrompt);\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()));\n console.log(log.helpText(messages.app.help()));\n\n this.start().catch(ex => log.error(ex));\n }\n );\n }\n\n start = async () => {\n this.log.line();\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) this.userId = env.lastUserId;\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 'get block',\n 'get block logs',\n 'get contenttype',\n 'get component',\n 'get entries',\n 'import contenttypes',\n 'import components',\n 'import entries',\n 'list blocks',\n 'list contenttypes',\n 'list components',\n 'list models',\n 'list keys',\n 'list webhooks',\n 'create key',\n 'push block',\n 'remove key',\n 'remove entry',\n 'remove contenttypes',\n 'remove components'\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,\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 || '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(ex, `Shell ${ex.toString()}`);\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 if (typeof process.argv?.[2] !== 'undefined') return { start() {} } 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 console.log('catching SIGINT');\n shell().quit();\n});\n\nprocess.on('SIGTERM', () => {\n console.log('catching 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,kBAAiB;AACjB,oBAAmB;AACnB,sBAAqB;AACrB,qCAA2B;AAC3B,sBAAqB;AACrB,mBAA4B;AAC5B,oBAAiC;AACjC,gCAA+B;AAC/B,iCAAyC;AACzC,kBAAwB;AAExB,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,YAAAC,QAAK,KAAK,WAAW,KAAK;AAAA,QAClC,OAAO;AAAA,QACP,WAAW,CAAC,MAAM;AA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E,QAAQ;AAAA,IAAC,EAAE;AAClE,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,UAAQ,IAAI,iBAAiB;AAC7B,QAAM,EAAE,KAAK;AACf,CAAC;AAED,QAAQ,GAAG,WAAW,MAAM;AAC1B,UAAQ,IAAI,kBAAkB;AAC9B,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
|
+
"names": ["ContensisCli", "inquirerPrompt", "path", "figlet", "CredentialProvider", "inquirer", "commands"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
+
mod
|
|
23
|
+
));
|
|
24
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
|
+
var console_printer_exports = {};
|
|
26
|
+
__export(console_printer_exports, {
|
|
27
|
+
printBlockVersion: () => printBlockVersion,
|
|
28
|
+
printMigrateResult: () => printMigrateResult
|
|
29
|
+
});
|
|
30
|
+
module.exports = __toCommonJS(console_printer_exports);
|
|
31
|
+
var import_dayjs = __toESM(require("dayjs"));
|
|
32
|
+
const formatDate = (date, format = "DD/MM/YYYY HH:mm") => (0, import_dayjs.default)(date).format(format);
|
|
33
|
+
const printBlockVersion = ({ log, messages }, block, printOptions = {
|
|
34
|
+
showSource: true,
|
|
35
|
+
showStatus: true,
|
|
36
|
+
showStaticPaths: true,
|
|
37
|
+
showImage: true
|
|
38
|
+
}) => {
|
|
39
|
+
var _a, _b;
|
|
40
|
+
console.log(
|
|
41
|
+
` ${log.standardText(`v${block.version.versionNo}`)} ${block.id}`
|
|
42
|
+
);
|
|
43
|
+
console.log(
|
|
44
|
+
` state: ${messages.blocks.runningStatus(
|
|
45
|
+
block.status.broken ? "broken" : block.status.running.global
|
|
46
|
+
)}`
|
|
47
|
+
);
|
|
48
|
+
console.log(
|
|
49
|
+
` released: ${log.infoText(
|
|
50
|
+
block.version.released ? `[${formatDate(block.version.released)}] ${block.version.releasedBy}` : "no"
|
|
51
|
+
)}`
|
|
52
|
+
);
|
|
53
|
+
if (block.version.madeLive)
|
|
54
|
+
console.log(
|
|
55
|
+
` live: ${log.infoText(
|
|
56
|
+
`[${formatDate(block.version.madeLive)}] ${block.version.madeLiveBy}`
|
|
57
|
+
)}`
|
|
58
|
+
);
|
|
59
|
+
if (printOptions.showStatus) {
|
|
60
|
+
console.log(` status:`);
|
|
61
|
+
console.log(` deployment: ${log.infoText(block.status.deployment)}`);
|
|
62
|
+
console.log(` workflow: ${log.infoText(block.status.workflow)}`);
|
|
63
|
+
console.log(
|
|
64
|
+
` running status: ${messages.blocks.runningStatus(
|
|
65
|
+
block.status.running.global
|
|
66
|
+
)}`
|
|
67
|
+
);
|
|
68
|
+
console.log(` datacentres:`);
|
|
69
|
+
console.log(
|
|
70
|
+
` hq: ${messages.blocks.runningStatus(
|
|
71
|
+
block.status.running.dataCenters.hq
|
|
72
|
+
)}`
|
|
73
|
+
);
|
|
74
|
+
console.log(
|
|
75
|
+
` london: ${messages.blocks.runningStatus(
|
|
76
|
+
block.status.running.dataCenters.london
|
|
77
|
+
)}`
|
|
78
|
+
);
|
|
79
|
+
console.log(
|
|
80
|
+
` manchester: ${messages.blocks.runningStatus(
|
|
81
|
+
block.status.running.dataCenters.manchester
|
|
82
|
+
)}`
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
if (printOptions.showSource) {
|
|
86
|
+
console.log(` source:`);
|
|
87
|
+
console.log(` commit: ${log.helpText(block.source.commit.id)}`);
|
|
88
|
+
console.log(
|
|
89
|
+
` message: ${log.infoText(
|
|
90
|
+
(_a = block.source.commit.message) == null ? void 0 : _a.replaceAll("\n", "\\n").replaceAll("\\n\\n", "\\n").replaceAll("\\n", "; ")
|
|
91
|
+
)}`
|
|
92
|
+
);
|
|
93
|
+
console.log(
|
|
94
|
+
` committed: ${log.infoText(
|
|
95
|
+
`[${formatDate(block.source.commit.dateTime)}] ${block.source.commit.authorEmail}`
|
|
96
|
+
)}`
|
|
97
|
+
);
|
|
98
|
+
console.log(
|
|
99
|
+
` pushed: ${log.infoText(
|
|
100
|
+
`[${formatDate(block.version.pushed)}] ${block.version.pushedBy}`
|
|
101
|
+
)}`
|
|
102
|
+
);
|
|
103
|
+
console.log(` ${log.infoText(block.source.commit.commitUrl)}`);
|
|
104
|
+
}
|
|
105
|
+
if (printOptions.showImage) {
|
|
106
|
+
console.log(` image:`);
|
|
107
|
+
console.log(` uri: ${log.infoText(block.image.uri)}`);
|
|
108
|
+
console.log(` tag: ${log.helpText(block.image.tag)}`);
|
|
109
|
+
}
|
|
110
|
+
if (printOptions.showStaticPaths) {
|
|
111
|
+
if ((_b = block.staticPaths) == null ? void 0 : _b.length) {
|
|
112
|
+
console.log(` static paths:`);
|
|
113
|
+
for (const path of block.staticPaths)
|
|
114
|
+
console.log(` - ${path}`);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
if (block.stagingUrl)
|
|
118
|
+
console.log(` staging url: ${log.infoText(block.stagingUrl)}`);
|
|
119
|
+
console.log("");
|
|
120
|
+
};
|
|
121
|
+
const printMigrateResult = ({ log, messages, contensis, currentProject }, migrateResult, { action = "import" } = {}) => {
|
|
122
|
+
var _a, _b, _c, _d, _e, _f;
|
|
123
|
+
console.log(``);
|
|
124
|
+
if (action === "import") {
|
|
125
|
+
for (const [projectId, contentTypeCounts] of Object.entries(
|
|
126
|
+
migrateResult.entries || {}
|
|
127
|
+
)) {
|
|
128
|
+
console.log(
|
|
129
|
+
`import from project ${log.highlightText(projectId)} to ${log.boldText(
|
|
130
|
+
log.successText(currentProject)
|
|
131
|
+
)}`
|
|
132
|
+
);
|
|
133
|
+
for (const [contentTypeId, count] of Object.entries(
|
|
134
|
+
contentTypeCounts
|
|
135
|
+
)) {
|
|
136
|
+
const entriesToMigrate = (_b = (_a = migrateResult.entriesToMigrate) == null ? void 0 : _a[projectId]) == null ? void 0 : _b[contentTypeId];
|
|
137
|
+
console.log(
|
|
138
|
+
` - ${contentTypeId === "totalCount" ? log.warningText(`${contentTypeId}: ${count}`) : log.helpText(`${contentTypeId}: ${count}`)} ${log.infoText`[existing: ${((((_d = (_c = migrateResult.existing) == null ? void 0 : _c[projectId]) == null ? void 0 : _d[contentTypeId]) || 0) / count * 100).toFixed(0)}%]`} [${typeof entriesToMigrate !== "number" ? `unchanged` : `to update`}: ${((typeof entriesToMigrate !== "number" ? (entriesToMigrate == null ? void 0 : entriesToMigrate["no change"]) || 0 : entriesToMigrate) / count * 100).toFixed(0)}%]`
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
console.log(``);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
if ((contensis == null ? void 0 : contensis.isPreview) && ((_f = (_e = migrateResult.entriesToMigrate) == null ? void 0 : _e[currentProject]) == null ? void 0 : _f.totalCount) > 0 && !migrateResult.errors) {
|
|
145
|
+
log.help(messages.entries.commitTip());
|
|
146
|
+
}
|
|
147
|
+
for (const [contentTypeId, entryRes] of Object.entries(
|
|
148
|
+
migrateResult.entriesToMigrate.entryIds
|
|
149
|
+
)) {
|
|
150
|
+
for (const [originalId, entryStatus] of Object.entries(entryRes)) {
|
|
151
|
+
console.log(
|
|
152
|
+
log.infoText(
|
|
153
|
+
`${originalId} [${Object.entries(entryStatus || {}).filter((x) => x[0] !== "entryTitle").map(([projectId, projectStatus]) => {
|
|
154
|
+
var _a2;
|
|
155
|
+
const [targetGuid, { status }] = ((_a2 = Object.entries(
|
|
156
|
+
projectStatus || {}
|
|
157
|
+
)) == null ? void 0 : _a2[0]) || [
|
|
158
|
+
"",
|
|
159
|
+
{ x: { status: void 0 } }
|
|
160
|
+
];
|
|
161
|
+
return `${messages.entries.migrateStatus(status)(
|
|
162
|
+
`${projectId}: ${status}`
|
|
163
|
+
)}${targetGuid !== originalId ? `-> ${targetGuid}` : ""}`;
|
|
164
|
+
})}]`
|
|
165
|
+
)
|
|
166
|
+
);
|
|
167
|
+
console.log(` ${log.helpText(contentTypeId)} ${entryStatus.entryTitle}`);
|
|
168
|
+
for (const [projectId, projectStatus] of Object.entries(
|
|
169
|
+
entryStatus
|
|
170
|
+
).filter(([key]) => key !== "entryTitle")) {
|
|
171
|
+
const [targetGuid, { error, diff, status }] = Object.entries(
|
|
172
|
+
projectStatus
|
|
173
|
+
)[0];
|
|
174
|
+
if (error)
|
|
175
|
+
log.error(error);
|
|
176
|
+
if (diff) {
|
|
177
|
+
console.log(
|
|
178
|
+
` ${messages.entries.migrateStatus(status)(status)} ${log.infoText(
|
|
179
|
+
targetGuid
|
|
180
|
+
)} ${log.infoText(contentTypeId)} ${log.infoText(projectId)}`
|
|
181
|
+
);
|
|
182
|
+
console.log(``);
|
|
183
|
+
console.log(log.highlightText(diff));
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
};
|
|
189
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
190
|
+
0 && (module.exports = {
|
|
191
|
+
printBlockVersion,
|
|
192
|
+
printMigrateResult
|
|
193
|
+
});
|
|
194
|
+
//# sourceMappingURL=console.printer.js.map
|