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

sofa-scripts

v1.2.1

Published

sofa入口;

Downloads

14

Readme

sofa-scripts

sofa入口;

对外需求

对于外部的需求,需要明确方法名、导入方式、input、output、同步异步等;

  1. sofa-config: 检查是否存在有效的sofa.global.config.json文件;异步方法?同步方法?
  2. sofa-dev-utils: 与用户交互获取用户输入信息;
  3. sofa-database-helper: 测试数据库是否能够正常连接;
  4. sofa-git-helper: 检查是否安装Git;可以以伪代码示意;
  5. sofa-config: 初始化sofa.global.config.json文件,将文件持久化到用户系统;
  6. sofa-config: 将db配置写入到sofa.global.config.json文件;
  7. sofa-git-helper: 检查是否登录Git;可以以伪代码示意;
  8. sofa-git-helper: 获取当前git仓库关联的远程地址;
  9. sofa-dev-utils: 获取项目根路径;
  10. sofa-dev-utils: 获取模板根路径;
  11. sofa-dev-utils: 控制台打印,成功消息;
  12. sofa-dev-utils: 控制台打印,警示消息;
  13. sofa-dev-utils: 控制台打印,错误、失败消息;

全局安装

npm i sofa-scripts -g

全局安装成功后,可使用 sofa 命令;

A lot of packages have one or more executable files that they’d like to install into the PATH. npm makes this pretty easy (in fact, it uses this feature to install the “npm” executable.) To use this, supply a bin field in your package.json which is a map of command name to local file name. On install, npm will symlink that file into prefix/bin for global installs, or ./node_modules/.bin/ for local installs.

命令

安装后执行脚本

  1. 检查是否存在有效的sofa.global.config.json文件;
  2. 若不存在,执行init命令;

init

初始化用户配置,会直接重写sofa.global.config.json文件;需要确定sofa.global.config.json文件放在哪个位置比较合适;

  • 1 初始化db配置,与用户交互,要求用户输入数据库连接地址;
  • 2 获取用户输入后,测试是否能够正常连接到数据库;
  • 3.1 连接成功,将db配置写入到sofa.global.config.json;
  • 3.2 连接失败,提示用户重新输入;
  • 4 检查Git是否安装;
  • 5.1 未安装,提示安装Git,退出;
  • 5.2 已安装;
  • 6 检查Git是否登录;
  • 6.1 未登录,提示登录Git,退出;
  • 6.2 已登录,提示初始化成功,退出;

set

当前sofa.global.config.json中仅存在db一项配置;

help

给出完整的命令范围和命令示例;

命令分发

sofa-scripts是sofa命令的入口,需要将所有命令向下进行分发,此外还有基础命令校验;

  • init 不需要参数,直接本模块调用;
  • set 不需要参数,直接本模块调用;
  • publish <type> 将用户输入参数、templateRootPath、config作为参数,调用template模块;
  • update <type> [updateConfigPath] 将用户输入参数、templateRootPath、config作为参数,调用template模块;
  • remove <type> [id] 将用户输入参数,调用template模块;
  • search <type> [keyword] 将用户输入参数作为参数,调用template模块;
  • create <type> 将用户输入参数、projectRootPath、config作为参数,调用factory模块;如果是project,将当前目录作为projectRootPath,config为空;若为module、component则向上查找到sofa.config.js,将此路径设置为projectRootPath,配置文件内容设置为config;
  • add <type> 将用户输入参数、projectRootPath、config作为参数,调用factory模块;如果是project,将当前目录作为projectRootPath,config为空;若为module、component则向上查找到sofa.config.js,将此路径设置为projectRootPath,配置文件内容设置为config;