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

dynamic-pack

v2.1.5

Published

[TOC]

Downloads

7

Readme

[TOC]

文档版本

2.1.5

2.0特性

  • 文件配置 原来由命令行参数输入的部分,改为由dp.config.json进行配置

支持的命令参数

目前支持以下三种命令:

  • -h --help 输出帮助列表
  • -v --version 输出当前dynamic-pack版本
  • -c --config 读取配置执行脚本,下面会详细介绍,默认为./dp.config.json

使用

可以直接作为命令行执行,不过推荐放到package.json作为打包指令:

//package.json
{
    scripts:{
        "build-csfs": "dp --classify=csfs" //classify用于指定dp.config.json中的配置项
    }
}

-c --config

配置示例,例如dp.config.json:

配置文件命名和存放位置可自由控制,无特殊要求,推荐放在根目录下

{
  "classify": "ubs",
  "isRecovery": true,
  "scripts": [
    "dp -v",
    "dp -h",
    "dp --test",
    "mockDp --test"
  ],
  "errorLogPath": "./",
  "classifyConfig":{
    "ubs": {
      "sourceFile": "./files/otherMain.js",
      "targetFile": "./files/main.js",
      "moduleConfig": [
        {
          "filePath": "./files/children/file.js",
          "replaceModules": [
            {
              "source": "import C from './C';",
              "target": "import C from './testC';"
            },
            {
              "source": "import D from './D';",
              "target": "import D from './testD';"
            }
          ]
        }
      ]
    }
  }
}

isRecovery

指定脚本执行完成后是否将文件还原至初始状态

如果不设置isRecovery,或isRecovery设置为false则不执行还原

scripts

配置自定义执行脚本,脚本执行时机在核心处理之后,还原处理之前。

注意事项:

  • 如果不设置scripts,或scripts设置为空则不会执行
  • 目前scripts只支持串行执行【同步模式】

errorLogPath

错误日志生成路径,如果不配置则默认是./,即dp.config.json所在目录

classifyConfig

根据需要可以配置多个子项,每个子项分别对应不同分类,根据classify选取对应分类配置执行

设置MainPanel

关键路由文件,决定此分类下使用的View

相关配置:

  • "sourceFile":此次处理选择的文件
  • "targetFile":此处处理需要替换的文件

moduleConfig 处理相同View下的不同功能模块

实际项目中有版本存在特定需求,比如一般客户都是用A功能模板,但是客户ubs对功能A模板有定制化需求,使用UBS_A模块。

针对这一类需求,可以配置moduleConfig

如果没有这种需求,则对应分类下可以不配置此项

  • filePath 对应View文件路径
  • replaceModules 需要替换的功能模块集合
    • source 此分类下需要的功能模块
    • target 被替换的功能模块

运行生命周期

  1. 根据classifyConfig[classify]进行核心处理
    1. 替换MainPanel
    2. 替换功能模块
    3. 生成packInfo.json文件,包含classifyupdateTime
  2. 自定义脚本执行
  3. 执行还原指令

错误日志

错误日志仅在发生错误时生成。错误日志的名称是dp_error_log_加上当前格林威治时间数值,比如:dp_error_log_1626141795237.txt

如果想要快速查看错误日志的生成时间,脚本在日志最开始一行插入了生成时间,格式如:Log output time:2021-7-13 10:46:28