Skip to content

Commit

Permalink
feat: removed unit test questionaire and added "pre-push" command (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
patelvimal authored Jan 8, 2022
1 parent 621a7f9 commit ad23ba4
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 31 deletions.
39 changes: 28 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@

# @ng-vim/devtools

1. Auto format your staged files before commiting using prettier configuration
2. Run your unit test cases before pushing your code to server.
3. Make sure your commit messages are per commitlint standard.

Above funtionality can be integrated in your angular workspace using single schematic command.
This schematics will integrate git hooks using husky in your angular workspace.
<p align="center">
<img width="30%" height="30%" src="./logo.png">
</p>

<br/>
# @ng-vim/devtools
A schematic to integrate husky, prettier and commit-lint in your angular application

<p align="center">
<p align="left">
<a href="https://www.npmjs.com/package/@ng-vim/devtools">
<img src="https://img.shields.io/npm/v/@ng-vim/devtools/latest.svg" alt="NPM Version" />
</a>
Expand All @@ -19,13 +15,34 @@ This schematics will integrate git hooks using husky in your angular workspace.
</a>
</p>


## 🌟 Install

```sh
$ ng add @ng-vim/devtools
```

that's it.

Running above schematics in your angular application will integrate below functionality.
1. Auto format your staged files before commiting using prettier configuration
1. Make sure your commit messages are per commitlint standard.

<br/>


After this whenever you will try to perform any git actions like `git commit` and `git push`, husky command will be executed for the respective commands.

## Troubleshoot
If you are using Linux/Max operating system you need to give execution permission to `.husky` and `.git/hooks` folder.
```sh
chmod ug+x .husky/*
chmod ug+x .git/hooks/*
```


## Husky Documentation
https://typicode.github.io/husky



## License
Expand Down
Binary file added logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ng-vim/devtools",
"version": "1.0.5",
"version": "1.1.0",
"description": "A schematics to integrate husky with prettier and commitlint in your angular workspace",
"license": "MIT",
"schematics": "./collection.json",
Expand Down
2 changes: 1 addition & 1 deletion src/ng-add/files/.husky/pre-push.template
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

<% if(includeAngularCommands) %> npm run test-ci
npm run pre-push
14 changes: 5 additions & 9 deletions src/ng-add/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ export default function (options: Options): Rule {
addPackageJsonDependencies(),
installDependencies(),
addTemplateFiles(options),
updatePackageCommands(options)
updatePackageCommands()
])(tree, _context);
};
}

function updatePackageCommands(options: Options): Rule {
function updatePackageCommands(): Rule {
return (tree: Tree, _context: SchematicContext) => {
const packagePath: string = './package.json';
const buffer = tree.read(packagePath);
Expand All @@ -32,15 +32,11 @@ function updatePackageCommands(options: Options): Rule {

const pkg: any = JSON.parse(buffer.toString());

pkg.scripts['format'] = 'pretty-quick --staged';
pkg.scripts['pre-commit'] = 'npm run format';
pkg.scripts['prettier'] = 'pretty-quick --staged';
pkg.scripts['pre-commit'] = 'npm run prettier';
pkg.scripts['pre-push'] = '';
pkg.scripts['prepare'] = 'husky install';

if (options.includeAngularCommands) {
pkg.scripts['test-ci'] =
'ng test -- --no-watch --no-progress --browsers=ChromeHeadless';
}

tree.overwrite(packagePath, JSON.stringify(pkg, null, 2));
};
}
1 change: 0 additions & 1 deletion src/ng-add/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,4 @@ export interface Workspace {

export interface Options {
integrateCommitlint: boolean;
includeAngularCommands: boolean;
}
6 changes: 0 additions & 6 deletions src/ng-add/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,6 @@
"title": "Ngx Builder ng-add schematic",
"type": "object",
"properties": {
"includeAngularCommands": {
"description": "commitlint integration",
"type": "boolean",
"default": false,
"x-prompt": "Would you like to integrate angular unit test command ?"
},
"skipConfirmation": {
"description": "Skip asking a confirmation prompt before installing and executing the package. Ensure package name is correct prior to using this option.",
"type": "boolean",
Expand Down

0 comments on commit ad23ba4

Please sign in to comment.