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

development-tool

Package Overview
Dependencies
Maintainers
1
Versions
64
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

development-tool - npm Package Compare versions

Comparing version 0.1.1 to 0.1.5

29

lib/loaderFactory.js
"use strict";
const DirLoader_1 = require('./loaders/DirLoader');
const ModuleLoader_1 = require('./loaders/ModuleLoader');
const _ = require('lodash');
class LoaderFactory {

@@ -8,15 +9,23 @@ constructor() {

create(option) {
let loader = null;
switch (option.loader.type) {
case 'dir':
loader = new DirLoader_1.DirLoader(option);
break;
case 'module':
default:
loader = new ModuleLoader_1.ModuleLoader(option);
break;
if (option.loader['dir']) {
return new DirLoader_1.DirLoader(option);
}
return loader;
if (_.isString(option.loader)) {
return new ModuleLoader_1.ModuleLoader(option);
}
else {
let loader = null;
switch (option.loader.type) {
case 'dir':
loader = new DirLoader_1.DirLoader(option);
break;
case 'module':
default:
loader = new ModuleLoader_1.ModuleLoader(option);
break;
}
return loader;
}
}
}
exports.LoaderFactory = LoaderFactory;

@@ -47,4 +47,6 @@ "use strict";

let tsdef = null;
if (this.option.loader.taskDefine) {
tsdef = this.option.loader.taskDefine;
if (!_.isString(this.option.loader)) {
if (this.option.loader.taskDefine) {
tsdef = this.option.loader.taskDefine;
}
}

@@ -63,3 +65,9 @@ if (!tsdef) {

getConfigModule() {
let ml = this.option.loader.configModule || this.option.loader.module;
let ml;
if (_.isString(this.option.loader)) {
ml = this.option.loader;
}
else {
ml = this.option.loader.configModule || this.option.loader.module;
}
if (_.isString(ml)) {

@@ -73,3 +81,9 @@ return require(ml);

getTaskModule() {
let ml = this.option.loader.taskModule || this.option.loader.module;
let ml;
if (_.isString(this.option.loader)) {
ml = this.option.loader;
}
else {
ml = this.option.loader.taskModule || this.option.loader.module;
}
if (_.isString(ml)) {

@@ -104,3 +118,3 @@ return require(ml);

}
if (this.option.loader.isTaskDefine) {
if (!_.isString(this.option.loader) && this.option.loader.isTaskDefine) {
return this.option.loader.isTaskDefine(mdl);

@@ -114,3 +128,3 @@ }

}
if (this.option.loader.isTaskFunc) {
if (!_.isString(this.option.loader) && this.option.loader.isTaskFunc) {
return this.option.loader.isTaskFunc(mdl);

@@ -117,0 +131,0 @@ }

@@ -49,3 +49,3 @@ /// <reference types="gulp" />

export interface TaskOption {
loader: LoaderOption;
loader: string | LoaderOption;
src?: string;

@@ -52,0 +52,0 @@ dist?: string;

@@ -22,3 +22,3 @@ /// <reference types="gulp" />

protected loadTasks(gulp: Gulp, tasks: TaskOption | TaskOption[], env: EnvOption): Promise<Src[]>;
protected setup(gulp: Gulp, config: TaskConfig, tasks: Task[]): Promise<Src[]>;
protected setup(gulp: Gulp, config: TaskConfig, tasks: Task[], subGroupTask: Src): Promise<Src[]>;
protected loadSubTask(gulp: Gulp, config: TaskConfig): Promise<Src>;

@@ -25,0 +25,0 @@ protected createLoader(option: TaskOption): ITaskLoader;

@@ -63,3 +63,3 @@ "use strict";

return Promise.all(_.map(_.isArray(tasks) ? tasks : [tasks], optask => {
console.log(chalk.grey('begin load task via loader type:'), chalk.cyan(optask.loader.type || 'module'));
console.log(chalk.grey('begin load task via loader:'), optask.loader);
let loader = this.createLoader(optask);

@@ -93,6 +93,10 @@ let oper;

else {
return loader.load(this.bindingConfig(cfg))
.then(tasks => {
console.log(chalk.green('tasks loaded.\n'));
return this.setup(gulp, cfg, tasks);
cfg = this.bindingConfig(cfg);
return this.loadSubTask(gulp, cfg)
.then(subtask => {
return loader.load(cfg)
.then(tasks => {
console.log(chalk.green('tasks loaded.\n'));
return this.setup(gulp, cfg, tasks, subtask);
});
});

@@ -105,3 +109,3 @@ }

}
setup(gulp, config, tasks) {
setup(gulp, config, tasks, subGroupTask) {
return Promise.all(_.map(tasks, t => {

@@ -111,23 +115,20 @@ return t(gulp, config);

.then(ts => {
return this.loadSubTask(gulp, config)
.then(subGroupTask => {
let tsqs = this.toSquence(ts);
if (config.option.runTasks) {
if (_.isFunction(config.option.runTasks)) {
tsqs = config.option.runTasks(config.oper, tsqs, subGroupTask);
}
else {
tsqs = config.option.runTasks;
subGroupTask && tsqs.push(subGroupTask);
}
return tsqs;
let tsqs = this.toSquence(ts);
if (config.option.runTasks) {
if (_.isFunction(config.option.runTasks)) {
tsqs = config.option.runTasks(config.oper, tsqs, subGroupTask);
}
else if (config.runTasks) {
return config.runTasks(subGroupTask);
}
else {
tsqs = config.option.runTasks;
subGroupTask && tsqs.push(subGroupTask);
return tsqs;
}
});
return tsqs;
}
else if (config.runTasks) {
return config.runTasks(subGroupTask);
}
else {
subGroupTask && tsqs.push(subGroupTask);
return tsqs;
}
});

@@ -134,0 +135,0 @@ }

{
"name": "development-tool",
"version": "0.1.1",
"version": "0.1.5",
"description": "development build tools.",

@@ -5,0 +5,0 @@ "main": "./lib/tools.js",

@@ -25,4 +25,50 @@ # packaged development-tool

import { Development, TaskOption } from 'development-tool';
let tasks: TaskOption| TaskOption[];
import { NodeBuildOption } from 'development-tool-node';
// import 'development-tool-*';
let tasks: TaskOption| TaskOption[]= [
<NodeBuildOption>{
src: 'src',
dist: 'lib',
asserts: {
json: 'src/**/*.json',
css: {src: 'src/**/*.css', dist:'lib/style'}
},
loader: 'development-tool-node', //the module must implement ITaskDefine.
tasks: [
{
src: 'files be dealt with',
dist: 'dist',
loader:'development-tool-*' //the module must implement ITaskDefine.
},
{
src: 'src/**/*.css',
dist: 'dist',
loader: {
configModule: path.join(__dirname, './src/task.ts'), //the module must implement ITaskDefine.
dir: [path.join(__dirname, './src/mytasks')]
},
tasks: [
{
src: 'files be dealt with',
dist: 'dist',
loader: {
//./src/mytasks folder must has module implement ITaskDefine.
dir: path.join(__dirname, './src/mytasks')
}
},
{
src: 'files be dealt with',
dist: 'dist',
loader: {
module: path.join(__dirname, './src/mytasks/dosomething'),
configModule: path.join(__dirname, './src/mytasks/config') //the module must implement ITaskDefine.
}
}
]
}
...
]
}
...
];
Development.create(gulp, __dirname, {

@@ -29,0 +75,0 @@ tasks:tasks

import { ITaskLoader } from './ITaskLoader';
import { DirLoader } from './loaders/DirLoader';
import { DirLoader } from './loaders/DirLoader';
import { TaskOption } from './TaskConfig';
import { ModuleLoader } from './loaders/ModuleLoader';
import { ModuleLoader } from './loaders/ModuleLoader';
import * as _ from 'lodash';
/**

@@ -29,15 +29,24 @@ * loader factory.

create(option: TaskOption): ITaskLoader {
let loader = null;
switch (option.loader.type) {
case 'dir':
loader = new DirLoader(option);
break;
// if config dir.
if (option.loader['dir']) {
return new DirLoader(option);
}
case 'module':
default:
loader = new ModuleLoader(option);
break;
if (_.isString(option.loader)) {
return new ModuleLoader(option);
} else {
let loader = null;
switch (option.loader.type) {
case 'dir':
loader = new DirLoader(option);
break;
case 'module':
default:
loader = new ModuleLoader(option);
break;
}
return loader;
}
return loader;
}
}

@@ -56,4 +56,6 @@ import * as _ from 'lodash';

let tsdef: ITaskDefine = null;
if (this.option.loader.taskDefine) {
tsdef = this.option.loader.taskDefine;
if (!_.isString(this.option.loader)) {
if (this.option.loader.taskDefine) {
tsdef = this.option.loader.taskDefine;
}
}

@@ -73,3 +75,9 @@ if (!tsdef) {

protected getConfigModule(): any {
let ml = this.option.loader.configModule || this.option.loader.module;
let ml: string;
if (_.isString(this.option.loader)) {
ml = this.option.loader
} else {
ml = this.option.loader.configModule || this.option.loader.module;
}
if (_.isString(ml)) {

@@ -83,3 +91,9 @@ return require(ml);

protected getTaskModule(): any {
let ml = this.option.loader.taskModule || this.option.loader.module;
let ml: string;
if (_.isString(this.option.loader)) {
ml = this.option.loader
} else {
ml = this.option.loader.taskModule || this.option.loader.module;
}
if (_.isString(ml)) {

@@ -118,3 +132,3 @@ return require(ml);

}
if (this.option.loader.isTaskDefine) {
if (!_.isString(this.option.loader) && this.option.loader.isTaskDefine) {
return this.option.loader.isTaskDefine(mdl);

@@ -130,3 +144,3 @@ }

if (this.option.loader.isTaskFunc) {
if (!_.isString(this.option.loader) && this.option.loader.isTaskFunc) {
return this.option.loader.isTaskFunc(mdl);

@@ -133,0 +147,0 @@ }

@@ -213,6 +213,6 @@ import { Gulp } from 'gulp';

*
* @type {string}
* @memberOf TaskConfig
* @type {(string | LoaderOption)}
* @memberOf TaskOption
*/
loader: LoaderOption;
loader: string | LoaderOption;
/**

@@ -219,0 +219,0 @@ * the project src root folder. default 'src'.

@@ -92,3 +92,3 @@ import * as _ from 'lodash';

_.map(_.isArray(tasks) ? <TaskOption[]>tasks : [<TaskOption>tasks], optask => {
console.log(chalk.grey('begin load task via loader type:'), chalk.cyan(optask.loader.type || 'module'));
console.log(chalk.grey('begin load task via loader:'), optask.loader);
let loader = this.createLoader(optask);

@@ -118,7 +118,10 @@ let oper: Operation;

} else {
// console.log(chalk.grey('load tasks...'));
return loader.load(this.bindingConfig(cfg))
.then(tasks => {
console.log(chalk.green('tasks loaded.\n'));
return this.setup(gulp, cfg, tasks)
cfg = this.bindingConfig(cfg);
return this.loadSubTask(gulp, cfg)
.then(subtask => {
return loader.load(cfg)
.then(tasks => {
console.log(chalk.green('tasks loaded.\n'));
return this.setup(gulp, cfg, tasks, subtask)
});
});

@@ -132,3 +135,3 @@ }

protected setup(gulp: Gulp, config: TaskConfig, tasks: Task[]): Promise<Src[]> {
protected setup(gulp: Gulp, config: TaskConfig, tasks: Task[], subGroupTask: Src): Promise<Src[]> {
return Promise.all(_.map(tasks, t => {

@@ -138,20 +141,17 @@ return t(gulp, config);

.then(ts => {
return this.loadSubTask(gulp, config)
.then(subGroupTask => {
let tsqs: Src[] = this.toSquence(ts);
if (config.option.runTasks) {
if (_.isFunction(config.option.runTasks)) {
tsqs = config.option.runTasks(config.oper, tsqs, subGroupTask);
} else {
tsqs = config.option.runTasks;
subGroupTask && tsqs.push(subGroupTask);
}
return tsqs;
} else if (config.runTasks) {
return config.runTasks(subGroupTask);
} else {
subGroupTask && tsqs.push(subGroupTask);
return tsqs;
}
});
let tsqs: Src[] = this.toSquence(ts);
if (config.option.runTasks) {
if (_.isFunction(config.option.runTasks)) {
tsqs = config.option.runTasks(config.oper, tsqs, subGroupTask);
} else {
tsqs = config.option.runTasks;
subGroupTask && tsqs.push(subGroupTask);
}
return tsqs;
} else if (config.runTasks) {
return config.runTasks(subGroupTask);
} else {
subGroupTask && tsqs.push(subGroupTask);
return tsqs;
}
});

@@ -158,0 +158,0 @@ }

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