Skip to content

Commit 012b1d8

Browse files
author
Ovidiu Barabula
committed
feat(core): update task template and implement new plugin features
support for custom configuration, plugin manager provides custom logger instance, removed plugable from task file
1 parent 7c57b70 commit 012b1d8

File tree

2 files changed

+45
-20
lines changed

2 files changed

+45
-20
lines changed

src/tasks/task-init-project.ts

Lines changed: 36 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,30 +6,53 @@
66
*/
77

88
import * as gulp from 'gulp';
9-
import { Task } from '../task-manager';
10-
import PlugableTask from '../task-manager/plugable-task';
11-
import Logger from '../util/logger';
12-
import { AnyFunction } from '../util/utility-functions';
9+
import { PluginProvider } from '../plugin-manager/installable';
10+
import { AnyFunction, sleep } from '../util/utility-functions';
1311

14-
const logger = Logger('frontvue')('init');
1512

16-
// Task meta data
17-
const hook = 'init';
18-
const name = 'init-project';
19-
const description = 'Task for initializing a new project';
13+
// Configuration defaults
14+
const configDefaults = {
15+
fullName: 'John Smith',
16+
useDefault: true,
17+
};
18+
19+
// Configuration wizard questions
20+
const questions = [
21+
{
22+
default: configDefaults.fullName,
23+
message: 'Type in your full name',
24+
name: 'fullName',
25+
type: 'input',
26+
},
27+
];
28+
29+
// Object to be exported
30+
const taskExport = {
31+
// configDefaults,
32+
// configQuestionnaire: {
33+
// namespace: 'init',
34+
// questions,
35+
// },
36+
description: 'Task for initializing a new project',
37+
hook: 'init',
38+
name: 'init',
39+
taskFn,
40+
};
2041

2142

2243
/**
2344
* Task main function
2445
* @param done Gulp async callback
2546
*/
26-
function task(done?: AnyFunction): any {
27-
logger.log(`Running Task: ${name}`);
47+
async function taskFn(done: AnyFunction, { logger }: PluginProvider): Promise<any> {
48+
logger.debug('Something happening now...');
49+
logger.debug('That something has been completed!');
2850
done && done();
2951
}
3052

53+
3154
/* test:start */
32-
export { task };
55+
export { taskFn };
3356
/* test:end */
3457

35-
export default PlugableTask(task, hook, name, description);
58+
export default taskExport;

src/tasks/task-init-projects.spec.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
11
import { assert, expect } from 'chai';
22
import 'mocha';
3-
import { task } from './task-init-project';
3+
import Logger from '../util/logger';
4+
import { AnyFunction } from '../util/utility-functions';
5+
import { taskFn } from './task-init-project';
46

57
describe('#Task: Init project', () => {
8+
const callback: AnyFunction = () => true;
9+
const logger = Logger('frontvue')('init');
10+
611
it('does what it is supposed to do', () => {
7-
expect(task()).to.not.throw;
12+
expect(taskFn(callback, { logger })).to.not.throw;
813
});
914

1015

1116
it('calls the callback function', () => {
1217
let wasCalled = false;
13-
const callback = () => wasCalled = true;
14-
task(callback);
18+
const customCallback = () => wasCalled = true;
19+
taskFn(customCallback, { logger});
1520
expect(wasCalled).to.have.been.true;
1621
});
17-
18-
19-
it('should be tested more');
2022
});

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy