Skip to content

Commit 512556c

Browse files
committed
✨ (tasks) upgrade tasks to latest itee and gulp standards
1 parent b586af7 commit 512556c

31 files changed

+1064
-407
lines changed

.tasks/.builds/build.task.mjs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const {
99
yellow
1010
} = colors
1111

12-
async function buildTask( done ) {
12+
const buildTask = async ( done ) => {
1313

1414
const configs = getRollupConfigurationFor( 'build' )
1515

@@ -39,5 +39,8 @@ async function buildTask( done ) {
3939
done()
4040

4141
}
42+
buildTask.displayName = 'build'
43+
buildTask.description = 'Todo...'
44+
buildTask.flags = null
4245

43-
export { buildTask }
46+
export { buildTask }

.tasks/.cleans/clean.task.mjs

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,23 @@
1-
import colors from 'ansi-colors'
2-
import { deleteAsync } from 'del'
3-
import log from 'fancy-log'
4-
import { cleanConf as filesToClean } from '../configs/clean.conf.mjs'
1+
import colors from 'ansi-colors'
2+
import { deleteAsync } from 'del'
3+
import log from 'fancy-log'
4+
import { cleanConf } from '../configs/clean.conf.mjs'
55

66
const red = colors.red
77

8-
async function cleanTask( done ) {
9-
10-
try {
11-
await deleteAsync( filesToClean, {
12-
onProgress: progress => {
13-
const path = progress.path || 'Nothing to clean...'
14-
log( `Delete [${ progress.deletedCount }/${ progress.totalCount }] (${ Math.round( progress.percent * 100 ) }%):`, red( path ) )
15-
}
16-
} )
17-
done()
18-
} catch ( error ) {
19-
done( red( error.message ) )
8+
/**
9+
* @method npm run clean
10+
* @global
11+
* @description Will delete builds and temporary folders
12+
*/
13+
const cleanTask = () => deleteAsync( cleanConf, {
14+
onProgress: progress => {
15+
const path = progress.path || 'Nothing to clean...'
16+
log( `Delete [${ progress.deletedCount }/${ progress.totalCount }] (${ Math.round( progress.percent * 100 ) }%):`, red( path ) )
2017
}
18+
} )
19+
cleanTask.displayName = 'clean'
20+
cleanTask.description = 'Will delete builds and temporary folders'
21+
cleanTask.flags = null
2122

22-
23-
}
24-
25-
export { cleanTask }
23+
export { cleanTask }

.tasks/.docs/doc.task.mjs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,12 @@ import { promisify } from 'node:util'
66
const execFile = promisify( child_process.execFile )
77
const red = colors.red
88

9-
async function docTask( done ) {
9+
/**
10+
* @method npm run doc
11+
* @global
12+
* @description Will generate this documentation
13+
*/
14+
const docTask = async ( done ) => {
1015

1116
try {
1217
const { stdout } = await execFile(
@@ -23,5 +28,8 @@ async function docTask( done ) {
2328
}
2429

2530
}
31+
docTask.displayName = 'doc'
32+
docTask.description = 'Will generate this documentation.'
33+
docTask.flags = null
2634

2735
export { docTask }

.tasks/.helps/help.task.mjs

Lines changed: 38 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,12 @@ function alignTextRight( text, width ) {
5757

5858
}
5959

60-
function helpTask( done ) {
60+
/**
61+
* @method npm run help ( default )
62+
* @global
63+
* @description Will display the help in console
64+
*/
65+
const helpTask = ( done ) => {
6166

6267
const bannerWidth = 70
6368
const prettyPackageName = getPrettyPackageName()
@@ -85,7 +90,13 @@ function helpTask( done ) {
8590
const tableBottom = `${ tableCharset.bottomLeftCorner }${ mainBorder }${ tableCharset.bottomRightCorner }`
8691
const tableLine = ( innerText ) => `${ tableCharset.verticalBorder }${ innerText }${ tableCharset.verticalBorder }`
8792

88-
const I = new Indenter( ' ', 5 )
93+
const {
94+
I_,
95+
I__,
96+
I___,
97+
I____,
98+
} = new Indenter( '\t', 4 )
99+
89100
const npmRun = blue( 'npm run' )
90101

91102
log( '' )
@@ -97,41 +108,44 @@ function helpTask( done ) {
97108
log( tableLine( alignTextLeft( prettyNodeVersion, bannerWidth ) ) )
98109
log( tableLine( alignTextLeft( prettyNpmVersion, bannerWidth ) ) )
99110
log( tableBottom )
100-
log( I._, 'Available commands are:' )
101-
log( I.__, npmRun, cyan( 'help' ), '- Display this help.' )
102-
log( I.__, npmRun, cyan( 'patch' ), '- Will apply some patch/replacements in dependencies.', red( '(Apply only once after run "npm install")' ) )
103-
log( I.__, npmRun, cyan( 'clean' ), '- Will delete builds and temporary folders.' )
104-
log( I.__, npmRun, cyan( 'lint' ), '- Will run the eslint in pedantic mode with auto fix when possible.' )
105-
log( I.__, npmRun, cyan( 'doc' ), '- Will run jsdoc, and create documentation under `documentation` folder, using the docdash theme' )
106-
log( I.__, npmRun, cyan( 'test' ), '- Will run the test framworks (unit and bench), and create reports under `documentation/report` folder, using the mochawesome theme' )
107-
log( I.__, npmRun, cyan( 'unit' ), '- Will run the karma server for unit tests.' )
108-
log( I.__, npmRun, cyan( 'bench' ), '- Will run the karma server for benchmarks.' )
109-
log( I.__, npmRun, cyan( 'build' ), yellow( '--' ), green( '<options>' ), '- Will build the application for development and/or production environments.' )
110-
log( I.___, yellow( 'Note: The two dash are only required if you provide options !' ) )
111-
log( I.___, 'The available', green( '<options>' ), 'are:' )
112-
log( I.____, green( '-i' ), 'or', green( '--input' ), '- The main file path to build', cyan( '[Default: "sources/main.js"]' ), '.' )
113-
log( I.____, green( '-o' ), 'or', green( '--output' ), '- The folder where output the build', cyan( '[Default: "builds"]' ), '.' )
111+
log( I_, 'Available commands are:' )
112+
log( I__, npmRun, cyan( 'help' ), '- Display this help.' )
113+
log( I__, npmRun, cyan( 'patch' ), '- Will apply some patch/replacements in dependencies.', red( '(Apply only once after run "npm install")' ) )
114+
log( I__, npmRun, cyan( 'clean' ), '- Will delete builds and temporary folders.' )
115+
log( I__, npmRun, cyan( 'lint' ), '- Will run the eslint in pedantic mode with auto fix when possible.' )
116+
log( I__, npmRun, cyan( 'doc' ), '- Will run jsdoc, and create documentation under `documentation` folder, using the docdash theme' )
117+
log( I__, npmRun, cyan( 'test' ), '- Will run the test framworks (unit and bench), and create reports under `documentation/report` folder, using the mochawesome theme' )
118+
log( I__, npmRun, cyan( 'unit' ), '- Will run the karma server for unit tests.' )
119+
log( I__, npmRun, cyan( 'bench' ), '- Will run the karma server for benchmarks.' )
120+
log( I__, npmRun, cyan( 'build' ), yellow( '--' ), green( '<options>' ), '- Will build the application for development and/or production environments.' )
121+
log( I___, yellow( 'Note: The two dash are only required if you provide options !' ) )
122+
log( I___, 'The available', green( '<options>' ), 'are:' )
123+
log( I____, green( '-i' ), 'or', green( '--input' ), '- The main file path to build', cyan( '[Default: "sources/main.js"]' ), '.' )
124+
log( I____, green( '-o' ), 'or', green( '--output' ), '- The folder where output the build', cyan( '[Default: "builds"]' ), '.' )
114125
log(
115-
I.____,
126+
I____,
116127
green( '-f:' ),
117128
magenta( '<format>' ),
118129
'or',
119130
green( '--format:' ),
120131
magenta( '<format>' ),
121132
' - to specify the output build type. Where format could be any of:', magenta( 'cjs, esm, iife, umd' ), '.'
122133
)
123-
log( I.____, green( '-e:' ), magenta( '<env>' ), 'or', green( '--env:' ), magenta( '<env>' ), ' - to specify the build environment. Where env could be any of:', magenta(
134+
log( I____, green( '-e:' ), magenta( '<env>' ), 'or', green( '--env:' ), magenta( '<env>' ), ' - to specify the build environment. Where env could be any of:', magenta(
124135
'dev' ), magenta( 'prod' ), cyan( '[Default: "dev"]' ), '.' )
125-
log( I.____, green( '-s' ), 'or', green( '--sourcemap' ), ' - to build with related source map', cyan( '[Default: true]' ), '.' )
126-
log( I.____, green( '-t' ), 'or', green( '--treeshake' ), ' - allow to perform treeshaking when building', cyan( '[Default: true]' ), '.' )
127-
log( I.__, npmRun, cyan( 'release' ), '- Will run all the lint, test stuff, and if succeed will build the application.' )
136+
log( I____, green( '-s' ), 'or', green( '--sourcemap' ), ' - to build with related source map', cyan( '[Default: true]' ), '.' )
137+
log( I____, green( '-t' ), 'or', green( '--treeshake' ), ' - allow to perform treeshaking when building', cyan( '[Default: true]' ), '.' )
138+
log( I__, npmRun, cyan( 'release' ), '- Will run all the lint, test stuff, and if succeed will build the application.' )
128139
log( '' )
129-
log( I._, 'In case you have', blue( 'gulp' ), 'installed globally, you could use also:' )
130-
log( I.__, blue( 'gulp' ), cyan( 'command' ), '- It will perform the command like using "npm run" but with less characters to type... Because you\'re a developer, right ?' )
140+
log( I_, 'In case you have', blue( 'gulp' ), 'installed globally, you could use also:' )
141+
log( I__, blue( 'gulp' ), cyan( 'command' ), '- It will perform the command like using "npm run" but with less characters to type... Because you\'re a developer, right ?' )
131142
log( '' )
132143

133144
done()
134145

135146
}
147+
helpTask.displayName = 'help'
148+
helpTask.description = 'Display the package help'
149+
helpTask.flags = null
136150

137-
export { helpTask }
151+
export { helpTask }

.tasks/.lints/lint.task.mjs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,12 @@ import { promisify } from 'node:util'
66
const execFile = promisify( child_process.execFile )
77
const red = colors.red
88

9-
async function lintTask( done ) {
9+
/**
10+
* @method npm run lint
11+
* @global
12+
* @description Will lint the sources files and try to fix the style when possible
13+
*/
14+
const lintTask = async ( done ) => {
1015

1116
try {
1217

@@ -25,5 +30,8 @@ async function lintTask( done ) {
2530
}
2631

2732
}
33+
lintTask.displayName = 'lint'
34+
lintTask.description = 'Will lint the sources files and try to fix the style when possible.'
35+
lintTask.flags = null
2836

2937
export { lintTask }

.tasks/.patches/patch.task.mjs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
1-
function patchTask( done ) {
2-
1+
/**
2+
* @method npm run patch
3+
* @global
4+
* @description Will apply some patch/replacements in dependencies
5+
*/
6+
const patchTask = ( done ) => {
37
done()
4-
58
}
9+
patchTask.displayName = 'patch'
10+
patchTask.description = 'Will apply some patch/replacements in dependencies'
11+
patchTask.flags = null
612

713
export { patchTask }

.tasks/.releases/release.task.mjs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { series } from 'gulp'
2+
import { buildTask } from '../.builds/build.task.mjs'
3+
import { cleanTask } from '../.cleans/clean.task.mjs'
4+
import { docTask } from '../.docs/doc.task.mjs'
5+
import { lintTask } from '../.lints/lint.task.mjs'
6+
import { buildTestsTask } from '../.tests/build-tests.task.mjs'
7+
import { runTestsTask } from '../.tests/run-tests.task.mjs'
8+
9+
const releaseTask = series(
10+
cleanTask,
11+
buildTask,
12+
buildTestsTask,
13+
lintTask,
14+
runTestsTask,
15+
docTask,
16+
)
17+
releaseTask.displayName = 'release'
18+
releaseTask.description = 'Will perform a complete release of the library including \'clean\', \'lint\', \'doc\', \'build-tests\', \'test\' and finally \'build\'.'
19+
releaseTask.flags = null
20+
21+
/**
22+
* @method npm run release
23+
* @global
24+
* @description Will perform a complete release of the library including 'clean', 'lint', 'doc', 'build-tests', 'test' and finally 'build'.
25+
*/
26+
export { releaseTask }
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import colors from 'ansi-colors'
2+
import log from 'fancy-log'
3+
import { rollup } from 'rollup'
4+
import { buildBenchmarksBackendConfig as config } from '../../configs/build-benchmarks-backend.conf.mjs'
5+
6+
const {
7+
red,
8+
green
9+
} = colors
10+
11+
/**
12+
* @description Will generate benchmarks bundles based on provided configs
13+
*/
14+
const buildBenchmarksBackendTask = async ( done ) => {
15+
16+
if ( config === undefined || config === null || config.length === 0 ) {
17+
done( red( 'Empty configuration!' ) )
18+
return
19+
}
20+
21+
log( 'Building', green( config.output.file ) )
22+
23+
try {
24+
25+
const bundle = await rollup( config )
26+
await bundle.write( config.output )
27+
28+
} catch ( error ) {
29+
30+
done( red( error.message ) )
31+
return
32+
33+
}
34+
35+
done()
36+
37+
}
38+
buildBenchmarksBackendTask.displayName = 'build-benchmarks-backend'
39+
buildBenchmarksBackendTask.description = 'Will apply some patch/replacements in dependencies'
40+
buildBenchmarksBackendTask.flags = null
41+
42+
export { buildBenchmarksBackendTask }
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { series } from 'gulp'
2+
import { buildBenchmarksBackendTask } from './build-benchmarks-backend.task.mjs'
3+
import { computeBenchmarksTask } from './compute-benchmarks.task.mjs'
4+
5+
/**
6+
* @description Will compute and generate bundle for benchmarks
7+
*/
8+
const buildBenchmarksTask = series(
9+
computeBenchmarksTask,
10+
buildBenchmarksBackendTask,
11+
)
12+
buildBenchmarksTask.displayName = 'build-benchmarks'
13+
buildBenchmarksTask.description = 'Will compute and generate bundle for benchmarks.'
14+
buildBenchmarksTask.flags = null
15+
16+
export { buildBenchmarksTask }

.tasks/.tests/benchmarks/bundle-benchmarks.task.mjs

Lines changed: 0 additions & 46 deletions
This file was deleted.

0 commit comments

Comments
 (0)