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

workflow-admin

v1.0.5

Published

每个项目都需要有自己的研发、打包工作流。这个工作流包含多个步骤,都需要输出一些信息和收集运行日志。

Downloads

41

Readme

工作流程管理

每个项目都需要有自己的研发、打包工作流。这个工作流包含多个步骤,都需要输出一些信息和收集运行日志。

workflow-admin 小工具可以协助项目管理编译任务,并逐个工作区去运行这些流程,最终返回输出收集到的信息。

我们将仓库工作流分成了 "流程任务" 和 "工作区"。

流程任务就是一个最基础的编译或者操作任务,例如使用 tsc 编译,使用 lessc 编译,甚至是移动文件到指定位置。

工作区则是 mono repo 思路下诞生的产物,每一个仓库里可能有非常多的需要使用相同工作流程的模块,每个模块就是一个 "工作区",当执行 tsc 编译的时候,会循环每一个工作区都执行一遍。

安装

npm install workflow-admin

开始使用

在开始流程的入口文件内初始化所有的 "流程任务",例如 tsc 编译、lessc 编译等任务。

workflow.register('tsc', {
    // 显示的任务名称
    title: 'Build Typescript',
    // 同时允许并发处理的数量
    parallel: 2,
    // 单前任务运行前,执行的回调
    pre() {
        this.time = Date.now();
    },
    // 当前任务运行完毕后,执行的回调
    post() {
        console.log(`总耗时: ${Date.now() - this.time}ms`);
    },
    // 当前任务,在每个工作区执行的实际逻辑
    async execute(config) {
        // 调用 spawn 执行 tsc 任务
        // return 'error';
        return 'success';
    },
});

然后我们需要注册每一个工作区。

workflow.addWorkspace('/Downloads/a');
workflow.addWorkspace('/Downloads/b');

设置工作区内的配置文件名字。

workflow.config({
    entry: '.config.js',
});

这样工作流在每个工作区内,就会自动去寻找配置文件。

同时我们需要在工作区里放一个配置文件,可以这样注册配置文件名称。

配置文件里里暴露的名字是注册任务的时候的名字,例如下面 tsc 传出了一个数组,在执行 tsc 任务的时候,就会将数组传递给任务作为入参。

exports.tsc = function(params) {
    return [];
};

最终我们准备好数据后,就可以执行某一个或者一些的任务。

// 执行
workflow.execute('js').then((results) => {
    console.log(results.length)
    console.log(results);
});

开发

编译:

tsc

测试:

npm run test