Created
July 27, 2018 03:58
-
-
Save unlocomqx/f759b6ce5a25e0d5538508bc2ed70da2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* Angular lib automated publish to git remote */ | |
| // add the following scripts to the package.json inside lib folder projects/new-lib | |
| /* | |
| "scripts": { | |
| "publish": "npm version patch && npm run build && npm run release", | |
| "build": "ng build --prod new-lib", | |
| "release": "node publish.js" | |
| }, | |
| */ | |
| // remove dist from .gitignore | |
| // copy the following script to projects/new-lib/publish.js | |
| // add this script to the package.json file in the root | |
| /* | |
| "publish": "cd projects/new-lib && npm run publish" | |
| */ | |
| // npm install -D simple-git | |
| // npm run publish | |
| const path = require('path'); | |
| const dist_dir = '../../dist/new-lib'; | |
| const root_dir = '../../'; | |
| const simpleGit = require('simple-git')(root_dir); | |
| // simpleGit.add(`${dist_dir}/*`); // add only dist/new-lib/* | |
| simpleGit.add('.'); // add all files | |
| const package = require(path.join(dist_dir, 'package.json')); | |
| const version = package.version; | |
| simpleGit.commit(`version ${version}`); | |
| simpleGit.addTag(`v${version}`); | |
| console.log(`Pushing version ${version} to remote`); | |
| simpleGit.push(); | |
| simpleGit.pushTags(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment