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

@pluve/version-output-cli

v0.0.2

Published

The version output cli

Downloads

4

Readme

@pluve/version-output-cli

npm (scoped)

关于

通用型版本构建命令行工具,在原始构建输出目录下,输出以下文件:

  • version.jsonversion.js - 记录最新版本号
  • 对外入口文件(默认为 main.html)- 当访问入口文件时,从 version.jsonversion.js 获取最新版本号, 匹配一定的规则跳转到对应的版本号文件路径
  • {version} - 版本文件夹,内容为原始输出文件

安装

yarn add @pluve/version-output-cli -D

使用

在打包命令执行完成后执行version-output命令

// package.json
{
  "name": "demo",
  "version": "1.0.0",
  "private": true,
  "scripts": {
    "build:testing": "xxx && version-output --output dist --main-file-name index.html --vconsole",
    "build:product": "xxx && version-output --output dist --main-file-name index.html",
  }
}

配置参考

version-output -h

转发规则

入口文件转发规则如下:

[path]/[mainHtml]#/t/[m] -> [path]/[version]/[n]

  • path - url基础路径
  • mainHtml - 入口文件,如 main.html
  • t - 固定值
  • m - 转发后的路径,使用 先encodeURIComponentbase64(window.btoa) 编码
  • version - 构建的版本号
  • n - 解码m得到的路径

示例

假设存在项目构建后结构如下,存在订单号为1的订单详情页,访问地址为 https://example.com/html/rest/order.html?orderCode=1

├── html							
│   ├── rest				      
│   │   ├── order.html
│   │   └── orders.html
└── 

现在,我们将此项目使用 @pluve/version-output-cli 并在项目构建完成后执行 version-output --output dist --main-file-name index.html, 则最终的输出结构变更为(假设执行版本构建时间为 2024/03/14 09:50):

├── 202403140950							
│   ├── html				      
│   │   ├── rest
│   │   │   ├── order.html   
│   │   │   └── orders.html
├── version.json
└── index.html

现在,我们对外提供的订单号为1的订单详情页则调整为 https://example.com/index.html#/t/aHRtbCUyRnJlc3QlMkZvcmRlci5odG1sJTNGb3JkZXJDb2RlJTNEMQ==, 最终转发到 https://example.com/index.html#/t/aHRtbCUyRnJlc3QlMkZvcmRlci5odG1sJTNGb3JkZXJDb2RlJTNEMQ==

注1: aHRtbCUyRnJlc3QlMkZvcmRlci5odG1sJTNGb3JkZXJDb2RlJTNEMQ==window.btoa(encodeURIComponent('html/rest/order.html?orderCode=1')) 的结果 https://example.com/202403140950/html/rest/order.html?orderCode=1