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

@wecity/weshop

v2.3.10

Published

微前端模型

Downloads

3

Readme

weshop 工具

介绍

模块化开发是一种开发模式,而 weshop 合包工具是为了实现模块化开发这种模式而诞生的CLI工具。

主要解决模块化独立开发后,保证子模块的独立开发和主模块的合包功能能够相互独立,同时提供一些其他的如代码规范校验等功能。

安装

安装 weshop

npm install -g @wecity/weshop

安装结束之后,你可以通过 weshop -v 命令来查看版本。

环境要求

  • node v8+。node -v 查看当前的 Node 版本。
  • git v2+。git --version 查看当前的 git 版本。

weshop.config.json 配置项说明

{
  // 类型
  "type": "miniprogram",
  // ssh 连接限制
  "sshLimit": 10,
  // 主包配置,仓库地址和分支
  "mainPackage": {
    "url": "xxx/main-app.git",
    "branch": "master"
  },
  // 子包配置,仓库地址和分支
  "subPackages": [{
      "url": "xxx/gss-canlian.git",
      "branch": "master"
    }
  ],
  // 开发依赖,仓库地址/分支/拷贝路径
  "dependencies": [{
      "url": "xxx/gsd-kit.git",
      "branch": "master",
      // 拷贝路径,从哪到哪,from -> to
      "copy": [{
          "from": "dist/components/gsd-ui",
          "to": "components/gsd-ui"
        },
        {
          "from": "dist/components/dgd-sdk",
          "to": "components/dgd-sdk"
        },
        {
          "from": "dist/pages/gsd-ui",
          "to": "pages/gsd-ui"
        }
      ]
    },
    {
      "url": "xxx/main-app.git",
      "branch": "master",
      "copy": [{
        "from": "main-app.js",
        "to": "main-app.js"
      }]
    }
  ],
  // 环境配置,仅支持 dev/test/stage/prod 自由配置
  "env": {
    "dev": {
      // config 内容最终会写入项目的 constant/config.js 进行替换覆盖
      "config": {
        "appid": "xxx",
        "paasid": "gss",
        "projectName": "GSS主框 dev 环境",
        "domain": "https://xxx.cn",
	"cdnDomain": "https://xxx.com"
        // 其他参数可自定义
      }
    },
    "prod": {
      "config": {
        "appid": "",
        "paasid": "gss",
        "projectName": "主框 prod 环境",
        "domain": "https://xxx.cn",
	"cdnDomain": "https://xxx.com"
      },
      // CDN 配置
      "cdn": {
        // 图片域名
        "publicPath": "https://xxx.com/",
        // 是否根据 URl 路径生成文件夹,默认是 true
        "dirs": true,
        // 最大可接受的图片(告警)
        "maxSize": 51200,
        // 哪些图片不需要 CDN 处理
        "excludes": [
          "markers",
          "home-icon"
        ]
      },
      // 压缩配置
      "uglify": {
        // 是否去除 console(耗时)
        "dropConsole": false,
        // 哪些文件无需压缩
        "excludes": [
          "thrid/echarts/index.js"
        ]
      }
    }
  },
  // 支持修改微信全局函数
  "wxFn": {
    "Page": "getApp().sdk.Page"
  }
}

命令简介

# 合并
weshop a --env dev

# 本地代码合并
weshop a -d

# 更新依赖
weshop u

# 检查代码
weshop lint

# 查看更新日志
weshop changelog

更新命令 update

更新依赖,读取 weshop.config.json 里 dependencies 配置的依赖,并更新到当前项目的指定目录

使用方法

weshop update
# 简写命令 weshop u

注意事项

::: tip 优先使用主模块的 weshop.config.json

  • 对于子模块更新依赖时, weshop 会先从主模块拉取一份最新的 weshop.config.json 文件,然后根据这个文件来进行更新。
  • 对于子模块 weshop.config.json 只有第一行的 mainPackage 修改是有效的,可以通过修改 branch 来决定拉取主程序哪个分支的 weshop.config.json。 :::

::: tip 更新失败? 由于 Window 系统下的 微信开发者工具 会占用当前项目的文件,因此 Window 用户使用 updateassemble 命令的时候,需要先关闭 微信开发者工具。 :::

合包命令 assemble

将主模块和子模块合并成一个小程序

使用方法

weshop a
# 详细命令 weshop assemble

环境选择

参数使用方法是 --env <env> 。根据 weshop.config.json 里的 env 参数来切换合包环境,目前可选环境有 stage test prod test。默认是 dev 环境。

weshop a --env prod

本地合包

进行本地合包时,会选择使用本地的代码进行合并,方便进行合包调试。

weshop a -d

注意事项

使用合包命令 weshop a 时,主模块还是子模块会稍微有不同的实现。

1. 主模块

主模块下,subPackages 的配置才会生效,可以自行选择需要合包的仓库。合包结果包含主模块和 subPackages 里的所有项目。

2. 子模块

子模块下,会根据 mainPackagedependencies 的配置来拉取对应的主模块和组件依赖。合包结果只包含当前子模块和主模块

更新命令 update

可以更新依赖文件,还可以更新主模块的 weshop.config.json / main-app.js 等依赖文件

weshop update

初始化脚手架 init

初始化前,请先确定 ~/.weshoprc.json 已经配置了 template.maintemplate.sub 的仓库地址。

weshop init

本地配置 config

weshop config      		查看命令
weshop config list 		查看配置
weshop config get <key>         获取配置
weshop config set <key> <value> 设置配置
weshop config delete <key>      删除配置