-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for extendedPublishConfig, apply to workspace resolver (#…
…2146) * Remove the need to build the workspace resolver in local dev * Add changeset
- Loading branch information
Showing
3 changed files
with
43 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@modular-scripts/workspace-resolver': patch | ||
--- | ||
|
||
Remove requirement to build the package in local dev |
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,30 @@ | ||
'use strict'; | ||
|
||
const { writeFileSync } = require('fs'); | ||
const { resolve } = require('path'); | ||
|
||
// This script applies the contents of any `extendedPublishConfig` blocks | ||
// to the root package.json of affected packages in PACKAGES_TO_EXTEND. | ||
// | ||
// It also removes `scripts` on the assumption none are needed when installing npm libraries. | ||
|
||
const PACKAGES_TO_EXTEND = ['workspace-resolver']; | ||
|
||
function writeNewPackageJson(src, content) { | ||
writeFileSync(src, JSON.stringify(content, null, 2)); | ||
} | ||
|
||
function updatePackageJson(src) { | ||
const { extendedPublishConfig, scripts, ...pkg } = require(src); | ||
|
||
return { | ||
...pkg, | ||
...extendedPublishConfig, | ||
}; | ||
} | ||
|
||
PACKAGES_TO_EXTEND.forEach((dirName) => { | ||
const src = resolve(__dirname, `../packages/${dirName}`, 'package.json'); | ||
const content = updatePackageJson(src); | ||
writeNewPackageJson(src, content); | ||
}); |