Giter VIP home page Giter VIP logo

node-cli-tools's Introduction

node-cli-tools's People

Contributors

xgqfrms avatar xgqfrms-github avatar xyzdata avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

xyz-data xyzdata

node-cli-tools's Issues

bash, cmd, clip, cli

github repos commits

https://developer.github.com/v3/repos/commits/

let username = `xgqfrms-GitHub`;
     repo = `Node-CLI-Tools`;

fetch(`https://api.github.com/repos/${username}/${repo}/commits`,{
    data: {
        client_id: '08ecc2f68d922f18800e',
        client_secret: '5846d428b5340812b76c9637eceaee979340b922'
    }
})
.then((response) => response.json())
.then((json)=> {
    console.log(`json = ${json}`);
    return repos = json;
})
.then((repos)=>{
    console.log(`repos = ${repos}`);
    console.log(`repos = ${repos.length}`);
    for (let i = 0; i < repos.length; i++) {
        console.log(`repos${i}  = ${repos[i].commit.message}`);
    }
});

npm link & run npm script

npm link & run npm script

https://blog.csdn.net/juhaotian/article/details/78672390

npm link命令可以将一个任意位置的npm包链接到全局执行环境,从而在任意位置使用命令行都可以直接运行该npm包。

app-cmd.cmd

#!/usr/bin/env node

echo "666" && npm run app

package.json

{
    "scripts": {
        "app": "npm run rmrf-all && webpack -p",
        "dev": "npm run rmrf && webpack -p -w",
        "prod": "webpack -p",
        "rmrf": "rimraf build/js && rimraf build/css",
        "rmrf-all": "rimraf build/*",
        "page": "cd modules && browser-sync start --server --files './*.html'",
        "index": "cd build && browser-sync start --server --files './index.html'",
        "test": "cd src && browser-sync start --server --files './*.*'"
    },
    "private": true,
    "bin": {
        "app": "app-shell",
        "cmd": "app-cmd"
    },
}

npm

https://docs.npmjs.com/cli/link

https://docs.npmjs.com/cli/run-script

https://docs.npmjs.com/misc/scripts

nct Testing Case

Testing Case

const nct = (username, repo) => {
    fetch(`https://api.github.com/repos/${username}/${repo}/commits`,{
        data: {
            client_id: '08ecc2f68d922f18800e',
            client_secret: '5846d428b5340812b76c9637eceaee979340b922'
        }
    })
    .then((response) => response.json())
    .then((json)=> {
        return repos = json;
    })
    .then((repos)=>{
        console.log(repos);
    });
};

// key ? true : false
let username = username ? username : `xgqfrms-GitHub`;
     repo = repo ? repo : `Node-CLI-Tools`;

nct(username, repo);


// es6 
nct(username=`xgqfrms-GitHub`, repo=`Node-CLI-Tools`);


// node cli
let username = process.argv[2] ? process.argv[2] : `xgqfrms-GitHub`;
     repo = process.argv[3] ? process.argv[3] : `Node-CLI-Tools`;

nct(username, repo);

CLI

https://github.com/xgqfrms-GitHub/Node-CLI-Tools/blob/master/nctcli

https://github.com/xgqfrms-GitHub/Node-CLI-Tools/tree/master/libs

Node.js CLI & Linux shell `#!` interpreter

Node.js CLI & Linux shell #! interpreter

#!/usr/bin/env node

# ✅ 推荐写法, 动态读取 env 配置的解释器路径,切换系统环境不会报错,可移植性高 🚀 
#!/usr/bin/node

# 👎 不推荐写法,写死了解释器路径,切换系统环境有可能会报错,可移植性低 

image

作者:xgqfrms
链接:https://www.cnblogs.com/xgqfrms/p/17273683.html
来源:https://www.cnblogs.com
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
©xgqfrms 2012-2023
www.cnblogs.com 发布文章使用:只允许注册用户才可以访问!
原创文章,版权所有©️xgqfrms, 禁止转载 🈲️,侵权必究⚠️

node module

node module

nct.js

    
// todo

lib/index.js

    
// todo

lib/showdata.js

    
// todo

api tesing

http://fanyi.youdao.com/openapi.do?keyfrom=node-translator&key=2058911035&type=data&doctype=json&version=1.1&q=tet

{
    "translation": [
        "春节"
    ],
    "basic": {
        "us-phonetic": "tet",
        "phonetic": "tet",
        "uk-phonetic": "tet",
        "explains": [
            "abbr. 测试设备组(Test Equipment Team)"
        ]
    },
    "query": "TET",
    "errorCode": 0,
    "web": [
        {
            "value": [
                "四环素",
                "西山彻",
                "汉防己甲素"
            ],
            "key": "Tet"
        },
        {
            "value": [
                "天哲"
            ],
            "key": "Tet Wada"
        },
        {
            "value": [
                "四环素操纵子"
            ],
            "key": "tet operon"
        }
    ]
}

