Git Product home page Git Product logo

simple-cli's Introduction

simple-cli

项目脚手架

项目初始化 init

pnpm init -y

脚本文件初始化

脚本执行原理,通过 package.json 中的 bin 字段配置脚本入口文件,当上传到 npm 服务器后,再从 npm 下载之后,npm install -g 之后脚本 bin 会添加到系统环境变量中,然后就可以在命令行使用,定义的脚本命令了(本地调试可以通过以下3进行调试,等等好像不需要install也能行得通)

1.package.json

脚本程序入口文件声明,spc是命令行输入的执行命令,值是脚本入口文件

{
  "bin": {
    "spc": "./bin/index.js"
  }
}

2.脚本初始化

在./bin/index.js 中添加一个 js 脚本 声明是一个 node 环境执行的脚本文件

#!/usr/bin/env node
console.log("我通过命令行,执行脚本啦~");

3.模拟安装脚本文件到 node_modules

安装之后,node_modules 中就会出现,脚手架的包 simple-cli

pnpm install .
# or
pnpm link

4.测试运行

命令行输入

spc

可以在命令看到 我通过命令行, 执行脚本啦~ 脚本进行就初始化成功了

simple-cli's People

Contributors

dreamchaser-lcc avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.