standard-version changeLog generation problem with pathspec - node.js

I've tried to install it locally yarn add -D standard-version package and use it for release versioning and changeLog.md generation, But when I run yarn release which is standard-version, it will generate changeLog and does the version updating, but there are two problems:
error: pathspec 'CHANGELOG.md' did not match any file(s) known to git
λ yarn release
yarn run v1.17.3
$ standard-version
√ bumping version in package.json from 0.6.3 to 0.6.4
√ outputting changes to CHANGELOG.md
√ committing package.json and CHANGELOG.md
error: pathspec 'CHANGELOG.md' did not match any file(s) known to git
Command failed: git commit CHANGELOG.md package.json -m chore(release): 0.6.4
error: pathspec 'CHANGELOG.md' did not match any file(s) known to git
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
repeating previous release commit messages in the new release changelog
What is the problem and how should I fix this?

You should change your file changelog.md to CHANGELOG.md, the issue related to naming convention
I had searched this issue for a while and currently I don't see any solutions so far. My current approach is to replace new content with old content in the file. Hope it helps.

Related

Workflow to checkout single node package for developing a patch / pull request

I want to add a feature to https://github.com/opentripplanner/otp-react-redux/ which is pulled in from the https://github.com/opentripplanner/otp-ui/tree/master/packages/geocoder package (add another geocoder).
Coming from the PHP world and composer, I normally do in such cases
composer install
rm -r vendor/foo/bar
composer install --prefer-source
cd vendor/foo/bar
git remote set-url origin <myforkURL>
git checkout main
Now I can easily edit that package in-place and make a pull request.
My question is: Is there a similar work-flow possible for node packages using yarn?
I already tried
yarn add "#opentripplanner/geocoder#master"
but no .git folder appeared in otp-react-redux/node_modules/#opentripplanner or otp-react-redux/node_modules/#opentripplanner/geocoder
Also it looks like that multiple packages are created from the #opentripplanner repo, which might complicate things.
I could try to simply edit the files in node_modules and then copy them to the a manually checked-out git repository, but when running yarn start everything is also overwritten.
EDIT: As the packages come from a monorepo I tried to delete all the #opentripplanner lines from packages.json and added:
yarn add opentripplanner/otp-ui#main
This now causes the build to fail.
I noticed, that the base package.json requires different package versions from the monorepo, so it will not work to require the complete the full main branch.
EDIT2: I found some clue here:
https://github.com/opentripplanner/otp-ui#development
but that also caused dependencies to not resolve properly.
EDIT3: yarn link actually looked promissing:
cd ..
git clone https://github.com/opentripplanner/otp-ui
cd otp-ui/packages/geocoder
yarn link
Now in the main project code (otp-react-redux)
yarn link "#opentripplanner/geocoder"
This creates a symlink in the node_modules folder to the specific folder in the monorepo I have cloned.
Unfortunately the build does not work:
Module not found: Can't resolve '#opentripplanner/geocoder' in 'otp-react-redux/lib/actions'
I even tried to match the version which is used in the main project by checking out the revision of 1.2.1
yarn link does the job!
cd ..
git clone https://github.com/opentripplanner/otp-ui
cd otp-ui
yarn
cd packages/geocoder
yarn link
Now in the main project code (otp-react-redux)
yarn link "#opentripplanner/geocoder"
This creates a symlink in the node_modules folder to the specific folder in the monorepo I have cloned.
To make the build work, the important part is that we run yarn in the monorepo before!
EDIT: Unfortunately the link process needs to be repeated for each of the #opentripplanner modules which require geocoder:
cd node_modules
$ find -name geocoder -type d
./trip-details/node_modules/#opentripplanner/geocoder
./vehicle-rental-overlay/node_modules/#opentripplanner/geocoder
./transitive-overlay/node_modules/#opentripplanner/geocoder
./endpoints-overlay/node_modules/#opentripplanner/geocoder
./zoom-based-markers/node_modules/#opentripplanner/geocoder
./trip-viewer-overlay/node_modules/#opentripplanner/geocoder
./trip-form/node_modules/#opentripplanner/geocoder
./transit-vehicle-overlay/node_modules/#opentripplanner/geocoder
./itinerary-body/node_modules/#opentripplanner/geocoder
./icons/node_modules/#opentripplanner/geocoder
./route-viewer-overlay/node_modules/#opentripplanner/geocoder
./printable-itinerary/node_modules/#opentripplanner/geocoder
./stop-viewer-overlay/node_modules/#opentripplanner/geocoder
./stops-overlay/node_modules/#opentripplanner/geocoder
./location-field/node_modules/#opentripplanner/geocoder
./park-and-ride-overlay/node_modules/#opentripplanner/geocoder
cd trip-details
yarn link "#opentripplanner/geocoder"
repeat for each of them until they are all links:
otp-react-redux$ find node_modules/ -name geocoder -type l
node_modules/#opentripplanner/trip-details/node_modules/#opentripplanner/geocoder
node_modules/#opentripplanner/vehicle-rental-overlay/node_modules/#opentripplanner/geocoder
node_modules/#opentripplanner/transitive-overlay/node_modules/#opentripplanner/geocoder
node_modules/#opentripplanner/endpoints-overlay/node_modules/#opentripplanner/geocoder
node_modules/#opentripplanner/zoom-based-markers/node_modules/#opentripplanner/geocoder
node_modules/#opentripplanner/trip-viewer-overlay/node_modules/#opentripplanner/geocoder
node_modules/#opentripplanner/trip-form/node_modules/#opentripplanner/geocoder
node_modules/#opentripplanner/transit-vehicle-overlay/node_modules/#opentripplanner/geocoder
node_modules/#opentripplanner/itinerary-body/node_modules/#opentripplanner/geocoder
node_modules/#opentripplanner/icons/node_modules/#opentripplanner/geocoder
node_modules/#opentripplanner/route-viewer-overlay/node_modules/#opentripplanner/geocoder
node_modules/#opentripplanner/printable-itinerary/node_modules/#opentripplanner/geocoder
node_modules/#opentripplanner/stop-viewer-overlay/node_modules/#opentripplanner/geocoder
node_modules/#opentripplanner/stops-overlay/node_modules/#opentripplanner/geocoder
node_modules/#opentripplanner/location-field/node_modules/#opentripplanner/geocoder
node_modules/#opentripplanner/park-and-ride-overlay/node_modules/#opentripplanner/geocoder
node_modules/#opentripplanner/base-map/node_modules/#opentripplanner/geocoder
node_modules/#opentripplanner/geocoder
yalc seems a good solution for this kind of problem
cd ~/projects/otp-ui/packages/itinerary-body
yarn tsc
yalc publish
cd ~/projects/otp-react-redux
yalc link #opentripplanner/itinerary-body
Now each time you change something in the package:
cd ~/projects/otp-ui/packages/itinerary-body
yarn tsc && yalc publish
cd ~/projects/otp-react-redux
yalc update
yarn start

