@itee/tasks 1.0.12 → 1.1.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 CHANGED
@@ -1,3 +1,13 @@
1
+ # [v1.1.0](https://github.com/Itee/tasks/compare/v1.0.13...v1.1.0) (2026-01-15)
2
+
3
+ ## ✨ New Features
4
+ - [`f6c941a`](https://github.com/Itee/tasks/commit/f6c941a) (builds) add default config for build task
5
+
6
+ ## 🐛 Bug Fixes
7
+ - [`231bd19`](https://github.com/Itee/tasks/commit/231bd19) (utils) fix strict usage with complex options
8
+
9
+ # [v1.0.13](https://github.com/Itee/tasks/compare/v1.0.12...v1.0.13) (2026-01-15)
10
+
1
11
  # [v1.0.12](https://github.com/Itee/itee-tasks/compare/v1.0.11...v1.0.12) (2026-01-14)
2
12
 
3
13
  # [v1.0.11](https://github.com/Itee/itee-tasks/compare/v1.0.10...v1.0.11) (2026-01-14)
@@ -1 +1,3 @@
1
- export default []
1
+ import { createRollupConfigs } from '../../sources/_utils.mjs'
2
+
3
+ export default createRollupConfigs()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itee/tasks",
3
- "version": "1.0.12",
3
+ "version": "1.1.0",
4
4
  "description": "Allow to manage all commons itee gulp tasks into one place ",
5
5
  "keywords": [
6
6
  "itee",
@@ -49,8 +49,7 @@
49
49
  "tests:units:run:back": "gulp run-unit-tests-for-backend",
50
50
  "tests:units:run:front": "gulp run-unit-tests-for-frontend",
51
51
  "release": "gulp release",
52
- "semantic-release": "semantic-release --dry-run --no-ci",
53
- "postversion": "gulp build"
52
+ "semantic-release": "semantic-release --dry-run --no-ci"
54
53
  },
55
54
  "devDependencies": {
56
55
  "@semantic-release/changelog": "^6.0.3",
@@ -1,6 +1,10 @@
1
+ import commonjs from '@rollup/plugin-commonjs'
2
+ import nodeResolve from '@rollup/plugin-node-resolve'
3
+ import terser from '@rollup/plugin-terser'
1
4
  import colors from 'ansi-colors'
2
5
  import childProcess from 'child_process'
3
6
  import log from 'fancy-log'
7
+ import figlet from 'figlet'
4
8
  import { glob } from 'glob'
5
9
  import {
6
10
  parallel,
@@ -21,6 +25,7 @@ import {
21
25
  relative,
22
26
  } from 'node:path'
23
27
  import { fileURLToPath } from 'node:url'
28
+ import replace from 'rollup-plugin-re'
24
29
 
25
30
  const {
26
31
  red,
@@ -33,122 +38,7 @@ const {
33
38
 
34
39
  ///
35
40
 
36
- function createDirectoryIfNotExist( directoryPath ) {
37
-
38
- if ( !existsSync( directoryPath ) ) {
39
- log( 'Creating', green( directoryPath ) )
40
- mkdirSync( directoryPath, { recursive: true } )
41
- }
42
-
43
- }
44
-
45
- function getJsonFrom( path ) {
46
-
47
- const buffer = readFileSync( path )
48
- return JSON.parse( buffer.toString() )
49
-
50
- }
51
-
52
- function getTaskConfigurationPathFor( filename ) {
53
-
54
- // Get relative path of the task between internal or user defined
55
- let relativeTaskPath = filename.includes( iteePackageSourcesDirectory )
56
- ? relative( iteePackageSourcesDirectory, filename )
57
- : relative( packageTasksDirectory, filename )
58
-
59
- // Generate all possible config file path depending on file extension and default or user defined
60
- const terminalExtension = extname( relativeTaskPath )
61
- const searchValue = relativeTaskPath.includes( '.task.' ) ? `.task${ terminalExtension }` : terminalExtension
62
- const replaceValues = [
63
- '.conf.json',
64
- '.conf.js',
65
- '.conf.mjs',
66
- ]
67
-
68
- const packageConfigurationPaths = []
69
- const defaultConfigurationPaths = []
70
-
71
- for ( const replaceValue of replaceValues ) {
72
- const configurationLocation = relativeTaskPath.replace( searchValue, replaceValue )
73
- const packageConfigurationPath = join( packageTasksConfigurationsDirectory, configurationLocation )
74
- const defaultConfigurationPath = join( iteePackageConfigurationsDirectory, configurationLocation )
75
-
76
- packageConfigurationPaths.push( packageConfigurationPath )
77
- defaultConfigurationPaths.push( defaultConfigurationPath )
78
- }
79
-
80
- // Take care of the configuration search order (package first then default !)
81
- const configurationPaths = [ ...packageConfigurationPaths, ...defaultConfigurationPaths ]
82
- let configurationPath = undefined
83
-
84
- // Looking for existing configuration file
85
- for ( const packageConfigurationPath of configurationPaths ) {
86
-
87
- if ( existsSync( packageConfigurationPath ) ) {
88
- configurationPath = packageConfigurationPath
89
- break
90
- }
91
-
92
- }
93
-
94
- // Else throw an error
95
- if ( !configurationPath ) {
96
- throw new Error( `Unable to find configuration in package configuration paths ${ configurationPaths.join( ', ' ) }.` )
97
- }
98
-
99
- return configurationPath
100
-
101
- }
102
-
103
- async function getTaskConfigurationFor( filename ) {
104
-
105
- const configurationFilePath = getTaskConfigurationPathFor( filename )
106
-
107
- log( `Loading configuration from ${ cyan( configurationFilePath ) }` )
108
-
109
- let configuration = null
110
-
111
- try {
112
-
113
- if ( extname( configurationFilePath ) === '.json' ) {
114
-
115
- configuration = getJsonFrom( configurationFilePath )
116
-
117
- } else {
118
-
119
- const moduleData = await import( configurationFilePath )
120
- configuration = moduleData.default
121
-
122
- }
123
-
124
- } catch ( e ) {
125
-
126
- log( red( e ) )
127
-
128
- }
129
-
130
- return configuration
131
-
132
- }
133
-
134
- function createFile( filePath, fileContent ) {
135
-
136
- log( 'Creating', green( filePath ) )
137
- writeFileSync( filePath, fileContent )
138
-
139
- }
140
-
141
- function getFilesFrom( globPattern, filter = ( any ) => true ) {
142
-
143
- return glob.sync( globPattern )
144
- .map( filePath => normalize( filePath ) )
145
- .filter( filter )
146
-
147
- }
148
-
149
- ///
150
-
151
- function getPackageRootDirectory() {
41
+ function _getPackageRootDirectory() {
152
42
 
153
43
  let __dirname
154
44
 
@@ -167,7 +57,7 @@ function getPackageRootDirectory() {
167
57
 
168
58
  }
169
59
 
170
- const iteePackageRootDirectory = getPackageRootDirectory()
60
+ const iteePackageRootDirectory = _getPackageRootDirectory()
171
61
  const iteePackageJsonPath = join( iteePackageRootDirectory, 'package.json' )
172
62
  const iteePackageConfigurationsDirectory = join( iteePackageRootDirectory, 'configs' )
173
63
  const iteePackageNodeModulesDirectory = join( iteePackageRootDirectory, 'node_modules' )
@@ -196,6 +86,8 @@ const packageJson = getJsonFrom( packageJsonPath )
196
86
  const packageName = packageJson.name
197
87
  const packageVersion = packageJson.version
198
88
  const packageDescription = packageJson.description
89
+ const packageAuthor = packageJson.author
90
+ const packageLicense = packageJson.license
199
91
 
200
92
  function getPrettyPackageName( separator = ' ' ) {
201
93
 
@@ -257,7 +149,40 @@ function getPrettyNpmVersion() {
257
149
 
258
150
  }
259
151
 
260
- ///
152
+ /// File system Management
153
+
154
+ function createDirectoryIfNotExist( directoryPath ) {
155
+
156
+ if ( !existsSync( directoryPath ) ) {
157
+ log( 'Creating', green( directoryPath ) )
158
+ mkdirSync( directoryPath, { recursive: true } )
159
+ }
160
+
161
+ }
162
+
163
+ function getJsonFrom( path ) {
164
+
165
+ const buffer = readFileSync( path )
166
+ return JSON.parse( buffer.toString() )
167
+
168
+ }
169
+
170
+ function createFile( filePath, fileContent ) {
171
+
172
+ log( 'Creating', green( filePath ) )
173
+ writeFileSync( filePath, fileContent )
174
+
175
+ }
176
+
177
+ function getFilesFrom( globPattern, filter = ( any ) => true ) {
178
+
179
+ return glob.sync( globPattern )
180
+ .map( filePath => normalize( filePath ) )
181
+ .filter( filter )
182
+
183
+ }
184
+
185
+ /// Task Management
261
186
 
262
187
  async function getTasksFrom( taskFiles = [] ) {
263
188
 
@@ -310,7 +235,274 @@ async function parallelizeTasksFrom( taskFiles = [] ) {
310
235
 
311
236
  }
312
237
 
313
- ///
238
+ /// Task configuration management
239
+
240
+ function getTaskConfigurationPathFor( filename ) {
241
+
242
+ // Get relative path of the task between internal or user defined
243
+ let relativeTaskPath = filename.includes( iteePackageSourcesDirectory )
244
+ ? relative( iteePackageSourcesDirectory, filename )
245
+ : relative( packageTasksDirectory, filename )
246
+
247
+ // Generate all possible config file path depending on file extension and default or user defined
248
+ const terminalExtension = extname( relativeTaskPath )
249
+ const searchValue = relativeTaskPath.includes( '.task.' ) ? `.task${ terminalExtension }` : terminalExtension
250
+ const replaceValues = [
251
+ '.conf.json',
252
+ '.conf.js',
253
+ '.conf.mjs',
254
+ ]
255
+
256
+ const packageConfigurationPaths = []
257
+ const defaultConfigurationPaths = []
258
+
259
+ for ( const replaceValue of replaceValues ) {
260
+ const configurationLocation = relativeTaskPath.replace( searchValue, replaceValue )
261
+ const packageConfigurationPath = join( packageTasksConfigurationsDirectory, configurationLocation )
262
+ const defaultConfigurationPath = join( iteePackageConfigurationsDirectory, configurationLocation )
263
+
264
+ packageConfigurationPaths.push( packageConfigurationPath )
265
+ defaultConfigurationPaths.push( defaultConfigurationPath )
266
+ }
267
+
268
+ // Take care of the configuration search order (package first then default !)
269
+ const configurationPaths = [ ...packageConfigurationPaths, ...defaultConfigurationPaths ]
270
+ let configurationPath = undefined
271
+
272
+ // Looking for existing configuration file
273
+ for ( const packageConfigurationPath of configurationPaths ) {
274
+
275
+ if ( existsSync( packageConfigurationPath ) ) {
276
+ configurationPath = packageConfigurationPath
277
+ break
278
+ }
279
+
280
+ }
281
+
282
+ // Else throw an error
283
+ if ( !configurationPath ) {
284
+ throw new Error( `Unable to find configuration in package configuration paths ${ configurationPaths.join( ', ' ) }.` )
285
+ }
286
+
287
+ return configurationPath
288
+
289
+ }
290
+
291
+ async function getTaskConfigurationFor( filename ) {
292
+
293
+ const configurationFilePath = getTaskConfigurationPathFor( filename )
294
+
295
+ log( `Loading configuration from ${ cyan( configurationFilePath ) }` )
296
+
297
+ let configuration = null
298
+
299
+ try {
300
+
301
+ if ( extname( configurationFilePath ) === '.json' ) {
302
+
303
+ configuration = getJsonFrom( configurationFilePath )
304
+
305
+ } else {
306
+
307
+ const moduleData = await import( configurationFilePath )
308
+ configuration = moduleData.default
309
+
310
+ }
311
+
312
+ } catch ( e ) {
313
+
314
+ log( red( e ) )
315
+
316
+ }
317
+
318
+ return configuration
319
+
320
+ }
321
+
322
+ /// Build management
323
+
324
+ function getPrettyFormatForBanner( format ) {
325
+
326
+ let prettyFormat = ''
327
+
328
+ switch ( format ) {
329
+
330
+ case 'cjs':
331
+ prettyFormat = 'CommonJs'
332
+ break
333
+
334
+ case 'esm':
335
+ prettyFormat = 'EsModule'
336
+ break
337
+
338
+ case 'iife':
339
+ prettyFormat = 'Standalone'
340
+ break
341
+
342
+ case 'umd':
343
+ prettyFormat = 'Universal'
344
+ break
345
+
346
+ default:
347
+ throw new RangeError( `Invalid switch parameter: ${ format }` )
348
+
349
+ }
350
+
351
+ return prettyFormat
352
+
353
+ }
354
+
355
+ function convertBannerIntoComment( banner ) {
356
+
357
+ let bannerCommented = '/**\n'
358
+ bannerCommented += ' * '
359
+ bannerCommented += banner.replaceAll( '\n', '\n * ' )
360
+ bannerCommented += '\n'
361
+ bannerCommented += ` * @desc ${ packageDescription }\n`
362
+ bannerCommented += ' * @author [Tristan Valcke]{@link https://github.com/Itee}\n'
363
+ bannerCommented += ' * @license [BSD-3-Clause]{@link https://opensource.org/licenses/BSD-3-Clause}\n'
364
+ bannerCommented += ' * \n'
365
+ bannerCommented += ' */'
366
+
367
+ return bannerCommented
368
+
369
+ }
370
+
371
+ function computeBannerFor( format ) {
372
+
373
+ const packageName = getPrettyPackageName( '.' )
374
+ const packageVersion = getPrettyPackageVersion()
375
+ const prettyFormat = getPrettyFormatForBanner( format )
376
+
377
+ const figText = figlet.textSync(
378
+ `${ packageName } ${ packageVersion } - ${ prettyFormat }`,
379
+ {
380
+ font: 'Tmplr',
381
+ horizontalLayout: 'default',
382
+ verticalLayout: 'default',
383
+ whitespaceBreak: true,
384
+ }
385
+ )
386
+
387
+ return convertBannerIntoComment( figText )
388
+
389
+ }
390
+
391
+ function computeIntroFor( requestPackages ) {
392
+
393
+ return ''
394
+
395
+ }
396
+
397
+ /**
398
+ * Will create an appropriate configuration object for rollup, related to the given arguments.
399
+ *
400
+ * @generator
401
+ * @param options
402
+ * @return {Array.<json>} An array of rollup configuration
403
+ */
404
+ function createRollupConfigs( options = undefined ) {
405
+
406
+ const _options = options ? options : {
407
+ input: join( packageSourcesDirectory, `${ packageName }.js` ),
408
+ output: packageBuildsDirectory,
409
+ formats: [ 'esm', 'cjs', 'iife' ],
410
+ envs: [ 'dev', 'prod' ],
411
+ treeshake: true
412
+ }
413
+
414
+ const {
415
+ input,
416
+ output,
417
+ formats,
418
+ envs,
419
+ treeshake
420
+ } = _options
421
+ const name = getPrettyPackageName( '.' )
422
+ const fileName = basename( input, '.js' )
423
+
424
+ const configs = []
425
+
426
+ for ( let formatIndex = 0, numberOfFormats = formats.length ; formatIndex < numberOfFormats ; ++formatIndex ) {
427
+
428
+ for ( let envIndex = 0, numberOfEnvs = envs.length ; envIndex < numberOfEnvs ; envIndex++ ) {
429
+
430
+ const env = envs[ envIndex ]
431
+ const isProd = ( env.includes( 'prod' ) )
432
+ const format = formats[ formatIndex ]
433
+ const outputPath = ( isProd ) ? join( output, `${ fileName }.${ format }.min.js` ) : join( output, `${ fileName }.${ format }.js` )
434
+
435
+ configs.push( {
436
+ input: input,
437
+ external: ( format === 'cjs' ) ? [
438
+ 'fs'
439
+ ] : [],
440
+ plugins: [
441
+ replace( {
442
+ defines: {
443
+ IS_REMOVE_ON_BUILD: false,
444
+ IS_BACKEND_SPECIFIC: ( format === 'cjs' )
445
+ }
446
+ } ),
447
+ commonjs( {
448
+ include: 'node_modules/**'
449
+ } ),
450
+ nodeResolve( {
451
+ preferBuiltins: true
452
+ } ),
453
+ isProd && terser()
454
+ ],
455
+ onwarn: ( {
456
+ loc,
457
+ frame,
458
+ message
459
+ } ) => {
460
+
461
+ // Ignore some errors
462
+ if ( message.includes( 'Circular dependency' ) ) { return }
463
+ if ( message.includes( 'plugin uglify is deprecated' ) ) { return }
464
+
465
+ if ( loc ) {
466
+ process.stderr.write( `/!\\ ${ loc.file } (${ loc.line }:${ loc.column }) ${ frame } ${ message }\n` )
467
+ } else {
468
+ process.stderr.write( `/!\\ ${ message }\n` )
469
+ }
470
+
471
+ },
472
+ treeshake: treeshake,
473
+ output: {
474
+ // core options
475
+ file: outputPath,
476
+ format: format,
477
+ name: name,
478
+ globals: {},
479
+
480
+ // advanced options
481
+ paths: {},
482
+ banner: ( isProd ) ? '' : computeBannerFor( format ),
483
+ footer: '',
484
+ intro: ( !isProd && format === 'iife' ) ? computeIntroFor() : '',
485
+ outro: '',
486
+ sourcemap: !isProd,
487
+ interop: 'auto',
488
+
489
+ // danger zone
490
+ exports: 'auto',
491
+ amd: {},
492
+ indent: '\t',
493
+ strict: true
494
+ }
495
+ } )
496
+
497
+ }
498
+
499
+ }
500
+
501
+ return configs
502
+
503
+ }
504
+
505
+ /// Log Management
314
506
 
315
507
  function logLoadingTask( filename ) {
316
508
 
@@ -365,13 +557,6 @@ class Indenter {
365
557
  ///
366
558
 
367
559
  export {
368
- createDirectoryIfNotExist,
369
- getJsonFrom,
370
- getTaskConfigurationPathFor,
371
- getTaskConfigurationFor,
372
- createFile,
373
- getFilesFrom,
374
-
375
560
  iteePackageRootDirectory,
376
561
  iteePackageJsonPath,
377
562
  iteePackageConfigurationsDirectory,
@@ -394,18 +579,37 @@ export {
394
579
  packageDocsDirectory,
395
580
  packageTutorialsDirectory,
396
581
  packageJsonPath,
582
+
397
583
  packageJson,
398
584
  packageName,
399
585
  packageVersion,
400
586
  packageDescription,
587
+ packageAuthor,
588
+ packageLicense,
401
589
  getPrettyPackageName,
402
590
  getPrettyPackageVersion,
403
591
  getPrettyNodeVersion,
404
592
  getPrettyNpmVersion,
405
593
 
594
+
595
+ createDirectoryIfNotExist,
596
+ getJsonFrom,
597
+ createFile,
598
+ getFilesFrom,
599
+
406
600
  getTasksFrom,
407
601
  serializeTasksFrom,
408
602
  parallelizeTasksFrom,
603
+
604
+ getTaskConfigurationPathFor,
605
+ getTaskConfigurationFor,
606
+
607
+ getPrettyFormatForBanner,
608
+ convertBannerIntoComment,
609
+ computeBannerFor,
610
+ computeIntroFor,
611
+ createRollupConfigs,
612
+
409
613
  logLoadingTask,
410
614
 
411
615
  IndenterFactory as Indenter
@@ -1,11 +1,11 @@
1
- import colors from 'ansi-colors'
2
- import log from 'fancy-log'
1
+ import colors from 'ansi-colors'
2
+ import log from 'fancy-log'
3
3
  import { basename } from 'node:path'
4
- import { rollup } from 'rollup'
4
+ import { rollup } from 'rollup'
5
5
  import {
6
6
  getTaskConfigurationFor,
7
7
  logLoadingTask
8
- } from '../_utils.mjs'
8
+ } from '../_utils.mjs'
9
9
 
10
10
  logLoadingTask( import.meta.filename )
11
11
 
@@ -1,6 +0,0 @@
1
- <component name="InspectionProjectProfileManager">
2
- <profile version="1.0">
3
- <option name="myName" value="Project Default" />
4
- <inspection_tool class="Eslint" enabled="true" level="WARNING" enabled_by_default="true" />
5
- </profile>
6
- </component>
package/.idea/modules.xml DELETED
@@ -1,8 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="ProjectModuleManager">
4
- <modules>
5
- <module fileurl="file://$PROJECT_DIR$/.idea/tasks.iml" filepath="$PROJECT_DIR$/.idea/tasks.iml" />
6
- </modules>
7
- </component>
8
- </project>
package/.idea/tasks.iml DELETED
@@ -1,8 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <module type="WEB_MODULE" version="4">
3
- <component name="NewModuleRootManager">
4
- <content url="file://$MODULE_DIR$" />
5
- <orderEntry type="inheritedJdk" />
6
- <orderEntry type="sourceFolder" forTests="false" />
7
- </component>
8
- </module>
package/.idea/vcs.xml DELETED
@@ -1,6 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="VcsDirectoryMappings">
4
- <mapping directory="" vcs="Git" />
5
- </component>
6
- </project>