http://fanyi.youdao.com/openapi.do?keyfrom=node-translator&key=2058911035&type=data&doctype=json&version=1.1&q=test

{
    "translation": [
        "测试"
    ],
    "basic": {
        "us-phonetic": "tɛst",
        "phonetic": "test",
        "uk-phonetic": "test",
        "explains": [
            "n. 试验;检验",
            "vt. 试验;测试",
            "vi. 试验;测试",
            "n. (Test)人名;(英)特斯特"
        ]
    },
    "query": "test",
    "errorCode": 0,
    "web": [
        {
            "value": [
                "测试",
                "测验",
                "检验"
            ],
            "key": "Test"
        },
        {
            "value": [
                "Test Drive",
                "Test Drive",
                "无限狂飙"
            ],
            "key": "Test Drive"
        },
        {
            "value": [
                "测试员",
                "测试工程师",
                "软件测试工程师"
            ],
            "key": "Test Engineer"
        }
    ]
}

http://fanyi.youdao.com/openapi.do?keyfrom=node-translator&key=2058911035&type=data&doctype=json&version=1.1&q=xgqfrms

{
    "translation": [
        "xgqfrms"
    ],
    "query": "xgqfrms",
    "errorCode": 0
}

npm scripts & auto open default browser & run multi commands

npm scripts & auto open default browser & run multi commands

macOS

{
  "auto": "npm run dev & open http://localhost:8000",
}

Windows

// bad
{
  "start": "npm run dev & start http://localhost:8000",
}
// good 
{
  "start": "start http://localhost:8000 & npm run dev",
}
// bad
{
  "start": "npm run dev & npm run open",
  "open": "start http://localhost:8000",
}

demo

{
    "private": true,
    "entry": {
        "index": "./src/index.js"
    },
    "scripts": {
        "dev": "dora --plugins \"webpack?config=conf/webpack.config.js&publicPath=/,webpack-hmr,browser-history?index=/src/index.html\"",
        "build-dev": "atool-build --config conf/webpack.config.js --publicPath /",
        "build-staging": "atool-build --config conf/webpack.config.staging.js --publicPath /",
        "build-release": "atool-build --config conf/webpack.config.release.js --publicPath /",
        "start": "start http://localhost:8000 && npm run dev",
        "lint": "eslint --fix --ext .js,.jsx src/components/layout"
    },
    "dependencies": {
        "antd": "^2.11.0",
        "classnames": "^2.2.5",
        "dva": "^1.1.0",
        "dva-loading": "^0.2.0",
        "immutable": "^3.8.1",
        "js-cookie": "^2.1.3",
        "lodash": "^4.17.4",
        "moment": "^2.17.1",
        "prop-types": "^15.5.10",
        "qs": "^6.2.0",
        "rc-queue-anim": "^0.13.0",
        "rc-tween-one": "^1.0.0",
        "react": "^15.4.1",
        "react-countup": "^1.3.0",
        "react-dom": "^15.4.1",
        "react-lz-editor": "^0.10.15",
        "react-media-player": "^0.6.1",
        "react-motion-ui-pack": "^0.10.2",
        "recharts": "^0.19.0",
        "reselect": "^2.5.4"
    },
    "devDependencies": {
        "atool-build": "^0.7.6",
        "axios": "^0.15.3",
        "babel-eslint": "^6.0.4",
        "babel-plugin-dev-expression": "^0.2.1",
        "babel-plugin-dva-hmr": "^0.1.0",
        "babel-plugin-import": "^1.0.1",
        "babel-plugin-transform-runtime": "^6.9.0",
        "babel-polyfill": "^6.23.0",
        "babel-runtime": "^6.9.2",
        "dora": "^0.4.3",
        "dora-plugin-browser-history": "^0.2.0",
        "dora-plugin-proxy": "^0.8.5",
        "dora-plugin-webpack": "^0.8.1",
        "dora-plugin-webpack-hmr": "^0.2.1",
        "eslint": "^2.13.1",
        "eslint-config-airbnb": "^9.0.1",
        "eslint-plugin-import": "^1.8.1",
        "eslint-plugin-jsx-a11y": "^1.4.2",
        "eslint-plugin-react": "^5.1.1",
        "glob": "^7.0.5",
        "mockjs": "^1.0.1-beta3",
        "path-to-regexp": "^1.7.0",
        "redbox-react": "^1.2.10",
        "robe-ajax": "^1.0.0",
        "watchjs": "^0.0.0"
    },
    "theme": "./src/theme.js",
    "standard": {
        "parser": "babel-eslint",
        "globals": [
            "location",
            "localStorage"
        ]
    }
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.