Pridal: Pred 6 rokmi
Managing private npm packages.
1.) Create new feed Build & Releases > Packages > New Feed
2.) Create local project or local package source on your PC disk
3.) install vsts-npm-auth globally on your maschine with:
npm install -g vsts-npm-auth
4.) Create file for vsts-npm-auth in the root of the project/module (or higher in the directory-tree) with the name .npmrc
5.) Go to new created feed “Connect to feed”
Check copy the registry path to the newly created .npmrc and copy this link in to the file.
Only one line for registry per file is allowed
6.) In the project module package.json add following lines:
"scripts": {
"refreshVSToken" : "vsts-npm-auth -config .npmrc -F"
}
7.) Update or create with npm run refreshVSToken –f with script or manualy with vsts-npm-auth -config path-to-your\.npmrc
or vsts-npm-auth -config .npmrc from root of the module
8.) In your profile go to the Security > Personal access tokens > Add -> create new access token that last longer (max 1 year) than manually generated one (90 days token) from the feed connection page.
9.) Copy the newly created token from “Personal access tokens”
and generate Base64String in powershell with following command
[Convert]::ToBase64String([system.Text.Encoding]::UTF8.GetBytes("___Copy_Access_Token_Here______"))
10.) Include generated base64String to the .npmrc with loginName, email etc:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
//tfs.st.it.local/tfs/DefaultCollection/_packaging/local_npm_storage_test/npm/registry/:username=IT\YourLoginName
//tfs.st.it.local/tfs/DefaultCollection/_packaging/local_npm_storage_test/npm/registry/:_password=___Copy_Base64String_Access_Token_Here______
//tfs.st.it.local/tfs/DefaultCollection/_packaging/local_npm_storage_test/npm/registry/:email=fullEmail@email.sk
//tfs.st.it.local/tfs/DefaultCollection/_packaging/local_npm_storage_test/npm/registry/:always-auth=true
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
After this setup modules can be published
11.) For publishing an module is required to follow this steps:
- Run the configuration update to new version with C:\NpmStorage\Test1\node_modules\test1>vsts-npm-auth -config .\.npmrc
- Then > npm publish
In TFS the package should be displayed in the list as private package marked as for “This feed” only:
Sources:
https://www.youtube.com/watch?v=sTVtn9nTquk
https://docs.microsoft.com/en-us/vsts/package/npm/npmrc?view=vsts
https://blogs.msdn.microsoft.com/devops/2017/11/20/package-management-adds-nuget-org-upstream-source/ (note: currently, the nuget.org upstream supports guaranteed saving; the npmjs.com upstream will be enabled for guaranteed saving early in 2018)
https://www.benday.com/2017/05/03/walkthrough-use-a-package-from-a-private-nuget-server-in-tfs2017/
https://docs.microsoft.com/en-us/vsts/package/how-to/set-up-upstream-sources?view=vsts
1.) Create new feed Build & Releases > Packages > New Feed
2.) Create local project or local package source on your PC disk
3.) install vsts-npm-auth globally on your maschine with:
npm install -g vsts-npm-auth
4.) Create file for vsts-npm-auth in the root of the project/module (or higher in the directory-tree) with the name .npmrc
5.) Go to new created feed “Connect to feed”
Check copy the registry path to the newly created .npmrc and copy this link in to the file.
Only one line for registry per file is allowed
6.) In the project module package.json add following lines:
"scripts": {
"refreshVSToken" : "vsts-npm-auth -config .npmrc -F"
}
7.) Update or create with npm run refreshVSToken –f with script or manualy with vsts-npm-auth -config path-to-your\.npmrc
or vsts-npm-auth -config .npmrc from root of the module
8.) In your profile go to the Security > Personal access tokens > Add -> create new access token that last longer (max 1 year) than manually generated one (90 days token) from the feed connection page.
9.) Copy the newly created token from “Personal access tokens”
and generate Base64String in powershell with following command
[Convert]::ToBase64String([system.Text.Encoding]::UTF8.GetBytes("___Copy_Access_Token_Here______"))
10.) Include generated base64String to the .npmrc with loginName, email etc:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
//tfs.st.it.local/tfs/DefaultCollection/_packaging/local_npm_storage_test/npm/registry/:username=IT\YourLoginName
//tfs.st.it.local/tfs/DefaultCollection/_packaging/local_npm_storage_test/npm/registry/:_password=___Copy_Base64String_Access_Token_Here______
//tfs.st.it.local/tfs/DefaultCollection/_packaging/local_npm_storage_test/npm/registry/:email=fullEmail@email.sk
//tfs.st.it.local/tfs/DefaultCollection/_packaging/local_npm_storage_test/npm/registry/:always-auth=true
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
After this setup modules can be published
11.) For publishing an module is required to follow this steps:
- Run the configuration update to new version with C:\NpmStorage\Test1\node_modules\test1>vsts-npm-auth -config .\.npmrc
- Then > npm publish
In TFS the package should be displayed in the list as private package marked as for “This feed” only:
Sources:
https://www.youtube.com/watch?v=sTVtn9nTquk
https://docs.microsoft.com/en-us/vsts/package/npm/npmrc?view=vsts
https://blogs.msdn.microsoft.com/devops/2017/11/20/package-management-adds-nuget-org-upstream-source/ (note: currently, the nuget.org upstream supports guaranteed saving; the npmjs.com upstream will be enabled for guaranteed saving early in 2018)
https://www.benday.com/2017/05/03/walkthrough-use-a-package-from-a-private-nuget-server-in-tfs2017/
https://docs.microsoft.com/en-us/vsts/package/how-to/set-up-upstream-sources?view=vsts