git submodule to npm dependency - ruby-on-rails

I working on Rails application of version 4.1.5. Rails application consists git submodules in it. I would like to change git submodules to npm package dependencies and include them to asset pipeline in a proper way. Could someone please suggest me gem or procedure to do it.

Convert a git submodule to an npm package remains a manual process.
You can see an example of such a procedure in xolvio/rtd issue 61: Convert RTD to an NPM module instead of a git submodule.
It was resolved in PR 163, and involved (that will differ depending on your own application):
Updating paths in gruntfile for npm support
keeping lib/bin around
Consolidate package deps and add bin to package.json

Related

npm ci in Jenkins parallel pipeline

I've got a monorepo with roughly the following structure (npm modules):
myProject
|-base
|-ui1
|-ui2
In the base module I have all the stuff combined which my ui1 and ui2 projects use commonly. I use npm local paths to add the base module as a dependency to the ui-projects.
...
"dependencies": {
...
"base": "file:../base"
...
}
...
So far so good...
In my CI environment (Jenkins) I use npm ci to install the dependencies. Since these steps are executed parallelly, the node_modules folder of base will be deleted by the npm ci call of ui1 while ui2 is trying to install the dependencies as well. This causes random errors of course...
Now my actual question: Is there a way to tell npm ci not to delete the node_modules of path dependencies? Of course any other hint to solve this kind of problem is appreciated as well... ;)
Thanks a lot for your help!

update yarn .lock and push to remote to affect docker instance

In the project, I have cloned from my organization's GitLab, there is a module in the package.json as:
"react-native-device-info": "https://github.com/KarlosQ/react-native-device-info#master",
and respectively in the yarn.lock we have
"react-native-device-info#https://github.com/KarlosQ/react-native-device-info#master":
version "0.21.5"
resolved "https://github.com/KarlosQ/react-native-device-info#beebff8dc284decfba917f2c6d30d0e535cc4002"
For any reason that commit beebff8dc... does not exist at the master branch of the module.
Because of that, all builds in the GitLab pipeline fails.
error Couldn't find match for "beebff8dc..." in ....
How can I change it locally and push to the remote branch that affects the pipeline and build passes?
Clearing the Yarn cache locally did not help. deleting that module from yarn.lock causes other issues that my organization account is not recognized anymore and yarn install fails!
Run:
yarn uninstall react-native-device-info && yarn add react-native-device-info#0.21.5
The first one will remove the dependency from your node_modules, package.json and yarn.lock.
The second one will recover the version you are depending on, namely 0.21.5 as stated in your old yarn.lock.
You should not concern yourself with any specific commit, but should yarn handle the internals.
The missing commit was most likely deleted from the master branch of the external repository and hence will never be resolved properly.

rebar dependency without repository

I have rebar project with dependencies, so after clean when I run rebar compile, it downloads dependencies (for git runs git clone, looks like), runs configure for them and then compiles everything. Can I somehow make those dependencies local? I mean to skip downloading them and directly run configure there?
Try to use
rsync option and specify the file path
{rsync, "file:///foo/bar/baz"}
is the shape of it as long as I remember

Bower: Install package that doesn't have bower.json file

I'm trying to get Bower to install this javascript:
https://github.com/markmalek/Fixed-Header-Table
I use: bower install git#github.com:markmalek/Fixed-Header-Table.git --save
It installs the package into bower-components, and even adds it to my project's bower.json, but it doesn't add the to my html. I'm guessing it's because that particular git repo doesn't contain a bower.json telling my project which js file is the main one. So how do I install this package?
Thanks!
This answer takes your assumption that your HTML is picking up scripts loaded via Bower using the bower.json file as correct.
There are two options. The quickest is to fork the repo yourself, and in the main directory use the command bower init to create your own bower.json file in your forked version of the repo. Then, change the github url to the repo to your forked version rather than the original you have above.
The second option is to submit a pull request to the package owner adding a bower.json file so that you can continue to pull directly from his repo.
There are probably more options like manually loading the script outside of pulling from a bower.json file but the two above seem simplest.

Solutions for installing libraries without a prebuilt file in bower

Some libraries don't have an already build JavaScript file in their Github repository because the authors of these libraries are against keeping build artifacts around (Sinon.JS for example). Is there a preferred way to deal with this using Bower?
I know that I could fork the repository and register my fork with the prebuilt file with Bower. I'm just not sure if this is the best/correct way to handle this.
If there's not a proper Bower package registeres, you can install from any git repo (you can specify versions if there are proper git tags), and even from a .zip or .tar.gz files if you provide an url.
This is from http://bower.io/
bower install <package>
Where <package> can be any one of the following:
A name that maps to a package registered with Bower, e.g, jquery.
A remote Git endpoint, e.g., git://github.com/someone/some-package.git. Can be public or private.
A local Git endpoint, i.e., a folder that's a Git repository.
A shorthand endpoint, e.g., someone/some-package (defaults to GitHub).
A URL to a file, including zip and tar.gz files. It's contents will be extracted.
Of course you won't get any dependency resolution this way, but you can take care of that manually adding any dependency explicitly to your bower.json file
Currently that is the best way. You can also keep it locally and reference it in 'dependencies' with full path. We're working on adding ability for author to publish components, like npm.

Resources