From 12f6a3202ee401063974aee17b49aac2038fb70c Mon Sep 17 00:00:00 2001 From: gregharvey Date: Mon, 29 Jan 2024 16:17:55 +0100 Subject: [PATCH] Merging 1.x. --- src/commands/deploy.ts | 18 ++++++++++++++++-- src/commands/provision.ts | 40 +++++++++++++++++++++++++++++++++++---- 2 files changed, 52 insertions(+), 6 deletions(-) diff --git a/src/commands/deploy.ts b/src/commands/deploy.ts index ad9b509..4a61ae6 100644 --- a/src/commands/deploy.ts +++ b/src/commands/deploy.ts @@ -1,24 +1,37 @@ import AnsibleCmd from '../base-cmd-ansible-abstract' +import {flags} from '@oclif/command' export default class DeployCmd extends AnsibleCmd { static description = 'Setup an app with Ansible playbooks.' static examples = [ - '$ ce-dev deploy example-app', + '$ ce-dev deploy example-app --verbose', ] + static flags = { + help: flags.help({char: 'h'}), + verbose: flags.boolean({ + char: 'v', + description: 'Enable verbose output in Ansible.', + }), + } + protected ansibleProjectPlaybooksPath = '/home/ce-dev/projects-playbooks/deploy' protected ansibleScriptsPath = '/home/ce-dev/ce-deploy' protected ansibleScript = 'scripts/deploy.sh' + protected verbose = false + /** * @inheritdoc */ public constructor(argv: string[], config: any) { super(argv, config) + const {flags} = this.parse(DeployCmd) this.ansiblePaths = this.activeProjectInfo.deploy + if (flags.verbose) this.verbose = true } protected getCommandParameters(ansiblePath: string): string { @@ -26,7 +39,8 @@ export default class DeployCmd extends AnsibleCmd { const buildId = this.activeProjectInfo.project_name const ownBranch = '1.x' const configBranch = '1.x' - const cmd = '--own-branch ' + ownBranch + ' --config-branch ' + configBranch + ' --workspace ' + workspace + ' --build-id ' + buildId + ' --playbook ' + ansiblePath + ' --build-number 1 --previous-stable-build-number 1 --ansible-extra-vars \'{"is_local":"true"}\'' + let cmd = '--own-branch ' + ownBranch + ' --config-branch ' + configBranch + ' --workspace ' + workspace + ' --build-id ' + buildId + ' --playbook ' + ansiblePath + ' --build-number 1 --previous-stable-build-number 1 --ansible-extra-vars \'{"is_local":"true"}\'' + if (this.verbose) cmd += ' --verbose' return cmd } } diff --git a/src/commands/provision.ts b/src/commands/provision.ts index 45be286..12a09d2 100644 --- a/src/commands/provision.ts +++ b/src/commands/provision.ts @@ -1,29 +1,61 @@ import AnsibleCmd from '../base-cmd-ansible-abstract' +import {flags} from '@oclif/command' export default class ProvisionCmd extends AnsibleCmd { static description = 'Provision containers with Ansible playbooks.' + static examples = [ + '$ ce-dev provision --branch 1.x --config 1.x --verbose', + ] + + static flags = { + help: flags.help({char: 'h'}), + branch: flags.string({ + char: 'b', + description: 'The branch of ce-provision to use for provisioning your containers. See https://github.com/codeenigma/ce-provision for options.', + default: '1.x', + }), + config: flags.string({ + char: 'c', + description: 'The branch of the ce-provision-config repository. See https://github.com/codeenigma/ce-dev-ce-provision-config for options.', + default: '1.x', + }), + verbose: flags.boolean({ + char: 'v', + description: 'Enable verbose output in Ansible.', + }), + } + protected ansibleProjectPlaybooksPath = '/home/ce-dev/projects-playbooks/provision' protected ansibleScriptsPath = '/home/ce-dev/ce-provision' protected ansibleScript = 'scripts/provision.sh' + protected ownBranch = '1.x' + + protected configBranch = '1.x' + + protected verbose = false + /** * @inheritdoc */ public constructor(argv: string[], config: any) { super(argv, config) + const {flags} = this.parse(ProvisionCmd) this.ansiblePaths = this.activeProjectInfo.provision + this.ownBranch = flags.branch + this.configBranch = flags.config + if (flags.verbose) this.verbose = true } protected getCommandParameters(ansiblePath: string): string { const workspace = this.ansibleProjectPlaybooksPath const repo = this.activeProjectInfo.project_name - const ownBranch = '1.x' - const configBranch = '1.x' - let cmd = '--own-branch ' + ownBranch - cmd += ' --config-branch ' + configBranch + let cmd = '--own-branch ' + this.ownBranch + if (this.verbose) cmd += ' --verbose' + cmd += ' --config-branch ' + this.configBranch cmd += ' --workspace ' + workspace cmd += ' --repo ' + repo cmd += ' --branch ce-dev --playbook ' + ansiblePath