error Your lockfile needs to be updated, but yarn was run with `--frozen-lockfile`

I have an issue regarding one dependency in my yarn.lock file. The issue is with ldapjs, the latest version has a bug regarding special characters in user or password so I want to freeze it in the latest working version which is 1.0.2.
As I commited my code to master branch, the step of building this project started to fail saying the message of the title.
Here is my dockerfile
FROM repository/node-oracle:10.15.3
LABEL maintainer="Me"
RUN yarn cache clean
# Add Tini
ENV TINI_VERSION v0.18.0
ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /tini
RUN chmod +x /tini
ENTRYPOINT ["/tini", "--"]
WORKDIR /usr/src/auth
COPY . .
RUN yarn install --frozen-lockfile --non-interactive --silent
ENV PATH /usr/src/auth/node_modules/.bin:$PATH
EXPOSE 3000
CMD ["node", "./bin/www"]
Any work around on how can I make this work?
Also as an extra info, I was able to run the pipeline with this step in a feature branch, the message started in develop and master branch.
[UPDATE]
These are the dependencies updated and freezed in my yarn.lock file
activedirectory#^0.7.2:
version "0.7.2"
resolved "https://registry.yarnpkg.com/activedirectory/-/activedirectory-0.7.2.tgz#19286d10c6b24a98cc906dc638256191686fa91f"
integrity sha1-GShtEMaySpjMkG3GOCVhkWhvqR8=
dependencies:
async ">= 0.1.22"
bunyan ">= 1.3.5"
**ldapjs "=1.0.2"**
underscore ">= 1.4.3"
***ldapjs#1.0.2***:
version "1.0.2"
resolved "https://registry.yarnpkg.com/ldapjs/-/ldapjs-1.0.2.tgz#346e040a95a936e90c47edd6ede5df257dd21ee6"
integrity sha512-XzF2BEGeM/nenYDAJvkDMYovZ07fIGalrYD+suprSqUWPCWpoa+a4vWl5g8o/En85m6NHWBpirDFNClWLAd77w==
dependencies:
asn1 "0.2.1"
assert-plus "0.1.5"
bunyan "0.22.1"
nopt "2.1.1"
pooling "0.4.6"
optionalDependencies:
dtrace-provider "0.2.8"
I was stuck in the same error and the issue was that my yarn.lock file was not up to date. I followed the following link and it fixed my issue.
Apparently, I just had to run yarn install to update my yarn.lock file and push to the repository.
Just an Update. After a few attempts I was finally able to do what i wanted. Removing the ^ from ldap.js and from active directory (which contains the ldap.js library) did the job as expected.
Sometimes the error occurs if the yarn install is run from a folder which contains no yarn.lock file. For example if building inside a docker which contains separate frontend and backend.
Solution 1
In that case go to the specific frontend folder which contains the package.json and yarn.lock folder and run the yarn install from there.
Solution 2
run yarn add <package> which will generate a file yarn.lock in the project base folder if the command is run from the base folder. Copy the contents of that file to the existing yarn.lock. This should solve the problem. Here is a link for yarn add package.

