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

bin & cli & rm -rf & npm link #19

Closed xgqfrms-GitHub closed 1 year ago

xgqfrms-GitHub commented 6 years ago

bin & cli & rm -rf

https://github.com/gildata/RAIO/issues/211#issuecomment-346781276

https://github.com/gildata/RAIO/issues/211#issuecomment-346924503

xgqfrms-GitHub commented 6 years ago

link to commands

Node-CLI-Tools

Node.js CLI 一: 开发一个 Node.js CLI 工具

  1. 必选项:

    • [x] 查看指定 git 仓库的 commit history
  2. 加分项:

    • [ ] 能对 commit history 进行搜索
    • [ ] 能查看指定时间范围的 commit history

link


# link `nct` to cli commands

$ npm i
$ npm link

run

# parameters can be ignore

$ nct [user_name, [repo_name]]
$ nct user_name repo_name

demo

$ nct

$ nct xgqfrms react

nct

nct-test-ok

nct xgqfrms react

nct-react-test-ok

travis-ci

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

xgqfrms-GitHub commented 6 years ago

npm i & npm link

image

xgqfrms-GitHub commented 6 years ago

OK

image

xgqfrms-GitHub commented 6 years ago

npm i & npm link


# link `nct` to cli commands

$ npm i
$ npm link

run

# parameters can be ignore

$ nct [user_name, [repo_name]]
$ nct user_name repo_name
xgqfrms-GitHub commented 6 years ago

https://github.com/gildata/RAIO/issues/211#issuecomment-346924503

xgqfrms-GitHub commented 6 years ago
"bin": {
    "rmrf": "rm-rf.js",
    "bin_comments": "no need .js extends name!",
    "npm_cli_commands": "npm i & npm link"
},
xgqfrms-GitHub commented 6 years ago

image

xgqfrms-GitHub commented 6 years ago

image

xgqfrms-GitHub commented 6 years ago

image

xgqfrms-GitHub commented 6 years ago

OK

image


#! /usr/bin/env node

/**
 * [rmrf : node cli tools]
 * @author: xgqfrms
 * @date: 2017-01-01
 */

const path = require('path');
const rimraf = require('rimraf');

console.log(`hello world!`);
let folder_pathname = path.resolve(__dirname, "dist/js");

// https://github.com/isaacs/rimraf#api
// rimraf(f, [opts], callback);
rimraf.sync(folder_pathname, {}, function(){
    // callback
    console.log("this is a rmrf callback!");
});

// rimraf.sync(__dirname + '/target');

// fs.readFileSync(__dirname + '/src/template.ejs', 'utf-8')

// path: path.resolve(__dirname, "build/public/"),//主目录

// rimraf dist

npm i & npm link


# link `nct` to cli commands

$ npm i
$ npm link

run

# parameters can be ignore

$ nct [user_name, [repo_name]]
$ nct user_name repo_name
xgqfrms-GitHub commented 6 years ago

{
    "name": "webpack-demo",
    "version": "1.0.0",
    "description": "Working demo of CSS Modules, using Webpack's css-loader in module mode.",
    "module": "webpack.config.js",
    "main": "index.js",
    "scripts": {
        "test": "webpack",
        "start": "webpack-dev-server",
        "clean": "rm -rf dist",
        "clear": "rimraf dist",
        "build": "npm run clean && webpack",
        "deploy": "npm run build && gh-pages -d dist -m \"Updates --skip-ci\"",
        "linux_rmrf": "rm -rf build/public",
        "windows_clear": "rimraf build/public",
        "rmrf": "node rm-rf.js"
    },
    "bin": {
        "rmrf": "rm-rf.js",
        "bin_comments": "no need .js extends name!",
        "npm_cli_commands": "npm i & npm link"
    },
    "author": "Mark Dalgleish",
    "license": "MIT",
    "devDependencies": {
        "rimraf": "^2.6.2",
        "autoprefixer-core": "^5.1.11",
        "babel-core": "^5.2.17",
        "babel-loader": "^5.0.0",
        "css-loader": "^0.15.1",
        "ejs": "^2.3.1",
        "extract-text-webpack-plugin": "^0.8.1",
        "file-loader": "^0.8.4",
        "gh-pages": "git://github.com/markdalgleish/gh-pages#cli-message",
        "node-libs-browser": "^0.5.0",
        "postcss-color-rebeccapurple": "^1.1.0",
        "postcss-loader": "^0.4.3",
        "raw-loader": "^0.5.1",
        "react": "^0.13.3",
        "react-to-html-webpack-plugin": "^2.2.0",
        "style-loader": "^0.12.3",
        "url-loader": "^0.5.6",
        "webpack": "^1.9.10",
        "webpack-dev-server": "^1.9.0"
    }
}

