-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
922a59f
commit b81c673
Showing
27 changed files
with
943 additions
and
801 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,6 +1,3 @@ | ||
{ | ||
".": "4.11.4", | ||
"workspaces/config": "1.0.0", | ||
"workspaces/get-workspaces": "1.0.0", | ||
"workspaces/release-manager": "1.0.0" | ||
".": "4.11.4" | ||
} |
This file was deleted.
Oops, something went wrong.
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,51 @@ | ||
const { omit } = require('lodash') | ||
const { mergeWithArrays } = require('./merge') | ||
|
||
const mergeDataOptions = mergeWithArrays('mergeArrays') | ||
|
||
// Lookup a key in any config. First lookup the toplevel key | ||
// and then lookup the same key in either the toplevel `root` | ||
// or `workspace` objects | ||
const getRootOrWorkspace = (data = {}, options) => { | ||
const sharedData = omit(data, 'root', 'workspace') | ||
const pkgData = options.pkg.isRoot ? data.root : data.workspace | ||
return [sharedData, pkgData].filter(Boolean) | ||
} | ||
|
||
// Get the `data` config object and run it through the `postData` | ||
// config function at each layer and then merge the results | ||
const getData = (configs, baseOptions) => { | ||
const dataLayers = configs.flatMap(({ config }) => | ||
getRootOrWorkspace(config.data, baseOptions)) | ||
|
||
const allLayers = dataLayers.reduce((acc, data) => { | ||
if (data.values) { | ||
acc.values.push(data.values) | ||
} | ||
if (data.options) { | ||
acc.options.push(data.options) | ||
} | ||
if (data.postData) { | ||
acc.postData.push(data.postData) | ||
} | ||
return acc | ||
}, { values: [], options: [], postData: [] }) | ||
|
||
const mergedOptions = mergeDataOptions(...allLayers.options) | ||
const mergeValues = mergeWithArrays(...mergedOptions.mergeArrays ?? []) | ||
|
||
const allData = [] | ||
for (const values of allLayers.values) { | ||
allData.push(values) | ||
for (const fn of allLayers.postData) { | ||
allData.push(fn(values, baseOptions)) | ||
} | ||
} | ||
|
||
return mergeValues(...allData) | ||
} | ||
|
||
module.exports = { | ||
getData, | ||
getRootOrWorkspace, | ||
} |
Oops, something went wrong.