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

nct Testing Case #15

Open xgqfrms-GitHub opened 7 years ago

xgqfrms-GitHub commented 7 years ago

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

xgqfrms-GitHub commented 7 years ago
const nct = (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)=> {
        return repos = json;
    })
    .then((repos)=>{
        console.log(repos);
    });
};

nctcli();
xgqfrms-GitHub commented 7 years ago
const cli = ((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)=> {
        return repos = json;
    })
    .then((repos)=>{
        console.log(repos);
    });
})();
xgqfrms-GitHub commented 7 years ago
const data = [
    {"id": "1", "name": "name_1", "parent_id": "0", "depth": "0"},
    {"id": "2", "name": "name_2", "parent_id": "0", "depth": "0"},
    {"id": "3", "name": "name_3", "parent_id": "1", "depth": "1"},
    {"id": "4", "name": "name_4", "parent_id": "3", "depth": "2"}
];

function getMenu(parentID){
    let style = `
        color: rgba(0,2555,0,0.7);
        font-size: 32px;
        border: 1px solid red;
        background: #000;
    `;
    return (
        data.filter(
            // filter parentID
            function(node){
                console.log(`%c nodes = `, `${style}`, node);
                return node.parent_id === parentID;
            }
        ).map(
            // map subMenu
            function(node){
                let exists = data.some(
                    // test childNode
                    function(childNode){
                        console.log(`%c childNode = `, `${style}`, node);
                        return childNode.parent_id === node.id;
                    }
                );
                // recursive
                let subMenu = exists ? `<ul>${getMenu(node.id).join('')}</ul>` : ``;
                return `<li>${node.name}&${subMenu}</li>`;
            }
        )
    );
}

// let initLevel = 0;

let endMenu =getMenu("0");

console.log(`<ul>${endMenu.join('<br/>')}</ul>`);

/*
<ul>
    <li> name_1
        <ul>
            <li> name_3
                <ul>
                    <li> name_4 </li>
                </ul>
            </li>
        </ul>
    </li>
    <li> name_2 </li>
</ul>
*/

/*
<ul>
    <li> name_1 
        <ul>
            <li> name_3 
                <ul> 
                    <li> name_4  </li>
                </ul>
            </li>
        </ul>
    </li>
    <br/>
    <li> name_2  </li>
</ul>
*/

https://gist.github.com/xgqfrms-gildata/5acc4a357722e9e2636009fbd6846338#gistcomment-2133537

xyzdata commented 6 years ago

fetch(`http://localhost:7777/datas`)
.then((response) => response.json())
.then((json)=> {
    console.log(`json = ${json}`);
    return repos = json;
});

https://github.com/gildata/json/issues/1