-
-
Notifications
You must be signed in to change notification settings - Fork 201
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve build preview message (#984)
The build preview message now includes a link to the build preview instructions, and a collapsible list of all published packages. Co-authored-by: Maarten Zuidhoorn <[email protected]>
- Loading branch information
Showing
3 changed files
with
61 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#!yarn ts-node | ||
|
||
import fs from 'fs'; | ||
import path from 'path'; | ||
import execa from 'execa'; | ||
|
||
/** | ||
* Write a preview build message to the path "preview-build-message.txt". | ||
*/ | ||
async function main() { | ||
const packageMap: Record<string, string> = {}; | ||
|
||
const { stdout } = await execa('yarn', [ | ||
'workspaces', | ||
'list', | ||
'--no-private', | ||
'--json', | ||
]); | ||
const packages = stdout.split('\n').map((line) => JSON.parse(line)); | ||
const packageManifestPaths = packages.map(({ location }) => | ||
path.join(location, 'package.json'), | ||
); | ||
for (const manifestPath of packageManifestPaths) { | ||
const rawManifest = await fs.promises.readFile(manifestPath, { | ||
encoding: 'utf8', | ||
}); | ||
const { name, version } = JSON.parse(rawManifest); | ||
|
||
packageMap[name] = version; | ||
} | ||
|
||
const previewBuildMessage = ` | ||
Preview builds have been published. [See these instructions](https://github.com/MetaMask/controllers/blob/main/docs/contributing.md#using-controllers-in-other-projects-during-developmenttesting) for more information about preview builds. | ||
<details> | ||
<summary>Expand for full list of packages and versions.</summary> | ||
\`\`\` | ||
${JSON.stringify(packageMap, null, 2)} | ||
\`\`\` | ||
</details> | ||
`; | ||
|
||
const messagePath = path.resolve(__dirname, '../preview-build-message.txt'); | ||
await fs.promises.writeFile(messagePath, previewBuildMessage); | ||
} | ||
|
||
main().catch((error) => { | ||
console.error(error); | ||
process.exitCode = 1; | ||
}); |