├── test ├── sample_project │ ├── foo │ │ ├── all-unused.js │ │ ├── index.js │ │ └── package.json │ ├── c │ │ ├── index.js │ │ └── d │ │ │ ├── index.js │ │ │ └── f │ │ │ └── index.js │ ├── a │ │ └── index.js │ ├── b │ │ ├── e │ │ │ └── index.js │ │ └── index.js │ ├── index.js │ └── package.json ├── sample_project_no_package_json │ ├── foo │ │ ├── all-unused.js │ │ ├── index.js │ │ └── package.json │ ├── sample_project │ │ ├── foo │ │ │ ├── all-unused.js │ │ │ ├── index.js │ │ │ └── package.json │ │ ├── a │ │ │ └── index.js │ │ ├── c │ │ │ ├── d │ │ │ │ ├── index.js │ │ │ │ └── f │ │ │ │ │ └── index.js │ │ │ └── index.js │ │ ├── b │ │ │ ├── index.js │ │ │ └── e │ │ │ │ └── index.js │ │ ├── index.js │ │ └── package.json │ ├── a │ │ └── index.js │ ├── c │ │ ├── d │ │ │ ├── index.js │ │ │ └── f │ │ │ │ └── index.js │ │ └── index.js │ ├── b │ │ ├── index.js │ │ └── e │ │ │ └── index.js │ └── index.js └── szero.test.js ├── .gitignore ├── .travis.yml ├── licenses ├── licenses.css ├── NODE-BUILTINS_APACHE-2.0.TXT ├── licenses.html └── ROI_APACHE-2.0.TXT ├── LICENSE.txt ├── package.json ├── bin ├── szero └── cli.js ├── CHANGELOG.md ├── CONTRIBUTING.md └── README.md /test/sample_project/foo/all-unused.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | console.log(1 + 1); 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | *.log 3 | .vscode 4 | coverage 5 | szero.txt 6 | docs/ 7 | .nyc_output -------------------------------------------------------------------------------- /test/sample_project_no_package_json/foo/all-unused.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | console.log(1 + 1); 4 | -------------------------------------------------------------------------------- /test/sample_project/foo/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const roi = require('roi'); 4 | 5 | console.log(roi); 6 | -------------------------------------------------------------------------------- /test/sample_project_no_package_json/sample_project/foo/all-unused.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | console.log(1 + 1); 4 | -------------------------------------------------------------------------------- /test/sample_project/c/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const indexOnRootDirectoryRequiredFromC = require('../index.js'); 4 | -------------------------------------------------------------------------------- /test/sample_project/a/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const b = require('../b/index.js'); 4 | const foo = require('roi'); 5 | -------------------------------------------------------------------------------- /test/sample_project/c/d/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const indexOnRootDirectoryRequiredFromD = require('../../index'); 4 | -------------------------------------------------------------------------------- /test/sample_project/b/e/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | 4 | const indexOnRootDirectoryRequiredFromE = require('../../index.js'); 5 | -------------------------------------------------------------------------------- /test/sample_project/b/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const indexOnRootDirectoryRequiredFromB = require('../index'); 4 | 5 | 6 | -------------------------------------------------------------------------------- /test/sample_project_no_package_json/foo/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const roi = require('roi'); 4 | 5 | console.log(roi); 6 | -------------------------------------------------------------------------------- /test/sample_project/index.js: -------------------------------------------------------------------------------- 1 | const roi = require('roi'); 2 | const fs = require('fs'); 3 | 4 | roi.doCoolTHing(); 5 | console.log(fs); 6 | -------------------------------------------------------------------------------- /test/sample_project_no_package_json/a/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const b = require('../b/index.js'); 4 | const foo = require('roi'); 5 | -------------------------------------------------------------------------------- /test/sample_project_no_package_json/c/d/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const indexOnRootDirectoryRequiredFromD = require('../../index'); 4 | -------------------------------------------------------------------------------- /test/sample_project_no_package_json/c/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const indexOnRootDirectoryRequiredFromC = require('../index.js'); 4 | -------------------------------------------------------------------------------- /test/sample_project_no_package_json/b/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const indexOnRootDirectoryRequiredFromB = require('../index'); 4 | 5 | 6 | -------------------------------------------------------------------------------- /test/sample_project_no_package_json/sample_project/foo/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const roi = require('roi'); 4 | 5 | console.log(roi); 6 | -------------------------------------------------------------------------------- /test/sample_project_no_package_json/b/e/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | 4 | const indexOnRootDirectoryRequiredFromE = require('../../index.js'); 5 | -------------------------------------------------------------------------------- /test/sample_project_no_package_json/index.js: -------------------------------------------------------------------------------- 1 | const roi = require('roi'); 2 | const fs = require('fs'); 3 | 4 | roi.doCoolTHing(); 5 | console.log(fs); 6 | -------------------------------------------------------------------------------- /test/sample_project_no_package_json/sample_project/a/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const b = require('../b/index.js'); 4 | const foo = require('roi'); 5 | -------------------------------------------------------------------------------- /test/sample_project_no_package_json/sample_project/c/d/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const indexOnRootDirectoryRequiredFromD = require('../../index'); 4 | -------------------------------------------------------------------------------- /test/sample_project_no_package_json/sample_project/c/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const indexOnRootDirectoryRequiredFromC = require('../index.js'); 4 | -------------------------------------------------------------------------------- /test/sample_project_no_package_json/sample_project/b/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const indexOnRootDirectoryRequiredFromB = require('../index'); 4 | 5 | 6 | -------------------------------------------------------------------------------- /test/sample_project_no_package_json/sample_project/b/e/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | 4 | const indexOnRootDirectoryRequiredFromE = require('../../index.js'); 5 | -------------------------------------------------------------------------------- /test/sample_project_no_package_json/sample_project/index.js: -------------------------------------------------------------------------------- 1 | const roi = require('roi'); 2 | const fs = require('fs'); 3 | 4 | roi.doCoolTHing(); 5 | console.log(fs); 6 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - "8" 4 | - "9" 5 | script: 6 | - npm test 7 | branches: 8 | only: 9 | - master 10 | notifications: 11 | irc: "chat.freenode.net#bucharest-gold" -------------------------------------------------------------------------------- /test/sample_project/c/d/f/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const opossum = require('opossum'); 4 | console.log(opossum); 5 | 6 | // require('tape'); 7 | 8 | /* 9 | 10 | require('roi'); 11 | 12 | */ 13 | -------------------------------------------------------------------------------- /test/sample_project_no_package_json/c/d/f/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const opossum = require('opossum'); 4 | console.log(opossum); 5 | 6 | // require('tape'); 7 | 8 | /* 9 | 10 | require('roi'); 11 | 12 | */ 13 | -------------------------------------------------------------------------------- /test/sample_project_no_package_json/sample_project/c/d/f/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const opossum = require('opossum'); 4 | console.log(opossum); 5 | 6 | // require('tape'); 7 | 8 | /* 9 | 10 | require('roi'); 11 | 12 | */ 13 | -------------------------------------------------------------------------------- /test/szero.test.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const cli = require('../bin/cli'); 4 | 5 | test('checks if the project has unused dependencies.', () => { 6 | expect.assertions(1); 7 | const options = { directory: process.cwd() }; 8 | expect(1).toBe(1); 9 | console.log(cli); 10 | }); 11 | -------------------------------------------------------------------------------- /licenses/licenses.css: -------------------------------------------------------------------------------- 1 | table { 2 | border-collapse: collapse; 3 | } 4 | 5 | table, th, td { 6 | border: 1px solid navy; 7 | } 8 | 9 | th { 10 | text-align: left; 11 | background-color: #BCC6CC; 12 | 13 | } 14 | 15 | th, td { 16 | padding: 2px; 17 | text-align: left; 18 | } 19 | 20 | tr:nth-child(even) { 21 | background-color: #f2f2f2; 22 | } -------------------------------------------------------------------------------- /test/sample_project/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "test_project", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "keywords": [], 10 | "author": "", 11 | "license": "ISC", 12 | "devDependencies": { 13 | "eslint": "~3.8.1" 14 | }, 15 | "dependencies": { 16 | "roi": "*", 17 | "swapi-node": "^0.4.0" 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /test/sample_project_no_package_json/sample_project/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "test_project", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "keywords": [], 10 | "author": "", 11 | "license": "ISC", 12 | "devDependencies": { 13 | "eslint": "~3.8.1" 14 | }, 15 | "dependencies": { 16 | "roi": "*", 17 | "swapi-node": "^0.4.0" 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright 2016 Red Hat, Inc. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. -------------------------------------------------------------------------------- /licenses/NODE-BUILTINS_APACHE-2.0.TXT: -------------------------------------------------------------------------------- 1 | 2 | Copyright 2016 Red Hat, Inc. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | -------------------------------------------------------------------------------- /test/sample_project/foo/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "foo", 3 | "version": "1.2.3", 4 | "description": "Foo-ing.", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "n/a" 8 | }, 9 | "dependencies": { 10 | "roi": "^0.2.'" 11 | }, 12 | "license": "Apache-2.0", 13 | "devDependencies": { 14 | "eslint": "^3.5.0", 15 | "eslint-config-semistandard": "^7.0.0", 16 | "eslint-config-standard": "^6.0.0", 17 | "eslint-plugin-promise": "^2.0.1", 18 | "eslint-plugin-react": "^6.2.0", 19 | "eslint-plugin-standard": "^2.0.0", 20 | "istanbul": "^0.4.5", 21 | "nsp": "^2.6.1", 22 | "tap-spec": "^4.1.1", 23 | "tape": "^4.6.0", 24 | "test-console": "^1.0.0" 25 | }, 26 | "repository": { 27 | "type": "git", 28 | "url": "bucharest-gold/szero" 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /test/sample_project_no_package_json/foo/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "foo", 3 | "version": "1.2.3", 4 | "description": "Foo-ing.", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "n/a" 8 | }, 9 | "dependencies": { 10 | "roi": "^0.2.'" 11 | }, 12 | "license": "Apache-2.0", 13 | "devDependencies": { 14 | "eslint": "^3.5.0", 15 | "eslint-config-semistandard": "^7.0.0", 16 | "eslint-config-standard": "^6.0.0", 17 | "eslint-plugin-promise": "^2.0.1", 18 | "eslint-plugin-react": "^6.2.0", 19 | "eslint-plugin-standard": "^2.0.0", 20 | "istanbul": "^0.4.5", 21 | "nsp": "^2.6.1", 22 | "tap-spec": "^4.1.1", 23 | "tape": "^4.6.0", 24 | "test-console": "^1.0.0" 25 | }, 26 | "repository": { 27 | "type": "git", 28 | "url": "bucharest-gold/szero" 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /test/sample_project_no_package_json/sample_project/foo/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "foo", 3 | "version": "1.2.3", 4 | "description": "Foo-ing.", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "n/a" 8 | }, 9 | "dependencies": { 10 | "roi": "^0.2.'" 11 | }, 12 | "license": "Apache-2.0", 13 | "devDependencies": { 14 | "eslint": "^3.5.0", 15 | "eslint-config-semistandard": "^7.0.0", 16 | "eslint-config-standard": "^6.0.0", 17 | "eslint-plugin-promise": "^2.0.1", 18 | "eslint-plugin-react": "^6.2.0", 19 | "eslint-plugin-standard": "^2.0.0", 20 | "istanbul": "^0.4.5", 21 | "nsp": "^2.6.1", 22 | "tap-spec": "^4.1.1", 23 | "tape": "^4.6.0", 24 | "test-console": "^1.0.0" 25 | }, 26 | "repository": { 27 | "type": "git", 28 | "url": "bucharest-gold/szero" 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /licenses/licenses.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

