-
Notifications
You must be signed in to change notification settings - Fork 378
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1911 from daniel-samson/fix/custom-schematics-in-…
…help fix: display custom schematics in help
- Loading branch information
Showing
7 changed files
with
66 additions
and
18 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,29 @@ | ||
import { description } from 'commander'; | ||
import { readFileSync } from 'fs'; | ||
import { dirname, join } from 'path'; | ||
import { AbstractCollection } from './abstract.collection'; | ||
import { Schematic } from './nest.collection'; | ||
|
||
export class CustomCollection extends AbstractCollection {} | ||
export interface CollectionSchematic { | ||
schema: string; | ||
description: string; | ||
aliases: string[]; | ||
} | ||
|
||
export class CustomCollection extends AbstractCollection { | ||
public getSchematics(): Schematic[] { | ||
const collectionPackagePath = dirname(require.resolve(this.collection)); | ||
const collectionPath = join(collectionPackagePath, 'collection.json'); | ||
const collection = JSON.parse(readFileSync(collectionPath, 'utf8')); | ||
const schematics = Object.entries(collection.schematics).map( | ||
([name, value]) => { | ||
const schematic = value as CollectionSchematic; | ||
const description = schematic.description; | ||
const alias = schematic?.aliases?.length ? schematic.aliases[0] : ''; | ||
return { name, description, alias }; | ||
}, | ||
); | ||
|
||
return schematics; | ||
} | ||
} |
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