Skip to content

Commit f90db0c

Browse files
committed
fix gulp tasks
1 parent 6d38c46 commit f90db0c

File tree

6 files changed

+7
-350
lines changed

6 files changed

+7
-350
lines changed

gulpfile.js

Lines changed: 2 additions & 344 deletions
Original file line numberDiff line numberDiff line change
@@ -6,348 +6,6 @@ var buildReadme = require('./tasks/build-readme')
66

77
gulp.task('build:base', buildBase)
88
gulp.task('build:api', buildApi)
9-
gulp.task('build:interface', buildInterface)
9+
gulp.task('build:interface', ['build:api'], buildInterface)
1010
gulp.task('build:readme', buildReadme)
11-
gulp.task('build', ['build:base', 'build:api', 'build:interface'])
12-
13-
14-
15-
16-
17-
// var gulp = require('gulp')
18-
// var through = require('through2')
19-
// var _ = require('lodash')
20-
// var rename = require('gulp-rename')
21-
// var Path = require('path')
22-
// var concat = require('gulp-concat')
23-
// var gulpCopy = require('gulp-copy')
24-
// var beautify = require('js-beautify').js_beautify
25-
// var fs = require('fs')
26-
27-
// var tasks = ['build:methods', 'build:props', 'build:api']
28-
// gulp.task('build', tasks)
29-
// gulp.task('build:all', tasks.concat(['build:readme']))
30-
31-
// gulp.task('watch', function() {
32-
// gulp.watch('./src/**/README.md', ['build:readme'])
33-
// gulp.watch('./src/components/**/schema/*.json', ['build'])
34-
// })
35-
36-
37-
// gulp.task('build:readme', function() {
38-
// gulp.src('./src/**/README.md').pipe(gulpCopy('./demo/src/readme'))
39-
// })
40-
41-
42-
// function hasReadme(path) {
43-
// var toCheck = Path.join(path, 'README.md')
44-
// var exists = statPath(toCheck);
45-
// return exists && exists.isFile()
46-
// }
47-
48-
// function statPath(path) {
49-
// try {
50-
// return fs.statSync(path);
51-
// } catch (ex) {}
52-
// return false;
53-
// }
54-
55-
// gulp.task('build:api', function() {
56-
// gulp.src(['./src/components/**/schema/*.json', './src/modules/*/index.ts', './src/filters/*/index.ts', './src/decorators/*/index.ts'])
57-
// .pipe(through.obj(function(file, enc, cb) {
58-
// switch (Path.extname(file.path)) {
59-
// case '.ts':
60-
// var relativePath = (Path.relative('./src', file.path))
61-
// var type = ''
62-
// if (relativePath.startsWith('modules'))
63-
// type = 'module'
64-
// else if (relativePath.startsWith('filters'))
65-
// type = 'filter'
66-
// if (relativePath.startsWith('decorators'))
67-
// type = 'decorator'
68-
69-
// var dir = Path.relative('./', Path.dirname(file.path))
70-
// var moduleName = Path.basename(Path.dirname(file.path))
71-
// var result = {
72-
// dir: dir,
73-
// module: moduleName,
74-
// value: moduleName,
75-
// type: type
76-
// }
77-
78-
// file.contents = new Buffer(JSON.stringify(result))
79-
// break
80-
81-
// case '.json':
82-
// var kind = Path.basename(file.path, '.json')
83-
// var module = Path.basename(Path.resolve(Path.dirname(file.path), '..'))
84-
// var json = JSON.parse(String(file.contents))
85-
// var isBase = false
86-
// var base = {}
87-
// if (kind === 'props') {
88-
// isBase = json.isBase
89-
// base = json.base
90-
// json = json.props
91-
// }
92-
93-
// var dir = Path.relative('./', Path.dirname(file.path))
94-
// var result = {
95-
// dir: dir.substr(0, dir.length - '\\schema'.length),
96-
// module: module,
97-
// kind: kind,
98-
// value: json,
99-
// isBase: isBase,
100-
// base: base,
101-
// type: 'component'
102-
// }
103-
104-
// file.contents = new Buffer(JSON.stringify(result))
105-
// }
106-
107-
// cb(null, file)
108-
// }))
109-
// .pipe(concat('api.json', { newLine: ',\r\n' }))
110-
// .pipe(through.obj(function(file, enc, cb) {
111-
// var json = JSON.parse('[' + String(file.contents) + ']')
112-
// json = _.map(json, function(v) {
113-
// var obj = {
114-
// dir: v.dir.replace(/\\/g, '/'),
115-
// id: v.type + '/' + v.module,
116-
// module: v.module,
117-
// isBase: v.isBase,
118-
// base: v.base,
119-
// type: v.type,
120-
// readme: hasReadme(v.dir)
121-
// }
122-
123-
// if (v.kind)
124-
// obj[v.kind] = v.value
125-
126-
// return obj
127-
// })
128-
129-
// json = _.groupBy(json, 'id')
130-
// // json = _.groupBy(json, 'module')
131-
// json = _.mapValues(json, function(v) { return _.merge.apply({}, v) })
132-
133-
// _.each(json, function(obj, k) {
134-
// if (obj.type === 'component') {
135-
136-
// // extending base props
137-
// var baseKey = _.keys(obj.base)[0]
138-
// while (baseKey !== 'Vue') {
139-
// var base = json['component/' + _.kebabCase(baseKey)]
140-
// if (base) {
141-
// _.extend(obj.props, base.props)
142-
// }
143-
// baseKey = _.keys(base.base)[0]
144-
// }
145-
146-
// // sorting
147-
// obj.props = sortByKey(obj.props)
148-
// obj.methods = sortByKey(obj.methods)
149-
// }
150-
// })
151-
152-
// json = sortByKey(json)
153-
154-
// file.contents = new Buffer(beautify(JSON.stringify(json), { indent_size: 2 }))
155-
156-
// cb(null, file)
157-
// }))
158-
// .pipe(gulp.dest('./doc'))
159-
// })
160-
161-
// gulp.task('build:modules', function() {
162-
// gulp.src('./src/modules/*/index.ts')
163-
// .pipe(through.obj(function(file, enc, cb) {
164-
// var moduleName = Path.basename(Path.dirname(file.path))
165-
// cb(null, file)
166-
// }))
167-
// })
168-
169-
// gulp.task('build:methods', function() {
170-
// gulp.src('./src/components/**/schema/methods.json')
171-
// .pipe(through.obj(function(file, enc, cb) {
172-
// file.contents = new Buffer(parseMethod(Path.basename(Path.resolve(Path.dirname(file.path), '..')), String(file.contents)))
173-
// cb(null, file)
174-
// }))
175-
// .pipe(concat('methods.d.ts', { newLine: '\r\n\r\n' }))
176-
// .pipe(through.obj(function(file, enc, cb) {
177-
// var contents = String(file.contents)
178-
// var methods = 'export class VueTypedUIMethods {\r\n'
179-
// _.each(contents.match(/export interface(.*?){/g), function(s) {
180-
// var name = s.substring(17)
181-
// name = name.substr(0, name.length - 1).trim()
182-
// methods += '\r\n' + _.camelCase(name) + '(element: string | HTMLElement | JQuery): ' + pascalCase(name)
183-
// })
184-
// methods += '\r\n\r\n}'
185-
// contents = beautify(contents + '\r\n\r\n' + methods)
186-
// file.contents = new Buffer(contents)
187-
188-
// cb(null, file)
189-
// }))
190-
// .pipe(gulp.dest('./lib'))
191-
// })
192-
193-
// gulp.task('build:props', function() {
194-
// gulp.src('./src/components/**/schema/props.json')
195-
// .pipe(through.obj(function(file, enc, cb) {
196-
// file.contents = new Buffer(parseProp(Path.basename(Path.resolve(Path.dirname(file.path), '..')), String(file.contents)))
197-
// cb(null, file)
198-
// }))
199-
// .pipe(rename(function(path) {
200-
// path.extname = '.ts'
201-
// path.basename = '_base'
202-
// path.dirname = path.dirname.substr(0, path.dirname.length - 7)
203-
// }))
204-
// .pipe(gulp.dest(function(file) {
205-
// return file.base
206-
// }))
207-
// })
208-
209-
// gulp.task('build:snippets', function() {
210-
// gulp.src('./doc/api.json')
211-
// .pipe(through.obj(function(file, enc, cb) {
212-
// var json = JSON.parse(String(file.contents))
213-
// var results = {}
214-
// var res = _.each(json, function(m) {
215-
// results['ui-' + m.module] = {
216-
// prefix: 'ui-' + m.module,
217-
// body: '<ui-' + m.module + '>$0</ui-' + m.module + '>',
218-
// 'description': 'VueTypedUI ' + pascalCase(m.module)
219-
// }
220-
// })
221-
222-
// file.contents = new Buffer(beautify(JSON.stringify(results)))
223-
// cb(null, file)
224-
// }))
225-
// .pipe(rename('snippets.json'))
226-
// .pipe(gulp.dest('./doc'))
227-
// })
228-
229-
// function parseProp(module, json) {
230-
// var schema = JSON.parse(json)
231-
// var strProps = ''
232-
// var strBase = ''
233-
234-
// strProps += comment('PLEASE DO NOT EDIT THIS FILE (automatically generated from ./schema/props.json)')
235-
236-
// if (schema.description) {
237-
// strProps += comment(schema.description)
238-
// }
239-
240-
// // strProps += 'import { Component, Prop } from "vue-typed"'
241-
// strProps += 'import { Prop, Virtual } from "vue-typed"'
242-
// strProps += '\r\nimport '
243-
// var base = _.keys(schema.base)[0]
244-
// if (base === 'Vue') {
245-
// strBase = 'Virtual<Vue>()'
246-
// strProps += '* as Vue from "vue"\r\n'
247-
// } else {
248-
// strBase = base
249-
// strProps += '{ ' + base + ' } from "' + schema.base[base] + '"\r\n'
250-
// }
251-
252-
// // strProps += '\r\n@Component({ name: "'+ pascalCase(module) +'Base" })'
253-
// strProps += '\r\nexport abstract class _' + pascalCase(module) + 'Base extends ' + strBase + ' { '
254-
255-
// var props = schema.props
256-
// _.each(props, (v, k) => {
257-
// strProps += '\r\n' + comment(v)
258-
// strProps += '\r\n@Prop('
259-
260-
// let prms = []
261-
262-
// if (v.type && v.type !== 'any' && v.type.indexOf('|') <= -1 && v.type.indexOf('.') <= -1) prms.push('type: ' + pascalCase(v.type))
263-
// if (typeof(v.default) !== 'undefined') prms.push('default: ' + v.default)
264-
265-
// if (prms.length)
266-
// strProps += '{ ' + prms.join() + ' }'
267-
268-
// strProps += ')'
269-
// strProps += '\r\n' + _.camelCase(k)
270-
// if (v.type) {
271-
// strProps += ': ' + v.type
272-
// }
273-
274-
// })
275-
// strProps += '\r\n\r\n}'
276-
// return beautify(strProps)
277-
// }
278-
279-
// function parseMethod(module, json) {
280-
// var schema = JSON.parse(json)
281-
// var strMethods = ''
282-
283-
// if (schema.description) {
284-
// strMethods += comment(schema.description)
285-
// }
286-
287-
// strMethods += '\r\nexport interface ' + pascalCase(module) + ' {'
288-
289-
// _.each(schema, (v, k) => {
290-
// strMethods += '\r\n' + comment(v)
291-
// strMethods += '\r\n' + k + '('
292-
// if (v.params) {
293-
// strMethods += _.map(v.params, function(vp, kp) {
294-
// if (vp.type) {
295-
// return kp + ': ' + vp.type
296-
// }
297-
298-
// return kp
299-
// }).join(', ')
300-
// }
301-
302-
// var type = v.type || 'void'
303-
// strMethods += '): ' + type
304-
// })
305-
306-
// strMethods += '\r\n\r\n}'
307-
308-
// return strMethods
309-
// }
310-
311-
// function comment(setting) {
312-
// var cmt = '\r\n/**'
313-
314-
// if (_.isString(setting)) {
315-
// cmt += '\r\n * ' + setting
316-
// } else {
317-
// cmt += '\r\n * ' + setting.description
318-
319-
// if (setting.params || setting.default || setting.category || setting.type)
320-
// cmt += '\r\n * '
321-
322-
// if (setting.category)
323-
// cmt += '\r\n * Category: ' + setting.category
324-
325-
// if (setting.params) {
326-
// _.each(setting.params, function(prm, k) {
327-
// cmt += '\r\n * @param {' + prm.type + '} ' + k
328-
// if (prm.description)
329-
// cmt += ' ' + prm.description
330-
// })
331-
// }
332-
333-
// if (setting.default) {
334-
// cmt += '\r\n * @default ' + setting.default
335-
// }
336-
337-
// if (setting.type) {
338-
// if (setting.isFunction)
339-
// cmt += '\r\n * @returns {' + setting.type + '}'
340-
// else
341-
// cmt += '\r\n * @type {' + setting.type + '}'
342-
// }
343-
// }
344-
// return cmt + '\r\n */'
345-
// }
346-
347-
// function pascalCase(str) {
348-
// return _.upperFirst(_.camelCase(str))
349-
// }
350-
351-
// function sortByKey(obj) {
352-
// return _(obj).toPairs().sortBy(0).fromPairs().value()
353-
// }
11+
gulp.task('build', ['build:base', 'build:interface', 'build:readme'])

tasks/build-api.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,6 @@ module.exports = function(done) {
103103
cb(null, file)
104104
}))
105105
.pipe(gulp.dest('./doc'))
106+
.on('end', done)
106107

107-
done()
108108
}

tasks/build-base.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ module.exports = function(done) {
2626
.pipe(gulp.dest(function(file) {
2727
return file.base
2828
}))
29-
30-
done()
29+
.on('end', done)
3130
}
3231

3332

tasks/build-interface.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ module.exports = function(done) {
3030
}))
3131
.pipe(rename('interface.d.ts'))
3232
.pipe(gulp.dest('./lib'))
33-
34-
done()
33+
.on('end', done)
3534
}
3635

3736
function parseComponent(obj) {

tasks/build-readme.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ var gulpCopy = require('gulp-copy')
44
module.exports = function(done) {
55
gulp.src('./src/**/README.md')
66
.pipe(gulpCopy('./demo/src/readme'))
7-
done()
7+
.on('end', done)
88
}

tasks/build-snippets.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,5 @@ module.exports = function(done) {
2424
}))
2525
.pipe(rename('snippets.json'))
2626
.pipe(gulp.dest('./doc'))
27+
.on('end', done)
2728
}

0 commit comments

Comments
 (0)