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

blueming-cli

v1.0.1

Published

前端脚手架/CLI

Downloads

1

Readme

前端脚手架/CLI-构建

目录
/bin 脚本入口
/src 代码逻辑

入门

mkdir blueming-cli && cd blueming-cli && npm init

  1. package.json
"bin": {
    "blueming": "./bin/main.js"
},
  1. Demo bin/index.js
#!/usr/bin/env node
// 指定用node执行脚本文件,/usr/bin/env 是告诉系统在PATH目录中查找node执行路径
require('../src/main.js')

src/main.js console.log("hello world")

运行 node ./bin/index.js

  1. 发布
    执行npm link 发布到全局

成功后可使用 blueming 指令

依赖

commander --命令行界面
inquirer  --命令行交互询问模块
chalk     --颜色增强模块(字体样式加粗等/字体颜色/背景颜色)
ora       --用于命令行上的加载效果
shelljs   --shell 命令
git-clone --git克隆模块

yarn add commander inquirer chalk shelljs ora git-clone

  1. commander --命令行界面
    文档:https://www.npmjs.com/package/commander
const program = require('commander'); // 令行界面模块
program
    // 版本选项
    .version('1.0.0', '-v --version')
    .description('init...')
  1. inquirer --命令行交互询问模块
    文档:https://www.npmjs.com/package/inquirer
const inquirer = require('inquirer');

const promptList = [
    // 具体交互内容
];

inquirer.prompt(promptList).then(answers => {
    console.log(answers); // 返回的结果
})

const promptList = [{
    type: 'input',
    message: '设置一个用户名:',
    name: 'name',
    default: "test_user" // 默认值
},{
    type: 'input',
    message: '请输入手机号:',
    name: 'phone',
    validate: function(val) {
        if(val.match(/\d{11}/g)) { // 校验位数
            return val;
        }
        return "请输入11位数字";
    }
}];
  1. chalk --颜色增强模块(字体样式加粗等/字体颜色/背景颜色)
    文档:https://www.npmjs.com/package/chalk
const chalk = require('chalk');
console.log(chalk.red.bold.bgWhite('Hello World')); // 红色 + 加粗 + 背景白色
console.log(chalk`{red.bold.bgWhite Hello World}`);
  1. sheeljs --用于命令行上的加载效果
    文档:https://www.npmjs.com/package/shelljs
const shell = require('shelljs'); 
shell.rm('-rf', 'dist'); // 删除dist 目录
  1. ora 命令行加载效果 --用于命令行上的加载效果
const ora = require('ora')
const spinner = ora('工程模板下载中...')
spinner.start()  //显示加载状态
setTimeout(()=>{
    spinner.stop()
},3000)
  1. git-clone --git克隆模块

使用流程

脚手架/CLI

  1. 拉取脚手架/CLI git clone
  2. 安装依赖 yarn
  3. 发布到全局 npm link

创建项目

  1. blueming create project-name
  2. 选择模板类型
  3. 选择具体模板
  4. 下载完成后,进入该项目并下载依赖 cd project-name && yarn