React λλ Vue κ°μ μΉκ΅¬λ€μ μ ν΄λ³΄μ ¨λ€λ©΄ μλμ κ°μ λͺ λ Ήμ΄λ₯Ό μ λ ₯νμ¬ νλ‘μ νΈλ₯Ό μμ±ν΄λ΄€μ κ²μ΄λ€.
$ create-react-app my-app
$ vue create my-app
μ΄λ κ² command μμμ μμ
μ μ²λ¦¬νλ λ°©μμ cli λΌκ³ νλ€.
cli λ command line interface
μ μ½μμ΄λ€.
Npm Finder
npm finder λΌλ cli λ₯Ό λ§λ€μ΄ μλμ λͺ λ Ήμ΄λ₯Ό μ λ ₯νλ©΄ npm μ¬μ΄νΈμ ν΄λΉ λͺ¨λ νμ΄μ§λ₯Ό μ°Ύμ λμμ£Όλ €νλ€.
$ n-finder react
Commander
λͺ¨λ μμ μ node.js κΈ°λ°μΌλ‘ μ΄λ€μ§κΈ° λλ¬Έμ node κ° μ€μΉλμ΄ μμ΄μΌ νλ€.
$ npm init -y
command μμ λͺ
λ Ήμ΄λ₯Ό μ€ννκ³ λ€μν option κ³Ό κ°λ€μ κ°μ Έμ€κΈ° μν΄μ commander
λΌλ λͺ¨λμ΄ νμνλ€.
$ npm install --save commander
commander λ₯Ό μ΄μ©νμ¬ index.js
λ₯Ό ꡬμ±ν΄λ³΄κ² μ΅λλ€.
!/usr/bin/env node λ κΌ μΆκ°ν΄μΌνλ€.
λ°°ν¬ ν global λ‘ μ€μΉνμ¬ μ¬μ© ν λ μμΌλ©΄ cli κ° λμνμ§ μλλ€.
#!/usr/bin/env nodeconst program = require("commander")
const pkg = require("./package.json")program
.version(pkg.version)
.arguments("<module-name>")
.action(module => console.log(`module: ${module}`))
.parse(process.argv)
μλμ κ°μ΄ index.js λ₯Ό μ€ννλ©° react
λΌλ κ°μ λ겨주면 module: react
λΌλ κ°μ΄ μ°νλ κ²μ λ³Ό μ μλ€.
node index.js react
commander
μ ν¨μλ₯Ό μν μ κ°λ¨νκ² μ΄ν΄λ³΄κ² λ€.
- version:
node index.js -V
μ κ°μ΄ ν΄λΉ λͺ¨λμ version μ μΆλ ₯ν μ μλλ‘ νλ€. - arguments: option μμ΄ νΈμΆλ κ°
- action: arguments κ°μ μ λ ₯λ°μ νμ λμμ μ μ
- parse: μ΄λμμ κ°μ μ λ ₯λ°λμ§ λνλΈλ€.
open
commander
λ₯Ό μ΄μ©νμ¬ κ°μ λ°μμΌλ μ΄ κ°μ μ΄μ©νμ¬ npm μ¬μ΄νΈμμ ν΄λΉ λͺ¨λ νμ΄μ§λ₯Ό open
νκΈ°λ§ νλ©΄λλ€ .
λΈλΌμ°μ λ₯Ό μ΄κΈ° μν΄ open
λͺ¨λμ μ¬μ©νλ€.
$ npm i --save open
NPM νμ΄μ§μμ λͺ¨λμ μ°Ύμκ°κΈ° μν BASE μ£Όμλ https://www.npmjs.com/package
μ΄λ€.
λͺ¨λμ μ°ΎκΈ° μν΄μλ λ€μκ³Ό κ°μ μ£Όμλ‘ μ κ·Όν΄μΌνλ€. https://www.npmjs.com/package/λͺ¨λμ΄λ¦
open μ μ€νμ λκ°μ§μ μΈμλ₯Ό λ°λλ€.
첫λ²μ§Έλ open ν μ£Όμ, λλ²μ§Έ μΈμλ λΈλΌμ°μ μ 보λ₯Ό λ°λλ€. (ν¬λ‘¬, νμ΄μ΄νμ€ λ±β¦)
$ open(url, browser)
ν¬λ‘¬μ μ¬μ©νκ² λ ν
λ° chrome
μ΄ μλ Google chrome
μΌλ‘ μ μ΄μ£Όμ΄μΌ νλ€.
const program = require("commander")
const pkg = require("./package.json")
const open = require("open")const BASE_NPM_URL = "https://www.npmjs.com/package"program
.version(pkg.version)
.arguments("<module-name>")
.action(module => open(`${BASE_NPM_URL}/${module}`, "Google chrome"))
.parse(process.argv)
μ΄μ μ€νν΄λ³΄μλ©΄ κ²μν λͺ¨λμ νμ΄μ§κ° λ¨λκ²μ λ³Ό μ μμ΅λλ€.
$ node index.js react

Deploy
λ¨Όμ μ°λ¦¬κ° λ§λ νλ‘μ νΈλ₯Ό git μ μ¬λ €μΌνλ€.
github μ νλ‘μ νΈκ° μ¬λΌκ° μλ€λ κ°μ νμ μ€λͺ
νκ² μ΅λλ€.
.npmignore
λ₯Ό μΆκ°νμ¬ λ°°ν¬μ μ μΈλ νμΌμ μμ±ν΄μΌνλ€.
λ§μ½ .npmignore
κ° μκ³ .gitignore
κ° μλ€λ©΄ gitignore μ κ·μΉμ λ°λ₯Έλ€.
.DS_Store
.git*
.idea
.vscode
npm μ λ°°ν¬νκΈ° μν΄μλ npm user λ₯Ό λ±λ‘ν΄μΌνλ€.
$ npm adduser

λ§μ§λ§μΌλ‘ package.json μ μ 보λ₯Ό μ±μ°λ©΄ λλ€.
{
"name": "npm-finder",
"version": "1.0.0",
"description": "This is CLI to find the module page in npm",
"main": "index.js",
"scripts": {},
"bin": {
"nfinder": "index.js"
},
"repository": {
"type": "git",
"url": "git+https://github.com/appear/npm-finder.git"
},
"author": {
"name": "olaf",
"email": "appear.ko@gmail.com",
"url": "https://appear.github.io/"
},
"license": "MIT",
"bugs": {
"url": "https://github.com/appear/npm-finder/issues"
},
"homepage": "https://github.com/appear/npm-finder#readme",
"dependencies": {
"commander": "^2.19.0",
"open": "0.0.5"
},
"keywords": ["npm", "finder", "cli"]
}
npm publish
λΌλ λͺ
λ Ήμ΄λ‘ λ°°ν¬ ν μ μλ€.
$ npm publish