
const bitbucket = require('./services/bitbucket')
const { requireValue } = require('./services/utils')
const path = require('path')

module.exports = async (options, logger) => {

  let {
    user = process.env.BITBUCKET_APP_USERNAME || 'jasonwicker-dxp',
    password = process.env.BITBUCKET_APP_PASSWORD || requireValue('password'),
    key = requireValue('key'),
    value = requireValue('value'),
  } = options;

  let secure = options.secure || false;

  let project = '';
  if (!options.workspace)
    project = process.env.BITBUCKET_REPO_SLUG || path.basename(path.resolve(process.cwd()));

  await bitbucket.setVariable(user, password, project, key, value, secure)

}
