-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #120 from bigbite/feature/targeted-entrypoints
Add support for declaring specific endpoints to be built
- Loading branch information
Showing
9 changed files
with
151 additions
and
13 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
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
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,21 @@ | ||
const { getFilteredEntryPoints } = require('../get-filtered-entrypoints'); | ||
|
||
describe('Get filtered entrypoints', () => { | ||
it('Return object with empty array if no filtered entry points', () => { | ||
const projects = 'test-project'; | ||
const result = getFilteredEntryPoints(projects); | ||
expect(result).toEqual({ 'test-project': [] }); | ||
}); | ||
|
||
it('Returns object with array of entrypoints', () => { | ||
const projects = 'test-project@frontend+editor'; | ||
const result = getFilteredEntryPoints(projects); | ||
expect(result).toEqual({ 'test-project': ['frontend', 'editor'] }); | ||
}); | ||
|
||
it('Return object with entrypoints where @ is present and empty array if non defined', () => { | ||
const projects = 'test-project@editor,test-project-2'; | ||
const result = getFilteredEntryPoints(projects); | ||
expect(result).toEqual({ 'test-project': ['editor'], 'test-project-2': []}); | ||
}); | ||
}); |
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,37 @@ | ||
/** | ||
* Get filtered entrypoints for projects. | ||
* | ||
* Example command: build project1@entry1+entry2,project2@entry3 | ||
* Example input: 'project1@entry1+entry2,project2@entry3' | ||
* Example return: { project1: ['entry1', 'entry2'], project2: ['entry3'] } | ||
* | ||
* @param {Array} projects Projects of which to filter entrypoints for. | ||
* @returns {object} An object with project keys of which value for each is the entrypoints to build. | ||
*/ | ||
const getFilteredEntryPoints = (projects) => { | ||
const filteredProjectEntryPoints = {}; | ||
const projectNames = projects.split(','); | ||
|
||
projectNames.forEach((project) => { | ||
const projectParts = project.split('@'); | ||
const projectName = projectParts[0]; | ||
const entryPoints = projectParts[1] ? projectParts[1].split('+') : []; | ||
|
||
if (!projectName) { | ||
return filteredProjectEntryPoints; | ||
} | ||
|
||
if (entryPoints.length === 0) { | ||
filteredProjectEntryPoints[projectName] = []; | ||
return; | ||
} | ||
|
||
return filteredProjectEntryPoints[projectName] = entryPoints; | ||
}); | ||
|
||
return filteredProjectEntryPoints; | ||
}; | ||
|
||
module.exports = { | ||
getFilteredEntryPoints, | ||
}; |
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