-
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.
chore(tsdocs): generate index.md for apidocs
- Loading branch information
1 parent
2ff66d4
commit 397b119
Showing
12 changed files
with
245 additions
and
53 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
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,18 @@ | ||
#!/usr/bin/env node | ||
// Copyright IBM Corp. 2019. All Rights Reserved. | ||
// Node module: @loopback/tsdocs | ||
// This file is licensed under the MIT License. | ||
// License text available at https://opensource.org/licenses/MIT | ||
|
||
/** | ||
* Update generated api md files with Jekyll macros and create index page | ||
*/ | ||
const updateApiDocs = require('..').updateApiDocs; | ||
const silent = process.argv.includes('--silent'); | ||
const dryRun = process.argv.includes('--dry-run'); | ||
|
||
async function main() { | ||
await updateApiDocs({silent, dryRun}); | ||
} | ||
|
||
main(); |
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,76 @@ | ||
// Copyright IBM Corp. 2019. All Rights Reserved. | ||
// Node module: @loopback/tsdocs | ||
// This file is licensed under the MIT License. | ||
// License text available at https://opensource.org/licenses/MIT | ||
|
||
import * as fs from 'fs-extra'; | ||
import * as path from 'path'; | ||
|
||
const Project = require('@lerna/project'); | ||
|
||
/** | ||
* TypeScript definition for Lerna Package | ||
*/ | ||
export interface LernaPackage { | ||
name: string; | ||
location: string; | ||
rootPath: string; | ||
manifestLocation: string; | ||
private: boolean; | ||
} | ||
|
||
/** | ||
* Get unscoped package name | ||
* @param name npm package name, such as `@loopback/context` or `express` | ||
*/ | ||
export function getUnscopedPackageName(name: string) { | ||
if (name.startsWith('@')) { | ||
return name.split('/')[1]; | ||
} | ||
return name; | ||
} | ||
|
||
/** | ||
* Get lerna packages | ||
* @param rootDir Root directory to find lerna.json | ||
*/ | ||
export async function getPackages( | ||
rootDir = process.cwd(), | ||
): Promise<LernaPackage[]> { | ||
const project = new Project(rootDir); | ||
const packages: LernaPackage[] = await project.getPackages(); | ||
packages.sort((p1, p2) => p1.location.localeCompare(p2.location)); | ||
return packages; | ||
} | ||
|
||
/** | ||
* Check if a package is TypeScript project | ||
* @param pkg Lerna package | ||
*/ | ||
export function isPublicTSPackage(pkg: LernaPackage) { | ||
if (pkg.private) return false; | ||
if (pkg.name.startsWith('@loopback/example-')) return false; | ||
|
||
if (!fs.existsSync(path.join(pkg.location, 'tsconfig.build.json'))) | ||
return false; | ||
|
||
if (!fs.existsSync(path.join(pkg.location, 'dist/index.d.ts'))) return false; | ||
|
||
return true; | ||
} | ||
|
||
/** | ||
* Get an array lerna-managed public TypeScript packages | ||
* @param rootDir | ||
*/ | ||
export async function getPublicTSPackages( | ||
rootDir = process.cwd(), | ||
): Promise<LernaPackage[]> { | ||
const packages = await getPackages(rootDir); | ||
return packages.filter(isPublicTSPackage); | ||
} | ||
|
||
/** | ||
* Export the TypeScript path from `@loopback/build` | ||
*/ | ||
export const typeScriptPath = require('@loopback/build').typeScriptPath; |
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
Oops, something went wrong.