szero

8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 |
Package GroupPackage ArtifactPackage VersionRemote LicensesLocal Licenses
N/Anode-builtins0.1.1http://www.apache.org/licenses/LICENSE-2.0NODE-BUILTINS_APACHE-2.0.TXT
N/Aroi0.15.0http://www.apache.org/licenses/LICENSE-2.0ROI_APACHE-2.0.TXT
31 | 32 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "szero", 3 | "version": "1.0.1", 4 | "description": "Sub Zero dependency search.", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "jest", 8 | "jest-w": "jest --watch", 9 | "prepare": "nsp check" 10 | }, 11 | "files": [ 12 | "bin", 13 | "LICENSE.txt", 14 | "package.json", 15 | "README.md" 16 | ], 17 | "author": "Helio Frota", 18 | "repository": { 19 | "type": "git", 20 | "url": "bucharest-gold/szero" 21 | }, 22 | "dependencies": { 23 | "detective": "^5.1.0", 24 | "license-reporter": "^1.1.0", 25 | "listjs": "^0.1.1", 26 | "node-builtins": "^0.1.1", 27 | "node-project-validator": "^0.1.3", 28 | "yargs": "^12.0.1" 29 | }, 30 | "license": "Apache-2.0", 31 | "devDependencies": { 32 | "jest": "^23.4.1", 33 | "nsp": "^3.2.1" 34 | }, 35 | "preferGlobal": true, 36 | "bin": { 37 | "szero": "./bin/szero" 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /bin/szero: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 'use strict'; 3 | 4 | const cli = require('./cli'); 5 | const yargs = require('yargs'); 6 | const { resolve } = require('path'); 7 | 8 | process.title = 'szero'; 9 | 10 | yargs 11 | .usage('Usage: $0 /path/to/project [options]') 12 | .option('ignore', { 13 | alias: 'i', 14 | describe: 'ignores the specified directories separated by space. e.g: bower_components examples test', 15 | type: 'array', 16 | default: [] 17 | }) 18 | .option('ci', { 19 | describe: 'enables process.exit() when unused dependency found.', 20 | default: false 21 | }) 22 | .option('dev', { 23 | describe: 'enables devDependencies processing.', 24 | default: false 25 | }) 26 | .option('license', { 27 | alias: 'l', 28 | describe: 'Displays license information for each dependency.', 29 | default: false 30 | }); 31 | 32 | const argv = yargs.argv; 33 | 34 | const options = { 35 | ignore: argv.ignore, 36 | directory: argv._[0], 37 | silent: argv.silent, 38 | dev: argv.dev, 39 | ci: argv.ci, 40 | license: argv.license 41 | }; 42 | 43 | if (!options.directory || options.directory === '.') { 44 | options.directory = process.cwd(); 45 | } 46 | 47 | options.directory = resolve(options.directory); 48 | 49 | cli.run(options); 50 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. 4 | 5 | 6 | # [0.8.0](https://github.com/bucharest-gold/szero/compare/v0.7.1...v0.8.0) (2016-12-28) 7 | 8 | 9 | ### Features 10 | 11 | * require count console report. ([9bffddc](https://github.com/bucharest-gold/szero/commit/9bffddc)) 12 | * silent mode ([a6f1d16](https://github.com/bucharest-gold/szero/commit/a6f1d16)) 13 | 14 | 15 | 16 | 17 | ## [0.7.1](https://github.com/bucharest-gold/szero/compare/v0.7.0...v0.7.1) (2016-11-17) 18 | 19 | 20 | ### Bug Fixes 21 | 22 | * Unused Dependecies was actually an Array of Dep objects if there were unused dependencies. Fixes issue #61 ([987e782](https://github.com/bucharest-gold/szero/commit/987e782)), closes [#61](https://github.com/bucharest-gold/szero/issues/61) 23 | 24 | 25 | 26 | 27 | # [0.7.0](https://github.com/bucharest-gold/szero/compare/v0.6.0...v0.7.0) (2016-11-09) 28 | 29 | 30 | ### Bug Fixes 31 | 32 | * Fix duplication of dep declaration. ([51d6ebc](https://github.com/bucharest-gold/szero/commit/51d6ebc)) 33 | * License as [object object] ([5b214b5](https://github.com/bucharest-gold/szero/commit/5b214b5)) 34 | * License Reporter no longer runs twice when doing the console reporter. For #57 ([df1f0e9](https://github.com/bucharest-gold/szero/commit/df1f0e9)) 35 | * The license search. ([49b9cd8](https://github.com/bucharest-gold/szero/commit/49b9cd8)) 36 | 37 | 38 | ### Features 39 | 40 | * add license report to the fileReporter ([1843555](https://github.com/bucharest-gold/szero/commit/1843555)) 41 | * license info added to the public API. must opt-in ([381e7f0](https://github.com/bucharest-gold/szero/commit/381e7f0)) 42 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to szero 2 | 3 | ## Issue contributions 4 | 5 | ### Did you find a bug ? 6 | 7 | Open a [new issue](https://github.com/bucharest-gold/szero/issues/new) 8 | and be sure to include a title and clear description, as much relevant information 9 | as possible, and a code sample or a test case demonstrating the expected behavior 10 | that is not occurring. 11 | 12 | Discussions can be done via github issues or IRC channel #bucharest-gold. 13 | 14 | ## Code contributions 15 | 16 | ### Fork 17 | 18 | Fork the project [on GitHub](https://github.com/bucharest-gold/szero) 19 | and check out your copy locally. 20 | 21 | ``` 22 | git clone git@github.com:username/szero.git 23 | cd szero 24 | git remote add upstream https://github.com/bucharest-gold/szero.git 25 | ``` 26 | 27 | ### Branch 28 | 29 | Create a feature branch and start hacking: 30 | 31 | ``` 32 | git checkout -b my-contrib-branch 33 | ``` 34 | 35 | ### Commit messages 36 | 37 | Writing good commit logs is important. A commit log should describe what 38 | changed and why. Follow these guidelines when writing one: 39 | 40 | 1. The first line should be 50 characters or less and contain a short 41 | description of the change. 42 | 2. Keep the second line blank. 43 | 3. Wrap all other lines at 72 columns. 44 | 45 | Example of commit message: 46 | 47 | ``` 48 | fix a bug with download url. 49 | 50 | The download url was not using https. 51 | Body of commit message is a few lines of text, explaining things 52 | in more detail, possibly giving some background about the issue 53 | being fixed, etc. etc. 54 | 55 | The body of the commit message can be several paragraphs, and 56 | please do proper word-wrap and keep columns shorter than about 57 | 72 characters or so. That way `git log` will show things 58 | nicely even when it is indented. 59 | ``` 60 | 61 | ### Rebase to keep updated. 62 | 63 | Use `git rebase` to sync your work from time to time. 64 | 65 | ``` 66 | git fetch upstream 67 | git rebase upstream/master 68 | ``` 69 | 70 | ### Development cycle 71 | 72 | Bug fixes and features should come with tests. 73 | The tests are on `test` directory. 74 | 75 | ``` 76 | npm run lint 77 | npm test 78 | ``` 79 | 80 | ### Push 81 | 82 | ``` 83 | git push origin my-contrib-branch 84 | ``` 85 | 86 | Go to https://github.com/yourusername/szero and select your feature branch. 87 | Click the 'Pull Request' button and fill out the form. 88 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # szero 2 | 3 | [![Coverage Status](https://coveralls.io/repos/github/bucharest-gold/szero/badge.svg)](https://coveralls.io/github/bucharest-gold/szero) 4 | [![Build Status](https://travis-ci.org/bucharest-gold/szero.svg?branch=master)](https://travis-ci.org/bucharest-gold/szero) 5 | [![Known Vulnerabilities](https://snyk.io/test/npm/szero/badge.svg)](https://snyk.io/test/npm/szero) 6 | [![dependencies Status](https://david-dm.org/bucharest-gold/szero/status.svg)](https://david-dm.org/bucharest-gold/szero) 7 | 8 | [![NPM](https://nodei.co/npm/szero.png)](https://npmjs.org/package/szero) 9 | 10 | Sub Zero dependency search. 11 | 12 | ## Installation 13 | 14 | ``` 15 | npm install szero -g 16 | ``` 17 | 18 | ## Usage 19 | 20 | ``` 21 | $ szero . --help 22 | Usage: szero /path/to/project [options] 23 | 24 | Options: 25 | --version Show version number [boolean] 26 | --ignore, -i ignores the specified directories separated by space. e.g: 27 | bower_components examples test [array] [default: []] 28 | --ci enables process.exit() when unused dependency found. 29 | [default: false] 30 | --dev enables devDependencies processing. [default: false] 31 | --license, -l Displays license information for each dependency. 32 | [default: false] 33 | --help Show help [boolean] 34 | ``` 35 | 36 | ``` 37 | ------------------------------------------------------------ 38 | [ Unused dependencies ] 39 | ------------------------------------------------------------ 40 | commander 41 | ------------------------------------------------------------ 42 | [ Unused devDependencies ] 43 | ------------------------------------------------------------ 44 | eslint 45 | eslint-config-semistandard 46 | eslint-config-standard 47 | eslint-plugin-import 48 | eslint-plugin-node 49 | eslint-plugin-promise 50 | eslint-plugin-react 51 | eslint-plugin-standard 52 | license-reporter 53 | nsp 54 | nyc 55 | standard-version 56 | tap-spec 57 | ``` 58 | 59 | > NOTE: Not always devDependences are used via require(), so a larger number of unused devDependencies is expected in the output result. 60 | 61 | When using the option `--license` or `-l` szero will display information about license for each dependency. 62 | 63 | > Thanks to [license-reporter](https://github.com/bucharest-gold/license-reporter) for the license information for each dependency. 64 | 65 | ## Contributing 66 | 67 | Please read the [contributing guide](./CONTRIBUTING.md) 68 | -------------------------------------------------------------------------------- /bin/cli.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const fs = require('fs'); 4 | const listJS = require('listjs'); 5 | const detective = require('detective'); 6 | const coreModules = require('node-builtins'); 7 | const validator = require('node-project-validator'); 8 | const licenseReporter = require('license-reporter'); 9 | 10 | const run = (options) => { 11 | const dir = options.directory; 12 | 13 | // validates the project. 14 | validator.hasPackageJson(dir, true); 15 | validator.hasAnyDependencies(dir, true); 16 | validator.hasNodeModules(dir, true); 17 | 18 | // ignores test directory by default. 19 | if (!options.dev) { 20 | options.ignore.push('test'); 21 | } 22 | 23 | // all the require() found. 24 | const requireSet = new Set(); 25 | 26 | // lists JS files. 27 | listJS(dir, options.ignore) 28 | .then((files) => { 29 | // searches the require() for each file. 30 | files.forEach((f) => { 31 | const src = fs.readFileSync(f); 32 | const requires = detective(src); 33 | // saves the requires found in a Set to avoid duplicated results. 34 | requires.forEach((r) => { 35 | requireSet.add(r); 36 | }); 37 | }); 38 | 39 | // removes core modules from the Set. 40 | const withoutCoreModules = Array.from(requireSet).filter(e => !coreModules.includes(e)); 41 | 42 | // compare with declared dependencies and display unused. 43 | const deps = Object.keys(require(`${dir}/package.json`).dependencies); 44 | const unusedDependencies = deps.filter(e => !withoutCoreModules.includes(e)); 45 | console.log('-'.repeat(60)); 46 | console.log('[ Unused dependencies ]'); 47 | console.log('-'.repeat(60)); 48 | if (unusedDependencies.length > 0) { 49 | unusedDependencies.forEach((e) => { 50 | console.log(e); 51 | }); 52 | if (options.ci) { 53 | process.exit(1); 54 | } 55 | } else { 56 | console.log('None.'); 57 | } 58 | 59 | if (options.dev) { 60 | // compare with declared devDependencies and display unused. 61 | const devDeps = Object.keys(require(`${dir}/package.json`).devDependencies); 62 | const unusedDevDependencies = devDeps.filter(e => !withoutCoreModules.includes(e)); 63 | console.log('-'.repeat(60)); 64 | console.log('[ Unused devDependencies ]'); 65 | console.log('-'.repeat(60)); 66 | if (unusedDevDependencies.length > 0) { 67 | unusedDevDependencies.forEach((e) => { 68 | console.log(e); 69 | }); 70 | if (options.ci) { 71 | process.exit(1); 72 | } 73 | } else { 74 | logRed('None.'); 75 | } 76 | } 77 | 78 | if (options.license) { 79 | console.log('-'.repeat(60)); 80 | console.log('[ Licenses ]'); 81 | console.log('-'.repeat(60)); 82 | licenseReporter.licenses(dir, false, true); 83 | } 84 | }) 85 | .catch((e) => { 86 | console.error(e); 87 | }); 88 | }; 89 | 90 | module.exports = { 91 | run 92 | }; 93 | -------------------------------------------------------------------------------- /licenses/ROI_APACHE-2.0.TXT: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | --------------------------------------------------------------------------------