Skip to content

Commit ea8840a

Browse files
committed
fix(gulpfile): apply some fixes to standardize gulpfile
1 parent 63e097a commit ea8840a

1 file changed

Lines changed: 87 additions & 16 deletions

File tree

gulpfile.mjs

Lines changed: 87 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ gulp.task( 'help', ( done ) => {
114114
log( '' )
115115

116116
done()
117+
117118
} )
118119

119120
//---------
@@ -378,10 +379,10 @@ gulp.task( 'check-bundling-by-source-file-export', async ( done ) => {
378379
} )
379380
],
380381
onwarn: ( {
381-
loc,
382-
frame,
383-
message
384-
} ) => {
382+
loc,
383+
frame,
384+
message
385+
} ) => {
385386

386387
// Ignore some errors
387388
if ( message.includes( 'Circular dependency' ) ) { return }
@@ -440,6 +441,8 @@ gulp.task( 'compute-unit-tests', async ( done ) => {
440441
const testsDir = path.join( basePath, 'tests' )
441442
const unitsDir = path.join( testsDir, 'units' )
442443

444+
fs.mkdirSync( unitsDir, { recursive: true } )
445+
443446
const filePathsToIgnore = [
444447
`${ packageInfos.name }.js`,
445448
'isTestUnitGenerator.js',
@@ -476,9 +479,46 @@ gulp.task( 'compute-unit-tests', async ( done ) => {
476479

477480
const jsdocPath = path.join(basePath, '/node_modules/jsdoc/jsdoc.js')
478481
const jsdocOutput = childProcess.execFileSync( 'node', [ jsdocPath, '-X', sourceFile ] ).toString()
479-
const jsonData = JSON.parse( jsdocOutput ).filter( data => {
480-
return ( data.kind === 'function' && !data.undocumented )
481-
} )
482+
483+
const classNames = []
484+
const usedLongnames = []
485+
const jsonData = JSON.parse(jsdocOutput).filter(data => {
486+
487+
const longName = data.longname
488+
489+
const kind = data.kind
490+
if (kind !== 'function') {
491+
if (kind === 'class' && !classNames.includes(longName)) {
492+
classNames.push(longName)
493+
}
494+
return false
495+
}
496+
497+
const undocumented = data.undocumented
498+
if (undocumented) {
499+
return false
500+
}
501+
502+
const scope = data.scope
503+
if (!['global', 'static'].includes(scope)) {
504+
return false
505+
}
506+
507+
if (longName.includes(' ') || longName.includes('~') || usedLongnames.includes(longName)) {
508+
return false
509+
}
510+
511+
for(let className of classNames) {
512+
if(longName.includes(className)) {
513+
return false
514+
}
515+
}
516+
517+
usedLongnames.push(longName)
518+
519+
return true
520+
521+
})
482522

483523
if ( jsonData.length === 0 ) {
484524
log( yellow( `No usable exports found in [${ sourceFile }]. Ignore it !` ) )
@@ -937,6 +977,8 @@ gulp.task( 'compute-unit-tests', async ( done ) => {
937977
'} )' + '\n'
938978

939979
const unitsFilePath = path.join( unitsDir, `${ packageInfos.name }.units.js` )
980+
981+
log( green( `Create ${ unitsFilePath }` ) )
940982
fs.writeFileSync( unitsFilePath, unitsTemplate )
941983

942984
done()
@@ -984,6 +1026,8 @@ gulp.task( 'compute-benchmarks', async ( done ) => {
9841026
const testsDir = path.join( basePath, 'tests' )
9851027
const benchsDir = path.join( testsDir, 'benchmarks' )
9861028

1029+
fs.mkdirSync( benchsDir, { recursive: true } )
1030+
9871031
const filePathsToIgnore = [
9881032
`${ packageInfos.name }.js`,
9891033
'isTestUnitGenerator.js',
@@ -1020,19 +1064,45 @@ gulp.task( 'compute-benchmarks', async ( done ) => {
10201064
const jsdocPath = path.join(basePath, '/node_modules/jsdoc/jsdoc.js')
10211065
const jsdocOutput = childProcess.execFileSync( 'node', [ jsdocPath, '-X', sourceFile ] ).toString()
10221066

1067+
const classNames = []
10231068
const usedLongnames = []
1024-
const jsonData = JSON.parse( jsdocOutput ).filter( data => {
1069+
const jsonData = JSON.parse(jsdocOutput).filter(data => {
1070+
1071+
const longName = data.longname
10251072

1026-
if( data.kind !== 'function' ) {
1073+
const kind = data.kind
1074+
if (kind !== 'function') {
1075+
if (kind === 'class' && !classNames.includes(longName)) {
1076+
classNames.push(longName)
1077+
}
10271078
return false
1028-
} else if(usedLongnames.includes(data.longname)) {
1079+
}
1080+
1081+
const undocumented = data.undocumented
1082+
if (undocumented) {
10291083
return false
1030-
} else {
1031-
usedLongnames.push(data.longname)
1032-
return true
10331084
}
10341085

1035-
} )
1086+
const scope = data.scope
1087+
if (!['global', 'static'].includes(scope)) {
1088+
return false
1089+
}
1090+
1091+
if (longName.includes(' ') || longName.includes('~') || usedLongnames.includes(longName)) {
1092+
return false
1093+
}
1094+
1095+
for(let className of classNames) {
1096+
if(longName.includes(className)) {
1097+
return false
1098+
}
1099+
}
1100+
1101+
usedLongnames.push(longName)
1102+
1103+
return true
1104+
1105+
})
10361106

10371107
if ( jsonData.length === 0 ) {
10381108
log( yellow( `No usable exports found in [${ sourceFile }]. Ignore it !` ) )
@@ -1079,8 +1149,7 @@ gulp.task( 'compute-benchmarks', async ( done ) => {
10791149

10801150
const template = '' + '\n' +
10811151
`import Benchmark from 'benchmark'` + '\n' +
1082-
`import { Testing } from 'itee-utils/sources/testings/benchmarks'` + '\n' +
1083-
// `import { Testing } from 'itee-utils'` + '\n' +
1152+
`import { Testing } from 'itee-utils'` + '\n' +
10841153
`import * as ${ nsName } from '${ importFilePath }'` + '\n' +
10851154
'\n' +
10861155
`${ benchSuites }` +
@@ -1130,6 +1199,8 @@ gulp.task( 'compute-benchmarks', async ( done ) => {
11301199
`}` + '\n'
11311200

11321201
const benchsFilePath = path.join( benchsDir, `${ packageInfos.name }.benchs.js` )
1202+
1203+
log( green( `Create ${ benchsFilePath }` ) )
11331204
fs.writeFileSync( benchsFilePath, benchsTemplate )
11341205

11351206
done()

0 commit comments

Comments
 (0)