itee-tasks 1.0.4 → 1.0.5
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/CHANGELOG.md +6 -0
- package/configs/tests/benchmarks/compute-benchmarks.conf.mjs +3 -23
- package/configs/tests/bundlings/check-bundling-from-esm-files-direct.conf.mjs +43 -37
- package/configs/tests/bundlings/check-bundling-from-esm-files-import.conf.mjs +40 -34
- package/configs/tests/units/compute-unit-tests.conf.mjs +2 -22
- package/package.json +1 -1
- package/sources/tests/benchmarks/compute-benchmarks.task.mjs +27 -10
- package/sources/tests/bundlings/check-bundling-from-esm-files-direct.task.mjs +23 -13
- package/sources/tests/bundlings/check-bundling-from-esm-files-import.task.mjs +25 -14
- package/sources/tests/units/compute-unit-tests.task.mjs +29 -12
- package/configs/tests/bundlings/check-bundling.conf.mjs +0 -25
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
# [v1.0.5](https://github.com/Itee/itee-tasks/compare/v1.0.4...v1.0.5) (2026-01-14)
|
|
2
|
+
|
|
3
|
+
## 🐛 Bug Fixes
|
|
4
|
+
- [`d46c8f8`](https://github.com/Itee/itee-tasks/commit/d46c8f8) (check-bundling) fix wrong package import path
|
|
5
|
+
- [`6bd2598`](https://github.com/Itee/itee-tasks/commit/6bd2598) (compute-benchmarks) fix wrong package import path
|
|
6
|
+
|
|
1
7
|
# [v1.0.4](https://github.com/Itee/itee-tasks/compare/v1.0.3...v1.0.4) (2026-01-13)
|
|
2
8
|
|
|
3
9
|
# [v1.0.3](https://github.com/Itee/itee-tasks/compare/v1.0.2...v1.0.3) (2026-01-13)
|
|
@@ -1,25 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
basename,
|
|
4
|
-
join,
|
|
5
|
-
normalize
|
|
6
|
-
} from 'path'
|
|
7
|
-
import {
|
|
8
|
-
packageName,
|
|
9
|
-
packageSourcesDirectory
|
|
10
|
-
} from '../../../sources/_utils.mjs'
|
|
1
|
+
import { packageName } from '../../../sources/_utils.mjs'
|
|
11
2
|
|
|
12
|
-
|
|
13
|
-
const filePathsToIgnore = [
|
|
3
|
+
export default [
|
|
14
4
|
`${ packageName }.js`
|
|
15
|
-
]
|
|
16
|
-
|
|
17
|
-
export default glob.sync( join( packageSourcesDirectory, '**' ) )
|
|
18
|
-
.map( filePath => normalize( filePath ) )
|
|
19
|
-
.filter( filePath => {
|
|
20
|
-
const fileName = basename( filePath )
|
|
21
|
-
const isJsFile = fileName.endsWith( '.js' )
|
|
22
|
-
const isNotPrivateFile = !fileName.startsWith( '_' )
|
|
23
|
-
const isNotIgnoredFile = !filePathsToIgnore.includes( fileName )
|
|
24
|
-
return isJsFile && isNotPrivateFile && isNotIgnoredFile
|
|
25
|
-
} )
|
|
5
|
+
]
|
|
@@ -1,45 +1,51 @@
|
|
|
1
|
-
import nodeResolve
|
|
2
|
-
import cleanup
|
|
1
|
+
import nodeResolve from '@rollup/plugin-node-resolve'
|
|
2
|
+
import cleanup from 'rollup-plugin-cleanup'
|
|
3
|
+
import { packageName } from '../../../sources/index.mjs'
|
|
3
4
|
|
|
4
5
|
export default {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
plugins: [
|
|
8
|
-
nodeResolve( {
|
|
9
|
-
preferBuiltins: true
|
|
10
|
-
} ),
|
|
11
|
-
cleanup( {
|
|
12
|
-
comments: 'none'
|
|
13
|
-
} )
|
|
6
|
+
ignoredFiles: [
|
|
7
|
+
`${ packageName }.js`
|
|
14
8
|
],
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
9
|
+
buildOptions: {
|
|
10
|
+
input: null,
|
|
11
|
+
external: [ '' ],
|
|
12
|
+
plugins: [
|
|
13
|
+
nodeResolve( {
|
|
14
|
+
preferBuiltins: true
|
|
15
|
+
} ),
|
|
16
|
+
cleanup( {
|
|
17
|
+
comments: 'none'
|
|
18
|
+
} )
|
|
19
|
+
],
|
|
20
|
+
onwarn: ( {
|
|
21
|
+
loc,
|
|
22
|
+
frame,
|
|
23
|
+
message
|
|
24
|
+
} ) => {
|
|
20
25
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
26
|
+
// Ignore some errors
|
|
27
|
+
if ( message.includes( 'Circular dependency' ) ) { return }
|
|
28
|
+
if ( message.includes( 'Generated an empty chunk' ) ) { return }
|
|
24
29
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
+
if ( loc ) {
|
|
31
|
+
process.stderr.write( `/!\\ ${ loc.file } (${ loc.line }:${ loc.column }) ${ frame } ${ message }\n` )
|
|
32
|
+
} else {
|
|
33
|
+
process.stderr.write( `/!\\ ${ message }\n` )
|
|
34
|
+
}
|
|
30
35
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
36
|
+
},
|
|
37
|
+
treeshake: {
|
|
38
|
+
moduleSideEffects: true,
|
|
39
|
+
annotations: true,
|
|
40
|
+
correctVarValueBeforeDeclaration: true,
|
|
41
|
+
propertyReadSideEffects: true,
|
|
42
|
+
tryCatchDeoptimization: true,
|
|
43
|
+
unknownGlobalSideEffects: true
|
|
44
|
+
},
|
|
45
|
+
output: {
|
|
46
|
+
indent: '\t',
|
|
47
|
+
format: 'esm',
|
|
48
|
+
file: null
|
|
49
|
+
}
|
|
44
50
|
}
|
|
45
51
|
}
|
|
@@ -1,42 +1,48 @@
|
|
|
1
|
-
import nodeResolve
|
|
2
|
-
import cleanup
|
|
1
|
+
import nodeResolve from '@rollup/plugin-node-resolve'
|
|
2
|
+
import cleanup from 'rollup-plugin-cleanup'
|
|
3
|
+
import { packageName } from '../../../sources/index.mjs'
|
|
3
4
|
|
|
4
5
|
export default {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
nodeResolve(),
|
|
8
|
-
cleanup( {
|
|
9
|
-
comments: 'all' // else remove __PURE__ declaration... -_-'
|
|
10
|
-
} )
|
|
6
|
+
ignoredFiles: [
|
|
7
|
+
`${ packageName }.js`
|
|
11
8
|
],
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
9
|
+
buildOptions: {
|
|
10
|
+
input: null,
|
|
11
|
+
plugins: [
|
|
12
|
+
nodeResolve(),
|
|
13
|
+
cleanup( {
|
|
14
|
+
comments: 'all' // else remove __PURE__ declaration... -_-'
|
|
15
|
+
} )
|
|
16
|
+
],
|
|
17
|
+
onwarn: ( {
|
|
18
|
+
loc,
|
|
19
|
+
frame,
|
|
20
|
+
message
|
|
21
|
+
} ) => {
|
|
17
22
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
23
|
+
// Ignore some errors
|
|
24
|
+
if ( message.includes( 'Circular dependency' ) ) { return }
|
|
25
|
+
if ( message.includes( 'Generated an empty chunk' ) ) { return }
|
|
21
26
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
+
if ( loc ) {
|
|
28
|
+
process.stderr.write( `/!\\ ${ loc.file } (${ loc.line }:${ loc.column }) ${ frame } ${ message }\n` )
|
|
29
|
+
} else {
|
|
30
|
+
process.stderr.write( `/!\\ ${ message }\n` )
|
|
31
|
+
}
|
|
27
32
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
33
|
+
},
|
|
34
|
+
treeshake: {
|
|
35
|
+
moduleSideEffects: true,
|
|
36
|
+
annotations: true,
|
|
37
|
+
correctVarValueBeforeDeclaration: true,
|
|
38
|
+
propertyReadSideEffects: true,
|
|
39
|
+
tryCatchDeoptimization: true,
|
|
40
|
+
unknownGlobalSideEffects: true
|
|
41
|
+
},
|
|
42
|
+
output: {
|
|
43
|
+
indent: '\t',
|
|
44
|
+
format: 'esm',
|
|
45
|
+
file: null
|
|
46
|
+
}
|
|
41
47
|
}
|
|
42
48
|
}
|
|
@@ -1,25 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
basename,
|
|
4
|
-
join,
|
|
5
|
-
normalize
|
|
6
|
-
} from 'path'
|
|
7
|
-
import {
|
|
8
|
-
packageName,
|
|
9
|
-
packageSourcesDirectory
|
|
10
|
-
} from '../../../sources/_utils.mjs'
|
|
1
|
+
import { packageName } from '../../../sources/_utils.mjs'
|
|
11
2
|
|
|
12
|
-
|
|
13
|
-
const filePathsToIgnore = [
|
|
3
|
+
export default [
|
|
14
4
|
`${ packageName }.js`
|
|
15
5
|
]
|
|
16
|
-
|
|
17
|
-
export default glob.sync( join( packageSourcesDirectory, '**' ) )
|
|
18
|
-
.map( filePath => normalize( filePath ) )
|
|
19
|
-
.filter( filePath => {
|
|
20
|
-
const fileName = basename( filePath )
|
|
21
|
-
const isJsFile = fileName.endsWith( '.js' )
|
|
22
|
-
const isNotPrivateFile = !fileName.startsWith( '_' )
|
|
23
|
-
const isNotIgnoredFile = !filePathsToIgnore.includes( fileName )
|
|
24
|
-
return isJsFile && isNotPrivateFile && isNotIgnoredFile
|
|
25
|
-
} )
|
package/package.json
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import colors from 'ansi-colors'
|
|
2
2
|
import childProcess from 'child_process'
|
|
3
3
|
import log from 'fancy-log'
|
|
4
|
+
import { glob } from 'glob'
|
|
4
5
|
import {
|
|
5
6
|
basename,
|
|
6
7
|
dirname,
|
|
7
8
|
extname,
|
|
8
9
|
join,
|
|
10
|
+
normalize,
|
|
9
11
|
relative
|
|
10
12
|
} from 'path'
|
|
11
13
|
import {
|
|
@@ -16,8 +18,8 @@ import {
|
|
|
16
18
|
logLoadingTask,
|
|
17
19
|
packageName,
|
|
18
20
|
packageNodeModulesDirectory,
|
|
19
|
-
packageSourcesDirectory
|
|
20
|
-
packageTestsBenchmarksDirectory
|
|
21
|
+
packageSourcesDirectory,
|
|
22
|
+
packageTestsBenchmarksDirectory,
|
|
21
23
|
packageTestsDirectory
|
|
22
24
|
} from '../../_utils.mjs'
|
|
23
25
|
|
|
@@ -35,21 +37,36 @@ const configuration = await getConfigurationFrom( configurationPath )
|
|
|
35
37
|
*/
|
|
36
38
|
const computeBenchmarksTask = ( done ) => {
|
|
37
39
|
|
|
38
|
-
createDirectoryIfNotExist(
|
|
40
|
+
createDirectoryIfNotExist( packageTestsBenchmarksDirectory )
|
|
41
|
+
|
|
42
|
+
// Get task configuration
|
|
43
|
+
const filePathsToIgnore = configuration
|
|
44
|
+
|
|
45
|
+
// Get source files to process
|
|
46
|
+
const pattern = join( packageSourcesDirectory, '**' )
|
|
47
|
+
const sourceFiles = glob.sync( pattern )
|
|
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
|
+
} )
|
|
39
56
|
|
|
40
57
|
const benchRootImports = []
|
|
41
|
-
for ( let sourceFile of
|
|
58
|
+
for ( let sourceFile of sourceFiles ) {
|
|
42
59
|
|
|
43
|
-
const specificFilePath = sourceFile.replace(
|
|
60
|
+
const specificFilePath = sourceFile.replace( packageSourcesDirectory, '' )
|
|
44
61
|
const specificDir = dirname( specificFilePath )
|
|
45
62
|
|
|
46
63
|
const fileName = basename( sourceFile, extname( sourceFile ) )
|
|
47
64
|
const benchFileName = `${ fileName }.bench.js`
|
|
48
|
-
const benchDirPath = join(
|
|
65
|
+
const benchDirPath = join( packageTestsBenchmarksDirectory, specificDir )
|
|
49
66
|
const benchFilePath = join( benchDirPath, benchFileName )
|
|
50
67
|
|
|
51
68
|
const nsName = `${ fileName }Namespace`
|
|
52
|
-
const importDirPath = relative( benchDirPath,
|
|
69
|
+
const importDirPath = relative( benchDirPath, packageSourcesDirectory )
|
|
53
70
|
const importFilePath = join( importDirPath, specificFilePath ).replace( /\\/g, '/' )
|
|
54
71
|
|
|
55
72
|
try {
|
|
@@ -159,7 +176,7 @@ const computeBenchmarksTask = ( done ) => {
|
|
|
159
176
|
`export { ${ suitesToExports } }` + '\n' +
|
|
160
177
|
'\n'
|
|
161
178
|
|
|
162
|
-
const importBenchFilePath = relative(
|
|
179
|
+
const importBenchFilePath = relative( packageTestsBenchmarksDirectory, benchFilePath ).replace( /\\/g, '/' )
|
|
163
180
|
benchRootImports.push( {
|
|
164
181
|
path: importBenchFilePath,
|
|
165
182
|
exports: suitesToExports
|
|
@@ -192,7 +209,7 @@ const computeBenchmarksTask = ( done ) => {
|
|
|
192
209
|
// Use a fallback in case no benches were found at all
|
|
193
210
|
if ( benchRootImports.length === 0 ) {
|
|
194
211
|
log( 'Warning ', yellow( 'No usable exports found, generate default file to avoid frontend breakage.' ) )
|
|
195
|
-
const defaultBenchesDir = join(
|
|
212
|
+
const defaultBenchesDir = join( packageTestsBenchmarksDirectory, 'default' )
|
|
196
213
|
const defaultBenchesPath = join( defaultBenchesDir, 'default.bench.js' )
|
|
197
214
|
|
|
198
215
|
createDirectoryIfNotExist( defaultBenchesDir )
|
|
@@ -209,7 +226,7 @@ const computeBenchmarksTask = ( done ) => {
|
|
|
209
226
|
`\tsuite.run()` + '\n' +
|
|
210
227
|
`}` + '\n'
|
|
211
228
|
|
|
212
|
-
const benchesFilePath = join(
|
|
229
|
+
const benchesFilePath = join( packageTestsBenchmarksDirectory, `${ packageName }.benchmarks.js` )
|
|
213
230
|
createFile( benchesFilePath, benchesTemplate )
|
|
214
231
|
|
|
215
232
|
done()
|
|
@@ -4,12 +4,14 @@ import {
|
|
|
4
4
|
existsSync,
|
|
5
5
|
rmSync
|
|
6
6
|
} from 'fs'
|
|
7
|
+
import { glob } from 'glob'
|
|
7
8
|
import {
|
|
8
9
|
basename,
|
|
9
10
|
dirname,
|
|
10
11
|
extname,
|
|
11
|
-
join
|
|
12
|
-
|
|
12
|
+
join,
|
|
13
|
+
normalize
|
|
14
|
+
} from 'path'
|
|
13
15
|
import { rollup } from 'rollup'
|
|
14
16
|
import {
|
|
15
17
|
getConfigurationFrom,
|
|
@@ -25,9 +27,6 @@ const {
|
|
|
25
27
|
magenta,
|
|
26
28
|
} = colors
|
|
27
29
|
|
|
28
|
-
const sourcesFilesLocation = join( 'tests', 'bundlings', 'check-bundling.conf.mjs' )
|
|
29
|
-
const sourcesFilesPath = getConfigurationPathFor( sourcesFilesLocation )
|
|
30
|
-
|
|
31
30
|
const configurationLocation = join( 'tests', 'bundlings', 'check-bundling-from-esm-files-direct.conf.mjs' )
|
|
32
31
|
const configurationPath = getConfigurationPathFor( configurationLocation )
|
|
33
32
|
|
|
@@ -45,10 +44,21 @@ const checkBundlingFromEsmFilesDirectTask = async ( done ) => {
|
|
|
45
44
|
rmSync( outputDir, { recursive: true } )
|
|
46
45
|
}
|
|
47
46
|
|
|
48
|
-
const sourcesFiles = await getConfigurationFrom( sourcesFilesPath )
|
|
49
47
|
const configuration = await getConfigurationFrom( configurationPath )
|
|
50
48
|
|
|
51
|
-
|
|
49
|
+
// Get source files to process
|
|
50
|
+
const pattern = join( packageSourcesDirectory, '**' )
|
|
51
|
+
const sourceFiles = glob.sync( pattern )
|
|
52
|
+
.map( filePath => normalize( filePath ) )
|
|
53
|
+
.filter( filePath => {
|
|
54
|
+
const fileName = basename( filePath )
|
|
55
|
+
const isJsFile = fileName.endsWith( '.js' )
|
|
56
|
+
const isNotPrivateFile = !fileName.startsWith( '_' )
|
|
57
|
+
const isNotIgnoredFile = !configuration.ignoredFiles.includes( fileName )
|
|
58
|
+
return isJsFile && isNotPrivateFile && isNotIgnoredFile
|
|
59
|
+
} )
|
|
60
|
+
|
|
61
|
+
for ( let sourceFile of sourceFiles ) {
|
|
52
62
|
|
|
53
63
|
const specificFilePath = sourceFile.replace( packageSourcesDirectory, '' )
|
|
54
64
|
const specificDir = dirname( specificFilePath )
|
|
@@ -57,16 +67,16 @@ const checkBundlingFromEsmFilesDirectTask = async ( done ) => {
|
|
|
57
67
|
const bundleFileName = `${ fileName }.bundle.js`
|
|
58
68
|
const bundleFilePath = join( outputDir, specificDir, bundleFileName )
|
|
59
69
|
|
|
60
|
-
configuration.input = sourceFile
|
|
61
|
-
configuration.output.file = bundleFilePath
|
|
70
|
+
configuration.buildOptions.input = sourceFile
|
|
71
|
+
configuration.buildOptions.output.file = bundleFilePath
|
|
62
72
|
|
|
63
73
|
try {
|
|
64
74
|
|
|
65
|
-
log( 'Bundling', green( configuration.output.file ) )
|
|
75
|
+
log( 'Bundling', green( configuration.buildOptions.output.file ) )
|
|
66
76
|
|
|
67
|
-
const bundle = await rollup( configuration )
|
|
68
|
-
await bundle.generate( configuration.output )
|
|
69
|
-
await bundle.write( configuration.output )
|
|
77
|
+
const bundle = await rollup( configuration.buildOptions )
|
|
78
|
+
await bundle.generate( configuration.buildOptions.output )
|
|
79
|
+
await bundle.write( configuration.buildOptions.output )
|
|
70
80
|
|
|
71
81
|
} catch ( error ) {
|
|
72
82
|
|
|
@@ -6,9 +6,12 @@ import {
|
|
|
6
6
|
rmSync,
|
|
7
7
|
writeFileSync
|
|
8
8
|
} from 'fs'
|
|
9
|
+
import { glob } from 'glob'
|
|
9
10
|
import {
|
|
11
|
+
basename,
|
|
10
12
|
dirname,
|
|
11
13
|
join,
|
|
14
|
+
normalize,
|
|
12
15
|
parse,
|
|
13
16
|
relative
|
|
14
17
|
} from 'path'
|
|
@@ -17,8 +20,8 @@ import {
|
|
|
17
20
|
getConfigurationFrom,
|
|
18
21
|
getConfigurationPathFor,
|
|
19
22
|
logLoadingTask,
|
|
20
|
-
packageSourcesDirectory
|
|
21
|
-
packageTestsBundlesDirectory
|
|
23
|
+
packageSourcesDirectory,
|
|
24
|
+
packageTestsBundlesDirectory
|
|
22
25
|
} from '../../_utils.mjs'
|
|
23
26
|
|
|
24
27
|
const {
|
|
@@ -27,15 +30,12 @@ const {
|
|
|
27
30
|
magenta,
|
|
28
31
|
} = colors
|
|
29
32
|
|
|
30
|
-
const sourcesFilesLocation = join( 'tests', 'bundlings', 'check-bundling.conf.mjs' )
|
|
31
|
-
const sourcesFilesPath = getConfigurationPathFor( sourcesFilesLocation )
|
|
32
|
-
|
|
33
33
|
const configurationLocation = join( 'tests', 'bundlings', 'check-bundling-from-esm-files-import.conf.mjs' )
|
|
34
34
|
const configurationPath = getConfigurationPathFor( configurationLocation )
|
|
35
35
|
|
|
36
36
|
const checkBundlingFromEsmFilesImportTask = async ( done ) => {
|
|
37
37
|
|
|
38
|
-
const outputDir = join(
|
|
38
|
+
const outputDir = join( packageTestsBundlesDirectory, 'from_files_import' )
|
|
39
39
|
const temporariesDir = join( outputDir, '.tmp' )
|
|
40
40
|
|
|
41
41
|
if ( existsSync( outputDir ) ) {
|
|
@@ -43,17 +43,28 @@ const checkBundlingFromEsmFilesImportTask = async ( done ) => {
|
|
|
43
43
|
rmSync( outputDir, { recursive: true } )
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
const sourcesFiles = await getConfigurationFrom( sourcesFilesPath )
|
|
47
46
|
const configuration = await getConfigurationFrom( configurationPath )
|
|
48
47
|
|
|
49
|
-
|
|
48
|
+
// Get source files to process
|
|
49
|
+
const pattern = join( packageSourcesDirectory, '**' )
|
|
50
|
+
const sourceFiles = glob.sync( pattern )
|
|
51
|
+
.map( filePath => normalize( filePath ) )
|
|
52
|
+
.filter( filePath => {
|
|
53
|
+
const fileName = basename( filePath )
|
|
54
|
+
const isJsFile = fileName.endsWith( '.js' )
|
|
55
|
+
const isNotPrivateFile = !fileName.startsWith( '_' )
|
|
56
|
+
const isNotIgnoredFile = !configuration.ignoredFiles.includes( fileName )
|
|
57
|
+
return isJsFile && isNotPrivateFile && isNotIgnoredFile
|
|
58
|
+
} )
|
|
59
|
+
|
|
60
|
+
for ( let sourceFile of sourceFiles ) {
|
|
50
61
|
|
|
51
62
|
const {
|
|
52
63
|
dir: sourceDir,
|
|
53
64
|
base: sourceBase,
|
|
54
65
|
name: sourceName
|
|
55
66
|
} = parse( sourceFile )
|
|
56
|
-
const specificFilePath = sourceFile.replace(
|
|
67
|
+
const specificFilePath = sourceFile.replace( packageSourcesDirectory, '' )
|
|
57
68
|
const specificDir = dirname( specificFilePath )
|
|
58
69
|
|
|
59
70
|
// Create temp import file per file in package
|
|
@@ -68,8 +79,8 @@ const checkBundlingFromEsmFilesImportTask = async ( done ) => {
|
|
|
68
79
|
const bundleFileName = `${ sourceName }.bundle.js`
|
|
69
80
|
const bundleFilePath = join( outputDir, specificDir, bundleFileName )
|
|
70
81
|
|
|
71
|
-
configuration.input = temporaryFile
|
|
72
|
-
configuration.output.file = bundleFilePath
|
|
82
|
+
configuration.buildOptions.input = temporaryFile
|
|
83
|
+
configuration.buildOptions.output.file = bundleFilePath
|
|
73
84
|
|
|
74
85
|
// create tmp file
|
|
75
86
|
try {
|
|
@@ -77,13 +88,13 @@ const checkBundlingFromEsmFilesImportTask = async ( done ) => {
|
|
|
77
88
|
mkdirSync( temporaryDir, { recursive: true } )
|
|
78
89
|
writeFileSync( temporaryFile, temporaryFileData )
|
|
79
90
|
|
|
80
|
-
const bundle = await rollup( configuration )
|
|
81
|
-
const { output } = await bundle.generate( configuration.output )
|
|
91
|
+
const bundle = await rollup( configuration.buildOptions )
|
|
92
|
+
const { output } = await bundle.generate( configuration.buildOptions.output )
|
|
82
93
|
|
|
83
94
|
let code = output[ 0 ].code
|
|
84
95
|
if ( code.length > 1 ) {
|
|
85
96
|
log( red( `[${ specificFilePath }] contain side-effects !` ) )
|
|
86
|
-
await bundle.write( configuration.output )
|
|
97
|
+
await bundle.write( configuration.buildOptions.output )
|
|
87
98
|
} else {
|
|
88
99
|
log( green( `[${ specificFilePath }] is side-effect free.` ) )
|
|
89
100
|
}
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import colors from 'ansi-colors'
|
|
2
2
|
import childProcess from 'child_process'
|
|
3
3
|
import log from 'fancy-log'
|
|
4
|
+
import { glob } from 'glob'
|
|
4
5
|
import { isNotEmptyArray } from 'itee-validators'
|
|
5
6
|
import {
|
|
6
7
|
basename,
|
|
7
8
|
dirname,
|
|
8
9
|
extname,
|
|
9
10
|
join,
|
|
11
|
+
normalize,
|
|
10
12
|
relative
|
|
11
|
-
}
|
|
13
|
+
} from 'path'
|
|
12
14
|
import {
|
|
13
15
|
createDirectoryIfNotExist,
|
|
14
16
|
createFile,
|
|
@@ -19,9 +21,9 @@ import {
|
|
|
19
21
|
logLoadingTask,
|
|
20
22
|
packageName,
|
|
21
23
|
packageNodeModulesDirectory,
|
|
22
|
-
packageSourcesDirectory
|
|
23
|
-
packageTestsUnitsDirectory
|
|
24
|
-
}
|
|
24
|
+
packageSourcesDirectory,
|
|
25
|
+
packageTestsUnitsDirectory
|
|
26
|
+
} from '../../_utils.mjs'
|
|
25
27
|
|
|
26
28
|
const configurationLocation = join( 'tests', 'units', 'compute-unit-tests.conf.mjs' )
|
|
27
29
|
const configurationPath = getConfigurationPathFor( configurationLocation )
|
|
@@ -37,22 +39,37 @@ const {
|
|
|
37
39
|
*/
|
|
38
40
|
const computeUnitTestsTask = ( done ) => {
|
|
39
41
|
|
|
40
|
-
createDirectoryIfNotExist(
|
|
42
|
+
createDirectoryIfNotExist( packageTestsUnitsDirectory )
|
|
43
|
+
|
|
44
|
+
// Get task configuration
|
|
45
|
+
const filePathsToIgnore = configuration
|
|
46
|
+
|
|
47
|
+
// Get source files to process
|
|
48
|
+
const pattern = join( packageSourcesDirectory, '**' )
|
|
49
|
+
const sourceFiles = glob.sync( pattern )
|
|
50
|
+
.map( filePath => normalize( filePath ) )
|
|
51
|
+
.filter( filePath => {
|
|
52
|
+
const fileName = basename( filePath )
|
|
53
|
+
const isJsFile = fileName.endsWith( '.js' )
|
|
54
|
+
const isNotPrivateFile = !fileName.startsWith( '_' )
|
|
55
|
+
const isNotIgnoredFile = !filePathsToIgnore.includes( fileName )
|
|
56
|
+
return isJsFile && isNotPrivateFile && isNotIgnoredFile
|
|
57
|
+
} )
|
|
41
58
|
|
|
42
59
|
const unitsImportMap = []
|
|
43
|
-
for ( let sourceFile of
|
|
60
|
+
for ( let sourceFile of sourceFiles ) {
|
|
44
61
|
|
|
45
|
-
const specificFilePath = sourceFile.replace(
|
|
62
|
+
const specificFilePath = sourceFile.replace( packageSourcesDirectory, '' )
|
|
46
63
|
const specificDir = dirname( specificFilePath )
|
|
47
64
|
|
|
48
65
|
const fileName = basename( sourceFile, extname( sourceFile ) )
|
|
49
66
|
const unitFileName = `${ fileName }.unit.mjs`
|
|
50
|
-
const unitDirPath = join(
|
|
67
|
+
const unitDirPath = join( packageTestsUnitsDirectory, specificDir )
|
|
51
68
|
const unitFilePath = join( unitDirPath, unitFileName )
|
|
52
69
|
|
|
53
70
|
const nsName = `${ fileName }Namespace`
|
|
54
71
|
const unitName = `${ fileName }Units`
|
|
55
|
-
const importDirPath = relative( unitDirPath,
|
|
72
|
+
const importDirPath = relative( unitDirPath, packageSourcesDirectory )
|
|
56
73
|
const importFilePath = join( importDirPath, specificFilePath ).replace( /\\/g, '/' )
|
|
57
74
|
|
|
58
75
|
try {
|
|
@@ -477,7 +494,7 @@ const computeUnitTestsTask = ( done ) => {
|
|
|
477
494
|
'' +
|
|
478
495
|
`} )` + '\n'
|
|
479
496
|
|
|
480
|
-
const importUnitFilePath = relative(
|
|
497
|
+
const importUnitFilePath = relative( packageTestsUnitsDirectory, unitFilePath )
|
|
481
498
|
unitsImportMap.push( {
|
|
482
499
|
exportName: unitName,
|
|
483
500
|
path: importUnitFilePath.replace( /\\/g, '/' )
|
|
@@ -509,7 +526,7 @@ const computeUnitTestsTask = ( done ) => {
|
|
|
509
526
|
} else {
|
|
510
527
|
|
|
511
528
|
log( 'Warning ', yellow( 'No tests were generated. Create fallback global root import file.' ) )
|
|
512
|
-
const defaultUnitsDir = join(
|
|
529
|
+
const defaultUnitsDir = join( packageTestsUnitsDirectory, 'default' )
|
|
513
530
|
const defaultUnitsPath = join( defaultUnitsDir, 'default.unit.mjs' )
|
|
514
531
|
|
|
515
532
|
createDirectoryIfNotExist( defaultUnitsDir )
|
|
@@ -520,7 +537,7 @@ const computeUnitTestsTask = ( done ) => {
|
|
|
520
537
|
|
|
521
538
|
}
|
|
522
539
|
|
|
523
|
-
const unitsFilePath = join(
|
|
540
|
+
const unitsFilePath = join( packageTestsUnitsDirectory, `${ packageName }.units.mjs` )
|
|
524
541
|
createFile( unitsFilePath, unitsTemplate )
|
|
525
542
|
|
|
526
543
|
done()
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { glob } from 'glob'
|
|
2
|
-
import {
|
|
3
|
-
basename,
|
|
4
|
-
join,
|
|
5
|
-
normalize
|
|
6
|
-
} from 'path'
|
|
7
|
-
import {
|
|
8
|
-
packageName,
|
|
9
|
-
packageSourcesDirectory
|
|
10
|
-
} from '../../../sources/_utils.mjs'
|
|
11
|
-
|
|
12
|
-
const pattern = join( packageSourcesDirectory, '**' )
|
|
13
|
-
const filePathsToIgnore = [
|
|
14
|
-
`${ packageName }.js`
|
|
15
|
-
]
|
|
16
|
-
|
|
17
|
-
export default glob.sync( pattern )
|
|
18
|
-
.map( filePath => normalize( filePath ) )
|
|
19
|
-
.filter( filePath => {
|
|
20
|
-
const fileName = basename( filePath )
|
|
21
|
-
const isJsFile = fileName.endsWith( '.js' )
|
|
22
|
-
const isNotPrivateFile = !fileName.startsWith( '_' )
|
|
23
|
-
const isNotIgnoredFile = !filePathsToIgnore.includes( fileName )
|
|
24
|
-
return isJsFile && isNotPrivateFile && isNotIgnoredFile
|
|
25
|
-
} )
|