@itee/tasks 1.0.12
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/.idea/inspectionProfiles/Project_Default.xml +6 -0
- package/.idea/modules.xml +8 -0
- package/.idea/tasks.iml +8 -0
- package/.idea/vcs.xml +6 -0
- package/CHANGELOG.md +56 -0
- package/README.md +1 -0
- package/configs/builds/build.conf.mjs +1 -0
- package/configs/cleans/clean.conf.mjs +1 -0
- package/configs/docs/doc.conf.json +1 -0
- package/configs/lints/lint.conf.mjs +91 -0
- package/configs/refresh.conf.mjs +1 -0
- package/configs/tests/benchmarks/compute-benchmarks.conf.mjs +5 -0
- package/configs/tests/benchmarks/run-benchmarks-for-frontend.conf.mjs +37 -0
- package/configs/tests/benchmarks/run-benchmarks.conf.mjs +7 -0
- package/configs/tests/bundlings/check-bundling-from-esm-build-import.conf.mjs +45 -0
- package/configs/tests/bundlings/check-bundling-from-esm-files-direct.conf.mjs +51 -0
- package/configs/tests/bundlings/check-bundling-from-esm-files-import.conf.mjs +48 -0
- package/configs/tests/units/compute-unit-tests.conf.mjs +5 -0
- package/configs/tests/units/run-unit-tests-for-frontend.conf.mjs +14 -0
- package/configs/tests/units/run-unit-tests.conf.mjs +7 -0
- package/package.json +100 -0
- package/sources/_utils.mjs +412 -0
- package/sources/builds/build.task.mjs +52 -0
- package/sources/cleans/clean.task.mjs +32 -0
- package/sources/docs/doc.task.mjs +48 -0
- package/sources/helps/help.task.mjs +155 -0
- package/sources/index.mjs +21 -0
- package/sources/lints/lint.task.mjs +46 -0
- package/sources/refresh.mjs +100 -0
- package/sources/releases/release.task.mjs +32 -0
- package/sources/tests/benchmarks/compute-benchmarks.task.mjs +236 -0
- package/sources/tests/benchmarks/run-benchmarks-for-backend.task.mjs +43 -0
- package/sources/tests/benchmarks/run-benchmarks-for-frontend.task.mjs +48 -0
- package/sources/tests/benchmarks/run-benchmarks.task.mjs +16 -0
- package/sources/tests/bundlings/check-bundling-from-esm-build-import.task.mjs +127 -0
- package/sources/tests/bundlings/check-bundling-from-esm-files-direct.task.mjs +94 -0
- package/sources/tests/bundlings/check-bundling-from-esm-files-import.task.mjs +113 -0
- package/sources/tests/bundlings/check-bundling.task.mjs +24 -0
- package/sources/tests/run-tests.task.mjs +22 -0
- package/sources/tests/units/compute-unit-tests.task.mjs +547 -0
- package/sources/tests/units/run-unit-tests-for-backend.task.mjs +48 -0
- package/sources/tests/units/run-unit-tests-for-frontend.task.mjs +48 -0
- package/sources/tests/units/run-unit-tests.task.mjs +16 -0
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import colors from 'ansi-colors'
|
|
2
|
+
import log from 'fancy-log'
|
|
3
|
+
import {
|
|
4
|
+
existsSync,
|
|
5
|
+
rmSync
|
|
6
|
+
} from 'fs'
|
|
7
|
+
import { glob } from 'glob'
|
|
8
|
+
import {
|
|
9
|
+
basename,
|
|
10
|
+
dirname,
|
|
11
|
+
extname,
|
|
12
|
+
join,
|
|
13
|
+
normalize
|
|
14
|
+
} from 'path'
|
|
15
|
+
import { rollup } from 'rollup'
|
|
16
|
+
import {
|
|
17
|
+
getTaskConfigurationFor,
|
|
18
|
+
logLoadingTask,
|
|
19
|
+
packageSourcesDirectory,
|
|
20
|
+
packageTestsBundlesDirectory
|
|
21
|
+
} from '../../_utils.mjs'
|
|
22
|
+
|
|
23
|
+
logLoadingTask( import.meta.filename )
|
|
24
|
+
|
|
25
|
+
const {
|
|
26
|
+
red,
|
|
27
|
+
green,
|
|
28
|
+
magenta,
|
|
29
|
+
} = colors
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* @description In view to detect bundling side effects this task will
|
|
33
|
+
* create intermediary file for each individual export from this package
|
|
34
|
+
* and then create rollup config for each of them and bundle
|
|
35
|
+
* Todo: Check for different target env like next task below this one
|
|
36
|
+
*/
|
|
37
|
+
const checkBundlingFromEsmFilesDirectTask = async ( done ) => {
|
|
38
|
+
|
|
39
|
+
const outputDir = join( packageTestsBundlesDirectory, 'from_files_direct' )
|
|
40
|
+
if ( existsSync( outputDir ) ) {
|
|
41
|
+
log( 'Clean up', magenta( outputDir ) )
|
|
42
|
+
rmSync( outputDir, { recursive: true } )
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const configuration = await getTaskConfigurationFor( import.meta.filename )
|
|
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 = !configuration.ignoredFiles.includes( fileName )
|
|
56
|
+
return isJsFile && isNotPrivateFile && isNotIgnoredFile
|
|
57
|
+
} )
|
|
58
|
+
|
|
59
|
+
for ( let sourceFile of sourceFiles ) {
|
|
60
|
+
|
|
61
|
+
const specificFilePath = sourceFile.replace( packageSourcesDirectory, '' )
|
|
62
|
+
const specificDir = dirname( specificFilePath )
|
|
63
|
+
const fileName = basename( sourceFile, extname( sourceFile ) )
|
|
64
|
+
|
|
65
|
+
const bundleFileName = `${ fileName }.bundle.js`
|
|
66
|
+
const bundleFilePath = join( outputDir, specificDir, bundleFileName )
|
|
67
|
+
|
|
68
|
+
configuration.buildOptions.input = sourceFile
|
|
69
|
+
configuration.buildOptions.output.file = bundleFilePath
|
|
70
|
+
|
|
71
|
+
try {
|
|
72
|
+
|
|
73
|
+
log( 'Bundling', green( configuration.buildOptions.output.file ) )
|
|
74
|
+
|
|
75
|
+
const bundle = await rollup( configuration.buildOptions )
|
|
76
|
+
await bundle.generate( configuration.buildOptions.output )
|
|
77
|
+
await bundle.write( configuration.buildOptions.output )
|
|
78
|
+
|
|
79
|
+
} catch ( error ) {
|
|
80
|
+
|
|
81
|
+
log( red( error.message ) )
|
|
82
|
+
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
done()
|
|
88
|
+
|
|
89
|
+
}
|
|
90
|
+
checkBundlingFromEsmFilesDirectTask.displayName = basename( import.meta.filename, '.task.mjs' )
|
|
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'
|
|
92
|
+
checkBundlingFromEsmFilesDirectTask.flags = null
|
|
93
|
+
|
|
94
|
+
export { checkBundlingFromEsmFilesDirectTask }
|
|
@@ -0,0 +1,113 @@
|
|
|
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 { glob } from 'glob'
|
|
10
|
+
import {
|
|
11
|
+
basename,
|
|
12
|
+
dirname,
|
|
13
|
+
join,
|
|
14
|
+
normalize,
|
|
15
|
+
parse,
|
|
16
|
+
relative
|
|
17
|
+
} from 'path'
|
|
18
|
+
import { rollup } from 'rollup'
|
|
19
|
+
import {
|
|
20
|
+
getTaskConfigurationFor,
|
|
21
|
+
logLoadingTask,
|
|
22
|
+
packageSourcesDirectory,
|
|
23
|
+
packageTestsBundlesDirectory
|
|
24
|
+
} from '../../_utils.mjs'
|
|
25
|
+
|
|
26
|
+
const {
|
|
27
|
+
red,
|
|
28
|
+
green,
|
|
29
|
+
magenta,
|
|
30
|
+
} = colors
|
|
31
|
+
|
|
32
|
+
const checkBundlingFromEsmFilesImportTask = async ( done ) => {
|
|
33
|
+
|
|
34
|
+
const outputDir = join( packageTestsBundlesDirectory, 'from_files_import' )
|
|
35
|
+
const temporariesDir = join( outputDir, '.tmp' )
|
|
36
|
+
|
|
37
|
+
if ( existsSync( outputDir ) ) {
|
|
38
|
+
log( 'Clean up', magenta( outputDir ) )
|
|
39
|
+
rmSync( outputDir, { recursive: true } )
|
|
40
|
+
}
|
|
41
|
+
|
|
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
|
+
} )
|
|
55
|
+
|
|
56
|
+
for ( let sourceFile of sourceFiles ) {
|
|
57
|
+
|
|
58
|
+
const {
|
|
59
|
+
dir: sourceDir,
|
|
60
|
+
base: sourceBase,
|
|
61
|
+
name: sourceName
|
|
62
|
+
} = parse( sourceFile )
|
|
63
|
+
const specificFilePath = sourceFile.replace( packageSourcesDirectory, '' )
|
|
64
|
+
const specificDir = dirname( specificFilePath )
|
|
65
|
+
|
|
66
|
+
// Create temp import file per file in package
|
|
67
|
+
const temporaryFileName = `${ sourceName }.import.js`
|
|
68
|
+
const temporaryDir = join( temporariesDir, specificDir )
|
|
69
|
+
const temporaryFile = join( temporaryDir, temporaryFileName )
|
|
70
|
+
const importDir = relative( temporaryDir, sourceDir )
|
|
71
|
+
const importFile = join( importDir, sourceBase )
|
|
72
|
+
const temporaryFileData = `import '${ importFile.replace( /\\/g, '/' ) }'`
|
|
73
|
+
|
|
74
|
+
// Bundle tmp file and check content for side effects
|
|
75
|
+
const bundleFileName = `${ sourceName }.bundle.js`
|
|
76
|
+
const bundleFilePath = join( outputDir, specificDir, bundleFileName )
|
|
77
|
+
|
|
78
|
+
configuration.buildOptions.input = temporaryFile
|
|
79
|
+
configuration.buildOptions.output.file = bundleFilePath
|
|
80
|
+
|
|
81
|
+
// create tmp file
|
|
82
|
+
try {
|
|
83
|
+
|
|
84
|
+
mkdirSync( temporaryDir, { recursive: true } )
|
|
85
|
+
writeFileSync( temporaryFile, temporaryFileData )
|
|
86
|
+
|
|
87
|
+
const bundle = await rollup( configuration.buildOptions )
|
|
88
|
+
const { output } = await bundle.generate( configuration.buildOptions.output )
|
|
89
|
+
|
|
90
|
+
let code = output[ 0 ].code
|
|
91
|
+
if ( code.length > 1 ) {
|
|
92
|
+
log( red( `[${ specificFilePath }] contain side-effects !` ) )
|
|
93
|
+
await bundle.write( configuration.buildOptions.output )
|
|
94
|
+
} else {
|
|
95
|
+
log( green( `[${ specificFilePath }] is side-effect free.` ) )
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
} catch ( error ) {
|
|
99
|
+
log( red( error.message ) )
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
done()
|
|
105
|
+
|
|
106
|
+
}
|
|
107
|
+
checkBundlingFromEsmFilesImportTask.displayName = basename( import.meta.filename, '.task.mjs' )
|
|
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'
|
|
109
|
+
checkBundlingFromEsmFilesImportTask.flags = null
|
|
110
|
+
|
|
111
|
+
logLoadingTask( import.meta.filename )
|
|
112
|
+
|
|
113
|
+
export { checkBundlingFromEsmFilesImportTask }
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { series } from 'gulp'
|
|
2
|
+
import { basename } from 'node:path'
|
|
3
|
+
import { logLoadingTask } from '../../_utils.mjs'
|
|
4
|
+
import { checkBundlingFromEsmBuildImportTask } from './check-bundling-from-esm-build-import.task.mjs'
|
|
5
|
+
import { checkBundlingFromEsmFilesDirectTask } from './check-bundling-from-esm-files-direct.task.mjs'
|
|
6
|
+
import { checkBundlingFromEsmFilesImportTask } from './check-bundling-from-esm-files-import.task.mjs'
|
|
7
|
+
|
|
8
|
+
logLoadingTask( import.meta.filename )
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @description In view to detect bundling side effects this task will
|
|
12
|
+
* create intermediary file for each individual export from this package
|
|
13
|
+
* and then create rollup config for each of them and bundle
|
|
14
|
+
* Todo: Check for different targets env like next task below this one
|
|
15
|
+
*/
|
|
16
|
+
const checkBundlingTask = series(
|
|
17
|
+
checkBundlingFromEsmFilesImportTask,
|
|
18
|
+
checkBundlingFromEsmBuildImportTask,
|
|
19
|
+
checkBundlingFromEsmFilesDirectTask
|
|
20
|
+
)
|
|
21
|
+
checkBundlingTask.displayName = basename( import.meta.filename, '.task.mjs' )
|
|
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.'
|
|
23
|
+
|
|
24
|
+
export { checkBundlingTask }
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { series } from 'gulp'
|
|
2
|
+
import { basename } from 'node:path'
|
|
3
|
+
import { logLoadingTask } from '../_utils.mjs'
|
|
4
|
+
import { runBenchmarksTestsTask } from './benchmarks/run-benchmarks.task.mjs'
|
|
5
|
+
import { runUnitTestsTask } from './units/run-unit-tests.task.mjs'
|
|
6
|
+
|
|
7
|
+
logLoadingTask( import.meta.filename )
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @method npm run test
|
|
11
|
+
* @global
|
|
12
|
+
* @description Will run unit tests and benchmarks for backend (node) and frontend (web-test-runner) environments
|
|
13
|
+
*/
|
|
14
|
+
const runTestsTask = series(
|
|
15
|
+
runBenchmarksTestsTask,
|
|
16
|
+
runUnitTestsTask,
|
|
17
|
+
)
|
|
18
|
+
runTestsTask.displayName = basename( import.meta.filename, '.task.mjs' )
|
|
19
|
+
runTestsTask.description = 'Will run unit tests and benchmarks for backend (node) and frontend (web-test-runner) environments.'
|
|
20
|
+
runTestsTask.flags = null
|
|
21
|
+
|
|
22
|
+
export { runTestsTask }
|