-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 258987a
Showing
16 changed files
with
2,793 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# editorconfig.org | ||
root = true | ||
|
||
[*] | ||
indent_style = space | ||
indent_size = 2 | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
max_line_length = 100 | ||
quote_type = single | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
extends: | ||
- '@frosti/eslint-config-base' |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# * Files | ||
*.log | ||
npm-debug.log* | ||
node_modules | ||
|
||
# . Files | ||
.DS_Store | ||
*.cache | ||
*.pem | ||
|
||
# ENV Files | ||
.env | ||
.env.development | ||
.env.development.local | ||
.env.local | ||
.env.test.local | ||
.env.test | ||
.env.production | ||
.env.production.local | ||
|
||
# Build Files | ||
.dist | ||
coverage | ||
|
||
|
||
# HOSTING | ||
.firebase | ||
**/.firebaserc |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
*.log | ||
index.js |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
10.15 |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
semi: true | ||
singleQuote: true | ||
trailingComma: none | ||
bracketSpacing: true | ||
arrowParens: always | ||
overrides: | ||
- files: | ||
- '.eslintrc' | ||
- '.prettierrc' | ||
options: | ||
parser: 'yaml' |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Changelog | ||
|
||
## 0.1.0 | ||
|
||
- Initial release |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
MIT LICENSE | ||
|
||
Copyright (c) 2019, Jesse Weed http://jesseweed.com | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
# Asguard | ||
|
||
Automated check to use as a guard against security risks and unused or missing dependencies. | ||
|
||
Can be used standalone, but is highly customized for use by [Frosti Boilerplates](https://github.com/frostijs/cli). | ||
|
||
### Scan For Security Vulnerabilities | ||
|
||
Utilizes [npm audit](https://docs.npmjs.com/cli/audit) to scan project dependencies for any know vulnerabilities. | ||
|
||
### Find Unused or Missing Dependencies | ||
|
||
Uses [depcheck](https://www.npmjs.com/package/depcheck) to look for any missing or unused dependencies in your projects `package.json` file. | ||
|
||
## Usage | ||
|
||
### Install | ||
|
||
###### As a Module | ||
|
||
``` | ||
$ npm install @frosti/asguard | ||
``` | ||
|
||
###### Globally | ||
|
||
``` | ||
$ npm install @frosti/asguard -g | ||
``` | ||
|
||
### Automated scanning | ||
|
||
The recommended usage is as an npm script in conjunction with something like [Husky](https://www.npmjs.com/package/husky) to automatically run before pushing any code into source control: | ||
|
||
``` | ||
{ | ||
"scripts": { | ||
"check": "asguard" | ||
}, | ||
"husky": { | ||
"hooks": { | ||
"pre-push": "npm run check" | ||
} | ||
}, | ||
} | ||
``` | ||
|
||
### Manual scanning | ||
|
||
If you prefer to just run your checks manually, you can also simply run Asguard directly: | ||
|
||
###### Installed globally | ||
|
||
``` | ||
$ asguard | ||
``` | ||
|
||
###### Installed as a module | ||
|
||
``` | ||
$ npx asguard | ||
``` | ||
|
||
## Options | ||
|
||
### Warn Only | ||
|
||
By default Asguard will throw an error and exit with [process.exit(1)](https://nodejs.org/api/process.html#process_event_exit) if it encounters any problems. | ||
|
||
If you would prefer to just show a warning instead of throwing an error, you can use the `--warn` flag. | ||
|
||
``` | ||
$ asguard --warn | ||
``` |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
const argv = require('minimist')(process.argv.slice(2)); | ||
const emoji = require('node-emoji'); | ||
|
||
let warnOnly = false; | ||
let errorColor = 'red'; | ||
let errorEmoji = emoji.get('x'); | ||
|
||
if (argv.v || argv.V || argv.warn) warnOnly = true; | ||
|
||
if (warnOnly) { | ||
errorColor = 'yellow'; | ||
errorEmoji = emoji.get('warning'); | ||
} | ||
|
||
module.exports = { | ||
warnOnly, | ||
errorColor, | ||
errorEmoji, | ||
name: 'Asguard', | ||
script: '@frosti/asguard' | ||
}; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
const emoji = require('node-emoji'); | ||
const figlet = require('figlet'); | ||
const config = require('./_config'); | ||
|
||
const { name, warnOnly } = config; | ||
|
||
const biglog = (msg, color) => { | ||
console.log('\n'); | ||
console.log('----------------------------------------------------------------'[color]); | ||
console.log(`${msg}`[color]); | ||
console.log('----------------------------------------------------------------'[color]); | ||
console.log('\n'); | ||
}; | ||
|
||
const start = () => { | ||
console.log('\n'); | ||
console.log('----------------------------------------------------------------'); | ||
console.log('\n'); | ||
console.log( | ||
figlet.textSync(` ${name}`, { | ||
horizontalLayout: 'full', | ||
font: 'ANSI Shadow' | ||
}).white | ||
); | ||
console.log( | ||
` ${emoji.get('shield')} Guard against security risks and unused dependencies ${emoji.get( | ||
'shield' | ||
)}` | ||
); | ||
console.log('\n'); | ||
console.log('----------------------------------------------------------------'); | ||
console.log('\n'); | ||
}; | ||
|
||
const quit = (code) => { | ||
if (code === 0) { | ||
biglog( | ||
` ${emoji.get('tada')} You're all good! ${name.bold} found no issues! ${emoji.get( | ||
'tada' | ||
)}`, | ||
'green' | ||
); | ||
} else if (warnOnly) { | ||
code = 0; | ||
biglog( | ||
`${emoji.get('cry')} ${name.bold} found some problems, check logs above for more info.`, | ||
'yellow' | ||
); | ||
} else { | ||
code = 0; | ||
console.log('\n'); | ||
console.log( | ||
`${emoji.get('broken_heart')} ${ | ||
name.bold | ||
} found some problems, check logs above for more info.!`.red | ||
); | ||
console.log('\n'); | ||
} | ||
process.exit(code); | ||
}; | ||
|
||
module.exports.biglog = biglog; | ||
module.exports.quit = quit; | ||
module.exports.start = start; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#! /usr/bin/env node | ||
|
||
// CHECKS | ||
const depcheck = require('./depcheck'); | ||
const npm = require('./npm'); | ||
const { quit, start } = require('./_logger'); | ||
|
||
const asguard = () => { | ||
start(); | ||
|
||
// Check for unused depewndencies | ||
depcheck() | ||
// Check for security risks | ||
.then(npm) | ||
.then(() => { | ||
quit(0); | ||
}) | ||
.catch(() => { | ||
quit(1); | ||
}); | ||
}; | ||
|
||
asguard(); |
Oops, something went wrong.