Bower install with Artifactory - github

I’m trying to set up an operation where the only internet access to external repos is via artifactory server. I have followed the bower information on this web page http://www.jfrog.com/confluence/display/RTF/Bower+Repositories
I can successfully do the npm installs of bower-art-resolver as described (utilizing npm remote repository for npmjs in artifactory), but then trying to do the example bower install of bootstrap it fails because bower is attempting to find git://github.com/twbs/bootstrap.git and I don't have an access to github.com due to firewalls.
How do I make the full bower workflow work then if having the bower registry remote repository is not suffient to make the setup work? Is there some way that the artifactory VCS functions come into play? How would I make bower utilize that instead of trying to reach github.com?
This firewall scenario seems like a common use case for a repository server, so I'm sure I'm missing something.

Make sure you are doing the following:
(1) Create a remote repository in Artifactory proxying the Bower registry. Notice that Artifactory will need to access both the Bower registry and Github.
(2) Configure Bower to use the Artifactory repository you created in the previous step as the Bower registry. This should be done in the .bowerrc file, for example:
{
"registry": "http://localhost:8081/artifactory/api/bower/bower-repo"
}
(3) Use bower-art instead of bower when installing packages, for example:
bower-art install bootstrap

Related

Why does Artifactory not list/cache NuGet Packages from remote NuGet Gallery repo?

I'm looking to migrate from an existing private NuGet Gallery repo. We have Artifactory (v6.10.1 , will be upgrading soon) with a nuget virtual, nuget-local, and nuget-remote-cache repo.
I have configured the Artifactory remote repo to point to the NuGet Gallery server and as you can see from the screenshot below, it passes the connection test. However, when I try to nuget list from the remote repo, I get no packages returned. If I try the same call directly against the NuGet Gallery, I get lots of packages returned. My account has the "anything" permission in artifactory (Effective permissions shows all 4 checks) and no authentication is required to retrieve from either NuGet Gallery or the artifactory repo but I've set up my un/pw and apikey all the same. If I try to browse Packages, NuGet isn't even available. In Artifacts, the only thing that shows up is the package.json from the local repo. What is going on here?
The problem turned out to be that I had enabled "Global Offline mode" so Artifactory was refusing to even attempt to access the Remote repository. This was evident by the complete lack of log entries in the request.log. Disabling the setting allowed the list to list packages.
I still did not see any packages in the cache but after running nuget install <package>, it appeared in the cache. Apparently the caching only occurs on a pull of a package and does not function as a full replica of the remote repo.
Remote repositories in Artifactory serves as a caching proxy that the URL of the repository points to. To have the control over the storage of your hardware, the artifacts are being cached by demand of the users therefore it’s not being synced with the remote URL.
With this said, if the remote repository is pointing to other Artifactory repository you can set the pull replication feature of Artifactory to retrieve the artifacts from the remote Artifactory server and populate the remote repository cache and in this way to synchronize the repositories.

Installing public npm packages from the GitHub package registry

