diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..4a7ea30 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,12 @@ +root = true + +[*] +indent_style = space +indent_size = 2 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +[*.md] +trim_trailing_whitespace = false diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..215000b --- /dev/null +++ b/.gitignore @@ -0,0 +1,28 @@ +# Logs +logs +*.log + +# Runtime data +pids +*.pid +*.seed + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage + +# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (http://nodejs.org/api/addons.html) +build/Release + +# Dependency directory +# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git +node_modules +lib diff --git a/.npmignore b/.npmignore new file mode 100644 index 0000000..e12d9f6 --- /dev/null +++ b/.npmignore @@ -0,0 +1,3 @@ +node_modules +.* +LICENSE diff --git a/.nvmrc b/.nvmrc new file mode 100644 index 0000000..9c0be88 --- /dev/null +++ b/.nvmrc @@ -0,0 +1 @@ +v6 diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..df08691 --- /dev/null +++ b/LICENSE @@ -0,0 +1,22 @@ +The MIT License (MIT) + +Copyright (c) 2016 Leonardo Gatica + +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. + diff --git a/README.md b/README.md new file mode 100644 index 0000000..aeb3d20 --- /dev/null +++ b/README.md @@ -0,0 +1,42 @@ +# m2m-status-cli + +[![npm version](https://img.shields.io/npm/v/m2m-status-cli.svg?style=flat-square)](https://www.npmjs.com/package/m2m-status-cli) +[![npm downloads](https://img.shields.io/npm/dm/m2m-status-cli.svg?style=flat-square)](https://www.npmjs.com/package/m2m-status-cli) +[![dependency Status](https://img.shields.io/david/lgaticaq/m2m-status-cli.svg?style=flat-square)](https://david-dm.org/lgaticaq/m2m-status-cli#info=dependencies) +[![devDependency Status](https://img.shields.io/david/dev/lgaticaq/m2m-status-cli.svg?style=flat-square)](https://david-dm.org/lgaticaq/m2m-status-cli#info=devDependencies) + +> CLI to check status of your m2m-status sims + +## Installation + +```bash +npm i -g m2m-status-cli +``` + +## Use + +```bash +m2m-status + +Usage: m2m-status -u -p -s + +CLI to check status of your m2m-status sims + +Options: + + -h, --help output usage information + -V, --version output the version number + -u, --user [user] Add user + -p, --password [password] Add password + -s, --sim [sim] Add sim +``` + +## Example + +```bash +m2m-status -u your-user -p your-password -s +569XXXXXXXX +``` + +## License + +[MIT](https://tldrlegal.com/license/mit-license) diff --git a/package.json b/package.json new file mode 100644 index 0000000..09fe98c --- /dev/null +++ b/package.json @@ -0,0 +1,72 @@ +{ + "name": "m2m-status-cli", + "version": "0.0.0", + "description": "CLI to check status of your m2m-status sims", + "main": "src", + "scripts": { + "prepublish": "eslint src", + "release:major": "changelog -M && git add CHANGELOG.md && git commit -m 'updated CHANGELOG.md' && npm version major && git push origin && git push origin --tags && npm publish", + "release:minor": "changelog -m && git add CHANGELOG.md && git commit -m 'updated CHANGELOG.md' && npm version minor && git push origin && git push origin --tags && npm publish", + "release:patch": "changelog -p && git add CHANGELOG.md && git commit -m 'updated CHANGELOG.md' && npm version patch && git push origin && git push origin --tags && npm publish" + }, + "engines": { + "node": ">=4" + }, + "bin": { + "m2m-status": "src/index.js" + }, + "preferGlobal": true, + "repository": { + "type": "git", + "url": "https://github.com/lgaticaq/m2m-status-cli.git" + }, + "keywords": [ + "m2m", + "sim", + "cli" + ], + "author": "Leonardo Gatica (https://about.me/lgatica)", + "license": "MIT", + "bugs": { + "url": "https://github.com/lgaticaq/m2m-status-cli/issues" + }, + "homepage": "https://github.com/lgaticaq/m2m-status-cli#readme", + "dependencies": { + "chalk": "^1.1.3", + "commander": "^2.9.0", + "m2m-status": "0.0.2", + "update-notifier": "^1.0.2" + }, + "devDependencies": { + "eslint": "^3.4.0", + "generate-changelog": "^1.0.2" + }, + "eslintConfig": { + "env": { + "es6": true, + "node": true + }, + "extends": "eslint:recommended", + "rules": { + "indent": [ + 2, + 2 + ], + "linebreak-style": [ + 2, + "unix" + ], + "quotes": [ + 2, + "single" + ], + "semi": [ + 2, + "always" + ], + "no-console": [ + 0 + ] + } + } +} diff --git a/src/index.js b/src/index.js new file mode 100644 index 0000000..477dc6b --- /dev/null +++ b/src/index.js @@ -0,0 +1,31 @@ +#!/usr/bin/env node + +'use strict'; + +const program = require('commander'); +const m2m = require('m2m-status'); +const pkg = require('../package.json'); +const updateNotifier = require('update-notifier'); +const chalk = require('chalk'); + +updateNotifier({pkg}).notify(); + +program + .version(pkg.version) + .usage('-u -p -s ') + .description('CLI to check status of your m2m-status sims') + .option('-u, --user [user]', 'Add user') + .option('-p, --password [password]', 'Add password') + .option('-s, --sim [sim]', 'Add sim') + .parse(process.argv); + +if (program.user && program.password && program.sim) { + const client = new m2m({user: program.user, password: program.password}); + client.checkSim(program.sim).then(result => { + console.log(chalk.green(`Administration: ${result.admin ? 'OK' : 'Error'}`)); + console.log(chalk.green(`GSM: ${result.gsm ? 'OK' : 'Error'}`)); + console.log(chalk.green(`GPRS: ${result.gprs ? 'OK' : 'Error'}`)); + }).catch(err => console.log(chalk.red(err.message))); +} else { + program.help(); +}