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

@fe-hl/cli-shared

v1.0.4

Published

cli脚手架工具库

Downloads

6

Readme

cli 脚手架工具库

引用

import {
  fse,
  pathExists,
  chalk,
  rootCheck,
  semver,
  logs,
  isDebug,
  request,
  spinnerLoading,
  makeList,
  makeInput,
  makeConfirm,
  makePassword,
  getLatestVersion,
  checkGlobalUpdate,
  welcome,
  checkNodeVersion,
  getPkgInfo,
  getDirname,
  getFilename,
  exception,
  printErrorLog,
} from "@fe-hl/cli-shared";

fse 等同 fs-extra 库

import fse from "fs-extra";

pathExists 等同 pathExists 库

import { pathExists } from "path-exists";

chalk 等同 chalk 库

import chalk from "chalk";

rootCheck 等同 rootCheck 库

import rootCheck from "root-check";

semver 等同 semver 库

import semver from "semver";

logs 日志输出

logs.silly(prefix, message);
logs.verbose(prefix, message);
logs.info(prefix, message);
logs.http(prefix, message);
logs.warn(prefix, message);
logs.error(prefix, message);

isDebug 模式判断

// hl-cli init createApp -- --debug
isDebug();

request http 请求

await request.get(url);
await request.post(url);

spinnerLoading

const { spinnerSucceed, spinnerFail } = spinnerLoading("开始创建远程仓库");
spinnerSucceed(message?);
spinnerFail(message?);

makeList,makeInput,makeConfirm,makePassword

await makeList({
  choices: [
    {
      name: "项目",
      value: "project",
    },
  ],
  message: "请选择初始化类型",
  defaultValue: "project",
});

await makeInput({
  message: "请输入开发语言",
});

await makeConfirm({
  message: `检测到新版本【${latestVersion}】,是否使用最新版本模版?`,
});

await makePassword({
  message: "请输入token信息",
});

getLatestVersion 获取 npm 最新的版本号

const lastVersion = await getLatestVersion(npmName);

checkGlobalUpdate 检测 npm 包是否有新版本

const importMeta = import.meta;
checkGlobalUpdate(importMeta);

welcome 欢迎语

const importMeta = import.meta;
welcome(importMeta);

checkNodeVersion 检测 Node 版本

checkNodeVersion("14.0.0");

getPkgInfo package.json 转 JSON

const importMeta = import.meta;
const pkg = getPkgInfo(importMeta);

getDirname 获取执行文件的目录路径

const importMeta = import.meta;
const dirname = getDirname(importMeta);

getFilename 获取执行文件的路径

const importMeta = import.meta;
const filename = getFilename(importMeta);

exception

  • node 全局异常、promise 异常打印控制台
exception();