contensis-cli 1.0.9-beta.4 → 1.0.9-beta.6
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/localisation/en-GB.js +12 -6
- package/dist/localisation/en-GB.js.map +2 -2
- package/dist/mappers/DevInit-to-CIWorkflow.js +11 -10
- package/dist/mappers/DevInit-to-CIWorkflow.js.map +2 -2
- package/dist/models/DevService.d.js.map +1 -1
- package/dist/services/ContensisDevService.js +24 -6
- package/dist/services/ContensisDevService.js.map +3 -3
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/package.json +1 -1
- package/src/localisation/en-GB.ts +13 -5
- package/src/mappers/DevInit-to-CIWorkflow.ts +9 -11
- package/src/models/DevService.d.ts +1 -0
- package/src/services/ContensisDevService.ts +26 -5
- package/src/version.ts +1 -1
|
@@ -355,12 +355,15 @@ ${import_logger.Logger.errorText(">>")} Available commands:`,
|
|
|
355
355
|
},
|
|
356
356
|
devinit: {
|
|
357
357
|
intro: () => `Contensis developer environment initialisation`,
|
|
358
|
-
projectDetails: (name, env, projectId, git) => `
|
|
359
|
-
|
|
360
|
-
|
|
358
|
+
projectDetails: (name, env, projectId, blockId, git) => `
|
|
359
|
+
Project: ${import_logger.Logger.standardText(name)}
|
|
360
|
+
- Home: ${import_logger.Logger.standardText(process.cwd())}
|
|
361
|
+
- Repository: ${import_logger.Logger.standardText(git.home)}
|
|
362
|
+
- Block id: ${import_logger.Logger.highlightText(blockId)}
|
|
361
363
|
|
|
362
|
-
Connect to Contensis instance: ${import_logger.Logger.standardText(env)}
|
|
363
|
-
|
|
364
|
+
Connect to Contensis instance: ${import_logger.Logger.standardText(env)}
|
|
365
|
+
- Project id: ${import_logger.Logger.standardText(projectId)}
|
|
366
|
+
`,
|
|
364
367
|
developmentKey: (name, existing) => ` - ${!existing ? "Create development API key" : "Development API key found"}: ${import_logger.Logger[!existing ? "highlightText" : "standardText"](name)}`,
|
|
365
368
|
deploymentKey: (name, existing) => ` - ${!existing ? "Create deployment API key" : "Deployment API key found"}: ${import_logger.Logger[!existing ? "highlightText" : "standardText"](name)}`,
|
|
366
369
|
ciIntro: (git, location) => `We will create API keys with permissions to use this project with Contensis, and add a job to your CI that will deploy a container build.
|
|
@@ -440,7 +443,10 @@ ${git.type === "github" ? `Add a "New repository secret"` : `Expand "Variables"
|
|
|
440
443
|
noChanges: () => `No changes were made to your project, run the command again without the ${import_logger.Logger.highlightText(
|
|
441
444
|
"--dry-run"
|
|
442
445
|
)} flag to update your project with these changes`,
|
|
443
|
-
startProjectTip: () => `Start up your project in the normal way for development
|
|
446
|
+
startProjectTip: () => `Start up your project in the normal way for development`,
|
|
447
|
+
blockIdQuestion: () => `Please enter your block id, this should be unquie and in kebab case e.g ${import_logger.Logger.highlightText(
|
|
448
|
+
"my-awesome-website"
|
|
449
|
+
)}`
|
|
444
450
|
}
|
|
445
451
|
};
|
|
446
452
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/localisation/en-GB.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n BlockActionType,\n BlockRunningStatus,\n MigrateModelsResult,\n MigrateStatus,\n} from 'migratortron';\nimport { GitHelper } from '~/util/git';\nimport { Logger } from '~/util/logger';\nimport { winSlash } from '~/util/os';\n\nexport const LogMessages = {\n app: {\n contensis: () => 'Contensis',\n quit: () => `Goodbye \uD83D\uDC4B\\n`,\n startup: (version: string) =>\n `v${version} \u00A9 2001-${new Date().getFullYear()} Zengenti \uD83C\uDDEC\uD83C\uDDE7. \\n - Creators of Contensis and purveyors of other fine software\\n\\n\uD83D\uDC4B Welcome to the contensis-cli\\n`,\n help: () =>\n 'Press [CTRL]+[C] or type \"quit\" to return to your system shell\\nPress [TAB] for suggestions\\n',\n suggestions: () =>\n `\\n${Logger.errorText('>>')} Press [TAB] for suggestions\\n`,\n autocomplete: () => `\\n${Logger.errorText('>>')} Available commands:`,\n unknownError: () => `Something went wrong...`,\n fileOutput: (format = 'json', path?: string) =>\n `Output ${format} file: ${Logger.infoText(path)}\\n`,\n noFileOutput: () => `No output written\\n`,\n },\n command: {\n notKnown: (command: string) => `${command} is not known`,\n },\n envs: {\n found: (num: number) =>\n `environments store found containing ${num} environment${\n num === 1 ? '' : 's'\n }`,\n tip: () =>\n `Connect to a Contensis cloud instance using \"contensis connect {cms alias}\"`,\n },\n connect: {\n command: {\n name: () => 'connect',\n example: () => `Example call:\\n > connect example-dev`,\n },\n args: {\n alias: {\n name: () => '<alias>',\n description: () => 'the Contensis Cloud alias to connect with',\n },\n },\n noEnv: () => `Cannot connect - no environment alias specified`,\n unreachable: (url: string, status: number) =>\n `Cannot reach ${url}${status ? ` - status ${status}` : ''}`,\n connected: (env: string) => `Current environment set to \"${env}\"`,\n help: () =>\n `Connect to a Contensis cloud instance using \"contensis connect {cms alias}\"`,\n projects: () => `Available projects:`,\n noProjects: () => `Cannot retrieve projects list`,\n tip: () =>\n `Introduce yourself with \"login {username}\" or \"login {clientId} -s {secret}\" or by passing credentials as options with your command`,\n },\n login: {\n command: {\n name: () => 'login',\n usage: () => `<user/clientId> [password] [-s <sharedSecret>]`,\n example: () =>\n `Example call:\\n > login myuserid\\n -- or --\\n > login {clientId} -s {sharedSecret}`,\n },\n args: {\n user: {\n name: () => '<user/clientId>',\n description: () => 'the username to login with',\n },\n password: {\n name: () => '[password]',\n description: () =>\n 'the password to use to login with (optional/insecure)',\n },\n secret: {\n name: () => '-s --sharedSecret <sharedSecret>',\n description: () =>\n 'the shared secret to use when logging in with a client id',\n },\n },\n passwordPrompt: (env?: string, userId?: string) =>\n userId\n ? `Enter password for ${userId}@${env}:`\n : `Please enter a password`,\n failed: (env: string, userId: string) =>\n `Unable to login to ${env} as ${userId}`,\n success: (env: string, userId: string) =>\n `User ${userId} connected to ${env} successfully\\n`,\n insecurePassword: () =>\n `Could not connect to local keystore - your password could be stored unencrypted!`,\n noEnv: () => `No environment set, use \"contensis connect {alias}\" first`,\n noUserId: () => `No user id specified`,\n },\n projects: {\n list: () => `Available projects:`,\n noList: () => `Cannot retrieve projects list`,\n set: (projectId: string) =>\n `Current project is set to ${Logger.highlightText(projectId)}`,\n failedSet: (projectId: string) =>\n `Project ${Logger.highlightText(projectId)} not found`,\n tip: () =>\n `You need to set your current working project with \"set project {projectId}\"`,\n created: (env: string, id: string) =>\n `[${env}] Created project ${Logger.highlightText(id)}`,\n failedCreate: (env: string, id: string) =>\n `[${env}] Unable to create project ${Logger.highlightText(id)}`,\n updated: (env: string, id: string) =>\n `[${env}] Updated project ${Logger.highlightText(id)}`,\n failedUpdate: (env: string, id: string) =>\n `[${env}] Unable to update project ${Logger.highlightText(id)}`,\n },\n migrate: {\n models: {\n result: (\n status: keyof MigrateModelsResult['project']['contentTypes']\n ) => {\n switch (status) {\n case 'created':\n case 'updated':\n return Logger.successText;\n case 'errors':\n return Logger.errorText;\n default:\n return Logger.infoText;\n }\n },\n },\n status: (status: MigrateStatus) => {\n switch (status) {\n case 'no change':\n return Logger.successText;\n case 'create':\n case 'two-pass':\n case 'update':\n case 'delete':\n return Logger.warningText;\n case 'error':\n case 'not found':\n return Logger.errorText;\n default:\n return Logger.infoText;\n }\n },\n },\n models: {\n list: (projectId: string) =>\n `Content models in ${Logger.highlightText(projectId)}:`,\n noList: (projectId: string) =>\n `[${projectId}] Cannot retrieve content models`,\n get: (projectId: string, id: string) =>\n `[${projectId}] Content models ${Logger.infoText(`[ ${id} ]`)}`,\n failedGet: (projectId: string, id: string) =>\n `[${projectId}] Unable to get content models ${Logger.highlightText(id)}`,\n },\n nodes: {\n imported: (env: string, commit: boolean, count: number) =>\n `[${env}] ${commit ? `Imported` : `Will import`} ${count} nodes`,\n failedImport: (env: string) => `[${env}] Unable to import nodes`,\n removed: (env: string, commit: boolean) =>\n `[${env}] ${commit ? `Deleted` : `Will delete`} nodes`,\n failedRemove: (env: string) => `[${env}] Unable to delete nodes`,\n notFound: (env: string) => `[${env}] Nodes were not found `,\n commitTip: () => `Add --commit flag to commit the previewed changes`,\n failedGet: (projectId: string) =>\n `[${projectId}] Cannot retrieve nodes from Site view`,\n get: (projectId: string, root: string, depth: number) =>\n `[${projectId}] Site view nodes at: ${Logger.highlightText(root)}${\n depth ? ` to a depth of ${depth}` : ``\n }\\n`,\n noChange: (env: string) => `[${env}] No changes to be made`,\n },\n contenttypes: {\n list: (projectId: string) =>\n `Content types in ${Logger.highlightText(projectId)}:`,\n get: (projectId: string, id: string) =>\n `[${projectId}] Content type ${Logger.highlightText(id)}`,\n failedGet: (projectId: string, id: string) =>\n `[${projectId}] Unable to get content type ${Logger.highlightText(id)}`,\n created: (projectId: string, id: string, status?: string) =>\n `[${projectId}] Content type ${status}d ${Logger.highlightText(id)}`,\n removed: (env: string, id: string, commit: boolean) =>\n `[${env}] ${\n commit ? `Deleted` : `Will delete`\n } content type ${Logger.highlightText(id)}`,\n failedRemove: (env: string, id: string) =>\n `[${env}] Unable to delete content type ${Logger.highlightText(id)}`,\n },\n components: {\n list: (projectId: string) =>\n `Components in ${Logger.highlightText(projectId)}:`,\n get: (projectId: string, id: string) =>\n `[${projectId}] Component ${Logger.highlightText(id)}`,\n failedGet: (projectId: string, id: string) =>\n `[${projectId}] Unable to get component ${Logger.highlightText(id)}`,\n created: (projectId: string, id: string, status?: string) =>\n `[${projectId}] Component ${status}d ${Logger.highlightText(id)}`,\n removed: (env: string, id: string, commit: boolean) =>\n `[${env}] ${\n commit ? `Deleted` : `Will delete`\n } component ${Logger.highlightText(id)}`,\n failedRemove: (env: string, id: string) =>\n `[${env}] Unable to delete component ${Logger.highlightText(id)}`,\n },\n version: {\n set: (env: string, versionStatus: string) =>\n `[${env}] Content version status set to \"${versionStatus}\"`,\n invalid: (versionStatus: string) =>\n `Content version status \"${versionStatus}\" is not valid, allowed values are \"published\" or \"latest\".`,\n noEnv: () =>\n `No Contensis environment set, connect to your Contensis cloud instance using \"contensis connect {cms alias}\"`,\n },\n entries: {\n imported: (env: string, commit: boolean, count: number) =>\n `[${env}] ${commit ? `Imported` : `Will import`} ${count} entries`,\n failedImport: (env: string) => `[${env}] Unable to import entries`,\n removed: (env: string, commit: boolean) =>\n `[${env}] ${commit ? `Deleted` : `Will delete`} entries`,\n failedRemove: (env: string) => `[${env}] Unable to delete entries`,\n notFound: (env: string) => `[${env}] Entries were not found`,\n commitTip: () => `Add --commit flag to commit the previewed changes`,\n },\n keys: {\n list: (env: string) => `[${env}] API keys:`,\n noList: (env: string) => `[${env}] Cannot retrieve API keys`,\n created: (env: string, name: string) =>\n `[${env}] Created API key ${Logger.highlightText(name)}`,\n tip: () =>\n `Assign your new key to a role with \"set role assignments\", or create a new role with \"create role\"`,\n failedCreate: (env: string, name: string) =>\n `[${env}] Unable to create API key ${Logger.highlightText(name)}`,\n failedUpdate: (env: string, name: string) =>\n `[${env}] Unable to update API key ${Logger.highlightText(name)}`,\n removed: (env: string, id: string) =>\n `[${env}] Deleted API key ${Logger.highlightText(id)}`,\n failedRemove: (env: string, id: string) =>\n `[${env}] Unable to delete API key ${Logger.highlightText(id)}`,\n },\n proxies: {\n list: (env: string, projectId: string | undefined) =>\n `[${env}] Retrieved proxies in project ${projectId}:`,\n noList: (env: string, projectId: string | undefined) =>\n `[${env}] Cannot retrieve proxies in project ${projectId}`,\n // noneExist: () => `Create a role with \"create renderer\"`,\n failedGet: (env: string, name: string, projectId: string) =>\n `[${env}] Unable to find proxy ${Logger.highlightText(\n name\n )} in project ${projectId}`,\n created: (env: string, name: string, projectId: string) =>\n `[${env}] Created proxy ${Logger.highlightText(\n name\n )} in project ${projectId}\\n`,\n failedCreate: (env: string, name: string, projectId: string) =>\n `[${env}] Unable to create proxy ${Logger.highlightText(\n name\n )} in project ${projectId}`,\n setPayload: () => `Updating proxy with details\\n`,\n set: () => `Succesfully updated proxy\\n`,\n failedSet: (env: string, name: string, projectId: string) =>\n `[${env}] Unable to update proxy ${Logger.highlightText(\n name\n )} in project ${projectId}`,\n removed: (env: string, id: string, projectId: string) =>\n `[${env}] Deleted proxy ${Logger.highlightText(\n id\n )} in project ${projectId}\\n`,\n failedRemove: (env: string, id: string, projectId: string) =>\n `[${env}] Unable to delete proxy ${Logger.highlightText(\n id\n )} in project ${projectId}`,\n },\n renderers: {\n list: (env: string, projectId: string | undefined) =>\n `[${env}] Retrieved renderers in project ${projectId}:`,\n noList: (env: string, projectId: string | undefined) =>\n `[${env}] Cannot retrieve renderers in project ${projectId}`,\n // noneExist: () => `Create a role with \"create renderer\"`,\n failedGet: (env: string, name: string, projectId: string) =>\n `[${env}] Unable to find renderer ${Logger.highlightText(\n name\n )} in project ${projectId}`,\n created: (env: string, name: string, projectId: string) =>\n `[${env}] Created renderer ${Logger.highlightText(\n name\n )} in project ${projectId}\\n`,\n failedCreate: (env: string, name: string, projectId: string) =>\n `[${env}] Unable to create renderer ${Logger.highlightText(\n name\n )} in project ${projectId}`,\n setPayload: () => `Updating renderer with details\\n`,\n set: () => `Succesfully updated renderer\\n`,\n failedSet: (env: string, name: string, projectId: string) =>\n `[${env}] Unable to update renderer ${Logger.highlightText(\n name\n )} in project ${projectId}`,\n removed: (env: string, id: string, projectId: string) =>\n `[${env}] Deleted renderer ${Logger.highlightText(\n id\n )} in project ${projectId}\\n`,\n failedRemove: (env: string, id: string, projectId: string) =>\n `[${env}] Unable to delete renderer ${Logger.highlightText(\n id\n )} in project ${projectId}`,\n },\n roles: {\n list: (env: string) => `[${env}] Retrieved roles`,\n noList: (env: string) => `[${env}] Cannot retrieve roles`,\n noneExist: () => `Create a role with \"create role\"`,\n failedGet: (env: string, name: string) =>\n `[${env}] Unable to find role ${Logger.highlightText(name)}`,\n created: (env: string, name: string) =>\n `[${env}] Created role ${Logger.highlightText(name)}\\n`,\n tip: () =>\n `Give access to your role with \"set role assignments\", allow your role to do things with \"set role permissions\"`,\n failedCreate: (env: string, name?: string) =>\n `[${env}] Unable to create role ${Logger.highlightText(name)}`,\n setPayload: () => `Updating role with details\\n`,\n set: () => `Succesfully updated role\\n`,\n failedSet: (env: string, name?: string) =>\n `[${env}] Unable to update role ${Logger.highlightText(name)}`,\n removed: (env: string, id: string) =>\n `[${env}] Deleted role ${Logger.highlightText(id)}\\n`,\n failedRemove: (env: string, id: string) =>\n `[${env}] Unable to delete role ${Logger.highlightText(id)}`,\n },\n blocks: {\n runningStatus: (status: BlockRunningStatus | 'broken') => {\n switch (status) {\n case 'available':\n return Logger.successText(status);\n case 'pending':\n case 'starting':\n case 'stopped':\n return Logger.warningText(status);\n case 'degraded':\n case 'faulted':\n case 'broken':\n return Logger.errorText(status);\n default:\n return Logger.infoText(status);\n }\n },\n get: (id: string, env: string, projectId?: string) =>\n `[${env}] Block ${id} in project ${projectId}:`,\n list: (env: string, projectId?: string) =>\n `[${env}] Blocks in project ${projectId}:`,\n noList: (env: string, projectId?: string) =>\n `[${env}] Cannot retrieve blocks in project ${projectId}`,\n getLogs: (id: string, branch: string, env: string, projectId?: string) =>\n `[${env}] Requesting logs from block ${Logger.highlightText(\n id\n )} in branch ${branch} in project ${projectId}`,\n failedGetLogs: (id: string, env: string, projectId?: string) =>\n `[${env}] Unable to fetch block logs for ${Logger.highlightText(\n id\n )} in project ${projectId}`,\n tryPush: (id: string, branch: string, env: string, projectId?: string) =>\n `[${env}] Request to push block ${Logger.highlightText(\n id\n )} in branch ${branch} in project ${projectId}`,\n pushed: (id: string, branch: string, env: string, projectId?: string) =>\n `[${env}] Pushed block ${Logger.highlightText(\n id\n )} in branch ${branch} in project ${projectId}`,\n failedPush: (id: string, env: string, projectId?: string) =>\n `[${env}] Unable to push block ${Logger.highlightText(\n id\n )} in project ${projectId}`,\n latestVersion: (\n version: string,\n id: string,\n env: string,\n projectId?: string\n ) =>\n `[${env}] Found latest block version ${Logger.highlightText(\n id\n )} in project ${projectId} ${Logger.highlightText(version)}`,\n failedParsingVersion: () =>\n `Did not find a \"version.versionNo\" in response`,\n actionComplete: (\n action: BlockActionType,\n id: string,\n env: string,\n projectId?: string\n ) =>\n `[${env}] Action ${Logger.highlightText(\n action\n )} on ${Logger.highlightText(\n id\n )} in project ${projectId} requested successfully`,\n actionFailed: (\n action: BlockActionType,\n id: string,\n env: string,\n projectId?: string\n ) =>\n `[${env}] Problem executing ${action} on block ${Logger.highlightText(\n id\n )} in project ${projectId}`,\n deleted: (id: string, env: string, projectId?: string) =>\n `[${env}] Deleted block ${Logger.highlightText(\n id\n )} in project ${projectId}`,\n failedDelete: (id: string, env: string, projectId?: string) =>\n `[${env}] Unable to delete block ${Logger.highlightText(\n id\n )} in project ${projectId}`,\n stopFollow: (id: string, env: string, projectId?: string) =>\n `[${env}]\\n\\n \uD83D\uDC4C stop fetching new ${Logger.highlightText(\n id\n )} logs in project ${projectId}`,\n timeoutFollow: (id: string, env: string, projectId?: string) =>\n `[${env}]\\n\\n \uD83E\uDD0F pausing fetching new ${Logger.highlightText(\n id\n )} logs in project ${projectId} due to too many requests`,\n },\n webhooks: {\n list: (env: string) => `[${env}] Webhook subscriptions:`,\n noList: (env: string) => `[${env}] Cannot retrieve webhook subscriptions`,\n noneExist: () => `No webhook subscriptions exist`,\n created: (env: string, name: string) =>\n `[${env}] Created Webhook subscription ${Logger.highlightText(name)}`,\n failedCreate: (env: string, name: string) =>\n `[${env}] Unable to create Webhook subscription ${Logger.highlightText(\n name\n )}`,\n deleted: (env: string, id: string) =>\n `[${env}] Deleted Webhook subscription ${Logger.highlightText(id)}`,\n failedDelete: (env: string, id: string) =>\n `[${env}] Unable to delete Webhook subscription ${Logger.highlightText(\n id\n )}`,\n },\n devinit: {\n intro: () => `Contensis developer environment initialisation`,\n //`This will initialise your local working directory to develop with the current connected Contensis project`,\n projectDetails: (\n name: string,\n env: string,\n projectId: string,\n git: GitHelper\n ) =>\n `Project: ${Logger.highlightText(name)} set arg --name to override\n - Home: ${Logger.standardText(process.cwd())}\n - Repository: ${git.home} \n \nConnect to Contensis instance: ${Logger.standardText(env)}\n - Project id: ${Logger.standardText(projectId)}`,\n developmentKey: (name: string, existing: boolean) =>\n ` - ${\n !existing ? 'Create development API key' : 'Development API key found'\n }: ${Logger[!existing ? 'highlightText' : 'standardText'](name)}`,\n deploymentKey: (name: string, existing: boolean) =>\n ` - ${\n !existing ? 'Create deployment API key' : 'Deployment API key found'\n }: ${Logger[!existing ? 'highlightText' : 'standardText'](name)}`,\n ciIntro: (git: GitHelper, location: 'git' | 'env') =>\n `We will create API keys with permissions to use this project with Contensis, and add a job to your CI that will deploy a container build.\n ${\n location === 'git'\n ? `We will ask you to add secrets/variables to your git repository to give your workflow permission to push a Block to Contensis.\n ${Logger.infoText(`You could visit ${git.secretsUri} to check that you can see repository settings, \n a page not found generally indicates you need to ask the repo owner for permission to add repository secrets, \n or ask the repo owner to add these secrets for you.`)}`\n : ''\n }`,\n ciDetails: (filename: string) =>\n `Add push-block job to CI file: ${Logger.highlightText(filename)}\\n`,\n ciMultipleChoices: () =>\n `Multiple GitHub workflow files found\\n${Logger.infoText(\n `Tell us which GitHub workflow builds a container image after each push:`\n )}`,\n ciMultipleBuildJobChoices: () =>\n `Multiple build jobs found in workflow\\n${Logger.infoText(\n `Choose the build job that produces a fresh container image to push to a block:`\n )}`,\n ciMultipleJobChoices: () =>\n `Other jobs found in workflow\\n${Logger.infoText(\n `Choose the job that produces a fresh container image we can push to a block:`\n )}`,\n ciMultipleAppImageVarChoices: () =>\n `Do one of these variables point to your tagged app image?\\n${Logger.infoText(\n `we have included a default choice - ensure your build image is tagged exactly the same as this`\n )}`,\n ciEnterOwnAppImagePrompt: (git: GitHelper) =>\n `Tell us the registry uri your app image is tagged and pushed with (\u23CE accept default) \\n${Logger.infoText(\n `Tip: ${\n git.type === 'github'\n ? `GitHub context variables available\\nhttps://docs.github.com/en/actions/learn-github-actions/variables#using-contexts-to-access-variable-values`\n : `GitLab CI/CD variables available\\nhttps://docs.gitlab.com/ee/ci/variables/`\n }`\n )}\\n`,\n confirm: () =>\n `Confirm these details are correct so we can make changes to your project`,\n createDevKey: (keyName: string, existing: boolean) =>\n `${\n !existing ? 'Created' : 'Checked permissions for'\n } development API key ${Logger.standardText(keyName)}`,\n createDeployKey: (keyName: string, existing: boolean) =>\n `${\n !existing ? 'Created' : 'Checked permissions for'\n } deployment API key ${Logger.standardText(keyName)}`,\n createKeyFail: (keyName: string, existing: boolean) =>\n `Failed to ${\n !existing ? 'create' : 'update'\n } API key ${Logger.highlightText(keyName)}`,\n writeEnvFile: () => `Written .env file to project home directory`,\n useEnvFileTip: () =>\n `You should alter existing project code that connects a Contensis client to use the variables from this file`,\n writeCiFile: (ciFilePath: string) =>\n `Updated CI file ${Logger.standardText(winSlash(ciFilePath))}`,\n ciFileNoChanges: (ciFilePath: string) =>\n `No updates needed for CI file ${Logger.standardText(\n winSlash(ciFilePath)\n )}`,\n ciBlockTip: (blockId: string, env: string, projectId: string) =>\n `A job is included to deploy your built container image to ${Logger.standardText(\n projectId\n )} at ${Logger.standardText(env)} in a block called ${Logger.standardText(\n blockId\n )}`,\n addGitSecretsIntro: () =>\n `We have created an API key that allows you to deploy your app image to a Contensis Block but we need you to add these details to your GitLab repository.`,\n addGitSecretsHelp: (git: GitHelper, id?: string, secret?: string) =>\n `Add secrets or variables in your repository's settings page\\n\\nGo to ${Logger.highlightText(\n git.secretsUri\n )}\\n\\n${\n git.type === 'github'\n ? `Add a \"New repository secret\"`\n : `Expand \"Variables\" and hit \"Add variable\"`\n }\\n\\n ${\n git.type === 'github' ? `Secret name:` : `Key:`\n } ${Logger.highlightText(`CONTENSIS_CLIENT_ID`)}\\n ${\n git.type === 'github' ? `Secret:` : `Value:`\n } ${Logger.standardText(\n id\n )}\\n\\n ${`Add one more secret/variable to the repository`}\\n\\n ${\n git.type === 'github' ? `Secret name:` : `Key:`\n } ${Logger.highlightText(`CONTENSIS_SHARED_SECRET`)}\\n ${\n git.type === 'github' ? `Secret:` : `Value:`\n } ${Logger.standardText(secret)}`,\n accessTokenFetch: () => `Please wait, fecthing Delivery API token \u23F3`,\n accessTokenSuccess: (token: string) =>\n `Successfully fetched Delivery API token \uD83D\uDC49 ${Logger.infoText(token)}`,\n accessTokenFailed: () =>\n `Something went wrong! If the problem persists, please contact our support team \uD83D\uDEDF`,\n accessTokenPermission: () =>\n `We need permission to fetch your Delivery API token, please try again \u26A0\uFE0F`,\n clientDetailsLocation: () =>\n `Which option would you like to use for storing your client ID and secret`,\n clientDetailsInGit: (git: GitHelper) =>\n `${\n git.type === 'github' ? 'GitHub' : 'GitLab'\n } variables (recommended for public repositories)`,\n clientDetailsInEnv: () =>\n `Env variables (recommended for private repositories)`,\n success: () => `Contensis developer environment initialisation complete`,\n partialSuccess: () =>\n `Contensis developer environment initialisation completed with errors`,\n failed: () => `Contensis developer environment initialisation failed`,\n dryRun: () =>\n `Contensis developer environment initialisation dry run completed`,\n noChanges: () =>\n `No changes were made to your project, run the command again without the ${Logger.highlightText(\n '--dry-run'\n )} flag to update your project with these changes`,\n startProjectTip: () =>\n `Start up your project in the normal way for development`,\n },\n};\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAOA,oBAAuB;AACvB,gBAAyB;AAElB,MAAM,cAAc;AAAA,EACzB,KAAK;AAAA,IACH,WAAW,MAAM;AAAA,IACjB,MAAM,MAAM;AAAA;AAAA,IACZ,SAAS,CAAC,YACR,IAAI,qBAAkB,IAAI,KAAK,EAAE,YAAY;AAAA;AAAA;AAAA;AAAA;AAAA,IAC/C,MAAM,MACJ;AAAA,IACF,aAAa,MACX;AAAA,EAAK,qBAAO,UAAU,IAAI;AAAA;AAAA,IAC5B,cAAc,MAAM;AAAA,EAAK,qBAAO,UAAU,IAAI;AAAA,IAC9C,cAAc,MAAM;AAAA,IACpB,YAAY,CAAC,SAAS,QAAQ,SAC5B,UAAU,gBAAgB,qBAAO,SAAS,IAAI;AAAA;AAAA,IAChD,cAAc,MAAM;AAAA;AAAA,EACtB;AAAA,EACA,SAAS;AAAA,IACP,UAAU,CAAC,YAAoB,GAAG;AAAA,EACpC;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BAAiB,UACvC,qBAAO,cAAc,qBAAqB;AAAA,MAC5C,IAAI,SAAS,WAAW,YAAY,YAClC,qBAAO;AAAA,MACT;AAAA,IACF;AAAA;AAAA,GAAS;AAAA;AAAA,MACP,IAAI,SAAS,WAAW,iBAAiB,UACvC,qBAAO,cAAc,yBAAyB;AAAA,MAChD,IAAI,SAAS,WAAW,YAAY,YAClC,qBAAO,aAAa,MAAM;AAAA,IAChC,kBAAkB,MAAM;AAAA,IACxB,oBAAoB,CAAC,UACnB,qDAA8C,qBAAO,SAAS,KAAK;AAAA,IACrE,mBAAmB,MACjB;AAAA,IACF,uBAAuB,MACrB;AAAA,IACF,uBAAuB,MACrB;AAAA,IACF,oBAAoB,CAAC,QACnB,GACE,IAAI,SAAS,WAAW,WAAW;AAAA,IAEvC,oBAAoB,MAClB;AAAA,IACF,SAAS,MAAM;AAAA,IACf,gBAAgB,MACd;AAAA,IACF,QAAQ,MAAM;AAAA,IACd,QAAQ,MACN;AAAA,IACF,WAAW,MACT,2EAA2E,qBAAO;AAAA,MAChF;AAAA,IACF;AAAA,IACF,iBAAiB,MACf;AAAA,EACJ;AACF;",
|
|
4
|
+
"sourcesContent": ["import {\n BlockActionType,\n BlockRunningStatus,\n MigrateModelsResult,\n MigrateStatus,\n} from 'migratortron';\nimport { GitHelper } from '~/util/git';\nimport { Logger } from '~/util/logger';\nimport { winSlash } from '~/util/os';\n\nexport const LogMessages = {\n app: {\n contensis: () => 'Contensis',\n quit: () => `Goodbye \uD83D\uDC4B\\n`,\n startup: (version: string) =>\n `v${version} \u00A9 2001-${new Date().getFullYear()} Zengenti \uD83C\uDDEC\uD83C\uDDE7. \\n - Creators of Contensis and purveyors of other fine software\\n\\n\uD83D\uDC4B Welcome to the contensis-cli\\n`,\n help: () =>\n 'Press [CTRL]+[C] or type \"quit\" to return to your system shell\\nPress [TAB] for suggestions\\n',\n suggestions: () =>\n `\\n${Logger.errorText('>>')} Press [TAB] for suggestions\\n`,\n autocomplete: () => `\\n${Logger.errorText('>>')} Available commands:`,\n unknownError: () => `Something went wrong...`,\n fileOutput: (format = 'json', path?: string) =>\n `Output ${format} file: ${Logger.infoText(path)}\\n`,\n noFileOutput: () => `No output written\\n`,\n },\n command: {\n notKnown: (command: string) => `${command} is not known`,\n },\n envs: {\n found: (num: number) =>\n `environments store found containing ${num} environment${\n num === 1 ? '' : 's'\n }`,\n tip: () =>\n `Connect to a Contensis cloud instance using \"contensis connect {cms alias}\"`,\n },\n connect: {\n command: {\n name: () => 'connect',\n example: () => `Example call:\\n > connect example-dev`,\n },\n args: {\n alias: {\n name: () => '<alias>',\n description: () => 'the Contensis Cloud alias to connect with',\n },\n },\n noEnv: () => `Cannot connect - no environment alias specified`,\n unreachable: (url: string, status: number) =>\n `Cannot reach ${url}${status ? ` - status ${status}` : ''}`,\n connected: (env: string) => `Current environment set to \"${env}\"`,\n help: () =>\n `Connect to a Contensis cloud instance using \"contensis connect {cms alias}\"`,\n projects: () => `Available projects:`,\n noProjects: () => `Cannot retrieve projects list`,\n tip: () =>\n `Introduce yourself with \"login {username}\" or \"login {clientId} -s {secret}\" or by passing credentials as options with your command`,\n },\n login: {\n command: {\n name: () => 'login',\n usage: () => `<user/clientId> [password] [-s <sharedSecret>]`,\n example: () =>\n `Example call:\\n > login myuserid\\n -- or --\\n > login {clientId} -s {sharedSecret}`,\n },\n args: {\n user: {\n name: () => '<user/clientId>',\n description: () => 'the username to login with',\n },\n password: {\n name: () => '[password]',\n description: () =>\n 'the password to use to login with (optional/insecure)',\n },\n secret: {\n name: () => '-s --sharedSecret <sharedSecret>',\n description: () =>\n 'the shared secret to use when logging in with a client id',\n },\n },\n passwordPrompt: (env?: string, userId?: string) =>\n userId\n ? `Enter password for ${userId}@${env}:`\n : `Please enter a password`,\n failed: (env: string, userId: string) =>\n `Unable to login to ${env} as ${userId}`,\n success: (env: string, userId: string) =>\n `User ${userId} connected to ${env} successfully\\n`,\n insecurePassword: () =>\n `Could not connect to local keystore - your password could be stored unencrypted!`,\n noEnv: () => `No environment set, use \"contensis connect {alias}\" first`,\n noUserId: () => `No user id specified`,\n },\n projects: {\n list: () => `Available projects:`,\n noList: () => `Cannot retrieve projects list`,\n set: (projectId: string) =>\n `Current project is set to ${Logger.highlightText(projectId)}`,\n failedSet: (projectId: string) =>\n `Project ${Logger.highlightText(projectId)} not found`,\n tip: () =>\n `You need to set your current working project with \"set project {projectId}\"`,\n created: (env: string, id: string) =>\n `[${env}] Created project ${Logger.highlightText(id)}`,\n failedCreate: (env: string, id: string) =>\n `[${env}] Unable to create project ${Logger.highlightText(id)}`,\n updated: (env: string, id: string) =>\n `[${env}] Updated project ${Logger.highlightText(id)}`,\n failedUpdate: (env: string, id: string) =>\n `[${env}] Unable to update project ${Logger.highlightText(id)}`,\n },\n migrate: {\n models: {\n result: (\n status: keyof MigrateModelsResult['project']['contentTypes']\n ) => {\n switch (status) {\n case 'created':\n case 'updated':\n return Logger.successText;\n case 'errors':\n return Logger.errorText;\n default:\n return Logger.infoText;\n }\n },\n },\n status: (status: MigrateStatus) => {\n switch (status) {\n case 'no change':\n return Logger.successText;\n case 'create':\n case 'two-pass':\n case 'update':\n case 'delete':\n return Logger.warningText;\n case 'error':\n case 'not found':\n return Logger.errorText;\n default:\n return Logger.infoText;\n }\n },\n },\n models: {\n list: (projectId: string) =>\n `Content models in ${Logger.highlightText(projectId)}:`,\n noList: (projectId: string) =>\n `[${projectId}] Cannot retrieve content models`,\n get: (projectId: string, id: string) =>\n `[${projectId}] Content models ${Logger.infoText(`[ ${id} ]`)}`,\n failedGet: (projectId: string, id: string) =>\n `[${projectId}] Unable to get content models ${Logger.highlightText(id)}`,\n },\n nodes: {\n imported: (env: string, commit: boolean, count: number) =>\n `[${env}] ${commit ? `Imported` : `Will import`} ${count} nodes`,\n failedImport: (env: string) => `[${env}] Unable to import nodes`,\n removed: (env: string, commit: boolean) =>\n `[${env}] ${commit ? `Deleted` : `Will delete`} nodes`,\n failedRemove: (env: string) => `[${env}] Unable to delete nodes`,\n notFound: (env: string) => `[${env}] Nodes were not found `,\n commitTip: () => `Add --commit flag to commit the previewed changes`,\n failedGet: (projectId: string) =>\n `[${projectId}] Cannot retrieve nodes from Site view`,\n get: (projectId: string, root: string, depth: number) =>\n `[${projectId}] Site view nodes at: ${Logger.highlightText(root)}${\n depth ? ` to a depth of ${depth}` : ``\n }\\n`,\n noChange: (env: string) => `[${env}] No changes to be made`,\n },\n contenttypes: {\n list: (projectId: string) =>\n `Content types in ${Logger.highlightText(projectId)}:`,\n get: (projectId: string, id: string) =>\n `[${projectId}] Content type ${Logger.highlightText(id)}`,\n failedGet: (projectId: string, id: string) =>\n `[${projectId}] Unable to get content type ${Logger.highlightText(id)}`,\n created: (projectId: string, id: string, status?: string) =>\n `[${projectId}] Content type ${status}d ${Logger.highlightText(id)}`,\n removed: (env: string, id: string, commit: boolean) =>\n `[${env}] ${\n commit ? `Deleted` : `Will delete`\n } content type ${Logger.highlightText(id)}`,\n failedRemove: (env: string, id: string) =>\n `[${env}] Unable to delete content type ${Logger.highlightText(id)}`,\n },\n components: {\n list: (projectId: string) =>\n `Components in ${Logger.highlightText(projectId)}:`,\n get: (projectId: string, id: string) =>\n `[${projectId}] Component ${Logger.highlightText(id)}`,\n failedGet: (projectId: string, id: string) =>\n `[${projectId}] Unable to get component ${Logger.highlightText(id)}`,\n created: (projectId: string, id: string, status?: string) =>\n `[${projectId}] Component ${status}d ${Logger.highlightText(id)}`,\n removed: (env: string, id: string, commit: boolean) =>\n `[${env}] ${\n commit ? `Deleted` : `Will delete`\n } component ${Logger.highlightText(id)}`,\n failedRemove: (env: string, id: string) =>\n `[${env}] Unable to delete component ${Logger.highlightText(id)}`,\n },\n version: {\n set: (env: string, versionStatus: string) =>\n `[${env}] Content version status set to \"${versionStatus}\"`,\n invalid: (versionStatus: string) =>\n `Content version status \"${versionStatus}\" is not valid, allowed values are \"published\" or \"latest\".`,\n noEnv: () =>\n `No Contensis environment set, connect to your Contensis cloud instance using \"contensis connect {cms alias}\"`,\n },\n entries: {\n imported: (env: string, commit: boolean, count: number) =>\n `[${env}] ${commit ? `Imported` : `Will import`} ${count} entries`,\n failedImport: (env: string) => `[${env}] Unable to import entries`,\n removed: (env: string, commit: boolean) =>\n `[${env}] ${commit ? `Deleted` : `Will delete`} entries`,\n failedRemove: (env: string) => `[${env}] Unable to delete entries`,\n notFound: (env: string) => `[${env}] Entries were not found`,\n commitTip: () => `Add --commit flag to commit the previewed changes`,\n },\n keys: {\n list: (env: string) => `[${env}] API keys:`,\n noList: (env: string) => `[${env}] Cannot retrieve API keys`,\n created: (env: string, name: string) =>\n `[${env}] Created API key ${Logger.highlightText(name)}`,\n tip: () =>\n `Assign your new key to a role with \"set role assignments\", or create a new role with \"create role\"`,\n failedCreate: (env: string, name: string) =>\n `[${env}] Unable to create API key ${Logger.highlightText(name)}`,\n failedUpdate: (env: string, name: string) =>\n `[${env}] Unable to update API key ${Logger.highlightText(name)}`,\n removed: (env: string, id: string) =>\n `[${env}] Deleted API key ${Logger.highlightText(id)}`,\n failedRemove: (env: string, id: string) =>\n `[${env}] Unable to delete API key ${Logger.highlightText(id)}`,\n },\n proxies: {\n list: (env: string, projectId: string | undefined) =>\n `[${env}] Retrieved proxies in project ${projectId}:`,\n noList: (env: string, projectId: string | undefined) =>\n `[${env}] Cannot retrieve proxies in project ${projectId}`,\n // noneExist: () => `Create a role with \"create renderer\"`,\n failedGet: (env: string, name: string, projectId: string) =>\n `[${env}] Unable to find proxy ${Logger.highlightText(\n name\n )} in project ${projectId}`,\n created: (env: string, name: string, projectId: string) =>\n `[${env}] Created proxy ${Logger.highlightText(\n name\n )} in project ${projectId}\\n`,\n failedCreate: (env: string, name: string, projectId: string) =>\n `[${env}] Unable to create proxy ${Logger.highlightText(\n name\n )} in project ${projectId}`,\n setPayload: () => `Updating proxy with details\\n`,\n set: () => `Succesfully updated proxy\\n`,\n failedSet: (env: string, name: string, projectId: string) =>\n `[${env}] Unable to update proxy ${Logger.highlightText(\n name\n )} in project ${projectId}`,\n removed: (env: string, id: string, projectId: string) =>\n `[${env}] Deleted proxy ${Logger.highlightText(\n id\n )} in project ${projectId}\\n`,\n failedRemove: (env: string, id: string, projectId: string) =>\n `[${env}] Unable to delete proxy ${Logger.highlightText(\n id\n )} in project ${projectId}`,\n },\n renderers: {\n list: (env: string, projectId: string | undefined) =>\n `[${env}] Retrieved renderers in project ${projectId}:`,\n noList: (env: string, projectId: string | undefined) =>\n `[${env}] Cannot retrieve renderers in project ${projectId}`,\n // noneExist: () => `Create a role with \"create renderer\"`,\n failedGet: (env: string, name: string, projectId: string) =>\n `[${env}] Unable to find renderer ${Logger.highlightText(\n name\n )} in project ${projectId}`,\n created: (env: string, name: string, projectId: string) =>\n `[${env}] Created renderer ${Logger.highlightText(\n name\n )} in project ${projectId}\\n`,\n failedCreate: (env: string, name: string, projectId: string) =>\n `[${env}] Unable to create renderer ${Logger.highlightText(\n name\n )} in project ${projectId}`,\n setPayload: () => `Updating renderer with details\\n`,\n set: () => `Succesfully updated renderer\\n`,\n failedSet: (env: string, name: string, projectId: string) =>\n `[${env}] Unable to update renderer ${Logger.highlightText(\n name\n )} in project ${projectId}`,\n removed: (env: string, id: string, projectId: string) =>\n `[${env}] Deleted renderer ${Logger.highlightText(\n id\n )} in project ${projectId}\\n`,\n failedRemove: (env: string, id: string, projectId: string) =>\n `[${env}] Unable to delete renderer ${Logger.highlightText(\n id\n )} in project ${projectId}`,\n },\n roles: {\n list: (env: string) => `[${env}] Retrieved roles`,\n noList: (env: string) => `[${env}] Cannot retrieve roles`,\n noneExist: () => `Create a role with \"create role\"`,\n failedGet: (env: string, name: string) =>\n `[${env}] Unable to find role ${Logger.highlightText(name)}`,\n created: (env: string, name: string) =>\n `[${env}] Created role ${Logger.highlightText(name)}\\n`,\n tip: () =>\n `Give access to your role with \"set role assignments\", allow your role to do things with \"set role permissions\"`,\n failedCreate: (env: string, name?: string) =>\n `[${env}] Unable to create role ${Logger.highlightText(name)}`,\n setPayload: () => `Updating role with details\\n`,\n set: () => `Succesfully updated role\\n`,\n failedSet: (env: string, name?: string) =>\n `[${env}] Unable to update role ${Logger.highlightText(name)}`,\n removed: (env: string, id: string) =>\n `[${env}] Deleted role ${Logger.highlightText(id)}\\n`,\n failedRemove: (env: string, id: string) =>\n `[${env}] Unable to delete role ${Logger.highlightText(id)}`,\n },\n blocks: {\n runningStatus: (status: BlockRunningStatus | 'broken') => {\n switch (status) {\n case 'available':\n return Logger.successText(status);\n case 'pending':\n case 'starting':\n case 'stopped':\n return Logger.warningText(status);\n case 'degraded':\n case 'faulted':\n case 'broken':\n return Logger.errorText(status);\n default:\n return Logger.infoText(status);\n }\n },\n get: (id: string, env: string, projectId?: string) =>\n `[${env}] Block ${id} in project ${projectId}:`,\n list: (env: string, projectId?: string) =>\n `[${env}] Blocks in project ${projectId}:`,\n noList: (env: string, projectId?: string) =>\n `[${env}] Cannot retrieve blocks in project ${projectId}`,\n getLogs: (id: string, branch: string, env: string, projectId?: string) =>\n `[${env}] Requesting logs from block ${Logger.highlightText(\n id\n )} in branch ${branch} in project ${projectId}`,\n failedGetLogs: (id: string, env: string, projectId?: string) =>\n `[${env}] Unable to fetch block logs for ${Logger.highlightText(\n id\n )} in project ${projectId}`,\n tryPush: (id: string, branch: string, env: string, projectId?: string) =>\n `[${env}] Request to push block ${Logger.highlightText(\n id\n )} in branch ${branch} in project ${projectId}`,\n pushed: (id: string, branch: string, env: string, projectId?: string) =>\n `[${env}] Pushed block ${Logger.highlightText(\n id\n )} in branch ${branch} in project ${projectId}`,\n failedPush: (id: string, env: string, projectId?: string) =>\n `[${env}] Unable to push block ${Logger.highlightText(\n id\n )} in project ${projectId}`,\n latestVersion: (\n version: string,\n id: string,\n env: string,\n projectId?: string\n ) =>\n `[${env}] Found latest block version ${Logger.highlightText(\n id\n )} in project ${projectId} ${Logger.highlightText(version)}`,\n failedParsingVersion: () =>\n `Did not find a \"version.versionNo\" in response`,\n actionComplete: (\n action: BlockActionType,\n id: string,\n env: string,\n projectId?: string\n ) =>\n `[${env}] Action ${Logger.highlightText(\n action\n )} on ${Logger.highlightText(\n id\n )} in project ${projectId} requested successfully`,\n actionFailed: (\n action: BlockActionType,\n id: string,\n env: string,\n projectId?: string\n ) =>\n `[${env}] Problem executing ${action} on block ${Logger.highlightText(\n id\n )} in project ${projectId}`,\n deleted: (id: string, env: string, projectId?: string) =>\n `[${env}] Deleted block ${Logger.highlightText(\n id\n )} in project ${projectId}`,\n failedDelete: (id: string, env: string, projectId?: string) =>\n `[${env}] Unable to delete block ${Logger.highlightText(\n id\n )} in project ${projectId}`,\n stopFollow: (id: string, env: string, projectId?: string) =>\n `[${env}]\\n\\n \uD83D\uDC4C stop fetching new ${Logger.highlightText(\n id\n )} logs in project ${projectId}`,\n timeoutFollow: (id: string, env: string, projectId?: string) =>\n `[${env}]\\n\\n \uD83E\uDD0F pausing fetching new ${Logger.highlightText(\n id\n )} logs in project ${projectId} due to too many requests`,\n },\n webhooks: {\n list: (env: string) => `[${env}] Webhook subscriptions:`,\n noList: (env: string) => `[${env}] Cannot retrieve webhook subscriptions`,\n noneExist: () => `No webhook subscriptions exist`,\n created: (env: string, name: string) =>\n `[${env}] Created Webhook subscription ${Logger.highlightText(name)}`,\n failedCreate: (env: string, name: string) =>\n `[${env}] Unable to create Webhook subscription ${Logger.highlightText(\n name\n )}`,\n deleted: (env: string, id: string) =>\n `[${env}] Deleted Webhook subscription ${Logger.highlightText(id)}`,\n failedDelete: (env: string, id: string) =>\n `[${env}] Unable to delete Webhook subscription ${Logger.highlightText(\n id\n )}`,\n },\n devinit: {\n intro: () => `Contensis developer environment initialisation`,\n //`This will initialise your local working directory to develop with the current connected Contensis project`,\n projectDetails: (\n name: string,\n env: string,\n projectId: string,\n blockId: string,\n git: GitHelper\n ) =>\n `\n Project: ${Logger.standardText(name)}\n - Home: ${Logger.standardText(process.cwd())}\n - Repository: ${Logger.standardText(git.home)} \n - Block id: ${Logger.highlightText(blockId)}\n \n Connect to Contensis instance: ${Logger.standardText(env)}\n - Project id: ${Logger.standardText(projectId)}\n `,\n developmentKey: (name: string, existing: boolean) =>\n ` - ${\n !existing ? 'Create development API key' : 'Development API key found'\n }: ${Logger[!existing ? 'highlightText' : 'standardText'](name)}`,\n deploymentKey: (name: string, existing: boolean) =>\n ` - ${\n !existing ? 'Create deployment API key' : 'Deployment API key found'\n }: ${Logger[!existing ? 'highlightText' : 'standardText'](name)}`,\n ciIntro: (git: GitHelper, location: 'git' | 'env') =>\n `We will create API keys with permissions to use this project with Contensis, and add a job to your CI that will deploy a container build.\n ${\n location === 'git'\n ? `We will ask you to add secrets/variables to your git repository to give your workflow permission to push a Block to Contensis.\n ${Logger.infoText(`You could visit ${git.secretsUri} to check that you can see repository settings, \n a page not found generally indicates you need to ask the repo owner for permission to add repository secrets, \n or ask the repo owner to add these secrets for you.`)}`\n : ''\n }`,\n ciDetails: (filename: string) =>\n `Add push-block job to CI file: ${Logger.highlightText(filename)}\\n`,\n ciMultipleChoices: () =>\n `Multiple GitHub workflow files found\\n${Logger.infoText(\n `Tell us which GitHub workflow builds a container image after each push:`\n )}`,\n ciMultipleBuildJobChoices: () =>\n `Multiple build jobs found in workflow\\n${Logger.infoText(\n `Choose the build job that produces a fresh container image to push to a block:`\n )}`,\n ciMultipleJobChoices: () =>\n `Other jobs found in workflow\\n${Logger.infoText(\n `Choose the job that produces a fresh container image we can push to a block:`\n )}`,\n ciMultipleAppImageVarChoices: () =>\n `Do one of these variables point to your tagged app image?\\n${Logger.infoText(\n `we have included a default choice - ensure your build image is tagged exactly the same as this`\n )}`,\n ciEnterOwnAppImagePrompt: (git: GitHelper) =>\n `Tell us the registry uri your app image is tagged and pushed with (\u23CE accept default) \\n${Logger.infoText(\n `Tip: ${\n git.type === 'github'\n ? `GitHub context variables available\\nhttps://docs.github.com/en/actions/learn-github-actions/variables#using-contexts-to-access-variable-values`\n : `GitLab CI/CD variables available\\nhttps://docs.gitlab.com/ee/ci/variables/`\n }`\n )}\\n`,\n confirm: () =>\n `Confirm these details are correct so we can make changes to your project`,\n createDevKey: (keyName: string, existing: boolean) =>\n `${\n !existing ? 'Created' : 'Checked permissions for'\n } development API key ${Logger.standardText(keyName)}`,\n createDeployKey: (keyName: string, existing: boolean) =>\n `${\n !existing ? 'Created' : 'Checked permissions for'\n } deployment API key ${Logger.standardText(keyName)}`,\n createKeyFail: (keyName: string, existing: boolean) =>\n `Failed to ${\n !existing ? 'create' : 'update'\n } API key ${Logger.highlightText(keyName)}`,\n writeEnvFile: () => `Written .env file to project home directory`,\n useEnvFileTip: () =>\n `You should alter existing project code that connects a Contensis client to use the variables from this file`,\n writeCiFile: (ciFilePath: string) =>\n `Updated CI file ${Logger.standardText(winSlash(ciFilePath))}`,\n ciFileNoChanges: (ciFilePath: string) =>\n `No updates needed for CI file ${Logger.standardText(\n winSlash(ciFilePath)\n )}`,\n ciBlockTip: (blockId: string, env: string, projectId: string) =>\n `A job is included to deploy your built container image to ${Logger.standardText(\n projectId\n )} at ${Logger.standardText(env)} in a block called ${Logger.standardText(\n blockId\n )}`,\n addGitSecretsIntro: () =>\n `We have created an API key that allows you to deploy your app image to a Contensis Block but we need you to add these details to your GitLab repository.`,\n addGitSecretsHelp: (git: GitHelper, id?: string, secret?: string) =>\n `Add secrets or variables in your repository's settings page\\n\\nGo to ${Logger.highlightText(\n git.secretsUri\n )}\\n\\n${\n git.type === 'github'\n ? `Add a \"New repository secret\"`\n : `Expand \"Variables\" and hit \"Add variable\"`\n }\\n\\n ${\n git.type === 'github' ? `Secret name:` : `Key:`\n } ${Logger.highlightText(`CONTENSIS_CLIENT_ID`)}\\n ${\n git.type === 'github' ? `Secret:` : `Value:`\n } ${Logger.standardText(\n id\n )}\\n\\n ${`Add one more secret/variable to the repository`}\\n\\n ${\n git.type === 'github' ? `Secret name:` : `Key:`\n } ${Logger.highlightText(`CONTENSIS_SHARED_SECRET`)}\\n ${\n git.type === 'github' ? `Secret:` : `Value:`\n } ${Logger.standardText(secret)}`,\n accessTokenFetch: () => `Please wait, fecthing Delivery API token \u23F3`,\n accessTokenSuccess: (token: string) =>\n `Successfully fetched Delivery API token \uD83D\uDC49 ${Logger.infoText(token)}`,\n accessTokenFailed: () =>\n `Something went wrong! If the problem persists, please contact our support team \uD83D\uDEDF`,\n accessTokenPermission: () =>\n `We need permission to fetch your Delivery API token, please try again \u26A0\uFE0F`,\n clientDetailsLocation: () =>\n `Which option would you like to use for storing your client ID and secret`,\n clientDetailsInGit: (git: GitHelper) =>\n `${\n git.type === 'github' ? 'GitHub' : 'GitLab'\n } variables (recommended for public repositories)`,\n clientDetailsInEnv: () =>\n `Env variables (recommended for private repositories)`,\n success: () => `Contensis developer environment initialisation complete`,\n partialSuccess: () =>\n `Contensis developer environment initialisation completed with errors`,\n failed: () => `Contensis developer environment initialisation failed`,\n dryRun: () =>\n `Contensis developer environment initialisation dry run completed`,\n noChanges: () =>\n `No changes were made to your project, run the command again without the ${Logger.highlightText(\n '--dry-run'\n )} flag to update your project with these changes`,\n startProjectTip: () =>\n `Start up your project in the normal way for development`,\n blockIdQuestion: () =>\n `Please enter your block id, this should be unquie and in kebab case e.g ${Logger.highlightText(\n 'my-awesome-website'\n )}`,\n },\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAOA,oBAAuB;AACvB,gBAAyB;AAElB,MAAM,cAAc;AAAA,EACzB,KAAK;AAAA,IACH,WAAW,MAAM;AAAA,IACjB,MAAM,MAAM;AAAA;AAAA,IACZ,SAAS,CAAC,YACR,IAAI,qBAAkB,IAAI,KAAK,EAAE,YAAY;AAAA;AAAA;AAAA;AAAA;AAAA,IAC/C,MAAM,MACJ;AAAA,IACF,aAAa,MACX;AAAA,EAAK,qBAAO,UAAU,IAAI;AAAA;AAAA,IAC5B,cAAc,MAAM;AAAA,EAAK,qBAAO,UAAU,IAAI;AAAA,IAC9C,cAAc,MAAM;AAAA,IACpB,YAAY,CAAC,SAAS,QAAQ,SAC5B,UAAU,gBAAgB,qBAAO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oBAAoB,MAClB;AAAA,IACF,mBAAmB,CAAC,KAAgB,IAAa,WAC/C;AAAA;AAAA,QAAwE,qBAAO;AAAA,MAC7E,IAAI;AAAA,IACN;AAAA;AAAA,EACE,IAAI,SAAS,WACT,kCACA;AAAA;AAAA,MAEJ,IAAI,SAAS,WAAW,iBAAiB,UACvC,qBAAO,cAAc,qBAAqB;AAAA,MAC5C,IAAI,SAAS,WAAW,YAAY,YAClC,qBAAO;AAAA,MACT;AAAA,IACF;AAAA;AAAA,GAAS;AAAA;AAAA,MACP,IAAI,SAAS,WAAW,iBAAiB,UACvC,qBAAO,cAAc,yBAAyB;AAAA,MAChD,IAAI,SAAS,WAAW,YAAY,YAClC,qBAAO,aAAa,MAAM;AAAA,IAChC,kBAAkB,MAAM;AAAA,IACxB,oBAAoB,CAAC,UACnB,qDAA8C,qBAAO,SAAS,KAAK;AAAA,IACrE,mBAAmB,MACjB;AAAA,IACF,uBAAuB,MACrB;AAAA,IACF,uBAAuB,MACrB;AAAA,IACF,oBAAoB,CAAC,QACnB,GACE,IAAI,SAAS,WAAW,WAAW;AAAA,IAEvC,oBAAoB,MAClB;AAAA,IACF,SAAS,MAAM;AAAA,IACf,gBAAgB,MACd;AAAA,IACF,QAAQ,MAAM;AAAA,IACd,QAAQ,MACN;AAAA,IACF,WAAW,MACT,2EAA2E,qBAAO;AAAA,MAChF;AAAA,IACF;AAAA,IACF,iBAAiB,MACf;AAAA,IACF,iBAAiB,MACf,2EAA2E,qBAAO;AAAA,MAChF;AAAA,IACF;AAAA,EACJ;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -38,13 +38,11 @@ const mapCIWorkflowContent = async (cli) => {
|
|
|
38
38
|
const workflowFile = (0, import_file_provider.readFile)(cli.git.ciFilePath);
|
|
39
39
|
if (!workflowFile)
|
|
40
40
|
return void 0;
|
|
41
|
-
const blockId = cli.git.name;
|
|
42
41
|
const workflowDoc = (0, import_yaml2.parseYamlDocument)(workflowFile);
|
|
43
42
|
const workflowJS = workflowDoc.toJS();
|
|
44
43
|
if (cli.git.type === "github") {
|
|
45
44
|
const newWorkflow = await mapGitHubActionCIWorkflowContent(
|
|
46
45
|
cli,
|
|
47
|
-
blockId,
|
|
48
46
|
workflowDoc,
|
|
49
47
|
workflowJS
|
|
50
48
|
);
|
|
@@ -56,7 +54,6 @@ const mapCIWorkflowContent = async (cli) => {
|
|
|
56
54
|
} else if (cli.git.type === "gitlab") {
|
|
57
55
|
const newWorkflow = await mapGitLabCIWorkflowContent(
|
|
58
56
|
cli,
|
|
59
|
-
blockId,
|
|
60
57
|
workflowDoc,
|
|
61
58
|
workflowJS
|
|
62
59
|
);
|
|
@@ -83,11 +80,11 @@ const setWorkflowElement = (workflowDoc, path, value) => {
|
|
|
83
80
|
workflowDoc.addIn(findPath(path), value);
|
|
84
81
|
}
|
|
85
82
|
};
|
|
86
|
-
const mapGitLabCIWorkflowContent = async (cli,
|
|
83
|
+
const mapGitLabCIWorkflowContent = async (cli, workflowDoc, workflowJS) => {
|
|
87
84
|
const addGitLabJobStage = {
|
|
88
85
|
stage: "push-block",
|
|
89
86
|
variables: {
|
|
90
|
-
block_id: blockId,
|
|
87
|
+
block_id: cli.blockId,
|
|
91
88
|
alias: cli.currentEnv,
|
|
92
89
|
project_id: cli.currentProject,
|
|
93
90
|
client_id: cli.clientDetailsLocation === "env" ? cli.clientId : "$CONTENSIS_CLIENT_ID",
|
|
@@ -133,7 +130,11 @@ const mapGitLabCIWorkflowContent = async (cli, blockId, workflowDoc, workflowJS)
|
|
|
133
130
|
`${stepPath}.variables.project_id`,
|
|
134
131
|
cli.currentProject
|
|
135
132
|
);
|
|
136
|
-
setWorkflowElement(
|
|
133
|
+
setWorkflowElement(
|
|
134
|
+
workflowDoc,
|
|
135
|
+
`${stepPath}.variables.block_id`,
|
|
136
|
+
cli.blockId
|
|
137
|
+
);
|
|
137
138
|
setWorkflowElement(
|
|
138
139
|
workflowDoc,
|
|
139
140
|
`${stepPath}.variables.client_id`,
|
|
@@ -165,13 +166,13 @@ ${workflowDoc}`);
|
|
|
165
166
|
);
|
|
166
167
|
return newWorkflow;
|
|
167
168
|
};
|
|
168
|
-
const mapGitHubActionCIWorkflowContent = async (cli,
|
|
169
|
+
const mapGitHubActionCIWorkflowContent = async (cli, workflowDoc, workflowJS) => {
|
|
169
170
|
const addGitHubActionJobStep = {
|
|
170
171
|
name: "Push block to Contensis",
|
|
171
172
|
id: "push-block",
|
|
172
173
|
uses: "contensis/block-push@v1",
|
|
173
174
|
with: {
|
|
174
|
-
"block-id": blockId,
|
|
175
|
+
"block-id": cli.blockId,
|
|
175
176
|
alias: cli.currentEnv,
|
|
176
177
|
"project-id": cli.currentProject,
|
|
177
178
|
"client-id": cli.clientDetailsLocation === "env" ? "${{ env.CONTENSIS_CLIENT_ID }}" : "${{ secrets.CONTENSIS_CLIENT_ID }}",
|
|
@@ -225,7 +226,7 @@ const mapGitHubActionCIWorkflowContent = async (cli, blockId, workflowDoc, workf
|
|
|
225
226
|
`${stepPath}.with.project-id`,
|
|
226
227
|
cli.currentProject
|
|
227
228
|
);
|
|
228
|
-
setWorkflowElement(workflowDoc, `${stepPath}.with.block-id`, blockId);
|
|
229
|
+
setWorkflowElement(workflowDoc, `${stepPath}.with.block-id`, cli.blockId);
|
|
229
230
|
setWorkflowElement(
|
|
230
231
|
workflowDoc,
|
|
231
232
|
`${stepPath}.with.client-id`,
|
|
@@ -315,7 +316,7 @@ ${workflowDoc}`);
|
|
|
315
316
|
`GitHub workflow YAML did not pass validation check`
|
|
316
317
|
);
|
|
317
318
|
}
|
|
318
|
-
const newWorkflow = workflowDoc.toString();
|
|
319
|
+
const newWorkflow = workflowDoc.toString({ lineWidth: 0 });
|
|
319
320
|
return newWorkflow;
|
|
320
321
|
};
|
|
321
322
|
const determineAppImageUri = async (cli, vars, defaultUri) => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/mappers/DevInit-to-CIWorkflow.ts"],
|
|
4
|
-
"sourcesContent": ["import inquirer from 'inquirer';\nimport { JSONPath, JSONPathOptions } from 'jsonpath-plus';\nimport { Document } from 'yaml';\nimport {\n GitHubActionPushBlockJob,\n GitHubActionPushBlockJobStep,\n GitLabPushBlockJobStage,\n} from '~/models/DevService';\nimport { readFile } from '~/providers/file-provider';\nimport ContensisDev from '~/services/ContensisDevService';\nimport { diffFileContent } from '~/util/diff';\nimport { logError } from '~/util/logger';\nimport { normaliseLineEndings } from '~/util/os';\nimport { parseYamlDocument, validateWorkflowYaml } from '~/util/yaml';\n\ntype MappedWorkflowOutput = {\n existingWorkflow: string;\n newWorkflow: string;\n diff: string;\n};\n\nexport const mapCIWorkflowContent = async (\n cli: ContensisDev\n): Promise<MappedWorkflowOutput | undefined> => {\n // get existing workflow file\n const workflowFile = readFile(cli.git.ciFilePath);\n if (!workflowFile) return undefined;\n\n const blockId = cli.git.name;\n\n // parse yaml to js\n const workflowDoc = parseYamlDocument(workflowFile);\n const workflowJS = workflowDoc.toJS();\n\n if (cli.git.type === 'github') {\n const newWorkflow = await mapGitHubActionCIWorkflowContent(\n cli,\n blockId,\n workflowDoc,\n workflowJS\n );\n return {\n existingWorkflow: workflowFile,\n newWorkflow,\n diff: diffFileContent(workflowFile, newWorkflow),\n };\n } else if (cli.git.type === 'gitlab') {\n const newWorkflow = await mapGitLabCIWorkflowContent(\n cli,\n blockId,\n workflowDoc,\n workflowJS\n );\n return {\n existingWorkflow: workflowFile,\n newWorkflow,\n diff: diffFileContent(workflowFile, newWorkflow),\n };\n }\n};\n\nconst findExistingJobSteps = (\n path: string,\n json: any,\n resultType: JSONPathOptions['resultType']\n) => {\n const existingJobStep = JSONPath({\n path,\n json,\n resultType: resultType,\n });\n\n return existingJobStep;\n};\n\nconst findPath = (path: string | any[]) =>\n typeof path === 'string' && path.includes('.')\n ? path.split('.').map(p => (Number(p) || Number(p) !== 0 ? p : Number(p)))\n : path;\n\nconst setWorkflowElement = (\n workflowDoc: Document,\n path: string | any[],\n value: any\n) => {\n if (workflowDoc.hasIn(findPath(path))) {\n workflowDoc.setIn(findPath(path), value);\n } else {\n workflowDoc.addIn(findPath(path), value);\n }\n};\n\nconst mapGitLabCIWorkflowContent = async (\n cli: ContensisDev,\n blockId: string,\n workflowDoc: Document,\n workflowJS: any\n) => {\n const addGitLabJobStage: GitLabPushBlockJobStage = {\n stage: 'push-block',\n variables: {\n block_id: blockId,\n alias: cli.currentEnv,\n project_id: cli.currentProject,\n client_id:\n cli.clientDetailsLocation === 'env'\n ? cli.clientId\n : '$CONTENSIS_CLIENT_ID',\n shared_secret:\n cli.clientDetailsLocation === 'env'\n ? cli.clientSecret\n : '$CONTENSIS_SHARED_SECRET',\n },\n };\n\n const addAppImageUri = async () => {\n // Look in document level \"variables\"\n const appImageUri = await determineAppImageUri(\n cli,\n Object.entries(workflowJS.variables || {}),\n '$CI_REGISTRY_IMAGE/$CI_COMMIT_REF_NAME/app:build-$CI_PIPELINE_IID'\n );\n\n if (appImageUri.addVar)\n setWorkflowElement(\n workflowDoc,\n `variables.${appImageUri.var}`,\n appImageUri.uri\n );\n\n if (appImageUri.var)\n addGitLabJobStage.variables['image_uri'] = `\\$${appImageUri.var}`;\n };\n\n // look for line in job\n // jobname[stage: push-block]\n const existingJobStep = findExistingJobSteps(\n '$..[?(@property === \"stage\" && @.match(/^push-block/i))]^',\n workflowJS,\n 'all'\n );\n\n // update job step\n if (existingJobStep.length) {\n // cli.log.json(existingJobStep);\n\n // The [0] index means we're only looking at updating the first instance in the file\n const step = existingJobStep[0];\n\n // Path looks like this \"$['job_name']\"\n // We want it to look like this \"job_name\"\n const stepPath = step.path\n .replace('$[', '')\n .replaceAll('][', '.')\n .replace(']', '')\n .replaceAll(\"'\", '');\n\n cli.log.info(\n `Found existing Job step:\n ${stepPath}\n stage: ${step.value.stage}\\n`\n );\n\n setWorkflowElement(\n workflowDoc,\n `${stepPath}.variables.alias`,\n cli.currentEnv\n );\n setWorkflowElement(\n workflowDoc,\n `${stepPath}.variables.project_id`,\n cli.currentProject\n );\n setWorkflowElement(workflowDoc, `${stepPath}.variables.block_id`, blockId);\n\n // This is likely not needed when updating an existing push-block job step\n // we are assuming this is a forked/copied workflow with an already working image-uri reference\n // await addAppImageUri();\n\n setWorkflowElement(\n workflowDoc,\n `${stepPath}.variables.client_id`,\n cli.clientDetailsLocation === 'env'\n ? cli.clientId\n : '$CONTENSIS_CLIENT_ID'\n );\n setWorkflowElement(\n workflowDoc,\n `${stepPath}.variables.shared_secret`,\n cli.clientDetailsLocation === 'env'\n ? cli.clientSecret\n : '$CONTENSIS_SHARED_SECRET'\n );\n } else {\n // create job with push step\n\n // Does a series of checks and prompts to determine the correct image-uri\n // for the app container build\n await addAppImageUri();\n\n // Add the new \"job\" to the Yaml Document\n workflowDoc.addIn(['stages'], 'push-block');\n workflowDoc.addIn([], {\n key: 'push-to-contensis',\n value: addGitLabJobStage,\n });\n setWorkflowElement(\n workflowDoc,\n `include`,\n 'https://gitlab.zengenti.com/ops/contensis-ci/-/raw/main/push-block.yml'\n );\n }\n\n cli.log.debug(`New file content to write\\n\\n${workflowDoc}`);\n\n const newWorkflow = normaliseLineEndings(\n workflowDoc.toString({ lineWidth: 0 })\n );\n\n return newWorkflow;\n};\n\nconst mapGitHubActionCIWorkflowContent = async (\n cli: ContensisDev,\n blockId: string,\n workflowDoc: Document,\n workflowJS: any\n) => {\n const addGitHubActionJobStep: GitHubActionPushBlockJobStep = {\n name: 'Push block to Contensis',\n id: 'push-block',\n uses: 'contensis/block-push@v1',\n with: {\n 'block-id': blockId,\n // 'image-uri': '${{ steps.build.outputs.image-uri }}',\n alias: cli.currentEnv,\n 'project-id': cli.currentProject,\n 'client-id':\n cli.clientDetailsLocation === 'env'\n ? '${{ env.CONTENSIS_CLIENT_ID }}'\n : '${{ secrets.CONTENSIS_CLIENT_ID }}',\n 'shared-secret':\n cli.clientDetailsLocation === 'env'\n ? '${{ env.CONTENSIS_SHARED_SECRET }}'\n : '${{ secrets.CONTENSIS_SHARED_SECRET }}',\n },\n };\n\n const addAppImageUri = async () => {\n // Look in document level \"env\" vars\n const appImageUri = await determineAppImageUri(\n cli,\n Object.entries(workflowJS.env || {}),\n 'ghcr.io/${{ github.repository }}/${{ github.ref_name }}/app'\n );\n\n if (appImageUri.addVar)\n setWorkflowElement(\n workflowDoc,\n `env.${appImageUri.var}`,\n appImageUri.uri\n );\n // workflowDoc.addIn(['env'], { [appImageUri.var]: appImageUri.uri });\n\n if (appImageUri.var)\n addGitHubActionJobStep.with[\n 'image-uri'\n ] = `\\${{ env.${appImageUri.var} }}:build-\\${{ github.run_number }}`;\n };\n\n // look for line in job\n // jobs.x.steps[uses: contensis/block-push]\n const existingJobStep = findExistingJobSteps(\n '$.jobs..steps.*[?(@property === \"uses\" && @.match(/^contensis\\\\/block-push/i))]^',\n workflowJS,\n 'all'\n );\n\n // Update 'env' and store client id and secret\n if (cli.clientDetailsLocation === 'env') {\n setWorkflowElement(workflowDoc, `env.CONTENSIS_CLIENT_ID`, cli.clientId);\n setWorkflowElement(\n workflowDoc,\n `env.CONTENSIS_SHARED_SECRET`,\n cli.clientSecret\n );\n }\n\n if (cli.clientDetailsLocation === 'git') {\n // remove env vars from yml if we choose git\n workflowDoc.deleteIn(findPath(`env.CONTENSIS_CLIENT_ID`));\n workflowDoc.deleteIn(findPath(`env.CONTENSIS_SHARED_SECRET`));\n }\n\n // update job step\n if (existingJobStep.length) {\n //cli.log.json(existingJobStep);\n\n // The [0] index means we're only looking at updating the first instance in the file\n const step = existingJobStep[0];\n\n // Path looks like this \"$['jobs']['build']['steps'][3]\"\n // We want it to look like this \"jobs.build.steps.3\"\n const stepPath = step.path\n .replace('$[', '')\n .replaceAll('][', '.')\n .replace(']', '')\n .replaceAll(\"'\", '');\n\n cli.log.info(\n `Found existing Job step: ${stepPath}\n - name: ${step.value.name}\n id: ${step.value.id}\\n`\n );\n\n setWorkflowElement(workflowDoc, `${stepPath}.with.alias`, cli.currentEnv);\n setWorkflowElement(\n workflowDoc,\n `${stepPath}.with.project-id`,\n cli.currentProject\n );\n setWorkflowElement(workflowDoc, `${stepPath}.with.block-id`, blockId);\n\n // This is likely not needed when updating an existing push-block job step\n // we are assuming this is a forked/copied workflow with an already working image-uri reference\n // await addAppImageUri();\n\n setWorkflowElement(\n workflowDoc,\n `${stepPath}.with.client-id`,\n cli.clientDetailsLocation === 'env'\n ? '${{ env.CONTENSIS_CLIENT_ID }}'\n : '${{ secrets.CONTENSIS_CLIENT_ID }}'\n );\n setWorkflowElement(\n workflowDoc,\n `${stepPath}.with.shared-secret`,\n cli.clientDetailsLocation === 'env'\n ? '${{ env.CONTENSIS_SHARED_SECRET }}'\n : '${{ secrets.CONTENSIS_SHARED_SECRET }}'\n );\n } else {\n // create job with push step\n\n // is there already a job with a property name containing \"build\"?\n const existingBuildJobStep = findExistingJobSteps(\n '$.jobs[?(@property.match(/build/i))]',\n workflowJS,\n 'all'\n ) as JSONPathOptions[]; // This isn't the correct type for this object\n\n let needs: string | undefined;\n // There are multiple jobs called *build*\n if (existingBuildJobStep.length > 1) {\n // prompt which build job we should depend on before pushing the block\n const choices = existingBuildJobStep.map(s => s.parentProperty);\n choices.push(new inquirer.Separator() as any);\n choices.push('none');\n if (choices.includes('build-app')) needs = 'build-app';\n else {\n ({ needs } = await inquirer.prompt([\n {\n type: 'list',\n prefix: '\u231B',\n message: cli.messages.devinit.ciMultipleBuildJobChoices(),\n name: 'needs',\n choices,\n default: choices.find(\n s => typeof s === 'string' && s.includes('docker')\n ),\n },\n ]));\n }\n\n cli.log.raw('');\n } else if (existingBuildJobStep.length === 1)\n // Exactly one job step found containing a property name of *build*\n // we'll assume that is the one the push-block job depends on\n needs = existingBuildJobStep[0].parentProperty;\n\n if (existingBuildJobStep.length === 0 || needs === 'none') {\n // No existing build step found or chosen, offer all job steps in prompt\n const choices = Object.keys(workflowJS.jobs);\n choices.push(new inquirer.Separator() as any);\n choices.push('none');\n\n ({ needs } = await inquirer.prompt([\n {\n type: 'list',\n prefix: '\u231B',\n message: cli.messages.devinit.ciMultipleJobChoices(),\n name: 'needs',\n choices,\n default: choices.find(\n j => typeof j === 'string' && j.includes('docker')\n ),\n },\n ]));\n if (needs === 'none') needs = undefined;\n cli.log.raw('');\n }\n\n // Does a series of checks and prompts to determine the correct image-uri\n // for the app container build\n await addAppImageUri();\n\n const newJob: GitHubActionPushBlockJob = {\n name: 'Deploy container image to Contensis',\n 'runs-on': 'ubuntu-latest',\n needs,\n steps: [addGitHubActionJobStep],\n };\n\n // Add the new \"job\" to the Yaml Document\n workflowDoc.addIn(['jobs'], {\n key: 'deploy',\n value: newJob,\n });\n }\n\n // Workflow validation provided by @action-validator/core package\n const workflowIsValid = validateWorkflowYaml(workflowDoc.toString());\n\n // We could expand validation to check for having a build step to wait for\n // or if a valid image-uri attribute is set\n if (workflowIsValid === true) {\n cli.log.success(`GitHub workflow YAML is valid`);\n cli.log.debug(`New file content to write\\n\\n${workflowDoc}`);\n } else if (Array.isArray(workflowIsValid)) {\n // Errors\n logError(\n [\n ...workflowIsValid.map(\n res => new Error(`${res.code}: ${res.detail || res.title}`)\n ),\n workflowDoc.toString(),\n ],\n `GitHub workflow YAML did not pass validation check`\n );\n }\n\n // const newWorkflow = normaliseLineEndings(\n // workflowDoc.toString({ lineWidth: 0 })\n // );\n\n const newWorkflow = workflowDoc.toString();\n\n return newWorkflow;\n};\n\nconst determineAppImageUri = async (\n cli: ContensisDev,\n vars: [string, string][],\n defaultUri: string\n) => {\n // Determine container image-uri via variables and/or prompts\n\n // Find vars including the word \"image\"\n const imageVars = vars.filter(([varname]) =>\n varname.toLowerCase().includes('image')\n );\n // Find vars named \"image\" that include the word \"app\"\n const appImageVars = imageVars.filter(\n ([varname, value]) =>\n !varname.toLowerCase().includes('builder_') &&\n (varname.toLowerCase().includes('app_') ||\n varname.toLowerCase().includes('build_') ||\n value?.toLowerCase().includes('/app'))\n );\n\n const appImageUriGuess = appImageVars?.[0];\n\n let appImageUri: string | undefined;\n let appImageVar: string | undefined;\n\n if (appImageUriGuess) {\n cli.log.success(\n `Found variable ${cli.log.standardText(\n appImageUriGuess[0]\n )} we'll use for pulling the block image from: ${cli.log.infoText(\n appImageUriGuess[1]\n )}`\n );\n appImageVar = appImageUriGuess[0];\n } else {\n // Could not find a suitable var to use for block image-uri\n // prompt for an app image uri\n const choices = vars.map(v => v[0]);\n const enterOwnMsg = 'enter my own / use default';\n\n choices.push(new inquirer.Separator() as any);\n choices.push(enterOwnMsg);\n choices.push(defaultUri);\n\n ({ appImageVar, appImageUri } = await inquirer.prompt([\n // First question determines if an existing env variable\n // already containes the tagged app image uri\n {\n type: 'list',\n prefix: '\uD83D\uDC33',\n message: cli.messages.devinit.ciMultipleAppImageVarChoices(),\n name: 'appImageVar',\n choices,\n default: choices.find(\n v => typeof v === 'string' && v.toLowerCase().includes('image')\n ),\n },\n // Subsequent prompt allows input of an image-uri if needed\n {\n type: 'input',\n when(answers) {\n return [enterOwnMsg, defaultUri].includes(answers.appImageVar);\n },\n prefix: `\\n \\n\uD83D\uDD17`,\n message: cli.messages.devinit.ciEnterOwnAppImagePrompt(cli.git),\n name: 'appImageUri',\n default: defaultUri,\n },\n ]));\n cli.log.raw('');\n\n // this indicates a uri has been added and we will add a new var\n // to the workflow to encourage users to update the docker tag part\n // of their build workflow to use the same var as the push-block job/step\n if ([enterOwnMsg, defaultUri].includes(appImageVar || ''))\n appImageVar = undefined;\n }\n\n if (appImageVar)\n appImageUri =\n cli.git.type === 'github'\n ? `\\${{ env.${appImageVar} }}`\n : `\\$${appImageVar}`;\n\n // TODO: prompt further for image tag\n\n return {\n addVar: !appImageVar,\n uri: appImageUri,\n var: appImageVar || 'BUILD_IMAGE',\n };\n};\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAAqB;AACrB,2BAA0C;AAO1C,2BAAyB;AAEzB,kBAAgC;AAChC,oBAAyB;AACzB,gBAAqC;AACrC,IAAAA,eAAwD;AAQjD,MAAM,uBAAuB,OAClC,QAC8C;AAE9C,QAAM,mBAAe,+BAAS,IAAI,IAAI,UAAU;AAChD,MAAI,CAAC;AAAc,WAAO;
|
|
4
|
+
"sourcesContent": ["import inquirer from 'inquirer';\nimport { JSONPath, JSONPathOptions } from 'jsonpath-plus';\nimport { Document } from 'yaml';\nimport {\n GitHubActionPushBlockJob,\n GitHubActionPushBlockJobStep,\n GitLabPushBlockJobStage,\n} from '~/models/DevService';\nimport { readFile } from '~/providers/file-provider';\nimport ContensisDev from '~/services/ContensisDevService';\nimport { diffFileContent } from '~/util/diff';\nimport { logError } from '~/util/logger';\nimport { normaliseLineEndings } from '~/util/os';\nimport { parseYamlDocument, validateWorkflowYaml } from '~/util/yaml';\n\ntype MappedWorkflowOutput = {\n existingWorkflow: string;\n newWorkflow: string;\n diff: string;\n};\n\nexport const mapCIWorkflowContent = async (\n cli: ContensisDev\n): Promise<MappedWorkflowOutput | undefined> => {\n // get existing workflow file\n const workflowFile = readFile(cli.git.ciFilePath);\n if (!workflowFile) return undefined;\n\n // parse yaml to js\n const workflowDoc = parseYamlDocument(workflowFile);\n const workflowJS = workflowDoc.toJS();\n\n if (cli.git.type === 'github') {\n const newWorkflow = await mapGitHubActionCIWorkflowContent(\n cli,\n workflowDoc,\n workflowJS\n );\n return {\n existingWorkflow: workflowFile,\n newWorkflow,\n diff: diffFileContent(workflowFile, newWorkflow),\n };\n } else if (cli.git.type === 'gitlab') {\n const newWorkflow = await mapGitLabCIWorkflowContent(\n cli,\n workflowDoc,\n workflowJS\n );\n return {\n existingWorkflow: workflowFile,\n newWorkflow,\n diff: diffFileContent(workflowFile, newWorkflow),\n };\n }\n};\n\nconst findExistingJobSteps = (\n path: string,\n json: any,\n resultType: JSONPathOptions['resultType']\n) => {\n const existingJobStep = JSONPath({\n path,\n json,\n resultType: resultType,\n });\n\n return existingJobStep;\n};\n\nconst findPath = (path: string | any[]) =>\n typeof path === 'string' && path.includes('.')\n ? path.split('.').map(p => (Number(p) || Number(p) !== 0 ? p : Number(p)))\n : path;\n\nconst setWorkflowElement = (\n workflowDoc: Document,\n path: string | any[],\n value: any\n) => {\n if (workflowDoc.hasIn(findPath(path))) {\n workflowDoc.setIn(findPath(path), value);\n } else {\n workflowDoc.addIn(findPath(path), value);\n }\n};\n\nconst mapGitLabCIWorkflowContent = async (\n cli: ContensisDev,\n workflowDoc: Document,\n workflowJS: any\n) => {\n const addGitLabJobStage: GitLabPushBlockJobStage = {\n stage: 'push-block',\n variables: {\n block_id: cli.blockId,\n alias: cli.currentEnv,\n project_id: cli.currentProject,\n client_id:\n cli.clientDetailsLocation === 'env'\n ? cli.clientId\n : '$CONTENSIS_CLIENT_ID',\n shared_secret:\n cli.clientDetailsLocation === 'env'\n ? cli.clientSecret\n : '$CONTENSIS_SHARED_SECRET',\n },\n };\n\n const addAppImageUri = async () => {\n // Look in document level \"variables\"\n const appImageUri = await determineAppImageUri(\n cli,\n Object.entries(workflowJS.variables || {}),\n '$CI_REGISTRY_IMAGE/$CI_COMMIT_REF_NAME/app:build-$CI_PIPELINE_IID'\n );\n\n if (appImageUri.addVar)\n setWorkflowElement(\n workflowDoc,\n `variables.${appImageUri.var}`,\n appImageUri.uri\n );\n\n if (appImageUri.var)\n addGitLabJobStage.variables['image_uri'] = `\\$${appImageUri.var}`;\n };\n\n // look for line in job\n // jobname[stage: push-block]\n const existingJobStep = findExistingJobSteps(\n '$..[?(@property === \"stage\" && @.match(/^push-block/i))]^',\n workflowJS,\n 'all'\n );\n\n // update job step\n if (existingJobStep.length) {\n // cli.log.json(existingJobStep);\n\n // The [0] index means we're only looking at updating the first instance in the file\n const step = existingJobStep[0];\n\n // Path looks like this \"$['job_name']\"\n // We want it to look like this \"job_name\"\n const stepPath = step.path\n .replace('$[', '')\n .replaceAll('][', '.')\n .replace(']', '')\n .replaceAll(\"'\", '');\n\n cli.log.info(\n `Found existing Job step:\n ${stepPath}\n stage: ${step.value.stage}\\n`\n );\n\n setWorkflowElement(\n workflowDoc,\n `${stepPath}.variables.alias`,\n cli.currentEnv\n );\n setWorkflowElement(\n workflowDoc,\n `${stepPath}.variables.project_id`,\n cli.currentProject\n );\n setWorkflowElement(\n workflowDoc,\n `${stepPath}.variables.block_id`,\n cli.blockId\n );\n\n // This is likely not needed when updating an existing push-block job step\n // we are assuming this is a forked/copied workflow with an already working image-uri reference\n // await addAppImageUri();\n\n setWorkflowElement(\n workflowDoc,\n `${stepPath}.variables.client_id`,\n cli.clientDetailsLocation === 'env'\n ? cli.clientId\n : '$CONTENSIS_CLIENT_ID'\n );\n setWorkflowElement(\n workflowDoc,\n `${stepPath}.variables.shared_secret`,\n cli.clientDetailsLocation === 'env'\n ? cli.clientSecret\n : '$CONTENSIS_SHARED_SECRET'\n );\n } else {\n // create job with push step\n\n // Does a series of checks and prompts to determine the correct image-uri\n // for the app container build\n await addAppImageUri();\n\n // Add the new \"job\" to the Yaml Document\n workflowDoc.addIn(['stages'], 'push-block');\n workflowDoc.addIn([], {\n key: 'push-to-contensis',\n value: addGitLabJobStage,\n });\n setWorkflowElement(\n workflowDoc,\n `include`,\n 'https://gitlab.zengenti.com/ops/contensis-ci/-/raw/main/push-block.yml'\n );\n }\n\n cli.log.debug(`New file content to write\\n\\n${workflowDoc}`);\n\n const newWorkflow = normaliseLineEndings(\n workflowDoc.toString({ lineWidth: 0 })\n );\n\n return newWorkflow;\n};\n\nconst mapGitHubActionCIWorkflowContent = async (\n cli: ContensisDev,\n workflowDoc: Document,\n workflowJS: any\n) => {\n const addGitHubActionJobStep: GitHubActionPushBlockJobStep = {\n name: 'Push block to Contensis',\n id: 'push-block',\n uses: 'contensis/block-push@v1',\n with: {\n 'block-id': cli.blockId,\n // 'image-uri': '${{ steps.build.outputs.image-uri }}',\n alias: cli.currentEnv,\n 'project-id': cli.currentProject,\n 'client-id':\n cli.clientDetailsLocation === 'env'\n ? '${{ env.CONTENSIS_CLIENT_ID }}'\n : '${{ secrets.CONTENSIS_CLIENT_ID }}',\n 'shared-secret':\n cli.clientDetailsLocation === 'env'\n ? '${{ env.CONTENSIS_SHARED_SECRET }}'\n : '${{ secrets.CONTENSIS_SHARED_SECRET }}',\n },\n };\n\n const addAppImageUri = async () => {\n // Look in document level \"env\" vars\n const appImageUri = await determineAppImageUri(\n cli,\n Object.entries(workflowJS.env || {}),\n 'ghcr.io/${{ github.repository }}/${{ github.ref_name }}/app'\n );\n\n if (appImageUri.addVar)\n setWorkflowElement(\n workflowDoc,\n `env.${appImageUri.var}`,\n appImageUri.uri\n );\n // workflowDoc.addIn(['env'], { [appImageUri.var]: appImageUri.uri });\n\n if (appImageUri.var)\n addGitHubActionJobStep.with[\n 'image-uri'\n ] = `\\${{ env.${appImageUri.var} }}:build-\\${{ github.run_number }}`;\n };\n\n // look for line in job\n // jobs.x.steps[uses: contensis/block-push]\n const existingJobStep = findExistingJobSteps(\n '$.jobs..steps.*[?(@property === \"uses\" && @.match(/^contensis\\\\/block-push/i))]^',\n workflowJS,\n 'all'\n );\n\n // Update 'env' and store client id and secret\n if (cli.clientDetailsLocation === 'env') {\n setWorkflowElement(workflowDoc, `env.CONTENSIS_CLIENT_ID`, cli.clientId);\n setWorkflowElement(\n workflowDoc,\n `env.CONTENSIS_SHARED_SECRET`,\n cli.clientSecret\n );\n }\n\n if (cli.clientDetailsLocation === 'git') {\n // remove env vars from yml if we choose git\n workflowDoc.deleteIn(findPath(`env.CONTENSIS_CLIENT_ID`));\n workflowDoc.deleteIn(findPath(`env.CONTENSIS_SHARED_SECRET`));\n }\n\n // update job step\n if (existingJobStep.length) {\n //cli.log.json(existingJobStep);\n\n // The [0] index means we're only looking at updating the first instance in the file\n const step = existingJobStep[0];\n\n // Path looks like this \"$['jobs']['build']['steps'][3]\"\n // We want it to look like this \"jobs.build.steps.3\"\n const stepPath = step.path\n .replace('$[', '')\n .replaceAll('][', '.')\n .replace(']', '')\n .replaceAll(\"'\", '');\n\n cli.log.info(\n `Found existing Job step: ${stepPath}\n - name: ${step.value.name}\n id: ${step.value.id}\\n`\n );\n\n setWorkflowElement(workflowDoc, `${stepPath}.with.alias`, cli.currentEnv);\n setWorkflowElement(\n workflowDoc,\n `${stepPath}.with.project-id`,\n cli.currentProject\n );\n setWorkflowElement(workflowDoc, `${stepPath}.with.block-id`, cli.blockId);\n\n // This is likely not needed when updating an existing push-block job step\n // we are assuming this is a forked/copied workflow with an already working image-uri reference\n // await addAppImageUri();\n\n setWorkflowElement(\n workflowDoc,\n `${stepPath}.with.client-id`,\n cli.clientDetailsLocation === 'env'\n ? '${{ env.CONTENSIS_CLIENT_ID }}'\n : '${{ secrets.CONTENSIS_CLIENT_ID }}'\n );\n setWorkflowElement(\n workflowDoc,\n `${stepPath}.with.shared-secret`,\n cli.clientDetailsLocation === 'env'\n ? '${{ env.CONTENSIS_SHARED_SECRET }}'\n : '${{ secrets.CONTENSIS_SHARED_SECRET }}'\n );\n } else {\n // create job with push step\n\n // is there already a job with a property name containing \"build\"?\n const existingBuildJobStep = findExistingJobSteps(\n '$.jobs[?(@property.match(/build/i))]',\n workflowJS,\n 'all'\n ) as JSONPathOptions[]; // This isn't the correct type for this object\n\n let needs: string | undefined;\n // There are multiple jobs called *build*\n if (existingBuildJobStep.length > 1) {\n // prompt which build job we should depend on before pushing the block\n const choices = existingBuildJobStep.map(s => s.parentProperty);\n choices.push(new inquirer.Separator() as any);\n choices.push('none');\n if (choices.includes('build-app')) needs = 'build-app';\n else {\n ({ needs } = await inquirer.prompt([\n {\n type: 'list',\n prefix: '\u231B',\n message: cli.messages.devinit.ciMultipleBuildJobChoices(),\n name: 'needs',\n choices,\n default: choices.find(\n s => typeof s === 'string' && s.includes('docker')\n ),\n },\n ]));\n }\n\n cli.log.raw('');\n } else if (existingBuildJobStep.length === 1)\n // Exactly one job step found containing a property name of *build*\n // we'll assume that is the one the push-block job depends on\n needs = existingBuildJobStep[0].parentProperty;\n\n if (existingBuildJobStep.length === 0 || needs === 'none') {\n // No existing build step found or chosen, offer all job steps in prompt\n const choices = Object.keys(workflowJS.jobs);\n choices.push(new inquirer.Separator() as any);\n choices.push('none');\n\n ({ needs } = await inquirer.prompt([\n {\n type: 'list',\n prefix: '\u231B',\n message: cli.messages.devinit.ciMultipleJobChoices(),\n name: 'needs',\n choices,\n default: choices.find(\n j => typeof j === 'string' && j.includes('docker')\n ),\n },\n ]));\n if (needs === 'none') needs = undefined;\n cli.log.raw('');\n }\n\n // Does a series of checks and prompts to determine the correct image-uri\n // for the app container build\n await addAppImageUri();\n\n const newJob: GitHubActionPushBlockJob = {\n name: 'Deploy container image to Contensis',\n 'runs-on': 'ubuntu-latest',\n needs,\n steps: [addGitHubActionJobStep],\n };\n\n // Add the new \"job\" to the Yaml Document\n workflowDoc.addIn(['jobs'], {\n key: 'deploy',\n value: newJob,\n });\n }\n\n // Workflow validation provided by @action-validator/core package\n const workflowIsValid = validateWorkflowYaml(workflowDoc.toString());\n\n // We could expand validation to check for having a build step to wait for\n // or if a valid image-uri attribute is set\n if (workflowIsValid === true) {\n cli.log.success(`GitHub workflow YAML is valid`);\n cli.log.debug(`New file content to write\\n\\n${workflowDoc}`);\n } else if (Array.isArray(workflowIsValid)) {\n // Errors\n logError(\n [\n ...workflowIsValid.map(\n res => new Error(`${res.code}: ${res.detail || res.title}`)\n ),\n workflowDoc.toString(),\n ],\n `GitHub workflow YAML did not pass validation check`\n );\n }\n\n // const newWorkflow = normaliseLineEndings(\n // workflowDoc.toString({ lineWidth: 0 })\n // );\n\n const newWorkflow = workflowDoc.toString({ lineWidth: 0 });\n\n return newWorkflow;\n};\n\nconst determineAppImageUri = async (\n cli: ContensisDev,\n vars: [string, string][],\n defaultUri: string\n) => {\n // Determine container image-uri via variables and/or prompts\n\n // Find vars including the word \"image\"\n const imageVars = vars.filter(([varname]) =>\n varname.toLowerCase().includes('image')\n );\n // Find vars named \"image\" that include the word \"app\"\n const appImageVars = imageVars.filter(\n ([varname, value]) =>\n !varname.toLowerCase().includes('builder_') &&\n (varname.toLowerCase().includes('app_') ||\n varname.toLowerCase().includes('build_') ||\n value?.toLowerCase().includes('/app'))\n );\n\n const appImageUriGuess = appImageVars?.[0];\n\n let appImageUri: string | undefined;\n let appImageVar: string | undefined;\n\n if (appImageUriGuess) {\n cli.log.success(\n `Found variable ${cli.log.standardText(\n appImageUriGuess[0]\n )} we'll use for pulling the block image from: ${cli.log.infoText(\n appImageUriGuess[1]\n )}`\n );\n appImageVar = appImageUriGuess[0];\n } else {\n // Could not find a suitable var to use for block image-uri\n // prompt for an app image uri\n const choices = vars.map(v => v[0]);\n const enterOwnMsg = 'enter my own / use default';\n\n choices.push(new inquirer.Separator() as any);\n choices.push(enterOwnMsg);\n choices.push(defaultUri);\n\n ({ appImageVar, appImageUri } = await inquirer.prompt([\n // First question determines if an existing env variable\n // already containes the tagged app image uri\n {\n type: 'list',\n prefix: '\uD83D\uDC33',\n message: cli.messages.devinit.ciMultipleAppImageVarChoices(),\n name: 'appImageVar',\n choices,\n default: choices.find(\n v => typeof v === 'string' && v.toLowerCase().includes('image')\n ),\n },\n // Subsequent prompt allows input of an image-uri if needed\n {\n type: 'input',\n when(answers) {\n return [enterOwnMsg, defaultUri].includes(answers.appImageVar);\n },\n prefix: `\\n \\n\uD83D\uDD17`,\n message: cli.messages.devinit.ciEnterOwnAppImagePrompt(cli.git),\n name: 'appImageUri',\n default: defaultUri,\n },\n ]));\n cli.log.raw('');\n\n // this indicates a uri has been added and we will add a new var\n // to the workflow to encourage users to update the docker tag part\n // of their build workflow to use the same var as the push-block job/step\n if ([enterOwnMsg, defaultUri].includes(appImageVar || ''))\n appImageVar = undefined;\n }\n\n if (appImageVar)\n appImageUri =\n cli.git.type === 'github'\n ? `\\${{ env.${appImageVar} }}`\n : `\\$${appImageVar}`;\n\n // TODO: prompt further for image tag\n\n return {\n addVar: !appImageVar,\n uri: appImageUri,\n var: appImageVar || 'BUILD_IMAGE',\n };\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;A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AM,YAAY,EAAE,YAAY,EAAE,SAAS,OAAO;AAAA,QAChE;AAAA,MACF;AAAA,MAEA;AAAA,QACE,MAAM;AAAA,QACN,KAAK,SAAS;AACZ,iBAAO,CAAC,aAAa,UAAU,EAAE,SAAS,QAAQ,WAAW;AAAA,QAC/D;AAAA,QACA,QAAQ;AAAA;AAAA;AAAA,QACR,SAAS,IAAI,SAAS,QAAQ,yBAAyB,IAAI,GAAG;AAAA,QAC9D,MAAM;AAAA,QACN,SAAS;AAAA,MACX;AAAA,IACF,CAAC;AACD,QAAI,IAAI,IAAI,EAAE;AAKd,QAAI,CAAC,aAAa,UAAU,EAAE,SAAS,eAAe,EAAE;AACtD,oBAAc;AAAA,EAClB;AAEA,MAAI;AACF,kBACE,IAAI,IAAI,SAAS,WACb,YAAY,mBACZ,IAAK;AAIb,SAAO;AAAA,IACL,QAAQ,CAAC;AAAA,IACT,KAAK;AAAA,IACL,KAAK,eAAe;AAAA,EACtB;AACF;",
|
|
6
6
|
"names": ["import_yaml", "inquirer"]
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/models/DevService.d.ts"],
|
|
4
|
-
"sourcesContent": ["export type EnvContentsToAdd = {\n ALIAS: string;\n PROJECT: string;\n ACCESS_TOKEN?: string;\n CONTENSIS_CLIENT_ID?: string;\n CONTENSIS_CLIENT_SECRET?: string;\n};\n\nexport type GitHubActionPushBlockJobStep = {\n name: string;\n id: 'push-block';\n uses: string;\n with: {\n 'block-id': string;\n alias: string;\n 'project-id': string;\n 'client-id': string;\n 'shared-secret': string;\n 'image-uri'?: string;\n };\n};\n\nexport type GitHubActionPushBlockJob = {\n name: string;\n 'runs-on': string;\n needs?: string;\n steps: GitHubActionPushBlockJobStep[];\n};\n\nexport type GitLabPushBlockJobStage = {\n stage: string;\n variables: {\n alias: string;\n project_id: string;\n block_id: string;\n image_uri?: string;\n client_id: string;\n shared_secret: string;\n };\n};\n"],
|
|
4
|
+
"sourcesContent": ["export type EnvContentsToAdd = {\n ALIAS: string;\n PROJECT: string;\n ACCESS_TOKEN?: string;\n CONTENSIS_CLIENT_ID?: string;\n CONTENSIS_CLIENT_SECRET?: string;\n BLOCK_ID: string;\n};\n\nexport type GitHubActionPushBlockJobStep = {\n name: string;\n id: 'push-block';\n uses: string;\n with: {\n 'block-id': string;\n alias: string;\n 'project-id': string;\n 'client-id': string;\n 'shared-secret': string;\n 'image-uri'?: string;\n };\n};\n\nexport type GitHubActionPushBlockJob = {\n name: string;\n 'runs-on': string;\n needs?: string;\n steps: GitHubActionPushBlockJobStep[];\n};\n\nexport type GitLabPushBlockJobStage = {\n stage: string;\n variables: {\n alias: string;\n project_id: string;\n block_id: string;\n image_uri?: string;\n client_id: string;\n shared_secret: string;\n };\n};\n"],
|
|
5
5
|
"mappings": ";;;;;;;;;;;;;;AAAA;AAAA;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -47,6 +47,7 @@ var import_yaml = require("../util/yaml");
|
|
|
47
47
|
var import_nanospinner = require("nanospinner");
|
|
48
48
|
class ContensisDev extends import_ContensisRoleService.default {
|
|
49
49
|
git;
|
|
50
|
+
blockId;
|
|
50
51
|
constructor(args, outputOpts, contensisOpts = {}) {
|
|
51
52
|
super(args, outputOpts, contensisOpts);
|
|
52
53
|
}
|
|
@@ -59,6 +60,22 @@ class ContensisDev extends import_ContensisRoleService.default {
|
|
|
59
60
|
const { currentEnv, currentProject, log, messages } = this;
|
|
60
61
|
const contensis = await this.ConnectContensis();
|
|
61
62
|
if (contensis) {
|
|
63
|
+
const validateBlockId = (blockId2) => {
|
|
64
|
+
const pattern = /^[a-z-]*$/;
|
|
65
|
+
if (typeof blockId2 === "string" && blockId2.length >= 3) {
|
|
66
|
+
return pattern.test(blockId2);
|
|
67
|
+
} else
|
|
68
|
+
return false;
|
|
69
|
+
};
|
|
70
|
+
let { blockId } = await import_inquirer.default.prompt({
|
|
71
|
+
name: "blockId",
|
|
72
|
+
type: "input",
|
|
73
|
+
prefix: "\u{1F9F1}",
|
|
74
|
+
message: messages.devinit.blockIdQuestion,
|
|
75
|
+
validate: validateBlockId
|
|
76
|
+
});
|
|
77
|
+
this.blockId = blockId.toLowerCase();
|
|
78
|
+
log.success(`Valid block id: ${blockId.toLowerCase()}`);
|
|
62
79
|
const [keysErr, apiKeys] = await contensis.apiKeys.GetKeys();
|
|
63
80
|
if (keysErr) {
|
|
64
81
|
log.error(messages.keys.noList(currentEnv));
|
|
@@ -70,8 +87,8 @@ class ContensisDev extends import_ContensisRoleService.default {
|
|
|
70
87
|
);
|
|
71
88
|
const workflowFiles = git.workflows;
|
|
72
89
|
let ciFileName = git.ciFileName;
|
|
73
|
-
const deployKeyName = `${
|
|
74
|
-
const deployKeyDescription = `${
|
|
90
|
+
const deployKeyName = `${blockId} deployment`;
|
|
91
|
+
const deployKeyDescription = `${blockId} deploy [contensis-cli]`;
|
|
75
92
|
let existingDeployKey = apiKeyExists(deployKeyName);
|
|
76
93
|
if (!existingDeployKey) {
|
|
77
94
|
log.info("Please wait, creating deploy key");
|
|
@@ -86,7 +103,6 @@ class ContensisDev extends import_ContensisRoleService.default {
|
|
|
86
103
|
this.clientId = existingDeployKey == null ? void 0 : existingDeployKey.id;
|
|
87
104
|
this.clientSecret = existingDeployKey == null ? void 0 : existingDeployKey.sharedSecret;
|
|
88
105
|
}
|
|
89
|
-
const blockId = git.name;
|
|
90
106
|
const errors = [];
|
|
91
107
|
log.raw("");
|
|
92
108
|
log.success(messages.devinit.intro());
|
|
@@ -97,6 +113,7 @@ class ContensisDev extends import_ContensisRoleService.default {
|
|
|
97
113
|
git.name,
|
|
98
114
|
currentEnv,
|
|
99
115
|
currentProject,
|
|
116
|
+
blockId,
|
|
100
117
|
git
|
|
101
118
|
)
|
|
102
119
|
)
|
|
@@ -140,10 +157,10 @@ class ContensisDev extends import_ContensisRoleService.default {
|
|
|
140
157
|
}
|
|
141
158
|
if (this.clientDetailsLocation === "env") {
|
|
142
159
|
mappedWorkflow = await (0, import_DevInit_to_CIWorkflow.mapCIWorkflowContent)(this);
|
|
143
|
-
log.help(messages.devinit.ciIntro(git,
|
|
160
|
+
log.help(messages.devinit.ciIntro(git, "env"));
|
|
144
161
|
} else {
|
|
145
162
|
mappedWorkflow = await (0, import_DevInit_to_CIWorkflow.mapCIWorkflowContent)(this);
|
|
146
|
-
log.help(messages.devinit.ciIntro(git,
|
|
163
|
+
log.help(messages.devinit.ciIntro(git, "git"));
|
|
147
164
|
}
|
|
148
165
|
if (!dryRun) {
|
|
149
166
|
const { confirm } = await import_inquirer.default.prompt([
|
|
@@ -204,7 +221,8 @@ class ContensisDev extends import_ContensisRoleService.default {
|
|
|
204
221
|
let existingEnvFileArray = (existingEnvFile || "").split("\n").filter((l) => !!l);
|
|
205
222
|
const envContentsToAdd = {
|
|
206
223
|
ALIAS: currentEnv,
|
|
207
|
-
PROJECT: currentProject
|
|
224
|
+
PROJECT: currentProject,
|
|
225
|
+
BLOCK_ID: blockId
|
|
208
226
|
};
|
|
209
227
|
if (accessToken)
|
|
210
228
|
envContentsToAdd["ACCESS_TOKEN"] = accessToken;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/services/ContensisDevService.ts"],
|
|
4
|
-
"sourcesContent": ["import to from 'await-to-js';\nimport { spawn } from 'child_process';\nimport inquirer from 'inquirer';\nimport path from 'path';\n\nimport { Role } from 'contensis-management-api/lib/models';\nimport { MigrateRequest } from 'migratortron';\n\nimport ContensisRole from './ContensisRoleService';\nimport { OutputOptionsConstructorArg } from '~/models/CliService';\nimport { EnvContentsToAdd } from '~/models/DevService';\nimport { mapSiteConfigYaml } from '~/mappers/DevRequests-to-RequestHanderSiteConfigYaml';\nimport { mapCIWorkflowContent } from '~/mappers/DevInit-to-CIWorkflow';\nimport {\n deployKeyRole,\n devKeyRole,\n} from '~/mappers/DevInit-to-RolePermissions';\nimport { appRootDir, readFile, writeFile } from '~/providers/file-provider';\nimport { diffFileContent } from '~/util/diff';\nimport { mergeDotEnvFileContents } from '~/util/dotenv';\nimport { findByIdOrName } from '~/util/find';\nimport { GitHelper } from '~/util/git';\nimport { jsonFormatter } from '~/util/json.formatter';\nimport { winSlash } from '~/util/os';\nimport { stringifyYaml } from '~/util/yaml';\nimport { createSpinner } from 'nanospinner';\n\nclass ContensisDev extends ContensisRole {\n git!: GitHelper;\n\n constructor(\n args: string[],\n outputOpts?: OutputOptionsConstructorArg,\n contensisOpts: Partial<MigrateRequest> = {}\n ) {\n super(args, outputOpts, contensisOpts);\n }\n\n DevelopmentInit = async (projectHome: string, opts: any) => {\n // Retrieve git info\n const git = (this.git = new GitHelper(projectHome));\n // Check if we are in a git repo\n const isRepo = git.checkIsRepo();\n if (!isRepo) return;\n\n const { dryRun = false } = opts || {};\n const { currentEnv, currentProject, log, messages } = this;\n const contensis = await this.ConnectContensis();\n\n if (contensis) {\n // Retrieve keys list for env\n const [keysErr, apiKeys] = await contensis.apiKeys.GetKeys();\n if (keysErr) {\n log.error(messages.keys.noList(currentEnv));\n log.error(jsonFormatter(keysErr));\n return;\n }\n const apiKeyExists = (findKey: string) =>\n apiKeys?.find(\n k => k.name.trim().toLowerCase() === findKey?.trim().toLowerCase()\n );\n\n // Retrieve ci workflow info\n const workflowFiles = git.workflows;\n\n // Set variables for performing operations and logging etc.\n let ciFileName = git.ciFileName;\n\n // const devKeyName = `${git.name} development`;\n // const devKeyDescription = `${git.name} [contensis-cli]`;\n // let existingDevKey = apiKeyExists(devKeyName);\n\n const deployKeyName = `${git.name} deployment`;\n const deployKeyDescription = `${git.name} deploy [contensis-cli]`;\n\n let existingDeployKey = apiKeyExists(deployKeyName);\n\n // if api key doesn't exisit go and create it (we need this for yml file).\n if (!existingDeployKey) {\n log.info('Please wait, creating deploy key');\n existingDeployKey = await this.CreateOrUpdateApiKey(\n existingDeployKey,\n deployKeyName,\n deployKeyDescription\n );\n log.success('Successfully created deploy key');\n }\n\n // check we have the deply key so we can assign them to this values\n if (existingDeployKey) {\n // Add client id and secret to global 'this'\n this.clientId = existingDeployKey?.id;\n this.clientSecret = existingDeployKey?.sharedSecret;\n }\n\n const blockId = git.name;\n const errors = [] as AppError[];\n\n // Start render console output\n log.raw('');\n log.success(messages.devinit.intro());\n log.raw('');\n log.raw(\n log.infoText(\n messages.devinit.projectDetails(\n git.name,\n currentEnv,\n currentProject,\n git\n )\n )\n );\n // log.raw(\n // log.infoText(\n // messages.devinit.developmentKey(devKeyName, !!existingDevKey)\n // )\n // );\n log.raw(\n log.infoText(\n messages.devinit.deploymentKey(deployKeyName, !!existingDeployKey)\n )\n );\n log.raw('');\n\n if (Array.isArray(workflowFiles) && workflowFiles.length > 1) {\n // Choose GitHub workflow file (if multiple)\n ({ ciFileName } = await inquirer.prompt([\n {\n type: 'list',\n prefix: '\u29F0',\n message: messages.devinit.ciMultipleChoices(),\n name: 'ciFileName',\n choices: workflowFiles,\n default: workflowFiles.find(f => f.includes('docker')),\n },\n ]));\n log.raw('');\n git.ciFileName = ciFileName;\n }\n\n log.raw(log.infoText(messages.devinit.ciDetails(ciFileName)));\n\n let mappedWorkflow;\n // Location for Client ID / Secret.\n const { clientDetailsOption } = await inquirer.prompt({\n name: 'clientDetailsOption',\n type: 'list',\n prefix: '\uD83D\uDD11',\n // Where would you like to store your Client ID/Secret?\n message: messages.devinit.clientDetailsLocation(),\n choices: [\n messages.devinit.clientDetailsInGit(git),\n messages.devinit.clientDetailsInEnv(),\n ],\n });\n\n // global 'clientDetailsLocation' variable stores users input on where client id / secert are stored\n if (clientDetailsOption === messages.devinit.clientDetailsInEnv()) {\n this.clientDetailsLocation = 'env';\n } else {\n this.clientDetailsLocation = 'git';\n }\n\n if (this.clientDetailsLocation === 'env') {\n // Update CI Workflow to pull from ENV variables\n mappedWorkflow = await mapCIWorkflowContent(this);\n log.help(messages.devinit.ciIntro(git, this.clientDetailsLocation));\n } else {\n // Look at the workflow file content and make updates\n mappedWorkflow = await mapCIWorkflowContent(this);\n log.help(messages.devinit.ciIntro(git, this.clientDetailsLocation));\n }\n\n if (!dryRun) {\n // Confirm prompt\n const { confirm } = await inquirer.prompt([\n {\n type: 'confirm',\n message: messages.devinit.confirm(),\n name: 'confirm',\n default: false,\n },\n ]);\n log.raw('');\n if (!confirm) return;\n }\n\n // Fetching access token\n let accessToken: string | undefined = undefined;\n log.raw('');\n\n const spinner = createSpinner(messages.devinit.accessTokenFetch());\n spinner.start();\n\n const token = await this.GetDeliveryApiKey();\n\n if (token) {\n spinner.success();\n this.log.success(messages.devinit.accessTokenSuccess(token));\n accessToken = token;\n } else {\n spinner.error();\n this.log.error(messages.devinit.accessTokenFailed());\n return;\n }\n\n // Magic happens...\n const checkpoint = (op: string) => {\n if (errors.length) throw errors[0];\n else log.debug(`${op} completed ok`);\n return true;\n };\n\n // Arrange API keys for development and deployment\n const [getRolesErr, roles] = await to(contensis.roles.GetRoles());\n if (!roles && getRolesErr) errors.push(getRolesErr);\n checkpoint(`fetched ${roles?.length} roles`);\n if (dryRun) {\n checkpoint(`skip api key creation (dry-run)`);\n } else {\n // existingDevKey = await this.CreateOrUpdateApiKey(\n // existingDevKey,\n // devKeyName,\n // devKeyDescription\n // );\n // checkpoint('dev key created');\n\n // Ensure dev API key is assigned to a role\n // let existingDevRole = findByIdOrName(roles || [], devKeyName, true) as\n // | Role\n // | undefined;\n // existingDevRole = await this.CreateOrUpdateRole(\n // existingDevRole,\n // devKeyRole(devKeyName, devKeyDescription)\n // );\n // checkpoint('dev key role assigned');\n // log.success(messages.devinit.createDevKey(devKeyName, true));\n\n // Ensure deploy API key is assigned to a role with the right permissions\n let existingDeployRole = findByIdOrName(\n roles || [],\n deployKeyName,\n true\n ) as Role | undefined;\n existingDeployRole = await this.CreateOrUpdateRole(\n existingDeployRole,\n deployKeyRole(deployKeyName, deployKeyDescription)\n );\n\n checkpoint('deploy key role assigned');\n log.success(messages.devinit.createDeployKey(deployKeyName, true));\n checkpoint('api keys done');\n }\n\n const envFilePath = `${projectHome}/.env`;\n const existingEnvFile = readFile(envFilePath);\n let existingEnvFileArray = (existingEnvFile || '')\n .split('\\n')\n .filter(l => !!l);\n\n // Update or create a file called .env in project home\n const envContentsToAdd: EnvContentsToAdd = {\n ALIAS: currentEnv,\n PROJECT: currentProject,\n };\n if (accessToken) envContentsToAdd['ACCESS_TOKEN'] = accessToken;\n // add client id and secret to the env file\n if (this.clientDetailsLocation === 'env') {\n envContentsToAdd['CONTENSIS_CLIENT_ID'] = this.clientId;\n envContentsToAdd['CONTENSIS_CLIENT_SECRET'] = this.clientSecret;\n }\n\n // if we have client id / secret in our env remove it\n const removeEnvItems = (items: string[]) => {\n const indexesToRemove = [];\n\n for (let i = 0; i < existingEnvFileArray.length; i++) {\n for (const item of items) {\n if (existingEnvFileArray[i].includes(item)) {\n indexesToRemove.push(i);\n break;\n }\n }\n }\n\n for (let i = indexesToRemove.length - 1; i >= 0; i--) {\n existingEnvFileArray.splice(indexesToRemove[i], 1);\n }\n };\n\n if (this.clientDetailsLocation === 'git') {\n removeEnvItems(['CONTENSIS_CLIENT_ID', 'CONTENSIS_CLIENT_SECRET']);\n }\n\n const envFileLines = mergeDotEnvFileContents(\n existingEnvFileArray,\n envContentsToAdd\n );\n const newEnvFileContent = envFileLines.join('\\n');\n const envDiff = diffFileContent(existingEnvFile || '', newEnvFileContent);\n\n if (dryRun) {\n if (envDiff) {\n log.info(`Updating .env file ${winSlash(envFilePath)}:\\n${envDiff}`);\n log.raw('');\n }\n checkpoint('skip .env file update (dry-run)');\n } else {\n if (envDiff) log.info(`updating .env file ${winSlash(envFilePath)}`);\n writeFile(envFilePath, envFileLines.join('\\n'));\n checkpoint('.env file updated');\n log.success(messages.devinit.writeEnvFile());\n // log.help(messages.devinit.useEnvFileTip());\n }\n\n // Update CI file -- different for GH/GL\n if (mappedWorkflow?.diff) {\n log.info(\n `Updating ${winSlash(ciFileName)} file:\\n${mappedWorkflow.diff}`\n );\n log.raw('');\n }\n if (dryRun) {\n checkpoint('skip CI file update (dry-run)');\n //log.object(ciFileLines);\n } else {\n if (mappedWorkflow?.newWorkflow) {\n if (mappedWorkflow?.diff) {\n writeFile(git.ciFilePath, mappedWorkflow.newWorkflow);\n log.success(messages.devinit.writeCiFile(`./${ciFileName}`));\n log.info(\n messages.devinit.ciBlockTip(blockId, currentEnv, currentProject)\n );\n } else {\n log.info(messages.devinit.ciFileNoChanges(`./${ciFileName}`));\n }\n checkpoint('CI file updated');\n }\n }\n\n if (this.clientDetailsLocation === 'git') {\n // Echo Deployment API key to console, ask user to add secrets to repo\n log.warning(messages.devinit.addGitSecretsIntro());\n log.help(\n messages.devinit.addGitSecretsHelp(\n git,\n existingDeployKey?.id,\n existingDeployKey?.sharedSecret\n )\n );\n }\n\n if (dryRun) {\n log.success(messages.devinit.dryRun());\n log.help(messages.devinit.noChanges());\n } else {\n log.success(messages.devinit.success());\n log.help(messages.devinit.startProjectTip());\n }\n }\n };\n\n ExecRequestHandler = async (blockIds: string[], overrideArgs?: string[]) => {\n // if no request handler exe\n // download it.\n\n // if update arg, redownload it\n\n const { log } = this;\n // const getPrefixOld = log.getPrefix;\n const exeHome = path.join(appRootDir, 'reqhan');\n const exe = 'Zengenti.Contensis.RequestHandler.LocalDevelopment';\n const exePath = path.join(exeHome, exe);\n const siteConfigPath = path.join(appRootDir, 'site_config.yaml');\n\n const siteConfig = await mapSiteConfigYaml(this);\n writeFile('site_config.yaml', stringifyYaml(siteConfig));\n\n const args = overrideArgs\n ? typeof overrideArgs?.[0] === 'string' &&\n overrideArgs[0].includes(' ', 2)\n ? overrideArgs[0].split(' ')\n : overrideArgs\n : []; // args could be [ '-c .\\\\site_config.yaml' ] or [ '-c', '.\\\\site_config.yaml' ]\n\n // Add required args\n if (!args.find(a => a === '-c')) args.push('-c', siteConfigPath);\n\n // const child = execFile(exePath, args);\n\n const child = spawn(exePath, args, { stdio: 'inherit' });\n\n // log.raw('');\n log.info(`Launching request handler...`);\n if (overrideArgs?.length)\n this.log.warning(\n `Spawning process with supplied args: ${JSON.stringify(\n child.spawnargs,\n null,\n 2\n )}`\n );\n\n let isRunning = false;\n\n // Log child output through event listeners\n child?.stdout?.on('data', data => {\n isRunning = true;\n log.raw(data);\n });\n\n child?.stderr?.on('data', data => {\n log.error(data);\n });\n\n child.on('spawn', () => {\n isRunning = true;\n log.help(\n `You may see a firewall popup requesting network access, it is safe to approve`\n );\n // log.getPrefix = () => Logger.infoText(`[rqh]`);\n });\n\n child.on('exit', code => {\n isRunning = false;\n\n log[code === 0 ? 'success' : 'warning'](\n `Request handler exited with code ${code}\\n`\n );\n });\n\n child.on('error', error => {\n isRunning = false;\n log.error(`Could not launch request handler due to error \\n${error}`);\n });\n\n await new Promise(resolve => setTimeout(resolve, 2000));\n\n // keep the method running until we can return\n while (true === true) {\n if (!isRunning) {\n // log.getPrefix = getPrefixOld; // restore logger state\n return;\n }\n await new Promise(resolve => setTimeout(resolve, 1000));\n }\n };\n}\nexport const devCommand = (\n commandArgs: string[],\n outputOpts: OutputOptionsConstructorArg,\n contensisOpts: Partial<MigrateRequest> = {}\n) => {\n return new ContensisDev(['', '', ...commandArgs], outputOpts, contensisOpts);\n};\n\nexport default ContensisDev;\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,yBAAe;AACf,2BAAsB;AACtB,sBAAqB;AACrB,kBAAiB;AAKjB,kCAA0B;AAG1B,wDAAkC;AAClC,mCAAqC;AACrC,wCAGO;AACP,2BAAgD;AAChD,kBAAgC;AAChC,oBAAwC;AACxC,kBAA+B;AAC/B,iBAA0B;AAC1B,kBAA8B;AAC9B,gBAAyB;AACzB,kBAA8B;AAC9B,yBAA8B;AAE9B,MAAM,qBAAqB,4BAAAA,QAAc;AAAA,EACvC;AAAA,EAEA,YACE,MACA,YACA,gBAAyC,CAAC,GAC1C;AACA,UAAM,MAAM,YAAY,aAAa;AAAA,EACvC;AAAA,EAEA,kBAAkB,OAAO,aAAqB,SAAc;AAE1D,UAAM,MAAO,KAAK,MAAM,IAAI,qBAAU,WAAW;AAEjD,UAAM,SAAS,IAAI,YAAY;AAC/B,QAAI,CAAC;AAAQ;AAEb,UAAM,EAAE,SAAS,MAAM,IAAI,QAAQ,CAAC;AACpC,UAAM,EAAE,YAAY,gBAAgB,KAAK,SAAS,IAAI;AACtD,UAAM,YAAY,MAAM,KAAK,iBAAiB;AAE9C,QAAI,WAAW;AAEb,YAAM,CAAC,SAAS,OAAO,IAAI,MAAM,UAAU,QAAQ,QAAQ;AAC3D,UAAI,SAAS;AACX,YAAI,MAAM,SAAS,KAAK,OAAO,UAAU,CAAC;AAC1C,YAAI,UAAM,2BAAc,OAAO,CAAC;AAChC;AAAA,MACF;AACA,YAAM,eAAe,CAAC,YACpB,mCAAS;AAAA,QACP,OAAK,EAAE,KAAK,KAAK,EAAE,YAAY,OAAM,mCAAS,OAAO;AAAA;AAIzD,YAAM,gBAAgB,IAAI;AAG1B,UAAI,aAAa,IAAI;AAMrB,YAAM,gBAAgB,GAAG
|
|
6
|
-
"names": ["ContensisRole", "inquirer", "to", "path"]
|
|
4
|
+
"sourcesContent": ["import to from 'await-to-js';\nimport { spawn } from 'child_process';\nimport inquirer from 'inquirer';\nimport path from 'path';\n\nimport { Role } from 'contensis-management-api/lib/models';\nimport { MigrateRequest } from 'migratortron';\n\nimport ContensisRole from './ContensisRoleService';\nimport { OutputOptionsConstructorArg } from '~/models/CliService';\nimport { EnvContentsToAdd } from '~/models/DevService';\nimport { mapSiteConfigYaml } from '~/mappers/DevRequests-to-RequestHanderSiteConfigYaml';\nimport { mapCIWorkflowContent } from '~/mappers/DevInit-to-CIWorkflow';\nimport {\n deployKeyRole,\n devKeyRole,\n} from '~/mappers/DevInit-to-RolePermissions';\nimport { appRootDir, readFile, writeFile } from '~/providers/file-provider';\nimport { diffFileContent } from '~/util/diff';\nimport { mergeDotEnvFileContents } from '~/util/dotenv';\nimport { findByIdOrName } from '~/util/find';\nimport { GitHelper } from '~/util/git';\nimport { jsonFormatter } from '~/util/json.formatter';\nimport { winSlash } from '~/util/os';\nimport { stringifyYaml } from '~/util/yaml';\nimport { createSpinner } from 'nanospinner';\n\nclass ContensisDev extends ContensisRole {\n git!: GitHelper;\n blockId: string;\n\n constructor(\n args: string[],\n outputOpts?: OutputOptionsConstructorArg,\n contensisOpts: Partial<MigrateRequest> = {}\n ) {\n super(args, outputOpts, contensisOpts);\n }\n\n DevelopmentInit = async (projectHome: string, opts: any) => {\n // Retrieve git info\n const git = (this.git = new GitHelper(projectHome));\n // Check if we are in a git repo\n const isRepo = git.checkIsRepo();\n if (!isRepo) return;\n\n const { dryRun = false } = opts || {};\n const { currentEnv, currentProject, log, messages } = this;\n const contensis = await this.ConnectContensis();\n\n if (contensis) {\n // First we need to get the block id from the user\n const validateBlockId = (blockId: string) => {\n const pattern = /^[a-z-]*$/;\n if (typeof blockId === 'string' && blockId.length >= 3) {\n return pattern.test(blockId);\n } else return false;\n };\n let { blockId } = await inquirer.prompt({\n name: 'blockId',\n type: 'input',\n prefix: '\uD83E\uDDF1',\n message: messages.devinit.blockIdQuestion,\n validate: validateBlockId,\n });\n // make sure block id is lowercase\n this.blockId = blockId.toLowerCase();\n log.success(`Valid block id: ${blockId.toLowerCase()}`);\n\n // Retrieve keys list for env\n const [keysErr, apiKeys] = await contensis.apiKeys.GetKeys();\n if (keysErr) {\n log.error(messages.keys.noList(currentEnv));\n log.error(jsonFormatter(keysErr));\n return;\n }\n const apiKeyExists = (findKey: string) =>\n apiKeys?.find(\n k => k.name.trim().toLowerCase() === findKey?.trim().toLowerCase()\n );\n\n // Retrieve ci workflow info\n const workflowFiles = git.workflows;\n\n // Set variables for performing operations and logging etc.\n let ciFileName = git.ciFileName;\n\n // const devKeyName = `${git.name} development`;\n // const devKeyDescription = `${git.name} [contensis-cli]`;\n // let existingDevKey = apiKeyExists(devKeyName);\n\n const deployKeyName = `${blockId} deployment`;\n const deployKeyDescription = `${blockId} deploy [contensis-cli]`;\n\n let existingDeployKey = apiKeyExists(deployKeyName);\n\n // if api key doesn't exisit go and create it (we need this for yml file).\n if (!existingDeployKey) {\n log.info('Please wait, creating deploy key');\n existingDeployKey = await this.CreateOrUpdateApiKey(\n existingDeployKey,\n deployKeyName,\n deployKeyDescription\n );\n log.success('Successfully created deploy key');\n }\n\n // check we have the deply key so we can assign them to this values\n if (existingDeployKey) {\n // Add client id and secret to global 'this'\n this.clientId = existingDeployKey?.id;\n this.clientSecret = existingDeployKey?.sharedSecret;\n }\n\n // const blockId = git.name;\n const errors = [] as AppError[];\n\n // Start render console output\n log.raw('');\n log.success(messages.devinit.intro());\n log.raw('');\n log.raw(\n log.infoText(\n messages.devinit.projectDetails(\n git.name,\n currentEnv,\n currentProject,\n blockId,\n git\n )\n )\n );\n // log.raw(\n // log.infoText(\n // messages.devinit.developmentKey(devKeyName, !!existingDevKey)\n // )\n // );\n log.raw(\n log.infoText(\n messages.devinit.deploymentKey(deployKeyName, !!existingDeployKey)\n )\n );\n log.raw('');\n\n if (Array.isArray(workflowFiles) && workflowFiles.length > 1) {\n // Choose GitHub workflow file (if multiple)\n ({ ciFileName } = await inquirer.prompt([\n {\n type: 'list',\n prefix: '\u29F0',\n message: messages.devinit.ciMultipleChoices(),\n name: 'ciFileName',\n choices: workflowFiles,\n default: workflowFiles.find(f => f.includes('docker')),\n },\n ]));\n log.raw('');\n git.ciFileName = ciFileName;\n }\n\n log.raw(log.infoText(messages.devinit.ciDetails(ciFileName)));\n\n let mappedWorkflow;\n // Location for Client ID / Secret.\n const { clientDetailsOption } = await inquirer.prompt({\n name: 'clientDetailsOption',\n type: 'list',\n prefix: '\uD83D\uDD11',\n // Where would you like to store your Client ID/Secret?\n message: messages.devinit.clientDetailsLocation(),\n choices: [\n messages.devinit.clientDetailsInGit(git),\n messages.devinit.clientDetailsInEnv(),\n ],\n });\n\n // global 'clientDetailsLocation' variable stores users input on where client id / secert are stored\n if (clientDetailsOption === messages.devinit.clientDetailsInEnv()) {\n this.clientDetailsLocation = 'env';\n } else {\n this.clientDetailsLocation = 'git';\n }\n\n if (this.clientDetailsLocation === 'env') {\n // Update CI Workflow to pull from ENV variables\n mappedWorkflow = await mapCIWorkflowContent(this);\n log.help(messages.devinit.ciIntro(git, 'env'));\n } else {\n // Look at the workflow file content and make updates\n mappedWorkflow = await mapCIWorkflowContent(this);\n log.help(messages.devinit.ciIntro(git, 'git'));\n }\n\n if (!dryRun) {\n // Confirm prompt\n const { confirm } = await inquirer.prompt([\n {\n type: 'confirm',\n message: messages.devinit.confirm(),\n name: 'confirm',\n default: false,\n },\n ]);\n log.raw('');\n if (!confirm) return;\n }\n\n // Fetching access token\n let accessToken: string | undefined = undefined;\n log.raw('');\n\n const spinner = createSpinner(messages.devinit.accessTokenFetch());\n spinner.start();\n\n const token = await this.GetDeliveryApiKey();\n\n if (token) {\n spinner.success();\n this.log.success(messages.devinit.accessTokenSuccess(token));\n accessToken = token;\n } else {\n spinner.error();\n this.log.error(messages.devinit.accessTokenFailed());\n return;\n }\n\n // Magic happens...\n const checkpoint = (op: string) => {\n if (errors.length) throw errors[0];\n else log.debug(`${op} completed ok`);\n return true;\n };\n\n // Arrange API keys for development and deployment\n const [getRolesErr, roles] = await to(contensis.roles.GetRoles());\n if (!roles && getRolesErr) errors.push(getRolesErr);\n checkpoint(`fetched ${roles?.length} roles`);\n if (dryRun) {\n checkpoint(`skip api key creation (dry-run)`);\n } else {\n // existingDevKey = await this.CreateOrUpdateApiKey(\n // existingDevKey,\n // devKeyName,\n // devKeyDescription\n // );\n // checkpoint('dev key created');\n\n // Ensure dev API key is assigned to a role\n // let existingDevRole = findByIdOrName(roles || [], devKeyName, true) as\n // | Role\n // | undefined;\n // existingDevRole = await this.CreateOrUpdateRole(\n // existingDevRole,\n // devKeyRole(devKeyName, devKeyDescription)\n // );\n // checkpoint('dev key role assigned');\n // log.success(messages.devinit.createDevKey(devKeyName, true));\n\n // Ensure deploy API key is assigned to a role with the right permissions\n let existingDeployRole = findByIdOrName(\n roles || [],\n deployKeyName,\n true\n ) as Role | undefined;\n existingDeployRole = await this.CreateOrUpdateRole(\n existingDeployRole,\n deployKeyRole(deployKeyName, deployKeyDescription)\n );\n\n checkpoint('deploy key role assigned');\n log.success(messages.devinit.createDeployKey(deployKeyName, true));\n checkpoint('api keys done');\n }\n\n const envFilePath = `${projectHome}/.env`;\n const existingEnvFile = readFile(envFilePath);\n let existingEnvFileArray = (existingEnvFile || '')\n .split('\\n')\n .filter(l => !!l);\n\n // Update or create a file called .env in project home\n const envContentsToAdd: EnvContentsToAdd = {\n ALIAS: currentEnv,\n PROJECT: currentProject,\n BLOCK_ID: blockId,\n };\n if (accessToken) envContentsToAdd['ACCESS_TOKEN'] = accessToken;\n // add client id and secret to the env file\n if (this.clientDetailsLocation === 'env') {\n envContentsToAdd['CONTENSIS_CLIENT_ID'] = this.clientId;\n envContentsToAdd['CONTENSIS_CLIENT_SECRET'] = this.clientSecret;\n }\n\n // if we have client id / secret in our env remove it\n const removeEnvItems = (items: string[]) => {\n const indexesToRemove = [];\n\n for (let i = 0; i < existingEnvFileArray.length; i++) {\n for (const item of items) {\n if (existingEnvFileArray[i].includes(item)) {\n indexesToRemove.push(i);\n break;\n }\n }\n }\n\n for (let i = indexesToRemove.length - 1; i >= 0; i--) {\n existingEnvFileArray.splice(indexesToRemove[i], 1);\n }\n };\n\n if (this.clientDetailsLocation === 'git') {\n removeEnvItems(['CONTENSIS_CLIENT_ID', 'CONTENSIS_CLIENT_SECRET']);\n }\n\n const envFileLines = mergeDotEnvFileContents(\n existingEnvFileArray,\n envContentsToAdd\n );\n const newEnvFileContent = envFileLines.join('\\n');\n const envDiff = diffFileContent(existingEnvFile || '', newEnvFileContent);\n\n if (dryRun) {\n if (envDiff) {\n log.info(`Updating .env file ${winSlash(envFilePath)}:\\n${envDiff}`);\n log.raw('');\n }\n checkpoint('skip .env file update (dry-run)');\n } else {\n if (envDiff) log.info(`updating .env file ${winSlash(envFilePath)}`);\n writeFile(envFilePath, envFileLines.join('\\n'));\n checkpoint('.env file updated');\n log.success(messages.devinit.writeEnvFile());\n // log.help(messages.devinit.useEnvFileTip());\n }\n\n // Update CI file -- different for GH/GL\n if (mappedWorkflow?.diff) {\n log.info(\n `Updating ${winSlash(ciFileName)} file:\\n${mappedWorkflow.diff}`\n );\n log.raw('');\n }\n if (dryRun) {\n checkpoint('skip CI file update (dry-run)');\n //log.object(ciFileLines);\n } else {\n if (mappedWorkflow?.newWorkflow) {\n if (mappedWorkflow?.diff) {\n writeFile(git.ciFilePath, mappedWorkflow.newWorkflow);\n log.success(messages.devinit.writeCiFile(`./${ciFileName}`));\n log.info(\n messages.devinit.ciBlockTip(blockId, currentEnv, currentProject)\n );\n } else {\n log.info(messages.devinit.ciFileNoChanges(`./${ciFileName}`));\n }\n checkpoint('CI file updated');\n }\n }\n\n if (this.clientDetailsLocation === 'git') {\n // Echo Deployment API key to console, ask user to add secrets to repo\n log.warning(messages.devinit.addGitSecretsIntro());\n log.help(\n messages.devinit.addGitSecretsHelp(\n git,\n existingDeployKey?.id,\n existingDeployKey?.sharedSecret\n )\n );\n }\n\n if (dryRun) {\n log.success(messages.devinit.dryRun());\n log.help(messages.devinit.noChanges());\n } else {\n log.success(messages.devinit.success());\n log.help(messages.devinit.startProjectTip());\n }\n }\n };\n\n ExecRequestHandler = async (blockIds: string[], overrideArgs?: string[]) => {\n // if no request handler exe\n // download it.\n\n // if update arg, redownload it\n\n const { log } = this;\n // const getPrefixOld = log.getPrefix;\n const exeHome = path.join(appRootDir, 'reqhan');\n const exe = 'Zengenti.Contensis.RequestHandler.LocalDevelopment';\n const exePath = path.join(exeHome, exe);\n const siteConfigPath = path.join(appRootDir, 'site_config.yaml');\n\n const siteConfig = await mapSiteConfigYaml(this);\n writeFile('site_config.yaml', stringifyYaml(siteConfig));\n\n const args = overrideArgs\n ? typeof overrideArgs?.[0] === 'string' &&\n overrideArgs[0].includes(' ', 2)\n ? overrideArgs[0].split(' ')\n : overrideArgs\n : []; // args could be [ '-c .\\\\site_config.yaml' ] or [ '-c', '.\\\\site_config.yaml' ]\n\n // Add required args\n if (!args.find(a => a === '-c')) args.push('-c', siteConfigPath);\n\n // const child = execFile(exePath, args);\n\n const child = spawn(exePath, args, { stdio: 'inherit' });\n\n // log.raw('');\n log.info(`Launching request handler...`);\n if (overrideArgs?.length)\n this.log.warning(\n `Spawning process with supplied args: ${JSON.stringify(\n child.spawnargs,\n null,\n 2\n )}`\n );\n\n let isRunning = false;\n\n // Log child output through event listeners\n child?.stdout?.on('data', data => {\n isRunning = true;\n log.raw(data);\n });\n\n child?.stderr?.on('data', data => {\n log.error(data);\n });\n\n child.on('spawn', () => {\n isRunning = true;\n log.help(\n `You may see a firewall popup requesting network access, it is safe to approve`\n );\n // log.getPrefix = () => Logger.infoText(`[rqh]`);\n });\n\n child.on('exit', code => {\n isRunning = false;\n\n log[code === 0 ? 'success' : 'warning'](\n `Request handler exited with code ${code}\\n`\n );\n });\n\n child.on('error', error => {\n isRunning = false;\n log.error(`Could not launch request handler due to error \\n${error}`);\n });\n\n await new Promise(resolve => setTimeout(resolve, 2000));\n\n // keep the method running until we can return\n while (true === true) {\n if (!isRunning) {\n // log.getPrefix = getPrefixOld; // restore logger state\n return;\n }\n await new Promise(resolve => setTimeout(resolve, 1000));\n }\n };\n}\nexport const devCommand = (\n commandArgs: string[],\n outputOpts: OutputOptionsConstructorArg,\n contensisOpts: Partial<MigrateRequest> = {}\n) => {\n return new ContensisDev(['', '', ...commandArgs], outputOpts, contensisOpts);\n};\n\nexport default ContensisDev;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,yBAAe;AACf,2BAAsB;AACtB,sBAAqB;AACrB,kBAAiB;AAKjB,kCAA0B;AAG1B,wDAAkC;AAClC,mCAAqC;AACrC,wCAGO;AACP,2BAAgD;AAChD,kBAAgC;AAChC,oBAAwC;AAC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AChB,WAAK,IAAI;AAAA,QACP,wCAAwC,KAAK;AAAA,UAC3C,MAAM;AAAA,UACN;AAAA,UACA;AAAA,QACF;AAAA,MACF;AAEF,QAAI,YAAY;AAGhB,yCAAO,WAAP,mBAAe,GAAG,QAAQ,UAAQ;AAChC,kBAAY;AACZ,UAAI,IAAI,IAAI;AAAA,IACd;AAEA,yCAAO,WAAP,mBAAe,GAAG,QAAQ,UAAQ;AAChC,UAAI,MAAM,IAAI;AAAA,IAChB;AAEA,UAAM,GAAG,SAAS,MAAM;AACtB,kBAAY;AACZ,UAAI;AAAA,QACF;AAAA,MACF;AAAA,IAEF,CAAC;AAED,UAAM,GAAG,QAAQ,UAAQ;AACvB,kBAAY;AAEZ,UAAI,SAAS,IAAI,YAAY;AAAA,QAC3B,oCAAoC;AAAA;AAAA,MACtC;AAAA,IACF,CAAC;AAED,UAAM,GAAG,SAAS,WAAS;AACzB,kBAAY;AACZ,UAAI,MAAM;AAAA,EAAmD,OAAO;AAAA,IACtE,CAAC;AAED,UAAM,IAAI,QAAQ,aAAW,WAAW,SAAS,GAAI,CAAC;AAGtD,WAAO,MAAe;AACpB,UAAI,CAAC,WAAW;AAEd;AAAA,MACF;AACA,YAAM,IAAI,QAAQ,aAAW,WAAW,SAAS,GAAI,CAAC;AAAA,IACxD;AAAA,EACF;AACF;AACO,MAAM,aAAa,CACxB,aACA,YACA,gBAAyC,CAAC,MACvC;AACH,SAAO,IAAI,aAAa,CAAC,IAAI,IAAI,GAAG,WAAW,GAAG,YAAY,aAAa;AAC7E;AAEA,IAAO,8BAAQ;",
|
|
6
|
+
"names": ["ContensisRole", "blockId", "inquirer", "to", "path"]
|
|
7
7
|
}
|
package/dist/version.js
CHANGED
|
@@ -21,7 +21,7 @@ __export(version_exports, {
|
|
|
21
21
|
LIB_VERSION: () => LIB_VERSION
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(version_exports);
|
|
24
|
-
const LIB_VERSION = "1.0.9-beta.
|
|
24
|
+
const LIB_VERSION = "1.0.9-beta.6";
|
|
25
25
|
// Annotate the CommonJS export names for ESM import in node:
|
|
26
26
|
0 && (module.exports = {
|
|
27
27
|
LIB_VERSION
|
package/dist/version.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/version.ts"],
|
|
4
|
-
"sourcesContent": ["export const LIB_VERSION = \"1.0.9-beta.
|
|
4
|
+
"sourcesContent": ["export const LIB_VERSION = \"1.0.9-beta.6\";\n"],
|
|
5
5
|
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,MAAM,cAAc;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "contensis-cli",
|
|
3
|
-
"version": "1.0.9-beta.
|
|
3
|
+
"version": "1.0.9-beta.6",
|
|
4
4
|
"description": "A fully featured Contensis command line interface with a shell UI provides simple and intuitive ways to manage or profile your content in any NodeJS terminal.",
|
|
5
5
|
"repository": "https://github.com/contensis/node-cli",
|
|
6
6
|
"homepage": "https://github.com/contensis/node-cli/tree/main/packages/contensis-cli#readme",
|
|
@@ -439,14 +439,18 @@ export const LogMessages = {
|
|
|
439
439
|
name: string,
|
|
440
440
|
env: string,
|
|
441
441
|
projectId: string,
|
|
442
|
+
blockId: string,
|
|
442
443
|
git: GitHelper
|
|
443
444
|
) =>
|
|
444
|
-
`
|
|
445
|
-
|
|
446
|
-
|
|
445
|
+
`
|
|
446
|
+
Project: ${Logger.standardText(name)}
|
|
447
|
+
- Home: ${Logger.standardText(process.cwd())}
|
|
448
|
+
- Repository: ${Logger.standardText(git.home)}
|
|
449
|
+
- Block id: ${Logger.highlightText(blockId)}
|
|
447
450
|
|
|
448
|
-
Connect to Contensis instance: ${Logger.standardText(env)}
|
|
449
|
-
|
|
451
|
+
Connect to Contensis instance: ${Logger.standardText(env)}
|
|
452
|
+
- Project id: ${Logger.standardText(projectId)}
|
|
453
|
+
`,
|
|
450
454
|
developmentKey: (name: string, existing: boolean) =>
|
|
451
455
|
` - ${
|
|
452
456
|
!existing ? 'Create development API key' : 'Development API key found'
|
|
@@ -567,5 +571,9 @@ Connect to Contensis instance: ${Logger.standardText(env)}
|
|
|
567
571
|
)} flag to update your project with these changes`,
|
|
568
572
|
startProjectTip: () =>
|
|
569
573
|
`Start up your project in the normal way for development`,
|
|
574
|
+
blockIdQuestion: () =>
|
|
575
|
+
`Please enter your block id, this should be unquie and in kebab case e.g ${Logger.highlightText(
|
|
576
|
+
'my-awesome-website'
|
|
577
|
+
)}`,
|
|
570
578
|
},
|
|
571
579
|
};
|
|
@@ -26,8 +26,6 @@ export const mapCIWorkflowContent = async (
|
|
|
26
26
|
const workflowFile = readFile(cli.git.ciFilePath);
|
|
27
27
|
if (!workflowFile) return undefined;
|
|
28
28
|
|
|
29
|
-
const blockId = cli.git.name;
|
|
30
|
-
|
|
31
29
|
// parse yaml to js
|
|
32
30
|
const workflowDoc = parseYamlDocument(workflowFile);
|
|
33
31
|
const workflowJS = workflowDoc.toJS();
|
|
@@ -35,7 +33,6 @@ export const mapCIWorkflowContent = async (
|
|
|
35
33
|
if (cli.git.type === 'github') {
|
|
36
34
|
const newWorkflow = await mapGitHubActionCIWorkflowContent(
|
|
37
35
|
cli,
|
|
38
|
-
blockId,
|
|
39
36
|
workflowDoc,
|
|
40
37
|
workflowJS
|
|
41
38
|
);
|
|
@@ -47,7 +44,6 @@ export const mapCIWorkflowContent = async (
|
|
|
47
44
|
} else if (cli.git.type === 'gitlab') {
|
|
48
45
|
const newWorkflow = await mapGitLabCIWorkflowContent(
|
|
49
46
|
cli,
|
|
50
|
-
blockId,
|
|
51
47
|
workflowDoc,
|
|
52
48
|
workflowJS
|
|
53
49
|
);
|
|
@@ -92,14 +88,13 @@ const setWorkflowElement = (
|
|
|
92
88
|
|
|
93
89
|
const mapGitLabCIWorkflowContent = async (
|
|
94
90
|
cli: ContensisDev,
|
|
95
|
-
blockId: string,
|
|
96
91
|
workflowDoc: Document,
|
|
97
92
|
workflowJS: any
|
|
98
93
|
) => {
|
|
99
94
|
const addGitLabJobStage: GitLabPushBlockJobStage = {
|
|
100
95
|
stage: 'push-block',
|
|
101
96
|
variables: {
|
|
102
|
-
block_id: blockId,
|
|
97
|
+
block_id: cli.blockId,
|
|
103
98
|
alias: cli.currentEnv,
|
|
104
99
|
project_id: cli.currentProject,
|
|
105
100
|
client_id:
|
|
@@ -171,7 +166,11 @@ const mapGitLabCIWorkflowContent = async (
|
|
|
171
166
|
`${stepPath}.variables.project_id`,
|
|
172
167
|
cli.currentProject
|
|
173
168
|
);
|
|
174
|
-
setWorkflowElement(
|
|
169
|
+
setWorkflowElement(
|
|
170
|
+
workflowDoc,
|
|
171
|
+
`${stepPath}.variables.block_id`,
|
|
172
|
+
cli.blockId
|
|
173
|
+
);
|
|
175
174
|
|
|
176
175
|
// This is likely not needed when updating an existing push-block job step
|
|
177
176
|
// we are assuming this is a forked/copied workflow with an already working image-uri reference
|
|
@@ -222,7 +221,6 @@ const mapGitLabCIWorkflowContent = async (
|
|
|
222
221
|
|
|
223
222
|
const mapGitHubActionCIWorkflowContent = async (
|
|
224
223
|
cli: ContensisDev,
|
|
225
|
-
blockId: string,
|
|
226
224
|
workflowDoc: Document,
|
|
227
225
|
workflowJS: any
|
|
228
226
|
) => {
|
|
@@ -231,7 +229,7 @@ const mapGitHubActionCIWorkflowContent = async (
|
|
|
231
229
|
id: 'push-block',
|
|
232
230
|
uses: 'contensis/block-push@v1',
|
|
233
231
|
with: {
|
|
234
|
-
'block-id': blockId,
|
|
232
|
+
'block-id': cli.blockId,
|
|
235
233
|
// 'image-uri': '${{ steps.build.outputs.image-uri }}',
|
|
236
234
|
alias: cli.currentEnv,
|
|
237
235
|
'project-id': cli.currentProject,
|
|
@@ -319,7 +317,7 @@ const mapGitHubActionCIWorkflowContent = async (
|
|
|
319
317
|
`${stepPath}.with.project-id`,
|
|
320
318
|
cli.currentProject
|
|
321
319
|
);
|
|
322
|
-
setWorkflowElement(workflowDoc, `${stepPath}.with.block-id`, blockId);
|
|
320
|
+
setWorkflowElement(workflowDoc, `${stepPath}.with.block-id`, cli.blockId);
|
|
323
321
|
|
|
324
322
|
// This is likely not needed when updating an existing push-block job step
|
|
325
323
|
// we are assuming this is a forked/copied workflow with an already working image-uri reference
|
|
@@ -443,7 +441,7 @@ const mapGitHubActionCIWorkflowContent = async (
|
|
|
443
441
|
// workflowDoc.toString({ lineWidth: 0 })
|
|
444
442
|
// );
|
|
445
443
|
|
|
446
|
-
const newWorkflow = workflowDoc.toString();
|
|
444
|
+
const newWorkflow = workflowDoc.toString({ lineWidth: 0 });
|
|
447
445
|
|
|
448
446
|
return newWorkflow;
|
|
449
447
|
};
|
|
@@ -27,6 +27,7 @@ import { createSpinner } from 'nanospinner';
|
|
|
27
27
|
|
|
28
28
|
class ContensisDev extends ContensisRole {
|
|
29
29
|
git!: GitHelper;
|
|
30
|
+
blockId: string;
|
|
30
31
|
|
|
31
32
|
constructor(
|
|
32
33
|
args: string[],
|
|
@@ -48,6 +49,24 @@ class ContensisDev extends ContensisRole {
|
|
|
48
49
|
const contensis = await this.ConnectContensis();
|
|
49
50
|
|
|
50
51
|
if (contensis) {
|
|
52
|
+
// First we need to get the block id from the user
|
|
53
|
+
const validateBlockId = (blockId: string) => {
|
|
54
|
+
const pattern = /^[a-z-]*$/;
|
|
55
|
+
if (typeof blockId === 'string' && blockId.length >= 3) {
|
|
56
|
+
return pattern.test(blockId);
|
|
57
|
+
} else return false;
|
|
58
|
+
};
|
|
59
|
+
let { blockId } = await inquirer.prompt({
|
|
60
|
+
name: 'blockId',
|
|
61
|
+
type: 'input',
|
|
62
|
+
prefix: '🧱',
|
|
63
|
+
message: messages.devinit.blockIdQuestion,
|
|
64
|
+
validate: validateBlockId,
|
|
65
|
+
});
|
|
66
|
+
// make sure block id is lowercase
|
|
67
|
+
this.blockId = blockId.toLowerCase();
|
|
68
|
+
log.success(`Valid block id: ${blockId.toLowerCase()}`);
|
|
69
|
+
|
|
51
70
|
// Retrieve keys list for env
|
|
52
71
|
const [keysErr, apiKeys] = await contensis.apiKeys.GetKeys();
|
|
53
72
|
if (keysErr) {
|
|
@@ -70,8 +89,8 @@ class ContensisDev extends ContensisRole {
|
|
|
70
89
|
// const devKeyDescription = `${git.name} [contensis-cli]`;
|
|
71
90
|
// let existingDevKey = apiKeyExists(devKeyName);
|
|
72
91
|
|
|
73
|
-
const deployKeyName = `${
|
|
74
|
-
const deployKeyDescription = `${
|
|
92
|
+
const deployKeyName = `${blockId} deployment`;
|
|
93
|
+
const deployKeyDescription = `${blockId} deploy [contensis-cli]`;
|
|
75
94
|
|
|
76
95
|
let existingDeployKey = apiKeyExists(deployKeyName);
|
|
77
96
|
|
|
@@ -93,7 +112,7 @@ class ContensisDev extends ContensisRole {
|
|
|
93
112
|
this.clientSecret = existingDeployKey?.sharedSecret;
|
|
94
113
|
}
|
|
95
114
|
|
|
96
|
-
const blockId = git.name;
|
|
115
|
+
// const blockId = git.name;
|
|
97
116
|
const errors = [] as AppError[];
|
|
98
117
|
|
|
99
118
|
// Start render console output
|
|
@@ -106,6 +125,7 @@ class ContensisDev extends ContensisRole {
|
|
|
106
125
|
git.name,
|
|
107
126
|
currentEnv,
|
|
108
127
|
currentProject,
|
|
128
|
+
blockId,
|
|
109
129
|
git
|
|
110
130
|
)
|
|
111
131
|
)
|
|
@@ -164,11 +184,11 @@ class ContensisDev extends ContensisRole {
|
|
|
164
184
|
if (this.clientDetailsLocation === 'env') {
|
|
165
185
|
// Update CI Workflow to pull from ENV variables
|
|
166
186
|
mappedWorkflow = await mapCIWorkflowContent(this);
|
|
167
|
-
log.help(messages.devinit.ciIntro(git,
|
|
187
|
+
log.help(messages.devinit.ciIntro(git, 'env'));
|
|
168
188
|
} else {
|
|
169
189
|
// Look at the workflow file content and make updates
|
|
170
190
|
mappedWorkflow = await mapCIWorkflowContent(this);
|
|
171
|
-
log.help(messages.devinit.ciIntro(git,
|
|
191
|
+
log.help(messages.devinit.ciIntro(git, 'git'));
|
|
172
192
|
}
|
|
173
193
|
|
|
174
194
|
if (!dryRun) {
|
|
@@ -262,6 +282,7 @@ class ContensisDev extends ContensisRole {
|
|
|
262
282
|
const envContentsToAdd: EnvContentsToAdd = {
|
|
263
283
|
ALIAS: currentEnv,
|
|
264
284
|
PROJECT: currentProject,
|
|
285
|
+
BLOCK_ID: blockId,
|
|
265
286
|
};
|
|
266
287
|
if (accessToken) envContentsToAdd['ACCESS_TOKEN'] = accessToken;
|
|
267
288
|
// add client id and secret to the env file
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const LIB_VERSION = "1.0.9-beta.
|
|
1
|
+
export const LIB_VERSION = "1.0.9-beta.6";
|