├── .editorconfig ├── .gitattributes ├── .gitignore ├── .travis.yml ├── cli.js ├── license ├── package.json ├── readme.md └── test.js /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_style = tab 5 | end_of_line = lf 6 | charset = utf-8 7 | trim_trailing_whitespace = true 8 | insert_final_newline = true 9 | 10 | [*.{json,yml}] 11 | indent_size = 2 12 | indent_style = space 13 | 14 | [*.md] 15 | trim_trailing_whitespace = false 16 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: false 2 | language: node_js 3 | node_js: 4 | - 'stable' 5 | -------------------------------------------------------------------------------- /cli.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 'use strict'; 3 | const meow = require('meow'); 4 | const getStdin = require('get-stdin'); 5 | const objToTable = require('obj-to-table'); 6 | const toCsv = require('to-csv'); 7 | const viewportList = require('viewport-list'); 8 | 9 | const cli = meow({ 10 | help: [ 11 | 'Usage', 12 | ' $ viewport-list [device]', 13 | ' $ viewport-list < ', 14 | '', 15 | 'Example', 16 | ' $ viewport-list iphone4 iphone5', 17 | ' $ viewport-list < devices.txt', 18 | '', 19 | 'Options', 20 | ' -p, --pretty Print the results in a table' 21 | ] 22 | }, {alias: {p: 'pretty'}}); 23 | 24 | function run(input, opts) { 25 | viewportList(input).then(devices => { 26 | if (opts.pretty) { 27 | console.log(objToTable(devices).toString()); 28 | return; 29 | } 30 | 31 | console.log(toCsv(devices)); 32 | }); 33 | } 34 | 35 | if (process.stdin.isTTY) { 36 | run(cli.input, cli.flags); 37 | } else { 38 | getStdin().then(data => { 39 | [].push.apply(cli.input, data.trim().split('\n')); 40 | run(cli.input, cli.flags); 41 | }); 42 | } 43 | -------------------------------------------------------------------------------- /license: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) Kevin Mårtensson 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "viewport-list-cli", 3 | "version": "2.0.0", 4 | "description": "Return a list of devices and their viewports", 5 | "license": "MIT", 6 | "repository": "kevva/viewport-list-cli", 7 | "author": { 8 | "email": "kevinmartensson@gmail.com", 9 | "name": "Kevin Mårtensson", 10 | "url": "https://github.com/kevva" 11 | }, 12 | "engines": { 13 | "node": ">=4" 14 | }, 15 | "bin": { 16 | "viewport-list": "cli.js" 17 | }, 18 | "scripts": { 19 | "test": "xo && ava" 20 | }, 21 | "files": [ 22 | "cli.js" 23 | ], 24 | "keywords": [ 25 | "app", 26 | "cli", 27 | "cli-app", 28 | "device", 29 | "json", 30 | "resolution", 31 | "size", 32 | "viewport" 33 | ], 34 | "dependencies": { 35 | "get-stdin": "^5.0.1", 36 | "meow": "^3.3.0", 37 | "obj-to-table": "^1.0.0", 38 | "to-csv": "^0.1.0", 39 | "viewport-list": "^4.0.1" 40 | }, 41 | "devDependencies": { 42 | "ava": "*", 43 | "execa": "^0.1.1", 44 | "xo": "*" 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # viewport-list-cli [![Build Status](http://img.shields.io/travis/kevva/viewport-list-cli.svg?style=flat)](https://travis-ci.org/kevva/viewport-list-cli) 2 | 3 | > Return a list of devices and their viewports 4 | 5 | 6 | ## Install 7 | 8 | ``` 9 | $ npm install --global viewport-list-cli 10 | ``` 11 | 12 | 13 | ## Usage 14 | 15 | ```bash 16 | $ viewport-list --help 17 | 18 | Usage 19 | $ viewport-list [device] 20 | $ viewport-list < 21 | 22 | Example 23 | $ viewport-list iphone4 iphone5 24 | $ viewport-list < devices.txt 25 | 26 | Options 27 | -p, --pretty Print the results in a table 28 | ``` 29 | 30 | 31 | ## Related 32 | 33 | * [viewport-list](https://github.com/kevva/viewport-list) - API for this module 34 | 35 | 36 | ## License 37 | 38 | MIT © [Kevin Mårtensson](https://github.com/kevva) 39 | -------------------------------------------------------------------------------- /test.js: -------------------------------------------------------------------------------- 1 | import execa from 'execa'; 2 | import test from 'ava'; 3 | 4 | test('show version', async t => { 5 | const ret = await execa('./cli.js', ['--version']); 6 | t.is(require('./package.json').version, ret.stdout); 7 | }); 8 | 9 | test('show help screen', async t => { 10 | const ret = await execa('./cli.js', ['--help']); 11 | t.regexTest(/Return a list of devices and their viewports/, ret.stdout); 12 | }); 13 | --------------------------------------------------------------------------------