Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

path option doesn't behave well with ember-cli-deploy's development workflow #48

Open
sumeetattree opened this issue Feb 20, 2018 · 9 comments

Comments

@sumeetattree
Copy link

I am using this addon with ember-cli-deploy's development workflow. I have 3 different env files for different environments: .env.deploy.${env}.

Here's the config/dotenv.js contents:

/* eslint-env node */

module.exports = function(env) {
  return {
    clientAllowedKeys: [
      'API_HOST',
      'ASSET_HOST',
      'REDIS_URL',
      'SOCKET_URL',
      'S3_BUCKET_NAME',
      'AWS_REGION',
    ],
    path: `./.env.deploy.${env}`
  }
}

Running ember s works fine for the development environment but ember deploy staging and ember deploy production commands seem to not find the correct env file.

Changing the path variable from ./.env.deploy.${env} to ../.env.deploy.${env} does the trick.

@sumeetattree
Copy link
Author

Forgot to mention that this is the behavior in 2.0.0

On the master branch path: '../.env.deploy.${env}' fails with:
[ember-cli-dotenv]: ENOENT: no such file or directory, open '../.env.deploy.development'

@xn
Copy link

xn commented Mar 26, 2018

same

@viniciussbs
Copy link

Any news?

@LBKinson
Copy link

LBKinson commented Jun 1, 2018

Same. Updates @fivetanley?

@sescobb27
Copy link

it seems that env is not properly set when issuing ember deploy production a workaround is specified in this issue #46

this worked for me

/* eslint-env node */

'use strict';

const path = require('path');

module.exports = function(env) {
  // $ ember deploy production
  // [0] = node
  // [1] = ember
  // [2] command = deploy
  // [3] target = production
  const [,, command, target] = process.argv;

  if (command && target && command === 'deploy') {
    env = target;
  }

  const isProd = env == 'production';
  const isStaging = env == 'staging';
  const envFile = (isProd || isStaging) ? `.env.deploy.${env}` : '.env';

  return {
    clientAllowedKeys: [...],
    path: path.join(__dirname, '..', envFile)
  };
};

@viniciussbs
Copy link

@sescobb27 where have you put this code?

@sescobb27
Copy link

@viniciussbs in config/dotenv.js

@viniciussbs
Copy link

Thank you, @sescobb27. I'll give it a try.

@jkeen
Copy link

jkeen commented May 28, 2020

Here I am in 2020 and I had this same puzzling issue. Not sure why it happened in a new ember app but didn't in another one also running dotenv 3, but this was really puzzling and surprising.

The code above helped, but it needed a small modification to support other commands from ember-cli-deploy like ember deploy:list prod, etc etc

For future confused travelers to this thread or #46

// config/dotenv.js

'use strict';
const path = require('path');

module.exports = function(env) {
  // $ ember deploy production
  // [0] = node
  // [1] = ember
  // [2] command = deploy
  // [3] target = production
  const [,, command, target] = process.argv;

  if (command && target && (command === 'deploy' || command.indexOf("deploy:") == 0)) {
    env = target;
  }

  const isProd     = (env == 'production' || env == 'prod');
  const isStaging  = env == 'staging';
  const envFile    = (isProd || isStaging) ? `.env.deploy.${env}` : '.env';

  return {
    clientAllowedKeys: [...],
    path: path.join(__dirname, '..', envFile)
  };
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants