itee-validators 6.0.0 → 6.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/publish.yml +61 -0
- package/.tasks/configs/lints/lint.conf.mjs +42 -0
- package/.tasks/configs/tests/benchmarks/compute-benchmarks.conf.mjs +5 -0
- package/.tasks/configs/tests/benchmarks/run-benchmarks-for-frontend.conf.mjs +5 -0
- package/.tasks/configs/tests/units/run-unit-tests-for-frontend.conf.mjs +5 -0
- package/CHANGELOG.md +13 -0
- package/builds/{itee-validators.cjs.js → validators.cjs} +3 -3
- package/builds/validators.cjs.map +1 -0
- package/builds/{itee-validators.iife.js → validators.js} +3 -3
- package/builds/validators.js.map +1 -0
- package/builds/{itee-validators.esm.js → validators.mjs} +3 -3
- package/builds/validators.mjs.map +1 -0
- package/package.json +9 -42
- package/.github/workflows/node.js.yml +0 -53
- package/.tasks/.builds/build-benchmarks.task.mjs +0 -16
- package/.tasks/.builds/build-tests.task.mjs +0 -18
- package/.tasks/.builds/build-unit-tests.task.mjs +0 -16
- package/.tasks/.builds/build.task.mjs +0 -46
- package/.tasks/.cleans/clean.task.mjs +0 -23
- package/.tasks/.docs/doc.task.mjs +0 -35
- package/.tasks/.helps/help.task.mjs +0 -151
- package/.tasks/.lints/lint.task.mjs +0 -37
- package/.tasks/.patches/patch.task.mjs +0 -13
- package/.tasks/.releases/release.task.mjs +0 -26
- package/.tasks/.tests/benchmarks/build-benchmarks-backend.task.mjs +0 -42
- package/.tasks/.tests/benchmarks/compute-benchmarks.task.mjs +0 -210
- package/.tasks/.tests/benchmarks/run-benchmarks-for-backend.task.mjs +0 -39
- package/.tasks/.tests/benchmarks/run-benchmarks-for-frontend.task.mjs +0 -41
- package/.tasks/.tests/benchmarks/run-benchmarks.task.mjs +0 -18
- package/.tasks/.tests/bundling/check-bundling-from-esm-build-import.task.mjs +0 -123
- package/.tasks/.tests/bundling/check-bundling-from-esm-files-direct.task.mjs +0 -77
- package/.tasks/.tests/bundling/check-bundling-from-esm-files-import.task.mjs +0 -95
- package/.tasks/.tests/bundling/check-bundling.task.mjs +0 -20
- package/.tasks/.tests/run-tests.task.mjs +0 -18
- package/.tasks/.tests/unit-tests/build-unit-tests-backend.task.mjs +0 -42
- package/.tasks/.tests/unit-tests/compute-unit-tests.task.mjs +0 -537
- package/.tasks/.tests/unit-tests/run-unit-tests-for-backend.task.mjs +0 -44
- package/.tasks/.tests/unit-tests/run-unit-tests-for-frontend.task.mjs +0 -41
- package/.tasks/.tests/unit-tests/run-unit-tests.task.mjs +0 -18
- package/.tasks/_refresh-gulpfile.task.mjs +0 -65
- package/.tasks/_utils.mjs +0 -192
- package/.tasks/configs/benchmarks.conf.mjs +0 -57
- package/.tasks/configs/build-benchmarks-backend.conf.mjs +0 -51
- package/.tasks/configs/build-unit-tests-backend.conf.mjs +0 -46
- package/.tasks/configs/build.conf.mjs +0 -354
- package/.tasks/configs/check-bundling.conf.mjs +0 -26
- package/.tasks/configs/clean.conf.mjs +0 -9
- package/.tasks/configs/compute-benchmarks.conf.mjs +0 -28
- package/.tasks/configs/compute-unit-tests.conf.mjs +0 -27
- package/.tasks/configs/doc.conf.json +0 -50
- package/.tasks/configs/eslint.conf.mjs +0 -121
- package/.tasks/configs/units.conf.mjs +0 -27
- package/.tasks/itee-benchmarks-framework.js +0 -186
- package/.tasks/itee-reporter.mjs +0 -217
- package/builds/itee-validators.cjs.js.map +0 -1
- package/builds/itee-validators.esm.js.map +0 -1
- package/builds/itee-validators.iife.js.map +0 -1
- /package/builds/{itee-validators.cjs.min.js → validators.min.cjs} +0 -0
- /package/builds/{itee-validators.iife.min.js → validators.min.js} +0 -0
- /package/builds/{itee-validators.esm.min.js → validators.min.mjs} +0 -0
- /package/sources/{itee-validators.js → validators.js} +0 -0
|
@@ -1,210 +0,0 @@
|
|
|
1
|
-
import colors from 'ansi-colors'
|
|
2
|
-
import childProcess from 'child_process'
|
|
3
|
-
import log from 'fancy-log'
|
|
4
|
-
import {
|
|
5
|
-
existsSync,
|
|
6
|
-
mkdirSync,
|
|
7
|
-
writeFileSync
|
|
8
|
-
} from 'fs'
|
|
9
|
-
import {
|
|
10
|
-
basename,
|
|
11
|
-
dirname,
|
|
12
|
-
extname,
|
|
13
|
-
join,
|
|
14
|
-
relative
|
|
15
|
-
} from 'path'
|
|
16
|
-
import {
|
|
17
|
-
nodeModulesDirectory,
|
|
18
|
-
packageName,
|
|
19
|
-
packageSourcesDirectory as sourcesDir,
|
|
20
|
-
packageTestsBenchmarksDirectory as benchesDir
|
|
21
|
-
} from '../../_utils.mjs'
|
|
22
|
-
import { sourcesFiles } from '../../configs/compute-benchmarks.conf.mjs'
|
|
23
|
-
|
|
24
|
-
const {
|
|
25
|
-
red,
|
|
26
|
-
green,
|
|
27
|
-
yellow
|
|
28
|
-
} = colors
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* @description Will generate benchmarks files from source code against provided alternatives
|
|
32
|
-
*/
|
|
33
|
-
const computeBenchmarksTask = ( done ) => {
|
|
34
|
-
|
|
35
|
-
if ( !existsSync( benchesDir ) ) {
|
|
36
|
-
log( 'Creating', green( benchesDir ) )
|
|
37
|
-
mkdirSync( benchesDir, { recursive: true } )
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
const benchRootImports = []
|
|
41
|
-
for ( let sourceFile of sourcesFiles ) {
|
|
42
|
-
|
|
43
|
-
const specificFilePath = sourceFile.replace( sourcesDir, '' )
|
|
44
|
-
const specificDir = dirname( specificFilePath )
|
|
45
|
-
|
|
46
|
-
const fileName = basename( sourceFile, extname( sourceFile ) )
|
|
47
|
-
const benchFileName = `${ fileName }.bench.js`
|
|
48
|
-
const benchDirPath = join( benchesDir, specificDir )
|
|
49
|
-
const benchFilePath = join( benchDirPath, benchFileName )
|
|
50
|
-
|
|
51
|
-
const nsName = `${ fileName }Namespace`
|
|
52
|
-
const importDirPath = relative( benchDirPath, sourcesDir )
|
|
53
|
-
const importFilePath = join( importDirPath, specificFilePath ).replace( /\\/g, '/' )
|
|
54
|
-
|
|
55
|
-
try {
|
|
56
|
-
|
|
57
|
-
const jsdocPath = join( nodeModulesDirectory, '/jsdoc/jsdoc.js' )
|
|
58
|
-
const jsdocOutput = childProcess.execFileSync( 'node', [ jsdocPath, '-X', sourceFile ] ).toString()
|
|
59
|
-
|
|
60
|
-
const classNames = []
|
|
61
|
-
const usedLongnames = []
|
|
62
|
-
const jsonData = JSON.parse( jsdocOutput ).filter( data => {
|
|
63
|
-
|
|
64
|
-
const longName = data.longname
|
|
65
|
-
|
|
66
|
-
const kind = data.kind
|
|
67
|
-
if ( kind !== 'function' ) {
|
|
68
|
-
if ( kind === 'class' && !classNames.includes( longName ) ) {
|
|
69
|
-
classNames.push( longName )
|
|
70
|
-
}
|
|
71
|
-
return false
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
// We don't care that data bloc have comment they are unused to generate benchmarks
|
|
75
|
-
// const undocumented = data.undocumented
|
|
76
|
-
// if ( undocumented ) {
|
|
77
|
-
// return false
|
|
78
|
-
// }
|
|
79
|
-
|
|
80
|
-
const scope = data.scope
|
|
81
|
-
if ( ![ 'global', 'static' ].includes( scope ) ) {
|
|
82
|
-
return false
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
if ( longName.includes( ' ' ) || longName.includes( '~' ) || usedLongnames.includes( longName ) ) {
|
|
86
|
-
return false
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
for ( let className of classNames ) {
|
|
90
|
-
if ( longName.includes( className ) ) {
|
|
91
|
-
return false
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
usedLongnames.push( longName )
|
|
96
|
-
|
|
97
|
-
return true
|
|
98
|
-
|
|
99
|
-
} )
|
|
100
|
-
|
|
101
|
-
if ( jsonData.length === 0 ) {
|
|
102
|
-
log( 'Ignoring', yellow( `${ sourceFile }, no usable exports found` ) )
|
|
103
|
-
continue
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
// Compute benchmark suites by grouping logically function by name[_x]
|
|
107
|
-
const suiteGroups = {}
|
|
108
|
-
for ( let docData of jsonData ) {
|
|
109
|
-
|
|
110
|
-
try {
|
|
111
|
-
|
|
112
|
-
const functionName = docData.name
|
|
113
|
-
const nameSplits = functionName.split( '_' )
|
|
114
|
-
const rootName = nameSplits[ 0 ]
|
|
115
|
-
|
|
116
|
-
if ( !( rootName in suiteGroups ) ) {
|
|
117
|
-
suiteGroups[ rootName ] = []
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
suiteGroups[ rootName ].push( functionName )
|
|
121
|
-
|
|
122
|
-
} catch ( error ) {
|
|
123
|
-
|
|
124
|
-
log( red( error.message ) )
|
|
125
|
-
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
// Generate suites
|
|
131
|
-
let benchSuites = ''
|
|
132
|
-
const suitesToExports = []
|
|
133
|
-
for ( let suiteGroupName in suiteGroups ) {
|
|
134
|
-
suitesToExports.push( `${ suiteGroupName }Suite` )
|
|
135
|
-
benchSuites += `const ${ suiteGroupName }Suite = Benchmark.Suite( '${ nsName }.${ suiteGroupName }', Testing.createSuiteOptions() )` + '\n'
|
|
136
|
-
|
|
137
|
-
for ( let suiteGroupValue of suiteGroups[ suiteGroupName ] ) {
|
|
138
|
-
benchSuites += ` .add( '${ suiteGroupValue }()', Testing.iterateOverDataMap( ${ nsName }.${ suiteGroupValue } ), Testing.createBenchmarkOptions() )` + '\n'
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
benchSuites += '\n'
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
const template = '' +
|
|
145
|
-
`import { Testing } from 'itee-utils/sources/testings/benchmarks.js'` + '\n' +
|
|
146
|
-
`import * as ${ nsName } from '${ importFilePath }'` + '\n' +
|
|
147
|
-
'\n' +
|
|
148
|
-
`${ benchSuites }` +
|
|
149
|
-
// '\n' +
|
|
150
|
-
`export { ${ suitesToExports } }` + '\n' +
|
|
151
|
-
'\n'
|
|
152
|
-
|
|
153
|
-
const importBenchFilePath = relative( benchesDir, benchFilePath ).replace( /\\/g, '/' )
|
|
154
|
-
benchRootImports.push( {
|
|
155
|
-
path: importBenchFilePath,
|
|
156
|
-
exports: suitesToExports
|
|
157
|
-
} )
|
|
158
|
-
|
|
159
|
-
if ( !existsSync( benchDirPath ) ) {
|
|
160
|
-
log( 'Creating', green( benchDirPath ) )
|
|
161
|
-
mkdirSync( benchDirPath, { recursive: true } )
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
log( 'Creating', green( benchFilePath ) )
|
|
165
|
-
writeFileSync( benchFilePath, template )
|
|
166
|
-
|
|
167
|
-
} catch ( error ) {
|
|
168
|
-
|
|
169
|
-
log( red( error.message ) )
|
|
170
|
-
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
let templateImports = ''
|
|
176
|
-
let suites = []
|
|
177
|
-
for ( let i = 0 ; i < benchRootImports.length ; i++ ) {
|
|
178
|
-
|
|
179
|
-
const currentBench = benchRootImports[ i ]
|
|
180
|
-
const namedExports = currentBench.exports
|
|
181
|
-
const imports = namedExports.join( ', ' )
|
|
182
|
-
suites.push( ...namedExports )
|
|
183
|
-
|
|
184
|
-
templateImports += `import {${ imports }} from './${ currentBench.path }'` + '\n'
|
|
185
|
-
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
const benchesTemplate = '' +
|
|
189
|
-
`${ templateImports }` + '\n' +
|
|
190
|
-
'const suites = [' + '\n' +
|
|
191
|
-
`${ suites.map( suite => `\t${ suite }` ).join( ',\n' ) }` + '\n' +
|
|
192
|
-
']' + '\n' +
|
|
193
|
-
'\n' +
|
|
194
|
-
`for ( const suite of suites ) {` + '\n' +
|
|
195
|
-
`\tsuite.run()` + '\n' +
|
|
196
|
-
`}` + '\n'
|
|
197
|
-
|
|
198
|
-
const benchesFilePath = join( benchesDir, `${ packageName }.benchmarks.js` )
|
|
199
|
-
|
|
200
|
-
log( 'Creating', green( benchesFilePath ) )
|
|
201
|
-
writeFileSync( benchesFilePath, benchesTemplate )
|
|
202
|
-
|
|
203
|
-
done()
|
|
204
|
-
|
|
205
|
-
}
|
|
206
|
-
computeBenchmarksTask.displayName = 'compute-benchmarks'
|
|
207
|
-
computeBenchmarksTask.description = 'Will generate benchmarks files from source code against provided alternatives.'
|
|
208
|
-
computeBenchmarksTask.flags = null
|
|
209
|
-
|
|
210
|
-
export { computeBenchmarksTask }
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import colors from 'ansi-colors'
|
|
2
|
-
import log from 'fancy-log'
|
|
3
|
-
import { existsSync } from 'fs'
|
|
4
|
-
import { join } from 'path'
|
|
5
|
-
import {
|
|
6
|
-
packageName,
|
|
7
|
-
packageTestsBenchmarksDirectory
|
|
8
|
-
} from '../../_utils.mjs'
|
|
9
|
-
|
|
10
|
-
const {
|
|
11
|
-
red,
|
|
12
|
-
yellow
|
|
13
|
-
} = colors
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* @description Will run benchmarks with node
|
|
17
|
-
*/
|
|
18
|
-
const runBenchmarksForBackendTask = async ( done ) => {
|
|
19
|
-
|
|
20
|
-
const benchesPath = join( packageTestsBenchmarksDirectory, `/builds/${ packageName }.benchmarks.cjs.js` )
|
|
21
|
-
if ( !existsSync( benchesPath ) ) {
|
|
22
|
-
log( yellow( `${ benchesPath } does not exist, skip backend benchmarks...` ) )
|
|
23
|
-
done()
|
|
24
|
-
return
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
try {
|
|
28
|
-
await import(benchesPath)
|
|
29
|
-
done()
|
|
30
|
-
} catch ( error ) {
|
|
31
|
-
done( red( error ) )
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
}
|
|
35
|
-
runBenchmarksForBackendTask.displayName = 'run-benchmarks-for-backend'
|
|
36
|
-
runBenchmarksForBackendTask.description = 'Will run benchmarks with node'
|
|
37
|
-
runBenchmarksForBackendTask.flags = null
|
|
38
|
-
|
|
39
|
-
export { runBenchmarksForBackendTask }
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { startTestRunner } from '@web/test-runner'
|
|
2
|
-
import colors from 'ansi-colors'
|
|
3
|
-
import { default as config } from '../../configs/benchmarks.conf.mjs'
|
|
4
|
-
|
|
5
|
-
const { red } = colors
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* @description Will run benchmarks with web-test-runner
|
|
9
|
-
*/
|
|
10
|
-
const runBenchmarksForFrontendTask = () => {
|
|
11
|
-
return new Promise( async ( resolve, reject ) => {
|
|
12
|
-
|
|
13
|
-
const testRunner = await startTestRunner( {
|
|
14
|
-
config: config,
|
|
15
|
-
readCliArgs: false,
|
|
16
|
-
readFileConfig: false,
|
|
17
|
-
autoExitProcess: false,
|
|
18
|
-
} )
|
|
19
|
-
|
|
20
|
-
if ( !testRunner ) {
|
|
21
|
-
reject( red( 'Internal test runner error.' ) )
|
|
22
|
-
return
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
// To ensure that testRunner exit event won't be used by other instance of test runner,
|
|
26
|
-
// we need to be sure that current test runner is ended
|
|
27
|
-
testRunner.on( 'finished', () => {
|
|
28
|
-
testRunner.stop()
|
|
29
|
-
} )
|
|
30
|
-
|
|
31
|
-
testRunner.on( 'stopped', () => {
|
|
32
|
-
resolve()
|
|
33
|
-
} )
|
|
34
|
-
|
|
35
|
-
} )
|
|
36
|
-
}
|
|
37
|
-
runBenchmarksForFrontendTask.displayName = 'run-benchmarks-for-frontend'
|
|
38
|
-
runBenchmarksForFrontendTask.description = 'Will run benchmarks with web-test-runner.'
|
|
39
|
-
runBenchmarksForFrontendTask.flags = null
|
|
40
|
-
|
|
41
|
-
export { runBenchmarksForFrontendTask }
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { series } from 'gulp'
|
|
2
|
-
import { runBenchmarksForBackendTask } from './run-benchmarks-for-backend.task.mjs'
|
|
3
|
-
import { runBenchmarksForFrontendTask } from './run-benchmarks-for-frontend.task.mjs'
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* @method npm run build-test
|
|
7
|
-
* @global
|
|
8
|
-
* @description Will run benchmarks in back and front environments
|
|
9
|
-
*/
|
|
10
|
-
const runBenchmarksTestsTask = series(
|
|
11
|
-
runBenchmarksForBackendTask,
|
|
12
|
-
runBenchmarksForFrontendTask,
|
|
13
|
-
)
|
|
14
|
-
runBenchmarksTestsTask.displayName = 'run-benchmarks'
|
|
15
|
-
runBenchmarksTestsTask.description = 'Will run benchmarks in back and front environments.'
|
|
16
|
-
runBenchmarksTestsTask.flags = null
|
|
17
|
-
|
|
18
|
-
export { runBenchmarksTestsTask }
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
import colors from 'ansi-colors'
|
|
2
|
-
import log from 'fancy-log'
|
|
3
|
-
import {
|
|
4
|
-
existsSync,
|
|
5
|
-
mkdirSync,
|
|
6
|
-
readFileSync,
|
|
7
|
-
rmSync,
|
|
8
|
-
writeFileSync
|
|
9
|
-
} from 'fs'
|
|
10
|
-
import {
|
|
11
|
-
basename,
|
|
12
|
-
join,
|
|
13
|
-
relative
|
|
14
|
-
} from 'path'
|
|
15
|
-
import { rollup } from 'rollup'
|
|
16
|
-
import {
|
|
17
|
-
packageBuildsDirectory as buildsDir,
|
|
18
|
-
packageName,
|
|
19
|
-
packageTestsBundlesDirectory as bundlesDir
|
|
20
|
-
} from '../../_utils.mjs'
|
|
21
|
-
import { getRollupConfigurationFor } from '../../configs/build.conf.mjs'
|
|
22
|
-
|
|
23
|
-
const {
|
|
24
|
-
red,
|
|
25
|
-
green,
|
|
26
|
-
magenta
|
|
27
|
-
} = colors
|
|
28
|
-
|
|
29
|
-
const checkBundlingFromEsmBuildImportTask = async ( done ) => {
|
|
30
|
-
|
|
31
|
-
const buildFilePath = join( buildsDir, `${ packageName }.esm.js` )
|
|
32
|
-
if ( !existsSync( buildFilePath ) ) {
|
|
33
|
-
done( red( buildFilePath + ' does not exist' ) )
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const outputDir = join( bundlesDir, 'from_build_import' )
|
|
37
|
-
const temporaryDir = join( bundlesDir, 'from_build_import', '.tmp' )
|
|
38
|
-
const importDir = relative( temporaryDir, buildsDir )
|
|
39
|
-
const importFilePath = join( importDir, `${ packageName }.esm.js` )
|
|
40
|
-
|
|
41
|
-
if ( existsSync( outputDir ) ) {
|
|
42
|
-
log( 'Clean up', magenta( outputDir ) )
|
|
43
|
-
rmSync( outputDir, { recursive: true } )
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
try {
|
|
47
|
-
|
|
48
|
-
// Get build exports list
|
|
49
|
-
const data = readFileSync( buildFilePath, 'utf8' )
|
|
50
|
-
const regex = /export\s{\s(.*)\s}/
|
|
51
|
-
const found = data.match( regex )
|
|
52
|
-
if ( found === null ) {
|
|
53
|
-
log( red( `Unable to find exports in ${ buildFilePath }` ) )
|
|
54
|
-
return
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
const exports = found[ 1 ].split( ',' )
|
|
58
|
-
.map( item => item.trim() )
|
|
59
|
-
|
|
60
|
-
// Create temporary imports files for each build export
|
|
61
|
-
// And then bundle it
|
|
62
|
-
let temporaryFilePaths = []
|
|
63
|
-
for ( let namedExport of exports ) {
|
|
64
|
-
if ( namedExport.includes( ' as ' ) ) {
|
|
65
|
-
namedExport = namedExport.split( ' as ' )[ 1 ]
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
const temporaryFileName = `${ namedExport }.import.js`
|
|
69
|
-
const temporaryFilePath = join( temporaryDir, temporaryFileName )
|
|
70
|
-
const temporaryFileData = `import { ${ namedExport } } from '${ importFilePath.replace( /\\/g, '/' ) }'`
|
|
71
|
-
|
|
72
|
-
mkdirSync( temporaryDir, { recursive: true } )
|
|
73
|
-
writeFileSync( temporaryFilePath, temporaryFileData )
|
|
74
|
-
|
|
75
|
-
temporaryFilePaths.push( temporaryFilePath )
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
// Bundle each temporary files and check side effects
|
|
79
|
-
const config = getRollupConfigurationFor( 'check-bundling-from-esm-build-import' )
|
|
80
|
-
let fileName, bundleFileName, bundleFilePath
|
|
81
|
-
for ( const temporaryFilePath of temporaryFilePaths ) {
|
|
82
|
-
|
|
83
|
-
fileName = basename( temporaryFilePath )
|
|
84
|
-
bundleFileName = fileName.replace( '.tmp.', '.bundle.' )
|
|
85
|
-
bundleFilePath = join( outputDir, bundleFileName )
|
|
86
|
-
|
|
87
|
-
try {
|
|
88
|
-
|
|
89
|
-
config.input = temporaryFilePath
|
|
90
|
-
config.output.file = bundleFilePath
|
|
91
|
-
|
|
92
|
-
const bundle = await rollup( config )
|
|
93
|
-
const { output } = await bundle.generate( config.output )
|
|
94
|
-
|
|
95
|
-
let code = output[ 0 ].code
|
|
96
|
-
if ( code.length > 1 ) {
|
|
97
|
-
log( red( `[${ bundleFileName }] contain side-effects !` ) )
|
|
98
|
-
await bundle.write( config.output )
|
|
99
|
-
} else {
|
|
100
|
-
log( green( `[${ bundleFileName }] is side-effect free.` ) )
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
} catch ( error ) {
|
|
104
|
-
|
|
105
|
-
log( red( error.message ) )
|
|
106
|
-
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
} catch ( error ) {
|
|
111
|
-
log( red( error.message ) )
|
|
112
|
-
} finally {
|
|
113
|
-
|
|
114
|
-
done()
|
|
115
|
-
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
}
|
|
119
|
-
checkBundlingFromEsmBuildImportTask.displayName = 'check-bundling-from-esm-build-import'
|
|
120
|
-
checkBundlingFromEsmBuildImportTask.description = 'Verify that the project esm build is correctly importable in third party esm files'
|
|
121
|
-
checkBundlingFromEsmBuildImportTask.flags = null
|
|
122
|
-
|
|
123
|
-
export { checkBundlingFromEsmBuildImportTask }
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import colors from 'ansi-colors'
|
|
2
|
-
import log from 'fancy-log'
|
|
3
|
-
import {
|
|
4
|
-
existsSync,
|
|
5
|
-
rmSync
|
|
6
|
-
} from 'fs'
|
|
7
|
-
import {
|
|
8
|
-
basename,
|
|
9
|
-
dirname,
|
|
10
|
-
extname,
|
|
11
|
-
join
|
|
12
|
-
} from 'path'
|
|
13
|
-
import { rollup } from 'rollup'
|
|
14
|
-
import {
|
|
15
|
-
packageSourcesDirectory as sourcesDir,
|
|
16
|
-
packageTestsBundlesDirectory as bundlesDir
|
|
17
|
-
} from '../../_utils.mjs'
|
|
18
|
-
import { getRollupConfigurationFor } from '../../configs/build.conf.mjs'
|
|
19
|
-
import { sourcesFiles } from '../../configs/check-bundling.conf.mjs'
|
|
20
|
-
|
|
21
|
-
const {
|
|
22
|
-
red,
|
|
23
|
-
green,
|
|
24
|
-
magenta
|
|
25
|
-
} = colors
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* @description In view to detect bundling side effects this task will
|
|
29
|
-
* create intermediary file for each individual export from this package
|
|
30
|
-
* and then create rollup config for each of them and bundle
|
|
31
|
-
* Todo: Check for different target env like next task below this one
|
|
32
|
-
*/
|
|
33
|
-
const checkBundlingFromEsmFilesDirectTask = async ( done ) => {
|
|
34
|
-
|
|
35
|
-
const outputDir = join( bundlesDir, 'from_files_direct' )
|
|
36
|
-
if ( existsSync( outputDir ) ) {
|
|
37
|
-
log( 'Clean up', magenta( outputDir ) )
|
|
38
|
-
rmSync( outputDir, { recursive: true } )
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
const config = getRollupConfigurationFor( 'check-bundling-from-esm-files-direct' )
|
|
42
|
-
for ( let sourceFile of sourcesFiles ) {
|
|
43
|
-
|
|
44
|
-
const specificFilePath = sourceFile.replace( sourcesDir, '' )
|
|
45
|
-
const specificDir = dirname( specificFilePath )
|
|
46
|
-
const fileName = basename( sourceFile, extname( sourceFile ) )
|
|
47
|
-
|
|
48
|
-
const bundleFileName = `${ fileName }.bundle.js`
|
|
49
|
-
const bundleFilePath = join( outputDir, specificDir, bundleFileName )
|
|
50
|
-
|
|
51
|
-
config.input = sourceFile
|
|
52
|
-
config.output.file = bundleFilePath
|
|
53
|
-
|
|
54
|
-
try {
|
|
55
|
-
|
|
56
|
-
log( 'Bundling', green( config.output.file ) )
|
|
57
|
-
|
|
58
|
-
const bundle = await rollup( config )
|
|
59
|
-
await bundle.generate( config.output )
|
|
60
|
-
await bundle.write( config.output )
|
|
61
|
-
|
|
62
|
-
} catch ( error ) {
|
|
63
|
-
|
|
64
|
-
log( red( error.message ) )
|
|
65
|
-
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
done()
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
checkBundlingFromEsmFilesDirectTask.displayName = 'check-bundling-from-esm-files-direct'
|
|
74
|
-
checkBundlingFromEsmFilesDirectTask.description = 'In view to detect bundling side effects this task will create intermediary file for each individual export from this package and then create rollup config for each of them and bundle'
|
|
75
|
-
checkBundlingFromEsmFilesDirectTask.flags = null
|
|
76
|
-
|
|
77
|
-
export { checkBundlingFromEsmFilesDirectTask }
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import colors from 'ansi-colors'
|
|
2
|
-
import log from 'fancy-log'
|
|
3
|
-
import {
|
|
4
|
-
existsSync,
|
|
5
|
-
mkdirSync,
|
|
6
|
-
rmSync,
|
|
7
|
-
writeFileSync
|
|
8
|
-
} from 'fs'
|
|
9
|
-
import {
|
|
10
|
-
dirname,
|
|
11
|
-
join,
|
|
12
|
-
parse,
|
|
13
|
-
relative
|
|
14
|
-
} from 'path'
|
|
15
|
-
import { rollup } from 'rollup'
|
|
16
|
-
import {
|
|
17
|
-
packageSourcesDirectory as sourcesDir,
|
|
18
|
-
packageTestsBundlesDirectory as bundleDir
|
|
19
|
-
} from '../../_utils.mjs'
|
|
20
|
-
import { getRollupConfigurationFor } from '../../configs/build.conf.mjs'
|
|
21
|
-
import { sourcesFiles } from '../../configs/check-bundling.conf.mjs'
|
|
22
|
-
|
|
23
|
-
const {
|
|
24
|
-
red,
|
|
25
|
-
green,
|
|
26
|
-
magenta
|
|
27
|
-
} = colors
|
|
28
|
-
|
|
29
|
-
const checkBundlingFromEsmFilesImportTask = async ( done ) => {
|
|
30
|
-
|
|
31
|
-
const outputDir = join( bundleDir, 'from_files_import' )
|
|
32
|
-
const temporariesDir = join( outputDir, '.tmp' )
|
|
33
|
-
|
|
34
|
-
if ( existsSync( outputDir ) ) {
|
|
35
|
-
log( 'Clean up', magenta( outputDir ) )
|
|
36
|
-
rmSync( outputDir, { recursive: true } )
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
const config = getRollupConfigurationFor( 'check-bundling-from-esm-files-import' )
|
|
40
|
-
for ( let sourceFile of sourcesFiles ) {
|
|
41
|
-
|
|
42
|
-
const {
|
|
43
|
-
dir: sourceDir,
|
|
44
|
-
base: sourceBase,
|
|
45
|
-
name: sourceName
|
|
46
|
-
} = parse( sourceFile )
|
|
47
|
-
const specificFilePath = sourceFile.replace( sourcesDir, '' )
|
|
48
|
-
const specificDir = dirname( specificFilePath )
|
|
49
|
-
|
|
50
|
-
// Create temp import file per file in package
|
|
51
|
-
const temporaryFileName = `${ sourceName }.import.js`
|
|
52
|
-
const temporaryDir = join( temporariesDir, specificDir )
|
|
53
|
-
const temporaryFile = join( temporaryDir, temporaryFileName )
|
|
54
|
-
const importDir = relative( temporaryDir, sourceDir )
|
|
55
|
-
const importFile = join( importDir, sourceBase )
|
|
56
|
-
const temporaryFileData = `import '${ importFile.replace( /\\/g, '/' ) }'`
|
|
57
|
-
|
|
58
|
-
// Bundle tmp file and check content for side effects
|
|
59
|
-
const bundleFileName = `${ sourceName }.bundle.js`
|
|
60
|
-
const bundleFilePath = join( outputDir, specificDir, bundleFileName )
|
|
61
|
-
|
|
62
|
-
config.input = temporaryFile
|
|
63
|
-
config.output.file = bundleFilePath
|
|
64
|
-
|
|
65
|
-
// create tmp file
|
|
66
|
-
try {
|
|
67
|
-
|
|
68
|
-
mkdirSync( temporaryDir, { recursive: true } )
|
|
69
|
-
writeFileSync( temporaryFile, temporaryFileData )
|
|
70
|
-
|
|
71
|
-
const bundle = await rollup( config )
|
|
72
|
-
const { output } = await bundle.generate( config.output )
|
|
73
|
-
|
|
74
|
-
let code = output[ 0 ].code
|
|
75
|
-
if ( code.length > 1 ) {
|
|
76
|
-
log( red( `[${ specificFilePath }] contain side-effects !` ) )
|
|
77
|
-
await bundle.write( config.output )
|
|
78
|
-
} else {
|
|
79
|
-
log( green( `[${ specificFilePath }] is side-effect free.` ) )
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
} catch ( error ) {
|
|
83
|
-
log( red( error.message ) )
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
done()
|
|
89
|
-
|
|
90
|
-
}
|
|
91
|
-
checkBundlingFromEsmFilesImportTask.displayName = 'check-bundling-from-esm-files-import'
|
|
92
|
-
checkBundlingFromEsmFilesImportTask.description = 'In view to detect bundling side effects this task will create intermediary file for each individual export from this package and then create rollup config for each of them and bundle'
|
|
93
|
-
checkBundlingFromEsmFilesImportTask.flags = null
|
|
94
|
-
|
|
95
|
-
export { checkBundlingFromEsmFilesImportTask }
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { series } from 'gulp'
|
|
2
|
-
import { checkBundlingFromEsmBuildImportTask } from './check-bundling-from-esm-build-import.task.mjs'
|
|
3
|
-
import { checkBundlingFromEsmFilesDirectTask } from './check-bundling-from-esm-files-direct.task.mjs'
|
|
4
|
-
import { checkBundlingFromEsmFilesImportTask } from './check-bundling-from-esm-files-import.task.mjs'
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* @description In view to detect bundling side effects this task will
|
|
8
|
-
* create intermediary file for each individual export from this package
|
|
9
|
-
* and then create rollup config for each of them and bundle
|
|
10
|
-
* Todo: Check for differents target env like next task below this one
|
|
11
|
-
*/
|
|
12
|
-
const checkBundlingTask = series(
|
|
13
|
-
checkBundlingFromEsmFilesImportTask,
|
|
14
|
-
checkBundlingFromEsmBuildImportTask,
|
|
15
|
-
checkBundlingFromEsmFilesDirectTask
|
|
16
|
-
)
|
|
17
|
-
checkBundlingTask.displayName = 'check-bundling'
|
|
18
|
-
checkBundlingTask.description = 'In view to detect bundling side effects this task will create intermediary file for each individual export and then try to bundle them.'
|
|
19
|
-
|
|
20
|
-
export { checkBundlingTask }
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { series } from 'gulp'
|
|
2
|
-
import { runBenchmarksTestsTask } from './benchmarks/run-benchmarks.task.mjs'
|
|
3
|
-
import { runUnitTestsTask } from './unit-tests/run-unit-tests.task.mjs'
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* @method npm run test
|
|
7
|
-
* @global
|
|
8
|
-
* @description Will run unit tests and benchmarks for backend (node) and frontend (web-test-runner) environments
|
|
9
|
-
*/
|
|
10
|
-
const runTestsTask = series(
|
|
11
|
-
runBenchmarksTestsTask,
|
|
12
|
-
runUnitTestsTask,
|
|
13
|
-
)
|
|
14
|
-
runTestsTask.displayName = 'run-tests'
|
|
15
|
-
runTestsTask.description = 'Will run unit tests and benchmarks for backend (node) and frontend (web-test-runner) environments.'
|
|
16
|
-
runTestsTask.flags = null
|
|
17
|
-
|
|
18
|
-
export { runTestsTask }
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import colors from 'ansi-colors'
|
|
2
|
-
import log from 'fancy-log'
|
|
3
|
-
import { rollup } from 'rollup'
|
|
4
|
-
import { buildUnitTestsBackendConfig as config } from '../../configs/build-unit-tests-backend.conf.mjs'
|
|
5
|
-
|
|
6
|
-
const {
|
|
7
|
-
red,
|
|
8
|
-
green
|
|
9
|
-
} = colors
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* @description Will generate unit test bundles based on provided configs
|
|
13
|
-
*/
|
|
14
|
-
const buildUnitTestsBackendTask = async ( done ) => {
|
|
15
|
-
|
|
16
|
-
if ( config === undefined || config === null || config.length === 0 ) {
|
|
17
|
-
done( red( 'Empty configuration!' ) )
|
|
18
|
-
return
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
log( 'Building', green( config.output.file ) )
|
|
22
|
-
|
|
23
|
-
try {
|
|
24
|
-
|
|
25
|
-
const bundle = await rollup( config )
|
|
26
|
-
await bundle.write( config.output )
|
|
27
|
-
|
|
28
|
-
} catch ( error ) {
|
|
29
|
-
|
|
30
|
-
done( red( error.message ) )
|
|
31
|
-
return
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
done()
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
buildUnitTestsBackendTask.displayName = 'build-unit-tests-backend'
|
|
39
|
-
buildUnitTestsBackendTask.description = 'Will generate unit test bundles based on provided configs'
|
|
40
|
-
buildUnitTestsBackendTask.flags = null
|
|
41
|
-
|
|
42
|
-
export { buildUnitTestsBackendTask }
|