New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

development-core

Package Overview
Dependencies
Maintainers
1
Versions
71
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

development-core

development build tools.

  • 0.5.5
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
11
increased by83.33%
Maintainers
1
Weekly downloads
 
Created
Source

packaged development-core

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. This package use to develop kit for project development via gulp tasks.

Development core can generate tasks, run task in sequence via Promise.

Install

You can install this package either with npm.

npm


npm install development-core

You can import modules:

import module

import * as gulp from 'gulp';
import  { generateTask, runTaskSequence, runSequence } from 'development-core';

run task by sequence via Promise


    runSequence('taskA', ['taskb','taskc'], 'taskd');

define task and taskdefine.

decorator not support function now, so refactor ITask interface.


// module A
import { taskdefine, bindingConfig, Operation, ITaskOption, IEnvOption, ITaskConfig, ITaskDefine, ITask, ITaskInfo, TaskResult, task, dynamicTask, IDynamicTasks } from 'development-core';

@dynamicTask
export class TestTaskC implements IDynamicTasks {
   tasks(): IDynamicTask[]{
       return [
           {
               name: 'tscompile', src: 'src/**/*.ts', dist: 'lib',
               pipes: [() => cache('typescript'), sourcemaps.init, tsProject],
               output: [
                   (tsmap, config, dt) => tsmap.dts.pipe(gulp.dest(config.getDist(dt))),
                   (tsmap, config, dt) => {
                       if (config.oper === Operation.release || config.oper === Operation.deploy) {
                           return tsmap.js.pipe(babel({ presets: ['es2015'] }))
                               .pipe(uglify()).pipe(sourcemaps.write('./sourcemaps'))
                               .pipe(gulp.dest(config.getDist(dt)));
                       } else {
                           return tsmap.js.pipe(sourcemaps.write('./sourcemaps')).pipe(gulp.dest(config.getDist(dt)));
                       }
                   }
               ]
           },
           {
               name: 'test', src: 'test/**/*spec.ts', order: 1,
               oper: Operation.test | Operation.release | Operation.deploy,
               pipe(src) {
                   return src.pipe(mocha())
                       .once('error', () => {
                           process.exit(1);
                       });
               }
           },
           { src: 'src/**/*.ts', name: 'watch', watch: ['tscompile'] },
           { name: 'clean', order: 0, src: 'src', dist: 'lib', task: (config) => del(config.getDist()) }
       ];
   }
}

@task({
   oper: Operation.build | Operation.test
})
export class TestTaskC implements ITask {
   public decorator: ITaskInfo = {};
   constructor() {
   }
   setup(config: ITaskConfig, gulp): TaskResult {
       // todo...

       let taskname = config.subTaskName('TestTaskC');

       gulp.task(taskname, ()=>{
           gulp.src(config.getSrc())
               .pipe(...)
               ...
               .pipe(gulp.dest(config.getDist()))
       });

       // return task name, enable this task to add in run sequence.
       // or just set to decorator.
       // this.decorator.name = taskname;
       return taskname
   }
}

@taskdefine()
export class TaskDefine implements ITaskDefine {
   loadConfig(oper: Operation, option: ITaskOption, env: IEnvOption): ITaskConfig {
       return bindingConfig({
           oper: oper,
           option: option,
           env: env
       });
   }
}


// module B
import { findTasks, Operation, runTaskSequence, findTaskDefine }  from 'development-core';
let moduleA = require('module a');
let tasks = findTasks(moduleA);
let tdfs = findTaskDefine(moduleA);

// run task;
runTaskSequence(tasks, tdfs.loadConfig(Operation.build, {src:'src', dist:'lib'}, {watch:true}));

Create development tool with dynamic tasks via Promise

import * as gulp from 'gulp';
import { bindingConfig, currentOperation, generateTask, runTaskSequence, IEnvOption, Operation } from 'development-core';
import * as mocha from 'gulp-mocha';
import * as minimist from 'minimist';
import * as _ from 'lodash';

const del = require('del');
const cache = require('gulp-cached');
const ts = require('gulp-typescript');
const sourcemaps = require('gulp-sourcemaps');
let tsProject = ts.createProject('tsconfig.json');
const uglify = require('gulp-uglify');
const babel = require('gulp-babel');

gulp.task('build', () => {
    var options: IEnvOption = minimist(process.argv.slice(2), {
        string: 'env',
        default: { env: process.env.NODE_ENV || 'development' }
    });
    return createTask(options);
});

let createTask = (env) => {
    let oper: Operation = currentOperation(env);
    let config = bindingConfig({
        env: env,
        oper: oper,
        option: { src: 'src', dist: 'lib' }
    });

    let tasks = generateTask([
        {
            name: 'tscompile', src: 'src/**/*.ts', dist: 'lib',
            pipes: [() => cache('typescript'), sourcemaps.init, tsProject],
            output: [
                (tsmap, config, dt) => tsmap.dts.pipe(gulp.dest(config.getDist(dt))),
                (tsmap, config, dt) => {
                    if (config.oper === Operation.release || config.oper === Operation.deploy) {
                        return tsmap.js.pipe(babel({ presets: ['es2015'] }))
                            .pipe(uglify()).pipe(sourcemaps.write('./sourcemaps'))
                            .pipe(gulp.dest(config.getDist(dt)));
                    } else {
                        return tsmap.js.pipe(sourcemaps.write('./sourcemaps')).pipe(gulp.dest(config.getDist(dt)));
                    }
                }
            ]
        },
        {
            name: 'test', src: 'test/**/*spec.ts', order: 1,
            oper: Operation.test | Operation.release | Operation.deploy,
            pipe(src) {
                return src.pipe(mocha())
                    .once('error', () => {
                        process.exit(1);
                    });
            }
        },
        { src: 'src/**/*.ts', name: 'watch', watchTasks: ['tscompile'] },
        { name: 'clean', order: 0, src: 'src', dist: 'lib', task: (config) => del(config.getDist()) }
    ], oper, env);

    return runTaskSequence(gulp, tasks, config);
}

https://github.com/zhouhoujun/development-core.git The mocks are then available at jspm_components/development-core/development-core.js.

Documentation

Documentation is available on the development-core docs site.

License

MIT © Houjun

Keywords

FAQs

Package last updated on 01 Nov 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc