Open fangmd opened 2 years ago
mkdir template-cli npm init npm i -D typescript @types/node tsc --init
// tsconfig.json { "compilerOptions": { "target": "es2016", "module": "commonjs", "esModuleInterop": true, "forceConsistentCasingInFileNames": true, "strict": true, "sourceMap": true, "outDir": "./lib", }, "include": [".eslintrc.js", "src/**/*"], "exclude": ["node_modules", "lib/**/*"], }
npm install -save-dev eslint @typescript-eslint/parser @typescript-eslint/eslint-plugin @eslint/config
// .eslintrc.js module.exports = { root: true, env: { node: true, es2021: true, }, parser: '@typescript-eslint/parser', parserOptions: { ecmaVersion: 12, sourceType: 'module', tsconfigRootDir: __dirname, project: ['./tsconfig.json'], }, plugins: ['@typescript-eslint'], extends: [ 'eslint:recommended', 'plugin:@typescript-eslint/recommended', 'plugin:@typescript-eslint/recommended-requiring-type-checking', ], }
// .eslintignore lib
// package.json "scripts": { "lint": "eslint --ext .js .", "lint:fix": "eslint --fix --ext .js ." },
npm link
// package.json "scripts": { "dev": "tsc && node lib/index.js", "build": "tsc", },
//src/index.ts #!/usr/bin/env node const msg = 'hello' console.log(msg)
npm install -save commander
npm install -save inquirer @types/inquirer
npm install -save git-clone && npm i -D @types/git-clone
npm i fs-extra && npm i -D @types/fs-extra
npm i ora
npm install chalk
创建过程