@itee/tasks 1.1.0 → 1.2.0
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/configs/docs/doc.conf.mjs +55 -0
- package/docs/-_utils.mjs.html +848 -0
- package/docs/cleans_clean.task.mjs.html +239 -0
- package/docs/fonts/glyphicons-halflings-regular.eot +0 -0
- package/docs/fonts/glyphicons-halflings-regular.svg +288 -0
- package/docs/fonts/glyphicons-halflings-regular.ttf +0 -0
- package/docs/fonts/glyphicons-halflings-regular.woff +0 -0
- package/docs/fonts/glyphicons-halflings-regular.woff2 +0 -0
- package/docs/global.html +1668 -0
- package/docs/helps_help.task.mjs.html +362 -0
- package/docs/img/glyphicons-halflings-white.png +0 -0
- package/docs/img/glyphicons-halflings.png +0 -0
- package/docs/index.html +228 -0
- package/docs/lints_lint.task.mjs.html +252 -0
- package/docs/patches_patch.task.mjs.html +251 -0
- package/docs/quicksearch.html +31 -0
- package/docs/releases_release.task.mjs.html +238 -0
- package/docs/scripts/docstrap.lib.js +11 -0
- package/docs/scripts/fulltext-search-ui.js +89 -0
- package/docs/scripts/fulltext-search.js +36 -0
- package/docs/scripts/lunr.min.js +6 -0
- package/docs/scripts/prettify/Apache-License-2.0.txt +202 -0
- package/docs/scripts/prettify/jquery.min.js +6 -0
- package/docs/scripts/prettify/lang-css.js +21 -0
- package/docs/scripts/prettify/prettify.js +496 -0
- package/docs/scripts/sunlight.js +1157 -0
- package/docs/scripts/toc.js +203 -0
- package/docs/styles/darkstrap.css +960 -0
- package/docs/styles/prettify-tomorrow.css +132 -0
- package/docs/styles/site.cerulean.css +7008 -0
- package/docs/styles/site.cosmo.css +7061 -0
- package/docs/styles/site.cyborg.css +7048 -0
- package/docs/styles/site.darkly.css +7171 -0
- package/docs/styles/site.darkstrap.css +5638 -0
- package/docs/styles/site.dibs-bootstrap.css +5899 -0
- package/docs/styles/site.flatly.css +7147 -0
- package/docs/styles/site.journal.css +6973 -0
- package/docs/styles/site.lumen.css +7298 -0
- package/docs/styles/site.paper.css +7623 -0
- package/docs/styles/site.readable.css +6997 -0
- package/docs/styles/site.sandstone.css +7035 -0
- package/docs/styles/site.simplex.css +7023 -0
- package/docs/styles/site.slate.css +7343 -0
- package/docs/styles/site.spacelab.css +7055 -0
- package/docs/styles/site.superhero.css +7131 -0
- package/docs/styles/site.united.css +6895 -0
- package/docs/styles/site.yeti.css +7195 -0
- package/docs/styles/sunlight.dark.css +345 -0
- package/docs/styles/sunlight.default.css +344 -0
- package/docs/tests_benchmarks_compute-benchmarks.task.mjs.html +442 -0
- package/docs/tests_benchmarks_run-benchmarks-for-backend.task.mjs.html +249 -0
- package/docs/tests_benchmarks_run-benchmarks-for-frontend.task.mjs.html +254 -0
- package/docs/tests_bundlings_check-bundling-from-esm-files-direct.task.mjs.html +300 -0
- package/docs/tests_bundlings_check-bundling.task.mjs.html +231 -0
- package/docs/tests_run-tests.task.mjs.html +228 -0
- package/docs/tests_units_compute-unit-tests.task.mjs.html +753 -0
- package/docs/tests_units_run-unit-tests-for-backend.task.mjs.html +254 -0
- package/docs/tests_units_run-unit-tests-for-frontend.task.mjs.html +254 -0
- package/package.json +5 -2
- package/sources/_utils.mjs +29 -3
- package/sources/patches/patch.task.mjs +45 -0
- package/configs/docs/doc.conf.json +0 -1
|
@@ -0,0 +1,848 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
|
|
3
|
+
<html lang="en">
|
|
4
|
+
<head>
|
|
5
|
+
<meta charset="utf-8">
|
|
6
|
+
<meta name="viewport" content="width=device-width">
|
|
7
|
+
<title>@itee/tasks v1.1.1 Source: _utils.mjs</title>
|
|
8
|
+
|
|
9
|
+
<!--[if lt IE 9]>
|
|
10
|
+
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
|
11
|
+
<![endif]-->
|
|
12
|
+
<link type="text/css" rel="stylesheet" href="styles/sunlight.dark.css">
|
|
13
|
+
|
|
14
|
+
<link type="text/css" rel="stylesheet" href="styles/site.cyborg.css">
|
|
15
|
+
|
|
16
|
+
</head>
|
|
17
|
+
|
|
18
|
+
<body>
|
|
19
|
+
|
|
20
|
+
<div class="navbar navbar-default navbar-fixed-top ">
|
|
21
|
+
<div class="container">
|
|
22
|
+
<div class="navbar-header">
|
|
23
|
+
<a class="navbar-brand" href="index.html">@itee/tasks v1.1.1</a>
|
|
24
|
+
<button class="navbar-toggle" type="button" data-toggle="collapse" data-target="#topNavigation">
|
|
25
|
+
<span class="icon-bar"></span>
|
|
26
|
+
<span class="icon-bar"></span>
|
|
27
|
+
<span class="icon-bar"></span>
|
|
28
|
+
</button>
|
|
29
|
+
</div>
|
|
30
|
+
<div class="navbar-collapse collapse" id="topNavigation">
|
|
31
|
+
<ul class="nav navbar-nav">
|
|
32
|
+
|
|
33
|
+
<li class="dropdown">
|
|
34
|
+
<a href="global.html" class="dropdown-toggle" data-toggle="dropdown">Global<b class="caret"></b></a>
|
|
35
|
+
<ul class="dropdown-menu inline">
|
|
36
|
+
<li><a href="global.html#checkBundlingFromEsmFilesDirectTask">checkBundlingFromEsmFilesDirectTask</a></li><li><a href="global.html#checkBundlingTask">checkBundlingTask</a></li><li><a href="global.html#computeBenchmarksTask">computeBenchmarksTask</a></li><li><a href="global.html#computeUnitTestsTask">computeUnitTestsTask</a></li><li><a href="global.html#createRollupConfigs">createRollupConfigs</a></li><li><a href="global.html#npmrunclean">npm run clean</a></li><li><a href="global.html#npmrunhelpdefault">npm run help ( default )</a></li><li><a href="global.html#npmrunlint">npm run lint</a></li><li><a href="global.html#npmrunpatch">npm run patch</a></li><li><a href="global.html#npmrunrelease">npm run release</a></li><li><a href="global.html#npmruntest">npm run test</a></li><li><a href="global.html#runBenchmarksForBackendTask">runBenchmarksForBackendTask</a></li><li><a href="global.html#runBenchmarksForFrontendTask">runBenchmarksForFrontendTask</a></li><li><a href="global.html#runUnitTestsForBackendTask">runUnitTestsForBackendTask</a></li><li><a href="global.html#runUnitTestsForFrontendTask">runUnitTestsForFrontendTask</a></li>
|
|
37
|
+
</ul>
|
|
38
|
+
</li>
|
|
39
|
+
|
|
40
|
+
</ul>
|
|
41
|
+
|
|
42
|
+
<div class="col-sm-3 col-md-3">
|
|
43
|
+
<form class="navbar-form" role="search">
|
|
44
|
+
<div class="input-group">
|
|
45
|
+
<input type="text" class="form-control" placeholder="Search" name="q" id="search-input">
|
|
46
|
+
<div class="input-group-btn">
|
|
47
|
+
<button class="btn btn-default" id="search-submit"><i class="glyphicon glyphicon-search"></i></button>
|
|
48
|
+
</div>
|
|
49
|
+
</div>
|
|
50
|
+
</form>
|
|
51
|
+
</div>
|
|
52
|
+
|
|
53
|
+
</div>
|
|
54
|
+
|
|
55
|
+
</div>
|
|
56
|
+
</div>
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
<div class="container" id="toc-content">
|
|
60
|
+
<div class="row">
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
<div class="col-md-12">
|
|
64
|
+
|
|
65
|
+
<div id="main">
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
<h1 class="page-title">Source: _utils.mjs</h1>
|
|
69
|
+
|
|
70
|
+
<section>
|
|
71
|
+
<article>
|
|
72
|
+
<pre
|
|
73
|
+
class="sunlight-highlight-javascript linenums">import commonjs from '@rollup/plugin-commonjs'
|
|
74
|
+
import nodeResolve from '@rollup/plugin-node-resolve'
|
|
75
|
+
import terser from '@rollup/plugin-terser'
|
|
76
|
+
import colors from 'ansi-colors'
|
|
77
|
+
import childProcess from 'child_process'
|
|
78
|
+
import log from 'fancy-log'
|
|
79
|
+
import figlet from 'figlet'
|
|
80
|
+
import { glob } from 'glob'
|
|
81
|
+
import {
|
|
82
|
+
parallel,
|
|
83
|
+
series
|
|
84
|
+
} from 'gulp'
|
|
85
|
+
import {
|
|
86
|
+
existsSync,
|
|
87
|
+
mkdirSync,
|
|
88
|
+
readFileSync,
|
|
89
|
+
writeFileSync
|
|
90
|
+
} from 'node:fs'
|
|
91
|
+
import {
|
|
92
|
+
basename,
|
|
93
|
+
dirname,
|
|
94
|
+
extname,
|
|
95
|
+
join,
|
|
96
|
+
normalize,
|
|
97
|
+
relative,
|
|
98
|
+
} from 'node:path'
|
|
99
|
+
import { fileURLToPath } from 'node:url'
|
|
100
|
+
import replace from 'rollup-plugin-re'
|
|
101
|
+
|
|
102
|
+
const {
|
|
103
|
+
red,
|
|
104
|
+
green,
|
|
105
|
+
yellow,
|
|
106
|
+
blue,
|
|
107
|
+
magenta,
|
|
108
|
+
cyan
|
|
109
|
+
} = colors
|
|
110
|
+
|
|
111
|
+
/// Debugging
|
|
112
|
+
|
|
113
|
+
const isDebugging = ( process.env.RUNNER_DEBUG && process.env.RUNNER_DEBUG === '1' )
|
|
114
|
+
|
|
115
|
+
/// Package paths and data
|
|
116
|
+
|
|
117
|
+
function _getPackageRootDirectory() {
|
|
118
|
+
|
|
119
|
+
let __dirname
|
|
120
|
+
|
|
121
|
+
if ( import.meta.dirname ) {
|
|
122
|
+
__dirname = import.meta.dirname
|
|
123
|
+
} else if ( import.meta.filename ) {
|
|
124
|
+
__dirname = dirname( import.meta.filename )
|
|
125
|
+
} else if ( import.meta.url ) {
|
|
126
|
+
const __filename = fileURLToPath( import.meta.url )
|
|
127
|
+
__dirname = dirname( __filename )
|
|
128
|
+
} else {
|
|
129
|
+
throw new Error( 'Unable to retrieve module dirname.' )
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
return join( __dirname, '..' )
|
|
133
|
+
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
const iteePackageRootDirectory = _getPackageRootDirectory()
|
|
137
|
+
const iteePackageJsonPath = join( iteePackageRootDirectory, 'package.json' )
|
|
138
|
+
const iteePackageConfigurationsDirectory = join( iteePackageRootDirectory, 'configs' )
|
|
139
|
+
const iteePackageNodeModulesDirectory = join( iteePackageRootDirectory, 'node_modules' )
|
|
140
|
+
const iteePackageSourcesDirectory = join( iteePackageRootDirectory, 'sources' )
|
|
141
|
+
|
|
142
|
+
const packageRootDirectory = iteePackageRootDirectory.includes( 'node_modules' ) ? join( iteePackageRootDirectory, '../../../' ) : iteePackageRootDirectory
|
|
143
|
+
const packageTasksDirectory = join( packageRootDirectory, '.tasks' )
|
|
144
|
+
const packageTasksConfigurationsDirectory = join( packageTasksDirectory, 'configs' )
|
|
145
|
+
const packageNodeModulesDirectory = join( packageRootDirectory, 'node_modules' )
|
|
146
|
+
const packageBuildsDirectory = join( packageRootDirectory, 'builds' )
|
|
147
|
+
const packageSourcesDirectory = join( packageRootDirectory, 'sources' )
|
|
148
|
+
const packageSourcesBackendDirectory = join( packageSourcesDirectory, 'backend' )
|
|
149
|
+
const packageSourcesCommonDirectory = join( packageSourcesDirectory, 'common' )
|
|
150
|
+
const packageSourcesFrontendDirectory = join( packageSourcesDirectory, 'frontend' )
|
|
151
|
+
const packageTestsDirectory = join( packageRootDirectory, 'tests' )
|
|
152
|
+
const packageTestsBenchmarksDirectory = join( packageTestsDirectory, 'benchmarks' )
|
|
153
|
+
const packageTestsBundlesDirectory = join( packageTestsDirectory, 'bundles' )
|
|
154
|
+
const packageTestsUnitsDirectory = join( packageTestsDirectory, 'units' )
|
|
155
|
+
const packageDocsDirectory = join( packageRootDirectory, 'docs' )
|
|
156
|
+
const packageTutorialsDirectory = join( packageRootDirectory, 'tutorials' )
|
|
157
|
+
const packageJsonPath = join( packageRootDirectory, 'package.json' )
|
|
158
|
+
|
|
159
|
+
///
|
|
160
|
+
|
|
161
|
+
const packageJson = getJsonFrom( packageJsonPath )
|
|
162
|
+
const packageName = packageJson.name
|
|
163
|
+
const packageVersion = packageJson.version
|
|
164
|
+
const packageDescription = packageJson.description
|
|
165
|
+
const packageAuthor = packageJson.author
|
|
166
|
+
const packageLicense = packageJson.license
|
|
167
|
+
|
|
168
|
+
function getPrettyPackageName( separator = ' ' ) {
|
|
169
|
+
|
|
170
|
+
let prettyPackageName = ''
|
|
171
|
+
|
|
172
|
+
const nameSplits = packageName.split( '-' )
|
|
173
|
+
for ( const nameSplit of nameSplits ) {
|
|
174
|
+
prettyPackageName += nameSplit.charAt( 0 ).toUpperCase() + nameSplit.slice( 1 ) + separator
|
|
175
|
+
}
|
|
176
|
+
prettyPackageName = prettyPackageName.slice( 0, -1 )
|
|
177
|
+
|
|
178
|
+
return prettyPackageName
|
|
179
|
+
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
function getPrettyPackageVersion() {
|
|
183
|
+
|
|
184
|
+
return 'v' + packageVersion
|
|
185
|
+
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
function getPrettyNodeVersion() {
|
|
189
|
+
|
|
190
|
+
let nodeVersion = 'vX.x.ₓ'
|
|
191
|
+
|
|
192
|
+
try {
|
|
193
|
+
nodeVersion = childProcess.execFileSync( 'node', [ '--version' ] )
|
|
194
|
+
.toString()
|
|
195
|
+
.replace( /(\r\n|\n|\r)/gm, '' )
|
|
196
|
+
} catch ( e ) {
|
|
197
|
+
log( red( e ) )
|
|
198
|
+
|
|
199
|
+
if ( e.message.includes( 'ENOENT' ) ) {
|
|
200
|
+
nodeVersion += yellow( ' Not seems to be accessible from the path environment.' )
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
return ' node: ' + nodeVersion
|
|
205
|
+
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
function getPrettyNpmVersion() {
|
|
209
|
+
|
|
210
|
+
let npmVersion = 'X.x.ₓ'
|
|
211
|
+
|
|
212
|
+
try {
|
|
213
|
+
npmVersion = childProcess.execFileSync( 'npm', [ '--version' ] )
|
|
214
|
+
.toString()
|
|
215
|
+
.replace( /(\r\n|\n|\r)/gm, '' )
|
|
216
|
+
} catch ( e ) {
|
|
217
|
+
log( red( e ) )
|
|
218
|
+
|
|
219
|
+
if ( e.message.includes( 'ENOENT' ) ) {
|
|
220
|
+
npmVersion += yellow( ' Not seems to be accessible from the path environment.' )
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
return ' npm: v' + npmVersion
|
|
225
|
+
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/// File system Management
|
|
229
|
+
|
|
230
|
+
function createDirectoryIfNotExist( directoryPath ) {
|
|
231
|
+
|
|
232
|
+
if ( !existsSync( directoryPath ) ) {
|
|
233
|
+
log( 'Creating', green( directoryPath ) )
|
|
234
|
+
mkdirSync( directoryPath, { recursive: true } )
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
function getJsonFrom( path ) {
|
|
240
|
+
|
|
241
|
+
const buffer = readFileSync( path )
|
|
242
|
+
return JSON.parse( buffer.toString() )
|
|
243
|
+
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
function createFile( filePath, fileContent ) {
|
|
247
|
+
|
|
248
|
+
log( 'Creating', green( filePath ) )
|
|
249
|
+
writeFileSync( filePath, fileContent )
|
|
250
|
+
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
function getFilesFrom( globPattern, filter = ( any ) => true ) {
|
|
254
|
+
|
|
255
|
+
return glob.sync( globPattern )
|
|
256
|
+
.map( filePath => normalize( filePath ) )
|
|
257
|
+
.filter( filter )
|
|
258
|
+
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
/// Task Management
|
|
262
|
+
|
|
263
|
+
async function getTasksFrom( taskFiles = [] ) {
|
|
264
|
+
|
|
265
|
+
const tasks = []
|
|
266
|
+
for ( const taskFile of taskFiles ) {
|
|
267
|
+
const relativeTaskFile = relative( packageRootDirectory, taskFile )
|
|
268
|
+
|
|
269
|
+
try {
|
|
270
|
+
|
|
271
|
+
const module = await import(taskFile)
|
|
272
|
+
|
|
273
|
+
const exportStrings = []
|
|
274
|
+
for ( const moduleKey in module ) {
|
|
275
|
+
const task = module[ moduleKey ]
|
|
276
|
+
tasks.push( task )
|
|
277
|
+
|
|
278
|
+
const name = task.name ?? null
|
|
279
|
+
const displayName = task.displayName ?? null
|
|
280
|
+
const fullName = ( moduleKey !== name ) ? `${ blue( moduleKey ) }( ${ magenta( name ) } )` : `${ blue( name ) }`
|
|
281
|
+
const exportAs = ( displayName ) ? ` as ${ cyan( displayName ) }` : ''
|
|
282
|
+
const exportString = fullName + exportAs
|
|
283
|
+
exportStrings.push( exportString )
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
//log( 'Process ', green( relativeTaskFile ), `with task${ ( exportStrings.length > 1 ) ? 's' : '' }`, exportStrings.join( ', ' ) )
|
|
287
|
+
|
|
288
|
+
} catch ( error ) {
|
|
289
|
+
|
|
290
|
+
log( 'Error ', red( relativeTaskFile ), error.message )
|
|
291
|
+
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
return tasks
|
|
297
|
+
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
async function serializeTasksFrom( taskFiles = [] ) {
|
|
301
|
+
|
|
302
|
+
const tasks = await getTasksFrom( taskFiles )
|
|
303
|
+
return series( ...tasks )
|
|
304
|
+
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
async function parallelizeTasksFrom( taskFiles = [] ) {
|
|
308
|
+
|
|
309
|
+
const tasks = await getTasksFrom( taskFiles )
|
|
310
|
+
return parallel( ...tasks )
|
|
311
|
+
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
/// Task configuration management
|
|
315
|
+
|
|
316
|
+
function getTaskConfigurationPathFor( filename ) {
|
|
317
|
+
|
|
318
|
+
// Get relative path of the task between internal or user defined
|
|
319
|
+
let relativeTaskPath = filename.includes( iteePackageSourcesDirectory )
|
|
320
|
+
? relative( iteePackageSourcesDirectory, filename )
|
|
321
|
+
: relative( packageTasksDirectory, filename )
|
|
322
|
+
|
|
323
|
+
// Generate all possible config file path depending on file extension and default or user defined
|
|
324
|
+
const terminalExtension = extname( relativeTaskPath )
|
|
325
|
+
const searchValue = relativeTaskPath.includes( '.task.' ) ? `.task${ terminalExtension }` : terminalExtension
|
|
326
|
+
const replaceValues = [
|
|
327
|
+
'.conf.json',
|
|
328
|
+
'.conf.js',
|
|
329
|
+
'.conf.cjs',
|
|
330
|
+
'.conf.mjs',
|
|
331
|
+
]
|
|
332
|
+
|
|
333
|
+
const packageConfigurationPaths = []
|
|
334
|
+
const defaultConfigurationPaths = []
|
|
335
|
+
|
|
336
|
+
for ( const replaceValue of replaceValues ) {
|
|
337
|
+
const configurationLocation = relativeTaskPath.replace( searchValue, replaceValue )
|
|
338
|
+
const packageConfigurationPath = join( packageTasksConfigurationsDirectory, configurationLocation )
|
|
339
|
+
const defaultConfigurationPath = join( iteePackageConfigurationsDirectory, configurationLocation )
|
|
340
|
+
|
|
341
|
+
packageConfigurationPaths.push( packageConfigurationPath )
|
|
342
|
+
defaultConfigurationPaths.push( defaultConfigurationPath )
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
// Take care of the configuration search order (package first then default !)
|
|
346
|
+
const configurationPaths = [ ...packageConfigurationPaths, ...defaultConfigurationPaths ]
|
|
347
|
+
let configurationPath = undefined
|
|
348
|
+
|
|
349
|
+
// Looking for existing configuration file
|
|
350
|
+
for ( const packageConfigurationPath of configurationPaths ) {
|
|
351
|
+
|
|
352
|
+
if ( existsSync( packageConfigurationPath ) ) {
|
|
353
|
+
configurationPath = packageConfigurationPath
|
|
354
|
+
break
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
// Else throw an error
|
|
360
|
+
if ( !configurationPath ) {
|
|
361
|
+
throw new Error( `Unable to find configuration in package configuration paths ${ configurationPaths.join( ', ' ) }.` )
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
return configurationPath
|
|
365
|
+
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
async function getTaskConfigurationFor( filename ) {
|
|
369
|
+
|
|
370
|
+
const configurationFilePath = getTaskConfigurationPathFor( filename )
|
|
371
|
+
|
|
372
|
+
log( `Loading configuration from ${ cyan( configurationFilePath ) }` )
|
|
373
|
+
|
|
374
|
+
let configuration = null
|
|
375
|
+
|
|
376
|
+
try {
|
|
377
|
+
|
|
378
|
+
if ( extname( configurationFilePath ) === '.json' ) {
|
|
379
|
+
|
|
380
|
+
configuration = getJsonFrom( configurationFilePath )
|
|
381
|
+
|
|
382
|
+
} else {
|
|
383
|
+
|
|
384
|
+
const moduleData = await import( configurationFilePath )
|
|
385
|
+
configuration = moduleData.default
|
|
386
|
+
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
} catch ( e ) {
|
|
390
|
+
|
|
391
|
+
log( red( e ) )
|
|
392
|
+
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
return configuration
|
|
396
|
+
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
/// Build management
|
|
400
|
+
|
|
401
|
+
function getPrettyFormatForBanner( format ) {
|
|
402
|
+
|
|
403
|
+
let prettyFormat = ''
|
|
404
|
+
|
|
405
|
+
switch ( format ) {
|
|
406
|
+
|
|
407
|
+
case 'cjs':
|
|
408
|
+
prettyFormat = 'CommonJs'
|
|
409
|
+
break
|
|
410
|
+
|
|
411
|
+
case 'esm':
|
|
412
|
+
prettyFormat = 'EsModule'
|
|
413
|
+
break
|
|
414
|
+
|
|
415
|
+
case 'iife':
|
|
416
|
+
prettyFormat = 'Standalone'
|
|
417
|
+
break
|
|
418
|
+
|
|
419
|
+
case 'umd':
|
|
420
|
+
prettyFormat = 'Universal'
|
|
421
|
+
break
|
|
422
|
+
|
|
423
|
+
default:
|
|
424
|
+
throw new RangeError( `Invalid switch parameter: ${ format }` )
|
|
425
|
+
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
return prettyFormat
|
|
429
|
+
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
function convertBannerIntoComment( banner ) {
|
|
433
|
+
|
|
434
|
+
let bannerCommented = '/**\n'
|
|
435
|
+
bannerCommented += ' * '
|
|
436
|
+
bannerCommented += banner.replaceAll( '\n', '\n * ' )
|
|
437
|
+
bannerCommented += '\n'
|
|
438
|
+
bannerCommented += ` * @desc ${ packageDescription }\n`
|
|
439
|
+
bannerCommented += ' * @author [Tristan Valcke]{@link https://github.com/Itee}\n'
|
|
440
|
+
bannerCommented += ' * @license [BSD-3-Clause]{@link https://opensource.org/licenses/BSD-3-Clause}\n'
|
|
441
|
+
bannerCommented += ' * \n'
|
|
442
|
+
bannerCommented += ' */'
|
|
443
|
+
|
|
444
|
+
return bannerCommented
|
|
445
|
+
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
function computeBannerFor( format ) {
|
|
449
|
+
|
|
450
|
+
const packageName = getPrettyPackageName( '.' )
|
|
451
|
+
const packageVersion = getPrettyPackageVersion()
|
|
452
|
+
const prettyFormat = getPrettyFormatForBanner( format )
|
|
453
|
+
|
|
454
|
+
const figText = figlet.textSync(
|
|
455
|
+
`${ packageName } ${ packageVersion } - ${ prettyFormat }`,
|
|
456
|
+
{
|
|
457
|
+
font: 'Tmplr',
|
|
458
|
+
horizontalLayout: 'default',
|
|
459
|
+
verticalLayout: 'default',
|
|
460
|
+
whitespaceBreak: true,
|
|
461
|
+
}
|
|
462
|
+
)
|
|
463
|
+
|
|
464
|
+
return convertBannerIntoComment( figText )
|
|
465
|
+
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
function computeIntroFor( requestPackages ) {
|
|
469
|
+
|
|
470
|
+
return ''
|
|
471
|
+
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
function getOutputFileExtensionBasedOnFileFormat( format ) {
|
|
475
|
+
|
|
476
|
+
let extension
|
|
477
|
+
|
|
478
|
+
if ( format === 'cjs' ) {
|
|
479
|
+
extension = 'cjs'
|
|
480
|
+
} else if ( format === 'esm' ) {
|
|
481
|
+
extension = 'mjs'
|
|
482
|
+
} else {
|
|
483
|
+
extension = 'js'
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
return extension
|
|
487
|
+
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
/**
|
|
491
|
+
* Will create an appropriate configuration object for rollup, related to the given arguments.
|
|
492
|
+
*
|
|
493
|
+
* @generator
|
|
494
|
+
* @param options
|
|
495
|
+
* @return {Array.<json>} An array of rollup configuration
|
|
496
|
+
*/
|
|
497
|
+
function createRollupConfigs( options = undefined ) {
|
|
498
|
+
|
|
499
|
+
const _options = options ? options : {
|
|
500
|
+
input: join( packageSourcesDirectory, `${ packageName }.js` ),
|
|
501
|
+
output: packageBuildsDirectory,
|
|
502
|
+
formats: [ 'esm', 'cjs', 'iife' ],
|
|
503
|
+
envs: [ 'dev', 'prod' ],
|
|
504
|
+
treeshake: true
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
const {
|
|
508
|
+
input,
|
|
509
|
+
output,
|
|
510
|
+
formats,
|
|
511
|
+
envs,
|
|
512
|
+
treeshake
|
|
513
|
+
} = _options
|
|
514
|
+
const name = getPrettyPackageName( '.' )
|
|
515
|
+
const fileName = basename( input, '.js' )
|
|
516
|
+
|
|
517
|
+
const configs = []
|
|
518
|
+
|
|
519
|
+
for ( let formatIndex = 0, numberOfFormats = formats.length ; formatIndex < numberOfFormats ; ++formatIndex ) {
|
|
520
|
+
|
|
521
|
+
for ( let envIndex = 0, numberOfEnvs = envs.length ; envIndex < numberOfEnvs ; envIndex++ ) {
|
|
522
|
+
|
|
523
|
+
const env = envs[ envIndex ]
|
|
524
|
+
const isProd = ( env.includes( 'prod' ) )
|
|
525
|
+
const format = formats[ formatIndex ]
|
|
526
|
+
const extension = getOutputFileExtensionBasedOnFileFormat( format )
|
|
527
|
+
const outputPath = ( isProd ) ? join( output, `${ fileName }.min.${ extension }` ) : join( output, `${ fileName }.${ extension }` )
|
|
528
|
+
|
|
529
|
+
configs.push( {
|
|
530
|
+
input: input,
|
|
531
|
+
external: ( format === 'cjs' ) ? [
|
|
532
|
+
'fs'
|
|
533
|
+
] : [],
|
|
534
|
+
plugins: [
|
|
535
|
+
replace( {
|
|
536
|
+
defines: {
|
|
537
|
+
IS_REMOVE_ON_BUILD: false,
|
|
538
|
+
IS_BACKEND_SPECIFIC: ( format === 'cjs' )
|
|
539
|
+
}
|
|
540
|
+
} ),
|
|
541
|
+
commonjs( {
|
|
542
|
+
include: 'node_modules/**'
|
|
543
|
+
} ),
|
|
544
|
+
nodeResolve( {
|
|
545
|
+
preferBuiltins: true
|
|
546
|
+
} ),
|
|
547
|
+
isProd && terser()
|
|
548
|
+
],
|
|
549
|
+
onwarn: ( {
|
|
550
|
+
loc,
|
|
551
|
+
frame,
|
|
552
|
+
message
|
|
553
|
+
} ) => {
|
|
554
|
+
|
|
555
|
+
// Ignore some errors
|
|
556
|
+
if ( message.includes( 'Circular dependency' ) ) { return }
|
|
557
|
+
if ( message.includes( 'plugin uglify is deprecated' ) ) { return }
|
|
558
|
+
|
|
559
|
+
if ( loc ) {
|
|
560
|
+
process.stderr.write( `/!\\ ${ loc.file } (${ loc.line }:${ loc.column }) ${ frame } ${ message }\n` )
|
|
561
|
+
} else {
|
|
562
|
+
process.stderr.write( `/!\\ ${ message }\n` )
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
},
|
|
566
|
+
treeshake: treeshake,
|
|
567
|
+
output: {
|
|
568
|
+
// core options
|
|
569
|
+
file: outputPath,
|
|
570
|
+
format: format,
|
|
571
|
+
name: name,
|
|
572
|
+
globals: {},
|
|
573
|
+
|
|
574
|
+
// advanced options
|
|
575
|
+
paths: {},
|
|
576
|
+
banner: ( isProd ) ? '' : computeBannerFor( format ),
|
|
577
|
+
footer: '',
|
|
578
|
+
intro: ( !isProd && format === 'iife' ) ? computeIntroFor() : '',
|
|
579
|
+
outro: '',
|
|
580
|
+
sourcemap: !isProd,
|
|
581
|
+
interop: 'auto',
|
|
582
|
+
|
|
583
|
+
// danger zone
|
|
584
|
+
exports: 'auto',
|
|
585
|
+
amd: {},
|
|
586
|
+
indent: '\t',
|
|
587
|
+
strict: true
|
|
588
|
+
}
|
|
589
|
+
} )
|
|
590
|
+
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
return configs
|
|
596
|
+
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
/// Log Management
|
|
600
|
+
|
|
601
|
+
function logLoadingTask( filename ) {
|
|
602
|
+
|
|
603
|
+
if ( !isDebugging ) {
|
|
604
|
+
return
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
const taskPath = relative( packageRootDirectory, filename )
|
|
608
|
+
const taskName = basename( filename, '.task.mjs' )
|
|
609
|
+
|
|
610
|
+
log( `Loading ${ green( taskPath ) } with task ${ blue( taskName ) }` )
|
|
611
|
+
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
///
|
|
615
|
+
|
|
616
|
+
function IndenterFactory( indentationChar = '\t', indentationLevel = 5 ) {
|
|
617
|
+
|
|
618
|
+
const indentationLevels = {}
|
|
619
|
+
let currentProperty = 'I_'
|
|
620
|
+
for ( let currentIndentationLevel = 1 ; currentIndentationLevel <= indentationLevel ; currentIndentationLevel++ ) {
|
|
621
|
+
indentationLevels[ currentProperty ] = indentationChar.repeat( currentIndentationLevel )
|
|
622
|
+
currentProperty += '_'
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
return {
|
|
626
|
+
I: new Indenter( indentationChar ),
|
|
627
|
+
...indentationLevels
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
class Indenter {
|
|
633
|
+
|
|
634
|
+
constructor( indentationChar = '\t' ) {
|
|
635
|
+
|
|
636
|
+
this.indentationChar = indentationChar
|
|
637
|
+
this.currentIndentationLevel = 0
|
|
638
|
+
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
_( indentationLevel = null ) {
|
|
642
|
+
return this.indentationChar.repeat( indentationLevel ?? this.currentIndentationLevel )
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
deeper( level = 1 ) {
|
|
646
|
+
this.currentIndentationLevel += level
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
shallower( level = 1 ) {
|
|
650
|
+
this.currentIndentationLevel -= level
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
///
|
|
656
|
+
|
|
657
|
+
export {
|
|
658
|
+
iteePackageRootDirectory,
|
|
659
|
+
iteePackageJsonPath,
|
|
660
|
+
iteePackageConfigurationsDirectory,
|
|
661
|
+
iteePackageNodeModulesDirectory,
|
|
662
|
+
iteePackageSourcesDirectory,
|
|
663
|
+
|
|
664
|
+
packageRootDirectory,
|
|
665
|
+
packageTasksDirectory,
|
|
666
|
+
packageTasksConfigurationsDirectory,
|
|
667
|
+
packageNodeModulesDirectory,
|
|
668
|
+
packageBuildsDirectory,
|
|
669
|
+
packageSourcesDirectory,
|
|
670
|
+
packageSourcesBackendDirectory,
|
|
671
|
+
packageSourcesCommonDirectory,
|
|
672
|
+
packageSourcesFrontendDirectory,
|
|
673
|
+
packageTestsDirectory,
|
|
674
|
+
packageTestsBenchmarksDirectory,
|
|
675
|
+
packageTestsBundlesDirectory,
|
|
676
|
+
packageTestsUnitsDirectory,
|
|
677
|
+
packageDocsDirectory,
|
|
678
|
+
packageTutorialsDirectory,
|
|
679
|
+
packageJsonPath,
|
|
680
|
+
|
|
681
|
+
packageJson,
|
|
682
|
+
packageName,
|
|
683
|
+
packageVersion,
|
|
684
|
+
packageDescription,
|
|
685
|
+
packageAuthor,
|
|
686
|
+
packageLicense,
|
|
687
|
+
getPrettyPackageName,
|
|
688
|
+
getPrettyPackageVersion,
|
|
689
|
+
getPrettyNodeVersion,
|
|
690
|
+
getPrettyNpmVersion,
|
|
691
|
+
|
|
692
|
+
|
|
693
|
+
createDirectoryIfNotExist,
|
|
694
|
+
getJsonFrom,
|
|
695
|
+
createFile,
|
|
696
|
+
getFilesFrom,
|
|
697
|
+
|
|
698
|
+
getTasksFrom,
|
|
699
|
+
serializeTasksFrom,
|
|
700
|
+
parallelizeTasksFrom,
|
|
701
|
+
|
|
702
|
+
getTaskConfigurationPathFor,
|
|
703
|
+
getTaskConfigurationFor,
|
|
704
|
+
|
|
705
|
+
getPrettyFormatForBanner,
|
|
706
|
+
convertBannerIntoComment,
|
|
707
|
+
computeBannerFor,
|
|
708
|
+
computeIntroFor,
|
|
709
|
+
createRollupConfigs,
|
|
710
|
+
|
|
711
|
+
logLoadingTask,
|
|
712
|
+
|
|
713
|
+
IndenterFactory as Indenter
|
|
714
|
+
}</pre>
|
|
715
|
+
</article>
|
|
716
|
+
</section>
|
|
717
|
+
|
|
718
|
+
|
|
719
|
+
|
|
720
|
+
|
|
721
|
+
|
|
722
|
+
</div>
|
|
723
|
+
</div>
|
|
724
|
+
|
|
725
|
+
<div class="clearfix"></div>
|
|
726
|
+
|
|
727
|
+
|
|
728
|
+
|
|
729
|
+
</div>
|
|
730
|
+
</div>
|
|
731
|
+
|
|
732
|
+
|
|
733
|
+
<div class="modal fade" id="searchResults">
|
|
734
|
+
<div class="modal-dialog">
|
|
735
|
+
<div class="modal-content">
|
|
736
|
+
<div class="modal-header">
|
|
737
|
+
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
|
|
738
|
+
<h4 class="modal-title">Search results</h4>
|
|
739
|
+
</div>
|
|
740
|
+
<div class="modal-body"></div>
|
|
741
|
+
<div class="modal-footer">
|
|
742
|
+
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
|
|
743
|
+
</div>
|
|
744
|
+
</div><!-- /.modal-content -->
|
|
745
|
+
</div><!-- /.modal-dialog -->
|
|
746
|
+
</div>
|
|
747
|
+
|
|
748
|
+
|
|
749
|
+
<footer>
|
|
750
|
+
|
|
751
|
+
|
|
752
|
+
<span class="copyright">
|
|
753
|
+
Copyright 2015-Present <a href="https://github.com/Itee">Itee</a> (Tristan Valcke)
|
|
754
|
+
</span>
|
|
755
|
+
|
|
756
|
+
<span class="jsdoc-message">
|
|
757
|
+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a>
|
|
758
|
+
|
|
759
|
+
using the <a href="https://github.com/docstrap/docstrap">DocStrap template</a>.
|
|
760
|
+
</span>
|
|
761
|
+
</footer>
|
|
762
|
+
|
|
763
|
+
<script src="scripts/docstrap.lib.js"></script>
|
|
764
|
+
<script src="scripts/toc.js"></script>
|
|
765
|
+
|
|
766
|
+
<script type="text/javascript" src="scripts/fulltext-search-ui.js"></script>
|
|
767
|
+
|
|
768
|
+
|
|
769
|
+
<script>
|
|
770
|
+
$( function () {
|
|
771
|
+
$( "[id*='$']" ).each( function () {
|
|
772
|
+
var $this = $( this );
|
|
773
|
+
|
|
774
|
+
$this.attr( "id", $this.attr( "id" ).replace( "$", "__" ) );
|
|
775
|
+
} );
|
|
776
|
+
|
|
777
|
+
$( ".tutorial-section pre, .readme-section pre, pre.prettyprint.source" ).each( function () {
|
|
778
|
+
var $this = $( this );
|
|
779
|
+
|
|
780
|
+
var example = $this.find( "code" );
|
|
781
|
+
exampleText = example.html();
|
|
782
|
+
var lang = /{@lang (.*?)}/.exec( exampleText );
|
|
783
|
+
if ( lang && lang[1] ) {
|
|
784
|
+
exampleText = exampleText.replace( lang[0], "" );
|
|
785
|
+
example.html( exampleText );
|
|
786
|
+
lang = lang[1];
|
|
787
|
+
} else {
|
|
788
|
+
var langClassMatch = example.parent()[0].className.match(/lang\-(\S+)/);
|
|
789
|
+
lang = langClassMatch ? langClassMatch[1] : "javascript";
|
|
790
|
+
}
|
|
791
|
+
|
|
792
|
+
if ( lang ) {
|
|
793
|
+
|
|
794
|
+
$this
|
|
795
|
+
.addClass( "sunlight-highlight-" + lang )
|
|
796
|
+
.addClass( "linenums" )
|
|
797
|
+
.html( example.html() );
|
|
798
|
+
|
|
799
|
+
}
|
|
800
|
+
} );
|
|
801
|
+
|
|
802
|
+
Sunlight.highlightAll( {
|
|
803
|
+
lineNumbers : true,
|
|
804
|
+
showMenu : true,
|
|
805
|
+
enableDoclinks : true
|
|
806
|
+
} );
|
|
807
|
+
|
|
808
|
+
$.catchAnchorLinks( {
|
|
809
|
+
navbarOffset: 10
|
|
810
|
+
} );
|
|
811
|
+
$( "#toc" ).toc( {
|
|
812
|
+
anchorName : function ( i, heading, prefix ) {
|
|
813
|
+
return $( heading ).attr( "id" ) || ( prefix + i );
|
|
814
|
+
},
|
|
815
|
+
selectors : "#toc-content h1,#toc-content h2,#toc-content h3,#toc-content h4",
|
|
816
|
+
showAndHide : false,
|
|
817
|
+
smoothScrolling: true
|
|
818
|
+
} );
|
|
819
|
+
|
|
820
|
+
$( "#main span[id^='toc']" ).addClass( "toc-shim" );
|
|
821
|
+
$( '.dropdown-toggle' ).dropdown();
|
|
822
|
+
|
|
823
|
+
$( "table" ).each( function () {
|
|
824
|
+
var $this = $( this );
|
|
825
|
+
$this.addClass('table');
|
|
826
|
+
} );
|
|
827
|
+
|
|
828
|
+
} );
|
|
829
|
+
</script>
|
|
830
|
+
|
|
831
|
+
|
|
832
|
+
|
|
833
|
+
<!--Navigation and Symbol Display-->
|
|
834
|
+
|
|
835
|
+
|
|
836
|
+
<!--Google Analytics-->
|
|
837
|
+
|
|
838
|
+
|
|
839
|
+
|
|
840
|
+
<script type="text/javascript">
|
|
841
|
+
$(document).ready(function() {
|
|
842
|
+
SearcherDisplay.init();
|
|
843
|
+
});
|
|
844
|
+
</script>
|
|
845
|
+
|
|
846
|
+
|
|
847
|
+
</body>
|
|
848
|
+
</html>
|