-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.ts
67 lines (58 loc) · 1.66 KB
/
gulpfile.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
var gulp = require('gulp');
var path = require('path');
var yargs = require('yargs').argv;
var tpl = require('gulp-template');
var rename = require('gulp-rename');
let toUppercase = (name: string) => {
return name.charAt(0).toUpperCase() + name.slice(1);
};
let toLowerCase = (name: string) => {
return name.charAt(0).toLowerCase() + name.slice(1);
};
gulp.task('createSlice', function () {
var name = yargs.name;
const templatePath = `templates/store/slice.ts`;
const destinationPath = `src/store/${toLowerCase(name)}`;
return gulp
.src(templatePath)
.pipe(
tpl({
name: toLowerCase(name),
upCaseName: toUppercase(name),
}),
)
.pipe(gulp.dest(destinationPath));
});
gulp.task('createScreen', function () {
var name = yargs.name;
let containerTemplatePath = `templates/screen/container.tsx`;
let screenDestinationPath = `src/screens/${toUppercase(name)}`;
let tplObj = {
name: name.toLowerCase(),
upCaseName: toUppercase(name),
};
gulp
.src(containerTemplatePath)
.pipe(tpl(tplObj))
.pipe(
rename((path: any) => {
path.basename = `${tplObj.upCaseName}.container`;
}),
)
.pipe(gulp.dest(screenDestinationPath));
containerTemplatePath = `templates/screen/index.tsx`;
gulp
.src(containerTemplatePath)
.pipe(tpl(tplObj))
.pipe(gulp.dest(screenDestinationPath));
const componentTemplatePath = `templates/screen/component.tsx`;
return gulp
.src(componentTemplatePath)
.pipe(tpl(tplObj))
.pipe(
rename((path: any) => {
path.basename = `${tplObj.upCaseName}.component`;
}),
)
.pipe(gulp.dest(screenDestinationPath));
});