@tsdi/pack
type task framework, base on AOP, Ioc container, via @tsdi. dev build pack activities.
Last updated 7 days ago by houjun .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @tsdi/pack 
SYNC missed versions from official npm registry.

packaged @tsdi/pack

@tsdi/pack is project build pack tools, base on AOP, Ioc container, via @tsdi. file stream pipes activities.

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.

Install

  1. install modules:
npm install @tsdi/pack
  1. install cli | build pack:

cli in global

npm install -g '@tsdi/cli'

build pack

npm install '@tsdi/pack'

use command: tsdi run [taskfile.ts], tsdi run [taskfile.js] use command: tsdi build [options]

You can import modules:

Doc

Define Task

  • define task component or attr task item.

@Task('clean, [clean]')
export class CleanActivity extends Activity<void> {

    @Input()
    protected clean: Expression<Src>;


    constructor(@Input() clean?: Expression<Src>) {
        super()
        this.clean = clean;
    }

    protected async execute(ctx: NodeActivityContext): Promise<void> {
        let clean = await this.resolveExpression(this.clean, ctx);
        if (clean) {
            await ctx.del(ctx.toRootSrc(clean), {force: true});
        }
    }
}


  • control flow activities.

see control flow codes

Define component Task

export interface LibTaskOption {
    clean?: Binding<Expression<Src>>;
    src?: Binding<Expression<Src>>;
    dist?: Binding<Expression<Src>>;
    uglify?: Binding<Expression<boolean>>;
    tsconfig?: Binding<Expression<string | CompilerOptions>>;

    /**
     * rollup input.
     *
     * @type {Binding<Expression<string>>}
     * @memberof LibTaskOption
     */
    input?: Binding<Expression<string>>;
    /**
     * rollup output file.
     *
     * @type {Binding<string>}
     * @memberof LibTaskOption
     */
    outputFile?: Binding<Expression<string>>;
    /**
     * rollup output dir.
     *
     * @type {Binding<string>}
     * @memberof LibTaskOption
     */
    outputDir?: Binding<Expression<string>>;
    /**
     * rollup format option.
     *
     * @type {Binding<string>}
     * @memberof LibTaskOption
     */
    format?: Binding<Expression<string>>;
}

@Task({
    selector: 'libs',
    template: {
        activity: 'each',
        each: 'binding: tasks'
        body: [
            {
                activity: 'if',
                condition: ctx => ctx.body.src,
                body: <TsBuildOption>{
                    activity: 'ts',
                    clean: ctx => ctx.body.clean,
                    src: ctx => ctx.body.src,
                    test: ctx => ctx.body.test,
                    uglify: ctx => ctx.body.uglify,
                    dist: ctx => ctx.body.dist,
                    annotation: true,
                    sourcemaps: './sourcemaps',
                    tsconfig: ctx => ctx.body.tsconfig
                }
            },
            {
                activity: Activities.if,
                condition: ctx => ctx.body.input,
                body: <RollupOption>{
                    activity: 'rollup',
                    input: ctx => ctx.body.input,
                    plugins: 'binding: plugins',
                    external: 'binding: external',
                    options: 'binding: options',
                    output: ctx => {
                        return {
                            format: ctx.body.format || 'cjs',
                            file: ctx.body.outputFile,
                            dir: ctx.body.outputDir,
                            globals: ctx.scope.globals
                        }
                    }
                }
            }
        ]
    }
})
export class LibPackBuilder implements AfterInit {

    constructor(private yourService: ServiceClass){

    }
    /**
     * tasks
     *
     * @type {(Expression<LibTaskOption|LibTaskOption[]>)}
     * @memberof LibPackBuilderOption
     */
    @Input()
    tasks: Expression<LibTaskOption | LibTaskOption[]>;
    /**
     * rollup external setting.
     *
     * @type {Expression<ExternalOption>}
     * @memberof RollupOption
     */
    @Input()
    external?: Expression<ExternalOption>;
    /**
     * rollup plugins setting.
     *
     * @type {Expression<Plugin[]>}
     * @memberof RollupOption
     */
    @Input()
    plugins?: Expression<Plugin[]>;

    @Input()
    cache?: Expression<RollupCache>;

    @Input()
    watch?: Expression<WatcherOptions>;
    /**
     * custom setup rollup options.
     *
     * @type {(Expression<RollupFileOptions | RollupDirOptions>)}
     * @memberof RollupOption
     */
    @Input()
    options?: Expression<RollupFileOptions | RollupDirOptions>;


    async onAfterInit(): Promise<void> {
        // to do init you component
        // this.yourService.
    }


}

Run task

  • use coustom task component.
@Task({
    deps: [
        PackModule,
        ServerActivitiesModule
    ],
    imports:[ LibPackBuilder ],
    baseURL: __dirname,
    template: <LibPackBuilderOption>{
        activity: 'libs',
        tasks:[
            { src: 'src/**/*.ts', clean: ['../../dist/pack/lib'], dist: '../../dist/pack/lib', uglify: false, tsconfig: './tsconfig.json' }
        ]
    }
})
export class PackBuilder implements AfterInit {
    onAfterInit(): void | Promise<void> {
        console.log('pack build has inited...')
    }
}

  • run task.
// 1. run modue
Workflow.run(PackBuilder);


// 2. run option
Workflow.run({
    name: 'test1',
    template: [
        {
            name: 'test------1',
            activity: SimpleTask
        },
        SimpleCTask
        // {
        //     name: 'test------2',
        //     activity: SimpleCTask
        // }
    ]

});

Documentation github

Documentation is available on the type-task docs site.

License

MIT © Houjun

Current Tags

  • 5.1.19                                ...           latest (7 days ago)

60 Versions

  • 5.1.19                                ...           7 days ago
  • 5.1.18                                ...           8 days ago
  • 5.1.17                                ...           11 days ago
  • 5.1.16                                ...           12 days ago
  • 5.1.15                                ...           20 days ago
  • 5.1.14                                ...           21 days ago
  • 5.1.13                                ...           22 days ago
  • 5.1.12                                ...           a month ago
  • 5.1.11                                ...           a month ago
  • 5.1.10                                ...           a month ago
  • 5.1.8                                ...           a month ago
  • 5.1.7                                ...           a month ago
  • 5.1.6                                ...           a month ago
  • 5.1.3                                ...           a month ago
  • 5.1.1                                ...           a month ago
  • 5.1.0                                ...           a month ago
  • 5.0.24                                ...           2 months ago
  • 5.0.23                                ...           2 months ago
  • 5.0.22                                ...           2 months ago
  • 5.0.21                                ...           2 months ago
  • 5.0.20                                ...           2 months ago
  • 5.0.19                                ...           2 months ago
  • 5.0.18                                ...           2 months ago
  • 5.0.18-beta                                ...           2 months ago
  • 5.0.15                                ...           2 months ago
  • 5.0.13                                ...           2 months ago
  • 5.0.12                                ...           2 months ago
  • 5.0.11                                ...           2 months ago
  • 5.0.10                                ...           2 months ago
  • 5.0.8                                ...           2 months ago
  • 5.0.7                                ...           2 months ago
  • 5.0.5                                ...           2 months ago
  • 5.0.4                                ...           2 months ago
  • 5.0.3                                ...           2 months ago
  • 5.0.2                                ...           2 months ago
  • 5.0.1                                ...           2 months ago
  • 5.0.0-beta25                                ...           2 months ago
  • 5.0.0-beta24                                ...           2 months ago
  • 5.0.0-beta23                                ...           3 months ago
  • 5.0.0-beta22                                ...           3 months ago
  • 5.0.0-beta20                                ...           3 months ago
  • 5.0.0-beta19                                ...           3 months ago
  • 5.0.0-beta18                                ...           3 months ago
  • 5.0.0-beta17                                ...           3 months ago
  • 5.0.0-beta16                                ...           3 months ago
  • 5.0.0-beta15                                ...           3 months ago
  • 5.0.0-beta14                                ...           3 months ago
  • 5.0.0-beta12                                ...           3 months ago
  • 5.0.0-beta11                                ...           3 months ago
  • 5.0.0-beta10                                ...           3 months ago
  • 5.0.0-beta9                                ...           3 months ago
  • 5.0.0-beta8                                ...           3 months ago
  • 5.0.0-beta7                                ...           3 months ago
  • 5.0.0-beta6                                ...           3 months ago
  • 5.0.0-beta5                                ...           3 months ago
  • 5.0.0-beta4                                ...           3 months ago
  • 5.0.0-beta3                                ...           3 months ago
  • 5.0.0-beta2                                ...           3 months ago
  • 5.0.0-beta1                                ...           3 months ago
  • 5.0.0-beta                                ...           3 months ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 85
Last Day 0
Last Week 54
Last Month 428
Dependencies (41)
Dev Dependencies (0)
None
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |