@itee/tasks 1.3.1 → 1.3.2

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.
Files changed (66) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/docs/cleans_clean.task.mjs.html +10 -11
  3. package/docs/global.html +14 -170
  4. package/docs/helps_help.task.mjs.html +24 -22
  5. package/docs/index.html +4 -4
  6. package/docs/lints_lint.task.mjs.html +14 -12
  7. package/docs/patches_patch.task.mjs.html +13 -5
  8. package/docs/quicksearch.html +1 -1
  9. package/docs/releases_release.task.mjs.html +5 -5
  10. package/docs/tests_benchmarks_compute-benchmarks.task.mjs.html +35 -38
  11. package/docs/tests_benchmarks_run-benchmarks-for-backend.task.mjs.html +20 -18
  12. package/docs/tests_benchmarks_run-benchmarks-for-frontend.task.mjs.html +10 -14
  13. package/docs/tests_bundlings_check-bundling-from-esm-files-direct.task.mjs.html +22 -34
  14. package/docs/tests_bundlings_check-bundling.task.mjs.html +5 -5
  15. package/docs/tests_run-tests.task.mjs.html +5 -5
  16. package/docs/tests_units_compute-unit-tests.task.mjs.html +40 -42
  17. package/docs/tests_units_run-unit-tests-for-backend.task.mjs.html +21 -19
  18. package/docs/tests_units_run-unit-tests-for-frontend.task.mjs.html +9 -13
  19. package/package.json +4 -4
  20. package/{sources → scripts}/refresh.mjs +10 -12
  21. package/sources/builds/build.conf.mjs +3 -0
  22. package/sources/builds/build.task.mjs +12 -14
  23. package/{configs → sources}/cleans/clean.conf.mjs +1 -1
  24. package/sources/cleans/clean.task.mjs +6 -7
  25. package/{configs → sources}/docs/doc.conf.mjs +8 -7
  26. package/sources/docs/doc.task.mjs +7 -8
  27. package/sources/helps/help.task.mjs +19 -17
  28. package/{configs → sources}/lints/lint.conf.mjs +18 -18
  29. package/sources/lints/lint.task.mjs +10 -8
  30. package/sources/patches/patch.task.mjs +9 -1
  31. package/sources/releases/release.task.mjs +1 -1
  32. package/sources/{index.mjs → tasks.js} +7 -2
  33. package/sources/tests/benchmarks/compute-benchmarks.conf.mjs +5 -0
  34. package/sources/tests/benchmarks/compute-benchmarks.task.mjs +31 -34
  35. package/sources/tests/benchmarks/run-benchmarks-for-backend.task.mjs +16 -14
  36. package/{configs → sources}/tests/benchmarks/run-benchmarks-for-frontend.conf.mjs +6 -6
  37. package/sources/tests/benchmarks/run-benchmarks-for-frontend.task.mjs +6 -10
  38. package/{configs → sources}/tests/benchmarks/run-benchmarks.conf.mjs +2 -2
  39. package/sources/tests/benchmarks/run-benchmarks.task.mjs +3 -3
  40. package/{configs → sources}/tests/bundlings/check-bundling-from-esm-build-import.conf.mjs +12 -10
  41. package/sources/tests/bundlings/check-bundling-from-esm-build-import.task.mjs +17 -17
  42. package/{configs → sources}/tests/bundlings/check-bundling-from-esm-files-direct.conf.mjs +20 -14
  43. package/sources/tests/bundlings/check-bundling-from-esm-files-direct.task.mjs +17 -29
  44. package/{configs → sources}/tests/bundlings/check-bundling-from-esm-files-import.conf.mjs +15 -13
  45. package/sources/tests/bundlings/check-bundling-from-esm-files-import.task.mjs +17 -29
  46. package/sources/tests/bundlings/check-bundling.task.mjs +1 -1
  47. package/sources/tests/run-tests.task.mjs +1 -1
  48. package/sources/tests/units/compute-unit-tests.conf.mjs +5 -0
  49. package/sources/tests/units/compute-unit-tests.task.mjs +36 -38
  50. package/sources/tests/units/run-unit-tests-for-backend.task.mjs +17 -15
  51. package/{configs → sources}/tests/units/run-unit-tests-for-frontend.conf.mjs +1 -1
  52. package/sources/tests/units/run-unit-tests-for-frontend.task.mjs +5 -9
  53. package/{configs → sources}/tests/units/run-unit-tests.conf.mjs +2 -2
  54. package/sources/tests/units/run-unit-tests.task.mjs +3 -3
  55. package/sources/utils/builds.mjs +238 -0
  56. package/sources/utils/colors.mjs +19 -0
  57. package/sources/utils/files.mjs +70 -0
  58. package/sources/utils/loggings.mjs +33 -0
  59. package/sources/utils/packages.mjs +172 -0
  60. package/sources/utils/tasks.mjs +170 -0
  61. package/sources/utils/texts.mjs +98 -0
  62. package/configs/builds/build.conf.mjs +0 -3
  63. package/configs/tests/benchmarks/compute-benchmarks.conf.mjs +0 -5
  64. package/configs/tests/units/compute-unit-tests.conf.mjs +0 -5
  65. package/sources/_utils.mjs +0 -692
  66. /package/{configs → scripts}/refresh.conf.mjs +0 -0
@@ -1,27 +1,29 @@
1
- import colors from 'ansi-colors'
2
- import log from 'fancy-log'
3
- import { existsSync } from 'fs'
4
- import { basename } from 'node:path'
5
- import { join } from 'path'
1
+ import { existsSync } from 'node:fs'
6
2
  import {
7
- logLoadingTask,
8
- packageName,
3
+ basename,
4
+ join
5
+ } from 'node:path'
6
+ import {
7
+ red,
8
+ yellow
9
+ } from '../../utils/colors.mjs'
10
+ import {
11
+ log,
12
+ logLoadingTask
13
+ } from '../../utils/loggings.mjs'
14
+ import {
15
+ getUnscopedPackageName,
9
16
  packageTestsBenchmarksDirectory
10
- } from '../../_utils.mjs'
17
+ } from '../../utils/packages.mjs'
11
18
 
12
19
  logLoadingTask( import.meta.filename )
13
20
 
14
- const {
15
- red,
16
- yellow
17
- } = colors
18
-
19
21
  /**
20
22
  * @description Will run benchmarks with node
21
23
  */
22
24
  const runBenchmarksForBackendTask = async ( done ) => {
23
25
 
24
- const benchesPath = join( packageTestsBenchmarksDirectory, `/${ packageName }.benchmarks.js` )
26
+ const benchesPath = join( packageTestsBenchmarksDirectory, `/${ getUnscopedPackageName() }.benchmarks.js` )
25
27
  if ( !existsSync( benchesPath ) ) {
26
28
  log( yellow( `${ benchesPath } does not exist, skip backend benchmarks...` ) )
27
29
  done()
@@ -2,17 +2,17 @@ import { jsonReporter } from '@itee/json-reporter'
2
2
  import { playwrightLauncher } from '@web/test-runner-playwright'
3
3
 
4
4
  export default {
5
- files: [
5
+ files: [
6
6
  'tests/benchmarks/**/*.bench.js'
7
7
  ],
8
- debug: false,
9
- nodeResolve: true,
10
- browsers: [
8
+ debug: false,
9
+ nodeResolve: true,
10
+ browsers: [
11
11
  playwrightLauncher( { product: 'chromium' } ),
12
12
  playwrightLauncher( { product: 'webkit' } ),
13
13
  playwrightLauncher( { product: 'firefox' } ),
14
14
  ],
15
- testFramework: {
15
+ testFramework: {
16
16
  path: 'node_modules/@itee/benchmarks-framework/benchmarks-framework.js',
17
17
  config: {
18
18
  foo: 'bar'
@@ -29,7 +29,7 @@ export default {
29
29
  </body>
30
30
  </html>
31
31
  `,
32
- reporters: [
32
+ reporters: [
33
33
  jsonReporter( {
34
34
  reportProgress: true
35
35
  } )
@@ -1,19 +1,15 @@
1
- import { startTestRunner } from '@web/test-runner'
2
- import colors from 'ansi-colors'
3
- import { basename } from 'node:path'
4
- import {
5
- getTaskConfigurationFor,
6
- logLoadingTask
7
- } from '../../_utils.mjs'
1
+ import { startTestRunner } from '@web/test-runner'
2
+ import { basename } from 'node:path'
3
+ import { red } from '../../utils/colors.mjs'
4
+ import { logLoadingTask } from '../../utils/loggings.mjs'
5
+ import { getTaskConfigurationFor } from '../../utils/tasks.mjs'
8
6
 
9
7
  logLoadingTask( import.meta.filename )
10
8
 
11
- const { red } = colors
12
-
13
9
  /**
14
10
  * @description Will run benchmarks with web-test-runner
15
11
  */
16
- const runBenchmarksForFrontendTask = async () => {
12
+ const runBenchmarksForFrontendTask = async () => {
17
13
 
18
14
  const configuration = await getTaskConfigurationFor( import.meta.filename )
19
15
  const testRunner = await startTestRunner( {
@@ -1,5 +1,5 @@
1
- import { join } from 'path'
2
- import { iteePackageSourcesDirectory } from '../../../sources/_utils.mjs'
1
+ import { join } from 'node:path'
2
+ import { iteePackageSourcesDirectory } from '../../utils/packages.mjs'
3
3
 
4
4
  export default [
5
5
  join( iteePackageSourcesDirectory, 'tests/benchmarks/run-benchmarks-for-backend.task.mjs' ),
@@ -1,9 +1,9 @@
1
- import { basename } from 'node:path'
1
+ import { basename } from 'node:path'
2
+ import { logLoadingTask } from '../../utils/loggings.mjs'
2
3
  import {
3
4
  getTaskConfigurationFor,
4
- logLoadingTask,
5
5
  serializeTasksFrom
6
- } from '../../_utils.mjs'
6
+ } from '../../utils/tasks.mjs'
7
7
 
8
8
  logLoadingTask( import.meta.filename )
9
9
 
@@ -1,10 +1,12 @@
1
1
  import nodeResolve from '@rollup/plugin-node-resolve'
2
2
  import cleanup from 'rollup-plugin-cleanup'
3
+ import { red } from '../../utils/colors.mjs'
4
+ import { log } from '../../utils/loggings.mjs'
3
5
 
4
6
  export default {
5
- input: null,
6
- external: [ '' ],
7
- plugins: [
7
+ input: null,
8
+ external: [ '' ],
9
+ plugins: [
8
10
  nodeResolve( {
9
11
  preferBuiltins: true
10
12
  } ),
@@ -12,7 +14,7 @@ export default {
12
14
  comments: 'all' // else remove __PURE__ declaration... -_-'
13
15
  } )
14
16
  ],
15
- onwarn: ( {
17
+ onwarn: ( {
16
18
  loc,
17
19
  frame,
18
20
  message
@@ -22,11 +24,11 @@ export default {
22
24
  if ( message.includes( 'Circular dependency' ) ) { return }
23
25
  if ( message.includes( 'Generated an empty chunk' ) ) { return }
24
26
 
25
- if ( loc ) {
26
- process.stderr.write( `/!\\ ${ loc.file } (${ loc.line }:${ loc.column }) ${ frame } ${ message }\n` )
27
- } else {
28
- process.stderr.write( `/!\\ ${ message }\n` )
29
- }
27
+ let errorMessage = ( loc )
28
+ ? `/!\\ ${ loc.file } (${ loc.line }:${ loc.column }) ${ frame } ${ message }\n`
29
+ : `/!\\ ${ message }\n`
30
+
31
+ log( red( errorMessage ) )
30
32
 
31
33
  },
32
34
  treeshake: {
@@ -37,7 +39,7 @@ export default {
37
39
  tryCatchDeoptimization: true,
38
40
  unknownGlobalSideEffects: true
39
41
  },
40
- output: {
42
+ output: {
41
43
  indent: '\t',
42
44
  format: 'esm',
43
45
  file: null
@@ -1,39 +1,39 @@
1
- import colors from 'ansi-colors'
2
- import log from 'fancy-log'
3
1
  import {
4
2
  existsSync,
5
3
  mkdirSync,
6
4
  readFileSync,
7
5
  rmSync,
8
6
  writeFileSync
9
- } from 'fs'
7
+ } from 'node:fs'
10
8
  import {
11
9
  basename,
12
10
  join,
13
11
  relative
14
- } from 'path'
15
- import { rollup } from 'rollup'
12
+ } from 'node:path'
13
+ import { rollup } from 'rollup'
16
14
  import {
17
- getTaskConfigurationFor,
18
- logLoadingTask,
15
+ green,
16
+ magenta,
17
+ red
18
+ } from '../../utils/colors.mjs'
19
+ import {
20
+ log,
21
+ logLoadingTask
22
+ } from '../../utils/loggings.mjs'
23
+ import {
24
+ getUnscopedPackageName,
19
25
  packageBuildsDirectory,
20
- packageName,
21
26
  packageTestsBundlesDirectory
22
- } from '../../_utils.mjs'
27
+ } from '../../utils/packages.mjs'
28
+ import { getTaskConfigurationFor } from '../../utils/tasks.mjs'
23
29
 
24
30
  logLoadingTask( import.meta.filename )
25
31
 
26
- const {
27
- red,
28
- green,
29
- magenta,
30
- } = colors
31
-
32
32
  const checkBundlingFromEsmBuildImportTask = async ( done ) => {
33
33
 
34
34
  const configuration = await getTaskConfigurationFor( import.meta.filename )
35
35
 
36
- const buildFilePath = join( packageBuildsDirectory, `${ packageName }.esm.js` )
36
+ const buildFilePath = join( packageBuildsDirectory, `${ getUnscopedPackageName() }.esm.js` )
37
37
  if ( !existsSync( buildFilePath ) ) {
38
38
  done( red( buildFilePath + ' does not exist' ) )
39
39
  }
@@ -41,7 +41,7 @@ const checkBundlingFromEsmBuildImportTask = async ( done ) => {
41
41
  const outputDir = join( packageTestsBundlesDirectory, 'from_build_import' )
42
42
  const temporaryDir = join( packageTestsBundlesDirectory, 'from_build_import', '.tmp' )
43
43
  const importDir = relative( temporaryDir, packageBuildsDirectory )
44
- const importFilePath = join( importDir, `${ packageName }.esm.js` )
44
+ const importFilePath = join( importDir, `${ getUnscopedPackageName() }.esm.js` )
45
45
 
46
46
  if ( existsSync( outputDir ) ) {
47
47
  log( 'Clean up', magenta( outputDir ) )
@@ -1,15 +1,21 @@
1
- import nodeResolve from '@rollup/plugin-node-resolve'
2
- import cleanup from 'rollup-plugin-cleanup'
3
- import { packageName } from '../../../sources/index.mjs'
1
+ import commonjs from '@rollup/plugin-commonjs'
2
+ import nodeResolve from '@rollup/plugin-node-resolve'
3
+ import cleanup from 'rollup-plugin-cleanup'
4
+ import { red } from '../../utils/colors.mjs'
5
+ import { log } from '../../utils/loggings.mjs'
6
+ import { getUnscopedPackageName } from '../../utils/packages.mjs'
4
7
 
5
8
  export default {
6
9
  ignoredFiles: [
7
- `${ packageName }.js`
10
+ `${ getUnscopedPackageName() }.js`
8
11
  ],
9
12
  buildOptions: {
10
- input: null,
11
- external: [ '' ],
12
- plugins: [
13
+ input: null,
14
+ external: [ '' ],
15
+ plugins: [
16
+ commonjs( {
17
+ include: 'node_modules/**'
18
+ } ),
13
19
  nodeResolve( {
14
20
  preferBuiltins: true
15
21
  } ),
@@ -17,7 +23,7 @@ export default {
17
23
  comments: 'none'
18
24
  } )
19
25
  ],
20
- onwarn: ( {
26
+ onwarn: ( {
21
27
  loc,
22
28
  frame,
23
29
  message
@@ -27,11 +33,11 @@ export default {
27
33
  if ( message.includes( 'Circular dependency' ) ) { return }
28
34
  if ( message.includes( 'Generated an empty chunk' ) ) { return }
29
35
 
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
- }
36
+ let errorMessage = ( loc )
37
+ ? `/!\\ ${ loc.file } (${ loc.line }:${ loc.column }) ${ frame } ${ message }\n`
38
+ : `/!\\ ${ message }\n`
39
+
40
+ log( red( errorMessage ) )
35
41
 
36
42
  },
37
43
  treeshake: {
@@ -42,7 +48,7 @@ export default {
42
48
  tryCatchDeoptimization: true,
43
49
  unknownGlobalSideEffects: true
44
50
  },
45
- output: {
51
+ output: {
46
52
  indent: '\t',
47
53
  format: 'esm',
48
54
  file: null
@@ -1,33 +1,32 @@
1
- import colors from 'ansi-colors'
2
- import log from 'fancy-log'
3
1
  import {
4
2
  existsSync,
5
3
  rmSync
6
- } from 'fs'
7
- import { glob } from 'glob'
4
+ } from 'node:fs'
8
5
  import {
9
6
  basename,
10
7
  dirname,
11
8
  extname,
12
- join,
13
- normalize
14
- } from 'path'
15
- import { rollup } from 'rollup'
9
+ join
10
+ } from 'node:path'
11
+ import { rollup } from 'rollup'
12
+ import {
13
+ green,
14
+ magenta,
15
+ red,
16
+ } from '../../utils/colors.mjs'
17
+ import { getJavascriptSourceFiles } from '../../utils/files.mjs'
18
+ import {
19
+ log,
20
+ logLoadingTask
21
+ } from '../../utils/loggings.mjs'
16
22
  import {
17
- getTaskConfigurationFor,
18
- logLoadingTask,
19
23
  packageSourcesDirectory,
20
24
  packageTestsBundlesDirectory
21
- } from '../../_utils.mjs'
25
+ } from '../../utils/packages.mjs'
26
+ import { getTaskConfigurationFor } from '../../utils/tasks.mjs'
22
27
 
23
28
  logLoadingTask( import.meta.filename )
24
29
 
25
- const {
26
- red,
27
- green,
28
- magenta,
29
- } = colors
30
-
31
30
  /**
32
31
  * @description In view to detect bundling side effects this task will
33
32
  * create intermediary file for each individual export from this package
@@ -43,18 +42,7 @@ const checkBundlingFromEsmFilesDirectTask = async ( done ) => {
43
42
  }
44
43
 
45
44
  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
- } )
45
+ const sourceFiles = getJavascriptSourceFiles( configuration )
58
46
 
59
47
  for ( let sourceFile of sourceFiles ) {
60
48
 
@@ -1,20 +1,22 @@
1
- import nodeResolve from '@rollup/plugin-node-resolve'
2
- import cleanup from 'rollup-plugin-cleanup'
3
- import { packageName } from '../../../sources/index.mjs'
1
+ import nodeResolve from '@rollup/plugin-node-resolve'
2
+ import cleanup from 'rollup-plugin-cleanup'
3
+ import { red } from '../../utils/colors.mjs'
4
+ import { log } from '../../utils/loggings.mjs'
5
+ import { getUnscopedPackageName } from '../../utils/packages.mjs'
4
6
 
5
7
  export default {
6
8
  ignoredFiles: [
7
- `${ packageName }.js`
9
+ `${ getUnscopedPackageName() }.js`
8
10
  ],
9
11
  buildOptions: {
10
- input: null,
11
- plugins: [
12
+ input: null,
13
+ plugins: [
12
14
  nodeResolve(),
13
15
  cleanup( {
14
16
  comments: 'all' // else remove __PURE__ declaration... -_-'
15
17
  } )
16
18
  ],
17
- onwarn: ( {
19
+ onwarn: ( {
18
20
  loc,
19
21
  frame,
20
22
  message
@@ -24,11 +26,11 @@ export default {
24
26
  if ( message.includes( 'Circular dependency' ) ) { return }
25
27
  if ( message.includes( 'Generated an empty chunk' ) ) { return }
26
28
 
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
- }
29
+ let errorMessage = ( loc )
30
+ ? `/!\\ ${ loc.file } (${ loc.line }:${ loc.column }) ${ frame } ${ message }\n`
31
+ : `/!\\ ${ message }\n`
32
+
33
+ log( red( errorMessage ) )
32
34
 
33
35
  },
34
36
  treeshake: {
@@ -39,7 +41,7 @@ export default {
39
41
  tryCatchDeoptimization: true,
40
42
  unknownGlobalSideEffects: true
41
43
  },
42
- output: {
44
+ output: {
43
45
  indent: '\t',
44
46
  format: 'esm',
45
47
  file: null
@@ -1,33 +1,34 @@
1
- import colors from 'ansi-colors'
2
- import log from 'fancy-log'
3
1
  import {
4
2
  existsSync,
5
3
  mkdirSync,
6
4
  rmSync,
7
5
  writeFileSync
8
- } from 'fs'
9
- import { glob } from 'glob'
6
+ } from 'node:fs'
10
7
  import {
11
8
  basename,
12
9
  dirname,
13
10
  join,
14
- normalize,
15
11
  parse,
16
12
  relative
17
- } from 'path'
18
- import { rollup } from 'rollup'
13
+ } from 'node:path'
14
+ import { rollup } from 'rollup'
15
+ import {
16
+ green,
17
+ magenta,
18
+ red
19
+ } from '../../utils/colors.mjs'
20
+ import { getJavascriptSourceFiles } from '../../utils/files.mjs'
21
+ import {
22
+ log,
23
+ logLoadingTask
24
+ } from '../../utils/loggings.mjs'
19
25
  import {
20
- getTaskConfigurationFor,
21
- logLoadingTask,
22
26
  packageSourcesDirectory,
23
27
  packageTestsBundlesDirectory
24
- } from '../../_utils.mjs'
28
+ } from '../../utils/packages.mjs'
29
+ import { getTaskConfigurationFor } from '../../utils/tasks.mjs'
25
30
 
26
- const {
27
- red,
28
- green,
29
- magenta,
30
- } = colors
31
+ logLoadingTask( import.meta.filename )
31
32
 
32
33
  const checkBundlingFromEsmFilesImportTask = async ( done ) => {
33
34
 
@@ -40,18 +41,7 @@ const checkBundlingFromEsmFilesImportTask = async ( done ) => {
40
41
  }
41
42
 
42
43
  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
- } )
44
+ const sourceFiles = getJavascriptSourceFiles( configuration )
55
45
 
56
46
  for ( let sourceFile of sourceFiles ) {
57
47
 
@@ -108,6 +98,4 @@ checkBundlingFromEsmFilesImportTask.displayName = basename( import.meta.filename
108
98
  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
99
  checkBundlingFromEsmFilesImportTask.flags = null
110
100
 
111
- logLoadingTask( import.meta.filename )
112
-
113
101
  export { checkBundlingFromEsmFilesImportTask }
@@ -1,6 +1,6 @@
1
1
  import { series } from 'gulp'
2
2
  import { basename } from 'node:path'
3
- import { logLoadingTask } from '../../_utils.mjs'
3
+ import { logLoadingTask } from '../../utils/loggings.mjs'
4
4
  import { checkBundlingFromEsmBuildImportTask } from './check-bundling-from-esm-build-import.task.mjs'
5
5
  import { checkBundlingFromEsmFilesDirectTask } from './check-bundling-from-esm-files-direct.task.mjs'
6
6
  import { checkBundlingFromEsmFilesImportTask } from './check-bundling-from-esm-files-import.task.mjs'
@@ -1,6 +1,6 @@
1
1
  import { series } from 'gulp'
2
2
  import { basename } from 'node:path'
3
- import { logLoadingTask } from '../_utils.mjs'
3
+ import { logLoadingTask } from '../utils/loggings.mjs'
4
4
  import { runBenchmarksTestsTask } from './benchmarks/run-benchmarks.task.mjs'
5
5
  import { runUnitTestsTask } from './units/run-unit-tests.task.mjs'
6
6
 
@@ -0,0 +1,5 @@
1
+ import { getUnscopedPackageName } from '../../utils/packages.mjs'
2
+
3
+ export default [
4
+ `${ getUnscopedPackageName() }.js`
5
+ ]
@@ -1,36 +1,40 @@
1
- import colors from 'ansi-colors'
2
- import childProcess from 'child_process'
3
- import log from 'fancy-log'
4
- import { glob } from 'glob'
5
- import { isNotEmptyArray } from 'itee-validators'
1
+ import { isNotEmptyArray } from 'itee-validators'
2
+ import childProcess from 'node:child_process'
6
3
  import {
7
4
  basename,
8
5
  dirname,
9
6
  extname,
10
7
  join,
11
- normalize,
12
8
  relative
13
- } from 'path'
9
+ } from 'node:path'
10
+ import {
11
+ red,
12
+ yellow
13
+ } from '../../utils/colors.mjs'
14
14
  import {
15
- Indenter,
16
15
  createDirectoryIfNotExist,
17
16
  createFile,
17
+ getJavascriptSourceFiles
18
+ } from '../../utils/files.mjs'
19
+ import {
20
+ log,
21
+ logLoadingTask
22
+ } from '../../utils/loggings.mjs'
23
+ import {
18
24
  getPrettyPackageName,
19
- getTaskConfigurationFor,
20
- logLoadingTask,
21
- packageName,
25
+ getUnscopedPackageName,
22
26
  packageNodeModulesDirectory,
23
27
  packageSourcesDirectory,
24
28
  packageTestsUnitsDirectory
25
- } from '../../_utils.mjs'
29
+ } from '../../utils/packages.mjs'
30
+ import { getTaskConfigurationFor } from '../../utils/tasks.mjs'
31
+ import {
32
+ Indenter,
33
+ toCamelCase
34
+ } from '../../utils/texts.mjs'
26
35
 
27
36
  logLoadingTask( import.meta.filename )
28
37
 
29
- const {
30
- red,
31
- yellow,
32
- } = colors
33
-
34
38
  /**
35
39
  * @description Will generate unit test files from source code using type inference from comments
36
40
  */
@@ -38,20 +42,8 @@ const computeUnitTestsTask = async ( done ) => {
38
42
 
39
43
  createDirectoryIfNotExist( packageTestsUnitsDirectory )
40
44
 
41
- // Get task configuration
42
45
  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
- } )
46
+ const sourceFiles = getJavascriptSourceFiles( filePathsToIgnore )
55
47
 
56
48
  const unitsImportMap = []
57
49
  for ( let sourceFile of sourceFiles ) {
@@ -59,20 +51,26 @@ const computeUnitTestsTask = async ( done ) => {
59
51
  const specificFilePath = sourceFile.replace( packageSourcesDirectory, '' )
60
52
  const specificDir = dirname( specificFilePath )
61
53
 
62
- const fileName = basename( sourceFile, extname( sourceFile ) )
63
- const unitFileName = `${ fileName }.unit.mjs`
64
- const unitDirPath = join( packageTestsUnitsDirectory, specificDir )
65
- const unitFilePath = join( unitDirPath, unitFileName )
54
+ const fileName = basename( sourceFile, extname( sourceFile ) )
55
+ const camelCaseFileName = toCamelCase( fileName )
56
+ const unitFileName = `${ camelCaseFileName }.unit.mjs`
57
+ const unitDirPath = join( packageTestsUnitsDirectory, specificDir )
58
+ const unitFilePath = join( unitDirPath, unitFileName )
66
59
 
67
- const nsName = `${ fileName }Namespace`
68
- const unitName = `${ fileName }Units`
60
+ const nsName = `${ camelCaseFileName }Namespace`
61
+ const unitName = `${ camelCaseFileName }Units`
69
62
  const importDirPath = relative( unitDirPath, packageSourcesDirectory )
70
63
  const importFilePath = join( importDirPath, specificFilePath ).replace( /\\/g, '/' )
71
64
 
72
65
  try {
73
66
 
74
67
  const jsdocPath = join( packageNodeModulesDirectory, '/jsdoc/jsdoc.js' )
75
- const jsdocOutput = childProcess.execFileSync( 'node', [ jsdocPath, '-X', sourceFile ] ).toString()
68
+ const jsdocOutput = childProcess.execFileSync( 'node', [ jsdocPath, '--explain', sourceFile ] ).toString()
69
+
70
+ if ( jsdocOutput.includes( 'There are no input files to process' ) ) {
71
+ log( 'Error ', red( `${ sourceFile }, no input files to process` ) )
72
+ continue
73
+ }
76
74
 
77
75
  const classNames = []
78
76
  const usedLongnames = []
@@ -534,7 +532,7 @@ const computeUnitTestsTask = async ( done ) => {
534
532
 
535
533
  }
536
534
 
537
- const unitsFilePath = join( packageTestsUnitsDirectory, `${ packageName }.units.mjs` )
535
+ const unitsFilePath = join( packageTestsUnitsDirectory, `${ getUnscopedPackageName() }.units.mjs` )
538
536
  createFile( unitsFilePath, unitsTemplate )
539
537
 
540
538
  done()