@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.
- package/CHANGELOG.md +8 -0
- package/docs/cleans_clean.task.mjs.html +10 -11
- package/docs/global.html +14 -170
- package/docs/helps_help.task.mjs.html +24 -22
- package/docs/index.html +4 -4
- package/docs/lints_lint.task.mjs.html +14 -12
- package/docs/patches_patch.task.mjs.html +13 -5
- package/docs/quicksearch.html +1 -1
- package/docs/releases_release.task.mjs.html +5 -5
- package/docs/tests_benchmarks_compute-benchmarks.task.mjs.html +35 -38
- package/docs/tests_benchmarks_run-benchmarks-for-backend.task.mjs.html +20 -18
- package/docs/tests_benchmarks_run-benchmarks-for-frontend.task.mjs.html +10 -14
- package/docs/tests_bundlings_check-bundling-from-esm-files-direct.task.mjs.html +22 -34
- package/docs/tests_bundlings_check-bundling.task.mjs.html +5 -5
- package/docs/tests_run-tests.task.mjs.html +5 -5
- package/docs/tests_units_compute-unit-tests.task.mjs.html +40 -42
- package/docs/tests_units_run-unit-tests-for-backend.task.mjs.html +21 -19
- package/docs/tests_units_run-unit-tests-for-frontend.task.mjs.html +9 -13
- package/package.json +4 -4
- package/{sources → scripts}/refresh.mjs +10 -12
- package/sources/builds/build.conf.mjs +3 -0
- package/sources/builds/build.task.mjs +12 -14
- package/{configs → sources}/cleans/clean.conf.mjs +1 -1
- package/sources/cleans/clean.task.mjs +6 -7
- package/{configs → sources}/docs/doc.conf.mjs +8 -7
- package/sources/docs/doc.task.mjs +7 -8
- package/sources/helps/help.task.mjs +19 -17
- package/{configs → sources}/lints/lint.conf.mjs +18 -18
- package/sources/lints/lint.task.mjs +10 -8
- package/sources/patches/patch.task.mjs +9 -1
- package/sources/releases/release.task.mjs +1 -1
- package/sources/{index.mjs → tasks.js} +7 -2
- package/sources/tests/benchmarks/compute-benchmarks.conf.mjs +5 -0
- package/sources/tests/benchmarks/compute-benchmarks.task.mjs +31 -34
- package/sources/tests/benchmarks/run-benchmarks-for-backend.task.mjs +16 -14
- package/{configs → sources}/tests/benchmarks/run-benchmarks-for-frontend.conf.mjs +6 -6
- package/sources/tests/benchmarks/run-benchmarks-for-frontend.task.mjs +6 -10
- package/{configs → sources}/tests/benchmarks/run-benchmarks.conf.mjs +2 -2
- package/sources/tests/benchmarks/run-benchmarks.task.mjs +3 -3
- package/{configs → sources}/tests/bundlings/check-bundling-from-esm-build-import.conf.mjs +12 -10
- package/sources/tests/bundlings/check-bundling-from-esm-build-import.task.mjs +17 -17
- package/{configs → sources}/tests/bundlings/check-bundling-from-esm-files-direct.conf.mjs +20 -14
- package/sources/tests/bundlings/check-bundling-from-esm-files-direct.task.mjs +17 -29
- package/{configs → sources}/tests/bundlings/check-bundling-from-esm-files-import.conf.mjs +15 -13
- package/sources/tests/bundlings/check-bundling-from-esm-files-import.task.mjs +17 -29
- package/sources/tests/bundlings/check-bundling.task.mjs +1 -1
- package/sources/tests/run-tests.task.mjs +1 -1
- package/sources/tests/units/compute-unit-tests.conf.mjs +5 -0
- package/sources/tests/units/compute-unit-tests.task.mjs +36 -38
- package/sources/tests/units/run-unit-tests-for-backend.task.mjs +17 -15
- package/{configs → sources}/tests/units/run-unit-tests-for-frontend.conf.mjs +1 -1
- package/sources/tests/units/run-unit-tests-for-frontend.task.mjs +5 -9
- package/{configs → sources}/tests/units/run-unit-tests.conf.mjs +2 -2
- package/sources/tests/units/run-unit-tests.task.mjs +3 -3
- package/sources/utils/builds.mjs +238 -0
- package/sources/utils/colors.mjs +19 -0
- package/sources/utils/files.mjs +70 -0
- package/sources/utils/loggings.mjs +33 -0
- package/sources/utils/packages.mjs +172 -0
- package/sources/utils/tasks.mjs +170 -0
- package/sources/utils/texts.mjs +98 -0
- package/configs/builds/build.conf.mjs +0 -3
- package/configs/tests/benchmarks/compute-benchmarks.conf.mjs +0 -5
- package/configs/tests/units/compute-unit-tests.conf.mjs +0 -5
- package/sources/_utils.mjs +0 -692
- /package/{configs → scripts}/refresh.conf.mjs +0 -0
|
@@ -1,29 +1,31 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import log from 'fancy-log'
|
|
4
|
-
import { existsSync } from 'fs'
|
|
5
|
-
import { basename } from 'node:path'
|
|
6
|
-
import { join } from 'path'
|
|
1
|
+
import { spawn } from 'node:child_process'
|
|
2
|
+
import { existsSync } from 'node:fs'
|
|
7
3
|
import {
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
basename,
|
|
5
|
+
join
|
|
6
|
+
} from 'node:path'
|
|
7
|
+
import {
|
|
8
|
+
red,
|
|
9
|
+
yellow
|
|
10
|
+
} from '../../utils/colors.mjs'
|
|
11
|
+
import {
|
|
12
|
+
log,
|
|
13
|
+
logLoadingTask
|
|
14
|
+
} from '../../utils/loggings.mjs'
|
|
15
|
+
import {
|
|
16
|
+
getUnscopedPackageName,
|
|
10
17
|
packageNodeModulesDirectory,
|
|
11
18
|
packageTestsUnitsDirectory
|
|
12
|
-
} from '../../
|
|
19
|
+
} from '../../utils/packages.mjs'
|
|
13
20
|
|
|
14
21
|
logLoadingTask( import.meta.filename )
|
|
15
22
|
|
|
16
|
-
const {
|
|
17
|
-
red,
|
|
18
|
-
yellow,
|
|
19
|
-
} = colors
|
|
20
|
-
|
|
21
23
|
/**
|
|
22
24
|
* @description Will run unit tests with node
|
|
23
25
|
*/
|
|
24
26
|
const runUnitTestsForBackendTask = ( done ) => {
|
|
25
27
|
|
|
26
|
-
const testsPath = join( packageTestsUnitsDirectory, `/${
|
|
28
|
+
const testsPath = join( packageTestsUnitsDirectory, `/${ getUnscopedPackageName() }.units.mjs` )
|
|
27
29
|
if ( !existsSync( testsPath ) ) {
|
|
28
30
|
log( yellow( `${ testsPath } does not exist, skip backend unit tests...` ) )
|
|
29
31
|
done()
|
|
@@ -1,15 +1,11 @@
|
|
|
1
|
-
import { startTestRunner }
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
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 unit tests with web-test-runner
|
|
15
11
|
*/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { join } from 'path'
|
|
2
|
-
import { iteePackageSourcesDirectory } from '
|
|
1
|
+
import { join } from 'node:path'
|
|
2
|
+
import { iteePackageSourcesDirectory } from '../../utils/packages.mjs'
|
|
3
3
|
|
|
4
4
|
export default [
|
|
5
5
|
join( iteePackageSourcesDirectory, 'tests/units/run-unit-tests-for-backend.task.mjs' ),
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { basename }
|
|
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
|
-
}
|
|
6
|
+
} from '../../utils/tasks.mjs'
|
|
7
7
|
|
|
8
8
|
logLoadingTask( import.meta.filename )
|
|
9
9
|
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
import commonjs from '@rollup/plugin-commonjs'
|
|
2
|
+
import nodeResolve from '@rollup/plugin-node-resolve'
|
|
3
|
+
import terser from '@rollup/plugin-terser'
|
|
4
|
+
import figlet from 'figlet'
|
|
5
|
+
import {
|
|
6
|
+
basename,
|
|
7
|
+
join
|
|
8
|
+
} from 'node:path'
|
|
9
|
+
import replace from 'rollup-plugin-re'
|
|
10
|
+
import { red } from './colors.mjs'
|
|
11
|
+
import { log } from './loggings.mjs'
|
|
12
|
+
import {
|
|
13
|
+
getPrettyPackageName,
|
|
14
|
+
getPrettyPackageVersion,
|
|
15
|
+
getUnscopedPackageName,
|
|
16
|
+
packageAuthor,
|
|
17
|
+
packageBuildsDirectory,
|
|
18
|
+
packageDescription,
|
|
19
|
+
packageLicense,
|
|
20
|
+
packageSourcesDirectory
|
|
21
|
+
} from './packages.mjs'
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
function getPrettyFormatForBanner( format ) {
|
|
25
|
+
|
|
26
|
+
let prettyFormat = ''
|
|
27
|
+
|
|
28
|
+
switch ( format ) {
|
|
29
|
+
|
|
30
|
+
case 'cjs':
|
|
31
|
+
prettyFormat = 'CommonJs'
|
|
32
|
+
break
|
|
33
|
+
|
|
34
|
+
case 'esm':
|
|
35
|
+
prettyFormat = 'EsModule'
|
|
36
|
+
break
|
|
37
|
+
|
|
38
|
+
case 'iife':
|
|
39
|
+
prettyFormat = 'Standalone'
|
|
40
|
+
break
|
|
41
|
+
|
|
42
|
+
case 'umd':
|
|
43
|
+
prettyFormat = 'Universal'
|
|
44
|
+
break
|
|
45
|
+
|
|
46
|
+
default:
|
|
47
|
+
throw new RangeError( `Invalid switch parameter: ${ format }` )
|
|
48
|
+
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return prettyFormat
|
|
52
|
+
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function convertBannerIntoComment( banner ) {
|
|
56
|
+
|
|
57
|
+
let bannerCommented = '/**\n'
|
|
58
|
+
bannerCommented += ' * '
|
|
59
|
+
bannerCommented += banner.replaceAll( '\n', '\n * ' )
|
|
60
|
+
bannerCommented += '\n'
|
|
61
|
+
bannerCommented += ` * @desc ${ packageDescription }\n`
|
|
62
|
+
bannerCommented += ` * @author [${ packageAuthor.name }]{@link ${ packageAuthor.url }}\n`
|
|
63
|
+
bannerCommented += ` * @license [${ packageLicense }]{@link https://opensource.org/licenses}\n`
|
|
64
|
+
bannerCommented += ' * \n'
|
|
65
|
+
bannerCommented += ' */'
|
|
66
|
+
|
|
67
|
+
return bannerCommented
|
|
68
|
+
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function computeBannerFor( format ) {
|
|
72
|
+
|
|
73
|
+
const packageName = getPrettyPackageName( '.' )
|
|
74
|
+
const packageVersion = getPrettyPackageVersion()
|
|
75
|
+
const prettyFormat = getPrettyFormatForBanner( format )
|
|
76
|
+
|
|
77
|
+
const figText = figlet.textSync(
|
|
78
|
+
`${ packageName } ${ packageVersion } - ${ prettyFormat }`,
|
|
79
|
+
{
|
|
80
|
+
font: 'Tmplr',
|
|
81
|
+
horizontalLayout: 'default',
|
|
82
|
+
verticalLayout: 'default',
|
|
83
|
+
whitespaceBreak: true,
|
|
84
|
+
}
|
|
85
|
+
)
|
|
86
|
+
|
|
87
|
+
return convertBannerIntoComment( figText )
|
|
88
|
+
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function computeIntroFor( requestPackages = [] ) {
|
|
92
|
+
|
|
93
|
+
let intro = ''
|
|
94
|
+
|
|
95
|
+
for ( const requestPackage of requestPackages ) {
|
|
96
|
+
intro += `if( ${ requestPackage } === undefined ) { throw new Error('${ getPrettyPackageName() } need ${ requestPackage } to be defined first. Please check your scripts loading order.') }` + '\n'
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
return intro
|
|
100
|
+
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function getOutputFileExtensionBasedOnFileFormat( format ) {
|
|
104
|
+
|
|
105
|
+
let extension
|
|
106
|
+
|
|
107
|
+
if ( format === 'cjs' ) {
|
|
108
|
+
extension = 'cjs'
|
|
109
|
+
} else if ( format === 'esm' ) {
|
|
110
|
+
extension = 'mjs'
|
|
111
|
+
} else {
|
|
112
|
+
extension = 'js'
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
return extension
|
|
116
|
+
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Will create an appropriate configuration object for rollup, related to the given arguments.
|
|
121
|
+
*
|
|
122
|
+
* @generator
|
|
123
|
+
* @param options
|
|
124
|
+
* @return {Array.<json>} An array of rollup configuration
|
|
125
|
+
*/
|
|
126
|
+
function createRollupConfigs( options = {} ) {
|
|
127
|
+
|
|
128
|
+
const _options = {
|
|
129
|
+
input: join( packageSourcesDirectory, `${ getUnscopedPackageName() }.js` ),
|
|
130
|
+
output: packageBuildsDirectory,
|
|
131
|
+
formats: [ 'esm', 'cjs', 'iife' ],
|
|
132
|
+
envs: [ 'dev', 'prod' ],
|
|
133
|
+
treeshake: true,
|
|
134
|
+
...options
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
const {
|
|
138
|
+
input,
|
|
139
|
+
output,
|
|
140
|
+
formats,
|
|
141
|
+
envs,
|
|
142
|
+
treeshake
|
|
143
|
+
} = _options
|
|
144
|
+
const name = getPrettyPackageName( '.' )
|
|
145
|
+
const fileName = basename( input, '.js' )
|
|
146
|
+
|
|
147
|
+
const configs = []
|
|
148
|
+
|
|
149
|
+
for ( let formatIndex = 0, numberOfFormats = formats.length ; formatIndex < numberOfFormats ; ++formatIndex ) {
|
|
150
|
+
|
|
151
|
+
for ( let envIndex = 0, numberOfEnvs = envs.length ; envIndex < numberOfEnvs ; envIndex++ ) {
|
|
152
|
+
|
|
153
|
+
const env = envs[ envIndex ]
|
|
154
|
+
const isProd = ( env.includes( 'prod' ) )
|
|
155
|
+
const format = formats[ formatIndex ]
|
|
156
|
+
const extension = getOutputFileExtensionBasedOnFileFormat( format )
|
|
157
|
+
const outputPath = ( isProd )
|
|
158
|
+
? join( output, `${ fileName }.min.${ extension }` )
|
|
159
|
+
: join( output, `${ fileName }.${ extension }` )
|
|
160
|
+
|
|
161
|
+
configs.push( {
|
|
162
|
+
input: input,
|
|
163
|
+
external: ( format === 'cjs' ) ? [
|
|
164
|
+
'fs'
|
|
165
|
+
] : [],
|
|
166
|
+
plugins: [
|
|
167
|
+
replace( {
|
|
168
|
+
defines: {
|
|
169
|
+
IS_REMOVE_ON_BUILD: false,
|
|
170
|
+
IS_BACKEND_SPECIFIC: ( format === 'cjs' )
|
|
171
|
+
}
|
|
172
|
+
} ),
|
|
173
|
+
commonjs( {
|
|
174
|
+
include: 'node_modules/**'
|
|
175
|
+
} ),
|
|
176
|
+
nodeResolve( {
|
|
177
|
+
preferBuiltins: true
|
|
178
|
+
} ),
|
|
179
|
+
isProd && terser()
|
|
180
|
+
],
|
|
181
|
+
onwarn: ( {
|
|
182
|
+
loc,
|
|
183
|
+
frame,
|
|
184
|
+
message
|
|
185
|
+
} ) => {
|
|
186
|
+
|
|
187
|
+
// Ignore some errors
|
|
188
|
+
if ( message.includes( 'Circular dependency' ) ) { return }
|
|
189
|
+
if ( message.includes( 'plugin uglify is deprecated' ) ) { return }
|
|
190
|
+
|
|
191
|
+
let errorMessage = ( loc )
|
|
192
|
+
? `/!\\ ${ loc.file } (${ loc.line }:${ loc.column }) ${ frame } ${ message }\n`
|
|
193
|
+
: `/!\\ ${ message }\n`
|
|
194
|
+
|
|
195
|
+
log( red( errorMessage ) )
|
|
196
|
+
|
|
197
|
+
},
|
|
198
|
+
treeshake: treeshake,
|
|
199
|
+
output: {
|
|
200
|
+
// core options
|
|
201
|
+
file: outputPath,
|
|
202
|
+
format: format,
|
|
203
|
+
name: name,
|
|
204
|
+
globals: {},
|
|
205
|
+
|
|
206
|
+
// advanced options
|
|
207
|
+
paths: {},
|
|
208
|
+
banner: ( isProd ) ? '' : computeBannerFor( format ),
|
|
209
|
+
footer: '',
|
|
210
|
+
intro: ( !isProd && format === 'iife' ) ? computeIntroFor() : '',
|
|
211
|
+
outro: '',
|
|
212
|
+
sourcemap: !isProd,
|
|
213
|
+
interop: 'auto',
|
|
214
|
+
|
|
215
|
+
// danger zone
|
|
216
|
+
exports: 'auto',
|
|
217
|
+
amd: {},
|
|
218
|
+
indent: '\t',
|
|
219
|
+
strict: true
|
|
220
|
+
}
|
|
221
|
+
} )
|
|
222
|
+
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
return configs
|
|
228
|
+
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
export {
|
|
233
|
+
getPrettyFormatForBanner,
|
|
234
|
+
convertBannerIntoComment,
|
|
235
|
+
computeBannerFor,
|
|
236
|
+
computeIntroFor,
|
|
237
|
+
createRollupConfigs,
|
|
238
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import colors from 'ansi-colors'
|
|
2
|
+
|
|
3
|
+
const red = ( value ) => colors.red( value )
|
|
4
|
+
const green = ( value ) => colors.green( value )
|
|
5
|
+
const blue = ( value ) => colors.blue( value )
|
|
6
|
+
const cyan = ( value ) => colors.cyan( value )
|
|
7
|
+
const yellow = ( value ) => colors.yellow( value )
|
|
8
|
+
const magenta = ( value ) => colors.magenta( value )
|
|
9
|
+
const unstyle = ( value ) => colors.unstyle( value )
|
|
10
|
+
|
|
11
|
+
export {
|
|
12
|
+
red,
|
|
13
|
+
green,
|
|
14
|
+
blue,
|
|
15
|
+
cyan,
|
|
16
|
+
yellow,
|
|
17
|
+
magenta,
|
|
18
|
+
unstyle
|
|
19
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { glob } from 'glob'
|
|
2
|
+
import {
|
|
3
|
+
existsSync,
|
|
4
|
+
mkdirSync,
|
|
5
|
+
readFileSync,
|
|
6
|
+
writeFileSync
|
|
7
|
+
} from 'node:fs'
|
|
8
|
+
import {
|
|
9
|
+
basename,
|
|
10
|
+
extname,
|
|
11
|
+
join,
|
|
12
|
+
normalize
|
|
13
|
+
} from 'node:path'
|
|
14
|
+
import { green } from './colors.mjs'
|
|
15
|
+
import { log } from './loggings.mjs'
|
|
16
|
+
import { packageSourcesDirectory } from './packages.mjs'
|
|
17
|
+
|
|
18
|
+
function createDirectoryIfNotExist( directoryPath ) {
|
|
19
|
+
|
|
20
|
+
if ( existsSync( directoryPath ) ) { return }
|
|
21
|
+
|
|
22
|
+
log( 'Creating', green( directoryPath ) )
|
|
23
|
+
mkdirSync( directoryPath, { recursive: true } )
|
|
24
|
+
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function getJsonFrom( path ) {
|
|
28
|
+
|
|
29
|
+
const buffer = readFileSync( path )
|
|
30
|
+
const fileContent = buffer.toString()
|
|
31
|
+
return JSON.parse( fileContent )
|
|
32
|
+
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function createFile( filePath, fileContent ) {
|
|
36
|
+
|
|
37
|
+
log( 'Creating', green( filePath ) )
|
|
38
|
+
writeFileSync( filePath, fileContent )
|
|
39
|
+
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function getFilesFrom( globPattern, filter = ( /*any*/ ) => true ) {
|
|
43
|
+
|
|
44
|
+
return glob.sync( globPattern )
|
|
45
|
+
.map( filePath => normalize( filePath ) )
|
|
46
|
+
.filter( filter )
|
|
47
|
+
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function getJavascriptSourceFiles( filePathsToIgnore = [] ) {
|
|
51
|
+
|
|
52
|
+
return glob.sync( join( packageSourcesDirectory, '**' ) )
|
|
53
|
+
.map( filePath => normalize( filePath ) )
|
|
54
|
+
.filter( filePath => {
|
|
55
|
+
const fileName = basename( filePath )
|
|
56
|
+
const isJsFile = [ '.js', '.mjs', '.cjs' ].includes( extname( fileName ) )
|
|
57
|
+
const isNotPrivateFile = !fileName.startsWith( '_' )
|
|
58
|
+
const isNotIgnoredFile = !filePathsToIgnore.includes( fileName )
|
|
59
|
+
return isJsFile && isNotPrivateFile && isNotIgnoredFile
|
|
60
|
+
} )
|
|
61
|
+
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export {
|
|
65
|
+
createDirectoryIfNotExist,
|
|
66
|
+
getJsonFrom,
|
|
67
|
+
createFile,
|
|
68
|
+
getFilesFrom,
|
|
69
|
+
getJavascriptSourceFiles
|
|
70
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import log from 'fancy-log'
|
|
2
|
+
import {
|
|
3
|
+
basename,
|
|
4
|
+
relative
|
|
5
|
+
} from 'node:path'
|
|
6
|
+
import {
|
|
7
|
+
blue,
|
|
8
|
+
green
|
|
9
|
+
} from './colors.mjs'
|
|
10
|
+
import { packageRootDirectory } from './packages.mjs'
|
|
11
|
+
|
|
12
|
+
/* global process */
|
|
13
|
+
const isDebugging = ( process && process.env && process.env.RUNNER_DEBUG && process.env.RUNNER_DEBUG === '1' )
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
function logLoadingTask( filename ) {
|
|
17
|
+
|
|
18
|
+
if ( !isDebugging ) {
|
|
19
|
+
return
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const taskPath = relative( packageRootDirectory, filename )
|
|
23
|
+
const taskName = basename( filename, '.task.mjs' )
|
|
24
|
+
|
|
25
|
+
log( `Loading ${ green( taskPath ) } with task ${ blue( taskName ) }` )
|
|
26
|
+
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
export {
|
|
31
|
+
log,
|
|
32
|
+
logLoadingTask
|
|
33
|
+
}
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import childProcess from 'child_process'
|
|
2
|
+
import {
|
|
3
|
+
dirname,
|
|
4
|
+
join
|
|
5
|
+
} from 'node:path'
|
|
6
|
+
import { fileURLToPath } from 'node:url'
|
|
7
|
+
import {
|
|
8
|
+
red,
|
|
9
|
+
yellow
|
|
10
|
+
} from './colors.mjs'
|
|
11
|
+
import { getJsonFrom } from './files.mjs'
|
|
12
|
+
import { log } from './loggings.mjs'
|
|
13
|
+
|
|
14
|
+
function _getPackageRootDirectory() {
|
|
15
|
+
|
|
16
|
+
let __dirname
|
|
17
|
+
|
|
18
|
+
if ( import.meta.dirname ) {
|
|
19
|
+
__dirname = import.meta.dirname
|
|
20
|
+
} else if ( import.meta.filename ) {
|
|
21
|
+
__dirname = dirname( import.meta.filename )
|
|
22
|
+
} else if ( import.meta.url ) {
|
|
23
|
+
const __filename = fileURLToPath( import.meta.url )
|
|
24
|
+
__dirname = dirname( __filename )
|
|
25
|
+
} else {
|
|
26
|
+
throw new Error( 'Unable to retrieve module dirname.' )
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return join( __dirname, '../../' )
|
|
30
|
+
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const iteePackageRootDirectory = _getPackageRootDirectory()
|
|
34
|
+
const iteePackageJsonPath = join( iteePackageRootDirectory, 'package.json' )
|
|
35
|
+
const iteePackageNodeModulesDirectory = join( iteePackageRootDirectory, 'node_modules' )
|
|
36
|
+
const iteePackageSourcesDirectory = join( iteePackageRootDirectory, 'sources' )
|
|
37
|
+
|
|
38
|
+
const packageRootDirectory = iteePackageRootDirectory.includes( 'node_modules' ) ? join( iteePackageRootDirectory, '../../../' ) : iteePackageRootDirectory
|
|
39
|
+
const packageTasksDirectory = join( packageRootDirectory, '.tasks' )
|
|
40
|
+
const packageTasksConfigurationsDirectory = join( packageTasksDirectory, 'configs' )
|
|
41
|
+
const packageNodeModulesDirectory = join( packageRootDirectory, 'node_modules' )
|
|
42
|
+
const packageBuildsDirectory = join( packageRootDirectory, 'builds' )
|
|
43
|
+
const packageSourcesDirectory = join( packageRootDirectory, 'sources' )
|
|
44
|
+
const packageSourcesBackendDirectory = join( packageSourcesDirectory, 'backend' )
|
|
45
|
+
const packageSourcesCommonDirectory = join( packageSourcesDirectory, 'common' )
|
|
46
|
+
const packageSourcesFrontendDirectory = join( packageSourcesDirectory, 'frontend' )
|
|
47
|
+
const packageTestsDirectory = join( packageRootDirectory, 'tests' )
|
|
48
|
+
const packageTestsBenchmarksDirectory = join( packageTestsDirectory, 'benchmarks' )
|
|
49
|
+
const packageTestsBundlesDirectory = join( packageTestsDirectory, 'bundles' )
|
|
50
|
+
const packageTestsUnitsDirectory = join( packageTestsDirectory, 'units' )
|
|
51
|
+
const packageDocsDirectory = join( packageRootDirectory, 'docs' )
|
|
52
|
+
const packageTutorialsDirectory = join( packageRootDirectory, 'tutorials' )
|
|
53
|
+
const packageJsonPath = join( packageRootDirectory, 'package.json' )
|
|
54
|
+
|
|
55
|
+
///
|
|
56
|
+
|
|
57
|
+
const packageJson = getJsonFrom( packageJsonPath )
|
|
58
|
+
const packageName = packageJson.name
|
|
59
|
+
const packageVersion = packageJson.version
|
|
60
|
+
const packageDescription = packageJson.description
|
|
61
|
+
const packageAuthor = packageJson.author
|
|
62
|
+
const packageLicense = packageJson.license
|
|
63
|
+
const packageMain = packageJson.main
|
|
64
|
+
|
|
65
|
+
function getUnscopedPackageName() {
|
|
66
|
+
|
|
67
|
+
return packageName.startsWith( '@' )
|
|
68
|
+
? packageName.split( '/' )[ 1 ]
|
|
69
|
+
: packageName.split( '-' )[ 1 ]
|
|
70
|
+
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function getPrettyPackageName( separator = ' ' ) {
|
|
74
|
+
|
|
75
|
+
let prettyPackageName = ''
|
|
76
|
+
|
|
77
|
+
const nameSplits = packageName.startsWith( '@' )
|
|
78
|
+
? packageName.slice( 1 ).split( '/' )
|
|
79
|
+
: packageName.split( '-' )
|
|
80
|
+
|
|
81
|
+
for ( const nameSplit of nameSplits ) {
|
|
82
|
+
prettyPackageName += nameSplit.charAt( 0 ).toUpperCase() + nameSplit.slice( 1 ) + separator
|
|
83
|
+
}
|
|
84
|
+
prettyPackageName = prettyPackageName.slice( 0, -1 )
|
|
85
|
+
|
|
86
|
+
return prettyPackageName
|
|
87
|
+
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function getPrettyPackageVersion() {
|
|
91
|
+
|
|
92
|
+
return 'v' + packageVersion
|
|
93
|
+
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function getPrettyNodeVersion() {
|
|
97
|
+
|
|
98
|
+
let nodeVersion = 'vX.x.ₓ'
|
|
99
|
+
|
|
100
|
+
try {
|
|
101
|
+
nodeVersion = childProcess.execFileSync( 'node', [ '--version' ] )
|
|
102
|
+
.toString()
|
|
103
|
+
.replace( /(\r\n|\n|\r)/gm, '' )
|
|
104
|
+
} catch ( e ) {
|
|
105
|
+
log( red( e ) )
|
|
106
|
+
|
|
107
|
+
if ( e.message.includes( 'ENOENT' ) ) {
|
|
108
|
+
nodeVersion += yellow( ' Not seems to be accessible from the path environment.' )
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
return ' node: ' + nodeVersion
|
|
113
|
+
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function getPrettyNpmVersion() {
|
|
117
|
+
|
|
118
|
+
let npmVersion = 'X.x.ₓ'
|
|
119
|
+
|
|
120
|
+
try {
|
|
121
|
+
npmVersion = childProcess.execFileSync( 'npm', [ '--version' ] )
|
|
122
|
+
.toString()
|
|
123
|
+
.replace( /(\r\n|\n|\r)/gm, '' )
|
|
124
|
+
} catch ( e ) {
|
|
125
|
+
log( red( e ) )
|
|
126
|
+
|
|
127
|
+
if ( e.message.includes( 'ENOENT' ) ) {
|
|
128
|
+
npmVersion += yellow( ' Not seems to be accessible from the path environment.' )
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
return ' npm: v' + npmVersion
|
|
133
|
+
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
export {
|
|
138
|
+
iteePackageRootDirectory,
|
|
139
|
+
iteePackageJsonPath,
|
|
140
|
+
iteePackageNodeModulesDirectory,
|
|
141
|
+
iteePackageSourcesDirectory,
|
|
142
|
+
|
|
143
|
+
packageRootDirectory,
|
|
144
|
+
packageTasksDirectory,
|
|
145
|
+
packageTasksConfigurationsDirectory,
|
|
146
|
+
packageNodeModulesDirectory,
|
|
147
|
+
packageBuildsDirectory,
|
|
148
|
+
packageSourcesDirectory,
|
|
149
|
+
packageSourcesBackendDirectory,
|
|
150
|
+
packageSourcesCommonDirectory,
|
|
151
|
+
packageSourcesFrontendDirectory,
|
|
152
|
+
packageTestsDirectory,
|
|
153
|
+
packageTestsBenchmarksDirectory,
|
|
154
|
+
packageTestsBundlesDirectory,
|
|
155
|
+
packageTestsUnitsDirectory,
|
|
156
|
+
packageDocsDirectory,
|
|
157
|
+
packageTutorialsDirectory,
|
|
158
|
+
packageJsonPath,
|
|
159
|
+
|
|
160
|
+
packageJson,
|
|
161
|
+
packageName,
|
|
162
|
+
packageVersion,
|
|
163
|
+
packageDescription,
|
|
164
|
+
packageAuthor,
|
|
165
|
+
packageLicense,
|
|
166
|
+
packageMain,
|
|
167
|
+
getUnscopedPackageName,
|
|
168
|
+
getPrettyPackageName,
|
|
169
|
+
getPrettyPackageVersion,
|
|
170
|
+
getPrettyNodeVersion,
|
|
171
|
+
getPrettyNpmVersion,
|
|
172
|
+
}
|