npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

bf-pc-cli

v1.0.1

Published

碧服前端PC脚手架工具

Downloads

9

Readme

1. Shell、Bash、CLl

  1. Shell 是操作系统提供的接口程序,用于接收用户输入的命令,交给操作系统内核执行并接收响应结果
  2. Bash 是 Shell 的一个实现,用于执行用户车俞入的命令
  3. CLl是 Bash 的运行环境,CLl 接收用户键盘输入,交给 Bash 执行,并将程序处理结果以文本形式进行显示

2. vue command [options] 命令解析过程

  1. 主命令:vue (PS:which vue 可以查看vue命令在PC中得位置)
  2. command(子命令):create --> 向主命令发送一个请求,这个请求让我们的脚手架完成一个动作,这个动作就是create创建项目
  3. command的参数:app --> 创建什么什么项目呢?创建一个名为app的vue项目
  4. option(选项,配置):--force --> 用来辅助脚手架确定在特定场景下用户的选择(可以理解为配置)
  5. 带params的options: --default --> 默认选项,默认选项是脚手架提供的,用户可以不输入任何选项,直接使用默认选项

2.1、执行流程图

  1. 在终端输入 vue create app
  2. 终端解析出vue命令
  3. 终端在环境变量中找到vue命令
  4. 终端根
  5. 终端利用node执行vue.js
  6. vue.js解析command/options
  7. vue.js执行command
  8. 执行完毕,退出执行

3. 从应用的角度看如何开发一个脚手架

  1. 这里以 vue-c1í 为例
  • 开发 npm 项目,该项目中应包含一个 bin/vue.js 文件,并将这个项目发布到 npm
  • 将 npm 项目安装到 node 的 lib/node modules
  • 在 node 的 bin 目录下配置 vue 软链接指向 1ib/node modules/@vue/cli/bin/vue.js。
  • 这样我们在执行 wue 命令的时候就可以找到 vue.js 进行执行

以下三个命令是等价的,用于执行某个js文件 (/usr/bin/env node test.js) === (./test.js) === (node test.js)

4. 理解npm link 与npm unlink

  1. npm remove -g bf-pc-cli: 移除本地环境里面的bf-pc-cli包

  2. npm link: 将本地环境里面的bf-pc-cli包链接到全局环境

  3. npm link bf-pc-cli-lib: 将本地环境里面的bf-pc-cli-lib包链接到其它包的本地环境进行调试,避免频繁发包到npm调试

  4. npm link: 将当前项目链接到 node 全局 node_modules 中作为一个库文件,并解析 bin 配置创建可执行文件

  5. npm link name: 将当前项目中的 node_modules 下指定的库文件链接到 node 全局 node_modules 下的库文件

  6. npm unlink: 将当前项目从 node 全局 node_modules 中移除

  7. npm unlink name: 将当前项目中的库文件依赖移除

开发自定义脚手架的各步骤

1. 初始化:js脚本映射成命令

  1. 创建一个index.js文件,并在首行写入#!/usr/bin/env node,这样一个脚手架可执行入口文件就建立好了
  2. 执行npm init -y, 在package.json中配置bin字段,"bin": {"bf-pc-cli": "bin/index.js"}, bf-pc-cli就是类似vue一样的命令
  3. 执行npm link,将当前项目链接到全局node中,这样就可以直接在命令行中执行bf-pc-cli

2. 使用commander解析命令行参数

bf-pc-cli -h | --help 查看使用帮助 bf-pc-cli -v | --version 查看工具的版本号 bf-pc-cli list 列出所有可用模板 bf-pc-cli init 基于指定的模板进行项目初始化 commander获取用户输入的命令来执行不同的操作

3. download-git-repo 指定下载模板

开发好的框架模板放在github上,使用download-git-repo下载模板到本地

4. inquirer handlebars

inquirer 输入式命令行交互 handlebars 模板引擎

5. 视觉美化

ora 命令行进度条