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

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.

Related

Gitlab CI /CD: Cannot override private project npm package registry URL for dependencies

I was wondering if someone could help me with my CI/CD configuration for a multi-JS project setup.
Project js-core has some core JS libaries, and project vue-core has some reusable vue components. They are both published as npm packages to the "js-core" project's repository (so that we can use a deploy token with npm publish, as opposed to using a group deploy token, where you have to script the package creation and push directly to the API).
vue-core has a dependency of js-core, so it needs to access the npm package registry of the js-core project to download it inside of the Docker CI/CD instance.
However, gitlab does not allow me to override the package registry's URL. According to some google research, setting the values with yarn config set #myorg:registry <gitlab-url> / yarn config set //gitlab.com/api/v4/... <deploy token> or npm config set #myorg:registry <gitlab-url> / npm config set //gitlab.com/api/v4/... <deploy token> should work. However I can see that it is still trying to download the packages from the vue-core package registry, even though it is disabled as a feature there.
This is the part of my .gitlab-ci.yml that runs before it fails:
image: node:17-alpine
stages:
- build
- test
before_script:
- yarn config set #myorg:registry https://gitlab.com/api/v4/projects/${NPM_PACKAGES_PROJECT_ID}/packages/npm/
- yarn config set //gitlab.com/api/v4/projects/${NPM_PACKAGES_PROJECT_ID}/packages/npm/:_authToken ${NPM_PACKAGES_PROJECT_TOKEN}
- yarn install
It fails at yarn install with:
[2/4] Fetching packages...
error An unexpected error occurred: "https://gitlab.com/api/v4/projects/<vue-core_project_id>/packages/npm/#myorg/js-core/-/#myorg/js-core-1.0.0.tgz: Request failed \"404 Not Found\"".
Where the project ID should be the value of <js-core_project_id>.
I have tried writing to all possible .npmrc file paths (~/.npmrc, ./.npmrc, ${CI_BUILD_DIR}/.npmrc, setting the values with npm config set and yarn config set, deactivating the packages feature in the gitlab project itself. I have also not found any predefined environment variables that would override my configs (see https://docs.gitlab.com/ee/ci/variables/predefined_variables.html). #myorg is correct and matches the gitlab url, as the actual value for "myorg" is a single word...
I am pretty much out of ideas at this point, any help is appreciated!
Update 1: I don't think it is a npm / yarn issue, maybe a gitlab caching problem? If I execute npm config ls -l and yarn config list the correct URLs are output in a format that works locally. I will attempt to clear the yarn cache (globally and locally) and pray that that works.

git submodule to npm dependency

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

NPM: Only install missing - how to speed up npm install

I have a lot of devdepencencies in my npm script. npm install takes a few minutes the first time, that's ok.
But since I'm integrating with TFS build server, it only needs to npm install once. After that, npm install is just wasting time because it takes 2-3 minutes to just determin the packages are already installed. Also, it seems to always reinstall the packages with -g global flag, even when existing.
How can I make it check if packages exist, and if so, skip npm install?
You can use npm-cache as an alternative way if you use on-premise build agents for build.
It is useful for build processes that run [npm|bower|composer|jspm]
install every time as part of their build process. Since dependencies
don't change often, this often means slower build times. npm-cache
helps alleviate this problem by caching previously installed
dependencies on the build machine. npm-cache can be a drop-in
replacement for any build script that runs [npm|bower|composer|jspm]
install.
How it Works
When you run npm-cache install [npm|bower|jspm|composer], it first
looks for package.json, bower.json, or composer.json in the current
working directory depending on which dependency manager is requested.
It then calculates the MD5 hash of the configuration file and looks
for a filed named .tar.gz in the cache directory ($HOME/.package_cache
by default). If the file does not exist, npm-cache uses the system's
installed dependency manager to install the dependencies. Once the
dependencies are installed, npm-cache tars the newly downloaded
dependencies and stores them in the cache directory. The next time
npm-cache runs and sees the same config file, it will find the tarball
in the cache directory and untar the dependencies in the current
working directory.
And you can also try with npm-install-missing.
However, if you are using VSTS Hosted Build Agent, then you cannot do this since every time you queue a build with Hosted Build Agent, a clean build agent is assigned for the build. That means there is no dependency package installed on the agent. You need to perform a complete npm install.

Is there a way that VSO vNext builds can clean up long directory paths (>260 characters)

I've setup a .Net TFS Build vNext build to run the following:
npm install
gulp
visual studio solution build
The build is confgured to clean automatically before checking for sources like so:
I have two problems with this build but this question is about problem #2.
The npm install step fails to install phantomjs because the command node install.js can't find node, even though node is in the System path.
Running builds configured to Clean fails because of the path too long error below.
[error]The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.
I would like for the Clean setting to just work and clean up these longs paths, but I don't know how to make it work properly.
When I tried to re-create this same build in TeamCity the Clean option works just fine. Also, I know that if I had access to the script that is running the clean that it could just use a *rmdir /S /Q to remove these paths. Hopefully the VSO build can just run this or something that works.
[EDIT] - I have confirmed that this is fixed in the latest Build agent version (1.85.1)
I've been told by MS folks that this is currently a bug in the vNext builds and will be fixed in the next release of the product. I'll update this answer once I see this fix released.
From an admin console, run: npm install npm -g
Run npm version or npm -v to make sure it worked. Also note if you have node installed, you want to browse to the node directory and update it from there.
Also note vso agents sometimes store a local version. Browse to agent/tasks/npm.

Cocoapods error: "Pull is not possible because you have unmerged files."

When installing a new CocoaPod, I got the following error.
$ pod install
Analyzing dependencies
[!] Pod::Executable pull
A AFHARchiver/0.2.1/AFHARchiver.podspec
A AFWunderlist/1.0/AFWunderlist.podspec
A AFWunderlist/1.1/AFWunderlist.podspec
A AFgzipRequestSerializer/0.0.1/AFgzipRequestSerializer.podspec
.
.
.
A wpxmlrpc/0.4/wpxmlrpc.podspec
A zipzap/6.0/zipzap.podspec
Pull is not possible because you have unmerged files.
Please, fix them up in the work tree, and then use `'git add/rm <file>'`
as appropriate to mark resolution, or use `'git commit -a'`.
Thought I would share the fix below.
Problem was with specs repository, not on my side.
Found the answer here podfile gives an error on install, but since the question was less explicit on the symptom, I thought I would cross-reference it again in case someone was looking it up differently.
The answer is in the blog post here http://blog.cocoapods.org/Repairing-Our-Broken-Specs-Repository/ which explains the issue and the fix which is repeated below:
"You are going to have to manually delete any local copies of the Specs repository and re-clone the new version of the Specs repository. You can do that with the following commands:
$ pod repo remove master
$ pod setup
If you have any local commits or changes to the Specs repository which are not merged, you should ensure you have a copy of them. I would recommend that you manually copy these changes over and re-commit them. You can fix your repository without deleting, however, this is not a simple process, so we are instead recommending that you delete your copy of the Specs repository and any forks of it."
rm -rf ~/.cocoapods also works

Resources