Class: SAO
Hierarchy#
- SAO
Constructors#
constructor#
Parameters:#
| Name | Type |
|---|---|
opts | Options |
Returns: SAO
Defined in: src/index.ts:72
Properties#
_answers#
• Private _answers: { [k: string]: any; } | symbol
Defined in: src/index.ts:68
_data#
• Private _data: { [k: string]: any; } | symbol
Defined in: src/index.ts:69
colors#
• colors: Chalk & ChalkFunction & { BackgroundColor: BackgroundColor ; Color: Color ; ForegroundColor: ForegroundColor ; Level: chalk.Level ; Modifiers: Modifiers ; stderr: chalk.Chalk & { supportsColor: chalk.ColorSupport | false } ; supportsColor: chalk.ColorSupport | false }
Defined in: src/index.ts:65
generatorList#
• generatorList: GeneratorList
Defined in: src/index.ts:72
logger#
• logger: Logger
Defined in: src/index.ts:66
opts#
• opts: SetRequired<Options, outDir | logLevel>
Defined in: src/index.ts:63
parsedGenerator#
• parsedGenerator: ParsedGenerator
Defined in: src/index.ts:71
spinner#
• spinner: Ora
Defined in: src/index.ts:64
Accessors#
answers#
• answers(): object
Retrive the answers
You can't access this in prompts function
Returns: object
Defined in: src/index.ts:240
• answers(value: { [k: string]: any; }): void
Retrive the answers
You can't access this in prompts function
Parameters:#
| Name | Type |
|---|---|
value | { [k: string]: any; } |
Returns: void
Defined in: src/index.ts:247
data#
• data(): any
Returns: any
Defined in: src/index.ts:251
gitUser#
• gitUser(): GitUser
Get the information of system git user
Returns: GitUser
Defined in: src/index.ts:277
npmClient#
• npmClient(): NPM_CLIENT
The npm client
Returns: NPM_CLIENT
Defined in: src/index.ts:298
outDir#
• outDir(): string
The absolute path to output directory
Returns: string
Defined in: src/index.ts:291
outDirName#
• outDirName(): string
The basename of output directory
Returns: string
Defined in: src/index.ts:284
pkg#
• pkg(): any
Read package.json from output directory
Returns an empty object when it doesn't exist
Returns: any
Defined in: src/index.ts:266
Methods#
createError#
â–¸ createError(message: string): SAOError
Create an SAO Error so we can pretty print the error message instead of showing full error stack
Parameters:#
| Name | Type |
|---|---|
message | string |
Returns: SAOError
Defined in: src/index.ts:355
getGenerator#
â–¸ getGenerator(generator?: ParsedGenerator, hasParent?: boolean): Promise<{ config: GeneratorConfig ; generator: ParsedGenerator }>
Get actual generator to run and its config Download it if not yet cached
Parameters:#
| Name | Type | Default value |
|---|---|---|
generator | ParsedGenerator | ... |
hasParent? | boolean | - |
Returns: Promise<{ config: GeneratorConfig ; generator: ParsedGenerator }>
Defined in: src/index.ts:137
getGeneratorHelp#
â–¸ getGeneratorHelp(): Promise<string>
Get the help message for current generator
Used by SAO CLI, in general you don't want to touch this
Returns: Promise<string>
Defined in: src/index.ts:121
getOutputFiles#
â–¸ getOutputFiles(): Promise<string[]>
Get file list of output directory
Returns: Promise<string[]>
Defined in: src/index.ts:362
gitInit#
â–¸ gitInit(): void
Run git init in output directly
It will fail silently when git is not available
Returns: void
Defined in: src/index.ts:307
hasOutputFile#
â–¸ hasOutputFile(file: string): Promise<boolean>
Check if a file exists in output directory
Parameters:#
| Name | Type |
|---|---|
file | string |
Returns: Promise<boolean>
Defined in: src/index.ts:374
npmInstall#
â–¸ npmInstall(opts?: Pick<InstallOptions, npmClient | installArgs | packages | saveDev>): Promise<{ code: number }>
Run npm install in output directory
Parameters:#
| Name | Type |
|---|---|
opts? | Pick<InstallOptions, npmClient | installArgs | packages | saveDev> |
Returns: Promise<{ code: number }>
Defined in: src/index.ts:326
readOutputFile#
â–¸ readOutputFile(file: string): Promise<string>
Read a file in output directory
Parameters:#
| Name | Type | Description |
|---|---|---|
file | string | file path |
Returns: Promise<string>
Defined in: src/index.ts:382
run#
â–¸ run(): Promise<void>
Returns: Promise<void>
Defined in: src/index.ts:230
runGenerator#
â–¸ runGenerator(generator: ParsedGenerator, config: GeneratorConfig): Promise<void>
Parameters:#
| Name | Type |
|---|---|
generator | ParsedGenerator |
config | GeneratorConfig |
Returns: Promise<void>
Defined in: src/index.ts:199
showProjectTips#
â–¸ showProjectTips(): void
Display a success message
Returns: void
Defined in: src/index.ts:347