loading...
Cover image for Starting In A New Company? Think Npmrc And Git Name

Starting In A New Company? Think Npmrc And Git Name

daviddalbusco profile image David Dal Busco Originally published at Medium ・3 min read

One Trick A Day (35 Part Series)

1) How To Call The Service Worker From The Web App Context 2) Replace Environment Variables In Your Index.html 3 ... 33 3) Inject JavaScript Or CSS At Runtime And On Demand 4) Sometimes You Just Need A Dumb Library 5) Internationalization with Gatsby 6) How To Declare And Use Ionic Modals With Stencil 7) Get App Name And Version In Angular 8) Deploy Apps And Functions To Firebase From A Mono Repo With GitHub Actions 9) Starting In A New Company? Think Npmrc And Git Name 10) Test Angular Pipes With Services 11) Gatsby Tricks: Viewport, CSS Modules Transition And i18n Tricks 12) Takeover The Cordova Facebook Plugin Maintenance 13) Protect Your HTTP Firebase Cloud Functions 14) Create A Menu For Your Gatsby Website Without Libs 15) Create A Modal For Your Angular App Without Libs 16) Add A Slider To You Angular App 17) Test Angular Components and Services With HTTP Mocks 18) Merge Two Objects And Array To Object In JavaScript 19) JSX For Angular Developers 20) More JSX For Angular Developers 21) Create Your Own NPM Cli 22) Third Party Service Providers. Be transparent to each other! 23) React And Web Workers 24) Angular Testing: Mock Private Functions 25) React, Web Workers and IndexedDB 26) React, Web Workers, IndexedDB and ExcelJS 27) GitHub Actions: Hide And Set Angular Environment Variables 28) JavaScript Useful Functions 29) Deeplinking in Ionic Apps With Branch.io 30) Follow-up: Web Push Notifications And PWA In 2020 31) Angular And Web Workers 32) Git Commands I Always Forget 33) An Open Source Medium Like WYSIWYG Editor 34) Currency Picker And Formatter With Ionic React 35) Develop A Konami Code For Any Apps With Stencil

I share one trick a day until the end of the COVID-19 quarantine in Switzerland, April 19th 2020. Twenty-six days left until hopefully better days.


Every single time I am hired to join a team as an external developer for a while, I can guarantee you that I will have to google how I can configure the company npm Enterprise registry on my laptop 🙈. Moreover, it is also pretty sure that my first commit is going to happens with my GitHub username peterpeterparker instead of my real name or any other expected IDs 😄.

Therefore see this new article as an open letter to my future self 😉.


Setting your company’s npm Enterprise registry

If the company has hired you, there is a good chance that, unfortunately, at least some of their work is only available as closed source and distributed with a npm private registry. To configure such an entry, you can run the following command line in a terminal.

npm config set registry

Npmrc

If like me you are using your own laptop, you might not want to modify or mix up your private configuration with you client configuration right?

That’s why npmrc is there for us. With its help we are going to be able to define and switch between multiple npm profiles.

If you have not yet installed it, let’s first do so.

npm i npmrc -g

Once installed, we can use it to create Enterprise profile. For example, let’s create a profile called “client”.

npmrc -c client

After the profile has been created, it becomes the one in use, therefore, if we run the registry command, it will now set the registry only for the active profile.

npm config set registry 

Switch Between Profiles

Cool we now in our “client” profile, but how do we go back to the previous one, the default one? Nothing easier, run the npmrc command followed by the profile’s name.

npmrc default

Or if you want to switch back to the “client” one.

npmrc client

If you are lost and don’t know which profile is currently active, typing npmrc without any arguments will list the available profiles.

npmrc

Available npmrcs:

* default

client

Manual Configuration

You might like command lines but you may also rather like to modify manually your configuration using vi for example 😉.

On a Mac, the profiles find place in a folder .npmrcs added to your user directory. When you switch between these, npmrc is going to change the symlink at the root of your profile.

ls /Users/daviddalbusco/.npmrcs/default
/Users/daviddalbusco/.npmrcs/default

ls /Users/daviddalbusco/.npmrcs/client
/Users/daviddalbusco/.npmrcs/client

ls -ltr /Users/daviddalbusco/.npmrc
/Users/daviddalbusco/.npmrc -> /Users/daviddalbusco/.npmrcs/default

Setting Your Name In Git

To specify another name and email for your Git activity, you can either edit your global config or proceed by repository, up to you. I personally rather like to proceed by projects because I’ve got many clients.

Therefore, if like me you want to use your real name instead of your super cool GitHub username and also specify the email your client assigned to you, you can edit the file .git/config which find places, normally, in any Git project. In this data, add the following information:

[user]
    email = david.dalbusco@company.com
    name = David Dal Busco

And that’s it, all the interactions with the specific repo are going to be identified with these information.

Note that if you rather like to specify other inputs on a global level, you can run the following command lines.

git config --global user.name "David Dal Busco"
git config --global user.email "david.dalbusco@company.com"

Finally, in case you would have already performed a commit and are looking to amend your last commit user name, you can proceed with the --amend option of Git.

git commit --amend --author=”David Dal Busco <david.dalbusco@company.com>”

Summary

Well I am pretty sure that even if I wrote the above lines, I may forget again in the future how I have to proceed. But at least this time, I will just have to browse my blog history 😇.

Stay home, stay safe!

David

Cover photo by Max Rovensky on Unsplash

One Trick A Day (35 Part Series)

1) How To Call The Service Worker From The Web App Context 2) Replace Environment Variables In Your Index.html 3 ... 33 3) Inject JavaScript Or CSS At Runtime And On Demand 4) Sometimes You Just Need A Dumb Library 5) Internationalization with Gatsby 6) How To Declare And Use Ionic Modals With Stencil 7) Get App Name And Version In Angular 8) Deploy Apps And Functions To Firebase From A Mono Repo With GitHub Actions 9) Starting In A New Company? Think Npmrc And Git Name 10) Test Angular Pipes With Services 11) Gatsby Tricks: Viewport, CSS Modules Transition And i18n Tricks 12) Takeover The Cordova Facebook Plugin Maintenance 13) Protect Your HTTP Firebase Cloud Functions 14) Create A Menu For Your Gatsby Website Without Libs 15) Create A Modal For Your Angular App Without Libs 16) Add A Slider To You Angular App 17) Test Angular Components and Services With HTTP Mocks 18) Merge Two Objects And Array To Object In JavaScript 19) JSX For Angular Developers 20) More JSX For Angular Developers 21) Create Your Own NPM Cli 22) Third Party Service Providers. Be transparent to each other! 23) React And Web Workers 24) Angular Testing: Mock Private Functions 25) React, Web Workers and IndexedDB 26) React, Web Workers, IndexedDB and ExcelJS 27) GitHub Actions: Hide And Set Angular Environment Variables 28) JavaScript Useful Functions 29) Deeplinking in Ionic Apps With Branch.io 30) Follow-up: Web Push Notifications And PWA In 2020 31) Angular And Web Workers 32) Git Commands I Always Forget 33) An Open Source Medium Like WYSIWYG Editor 34) Currency Picker And Formatter With Ionic React 35) Develop A Konami Code For Any Apps With Stencil

Posted on by:

daviddalbusco profile

David Dal Busco

@daviddalbusco

Creator of DeckDeckGo | Organizer of the Ionic Zürich Meetup

Discussion

markdown guide
 
 

My pleasure Moses 😃
Thx for the read and comment!