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

Setting yarn as the default #102

Closed
af-mikecrowe opened this issue Nov 5, 2020 · 7 comments
Closed

Setting yarn as the default #102

af-mikecrowe opened this issue Nov 5, 2020 · 7 comments

Comments

@af-mikecrowe
Copy link

OK, this may be another easy one I'm missing, but here goes: Assume you have a new project with this as your ~/.mrm/config.json:

{
    "yarn": true,
    "aliases": {
        "default": ["package", "prettier", "typescript", "eslint"]
    }
}

If you run mrm default, prettier begins installing using npm.

It seems like getTaskOptions in mrm/packages/mrm/src/index.js is only using the default options if there are no parameters to the task.

Or, should mrm/packages/mrm-core/src/npm.js re-read the global config.json to get the yarn flag?

@sapegin
Copy link
Owner

sapegin commented Nov 6, 2020

Looks like it's not possible now but would be a nice addition so feel free to send a pull request 👾

One note though: mrm-core doesn't know anything about the config file but also there's no easy way to pass config options to the core right now.

What if make a yarn option for the package task that would create an empty yarn.lock or package-lock.json file? Then all the other tasks would work as expected without any changes.

@af-mikecrowe
Copy link
Author

Yeah, I thought about that. However, if we call:

install([], {yarn: true});

it doesn't actually call yarn. I'd have to also put logic into npm.js that checked for empty dependencies and run npm i or yarn with no args to create those files.

If this is OK, I'll see if I can do that...

@sapegin
Copy link
Owner

sapegin commented Nov 6, 2020

This sounds like a bug or we don't really need this parameter there ;-)

@af-mikecrowe
Copy link
Author

So, here's a couple of work-arounds:

First

{
    "yarn": true,
    "aliases": {
        "default": ["package", "custom-task-with-install", "prettier", "typescript", "eslint"]
    }
}

where custom-task-with-install calls install(..., {yarn: true})

Second

mrm package
yarn 
mrm default    <-- alias above w/o the package

@sapegin
Copy link
Owner

sapegin commented Nov 7, 2020

This might work as well as a workaround:

touch yarn.lock
mrm default

@fengzilong
Copy link
Contributor

fengzilong commented Apr 29, 2021

I'm using mrm task with programming api

Currently isUsingYarn use yarn.lock existence internally, in some case it's not enough( e.g. create a new project from template, no 'yarn' ran, directly ran mrm )

To solve this issue, can we officially add an env variable, then in isUsingYarn method fetch this env variable ?

for example

with programming api

process.env.MRM_INSTALL_USE_YARN = '1'

// ...then invoke mrm task

with cli

MRM_INSTALL_USE_YARN=1 mrm [task]

I can send a PR if needed

@kevinkhill
Copy link

Just flying by this issue and would like to comment that we should not have yarn be the default, IMHO....

Defaulting to a tool that is not always available on a users system seems like a wrong direction.

I would suggest that a smart resolution of package manager be used or stick with defaulting to npm.

For instance, I have adopted pnpm and find it much more useful than yarn. I used to be a yarn advocate and used it daily too.

Just my $0.02 as a casual mrm user

Repository owner locked and limited conversation to collaborators Sep 13, 2023
@sapegin sapegin converted this issue into discussion #301 Sep 13, 2023

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Projects
None yet
Development

No branches or pull requests

4 participants