Can't make git stop tracking package-lock.json

With npm v5 here is now package-lock.json file being created after npm install
It is recommended to commit this file, but I have issue that this file is different for some reason between my dev machine and my server. Even if I push that file to repo, after npm install on server, file changes.
So now I'm attempting to make git untrack this file. After following numerous answers from other questions, I seem to have almost managed to do so, it's not tracked on dev machine, doesn't appear in the repo itself, but after I pull code to server and make npm install, it appears in modified files.
File is in .gitignore, but server git for some reason ignores it.
git check-ignore -v -n package-lock.json
:: package-lock.json
git check-ignore -v -n --no-index package-lock.json
.gitignore:10:package-lock.json package-lock.json
Possibly relevant info:
Dev machine: Windows 10.
Server: Ubuntu 14.04.
I'm pulling code to server using tags.
You need to remove it from your repo (git rm package-lock.json) in order for git to stop tracking it.
.gitignore only works for untracked files. If you have a tracked file that is also in your .gitignore, the fact that the file is tracked overrides the fact that it is also in .gitignore.

Use of git tags in package.json (for git dependencies)

Is it possible some how to get update behaviour for git dependencies a like for NPM packages?
So I have git dependency:
"dependencies": {
"my-module": "github:me/my-module"
}
And want it be updated each time I do npm install, adding revision hash is solution but requires more work to track and update in package.json each time package is update on Github.
There are also git tags (which also can be set using npm version command - it creates commit with tag v1.2.3. Is there is way to use these tags in dependencies in package.json?
git tag on repo gives me:
v1.0.1
v1.0.0
If I try to add in package.json after module name version like: #1.0.0 or #v1.0.1
```
"dependencies": {
"my-module": "github:me/my-module#1.0.1"
}
```
Install fails with error:
Command failed: git -c core.longpaths=true rev-list -n1 1.0.0
fatal: ambiguous argument '1.0.0': unknown revision or path not in the
ree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
If you need help, you may report this error at:
<https://github.com/npm/npm/issues>
This can be done like this
"my-module": "git+https://github.com/user/repo.git#v1.2.3"
If you are looking for semver support for git dependencies, I am afraid you are out of luck.
When installing git dependencies, npm allows you to specify one of the following to control what particular commit you whish to install as a dependency:
commit (full sha1 string of the commit)
commit (short commit string)
branch
tag
The format is defined as follows:
package.json:
{
"dependencies": {
"some-dep": "username/reponame#commit-ish"
}
}
Where commit-ish is one of the items listed above.
Attempting to use one of the semver modifiers when specifying commit-ish will fail, ie. #~1.2.3 is not a valid commit-ish. See the docs for yourself.
I tried using git+ssh but didn't work. Finally this worked for me for repo in bitbucket
"my-module": "git+https://bitbucket.org/repos/myrepo/#0.1.0"

Travis CI: file from node module not found

I just configured Travis CI to also run my test cases. This is my .travis.yml file:
language: node_js
node_js:
- "0.10"
before_install: npm install -g grunt-cli
install: npm install
When it tries to run my test cases, it gives me the following error:
Error loading resource file:///home/travis/build/repo/test/node_modules/mocha/mocha.css (203).
Details: Error opening /home/travis/build/repo/test/node_modules/mocha/mocha.css: No such file or directory
Error loading resource file:///home/travis/build/repo/test/node_modules/mocha/mocha.js (203).
Details: Error opening /home/travis/build/repo/test/node_modules/mocha/mocha.js: No such file or directory
TypeError: 'undefined' is not a function (evaluating 'mocha.setup('bdd')')
So it can not find the mocha.css and mocha.js file in the node_modules folder.
I'm guessing it can not find these files because they are not uploaded to Git. This is because I specified node_modules in my .gitignore file, because I do not want to upload all the modules.
What is the common way/a clean way to fix this problem?
The simplest way to get out of this situation is
$ git add --force node_modules/mocha.css node_modules/mocha.js
$ git commit -m "Add the missing files"
$ git push
The "--force" option allows you to add files which are being ignored via .gitignore

Resources