Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

Read configuration from project directory #25

Closed
aleung opened this issue Oct 24, 2017 · 5 comments · May be fixed by #34
Closed

Read configuration from project directory #25

aleung opened this issue Oct 24, 2017 · 5 comments · May be fixed by #34

Comments

@aleung
Copy link
Contributor

aleung commented Oct 24, 2017

First introduce my use case:

My team develops a system in micro-service architecture which have several node.js projects. I'm trying to use mrm to unify configuration of all projects. I have defined a bunch of tasks according to our design guidelines. But not all configurations are common to all projects. Some configurations have to be set per-project. And also, some tasks should only be applied on part of projects.

I think if mrm would resolve configuration from .mrm file under project root directory, in which not only contains config items specific to current project but also defines which tasks from which preset should be applied, then I can run mrm without any argument inside each project to update its configuration according to latest version of preset/tasks published in our private npm registry.

It would be helpful for a big team to manage projects to keep them up-to-date with team's project template/configuration.

@sapegin
Copy link
Owner

sapegin commented Oct 28, 2017

You can already do this with --dir option.

@aleung
Copy link
Contributor Author

aleung commented Oct 30, 2017

@sapegin --dir option doesn't solve my issue. I have done a test:

Create .mrm/config.json with config items to take precedence in project directory. mrm mytask --dir .mrm --preset mypreset doesn't work. Config item in .mrm/config.json isn't used.

If I use --config option: mrm mytask --config:foo foo_value --preset mypreset works.

Reading mrm source code, I found that

function getConfigFromFile(directories, filename) {
doesn't merge configuration from files and it only load configure from the first file. In my use case, I expect that config files in dir and in preset both take effect.

@sapegin
Copy link
Owner

sapegin commented Oct 30, 2017

You’re right, it doesn’t merge configs. But you can change any option via command line.

@aleung
Copy link
Contributor Author

aleung commented Oct 30, 2017

Yes, config option works. But it looks not the best way to me for reasons:

  • When there are more configure items the command line is long.
  • To automatic the workflow, I have to create a shell script to call mrm with a long list of arguments. Whenever a config needs to be updated, the script will be modified. Embedding config in a script is not good for maintainence.
  • Or I create a property file to store configs. My script read it then pass configs to mrm. But it adds complexity. It'd be ideal to handle inside mrm.

Would you consider to support merge config from files? If yes maybe I can contribute a PR.

@sapegin sapegin reopened this Nov 6, 2017
@sapegin
Copy link
Owner

sapegin commented Nov 6, 2017

Would be nice if you could try to implement it. Maybe we could use cosmiconfig for that.

apoleshchuk added a commit to apoleshchuk/mrm that referenced this issue Oct 9, 2018
apoleshchuk added a commit to apoleshchuk/mrm that referenced this issue Oct 22, 2018
Repository owner locked and limited conversation to collaborators Sep 13, 2023
@sapegin sapegin converted this issue into discussion #299 Sep 13, 2023

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants