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

Add yarn global support #2

Closed
stevenjlho opened this issue Dec 16, 2016 · 17 comments
Closed

Add yarn global support #2

stevenjlho opened this issue Dec 16, 2016 · 17 comments

Comments

@stevenjlho
Copy link

I think this feature is helpful. Maybe I can implement it.

@fubarhouse
Copy link
Owner

fubarhouse commented Dec 16, 2016

@stevenjlho I'm happy for you to create a PR.

I don't use Yarn an awful lot, but it has been introduced in this role to run from a global location. If you understand how we can get it to run globally better I am happy to get the changes through if tests pass :)

I'd like to add a build system to build from source in the future, but I've quite a lot going in the ansible realm at the moment, I've almost bit off too much to chew. Load it up with issues you find useful and any details, and I'll certainly get around to them :)

@fubarhouse
Copy link
Owner

@stevenjlho Could you be more implicit about this functionality if you do not intend to complete it?

If the intend is to manage yarn global packages as documented here, let me know.

If you're intending to do this work, please let me know - I'm not particularly fond of stagnant issues nor am I one to dismiss a feature request without very good reasons and in this case there are none.

@stevenjlho
Copy link
Author

Yes, i want to add variable yarn_global_packages. Add a list of npm packages with a name and (optional) version to be installed globally. For example:

  yarn_global_packages:
      # Install a specific version of a package.
      - name: jslint
       version: 0.9.3
      # Install the latest stable release of a package.
      - name: node-sass

This is inspired by ansible-role-nodejs

@fubarhouse
Copy link
Owner

@stevenjlho Yeah my nodejs role works in a very similar way.

With the documentation in the link in my previous post, I'll add some yarn packages to install globally and make it configurable and I'll do some checks and balances - I'll aim for a release of this 2 days as I've got a lot of ongoings on my brand new golang role.

@stevenjlho
Copy link
Author

OK, i am waiting your next release.

@fubarhouse
Copy link
Owner

This is a draft of the work I'll begin tonight - if you see something out of wack let me know.

  • get a list of yarn packages installed globally
  • install packages
    • version specification optional
    • if it's installed & version is specified, ignore.
  • upgrade package
    • do not upgrade if version is specified or if the package is uninstalled
  • checks and balances.

@fubarhouse fubarhouse reopened this Dec 21, 2016
fubarhouse added a commit that referenced this issue Dec 21, 2016
@fubarhouse
Copy link
Owner

So this is now done, I'll give you a few days to test it out to provide any feedback or improvements.

I assume you know how to use this role from a git clone, let me know if you don't - but all you need to do is include the role from branch issue-2.

I'll give you a bit of warning before release, but I want you to have the chance to provide feedback for improving this.

@stevenjlho
Copy link
Author

I found a permission problem. When variable fubarhouse_user is not root user, yarn don't have permissions to touch the file in yarn global bin folder.

@fubarhouse
Copy link
Owner

fubarhouse commented Dec 22, 2016

Thanks, I'll resubmit shortly.

I'll make a comparison between what happens as root and other, but as the binary is installed through the native system could you please tell me the importance of running as another user and not root?

The following tasks have been added, all seems well here.
I'll commit these, and add a travis preventative task to try to get the fail passing.

- name: "Yarn | Get global directory"
  become: yes
  become_user: "{{ fubarhouse_user }}"
  shell: "yarn global bin"
  register: yarn_bin_folder
  failed_when: false

- name: "Yarn | Make sure user can write to bin folder"
  become: yes
  become_user: root
  file:
    path: "{{ yarn_bin_folder.stdout }}"
    state: directory
    mode: 0755
    owner: "{{ fubarhouse_user }}"

fubarhouse added a commit that referenced this issue Dec 22, 2016
@fubarhouse
Copy link
Owner

So Ubuntu 12.04 is still failing, but everything else is in check.
I believe this will fix the user permission issue - let me know.

@stevenjlho
Copy link
Author

It's working. But i think this solution is a bit tricky. Maybe we can change bin folder according to these issue.

@fubarhouse
Copy link
Owner

fubarhouse commented Dec 22, 2016

So I've been working with it a while, I've finally got something working better.

yarn global add gulp --PREFIX=/usr/local
$ which gulp
/usr/local/bin/gulp

So, I'll get in fixed, and make that path configurable.

Stay tuned.

@fubarhouse
Copy link
Owner

So, the next round of changes for branch issue-2 is ready for assessment.
I feel much happier and comfortable with the feature set in this revision - you have my thanks there.

Let me know.

@stevenjlho
Copy link
Author

I feel happier with your help.And please let me know what thing you do in next version.

@fubarhouse
Copy link
Owner

@stevenjlho the only thing I've (just) planned for either the next or the following release would be to utilize the self-update command more.

Though yarn isn't exactly something I use everyday I fully intend on making all of my Ansible roles as freaking awesome as possible - so I basically don't turn down feature requests and I take bugs rather personally. If you think of anything that can help you work or make this better, please let me know!

I take it from your response you're happy with the end result? I'll move onto the other task and look at a release hopefully tomorrow :)

@fubarhouse
Copy link
Owner

Pull request has been merged into master and branch issue-2 has been deleted.

A release will happen very soon!

@fubarhouse
Copy link
Owner

Version 1.1 is released and available via Ansible Galaxy.

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

2 participants