1.I publish a public package in an organization repo.
The repo link : https://github.com/JX3BOX/jx3box-config/packages/141887
2.And I wanna install the package from another repo.
I had set the dependencies in the package.json
"dependencies": {
"#jx3box/jx3box-config": "^1.0.3",
and I created a file named .npmrc ,and set :
#jx3box:registry=https://npm.pkg.github.com
3.When I use github actions to build
There is an error occur
Running build scripts... npm install && npm run build
npm ERR! code E401
npm ERR! Unable to authenticate, need: Basic realm="GitHub Package Registry"
It means maybe I need auth.But This is an public package.Is it should be auth too?
4.Now I had to prepend a line in the file .npmrc,just like
//npm.pkg.github.com/:_authToken=<mytoken>
But how can I set it in the actions .
or because this is a public pkg,how can I don't need any auth?
Thanks a lot!! ^_^
This is probably solved but posting anyway because this question ranks high on Google.
From the GitHub Docs:
You need an access token to publish, install, and delete packages. You can use a personal access token to authenticate with your username directly to GitHub Packages or the GitHub API.[...]
You cannot install packages (even public ones) from the GitHub npm registry without being authenticated.
More details and multiple authentication methods here:
https://docs.github.com/en/packages/guides/configuring-npm-for-use-with-github-packages#authenticating-to-github-packages
The docs should be updated.
You need an access token to publish, install, and delete packages.
This should really be changed to;
You need an access token to publish, install, and delete both private and public packages.

Configure npm to resolve dependencies using JFrog Artifactory as proxy for both npm registry and GitHub

I have a build server with no internet access, and I need to resolve dependencies from both github.com and registry.npmjs.org. The build server has access to Artifactory(jfrog), so I have created an npm repo to proxy for registry.npmjs.org and that is working, and I just created dependency-rewrite mechanism under virtual repo for remote npm repo as mentioned in this link--Configure npm to resolve dependencies using artifactory as proxy for both npm registry and github
after configuring still I face the same issue:
node-sass#4.11.0 install /app/jenkins/workspace/uiwidget_smarthome1.0_dev/bwtk/node_modules/node-sass
node scripts/install.js
Downloading binary from https://github.com/sass/node-sass/releases/download/v4.11.0/linux-x64-47_binding.node
Cannot download "https://github.com/sass/node-sass/releases/download/v4.11.0/linux-x64-47_binding.node":
How can I configure npm to resolve from both of these? Since the 2 repos are different types, I can't aggregate them into a single virtual repo. Can npm be configured to resolve dependencies from both of these?
Yes, you need to pass the virtual repo url to the npm command. You can use ---registry virtual repo url or you can set the registry to using npm command

Capistrano: Deploy Laravel app on ubuntu server

I have an ubuntu staging server where I have installed apache, php, mysql, git, composer installed. I have a private git repository setup on the bitbucket, the project is already cloned to the staging server and to my local development machine. The Laravel setup is working perfectly fine on both machine.
What I am currently doing is whenever there is an update to the git repository, I do login to the staging server, pull the latest code from the git repository and do composer install, npm install, bower install.
I want to automate this process via capistrano tool. I checked the tutorials online, but all of them do the clone of repository whenever, I issue a deploy command and creates a fresh installation every time. Can't capistrano helps me to work on the existing folder that is already setup?
The basic premise of Capistrano is the idea that a new installation is created each time, such that there is not much to be done initially in terms of setup. If you'd rather use a different mechanism, a different tool would work better for you! For such cases, you could try to write a script using SSHKit directly (fairly advanced), or write a makefile or some other tool to automate your process.
If you do want to try to make Capistrano work on its terms, look into how linked_dirs and linked_files work in it. They allow you to have some files (e.g. config files, log dirs, etc) which are outside of the deployment directory and as such are shared between deploys.

Configure npm to resolve dependencies using artifactory as proxy for both npm registry and github

I have a build server with no internet access, and I need to resolve dependencies from both github.com and registry.npmjs.org. The build server has access to Artifactory, so I have created an NPM repo to proxy for registry.npmjs.org and that is working, and I just created a VCS repo to proxy for github.com.
How can I configure npm to resolve from both of these? Since the 2 repos are different types, I can't aggregate them into a single virtual repo. Can NPM be configured to resolve dependencies from both of these?
VCS repos have zero correlation to NPM dependencies. A VCS repo is just a gateway to a set of APIs on the remote git server that will help you cache source binaries (i.e a zip/tarball of a particular branch/tag or even a release). The npm client is not familiar with the REST endpoints that Artifactory exposes for such repos.
For NPM packages that reference github repos inside their package.json (see URLs as dependencies & Git URLs as Dependencies sections here), you want to look into Artifactory's dependency-rewrite mechanism.
Since your NPM client is running on a machine that has no access to the internet, your own package.json files should not depend directly on "github dependencies", since these make the client bypass the registry configuration inside your ~/.npmrc and go directly to github instead of Artifactory.
When the package.json of one of your project's dependencies uses github dependencies, and this package is resolved via Artifactory, the dependency rewrite mechanism modifies the package.json on the fly before returning it to the client, so that subsequent dependency requests to resolve such dependencies are attempted via Artifactory, and not via github -- this is perfect for use cases such as yours.
In summary, you should stick with NPM repositories on Artifactory specifically, but also utilize the dependency rewrite mechanism of the Virtual Repository in order to avoid direct resolution of dependencies via github.
HTH,