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

wcrane-tool

v1.0.51

Published

脚手架集合,目前支持 npm 发布

Downloads

99

Readme

脚手架集合

安装

  1. 全局安装
npm i -g wcrane-tool
  1. 局部安装
npm i -D wcrane-tool

使用

pkg

介绍

该指令用于发布npm包,并同步到git仓库中

特点:

  • 支持自定义配置
  • 支持自定义发布
  • 支持自定义git tag
  • 支持自定义版本号
  • 支持自定义发布前、发布后操作
  • 支持自定义发布目录
  • 支持自定义git仓库根目录
  • 支持自定义git tag格式
  • 支持自定义版本号等级

init

初始化配置,生成配置文件

  • 使用
pkg init

publish

发布到npm & 同步到git

  • 使用:
pkg publish
支持自定义配置

esm配置文件

import { execSync } from 'child_process'
export default{
    // 发布目录
    root: ".",
    // git 仓库根目录, 不填写则跟root一致
    gitRoot: '.',
    // 是否同步git
    syncGit: true,
    // 是否同步git tag
    syncGitTag: true,
    // 升级版本号的等级
    versionLevel: 'patch', // major | minor | patch
    // 自定义发布
    customPublish: false,
    
    // 发布前执行
    before() {
        // console.log(config)
    },
    // 发布后执行
    after() {
        // console.log(config)
    },
    // git tag 格式
    gitTagFormat: (version) => {
        return `v${version}`
    },
}

cjs模式的配置文件将导出修改为

module.exports = {
    
}

实践案例

发布 tinypng-lib-wasm wasm 的包

  1. 项目发布前 构建wasm包,构建完成之后同步 README.md中的说明到 tinypng-lib-wasm npm包中
  2. 构建后修改Cargo.toml中的版本号
  3. 发布到npm & 同步到git & 打tag(release/v1.0.0)
const fs = require('fs');
const path = require('path');
const { execSync } = require('child_process');
module.exports = {
    // 发布目录
    root: "./pkg",
    // 是否同步git
    syncGit: true,
    // 是否同步git tag
    syncGitTag: true,
    // 升级版本号的等级
    versionLevel: 'patch', // major | minor | patch
    // 自定义发布
    customPublish: false,
    // git 仓库根目录
    gitRoot: '.',
    // 发布前执行
    before(config) {
        // 构建wasm 
        execSync('npm run build'); // 或者使用 wasm-pack build --target bundler
        // 拷贝当前目录下的 README 到 ./pkg下
        const pkgDir = path.resolve(__dirname, 'pkg');
        const pkgReadmePath = path.resolve(pkgDir, 'README.md');

        if (!fs.existsSync(pkgDir)) {
            fs.mkdirSync(pkgDir);
        }
        fs.copyFileSync(path.resolve(__dirname, 'README.md'), pkgReadmePath);
    },
    // 发布后执行
    after(config) {
        // 修改Cargo.toml 中的版本号
        const pkgDir = path.resolve(__dirname, '.');
        const pkgTomlPath = path.resolve(pkgDir, 'Cargo.toml');
        const pkgToml = fs.readFileSync(pkgTomlPath, 'utf-8');
        const newPkgToml = pkgToml.replace(/version = ".*?"/, `version = "${config.version}"`);
        fs.writeFileSync(pkgTomlPath, newPkgToml, 'utf-8');
    },
    // git tag 格式
    gitTagFormat: (version) => {
        return `release/v${version}`
    },
}