import packageJSON from './package.json';

const getAppConfig = (env) => {
  const envVars = [
    'ANALYTICS_WRITE_KEY',
    'CIRCLE_BRANCH',
    'CIRCLE_SHA1',
    'FACEBOOK_ID',
    'GITHUB_ID',
    'GOOGLE_ID',
    'SENTRY_DSN',
    'STRIPE_PUBLISHABLE_KEY',
    'SYNCANO_BASE_DOMAIN',
    'SYNCANO_BILLING_EMAIL',
    'SYNCANO_DEMO_APPS_ACCOUNT_KEY',
    'SYNCANO_SUPPORT_EMAIL',
    'SYNCANO_BASE_URL'
  ];
  const config = {
    ENV: Object.keys(env)[0],
    VERSION: packageJSON.version,
    SYNCANO_BASE_URL: 'https://api.syncano.io'
  };

  envVars.forEach((key) => {
    const envName = `${config.ENV.toUpperCase()}_${key}`;
    const value = process.env[envName] || process.env[key];

    if (value) {
      config[key] = value;
    }
  });

  return config;
};

const getS3Config = (env) => {
  const { CIRCLE_BRANCH } = process.env;

  if (!CIRCLE_BRANCH) {
    throw new Error('"CIRCLE_BRANCH" env variable is required');
  }

  const branch = CIRCLE_BRANCH.toLowerCase();
  const config = {
    beta: {
      directory: './dist/',
      s3Options: {
        region: 'us-east-1'
      },
      s3UploadOptions: {
        Bucket: process.env.BETA_AWS_BUCKET_NAME
      }
    },
    devel: {
      directory: './dist/',
      s3Options: {
        region: 'us-west-2'
      },
      s3UploadOptions: {
        Bucket: process.env.STAGING_AWS_BUCKET_NAME
      },
      cloudfrontInvalidateOptions: {
        DistributionId: process.env.STAGING_AWS_DISTRIBUTION_ID,
        Items: ['/*']
      }
    },
    master: {
      directory: './dist/',
      s3Options: {
        region: 'us-west-2'
      },
      s3UploadOptions: {
        Bucket: process.env.PRODUCTION_AWS_BUCKET_NAME
      },
      cloudfrontInvalidateOptions: {
        DistributionId: process.env.PRODUCTION_AWS_DISTRIBUTION_ID,
        Items: ['/*']
      }
    },
    default: {
      directory: './dist/',
      s3Options: {
        region: 'us-west-2'
      },
      s3UploadOptions: {
        Bucket: process.env.STAGING_AWS_BUCKET_NAME
      },
      basePath: branch
    }
  };

  if (env.beta) {
    return config.beta;
  }

  return config[branch] || config.default;
};

export {
  getAppConfig,
  getS3Config
};

@@ -34,16 +34,48 @@
 e.json';
+%0Aimport %7B resolve %7D from 'path';
 %0A%0Aconst 
@@ -1057,33 +1057,44 @@
  directory: 
-'./dist/'
+resolve('dist', '*')
 ,%0A      s3Op
@@ -1254,33 +1254,44 @@
  directory: 
-'./dist/'
+resolve('dist', '*')
 ,%0A      s3Op
@@ -1588,33 +1588,44 @@
  directory: 
-'./dist/'
+resolve('dist', '*')
 ,%0A      s3Op
@@ -1937,17 +1937,28 @@
 ry: 
-'./dist/'
+resolve('dist', '*')
 ,%0A  

Use resolve method and add star on the end of directory