@itee/tasks 1.3.1 → 1.3.3

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 +10 -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 +160 -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
@@ -0,0 +1,160 @@
1
+ import {
2
+ parallel,
3
+ series
4
+ } from 'gulp'
5
+ import { existsSync } from 'node:fs'
6
+ import {
7
+ extname,
8
+ join,
9
+ relative
10
+ } from 'node:path'
11
+ import {
12
+ cyan,
13
+ red,
14
+ } from './colors.mjs'
15
+ import { getJsonFrom } from './files.mjs'
16
+ import { log } from './loggings.mjs'
17
+ import {
18
+ iteePackageRootDirectory,
19
+ iteePackageSourcesDirectory,
20
+ packageRootDirectory,
21
+ packageTasksConfigurationsDirectory,
22
+ packageTasksDirectory
23
+ } from './packages.mjs'
24
+
25
+ async function getTasksFrom( taskFiles = [] ) {
26
+
27
+ const tasks = []
28
+ for ( const taskFile of taskFiles ) {
29
+ const relativeTaskFile = relative( packageRootDirectory, taskFile )
30
+
31
+ try {
32
+
33
+ const module = await import(taskFile)
34
+
35
+ for ( const moduleKey in module ) {
36
+ const task = module[ moduleKey ]
37
+ tasks.push( task )
38
+ }
39
+
40
+ } catch ( error ) {
41
+
42
+ log( 'Error ', red( relativeTaskFile ), error.message )
43
+
44
+ }
45
+
46
+ }
47
+
48
+ return tasks
49
+
50
+ }
51
+
52
+ async function serializeTasksFrom( taskFiles = [] ) {
53
+
54
+ const tasks = await getTasksFrom( taskFiles )
55
+ return series( ...tasks )
56
+
57
+ }
58
+
59
+ async function parallelizeTasksFrom( taskFiles = [] ) {
60
+
61
+ const tasks = await getTasksFrom( taskFiles )
62
+ return parallel( ...tasks )
63
+
64
+ }
65
+
66
+ /// Task configuration management
67
+
68
+ function getTaskConfigurationPathFor( filename ) {
69
+
70
+ // Get relative path of the task between internal or user defined
71
+ let relativeTaskPath = filename.includes( iteePackageRootDirectory )
72
+ ? relative( iteePackageSourcesDirectory, filename )
73
+ : relative( packageTasksDirectory, filename )
74
+
75
+ // Generate all possible config file path depending on file extension and default or user defined
76
+ const terminalExtension = extname( relativeTaskPath )
77
+ const searchValue = relativeTaskPath.includes( '.task.' ) ? `.task${ terminalExtension }` : terminalExtension
78
+ const replaceValues = [
79
+ '.conf.json',
80
+ '.conf.js',
81
+ '.conf.cjs',
82
+ '.conf.mjs',
83
+ ]
84
+
85
+ // Generate all potential config file paths
86
+ const configurationPaths = []
87
+ for ( const replaceValue of replaceValues ) {
88
+ const configurationLocation = relativeTaskPath.replace( searchValue, replaceValue )
89
+ const packageConfigurationPath = join( packageTasksConfigurationsDirectory, configurationLocation )
90
+
91
+ configurationPaths.push( packageConfigurationPath )
92
+ }
93
+
94
+ // Take care of the configuration search order (package first then default !)
95
+ const defaultConfigFilename = filename.includes( '.task.' )
96
+ ? filename.replace( '.task.', '.conf.' )
97
+ : filename.replace( '.mjs', '.conf.mjs' )
98
+
99
+ configurationPaths.push( defaultConfigFilename )
100
+
101
+ // Looking for existing configuration file
102
+ let configurationPath = undefined
103
+ for ( const packageConfigurationPath of configurationPaths ) {
104
+
105
+ if ( existsSync( packageConfigurationPath ) ) {
106
+ configurationPath = packageConfigurationPath
107
+ break
108
+ }
109
+
110
+ }
111
+
112
+ // Else throw an error
113
+ if ( !configurationPath ) {
114
+ throw new Error( `Unable to find configuration in package configuration paths ${ configurationPaths.join( ', ' ) }.` )
115
+ }
116
+
117
+ return configurationPath
118
+
119
+ }
120
+
121
+ async function getTaskConfigurationFor( filename ) {
122
+
123
+ const configurationFilePath = getTaskConfigurationPathFor( filename )
124
+
125
+ log( `Loading configuration from ${ cyan( configurationFilePath ) }` )
126
+
127
+ let configuration = null
128
+
129
+ try {
130
+
131
+ if ( extname( configurationFilePath ) === '.json' ) {
132
+
133
+ configuration = getJsonFrom( configurationFilePath )
134
+
135
+ } else {
136
+
137
+ const moduleData = await import( configurationFilePath )
138
+ configuration = moduleData.default
139
+
140
+ }
141
+
142
+ } catch ( e ) {
143
+
144
+ log( red( e ) )
145
+
146
+ }
147
+
148
+ return configuration
149
+
150
+ }
151
+
152
+
153
+ export {
154
+ getTasksFrom,
155
+ serializeTasksFrom,
156
+ parallelizeTasksFrom,
157
+
158
+ getTaskConfigurationPathFor,
159
+ getTaskConfigurationFor,
160
+ }
@@ -0,0 +1,98 @@
1
+ import { unstyle } from './colors.mjs'
2
+
3
+ function alignTextCenter( text, width ) {
4
+
5
+ const unstyledText = unstyle( text.repeat( 1 ) )
6
+ const marginLength = ( width - unstyledText.length ) / 2
7
+
8
+ let leftMargin, rightMargin
9
+ if ( Number.isInteger( marginLength ) ) {
10
+ leftMargin = marginLength
11
+ rightMargin = marginLength
12
+ } else {
13
+ const flooredMargin = Math.floor( marginLength )
14
+ leftMargin = flooredMargin
15
+ rightMargin = flooredMargin + 1
16
+ }
17
+
18
+ return ' '.repeat( leftMargin ) + text + ' '.repeat( rightMargin )
19
+
20
+ }
21
+
22
+ function alignTextLeft( text, width ) {
23
+
24
+ const unstyledText = unstyle( text.repeat( 1 ) )
25
+ let repeatTime = width - unstyledText.length
26
+ repeatTime = ( repeatTime > 0 ) ? repeatTime : 0
27
+
28
+ return text + ' '.repeat( repeatTime )
29
+
30
+ }
31
+
32
+ function alignTextRight( text, width ) {
33
+
34
+ const unstyledText = unstyle( text.repeat( 1 ) )
35
+ let repeatTime = width - unstyledText.length
36
+ repeatTime = ( repeatTime > 0 ) ? repeatTime : 0
37
+
38
+ return ' '.repeat( repeatTime ) + text
39
+
40
+ }
41
+
42
+ function IndenterFactory( indentationChar = '\t', indentationLevel = 5 ) {
43
+
44
+ const indentationLevels = {}
45
+ let currentProperty = 'I_'
46
+ for ( let currentIndentationLevel = 1 ; currentIndentationLevel <= indentationLevel ; currentIndentationLevel++ ) {
47
+ indentationLevels[ currentProperty ] = indentationChar.repeat( currentIndentationLevel )
48
+ currentProperty += '_'
49
+ }
50
+
51
+ return {
52
+ I: new Indenter( indentationChar ),
53
+ ...indentationLevels
54
+ }
55
+
56
+ }
57
+
58
+ function toCamelCase( string ) {
59
+
60
+ return string
61
+ .trim()
62
+ .toLowerCase()
63
+ .replace( /[^a-zA-Z0-9]+(.)/g, ( _, char ) => char.toUpperCase() )
64
+ .replace( /^[A-Z]/, ( char ) => char.toLowerCase() )
65
+
66
+ }
67
+
68
+ class Indenter {
69
+
70
+ constructor( indentationChar = '\t' ) {
71
+
72
+ this.indentationChar = indentationChar
73
+ this.currentIndentationLevel = 0
74
+
75
+ }
76
+
77
+ _( indentationLevel = null ) {
78
+ return this.indentationChar.repeat( indentationLevel ?? this.currentIndentationLevel )
79
+ }
80
+
81
+ deeper( level = 1 ) {
82
+ this.currentIndentationLevel += level
83
+ }
84
+
85
+ shallower( level = 1 ) {
86
+ this.currentIndentationLevel -= level
87
+ }
88
+
89
+ }
90
+
91
+
92
+ export {
93
+ alignTextCenter,
94
+ alignTextLeft,
95
+ alignTextRight,
96
+ toCamelCase,
97
+ IndenterFactory as Indenter
98
+ }
@@ -1,3 +0,0 @@
1
- import { createRollupConfigs } from '../../sources/_utils.mjs'
2
-
3
- export default createRollupConfigs()
@@ -1,5 +0,0 @@
1
- import { packageName } from '../../../sources/_utils.mjs'
2
-
3
- export default [
4
- `${ packageName }.js`
5
- ]
@@ -1,5 +0,0 @@
1
- import { packageName } from '../../../sources/_utils.mjs'
2
-
3
- export default [
4
- `${ packageName }.js`
5
- ]