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

type-task

v0.5.5

Published

type-task is task manager via AOP, IOC.

Downloads

16

Readme

packaged type-task

This repo is for distribution on npm. The source for this module is in the main repo. Please file issues and pull requests against that repo.

type-task is task manager via AOP, IOC.

Install

  1. install modules:
npm install -g type-task
  1. install cil:
npm install type-task

use command: type-task [task names] [--param param]

taskname: decorator class with @Task('taskname') or @TaskModule({name:'taskname'}).

You can import modules:

Doc

Define Task

  • Single task
@Task('test')
class SimpleTask extends AbstractTask implements ITask {

    constructor(name: string) {
        super(name);
    }

    run(): Promise<any> {
        // console.log('before simple task:', this.name);
        return Promise.resolve('simple task')
            .then(val => {
                console.log('return simple task:', val);
                return val;
            });
    }
}
  • Component task
@Task
class DelComponentTask extends TaskElement {
    execute(data?: any): Promise<any> {
        return del(['lib/**']);
    }
}
  • Task module
@TaskModule({
    providers: <IPipeElementProvider>{
        name: 'tscomplie',
        src: 'src/**/*.ts',
        dest: 'lib',
        pipes: [
            (ctx) => cache('typescript'),
            (ctx) => classAnnotations(),
            sourcemaps.init,
            (ctx) => tsProject()
        ]
    },
    task: PipeElement
})
class TsCompile extends TaskElement {
}

Run task

see interface

1.
let container = new TaskContainer(__dirname, moudles)
2.
TaskContainer.create(__dirname, moudles)
    .bootstrap(<IConfigure>{
        ...
        task:...
    });
3.
TaskContainer.create(__dirname, moudles)
    .bootstrap(TestTask);
4.
TaskContainer.create(__dirname)
    .bootstrap([TestTask, TsCompile, <IConfigure>{
        ...
        task: ...
    }]);

Simples

more simples see

import { Task, ITask, taskSymbols, TaskContainer, AbstractTask, TaskElement, PipeElement, ITaskComponent, IConfigure, PipeComponent, IPipeElementProvider, TaskModule, ITransform, Src, PipeExpress, RunWay, TransformExpress, TransformType } from 'type-task';
import * as mocha from 'gulp-mocha';

const del = require('del');
const cache = require('gulp-cached');
const ts = require('gulp-typescript');
const sourcemaps = require('gulp-sourcemaps');
const uglify = require('gulp-uglify');
import { classAnnotations } from 'typescript-class-annotations';
import { isFunction, isBoolean, ObjectMap } from 'tsioc';


@TaskModule({
    providers: <IPipeElementProvider>{
        pipes: [
            () => cache('typescript'),
            sourcemaps.init,
            () => classAnnotations(),
            (ctx, config) => {
                let target = config.moduleTarget as TsCompile;
                if (target.tsconfig) {
                    return ts(target.tsconfig);
                } else {
                    let tsProject = ts.createProject(ctx.toRootPath(target.tsconfigFile || './tsconfig.json'));
                    return tsProject();
                }
            }
        ],
        destPipes: {
            js: [
                (ctx, config, transform) => {
                    let trans: ITransform = transform.js;
                    trans.changeAsOrigin = true;
                    return trans;
                },
                (ctx, config) => {
                    let target = config.moduleTarget as TsCompile;
                    if (target.uglify) {
                        return isBoolean(target.uglify) ? uglify() : uglify(target.uglify);
                    }
                    return null;
                },
                (ctx) => sourcemaps.write('./sourcemaps')
            ],
            dts: [
                (ctx, config, transform) => {
                    let tans: ITransform = transform.dts;
                    tans.changeAsOrigin = true;
                    return tans;
                }
            ]
        }
    },
    task: PipeElement
})
export class TsCompile extends TaskElement {

    constructor(name: string, runWay?: RunWay, public src?: Src, public dest?: Src,
        private tsPipes?: TransformExpress, private jsPipes?: TransformExpress,
        public tsconfigFile?: string, public tsconfig?: ObjectMap<any>, public uglify?: boolean | ObjectMap<any>) {
        super(name, runWay);
    }

    onInit() {
        let providers = this.config.providers as IPipeElementProvider;

        console.log('src:', this.src, 'dest:', this.dest, 'providers:', providers);

        if (this.src) {
            providers.src = this.src;
        }

        if (this.dest) {
            providers.dest = this.dest;
        }

        if (this.tsPipes) {
            let pipes: TransformType[] = isFunction(providers.pipes) ? providers.pipes(this.context, this.config) : providers.pipes;
            let tsPipes: TransformType[] = isFunction(this.tsPipes) ? this.tsPipes(this.context, this.config) : this.tsPipes;
            pipes.splice(1, 0, ...tsPipes);
            providers.pipes = pipes;
        }

        if (this.jsPipes) {
            let destPipes: any = isFunction(providers.destPipes) ? providers.destPipes(this.context, this.config) : providers.destPipes;
            destPipes.js = isFunction(destPipes.js) ? destPipes.js(this.context, this.config) : destPipes.js;
            let jsPipes: TransformType[] = isFunction(this.jsPipes) ? this.jsPipes(this.context, this.config) : this.jsPipes;
            destPipes.js.splice(1, 0, ...jsPipes);
            providers.destPipes = destPipes;
        }
        this.config.providers = providers;
    }
}

@TaskModule({
    providers: {
        name: 'test',
        src: 'test/**/*.spec.ts',
        awaitPiped: true,
        pipes: [() => mocha()]
    },
    task: PipeElement
})
class TestTask extends TaskElement {
    execute(data?: any): Promise<any> {
        return del(['lib/**', 'bin/**']);
    }
}

TaskContainer.create(__dirname)
    .bootstrap([
        TestTask,
        {
            providers: {
                name: 'tscompLIB',
                src: ['src/**/*.ts', '!src/cli/**'],
                dest: 'lib',
                uglify: true
            },
            task: TsCompile
        },
        {
            providers: {
                name: 'tscompCLI',
                src: 'src/cli/*.ts',
                dest: 'bin',
                uglify: true
            },
            task: TsCompile
        }]);

Documentation github

Documentation is available on the type-task docs site.

License

MIT © Houjun