-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build(docs): include package READMEs at publish time
Add a script to copy per-package README files `docs/site/readmes`, run it as part of the release process.
- Loading branch information
Showing
4 changed files
with
62 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#!/usr/bin/env node | ||
// Copyright IBM Corp. 2017,2018. All Rights Reserved. | ||
// Node module: loopback-next | ||
// This file is licensed under the MIT License. | ||
// License text available at https://opensource.org/licenses/MIT | ||
|
||
'use strict'; | ||
|
||
/* | ||
* This is an internal script to gather READMEs of all packages | ||
* in our monorepo and copy them to `site/readmes` for consumption | ||
* from the docs. | ||
*/ | ||
|
||
const Project = require('@lerna/project'); | ||
const fs = require('fs-extra'); | ||
const path = require('path'); | ||
|
||
const REPO_ROOT = path.resolve(__dirname, '../..'); | ||
const DEST_ROOT = path.resolve(__dirname, '../site/readmes/loopback-next'); | ||
|
||
copyReadmes().catch(err => { | ||
console.error('Unhandled error.', err); | ||
process.exit(1); | ||
}); | ||
|
||
async function copyReadmes() { | ||
// Remove the original folder so we remove files from deleted packages | ||
fs.removeSync(DEST_ROOT); | ||
|
||
const project = new Project(REPO_ROOT); | ||
const allPackages = await project.getPackages(); | ||
|
||
const packages = allPackages.filter(isDocumented).map(pkg => ({ | ||
name: pkg.name, | ||
location: path.relative(REPO_ROOT, pkg.location), | ||
})); | ||
|
||
for (const {location} of packages) { | ||
const src = path.join(REPO_ROOT, location, 'README.md'); | ||
const dest = path.join(DEST_ROOT, location, 'README.md'); | ||
await fs.copy(src, dest, {overwrite: true}); | ||
} | ||
} | ||
|
||
function isDocumented(pkg) { | ||
return ( | ||
!pkg.name.startsWith('@loopback/sandbox-') && | ||
pkg.name !== '@loopback/docs' && | ||
pkg.name !== '@loopback/benchmark' | ||
); | ||
} |
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