update

// package.json
{
    "scripts": {
        "clean": "rm -rf dist",
        "clear": "rimraf dist"
    },
    "bin": {
        "rmrf": "rm-rf.js",
        "npm_cli_commands": "npm i & npm link"
    },
    "author": "xgqfrms",
    "license": "MIT",
    "devDependencies": {
        "rimraf": "^2.6.2"
    }
}
xgqfrms-GitHub commented 6 years ago

https://github.com/gildata/RAIO/issues/211#issuecomment-347054214

xgqfrms-GitHub commented 6 years ago

Bash On Windows10

https://github.com/xgqfrms/xgqfrms/blob/gh-pages/Bash%20On%20Windows10/Bash%20on%20Ubuntu%20on%20Windows%20UNIX%20OK.png

https://gist.github.com/xgqfrms-GitHub/d3f1ac685335d481572d5390d7c31a1c https://github.com/ReactTraining/react-router/issues/4648#issuecomment-284479720

xgqfrms-GitHub commented 6 years ago

VS Code

open vs-code in cmd!

code . (one space)

image

xgqfrms-GitHub commented 6 years ago

.sh & .bat .cmd

bash shell

shell scripts

xgqfrms commented 6 years ago

shell colors

shell colors


{
    "name": "node-cli-tools",
    "version": "1.1.1",
    "private": true,
    "bin": {
        "nct": "nctcli"
    },
    "scripts": {
        "nct": "node nctcli",
        "start": "node nctcli"
    },
    "dependencies": {
        "colors": "^1.1.2",
        "node-fetch": "^1.7.1"
    }
}
xgqfrms commented 3 years ago

rimraf

rmrf & clear build / dist folder caches

https://www.npmjs.com/package/rimraf

$ yarn add -D rimraf
# OR
$ npm i -D rimraf
{
  "clear": "rm -rf dist",
  "rmrf": "rimraf dist"
}

{
  "clear": "rm -rf build/**/*.js",
  "rmrf": "rimraf build/**/*.js"
}
xgqfrms commented 3 years ago

clean.sh

#!/usr/bin/env bash

# echo "^-v-^ cleaning files ..." && yarn clean
# echo "^-v-^ cleaning files ..." && rm -rf ./docs/*
# no yes/no ??? bug
# echo "^-v-^ cleaning files ..." && rm -Rf ./docs/*

echo "^-v-^ cleaning files ..." && rimraf ./docs
# echo "^-v-^ cleaning files ..." && rimraf ./docs/*.*
# echo "^-v-^ cleaning files ..." && rimraf ./docs/**/*.*

https://cnblogs.xgqfrms.xyz/

xgqfrms commented 1 year ago

rimraf

https://www.npmjs.com/package/rimraf

$ yarn add -D rimraf
#!/usr/bin/env bash

rm -rf
xgqfrms commented 1 year ago

https://github.com/isaacs/rimraf

https://www.cnblogs.com/xgqfrms/tag/rimraf/

https://www.cnblogs.com/xgqfrms/tag/rm%20-rf/

xgqfrms commented 9 months ago

shx

shx rm -rf ./dist/*

$ npm i -D shx

shx is a wrapper around ShellJS Unix commands, providing an easy solution for simple Unix-like, cross-platform commands in npm package scripts.

https://www.npmjs.com/package/shx

  "scripts": {
    "clean": "shx rm -fr dist/*",
    "rmrf": "rimraf dist/*",
  },

https://www.cnblogs.com/xgqfrms/p/17747301.html