itee-tasks 1.0.4 → 1.0.6
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 +11 -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/_utils.mjs +54 -35
- package/sources/builds/build.task.mjs +7 -10
- package/sources/cleans/clean.task.mjs +6 -10
- package/sources/docs/doc.task.mjs +7 -8
- package/sources/helps/help.task.mjs +4 -3
- package/sources/lints/lint.task.mjs +8 -9
- package/sources/refresh.mjs +5 -5
- package/sources/releases/release.task.mjs +4 -3
- package/sources/tests/benchmarks/compute-benchmarks.task.mjs +32 -20
- package/sources/tests/benchmarks/run-benchmarks-for-backend.task.mjs +4 -3
- package/sources/tests/benchmarks/run-benchmarks-for-frontend.task.mjs +6 -10
- package/sources/tests/benchmarks/run-benchmarks.task.mjs +6 -11
- package/sources/tests/bundlings/check-bundling-from-esm-build-import.task.mjs +5 -9
- package/sources/tests/bundlings/check-bundling-from-esm-files-direct.task.mjs +27 -21
- package/sources/tests/bundlings/check-bundling-from-esm-files-import.task.mjs +29 -22
- package/sources/tests/bundlings/check-bundling.task.mjs +4 -3
- package/sources/tests/run-tests.task.mjs +4 -3
- package/sources/tests/units/compute-unit-tests.task.mjs +31 -19
- package/sources/tests/units/run-unit-tests-for-backend.task.mjs +4 -3
- package/sources/tests/units/run-unit-tests-for-frontend.task.mjs +6 -10
- package/sources/tests/units/run-unit-tests.task.mjs +6 -11
- package/configs/tests/bundlings/check-bundling.conf.mjs +0 -25
|
@@ -1,55 +1,69 @@
|
|
|
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 {
|
|
12
14
|
createDirectoryIfNotExist,
|
|
13
15
|
createFile,
|
|
14
|
-
|
|
15
|
-
getConfigurationPathFor,
|
|
16
|
+
getTaskConfigurationFor,
|
|
16
17
|
logLoadingTask,
|
|
17
18
|
packageName,
|
|
18
19
|
packageNodeModulesDirectory,
|
|
19
|
-
packageSourcesDirectory
|
|
20
|
-
packageTestsBenchmarksDirectory
|
|
20
|
+
packageSourcesDirectory,
|
|
21
|
+
packageTestsBenchmarksDirectory,
|
|
21
22
|
packageTestsDirectory
|
|
22
23
|
} from '../../_utils.mjs'
|
|
23
24
|
|
|
25
|
+
logLoadingTask( import.meta.filename )
|
|
26
|
+
|
|
24
27
|
const {
|
|
25
28
|
red,
|
|
26
29
|
yellow,
|
|
27
30
|
} = colors
|
|
28
31
|
|
|
29
|
-
const configurationLocation = join( 'tests', 'benchmarks', 'compute-benchmarks.conf.mjs' )
|
|
30
|
-
const configurationPath = getConfigurationPathFor( configurationLocation )
|
|
31
|
-
const configuration = await getConfigurationFrom( configurationPath )
|
|
32
|
-
|
|
33
32
|
/**
|
|
34
33
|
* @description Will generate benchmarks files from source code against provided alternatives
|
|
35
34
|
*/
|
|
36
|
-
const computeBenchmarksTask = ( done ) => {
|
|
35
|
+
const computeBenchmarksTask = async ( done ) => {
|
|
36
|
+
|
|
37
|
+
createDirectoryIfNotExist( packageTestsBenchmarksDirectory )
|
|
37
38
|
|
|
38
|
-
|
|
39
|
+
// Get task configuration
|
|
40
|
+
const filePathsToIgnore = await getTaskConfigurationFor( import.meta.filename )
|
|
41
|
+
|
|
42
|
+
// Get source files to process
|
|
43
|
+
const pattern = join( packageSourcesDirectory, '**' )
|
|
44
|
+
const sourceFiles = glob.sync( pattern )
|
|
45
|
+
.map( filePath => normalize( filePath ) )
|
|
46
|
+
.filter( filePath => {
|
|
47
|
+
const fileName = basename( filePath )
|
|
48
|
+
const isJsFile = fileName.endsWith( '.js' )
|
|
49
|
+
const isNotPrivateFile = !fileName.startsWith( '_' )
|
|
50
|
+
const isNotIgnoredFile = !filePathsToIgnore.includes( fileName )
|
|
51
|
+
return isJsFile && isNotPrivateFile && isNotIgnoredFile
|
|
52
|
+
} )
|
|
39
53
|
|
|
40
54
|
const benchRootImports = []
|
|
41
|
-
for ( let sourceFile of
|
|
55
|
+
for ( let sourceFile of sourceFiles ) {
|
|
42
56
|
|
|
43
|
-
const specificFilePath = sourceFile.replace(
|
|
57
|
+
const specificFilePath = sourceFile.replace( packageSourcesDirectory, '' )
|
|
44
58
|
const specificDir = dirname( specificFilePath )
|
|
45
59
|
|
|
46
60
|
const fileName = basename( sourceFile, extname( sourceFile ) )
|
|
47
61
|
const benchFileName = `${ fileName }.bench.js`
|
|
48
|
-
const benchDirPath = join(
|
|
62
|
+
const benchDirPath = join( packageTestsBenchmarksDirectory, specificDir )
|
|
49
63
|
const benchFilePath = join( benchDirPath, benchFileName )
|
|
50
64
|
|
|
51
65
|
const nsName = `${ fileName }Namespace`
|
|
52
|
-
const importDirPath = relative( benchDirPath,
|
|
66
|
+
const importDirPath = relative( benchDirPath, packageSourcesDirectory )
|
|
53
67
|
const importFilePath = join( importDirPath, specificFilePath ).replace( /\\/g, '/' )
|
|
54
68
|
|
|
55
69
|
try {
|
|
@@ -159,7 +173,7 @@ const computeBenchmarksTask = ( done ) => {
|
|
|
159
173
|
`export { ${ suitesToExports } }` + '\n' +
|
|
160
174
|
'\n'
|
|
161
175
|
|
|
162
|
-
const importBenchFilePath = relative(
|
|
176
|
+
const importBenchFilePath = relative( packageTestsBenchmarksDirectory, benchFilePath ).replace( /\\/g, '/' )
|
|
163
177
|
benchRootImports.push( {
|
|
164
178
|
path: importBenchFilePath,
|
|
165
179
|
exports: suitesToExports
|
|
@@ -192,7 +206,7 @@ const computeBenchmarksTask = ( done ) => {
|
|
|
192
206
|
// Use a fallback in case no benches were found at all
|
|
193
207
|
if ( benchRootImports.length === 0 ) {
|
|
194
208
|
log( 'Warning ', yellow( 'No usable exports found, generate default file to avoid frontend breakage.' ) )
|
|
195
|
-
const defaultBenchesDir = join(
|
|
209
|
+
const defaultBenchesDir = join( packageTestsBenchmarksDirectory, 'default' )
|
|
196
210
|
const defaultBenchesPath = join( defaultBenchesDir, 'default.bench.js' )
|
|
197
211
|
|
|
198
212
|
createDirectoryIfNotExist( defaultBenchesDir )
|
|
@@ -209,16 +223,14 @@ const computeBenchmarksTask = ( done ) => {
|
|
|
209
223
|
`\tsuite.run()` + '\n' +
|
|
210
224
|
`}` + '\n'
|
|
211
225
|
|
|
212
|
-
const benchesFilePath = join(
|
|
226
|
+
const benchesFilePath = join( packageTestsBenchmarksDirectory, `${ packageName }.benchmarks.js` )
|
|
213
227
|
createFile( benchesFilePath, benchesTemplate )
|
|
214
228
|
|
|
215
229
|
done()
|
|
216
230
|
|
|
217
231
|
}
|
|
218
|
-
computeBenchmarksTask.displayName = '
|
|
232
|
+
computeBenchmarksTask.displayName = basename( import.meta.filename, '.task.mjs' )
|
|
219
233
|
computeBenchmarksTask.description = 'Will generate benchmarks files from source code against provided alternatives.'
|
|
220
234
|
computeBenchmarksTask.flags = null
|
|
221
235
|
|
|
222
|
-
logLoadingTask( import.meta.filename, computeBenchmarksTask, configurationPath )
|
|
223
|
-
|
|
224
236
|
export { computeBenchmarksTask }
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import colors from 'ansi-colors'
|
|
2
2
|
import log from 'fancy-log'
|
|
3
3
|
import { existsSync } from 'fs'
|
|
4
|
+
import { basename } from 'node:path'
|
|
4
5
|
import { join } from 'path'
|
|
5
6
|
import {
|
|
6
7
|
logLoadingTask,
|
|
@@ -8,6 +9,8 @@ import {
|
|
|
8
9
|
packageTestsBenchmarksDirectory
|
|
9
10
|
} from '../../_utils.mjs'
|
|
10
11
|
|
|
12
|
+
logLoadingTask( import.meta.filename )
|
|
13
|
+
|
|
11
14
|
const {
|
|
12
15
|
red,
|
|
13
16
|
yellow
|
|
@@ -33,10 +36,8 @@ const runBenchmarksForBackendTask = async ( done ) => {
|
|
|
33
36
|
}
|
|
34
37
|
|
|
35
38
|
}
|
|
36
|
-
runBenchmarksForBackendTask.displayName = '
|
|
39
|
+
runBenchmarksForBackendTask.displayName = basename( import.meta.filename, '.task.mjs' )
|
|
37
40
|
runBenchmarksForBackendTask.description = 'Will run benchmarks with node'
|
|
38
41
|
runBenchmarksForBackendTask.flags = null
|
|
39
42
|
|
|
40
|
-
logLoadingTask( import.meta.filename, runBenchmarksForBackendTask )
|
|
41
|
-
|
|
42
43
|
export { runBenchmarksForBackendTask }
|
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
import { startTestRunner } from '@web/test-runner'
|
|
2
2
|
import colors from 'ansi-colors'
|
|
3
|
-
import {
|
|
3
|
+
import { basename } from 'node:path'
|
|
4
4
|
import {
|
|
5
|
-
|
|
6
|
-
getConfigurationPathFor,
|
|
5
|
+
getTaskConfigurationFor,
|
|
7
6
|
logLoadingTask
|
|
8
7
|
} from '../../_utils.mjs'
|
|
9
8
|
|
|
10
|
-
|
|
9
|
+
logLoadingTask( import.meta.filename )
|
|
11
10
|
|
|
12
|
-
const
|
|
13
|
-
const configurationPath = getConfigurationPathFor( configurationLocation )
|
|
11
|
+
const { red } = colors
|
|
14
12
|
|
|
15
13
|
/**
|
|
16
14
|
* @description Will run benchmarks with web-test-runner
|
|
@@ -18,7 +16,7 @@ const configurationPath = getConfigurationPathFor( configurationLocation )
|
|
|
18
16
|
const runBenchmarksForFrontendTask = () => {
|
|
19
17
|
return new Promise( async ( resolve, reject ) => {
|
|
20
18
|
|
|
21
|
-
const configuration = await
|
|
19
|
+
const configuration = await getTaskConfigurationFor( import.meta.filename )
|
|
22
20
|
const testRunner = await startTestRunner( {
|
|
23
21
|
config: configuration,
|
|
24
22
|
readCliArgs: false,
|
|
@@ -43,10 +41,8 @@ const runBenchmarksForFrontendTask = () => {
|
|
|
43
41
|
|
|
44
42
|
} )
|
|
45
43
|
}
|
|
46
|
-
runBenchmarksForFrontendTask.displayName = '
|
|
44
|
+
runBenchmarksForFrontendTask.displayName = basename( import.meta.filename, '.task.mjs' )
|
|
47
45
|
runBenchmarksForFrontendTask.description = 'Will run benchmarks with web-test-runner.'
|
|
48
46
|
runBenchmarksForFrontendTask.flags = null
|
|
49
47
|
|
|
50
|
-
logLoadingTask( import.meta.filename, runBenchmarksForFrontendTask, configurationPath )
|
|
51
|
-
|
|
52
48
|
export { runBenchmarksForFrontendTask }
|
|
@@ -1,21 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { basename } from 'node:path'
|
|
2
2
|
import {
|
|
3
|
-
|
|
4
|
-
getConfigurationPathFor,
|
|
3
|
+
getTaskConfigurationFor,
|
|
5
4
|
logLoadingTask,
|
|
6
5
|
serializeTasksFrom
|
|
7
|
-
}
|
|
6
|
+
} from '../../_utils.mjs'
|
|
8
7
|
|
|
8
|
+
logLoadingTask( import.meta.filename )
|
|
9
9
|
|
|
10
|
-
const
|
|
11
|
-
const configurationPath = getConfigurationPathFor( configurationLocation )
|
|
12
|
-
const configuration = await getConfigurationFrom( configurationPath )
|
|
13
|
-
|
|
10
|
+
const configuration = await getTaskConfigurationFor( import.meta.filename )
|
|
14
11
|
const runBenchmarksTestsTask = await serializeTasksFrom( configuration )
|
|
15
|
-
runBenchmarksTestsTask.displayName = '
|
|
12
|
+
runBenchmarksTestsTask.displayName = basename( import.meta.filename, '.task.mjs' )
|
|
16
13
|
runBenchmarksTestsTask.description = 'Will run benchmarks in back and front environments.'
|
|
17
14
|
runBenchmarksTestsTask.flags = null
|
|
18
15
|
|
|
19
|
-
logLoadingTask( import.meta.filename, runBenchmarksTestsTask, configurationPath )
|
|
20
|
-
|
|
21
16
|
export { runBenchmarksTestsTask }
|
|
@@ -14,26 +14,24 @@ import {
|
|
|
14
14
|
} from 'path'
|
|
15
15
|
import { rollup } from 'rollup'
|
|
16
16
|
import {
|
|
17
|
-
|
|
18
|
-
getConfigurationPathFor,
|
|
17
|
+
getTaskConfigurationFor,
|
|
19
18
|
logLoadingTask,
|
|
20
19
|
packageBuildsDirectory,
|
|
21
20
|
packageName,
|
|
22
21
|
packageTestsBundlesDirectory
|
|
23
22
|
} from '../../_utils.mjs'
|
|
24
23
|
|
|
24
|
+
logLoadingTask( import.meta.filename )
|
|
25
|
+
|
|
25
26
|
const {
|
|
26
27
|
red,
|
|
27
28
|
green,
|
|
28
29
|
magenta,
|
|
29
30
|
} = colors
|
|
30
31
|
|
|
31
|
-
const configurationLocation = join( 'tests', 'bundlings', 'check-bundling-from-esm-build-import.conf.mjs' )
|
|
32
|
-
const configurationPath = getConfigurationPathFor( configurationLocation )
|
|
33
|
-
|
|
34
32
|
const checkBundlingFromEsmBuildImportTask = async ( done ) => {
|
|
35
33
|
|
|
36
|
-
const configuration = await
|
|
34
|
+
const configuration = await getTaskConfigurationFor( import.meta.filename )
|
|
37
35
|
|
|
38
36
|
const buildFilePath = join( packageBuildsDirectory, `${ packageName }.esm.js` )
|
|
39
37
|
if ( !existsSync( buildFilePath ) ) {
|
|
@@ -122,10 +120,8 @@ const checkBundlingFromEsmBuildImportTask = async ( done ) => {
|
|
|
122
120
|
}
|
|
123
121
|
|
|
124
122
|
}
|
|
125
|
-
checkBundlingFromEsmBuildImportTask.displayName =
|
|
123
|
+
checkBundlingFromEsmBuildImportTask.displayName = basename( import.meta.filename, '.task.mjs' )
|
|
126
124
|
checkBundlingFromEsmBuildImportTask.description = 'Verify that the project esm build is correctly importable in third party esm files'
|
|
127
125
|
checkBundlingFromEsmBuildImportTask.flags = null
|
|
128
126
|
|
|
129
|
-
logLoadingTask( import.meta.filename, checkBundlingFromEsmBuildImportTask, configurationPath )
|
|
130
|
-
|
|
131
127
|
export { checkBundlingFromEsmBuildImportTask }
|
|
@@ -4,33 +4,30 @@ 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
|
+
join,
|
|
13
|
+
normalize
|
|
12
14
|
} from 'path'
|
|
13
15
|
import { rollup } from 'rollup'
|
|
14
16
|
import {
|
|
15
|
-
|
|
16
|
-
getConfigurationPathFor,
|
|
17
|
+
getTaskConfigurationFor,
|
|
17
18
|
logLoadingTask,
|
|
18
19
|
packageSourcesDirectory,
|
|
19
20
|
packageTestsBundlesDirectory
|
|
20
21
|
} from '../../_utils.mjs'
|
|
21
22
|
|
|
23
|
+
logLoadingTask( import.meta.filename )
|
|
24
|
+
|
|
22
25
|
const {
|
|
23
26
|
red,
|
|
24
27
|
green,
|
|
25
28
|
magenta,
|
|
26
29
|
} = colors
|
|
27
30
|
|
|
28
|
-
const sourcesFilesLocation = join( 'tests', 'bundlings', 'check-bundling.conf.mjs' )
|
|
29
|
-
const sourcesFilesPath = getConfigurationPathFor( sourcesFilesLocation )
|
|
30
|
-
|
|
31
|
-
const configurationLocation = join( 'tests', 'bundlings', 'check-bundling-from-esm-files-direct.conf.mjs' )
|
|
32
|
-
const configurationPath = getConfigurationPathFor( configurationLocation )
|
|
33
|
-
|
|
34
31
|
/**
|
|
35
32
|
* @description In view to detect bundling side effects this task will
|
|
36
33
|
* create intermediary file for each individual export from this package
|
|
@@ -45,10 +42,21 @@ const checkBundlingFromEsmFilesDirectTask = async ( done ) => {
|
|
|
45
42
|
rmSync( outputDir, { recursive: true } )
|
|
46
43
|
}
|
|
47
44
|
|
|
48
|
-
const
|
|
49
|
-
const configuration = await getConfigurationFrom( configurationPath )
|
|
45
|
+
const configuration = await getTaskConfigurationFor( import.meta.filename )
|
|
50
46
|
|
|
51
|
-
|
|
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 = !configuration.ignoredFiles.includes( fileName )
|
|
56
|
+
return isJsFile && isNotPrivateFile && isNotIgnoredFile
|
|
57
|
+
} )
|
|
58
|
+
|
|
59
|
+
for ( let sourceFile of sourceFiles ) {
|
|
52
60
|
|
|
53
61
|
const specificFilePath = sourceFile.replace( packageSourcesDirectory, '' )
|
|
54
62
|
const specificDir = dirname( specificFilePath )
|
|
@@ -57,16 +65,16 @@ const checkBundlingFromEsmFilesDirectTask = async ( done ) => {
|
|
|
57
65
|
const bundleFileName = `${ fileName }.bundle.js`
|
|
58
66
|
const bundleFilePath = join( outputDir, specificDir, bundleFileName )
|
|
59
67
|
|
|
60
|
-
configuration.input = sourceFile
|
|
61
|
-
configuration.output.file = bundleFilePath
|
|
68
|
+
configuration.buildOptions.input = sourceFile
|
|
69
|
+
configuration.buildOptions.output.file = bundleFilePath
|
|
62
70
|
|
|
63
71
|
try {
|
|
64
72
|
|
|
65
|
-
log( 'Bundling', green( configuration.output.file ) )
|
|
73
|
+
log( 'Bundling', green( configuration.buildOptions.output.file ) )
|
|
66
74
|
|
|
67
|
-
const bundle = await rollup( configuration )
|
|
68
|
-
await bundle.generate( configuration.output )
|
|
69
|
-
await bundle.write( configuration.output )
|
|
75
|
+
const bundle = await rollup( configuration.buildOptions )
|
|
76
|
+
await bundle.generate( configuration.buildOptions.output )
|
|
77
|
+
await bundle.write( configuration.buildOptions.output )
|
|
70
78
|
|
|
71
79
|
} catch ( error ) {
|
|
72
80
|
|
|
@@ -79,10 +87,8 @@ const checkBundlingFromEsmFilesDirectTask = async ( done ) => {
|
|
|
79
87
|
done()
|
|
80
88
|
|
|
81
89
|
}
|
|
82
|
-
checkBundlingFromEsmFilesDirectTask.displayName = '
|
|
90
|
+
checkBundlingFromEsmFilesDirectTask.displayName = basename( import.meta.filename, '.task.mjs' )
|
|
83
91
|
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'
|
|
84
92
|
checkBundlingFromEsmFilesDirectTask.flags = null
|
|
85
93
|
|
|
86
|
-
logLoadingTask( import.meta.filename, checkBundlingFromEsmFilesDirectTask, configurationPath )
|
|
87
|
-
|
|
88
94
|
export { checkBundlingFromEsmFilesDirectTask }
|
|
@@ -6,19 +6,21 @@ 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'
|
|
15
18
|
import { rollup } from 'rollup'
|
|
16
19
|
import {
|
|
17
|
-
|
|
18
|
-
getConfigurationPathFor,
|
|
20
|
+
getTaskConfigurationFor,
|
|
19
21
|
logLoadingTask,
|
|
20
|
-
packageSourcesDirectory
|
|
21
|
-
packageTestsBundlesDirectory
|
|
22
|
+
packageSourcesDirectory,
|
|
23
|
+
packageTestsBundlesDirectory
|
|
22
24
|
} from '../../_utils.mjs'
|
|
23
25
|
|
|
24
26
|
const {
|
|
@@ -27,15 +29,9 @@ const {
|
|
|
27
29
|
magenta,
|
|
28
30
|
} = colors
|
|
29
31
|
|
|
30
|
-
const sourcesFilesLocation = join( 'tests', 'bundlings', 'check-bundling.conf.mjs' )
|
|
31
|
-
const sourcesFilesPath = getConfigurationPathFor( sourcesFilesLocation )
|
|
32
|
-
|
|
33
|
-
const configurationLocation = join( 'tests', 'bundlings', 'check-bundling-from-esm-files-import.conf.mjs' )
|
|
34
|
-
const configurationPath = getConfigurationPathFor( configurationLocation )
|
|
35
|
-
|
|
36
32
|
const checkBundlingFromEsmFilesImportTask = async ( done ) => {
|
|
37
33
|
|
|
38
|
-
const outputDir = join(
|
|
34
|
+
const outputDir = join( packageTestsBundlesDirectory, 'from_files_import' )
|
|
39
35
|
const temporariesDir = join( outputDir, '.tmp' )
|
|
40
36
|
|
|
41
37
|
if ( existsSync( outputDir ) ) {
|
|
@@ -43,17 +39,28 @@ const checkBundlingFromEsmFilesImportTask = async ( done ) => {
|
|
|
43
39
|
rmSync( outputDir, { recursive: true } )
|
|
44
40
|
}
|
|
45
41
|
|
|
46
|
-
const
|
|
47
|
-
|
|
42
|
+
const configuration = await getTaskConfigurationFor( import.meta.filename )
|
|
43
|
+
|
|
44
|
+
// Get source files to process
|
|
45
|
+
const pattern = join( packageSourcesDirectory, '**' )
|
|
46
|
+
const sourceFiles = glob.sync( pattern )
|
|
47
|
+
.map( filePath => normalize( filePath ) )
|
|
48
|
+
.filter( filePath => {
|
|
49
|
+
const fileName = basename( filePath )
|
|
50
|
+
const isJsFile = fileName.endsWith( '.js' )
|
|
51
|
+
const isNotPrivateFile = !fileName.startsWith( '_' )
|
|
52
|
+
const isNotIgnoredFile = !configuration.ignoredFiles.includes( fileName )
|
|
53
|
+
return isJsFile && isNotPrivateFile && isNotIgnoredFile
|
|
54
|
+
} )
|
|
48
55
|
|
|
49
|
-
for ( let sourceFile of
|
|
56
|
+
for ( let sourceFile of sourceFiles ) {
|
|
50
57
|
|
|
51
58
|
const {
|
|
52
59
|
dir: sourceDir,
|
|
53
60
|
base: sourceBase,
|
|
54
61
|
name: sourceName
|
|
55
62
|
} = parse( sourceFile )
|
|
56
|
-
const specificFilePath = sourceFile.replace(
|
|
63
|
+
const specificFilePath = sourceFile.replace( packageSourcesDirectory, '' )
|
|
57
64
|
const specificDir = dirname( specificFilePath )
|
|
58
65
|
|
|
59
66
|
// Create temp import file per file in package
|
|
@@ -68,8 +75,8 @@ const checkBundlingFromEsmFilesImportTask = async ( done ) => {
|
|
|
68
75
|
const bundleFileName = `${ sourceName }.bundle.js`
|
|
69
76
|
const bundleFilePath = join( outputDir, specificDir, bundleFileName )
|
|
70
77
|
|
|
71
|
-
configuration.input = temporaryFile
|
|
72
|
-
configuration.output.file = bundleFilePath
|
|
78
|
+
configuration.buildOptions.input = temporaryFile
|
|
79
|
+
configuration.buildOptions.output.file = bundleFilePath
|
|
73
80
|
|
|
74
81
|
// create tmp file
|
|
75
82
|
try {
|
|
@@ -77,13 +84,13 @@ const checkBundlingFromEsmFilesImportTask = async ( done ) => {
|
|
|
77
84
|
mkdirSync( temporaryDir, { recursive: true } )
|
|
78
85
|
writeFileSync( temporaryFile, temporaryFileData )
|
|
79
86
|
|
|
80
|
-
const bundle = await rollup( configuration )
|
|
81
|
-
const { output } = await bundle.generate( configuration.output )
|
|
87
|
+
const bundle = await rollup( configuration.buildOptions )
|
|
88
|
+
const { output } = await bundle.generate( configuration.buildOptions.output )
|
|
82
89
|
|
|
83
90
|
let code = output[ 0 ].code
|
|
84
91
|
if ( code.length > 1 ) {
|
|
85
92
|
log( red( `[${ specificFilePath }] contain side-effects !` ) )
|
|
86
|
-
await bundle.write( configuration.output )
|
|
93
|
+
await bundle.write( configuration.buildOptions.output )
|
|
87
94
|
} else {
|
|
88
95
|
log( green( `[${ specificFilePath }] is side-effect free.` ) )
|
|
89
96
|
}
|
|
@@ -97,10 +104,10 @@ const checkBundlingFromEsmFilesImportTask = async ( done ) => {
|
|
|
97
104
|
done()
|
|
98
105
|
|
|
99
106
|
}
|
|
100
|
-
checkBundlingFromEsmFilesImportTask.displayName =
|
|
107
|
+
checkBundlingFromEsmFilesImportTask.displayName = basename( import.meta.filename, '.task.mjs' )
|
|
101
108
|
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'
|
|
102
109
|
checkBundlingFromEsmFilesImportTask.flags = null
|
|
103
110
|
|
|
104
|
-
logLoadingTask( import.meta.filename
|
|
111
|
+
logLoadingTask( import.meta.filename )
|
|
105
112
|
|
|
106
113
|
export { checkBundlingFromEsmFilesImportTask }
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { series } from 'gulp'
|
|
2
|
+
import { basename } from 'node:path'
|
|
2
3
|
import { logLoadingTask } from '../../_utils.mjs'
|
|
3
4
|
import { checkBundlingFromEsmBuildImportTask } from './check-bundling-from-esm-build-import.task.mjs'
|
|
4
5
|
import { checkBundlingFromEsmFilesDirectTask } from './check-bundling-from-esm-files-direct.task.mjs'
|
|
5
6
|
import { checkBundlingFromEsmFilesImportTask } from './check-bundling-from-esm-files-import.task.mjs'
|
|
6
7
|
|
|
8
|
+
logLoadingTask( import.meta.filename )
|
|
9
|
+
|
|
7
10
|
/**
|
|
8
11
|
* @description In view to detect bundling side effects this task will
|
|
9
12
|
* create intermediary file for each individual export from this package
|
|
@@ -15,9 +18,7 @@ const checkBundlingTask = series(
|
|
|
15
18
|
checkBundlingFromEsmBuildImportTask,
|
|
16
19
|
checkBundlingFromEsmFilesDirectTask
|
|
17
20
|
)
|
|
18
|
-
checkBundlingTask.displayName = '
|
|
21
|
+
checkBundlingTask.displayName = basename( import.meta.filename, '.task.mjs' )
|
|
19
22
|
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.'
|
|
20
23
|
|
|
21
|
-
logLoadingTask( import.meta.filename, checkBundlingTask )
|
|
22
|
-
|
|
23
24
|
export { checkBundlingTask }
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { series } from 'gulp'
|
|
2
|
+
import { basename } from 'node:path'
|
|
2
3
|
import { logLoadingTask } from '../_utils.mjs'
|
|
3
4
|
import { runBenchmarksTestsTask } from './benchmarks/run-benchmarks.task.mjs'
|
|
4
5
|
import { runUnitTestsTask } from './units/run-unit-tests.task.mjs'
|
|
5
6
|
|
|
7
|
+
logLoadingTask( import.meta.filename )
|
|
8
|
+
|
|
6
9
|
/**
|
|
7
10
|
* @method npm run test
|
|
8
11
|
* @global
|
|
@@ -12,10 +15,8 @@ const runTestsTask = series(
|
|
|
12
15
|
runBenchmarksTestsTask,
|
|
13
16
|
runUnitTestsTask,
|
|
14
17
|
)
|
|
15
|
-
runTestsTask.displayName = '
|
|
18
|
+
runTestsTask.displayName = basename( import.meta.filename, '.task.mjs' )
|
|
16
19
|
runTestsTask.description = 'Will run unit tests and benchmarks for backend (node) and frontend (web-test-runner) environments.'
|
|
17
20
|
runTestsTask.flags = null
|
|
18
21
|
|
|
19
|
-
logLoadingTask( import.meta.filename, runTestsTask )
|
|
20
|
-
|
|
21
22
|
export { runTestsTask }
|
|
@@ -1,31 +1,30 @@
|
|
|
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,
|
|
15
|
-
getConfigurationFrom,
|
|
16
|
-
getConfigurationPathFor,
|
|
17
17
|
getPrettyPackageName,
|
|
18
|
+
getTaskConfigurationFor,
|
|
18
19
|
Indenter,
|
|
19
20
|
logLoadingTask,
|
|
20
21
|
packageName,
|
|
21
22
|
packageNodeModulesDirectory,
|
|
22
|
-
packageSourcesDirectory
|
|
23
|
-
packageTestsUnitsDirectory
|
|
23
|
+
packageSourcesDirectory,
|
|
24
|
+
packageTestsUnitsDirectory
|
|
24
25
|
} from '../../_utils.mjs'
|
|
25
26
|
|
|
26
|
-
|
|
27
|
-
const configurationPath = getConfigurationPathFor( configurationLocation )
|
|
28
|
-
const configuration = await getConfigurationFrom( configurationPath )
|
|
27
|
+
logLoadingTask( import.meta.filename )
|
|
29
28
|
|
|
30
29
|
const {
|
|
31
30
|
red,
|
|
@@ -35,24 +34,39 @@ const {
|
|
|
35
34
|
/**
|
|
36
35
|
* @description Will generate unit test files from source code using type inference from comments
|
|
37
36
|
*/
|
|
38
|
-
const computeUnitTestsTask = ( done ) => {
|
|
37
|
+
const computeUnitTestsTask = async ( done ) => {
|
|
39
38
|
|
|
40
|
-
createDirectoryIfNotExist(
|
|
39
|
+
createDirectoryIfNotExist( packageTestsUnitsDirectory )
|
|
40
|
+
|
|
41
|
+
// Get task configuration
|
|
42
|
+
const filePathsToIgnore = await getTaskConfigurationFor( import.meta.filename )
|
|
43
|
+
|
|
44
|
+
// Get source files to process
|
|
45
|
+
const pattern = join( packageSourcesDirectory, '**' )
|
|
46
|
+
const sourceFiles = glob.sync( pattern )
|
|
47
|
+
.map( filePath => normalize( filePath ) )
|
|
48
|
+
.filter( filePath => {
|
|
49
|
+
const fileName = basename( filePath )
|
|
50
|
+
const isJsFile = fileName.endsWith( '.js' )
|
|
51
|
+
const isNotPrivateFile = !fileName.startsWith( '_' )
|
|
52
|
+
const isNotIgnoredFile = !filePathsToIgnore.includes( fileName )
|
|
53
|
+
return isJsFile && isNotPrivateFile && isNotIgnoredFile
|
|
54
|
+
} )
|
|
41
55
|
|
|
42
56
|
const unitsImportMap = []
|
|
43
|
-
for ( let sourceFile of
|
|
57
|
+
for ( let sourceFile of sourceFiles ) {
|
|
44
58
|
|
|
45
|
-
const specificFilePath = sourceFile.replace(
|
|
59
|
+
const specificFilePath = sourceFile.replace( packageSourcesDirectory, '' )
|
|
46
60
|
const specificDir = dirname( specificFilePath )
|
|
47
61
|
|
|
48
62
|
const fileName = basename( sourceFile, extname( sourceFile ) )
|
|
49
63
|
const unitFileName = `${ fileName }.unit.mjs`
|
|
50
|
-
const unitDirPath = join(
|
|
64
|
+
const unitDirPath = join( packageTestsUnitsDirectory, specificDir )
|
|
51
65
|
const unitFilePath = join( unitDirPath, unitFileName )
|
|
52
66
|
|
|
53
67
|
const nsName = `${ fileName }Namespace`
|
|
54
68
|
const unitName = `${ fileName }Units`
|
|
55
|
-
const importDirPath = relative( unitDirPath,
|
|
69
|
+
const importDirPath = relative( unitDirPath, packageSourcesDirectory )
|
|
56
70
|
const importFilePath = join( importDirPath, specificFilePath ).replace( /\\/g, '/' )
|
|
57
71
|
|
|
58
72
|
try {
|
|
@@ -477,7 +491,7 @@ const computeUnitTestsTask = ( done ) => {
|
|
|
477
491
|
'' +
|
|
478
492
|
`} )` + '\n'
|
|
479
493
|
|
|
480
|
-
const importUnitFilePath = relative(
|
|
494
|
+
const importUnitFilePath = relative( packageTestsUnitsDirectory, unitFilePath )
|
|
481
495
|
unitsImportMap.push( {
|
|
482
496
|
exportName: unitName,
|
|
483
497
|
path: importUnitFilePath.replace( /\\/g, '/' )
|
|
@@ -509,7 +523,7 @@ const computeUnitTestsTask = ( done ) => {
|
|
|
509
523
|
} else {
|
|
510
524
|
|
|
511
525
|
log( 'Warning ', yellow( 'No tests were generated. Create fallback global root import file.' ) )
|
|
512
|
-
const defaultUnitsDir = join(
|
|
526
|
+
const defaultUnitsDir = join( packageTestsUnitsDirectory, 'default' )
|
|
513
527
|
const defaultUnitsPath = join( defaultUnitsDir, 'default.unit.mjs' )
|
|
514
528
|
|
|
515
529
|
createDirectoryIfNotExist( defaultUnitsDir )
|
|
@@ -520,16 +534,14 @@ const computeUnitTestsTask = ( done ) => {
|
|
|
520
534
|
|
|
521
535
|
}
|
|
522
536
|
|
|
523
|
-
const unitsFilePath = join(
|
|
537
|
+
const unitsFilePath = join( packageTestsUnitsDirectory, `${ packageName }.units.mjs` )
|
|
524
538
|
createFile( unitsFilePath, unitsTemplate )
|
|
525
539
|
|
|
526
540
|
done()
|
|
527
541
|
|
|
528
542
|
}
|
|
529
|
-
computeUnitTestsTask.displayName = '
|
|
543
|
+
computeUnitTestsTask.displayName = basename( import.meta.filename, '.task.mjs' )
|
|
530
544
|
computeUnitTestsTask.description = 'Will generate unit test files from source code using type inference from comments'
|
|
531
545
|
computeUnitTestsTask.flags = null
|
|
532
546
|
|
|
533
|
-
logLoadingTask( import.meta.filename, computeUnitTestsTask, configurationPath )
|
|
534
|
-
|
|
535
547
|
export { computeUnitTestsTask }
|