-
Notifications
You must be signed in to change notification settings - Fork 173
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace Lerna with custom scripts (#3527)
- Loading branch information
Showing
32 changed files
with
4,884 additions
and
14,232 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,14 +52,11 @@ jobs: | |
~/cypress-binary-cache | ||
key: ${{ inputs.buildcache_key }} | ||
- run: ls test | ||
- run: npm i -g [email protected] | ||
- run: lerna bootstrap --ci --force-local --ignore docs | ||
- run: lerna run bundle --ignore docs --scope luigi-client-private | ||
- run: lerna run bundle --ignore docs --scope @luigi-project/testing-utilities | ||
- run: lerna run bundle --ignore docs --scope @luigi-project/client-support-angular | ||
- run: lerna run bundle --ignore docs | ||
- run: lerna run bundlesizeOnly --ignore docs | ||
- run: lerna run build --ignore docs | ||
# Bundle all | ||
- run: npm run bootstrap | ||
- run: npm run bundle | ||
# Check bundlesize not exceeded | ||
- run: npm run bundlesize | ||
- run: pwd | ||
- run: sudo cp -r . ~/tmp_build | ||
- run: ls -l ~/tmp_build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,7 +50,6 @@ jobs: | |
key: buildcache | ||
- run: cp -r ~/tmp_build/* . | ||
- run: npm i -g cypress | ||
- run: npm i -g [email protected] | ||
- run: npm i -g live-server | ||
- run: bash ./test/mockengine.sh || exit 1 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/** | ||
* This file is used to run (npm install) in all of the folders which have it as a prerequisite in the pipeline and during local development | ||
*/ | ||
|
||
const { exec } = require('child_process'); | ||
|
||
// Array of folder names | ||
const folders = [ | ||
'./', | ||
'core', | ||
'client', | ||
'client-frameworks-support/client-support-angular', | ||
'client-frameworks-support/testing-utilities', | ||
'container', | ||
'plugins', | ||
'scripts', | ||
'test/e2e-test-application', | ||
'test/e2e-js-test-application', | ||
'client-frameworks-support/testing-utilities/test' | ||
]; | ||
// Check for verbose flag | ||
const verboseFlagIndex = process.argv.indexOf('--verbose'); | ||
let isVerbose = verboseFlagIndex !== -1; | ||
|
||
// Function to install npm packages in given folder | ||
function installPackages(folder, index, totalFolders) { | ||
return new Promise((resolve, reject) => { | ||
const command = `cd ${folder} && npm install`; | ||
|
||
exec(command, (error, stdout, stderr) => { | ||
if (error) { | ||
console.error(`\x1b[31mError installing npm packages in ${folder} \x1b[0m`); | ||
reject(error); | ||
} else { | ||
console.log( | ||
`\x1b[32m[${index + 1}/${totalFolders}] : npm packages installed successfully in \x1b[33m${folder}\x1b[0m` | ||
); | ||
// Print logs if needed | ||
if (isVerbose) { | ||
console.log('VERBOSE:', stdout); | ||
} | ||
resolve(); | ||
} | ||
}); | ||
}); | ||
} | ||
|
||
// Function to install packages in all folders sequentially | ||
async function installAllPackages() { | ||
for (let i = 0; i < folders.length; i++) { | ||
await installPackages(folders[i], i, folders.length); | ||
} | ||
} | ||
|
||
/** | ||
* Function to handle the error case for promises | ||
* @param {*} error error | ||
*/ | ||
function errorHandler(error) { | ||
console.error('Stopping execution of the process due to error:', error); | ||
process.exit(1); | ||
} | ||
|
||
// EXECUTE CODE STARTS HERE | ||
|
||
console.log( | ||
`\x1b[36m\n\nInstalling node_modules packages in these folders in the following order:\x1b[0m ${ | ||
isVerbose ? '\x1b[41m\x1b[37m(VERBOSE)\x1b[0m' : '' | ||
}` | ||
); | ||
for (const folder of folders) { | ||
console.log('- ' + folder); | ||
} | ||
|
||
console.log('Starting ---------->'); | ||
|
||
installAllPackages().then(() => { | ||
console.log('\x1b[32m+++++++++++> Finished installing packages successfuly. <++++++++++++++++\x1b[0m\n'); | ||
}, errorHandler); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/** | ||
* This file is used to check if bundle size threshold is not exceded | ||
*/ | ||
|
||
const fs = require('fs'); | ||
const path = require('path'); | ||
|
||
const filesAndLimits = [ | ||
{ | ||
path: 'client/public/luigi-client.js', | ||
limit: 50 | ||
}, | ||
{ | ||
path: 'core/public/luigi.js', | ||
limit: 650 | ||
}, | ||
{ | ||
path: 'core/public/luigi.css', | ||
limit: 800 | ||
}, | ||
{ | ||
path: 'plugins/auth/public/auth-oauth2/plugin.js', | ||
limit: 75 | ||
} | ||
]; | ||
|
||
async function checkFileSizes() { | ||
for (const { path: filePath, limit } of filesAndLimits) { | ||
const fullPath = path.resolve(__dirname, filePath); | ||
console.log(`\x1b[33m\n\nChecking bundlesize in \x1b[32m${filePath}\x1b[0m`); | ||
|
||
try { | ||
const stats = await fs.promises.stat(fullPath); | ||
const fileSizeInKB = (stats.size / 1024).toFixed(2); | ||
|
||
if (fileSizeInKB > limit) { | ||
console.error( | ||
`\x1b[31m \n ERROR: ${filePath} exceeds the size limit. Actual size: ${fileSizeInKB} KB, Limit: ${limit} KB ! \x1b[0m\n` | ||
); | ||
process.exit(1); | ||
} else { | ||
console.log( | ||
`\x1b[32m\u2713\x1b[0m ${filePath} is within the size limit. Size: \x1b[33m${fileSizeInKB} KB\x1b[0m < \x1b[32m${limit} KB\x1b[0m` | ||
); | ||
} | ||
} catch (error) { | ||
console.error(`Error reading file ${filePath}: ${error.message}`); | ||
process.exit(1); | ||
} | ||
} | ||
|
||
console.log('\x1b[32m\u2713\x1b[0m \x1b[32m All files are within their size limits.\x1b[0m \x1b[32m\u2713\x1b[0m'); | ||
} | ||
|
||
checkFileSizes(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
const { exec } = require('child_process'); | ||
|
||
// Array of folder names | ||
const foldersToBundle = [ | ||
'core', | ||
'client', | ||
'client-frameworks-support/testing-utilities', | ||
'client-frameworks-support/client-support-angular', | ||
'container', | ||
'plugins' | ||
]; | ||
|
||
const foldersToBuild = ['test/e2e-test-application']; | ||
|
||
let timeToBundle = 0; | ||
let timeToBuild = 0; | ||
|
||
// Check for verbose flag | ||
const verboseFlagIndex = process.argv.indexOf('--verbose'); | ||
let isVerbose = verboseFlagIndex !== -1; | ||
|
||
// Function to run 'npm run <operation>' in a folder | ||
function runCommand(folder, index, totalFolders, operation) { | ||
const startTime = new Date(); | ||
|
||
return new Promise((resolve, reject) => { | ||
const command = `cd ${folder} && npm run ${operation}`; | ||
|
||
exec(command, (error, stdout, stderr) => { | ||
const endTime = new Date(); | ||
const elapsedTime = (endTime - startTime) / 1000; | ||
timeToBundle += operation === 'bundle' ? elapsedTime : 0; | ||
timeToBuild += operation === 'build' ? elapsedTime : 0; | ||
|
||
if (error) { | ||
console.error(`\x1b[31mError when trying to ${operation} packages in ${folder} \x1b[0m`); | ||
reject(error); | ||
} else { | ||
console.log( | ||
`\x1b[36m[${index + | ||
1}/${totalFolders}]\x1b[0m: \x1b[33m${folder}\x1b[0m ${operation} successful (\x1b[33m${elapsedTime.toFixed( | ||
2 | ||
)}s\x1b[0m)` | ||
); | ||
// Print logs if needed | ||
if (isVerbose) { | ||
console.log('VERBOSE:', stdout); | ||
} | ||
resolve(); | ||
} | ||
}); | ||
}); | ||
} | ||
|
||
// Function to run 'npm run bundle' in all specified folders | ||
async function runCommandInAllFolders(folders, operation) { | ||
console.log( | ||
`\x1b[36m\n\nRunning (npm run ${operation}) in these folders in the following order:\x1b[0m ${ | ||
isVerbose ? '\x1b[41m\x1b[37m(VERBOSE)\x1b[0m' : '' | ||
}` | ||
); | ||
for (const folder of folders) { | ||
console.log('- ' + folder); | ||
} | ||
|
||
for (let i = 0; i < folders.length; i++) { | ||
console.log(`\n\x1b[37m${operation} \x1b[33m${folders[i]}\x1b[0m ...`); | ||
await runCommand(folders[i], i, folders.length, operation); | ||
} | ||
} | ||
|
||
// Run the 'npm run bundle' command in the specified folders | ||
runCommandInAllFolders(foldersToBundle, 'bundle').then(() => { | ||
console.log(`Bundle finished in ${timeToBundle.toFixed(2)}s`); | ||
|
||
// Run the 'npm run build' command in the specified folders | ||
runCommandInAllFolders(foldersToBuild, 'build').then(() => { | ||
console.log(`Build finished in ${timeToBuild.toFixed(2)}s\n`); | ||
console.log(`\nBuild+Bundle finished in ${(timeToBuild + timeToBundle).toFixed(2)}s\n`); | ||
}, errorHandler); | ||
}, errorHandler); | ||
|
||
/** | ||
* Function to handle the error case for promises | ||
* @param {*} error error | ||
*/ | ||
function errorHandler(error) { | ||
console.error('Stopping execution of the process due to error:', error); | ||
process.exit(1); | ||
} |
Oops, something went wrong.