xgqfrms-GitHub / Node-CLI-Tools

一个 Node.js CLI 工具,查看指定 git 仓库的 commit history ; 能对 commit history 进行搜索; 能查看指定时间范围的 commit history.
https://node-cli-tools.xgqfrms.xyz
MIT License
6 stars 2 forks source link

api tesing #5

Open xgqfrms-GitHub opened 7 years ago

xgqfrms-GitHub commented 7 years ago

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
}
xgqfrms-GitHub commented 7 years ago

https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse


// Request

/*

const request = require('request');

request('https://cdn.xgqfrms.xyz/json/badges.json', (error, response, body) => {
    console.log('error:', error); 
    // Print the error if one occurred 
    console.log('statusCode:', response && response.statusCode); 
    // Print the response status code if a response was received 
    console.log('body:', body); 
    // Print body. 
    console.log('body.user:', body.user); 
    // Print body.user
    }
);

*/

const request = require('request');
const colors = require('colors');

console.log(`process.argv = \n`.white, process.argv);
console.log(`process.argv[0] = \n`.red, process.argv[0]);
console.log(`process.argv[1] = \n`.green, process.argv[1]);
console.log(`process.argv[2] = \n`.blue, process.argv[2]);

const showjson = (data) => {
    console.log(`\ndata = ${data}`.red);
    console.log(typeof data);
    // string to JSON
    console.log(`\ndata.query = ${data.query}`);
    let db = data.basic,
        dw = data.web;
    console.log(`\ndata.basic = ${data.basic}`);
    console.log(`\ndata.web = ${data.web}`);
    if (db != null) {
        let us = typeof db["us-phonetic"] === 'string'
                ? `美音: [${db["us-phonetic"]}]`
                : '',
            uk = typeof db["uk-phonetic"] === 'string'
                ? `英音: [${db["uk-phonetic"]}]` 
                : ''; 
        if (uk && us) {
            console.log(`\n${us}\t${uk}\n`);
        }
        else if (typeof db["phonetic"] === 'string') {
            console.log(`拼音:`.bold.underline + `[${db["phonetic"]}]\n`);
        }
        console.log(`翻译:`.bold.underline + `${db["explains"]}\n`);
    }
    else if(dw != null) {
        console.log(`网络释义: `.bold.underline);
        for (let i = 0; i < dw.length; i++) {
            temp = dw[i];
            console.log(`\n\t${i+1}.${temp.key}`);
            console.log(`\n\t${temp.value}`);
        }
        console.log(`\ndata.web.length = ${dw.length}`);
    }else {
        console.log(`\n暂无释义!`.bold.underline.red);
    }
};

let query_key = process.argv[2];
let json_url = `
http://fanyi.youdao.com/openapi.do?keyfrom=node-translator&key=2058911035&type=data&doctype=json&version=1.1&q=${query_key}
`;

request(json_url, (error, response, body) => {
    if(!error && response.statusCode === 200) {
        console.log(`body =`.rainbow, body);
        console.log(typeof body);
        // string
        let data = JSON.parse(body);
        showjson(data);
    }
    else{
        console.log(`error =`.red, body);
    }
});
xgqfrms-GitHub commented 7 years ago
{
    "basic": [
       { "abc": "xgqfrms"}
    ],
    "query": "xgqfrms",
    "errorCode": 0
}
xgqfrms-GitHub commented 7 years ago
let data = {
    "basic": [
       { "abc": "xgqfrms"}
    ],
    "query": "xgqfrms",
    "errorCode": 0
};

let s1 = JSON.stringify(data.basic);
// "[{"abc":"xgqfrms"}]"

let s2 = JSON.stringify(data.basic[0]);
// "{"abc":"xgqfrms"}"
xgqfrms-GitHub commented 7 years ago
  1. https://github.com/SFantasy/node-translator/blob/master/source.es6

main

  1. https://github.com/SFantasy/node-translator/blob/master/config.js

url

  1. https://github.com/SFantasy/node-translator/blob/master/lib/index.js

lib === index.js

  1. https://github.com/SFantasy/node-translator/blob/master/lib/output.js

showjson

  1. https://github.com/SFantasy/node-translator/blob/master/compiled.js

webpack & minify, uglify

  1. https://github.com/SFantasy/node-translator/blob/master/bin/ntrans

publish bin

xgqfrms-GitHub commented 7 years ago

https://github.com/SFantasy/node-translator/blob/master/.npmignore

https://github.com/SFantasy/node-translator/blob/master/.gitignore

travis

https://github.com/SFantasy/node-translator/blob/master/.travis.yml

language: node_js

https://github.com/SFantasy/node-translator/blob/master/package.json

xgqfrms-GitHub commented 7 years ago

https://github.com/explore

https://jobs.github.com/

xgqfrms-GitHub commented 7 years ago

https://jobs.github.com/positions?description=JavaScript

https://github.com/sdmg15/Best-websites-a-programmer-should-visit#when-you-get-stuck

xgqfrms-GitHub commented 7 years ago

Travis CI

https://travis-ci.org/

https://github.com/travis-ci/travis-ci

轻松将您的GitHub项目与Travis CI进行同步,您将在几分钟内测试您的代码!

https://travis-ci.org/xgqfrms-GitHub/AngularJS-2/jobs/181823282

https://travis-ci.org/xgqfrms-GitHub/

https://travis-ci.org/xgqfrms-GitHub/Node-CLI-Tools/settings

travis ci tutorial javascript

https://docs.travis-ci.com/user/getting-started/

https://docs.travis-ci.com/user/for-beginners

https://github.com/marketplace/travis-ci

https://github.com/marketplace/travis-ci/order/MDIyOk1hcmtldHBsYWNlTGlzdGluZ1BsYW43MA==?utf8=%E2%9C%93&account=xgqfrms-GitHub

https://travis-ci.org/

https://github.com/mbonaci/mbo-storm/wiki/Integrate-Travis-CI-with-your-GitHub-repo

blogs

https://www.raywenderlich.com/109418/travis-ci-tutorial

https://docs.travis-ci.com/user/for-beginners

https://code.tutsplus.com/tutorials/travis-ci-what-why-how--net-34771

https://www.youtube.com/watch?v=Uft5KBimzyk

https://github.com/dwyl/learn-travis

xgqfrms-GitHub commented 7 years ago

https://learn-anything.xyz/

xgqfrms-GitHub commented 7 years ago

.travis.yml

xgqfrms-GitHub commented 7 years ago

https://github.com/showcases/front-end-javascript-frameworks

xgqfrms-GitHub commented 7 years ago

http://todomvc.com/examples/react/#/

xgqfrms-GitHub commented 7 years ago

https://gist.github.com/xgqfrms-GitHub/055b547f7a121162151517c58647dab2