So, I have a library haste-mapper (link to Github - I would like some opinions on it). It uses gulp, babel-core and a few other npm packages to build itself so as to have valid JavaScript instead of Flow into the build/ directory. I added that as a postinstall hook script in package.json:
"postinstall": "gulp build"
It works, the script starts running but it does not meet the required dependencies in the host package. I have gulp and babel-core as devDependencies and it seems not to install them. Adding them to dependencies seems semantically wrong. I tried adding them to peerDependencies, but instead of installing what's missing, it just complains about it.
How should I go about this?
P.S. Here is the package.json
If you want to use something in a postinstall hook, it needs to be a dependency.
However, you're doing it wrong. You shouldn't be transpiling your code after the install. Instead, you should transpile your code before you publish the package.
To do that, you will need to rename your script to prepublish so that it is run when you run npm publish. List gulp, babel, etc. as devDependencies. Add an .npmignore file in the root of your project, containing:
/src/
The .npmignore file works just like a .gitignore. You don't want your src/ directory included in the published package, only build/. Make sure .npmignore is committed to git. If you don't have an .npmignore, npm will use the .gitignore file. This isn't what you want, since build/ is ignored for version control, but should be included in the npm package.
When you run npm publish, npm will run your prepublish hook before bundling your package for the registry. Then when someone npm installs your package, they will get the build/ folder, but not src/. Just what you want!
I started to leave a comment on RyanZim's answer because his technique is correct. However, I wanted to give a slightly different approach. Our company maintains a lot of open source projects and this is how we would advise you.
Keep developing your project like you normally would. Your .gitignore file should be ignoring your dist directory (/build in your case).
When you are ready to deploy, you want to build your code, bump your version number inside package.json, tag the changes, and push the built code to both github and npm.
The main idea is that we want to keep a copy of our built code in github along with a "tag" for that version. This allows us to see exactly what was pushed to npm for any particular version. The built code is not part of the master branch but exists only under a tag (which is sort of like a branch). When a user reports a bug and he's using version x.x.x, you can checkout that exact version and start debugging. When you fix the bug, you release a new "patch" and your user will get the changes the next time he runs npm install or npm update.
We have created a set of npm scripts to do most of this for us. Here is what we use (this goes in your package.json):
"scripts": {
"build": "node build.js",
"preversion": "npm run build",
"version": "git commit -am \"Update dist for release\" && git checkout -b release && git add -f dist/",
"postversion": "git push --tags && git checkout master && git branch -D release && git push",
"release:pre": "npm version prerelease && npm publish",
"release:patch": "npm version patch && npm publish",
"release:minor": "npm version minor && npm publish",
"release:major": "npm version major && npm publish"
}
I know that may look confusing so let me explain. Whenever we are ready to release new code, we run one of the release: commands. For example, when we run npm run release:minor, here is the list of commands which are run in order. I have annotated it so you can see what happens:
node build.js ## run the build code - you will want to run gulp instead
npm version minor ## bumps the version number in package.json and creates a new git tag
git commit -am "Update dist for release" ## commit the package.json change to git (with new version number) - we will push it at the end
git checkout -b release ## create a temporary "release" branch
git add -f dist/ ## force add our dist/ directory - you will want to add your build/ directory instead
npm publish ## push the code to npm
git push --tags ## push the built code and tags to github
git checkout master ## go back to the master branch
git branch -D release ## delete the temporary "release" branch
git push ## push the updated package.json to github
If you have any questions, please ask. You might want to do things in a slightly different order as your situation is a little different. Please feel free to ask questions. This code works really well on dozens of projects - we release new code multiple times a day.
Related
When I run npm install, remove or add any package (or do anything that changes the local package.json) and commit to a PR branch, I get the following error in the github actions "run npm ci" build.
npm ERR! `npm ci` can only install packages when your package.json and package-lock.json or npm-shrinkwrap.json are in sync. Please update your lock file with `npm install` before continuing.
npm ERR!
npm ERR! Missing: webpack#5.74.0 from lock file
npm ERR! Missing: #types/eslint-scope#3.7.4 from lock file
Things i've tried:
Deleting node modules & package-lock.json & running npm i - DOESNT WORK
Changing my github main.yml to npm ci --legacy-peer-deps - DOES FIX THIS BUG but causes other weird bugs about paths to other React components withing my project to not be found with a Type error: Cannot find module '../ etc" (they all work fine if the old package-lock is used)
Pasting the old package-lock.json to overwrite my local copy and committing - WORKS? But I can never actually remove or add packages.
Running npm ci locally works perfectly fine.
In summary:
If I create a new branch from main > npm install a new package & push the updated package.json and package-lock.json to the branch > it fails the github actions check on npm ci with the above npm ERR because the package-lock.json does not match.
I'm stumped, any help would be greatly appreciated.
I have googled and searched and cannot find an answer to this. I have my page at github and it just returns a hyperlink with the readme. Here is the current repo: https://github.com/brianmsantos/brianmsantos.github.io.
Create an index.html and add your content there. See https://pages.github.com/
1 create package.json and add
{
"homepage": "https://name.github.io/appname",
…
}
2.Use the terminal and install gh pages using command:
npm install --save gh-pages
3.Add this to your scripts in package.json
"scripts": {
"predeploy": "npm run build",
"deploy": "gh-pages -d build",
…
}
make deploy using npm run deploy in commandline
5 in your repository settings set the branch to gh-pages branch and save
I've been trying for a while to get a Jekyll website running on Github Pages, but it doesn't seem to work. I've been getting the error
Your site is having problems building: The symbolic link
/vendor/bundle/ruby/2.3.0/gems/ffi-1.9.18/ext/ffi_c/libffi-x86_64-linux-gnu/include/ffitarget.h
targets a file which does not exist within your site's repository. For
more information, see
https://help.github.com/articles/page-build-failed-symlink-does-not-exist-within-your-site-s-repository/.
I have already tried it with 9 different Jekyll themes, but none of them seem to work, so I'm clearly doing something wrong. Here are the steps that I am taking
1) Create a new repo and put the files from a Jekyll Theme there, OR fork it from another repo (e.g. https://github.com/iwiedenm/jekyll-theme-massively-src)
2) Git pull it into my computer and make sure I'm on the gh-pages branch
3) Run bundle install --path vendor/bundle
4) Make sure it was built with bundle exec jekyll serve
5) Once it looks good, upload it into Github
git add *
git commit -m 'Test'
git push
Then I go to the repo in the browser and I see the error above, and I can't see the website because of that missing "ffitarget.h" file. When I go look for it in that directory, I am able to find it, but Github doesn't seem to be able to find it.
Nick Shu
PS: Feel free to mark this as a duplicate. I have seen other pages, such as this and I tried it, but it didn't work.
Github page will use local gems in vendor. If you commit them, you will have errors each time github pages tries to resolve symbolic links.
From a fresh repository
Add vendor/** in your .gitignore file before you do a git add . *.
The dot in git add . * forces git to stage dotfiles (.gitignore, ...).
From an already existing repository containing gems in a vendor folder
Add vendor/** in your .gitignore file,
Remove vendor/ files from versioning, git rm --cached -r vendor/
You can now stage, commit and push
git add . *
git commit -m 'remove vendor from versioning'
git push origin master`
Notes :
you can publish master branch content, as gh-pages branch is no more mandatory. See documentation.
unless you have special needs like debuging, it's not necessary to download gems for each of your project. You can just do a bundle install.
Ensure the vendor/bundle/ directory has been excluded..
By default, Jekyll excludes that directory and therefore, it would not care about the contents in your vendor directory..
When you fork/clone a repo, there's a possibility that the exclude: list has been customized (therefore overriding the default setting). You can ensure vendor/bundle/ is ignored by Jekyll by adding it to your custom exclude list:
# Exclude list
exclude:
- README.md
- Gemfile
- Gemfile.lock
- node_modules
- gulpfile.js
- package.json
- _site
- src
- vendor
- CNAME
- LICENSE
- Rakefile
- old
- vendor/bundle/
To locally emulate how the site is built on GitHub Pages, you can build using the --safe switch:
bundle exec jekyll serve --safe
I successfully compile alsa-lib when I run ./configure and subsequently make from the sources extracted from the original .tar.gz
Since I versioned with mercurial and then try to hg clone the full source tree, the ./configure and make doesn't work anymore.
I compared the .tar.gz extracted sources with the hg cloned sources using kdiff3 and they're exactly the same (except for the .hg folder).
What I notice is that running make from the extracted .tar.gz it simply compiles; running the same from the hg cloned sources instead, before compiling, calls
alsa-lib-1.0.24.1/missing --run aclocal-1.11 -I m4
....
then there's again a list of configuration commands before starting the compilation that fails.
deleting all the content of the file named "missing" I can have a successful compilation also from the hg cloned sources but this solution seems to me ugly, does anybody know what's happening here?
https://www.mercurial-scm.org/guide please visit this link.....right now i successfully install mercurial but next step not i am clear.....
Initialize the project
Now you add a new folder in which you want to work:
$ hg init project
Add files and track them
$ cd project
$ (add files)
$ hg add
$ hg commit
(enter the commit message)
add file means i dont know...can u explain please
now i am using ubuntu....
mercurial installation step1:
embdes#embdes-laptop:~$ sudo apt-get install mercurial
[sudo] password for embdes:
Reading package lists... Done
Building dependency tree
Reading state information... Done
mercurial is already the newest version.
The following packages were automatically installed and are no longer required:
libopenal1 wavpack kdelibs4c2a libdc1394-22 mppenc vorbis-tools libxvidcore4
libldns1 libsvga1 kdelibs-data mplayer kdemultimedia-kio-plugins liblualib50
libkcddb4 mp3gain vorbisgain speex libmp3lame0 faad libavahi-qt3-1 icedax
freepats ffmpeg libao2 liblzo2-2 libavfilter0 flac libev3 timidity libqt3-mt
liblua50 timidity-daemon libunbound2 libavdevice52
Use 'apt-get autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 261 not upgraded.
embdes#embdes-laptop:~$
step:2
embdes#embdes-laptop:~$ hg init project
abort: repository project already exists!
embdes#embdes-laptop:~$ cd project
embdes#embdes-laptop:~/project$ hg add
embdes#embdes-laptop:~/project$ hg commit
nothing changed
embdes#embdes-laptop:~/project$ hg init
abort: repository . already exists!
embdes#embdes-laptop:~/project$
This is the output from my commandline. Please correct me if I have done anything wrong.
The android project I develop will reside in the following directory,
/home/embdes/workspace
The following is the android sdk directory
/home/embdes/project/android/android-sdk/platform-tools/
how to install mercurial?
how to use android engine example project in my eclipse?
I am new in using commandline, so please help me in clearing above two doubts.
Thanks
You need to create files that are going to be version controlled. It is that simple.
You will find a full step-by-step tutorial at hginit
For instance, after an hg add, you need an hg commit:
There’s still one more step… you have to commit your changes. What changes? The change of adding all those files.
Why do you have to commit?
With Mercurial, committing says “hey, the way the files look right now—please remember that.” It’s like making a copy of the whole directory… every time you have something that you’ve changed that you sorta like, you commit.
When you issue the init command you are telling mercurial to track changes within the directory for a list of files... with the add command you tell mercurial which are these files.
By issuing the add command without any parameters you're telling mercurial to revision-control ALL the files within the "project" directory (recursively).
At any given time you can "forget" a file... and it will still be within "project" (directly or not) but mercurial won't care about any changes to the file.
You have to first get a basic understanding of what mercurial is for. Mercurial is a version control system which can store the changes you make your files. In your commandline output it is obvious that you have no files inside the,
/home/embdes/project
directory. That means you have made no change. Then what will mercurial store?? So only it says nothing has changed. You just create new files or directories there. Then do hg add. You will see the difference :)