itee-validators 5.6.0 → 6.0.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/node.js.yml +2 -2
- package/.releaserc.mjs +94 -0
- package/.tasks/.builds/build-benchmarks.task.mjs +16 -0
- package/.tasks/.builds/build-tests.task.mjs +18 -0
- package/.tasks/.builds/build-unit-tests.task.mjs +16 -0
- package/.tasks/.builds/build.task.mjs +46 -0
- package/.tasks/.cleans/clean.task.mjs +23 -0
- package/.tasks/.docs/doc.task.mjs +35 -0
- package/.tasks/.helps/help.task.mjs +151 -0
- package/.tasks/.lints/lint.task.mjs +37 -0
- package/.tasks/.patches/patch.task.mjs +13 -0
- package/.tasks/.releases/release.task.mjs +26 -0
- package/.tasks/.tests/benchmarks/build-benchmarks-backend.task.mjs +42 -0
- package/.tasks/{tests/benchmarks/compute-benchmarks.mjs → .tests/benchmarks/compute-benchmarks.task.mjs} +46 -51
- package/.tasks/.tests/benchmarks/run-benchmarks-for-backend.task.mjs +39 -0
- package/.tasks/.tests/benchmarks/run-benchmarks-for-frontend.task.mjs +41 -0
- package/.tasks/.tests/benchmarks/run-benchmarks.task.mjs +18 -0
- package/.tasks/{tests/bundling/check-bundling-from-esm-build-import.mjs → .tests/bundling/check-bundling-from-esm-build-import.task.mjs} +31 -75
- package/.tasks/.tests/bundling/check-bundling-from-esm-files-direct.task.mjs +77 -0
- package/.tasks/.tests/bundling/check-bundling-from-esm-files-import.task.mjs +95 -0
- package/.tasks/.tests/bundling/check-bundling.task.mjs +20 -0
- package/.tasks/.tests/run-tests.task.mjs +18 -0
- package/.tasks/.tests/unit-tests/build-unit-tests-backend.task.mjs +42 -0
- package/.tasks/{tests/unit-tests/compute-unit-tests.mjs → .tests/unit-tests/compute-unit-tests.task.mjs} +152 -193
- package/.tasks/.tests/unit-tests/run-unit-tests-for-backend.task.mjs +44 -0
- package/.tasks/.tests/unit-tests/run-unit-tests-for-frontend.task.mjs +41 -0
- package/.tasks/.tests/unit-tests/run-unit-tests.task.mjs +18 -0
- package/.tasks/_refresh-gulpfile.task.mjs +65 -0
- package/.tasks/_utils.mjs +159 -33
- package/.tasks/configs/benchmarks.conf.mjs +57 -0
- package/.tasks/configs/build-benchmarks-backend.conf.mjs +51 -0
- package/.tasks/configs/build-unit-tests-backend.conf.mjs +46 -0
- package/.tasks/configs/build.conf.mjs +354 -0
- package/.tasks/configs/check-bundling.conf.mjs +26 -0
- package/.tasks/configs/clean.conf.mjs +9 -0
- package/.tasks/configs/compute-benchmarks.conf.mjs +28 -0
- package/.tasks/configs/compute-unit-tests.conf.mjs +27 -0
- package/.tasks/configs/doc.conf.json +50 -0
- package/.tasks/configs/eslint.conf.mjs +121 -0
- package/.tasks/configs/units.conf.mjs +27 -0
- package/.tasks/itee-benchmarks-framework.js +186 -0
- package/.tasks/itee-reporter.mjs +217 -0
- package/CHANGELOG.md +12 -0
- package/builds/itee-validators.cjs.js +53 -15
- package/builds/itee-validators.cjs.js.map +1 -1
- package/builds/itee-validators.cjs.min.js +36 -35
- package/builds/itee-validators.esm.js +25 -2
- package/builds/itee-validators.esm.js.map +1 -1
- package/builds/itee-validators.esm.min.js +3 -3
- package/builds/itee-validators.iife.js +25 -4
- package/builds/itee-validators.iife.js.map +1 -1
- package/builds/itee-validators.iife.min.js +10 -10
- package/package.json +49 -41
- package/sources/cores/_cores.js +10 -10
- package/sources/cores/arrays/_arrays.js +12 -12
- package/sources/cores/arrays/isArrayOfArray.js +2 -2
- package/sources/cores/arrays/isArrayOfBoolean.js +3 -3
- package/sources/cores/arrays/isArrayOfFunction.js +3 -3
- package/sources/cores/arrays/isArrayOfMultiElement.js +1 -1
- package/sources/cores/arrays/isArrayOfNull.js +3 -3
- package/sources/cores/arrays/isArrayOfNumber.js +3 -3
- package/sources/cores/arrays/isArrayOfObject.js +3 -3
- package/sources/cores/arrays/isArrayOfSingleElement.js +1 -1
- package/sources/cores/arrays/isArrayOfString.js +3 -3
- package/sources/cores/arrays/isArrayOfUndefined.js +3 -3
- package/sources/cores/arrays/isEmptyArray.js +1 -1
- package/sources/cores/booleans/_booleans.js +2 -2
- package/sources/cores/booleans/isTrue.js +1 -1
- package/sources/cores/cores.js +8 -8
- package/sources/cores/functions/_functions.js +1 -1
- package/sources/cores/numbers/_numbers.js +6 -6
- package/sources/cores/numbers/isNumber.js +3 -3
- package/sources/cores/objects/_objects.js +2 -2
- package/sources/cores/objects/isEmptyObject.js +1 -1
- package/sources/cores/objects/isObject.js +1 -1
- package/sources/cores/strings/_strings.js +3 -3
- package/sources/cores/strings/isBlankString.js +2 -2
- package/sources/cores/strings/isEmptyString.js +1 -1
- package/sources/cores/symbols/_symbols.js +1 -1
- package/sources/cores/tests/isTestUnitGenerator.js +5 -6
- package/sources/cores/typed-arrays/_typedArrays.js +12 -12
- package/sources/cores/voids/_voids.js +4 -4
- package/sources/cores/voids/isEmpty.js +4 -4
- package/sources/file-system/_file-system.js +9 -9
- package/sources/file-system/block-devices/_blockDevices.js +3 -3
- package/sources/file-system/block-devices/isBlockDevicePath.js +3 -3
- package/sources/file-system/block-devices/isValidBlockDevicePath.js +2 -2
- package/sources/file-system/character-devices/_characterDevices.js +3 -3
- package/sources/file-system/character-devices/isCharacterDevicePath.js +3 -3
- package/sources/file-system/character-devices/isValidCharacterDevicePath.js +2 -2
- package/sources/file-system/directories/_directories.js +4 -4
- package/sources/file-system/directories/isDirectoryPath.js +3 -3
- package/sources/file-system/directories/isEmptyDirectory.js +2 -2
- package/sources/file-system/directories/isValidDirectoryPath.js +2 -2
- package/sources/file-system/fifo-pipes/_fifoPipes.js +3 -3
- package/sources/file-system/fifo-pipes/isFIFOPath.js +3 -3
- package/sources/file-system/fifo-pipes/isValidFIFOPath.js +2 -2
- package/sources/file-system/files/_files.js +4 -4
- package/sources/file-system/files/isEmptyFile.js +3 -3
- package/sources/file-system/files/isFilePath.js +3 -3
- package/sources/file-system/files/isValidFilePath.js +2 -2
- package/sources/file-system/paths/_paths.js +2 -2
- package/sources/file-system/paths/isValidPath.js +1 -1
- package/sources/file-system/sockets/_sockets.js +3 -3
- package/sources/file-system/sockets/isSocketPath.js +3 -3
- package/sources/file-system/sockets/isValidSocketPath.js +2 -2
- package/sources/file-system/symbolic-links/_symbolicLinks.js +3 -3
- package/sources/file-system/symbolic-links/isSymbolicLinkPath.js +3 -3
- package/sources/file-system/symbolic-links/isValidSymbolicLinkPath.js +2 -2
- package/sources/itee-validators.js +4 -4
- package/sources/maths/_maths.js +1 -1
- package/sources/physics/_physics.js +2 -2
- package/sources/physics/temperatures/_temperatures.js +5 -5
- package/sources/physics/temperatures/isCelsius.js +2 -2
- package/sources/physics/temperatures/isFahrenheit.js +2 -2
- package/sources/physics/temperatures/isKelvin.js +2 -2
- package/sources/physics/temperatures/isTemperature.js +3 -3
- package/.tasks/builds/build.mjs +0 -65
- package/.tasks/cleans/clean.mjs +0 -20
- package/.tasks/docs/doc.mjs +0 -37
- package/.tasks/helps/help.mjs +0 -195
- package/.tasks/lints/lint.mjs +0 -33
- package/.tasks/patches/patch.mjs +0 -9
- package/.tasks/tests/benchmarks/bundle-benchmarks.mjs +0 -33
- package/.tasks/tests/benchmarks/run-benchmarks-for-backend.mjs +0 -24
- package/.tasks/tests/benchmarks/run-benchmarks-for-frontend.mjs +0 -38
- package/.tasks/tests/bundling/check-bundling-from-esm-files-direct.mjs +0 -129
- package/.tasks/tests/bundling/check-bundling-from-esm-files-import.mjs +0 -149
- package/.tasks/tests/unit-tests/bundle-unit-tests.mjs +0 -33
- package/.tasks/tests/unit-tests/run-unit-tests-for-backend.mjs +0 -25
- package/.tasks/tests/unit-tests/run-unit-tests-for-frontend.mjs +0 -41
package/.tasks/helps/help.mjs
DELETED
|
@@ -1,195 +0,0 @@
|
|
|
1
|
-
import childProcess from 'child_process'
|
|
2
|
-
import log from 'fancy-log'
|
|
3
|
-
import colors from 'ansi-colors'
|
|
4
|
-
import {
|
|
5
|
-
packageInfos,
|
|
6
|
-
Indenter
|
|
7
|
-
} from '../_utils.mjs'
|
|
8
|
-
|
|
9
|
-
const {
|
|
10
|
-
red,
|
|
11
|
-
green,
|
|
12
|
-
blue,
|
|
13
|
-
cyan,
|
|
14
|
-
yellow,
|
|
15
|
-
magenta,
|
|
16
|
-
unstyle
|
|
17
|
-
} = colors
|
|
18
|
-
|
|
19
|
-
function getPrettyPackageName() {
|
|
20
|
-
|
|
21
|
-
let packageName = ''
|
|
22
|
-
|
|
23
|
-
const nameSplits = packageInfos.name.split( '-' )
|
|
24
|
-
for ( const nameSplit of nameSplits ) {
|
|
25
|
-
packageName += nameSplit.charAt( 0 ).toUpperCase() + nameSplit.slice( 1 ) + ' '
|
|
26
|
-
}
|
|
27
|
-
packageName = packageName.slice( 0, -1 )
|
|
28
|
-
|
|
29
|
-
return packageName
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
function getPrettyPackageVersion() {
|
|
34
|
-
|
|
35
|
-
return 'v' + packageInfos.version
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
function getPrettyNodeVersion() {
|
|
40
|
-
|
|
41
|
-
let nodeVersion = 'vX.x.ₓ'
|
|
42
|
-
|
|
43
|
-
try {
|
|
44
|
-
nodeVersion = childProcess.execFileSync( 'node', [ '--version' ] )
|
|
45
|
-
.toString()
|
|
46
|
-
.replace( /(\r\n|\n|\r)/gm, '' )
|
|
47
|
-
} catch ( e ) {
|
|
48
|
-
log( red( e ) )
|
|
49
|
-
|
|
50
|
-
if ( e.message.includes( 'ENOENT' ) ) {
|
|
51
|
-
nodeVersion += yellow( ' Not seems to be accessible from the path environment.' )
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
return ' node: ' + nodeVersion
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
function getPrettyNpmVersion() {
|
|
60
|
-
|
|
61
|
-
let npmVersion = 'X.x.ₓ'
|
|
62
|
-
|
|
63
|
-
try {
|
|
64
|
-
npmVersion = childProcess.execFileSync( 'npm', [ '--version' ] )
|
|
65
|
-
.toString()
|
|
66
|
-
.replace( /(\r\n|\n|\r)/gm, '' )
|
|
67
|
-
} catch ( e ) {
|
|
68
|
-
log( red( e ) )
|
|
69
|
-
|
|
70
|
-
if ( e.message.includes( 'ENOENT' ) ) {
|
|
71
|
-
npmVersion += yellow( ' Not seems to be accessible from the path environment.' )
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
return ' npm: v' + npmVersion
|
|
76
|
-
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
function alignTextCenter( text, width ) {
|
|
80
|
-
|
|
81
|
-
const unstyledText = unstyle( text.repeat( 1 ) )
|
|
82
|
-
const marginLength = ( width - unstyledText.length ) / 2
|
|
83
|
-
|
|
84
|
-
let leftMargin, rightMargin
|
|
85
|
-
if ( Number.isInteger( marginLength ) ) {
|
|
86
|
-
leftMargin = marginLength
|
|
87
|
-
rightMargin = marginLength
|
|
88
|
-
} else {
|
|
89
|
-
const flooredMargin = Math.floor( marginLength )
|
|
90
|
-
leftMargin = flooredMargin
|
|
91
|
-
rightMargin = flooredMargin + 1
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
return ' '.repeat( leftMargin ) + text + ' '.repeat( rightMargin )
|
|
95
|
-
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
function alignTextLeft( text, width ) {
|
|
99
|
-
|
|
100
|
-
const unstyledText = unstyle( text.repeat( 1 ) )
|
|
101
|
-
let repeatTime = width - unstyledText.length
|
|
102
|
-
repeatTime = ( repeatTime > 0 ) ? repeatTime : 0
|
|
103
|
-
|
|
104
|
-
return text + ' '.repeat( repeatTime )
|
|
105
|
-
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
function alignTextRight( text, width ) {
|
|
109
|
-
|
|
110
|
-
const unstyledText = unstyle( text.repeat( 1 ) )
|
|
111
|
-
let repeatTime = width - unstyledText.length
|
|
112
|
-
repeatTime = ( repeatTime > 0 ) ? repeatTime : 0
|
|
113
|
-
|
|
114
|
-
return ' '.repeat( repeatTime ) + text
|
|
115
|
-
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
function help( done ) {
|
|
119
|
-
|
|
120
|
-
const bannerWidth = 70
|
|
121
|
-
const prettyPackageName = getPrettyPackageName()
|
|
122
|
-
const prettyPackageVersion = getPrettyPackageVersion()
|
|
123
|
-
const prettyNodeVersion = getPrettyNodeVersion()
|
|
124
|
-
const prettyNpmVersion = getPrettyNpmVersion()
|
|
125
|
-
|
|
126
|
-
const tableCharset = {
|
|
127
|
-
topLeftCorner: '┏',
|
|
128
|
-
topRightCorner: '┓',
|
|
129
|
-
bottomRightCorner: '┛',
|
|
130
|
-
bottomLeftCorner: '┗',
|
|
131
|
-
horizontalBorder: '━',
|
|
132
|
-
horizontalSeparator: '─',
|
|
133
|
-
leftJoinSeparator: '┠',
|
|
134
|
-
rightJoinSeparator: '┨',
|
|
135
|
-
verticalBorder: '┃',
|
|
136
|
-
verticalSeparator: '',
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
const mainBorder = tableCharset.horizontalBorder.repeat( bannerWidth )
|
|
140
|
-
const thinBorder = tableCharset.horizontalSeparator.repeat( bannerWidth )
|
|
141
|
-
const tableTop = `${ tableCharset.topLeftCorner }${ mainBorder }${ tableCharset.topRightCorner }`
|
|
142
|
-
const tableSeparator = `${ tableCharset.leftJoinSeparator }${ thinBorder }${ tableCharset.rightJoinSeparator }`
|
|
143
|
-
const tableBottom = `${ tableCharset.bottomLeftCorner }${ mainBorder }${ tableCharset.bottomRightCorner }`
|
|
144
|
-
const tableLine = ( innerText ) => `${ tableCharset.verticalBorder }${ innerText }${ tableCharset.verticalBorder }`
|
|
145
|
-
|
|
146
|
-
const I = new Indenter( ' ', 5 )
|
|
147
|
-
const npmRun = blue( 'npm run' )
|
|
148
|
-
|
|
149
|
-
log( '' )
|
|
150
|
-
log( tableTop )
|
|
151
|
-
log( tableLine( alignTextCenter( 'HELP', bannerWidth ) ) )
|
|
152
|
-
log( tableLine( alignTextCenter( prettyPackageName, bannerWidth ) ) )
|
|
153
|
-
log( tableLine( alignTextCenter( prettyPackageVersion, bannerWidth ) ) )
|
|
154
|
-
log( tableSeparator )
|
|
155
|
-
log( tableLine( alignTextLeft( prettyNodeVersion, bannerWidth ) ) )
|
|
156
|
-
log( tableLine( alignTextLeft( prettyNpmVersion, bannerWidth ) ) )
|
|
157
|
-
log( tableBottom )
|
|
158
|
-
log( I._, 'Available commands are:' )
|
|
159
|
-
log( I.__, npmRun, cyan( 'help' ), '- Display this help.' )
|
|
160
|
-
log( I.__, npmRun, cyan( 'patch' ), '- Will apply some patch/replacements in dependencies.', red( '(Apply only once after run "npm install")' ) )
|
|
161
|
-
log( I.__, npmRun, cyan( 'clean' ), '- Will delete builds and temporary folders.' )
|
|
162
|
-
log( I.__, npmRun, cyan( 'lint' ), '- Will run the eslint in pedantic mode with auto fix when possible.' )
|
|
163
|
-
log( I.__, npmRun, cyan( 'doc' ), '- Will run jsdoc, and create documentation under `documentation` folder, using the docdash theme' )
|
|
164
|
-
log( I.__, npmRun, cyan( 'test' ), '- Will run the test framworks (unit and bench), and create reports under `documentation/report` folder, using the mochawesome theme' )
|
|
165
|
-
log( I.__, npmRun, cyan( 'unit' ), '- Will run the karma server for unit tests.' )
|
|
166
|
-
log( I.__, npmRun, cyan( 'bench' ), '- Will run the karma server for benchmarks.' )
|
|
167
|
-
log( I.__, npmRun, cyan( 'build' ), yellow( '--' ), green( '<options>' ), '- Will build the application for development and/or production environments.' )
|
|
168
|
-
log( I.___, yellow( 'Note: The two dash are only required if you provide options !' ) )
|
|
169
|
-
log( I.___, 'The available', green( '<options>' ), 'are:' )
|
|
170
|
-
log( I.____, green( '-i' ), 'or', green( '--input' ), '- The main file path to build', cyan( '[Default: "sources/main.js"]' ), '.' )
|
|
171
|
-
log( I.____, green( '-o' ), 'or', green( '--output' ), '- The folder where output the build', cyan( '[Default: "builds"]' ), '.' )
|
|
172
|
-
log(
|
|
173
|
-
I.____,
|
|
174
|
-
green( '-f:' ),
|
|
175
|
-
magenta( '<format>' ),
|
|
176
|
-
'or',
|
|
177
|
-
green( '--format:' ),
|
|
178
|
-
magenta( '<format>' ),
|
|
179
|
-
' - to specify the output build type. Where format could be any of:', magenta( 'cjs, esm, iife, umd' ), '.'
|
|
180
|
-
)
|
|
181
|
-
log( I.____, green( '-e:' ), magenta( '<env>' ), 'or', green( '--env:' ), magenta( '<env>' ), ' - to specify the build environment. Where env could be any of:', magenta(
|
|
182
|
-
'dev' ), magenta( 'prod' ), cyan( '[Default: "dev"]' ), '.' )
|
|
183
|
-
log( I.____, green( '-s' ), 'or', green( '--sourcemap' ), ' - to build with related source map', cyan( '[Default: true]' ), '.' )
|
|
184
|
-
log( I.____, green( '-t' ), 'or', green( '--treeshake' ), ' - allow to perform treeshaking when building', cyan( '[Default: true]' ), '.' )
|
|
185
|
-
log( I.__, npmRun, cyan( 'release' ), '- Will run all the lint, test stuff, and if succeed will build the application.' )
|
|
186
|
-
log( '' )
|
|
187
|
-
log( I._, 'In case you have', blue( 'gulp' ), 'installed globally, you could use also:' )
|
|
188
|
-
log( I.__, blue( 'gulp' ), cyan( 'command' ), '- It will perform the command like using "npm run" but with less characters to type... Because you\'re a developer, right ?' )
|
|
189
|
-
log( '' )
|
|
190
|
-
|
|
191
|
-
done()
|
|
192
|
-
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
export { help }
|
package/.tasks/lints/lint.mjs
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { getGulpConfigForTask } from '../../configs/gulp.conf.mjs'
|
|
2
|
-
import gulp from 'gulp'
|
|
3
|
-
import eslint from 'gulp-eslint'
|
|
4
|
-
import log from 'fancy-log'
|
|
5
|
-
|
|
6
|
-
function lint( done ) {
|
|
7
|
-
|
|
8
|
-
const filesToLint = getGulpConfigForTask( 'lint' )
|
|
9
|
-
|
|
10
|
-
for ( let fileIndex = 0, numberOfFiles = filesToLint.length ; fileIndex < numberOfFiles ; fileIndex++ ) {
|
|
11
|
-
log( `[${ fileIndex + 1 }/${ numberOfFiles }] Lint ${ filesToLint[ fileIndex ] }` )
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
return gulp.src( filesToLint, { base: './' } )
|
|
15
|
-
.pipe( eslint( {
|
|
16
|
-
allowInlineConfig: true,
|
|
17
|
-
globals: [],
|
|
18
|
-
fix: true,
|
|
19
|
-
quiet: false,
|
|
20
|
-
envs: [],
|
|
21
|
-
configFile: './configs/eslint.conf.js',
|
|
22
|
-
parserOptions: {},
|
|
23
|
-
plugins: [],
|
|
24
|
-
rules: {},
|
|
25
|
-
useEslintrc: false
|
|
26
|
-
} ) )
|
|
27
|
-
.pipe( eslint.format( 'stylish' ) )
|
|
28
|
-
.pipe( gulp.dest( '.' ) )
|
|
29
|
-
.pipe( eslint.failAfterError() )
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export { lint }
|
package/.tasks/patches/patch.mjs
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import rollupBenchesConfigurator from '../../../configs/rollup.benchs.conf.js'
|
|
2
|
-
import log from 'fancy-log'
|
|
3
|
-
import { rollup } from 'rollup'
|
|
4
|
-
import colors from 'ansi-colors'
|
|
5
|
-
|
|
6
|
-
const red = colors.red
|
|
7
|
-
|
|
8
|
-
async function bundleBenchmarks( done ) {
|
|
9
|
-
|
|
10
|
-
const configs = rollupBenchesConfigurator()
|
|
11
|
-
|
|
12
|
-
for ( let config of configs ) {
|
|
13
|
-
|
|
14
|
-
log( `Building ${ config.output.file }` )
|
|
15
|
-
|
|
16
|
-
try {
|
|
17
|
-
|
|
18
|
-
const bundle = await rollup( config )
|
|
19
|
-
await bundle.write( config.output )
|
|
20
|
-
|
|
21
|
-
} catch ( error ) {
|
|
22
|
-
|
|
23
|
-
log( red( error ) )
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
done()
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export { bundleBenchmarks }
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import path from 'path'
|
|
2
|
-
import childProcess from 'child_process'
|
|
3
|
-
import {
|
|
4
|
-
getDirname,
|
|
5
|
-
packageInfos
|
|
6
|
-
} from '../../_utils.mjs'
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
function runBenchmarksForBackend( done ) {
|
|
10
|
-
|
|
11
|
-
const projectDir = getDirname()
|
|
12
|
-
const benchsPath = path.join( projectDir, `tests/benchmarks/builds/${ packageInfos.name }.benchs.cjs.js` )
|
|
13
|
-
const benchmark = childProcess.spawn( 'node', [ benchsPath ], { stdio: 'inherit' } )
|
|
14
|
-
benchmark.on( 'close', ( code ) => {
|
|
15
|
-
|
|
16
|
-
( code === 0 )
|
|
17
|
-
? done()
|
|
18
|
-
: done( `benchmark exited with code ${ code }` )
|
|
19
|
-
|
|
20
|
-
} )
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export { runBenchmarksForBackend }
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import path from 'path'
|
|
2
|
-
import karma from 'karma'
|
|
3
|
-
import log from 'fancy-log'
|
|
4
|
-
import colors from 'ansi-colors'
|
|
5
|
-
import { getDirname } from '../../_utils.mjs'
|
|
6
|
-
|
|
7
|
-
const {
|
|
8
|
-
red,
|
|
9
|
-
green,
|
|
10
|
-
blue,
|
|
11
|
-
cyan,
|
|
12
|
-
yellow,
|
|
13
|
-
magenta
|
|
14
|
-
} = colors
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
async function runBenchmarksForFrontend( done ) {
|
|
18
|
-
|
|
19
|
-
const projectDir = getDirname()
|
|
20
|
-
const configFile = path.normalize( `${ projectDir }/configs/karma.benchs.conf.js` )
|
|
21
|
-
const karmaConfig = karma.config.parseConfig( configFile )
|
|
22
|
-
const karmaServer = new karma.Server( karmaConfig, ( exitCode ) => {
|
|
23
|
-
if ( exitCode === 0 ) {
|
|
24
|
-
log( `Karma server exit with code ${ exitCode }` )
|
|
25
|
-
done()
|
|
26
|
-
} else {
|
|
27
|
-
done( `Karma server exit with code ${ exitCode }` )
|
|
28
|
-
}
|
|
29
|
-
} )
|
|
30
|
-
karmaServer.on( 'browser_error', ( browser, error ) => {
|
|
31
|
-
log( red( error.message ) )
|
|
32
|
-
} )
|
|
33
|
-
|
|
34
|
-
await karmaServer.start()
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export { runBenchmarksForFrontend }
|
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
join,
|
|
3
|
-
normalize,
|
|
4
|
-
basename,
|
|
5
|
-
extname,
|
|
6
|
-
dirname,
|
|
7
|
-
relative
|
|
8
|
-
} from 'path'
|
|
9
|
-
import {
|
|
10
|
-
existsSync,
|
|
11
|
-
rmSync,
|
|
12
|
-
mkdirSync,
|
|
13
|
-
writeFileSync
|
|
14
|
-
} from 'fs'
|
|
15
|
-
import glob from 'glob'
|
|
16
|
-
import { nodeResolve } from '@rollup/plugin-node-resolve'
|
|
17
|
-
import cleanup from 'rollup-plugin-cleanup'
|
|
18
|
-
import { rollup } from 'rollup'
|
|
19
|
-
import { getGulpConfigForTask } from '../../../configs/gulp.conf.mjs'
|
|
20
|
-
import { getDirname } from '../../_utils.mjs'
|
|
21
|
-
import log from 'fancy-log'
|
|
22
|
-
import colors from 'ansi-colors'
|
|
23
|
-
|
|
24
|
-
const {
|
|
25
|
-
red,
|
|
26
|
-
green,
|
|
27
|
-
blue,
|
|
28
|
-
cyan,
|
|
29
|
-
yellow,
|
|
30
|
-
magenta
|
|
31
|
-
} = colors
|
|
32
|
-
|
|
33
|
-
async function checkBundlingFromEsmFilesDirect( done ) {
|
|
34
|
-
|
|
35
|
-
const baseDir = getDirname()
|
|
36
|
-
const sourcesDir = join( baseDir, 'sources' )
|
|
37
|
-
const testsDir = join( baseDir, 'tests' )
|
|
38
|
-
const bundlesDir = join( testsDir, 'bundles' )
|
|
39
|
-
const outputDir = join( bundlesDir, 'from_files_direct' )
|
|
40
|
-
const filePathsToIgnore = getGulpConfigForTask( 'check-bundling' )
|
|
41
|
-
|
|
42
|
-
if ( existsSync( outputDir ) ) {
|
|
43
|
-
log( 'Clean up', magenta( outputDir ) )
|
|
44
|
-
rmSync( outputDir, { recursive: true } )
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const sourcesFiles = glob.sync( join( sourcesDir, '**' ) )
|
|
48
|
-
.map( filePath => normalize( filePath ) )
|
|
49
|
-
.filter( filePath => {
|
|
50
|
-
const fileName = basename( filePath )
|
|
51
|
-
const isJsFile = fileName.endsWith( '.js' )
|
|
52
|
-
const isNotPrivateFile = !fileName.startsWith( '_' )
|
|
53
|
-
const isNotIgnoredFile = !filePathsToIgnore.includes( fileName )
|
|
54
|
-
return isJsFile && isNotPrivateFile && isNotIgnoredFile
|
|
55
|
-
} )
|
|
56
|
-
|
|
57
|
-
for ( let sourceFile of sourcesFiles ) {
|
|
58
|
-
|
|
59
|
-
const specificFilePath = sourceFile.replace( sourcesDir, '' )
|
|
60
|
-
const specificDir = dirname( specificFilePath )
|
|
61
|
-
const fileName = basename( sourceFile, extname( sourceFile ) )
|
|
62
|
-
|
|
63
|
-
const bundleFileName = `${ fileName }.bundle.js`
|
|
64
|
-
const bundleFilePath = join( outputDir, specificDir, bundleFileName )
|
|
65
|
-
|
|
66
|
-
const config = {
|
|
67
|
-
input: sourceFile,
|
|
68
|
-
external: [ '' ],
|
|
69
|
-
plugins: [
|
|
70
|
-
nodeResolve( {
|
|
71
|
-
preferBuiltins: true
|
|
72
|
-
} ),
|
|
73
|
-
cleanup( {
|
|
74
|
-
comments: 'none'
|
|
75
|
-
} )
|
|
76
|
-
],
|
|
77
|
-
onwarn: ( {
|
|
78
|
-
loc,
|
|
79
|
-
frame,
|
|
80
|
-
message
|
|
81
|
-
} ) => {
|
|
82
|
-
|
|
83
|
-
// Ignore some errors
|
|
84
|
-
if ( message.includes( 'Circular dependency' ) ) { return }
|
|
85
|
-
if ( message.includes( 'Generated an empty chunk' ) ) { return }
|
|
86
|
-
|
|
87
|
-
if ( loc ) {
|
|
88
|
-
process.stderr.write( `/!\\ ${ loc.file } (${ loc.line }:${ loc.column }) ${ frame } ${ message }\n` )
|
|
89
|
-
} else {
|
|
90
|
-
process.stderr.write( `/!\\ ${ message }\n` )
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
},
|
|
94
|
-
treeshake: {
|
|
95
|
-
moduleSideEffects: true,
|
|
96
|
-
annotations: true,
|
|
97
|
-
correctVarValueBeforeDeclaration: true,
|
|
98
|
-
propertyReadSideEffects: true,
|
|
99
|
-
tryCatchDeoptimization: true,
|
|
100
|
-
unknownGlobalSideEffects: true
|
|
101
|
-
},
|
|
102
|
-
output: {
|
|
103
|
-
indent: '\t',
|
|
104
|
-
format: 'esm',
|
|
105
|
-
file: bundleFilePath
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
try {
|
|
110
|
-
|
|
111
|
-
log( `Bundling ${ config.output.file }` )
|
|
112
|
-
|
|
113
|
-
const bundle = await rollup( config )
|
|
114
|
-
await bundle.generate( config.output )
|
|
115
|
-
await bundle.write( config.output )
|
|
116
|
-
|
|
117
|
-
} catch ( error ) {
|
|
118
|
-
|
|
119
|
-
log( red( error.message ) )
|
|
120
|
-
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
done()
|
|
126
|
-
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
export { checkBundlingFromEsmFilesDirect }
|
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
join,
|
|
3
|
-
normalize,
|
|
4
|
-
basename,
|
|
5
|
-
parse,
|
|
6
|
-
dirname,
|
|
7
|
-
relative
|
|
8
|
-
} from 'path'
|
|
9
|
-
import {
|
|
10
|
-
existsSync,
|
|
11
|
-
rmSync,
|
|
12
|
-
mkdirSync,
|
|
13
|
-
writeFileSync
|
|
14
|
-
} from 'fs'
|
|
15
|
-
import log from 'fancy-log'
|
|
16
|
-
import glob from 'glob'
|
|
17
|
-
import { nodeResolve } from '@rollup/plugin-node-resolve'
|
|
18
|
-
import cleanup from 'rollup-plugin-cleanup'
|
|
19
|
-
import { rollup } from 'rollup'
|
|
20
|
-
import colors from 'ansi-colors'
|
|
21
|
-
import { getGulpConfigForTask } from '../../../configs/gulp.conf.mjs'
|
|
22
|
-
import { getDirname } from '../../_utils.mjs'
|
|
23
|
-
|
|
24
|
-
const {
|
|
25
|
-
red,
|
|
26
|
-
green,
|
|
27
|
-
blue,
|
|
28
|
-
cyan,
|
|
29
|
-
yellow,
|
|
30
|
-
magenta
|
|
31
|
-
} = colors
|
|
32
|
-
|
|
33
|
-
async function checkBundlingFromEsmFilesImport( done ) {
|
|
34
|
-
|
|
35
|
-
const baseDir = getDirname()
|
|
36
|
-
const sourcesDir = join( baseDir, 'sources' )
|
|
37
|
-
const testsDir = join( baseDir, 'tests' )
|
|
38
|
-
const bundleDir = join( testsDir, 'bundles' )
|
|
39
|
-
const outputDir = join( bundleDir, 'from_files_import' )
|
|
40
|
-
const temporariesDir = join( outputDir, '.tmp' )
|
|
41
|
-
const filePathsToIgnore = getGulpConfigForTask( 'check-bundling' )
|
|
42
|
-
|
|
43
|
-
if ( existsSync( outputDir ) ) {
|
|
44
|
-
log( 'Clean up', magenta( outputDir ) )
|
|
45
|
-
rmSync( outputDir, { recursive: true } )
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
const sourcesFiles = glob.sync( join( sourcesDir, '/**' ) )
|
|
49
|
-
.map( filePath => {
|
|
50
|
-
return normalize( filePath )
|
|
51
|
-
} )
|
|
52
|
-
.filter( filePath => {
|
|
53
|
-
const fileName = basename( filePath )
|
|
54
|
-
const isJsFile = fileName.endsWith( '.js' )
|
|
55
|
-
const isNotPrivateFile = !fileName.startsWith( '_' )
|
|
56
|
-
const isNotIgnoredFile = !filePathsToIgnore.includes( fileName )
|
|
57
|
-
return isJsFile && isNotPrivateFile && isNotIgnoredFile
|
|
58
|
-
} )
|
|
59
|
-
|
|
60
|
-
for ( let sourceFile of sourcesFiles ) {
|
|
61
|
-
|
|
62
|
-
const {
|
|
63
|
-
dir: sourceDir,
|
|
64
|
-
base: sourceBase,
|
|
65
|
-
name: sourceName
|
|
66
|
-
} = parse( sourceFile )
|
|
67
|
-
const specificFilePath = sourceFile.replace( sourcesDir, '' )
|
|
68
|
-
const specificDir = dirname( specificFilePath )
|
|
69
|
-
|
|
70
|
-
// Create temp import file per file in package
|
|
71
|
-
const temporaryFileName = `${ sourceName }.import.js`
|
|
72
|
-
const temporaryDir = join( temporariesDir, specificDir )
|
|
73
|
-
const temporaryFile = join( temporaryDir, temporaryFileName )
|
|
74
|
-
const importDir = relative( temporaryDir, sourceDir )
|
|
75
|
-
const importFile = join( importDir, sourceBase )
|
|
76
|
-
const temporaryFileData = `import '${ importFile.replace( /\\/g, '/' ) }'`
|
|
77
|
-
|
|
78
|
-
// Bundle tmp file and check content for side effects
|
|
79
|
-
const bundleFileName = `${ sourceName }.bundle.js`
|
|
80
|
-
const bundleFilePath = join( outputDir, specificDir, bundleFileName )
|
|
81
|
-
|
|
82
|
-
const config = {
|
|
83
|
-
input: temporaryFile,
|
|
84
|
-
plugins: [
|
|
85
|
-
nodeResolve(),
|
|
86
|
-
cleanup( {
|
|
87
|
-
comments: 'all' // else remove __PURE__ declaration... -_-'
|
|
88
|
-
} )
|
|
89
|
-
],
|
|
90
|
-
onwarn: ( {
|
|
91
|
-
loc,
|
|
92
|
-
frame,
|
|
93
|
-
message
|
|
94
|
-
} ) => {
|
|
95
|
-
|
|
96
|
-
// Ignore some errors
|
|
97
|
-
if ( message.includes( 'Circular dependency' ) ) { return }
|
|
98
|
-
if ( message.includes( 'Generated an empty chunk' ) ) { return }
|
|
99
|
-
|
|
100
|
-
if ( loc ) {
|
|
101
|
-
process.stderr.write( `/!\\ ${ loc.file } (${ loc.line }:${ loc.column }) ${ frame } ${ message }\n` )
|
|
102
|
-
} else {
|
|
103
|
-
process.stderr.write( `/!\\ ${ message }\n` )
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
},
|
|
107
|
-
treeshake: {
|
|
108
|
-
moduleSideEffects: true,
|
|
109
|
-
annotations: true,
|
|
110
|
-
correctVarValueBeforeDeclaration: true,
|
|
111
|
-
propertyReadSideEffects: true,
|
|
112
|
-
tryCatchDeoptimization: true,
|
|
113
|
-
unknownGlobalSideEffects: true
|
|
114
|
-
},
|
|
115
|
-
output: {
|
|
116
|
-
indent: '\t',
|
|
117
|
-
format: 'esm',
|
|
118
|
-
file: bundleFilePath
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
// create tmp file
|
|
123
|
-
try {
|
|
124
|
-
|
|
125
|
-
mkdirSync( temporaryDir, { recursive: true } )
|
|
126
|
-
writeFileSync( temporaryFile, temporaryFileData )
|
|
127
|
-
|
|
128
|
-
const bundle = await rollup( config )
|
|
129
|
-
const { output } = await bundle.generate( config.output )
|
|
130
|
-
|
|
131
|
-
let code = output[ 0 ].code
|
|
132
|
-
if ( code.length > 1 ) {
|
|
133
|
-
log( red( `[${ specificFilePath }] contain side-effects !` ) )
|
|
134
|
-
await bundle.write( config.output )
|
|
135
|
-
} else {
|
|
136
|
-
log( green( `[${ specificFilePath }] is side-effect free.` ) )
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
} catch ( error ) {
|
|
140
|
-
log( red( error.message ) )
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
done()
|
|
146
|
-
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
export { checkBundlingFromEsmFilesImport }
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import rollupUnitTestsConfigurator from '../../../configs/rollup.units.conf.js'
|
|
2
|
-
import log from 'fancy-log'
|
|
3
|
-
import { rollup } from 'rollup'
|
|
4
|
-
import colors from 'ansi-colors'
|
|
5
|
-
|
|
6
|
-
const red = colors.red
|
|
7
|
-
|
|
8
|
-
async function bundleUnitTests( done ) {
|
|
9
|
-
|
|
10
|
-
const configs = rollupUnitTestsConfigurator()
|
|
11
|
-
|
|
12
|
-
for ( let config of configs ) {
|
|
13
|
-
|
|
14
|
-
log( `Building ${ config.output.file }` )
|
|
15
|
-
|
|
16
|
-
try {
|
|
17
|
-
|
|
18
|
-
const bundle = await rollup( config )
|
|
19
|
-
await bundle.write( config.output )
|
|
20
|
-
|
|
21
|
-
} catch ( error ) {
|
|
22
|
-
|
|
23
|
-
log( red( error ) )
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
done()
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export { bundleUnitTests }
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { join } from 'path'
|
|
2
|
-
import { spawn } from 'child_process'
|
|
3
|
-
import {
|
|
4
|
-
getDirname,
|
|
5
|
-
packageInfos
|
|
6
|
-
} from '../../_utils.mjs'
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
function runUnitTestsForBackend( done ) {
|
|
10
|
-
|
|
11
|
-
const projectDir = getDirname()
|
|
12
|
-
const mochaPath = join( projectDir, 'node_modules/mocha/bin/mocha' )
|
|
13
|
-
const testsPath = join( projectDir, `tests/units/builds/${ packageInfos.name }.units.cjs.js` )
|
|
14
|
-
const mocha = spawn( 'node', [ mochaPath, testsPath ], { stdio: 'inherit' } )
|
|
15
|
-
mocha.on( 'close', ( code ) => {
|
|
16
|
-
|
|
17
|
-
( code === 0 )
|
|
18
|
-
? done()
|
|
19
|
-
: done( `mocha exited with code ${ code }` )
|
|
20
|
-
|
|
21
|
-
} )
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export { runUnitTestsForBackend }
|