Skip to content

Commit

Permalink
Prepare to deprecate buildDependencies /w 2.0
Browse files Browse the repository at this point in the history
After introducting included/excludedDependencies w/ commit 48cd30d,
the buildDependencies parameter is no longer required. To build all
dependencies excludedDependencies can be set to an empty array, to
build no dependencies (default) excludedDependencies can be set to ["*"]

This change prepares the deprecation of the parameter, by introducing
a warning when buildDependencies is set (commented at the moment, as
buildDependencies is still used by many internal dependencies) and by
setting the new parameters feature comatible if buildDependencies is set
  • Loading branch information
kristian committed Dec 11, 2019
1 parent de170d3 commit 2bc71c6
Showing 1 changed file with 34 additions and 20 deletions.
54 changes: 34 additions & 20 deletions lib/builder/builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,13 +219,33 @@ module.exports = {
*/
async build({
tree, destPath, cleanDest = false,
buildDependencies = false, includedDependencies = [], excludedDependencies = [],
buildDependencies = false, includedDependencies, excludedDependencies,
dev = false, selfContained = false, jsdoc = false,
includedTasks = [], excludedTasks = [], devExcludeProject = []
}) {
if (buildDependencies) {
// TODO <2.0: Uncomment the warning below to prepare deprecation
// TODO 2.0: Remove deprecated "buildDependencies" parameter and set the default of
// includedDependencies to [] and, excludedDependencies to ["*"] for feature parity
// log.warn(`builder.build called with deprecated parameter "buildDependencies". ` +
// `This parameter will be removed in @ui5/builder version 2.0. ` +
// `Use parameters "includedDependencies" and "excludedDependencies" instead`);*/
}
if (buildDependencies && (includedDependencies || excludedDependencies)) {
throw new Error(
`builder.build called with parameters "buildDependencies" and ` +
`"includedDependencies" / "excludedDependencies". Please provide only one of the two.`);
} else if (includedDependencies || excludedDependencies) {
// as we don't set a default yet (because of the deprecation of buildDependencies), we have to check:
if (!includedDependencies) includedDependencies = [];
if (!excludedDependencies) excludedDependencies = [];
} else {
includedDependencies = [];
excludedDependencies = buildDependencies ? [] : ["*"];
}

const startTime = process.hrtime();
log.info(`Building project ${tree.metadata.name}` + (buildDependencies ? "" : " not") +
" including dependencies..." + (dev ? " [dev mode]" : ""));
log.info(`Building project ${tree.metadata.name}` + (dev ? " [dev mode]" : ""));
log.verbose(`Building to ${destPath}...`);

const selectedTasks = composeTaskList({dev, selfContained, jsdoc, includedTasks, excludedTasks});
Expand Down Expand Up @@ -257,32 +277,26 @@ module.exports = {

const projectCountMarker = {};
function projectCount(project, count = 0) {
if (buildDependencies) {
count = project.dependencies.filter(projectFilter).reduce((depCount, depProject) => {
return projectCount(depProject, depCount);
}, count);
}
count = project.dependencies.filter(projectFilter).reduce((depCount, depProject) => {
return projectCount(depProject, depCount);
}, count);
if (!projectCountMarker[project.metadata.name]) {
count++;
projectCountMarker[project.metadata.name] = true;
}
return count;
}
const iProjectCount = projectCount(tree);
const buildLogger = log.createTaskLogger("🛠 ", iProjectCount);
const buildLogger = log.createTaskLogger("🛠 ", projectCount(tree));

function buildProject(project) {
let depPromise;
let projectTasks = selectedTasks;
if (buildDependencies) {
// Build dependencies in sequence as it is far easier to detect issues and reduces
// side effects or other issues such as too many open files
depPromise = project.dependencies.filter(projectFilter).reduce(function(p, depProject) {
return p.then(() => buildProject(depProject));
}, Promise.resolve());
} else {
depPromise = Promise.resolve();
}

// Build dependencies in sequence as it is far easier to detect issues and reduces
// side effects or other issues such as too many open files
const depPromise = project.dependencies.filter(projectFilter).reduce(function(p, depProject) {
return p.then(() => buildProject(depProject));
}, Promise.resolve());

// Build the project after all dependencies have been built
return depPromise.then(() => {
if (projects[project.metadata.name]) {
Expand Down

0 comments on commit 2bc71c6

Please sign in to comment.