modules
@listenai/lisa_core / Exports
@listenai/lisa_core
#
Table of contents#
Namespaces#
Enumerations#
Classes#
Interfaces#
Type aliases#
Variables#
Functions- argv
- flags
- job
- load
- loadConfig
- loadDependencies
- loadDevDependencies
- loadFile
- loadPackageJSON
- loadTask
- loadTypescript
- minimist
- parsePackageJSON
- reloadApplication
- runner
#
Type aliases#
PipelineƬ Pipeline: Object
pipeline定义
#
Index signature▪ [key: string
]: PipelineObject
#
Defined in#
TaskObjectƬ TaskObject: Listr.ListrTask
<Listr.ListrContext
>
#
Defined in#
TaskOptionsƬ TaskOptions: Listr.ListrOptions
#
Defined in#
Variables#
Tasks• Const
Tasks: typeof Listr
引用Listr来执行task指令
#
Defined in#
application• application: Application
#
Defined in#
cli• Const
cli: Object
#
Type declarationName | Type | Description |
---|---|---|
action | ActionBase | - |
anykey | anykey | "press anykey to continue" |
config | Config | - |
confirm | confirm | - |
error | typeof Errors.error | - |
exit | typeof Errors.exit | - |
open | default | - |
prideAction | ActionBase | - |
progress | default | - |
prompt | prompt | - |
styledHeader | default | - |
styledJSON | default | - |
table | typeof table | - |
tree | default | - |
wait | (ms? : number ) => Promise <unknown > | - |
warn | typeof Errors.warn | - |
annotation | (text : string , annotation : string ) => void | - |
debug | (format : string , ...args : string []) => void | - |
done | () => Promise <void > | - |
flush | () => Promise <void > | - |
info | (format : string , ...args : string []) => void | - |
log | (format? : string , ...args : string []) => void | - |
styledObject | (obj : any , keys? : string []) => void | - |
trace | (format : string , ...args : string []) => void | - |
url | (text : string , uri : string , params? : {}) => void | - |
#
Defined innode_modules/cli-ux/lib/index.d.ts:38
#
cmd• Const
cmd: Object
#
Call signature▸ (file
, arguments?
, options?
): ExecaChildProcess
<string
>
Execute a file.
Think of this as a mix of child_process.execFile
and child_process.spawn
.
example
import execa = require('execa'); (async () => {const {stdout} = await execa('echo', ['unicorns']);console.log(stdout);//=> 'unicorns' // Cancelling a spawned process const subprocess = execa('node'); setTimeout(() => {subprocess.cancel()}, 1000); try {await subprocess;} catch (error) {console.log(subprocess.killed); // trueconsole.log(error.isCanceled); // true}})(); // Pipe the child process stdout to the current stdoutexeca('echo', ['unicorns']).stdout.pipe(process.stdout);
#
ParametersName | Type | Description |
---|---|---|
file | string | The program/script to execute. |
arguments? | readonly string [] | Arguments to pass to file on execution. |
options? | Options <string > | - |
#
ReturnsExecaChildProcess
<string
>
A child_process
instance, which is enhanced to also be a Promise
for a result Object
with stdout
and stderr
properties.
▸ (file
, arguments?
, options?
): ExecaChildProcess
<Buffer
>
引用execa来执行shell命令,解决windows一些兼容性问题,具体请查看 execa
#
ParametersName | Type |
---|---|
file | string |
arguments? | readonly string [] |
options? | Options <null > |
#
ReturnsExecaChildProcess
<Buffer
>
▸ (file
, options?
): ExecaChildProcess
<string
>
引用execa来执行shell命令,解决windows一些兼容性问题,具体请查看 execa
#
ParametersName | Type |
---|---|
file | string |
options? | Options <string > |
#
ReturnsExecaChildProcess
<string
>
▸ (file
, options?
): ExecaChildProcess
<Buffer
>
引用execa来执行shell命令,解决windows一些兼容性问题,具体请查看 execa
#
ParametersName | Type |
---|---|
file | string |
options? | Options <null > |
#
ReturnsExecaChildProcess
<Buffer
>
#
Type declarationName | Type |
---|---|
command | (command : string , options? : Options <string >) => ExecaChildProcess <string >(command : string , options? : Options <null >) => ExecaChildProcess <Buffer > |
commandSync | (command : string , options? : SyncOptions <string >) => ExecaSyncReturnValue <string >(command : string , options? : SyncOptions <null >) => ExecaSyncReturnValue <Buffer > |
node | (scriptPath : string , arguments? : readonly string [], options? : NodeOptions <string >) => ExecaChildProcess <string >(scriptPath : string , arguments? : readonly string [], options? : Options <null >) => ExecaChildProcess <Buffer >(scriptPath : string , options? : Options <string >) => ExecaChildProcess <string >(scriptPath : string , options? : Options <null >) => ExecaChildProcess <Buffer > |
sync | (file : string , arguments? : readonly string [], options? : SyncOptions <string >) => ExecaSyncReturnValue <string >(file : string , arguments? : readonly string [], options? : SyncOptions <null >) => ExecaSyncReturnValue <Buffer >(file : string , options? : SyncOptions <string >) => ExecaSyncReturnValue <string >(file : string , options? : SyncOptions <null >) => ExecaSyncReturnValue <Buffer > |
#
Defined in#
config• Const
config: Config
#
Defined innode_modules/cli-ux/lib/config.d.ts:19
#
got• Const
got: Got
使用 Got 来处理 HTTP 请求,具体请查看 GOT
#
Defined in#
project_lang• project_lang: string
项目引导能力,用于命令行引导程序
#
Defined in#
store• Const
store: Configstore
#
Defined in#
ux• Const
ux: Object
#
Type declarationName | Type | Description |
---|---|---|
action | ActionBase | - |
anykey | anykey | "press anykey to continue" |
config | Config | - |
confirm | confirm | - |
error | typeof Errors.error | - |
exit | typeof Errors.exit | - |
open | default | - |
prideAction | ActionBase | - |
progress | default | - |
prompt | prompt | - |
styledHeader | default | - |
styledJSON | default | - |
table | typeof table | - |
tree | default | - |
wait | (ms? : number ) => Promise <unknown > | - |
warn | typeof Errors.warn | - |
annotation | (text : string , annotation : string ) => void | - |
debug | (format : string , ...args : string []) => void | - |
done | () => Promise <void > | - |
flush | () => Promise <void > | - |
info | (format : string , ...args : string []) => void | - |
log | (format? : string , ...args : string []) => void | - |
styledObject | (obj : any , keys? : string []) => void | - |
trace | (format : string , ...args : string []) => void | - |
url | (text : string , uri : string , params? : {}) => void | - |
#
Defined innode_modules/cli-ux/lib/index.d.ts:7
#
Functions#
argv▸ argv(argv?
, opts?
): ParsedArgs
获取环境变量
#
ParametersName | Type | Description |
---|---|---|
argv | string [] | - |
opts? | _minimist.Opts | 设置解析参数 |
#
ReturnsParsedArgs
#
Defined in#
flags▸ flags(key
): (target
: any
, propertyKey
: string
, descriptor
: TypedPropertyDescriptor
<fn
>) => void
仅供typescript代码使用
example
export class CliUx {@flags("project_path")async getProjectPath() {const projectPath = await cli.prompt("请输入项目路径", {default: '.'})return path.resolve(projectPath)} @flags('author')async getAuthor() {const author = await cli.prompt('请输入作者名称', {default: ''}) as stringreturn author} getProjectName(projectPath: string) {return path.basename(projectPath)}}
#
ParametersName | Type | Description |
---|---|---|
key | string | 方法字段 |
#
Returnsfn
▸ (target
, propertyKey
, descriptor
): void
#
ParametersName | Type |
---|---|
target | any |
propertyKey | string |
descriptor | TypedPropertyDescriptor <fn > |
#
Returnsvoid
#
Defined in#
job▸ job(cmdName
, task
): void
创建任务
example
job("lisa_core:pre_build", { title: "编译任务1", task: async() => { console.log("a") await fs.remove("./out") fs.project.root = "./out" await fs.project.mkdir("app", "config", "target") }})
#
ParametersName | Type | Description |
---|---|---|
cmdName | string | 任务名称,必须是类似 build:pre 的名称;请注意,如果任务名称相同,不可知道任务是否会被替换,推荐使用 {包名}:{任务名} 的命名规范 |
task | TaskObject | 任务对象 |
#
Returnsvoid
#
Defined in#
load▸ load(): @listenai/lisa_core
#
Returns#
Defined in#
loadConfig▸ loadConfig(configPath?
): void
加载 config.[js|ts]
#
ParametersName | Type | Description |
---|---|---|
configPath? | string | config地址,默认为packge.json中配置的地址,如果没有配置,读取项目中config.js |
#
Returnsvoid
#
Defined in#
loadDependencies▸ loadDependencies(): void
#
Returnsvoid
#
Defined in#
loadDevDependencies▸ loadDevDependencies(): void
#
Returnsvoid
#
Defined in#
loadFile▸ loadFile(file
): void
#
ParametersName | Type | Description |
---|---|---|
file | string | 加载路径 |
#
Returnsvoid
#
Defined in#
loadPackageJSON▸ loadPackageJSON(packagePath?
): void
#
ParametersName | Type |
---|---|
packagePath? | string |
#
Returnsvoid
#
Defined in#
loadTask▸ loadTask(taskPath?
): void
加载 task.[js|ts]
#
ParametersName | Type | Description |
---|---|---|
taskPath? | string | task地址,默认为packge.json中配置的地址,如果没有配置,读取项目中 task.js |
#
Returnsvoid
#
Defined in#
loadTypescript▸ loadTypescript(): void
#
Returnsvoid
#
Defined in#
minimist▸ Const
minimist(args?
, opts?
): minimist.ParsedArgs
#
ParametersName | Type |
---|---|
args? | string [] |
opts? | minimist.Opts |
#
Returnsminimist.ParsedArgs
#
Defined in▸ Const
minimist<T
>(args?
, opts?
): T
& minimist.ParsedArgs
#
Type parametersName |
---|
T |
#
ParametersName | Type |
---|---|
args? | string [] |
opts? | minimist.Opts |
#
ReturnsT
& minimist.ParsedArgs
#
Defined in▸ Const
minimist<T
>(args?
, opts?
): T
#
Type parametersName | Type |
---|---|
T | extends ParsedArgs |
#
ParametersName | Type |
---|---|
args? | string [] |
opts? | minimist.Opts |
#
ReturnsT
#
Defined in#
parsePackageJSON▸ parsePackageJSON(packagePath?
): any
#
ParametersName | Type |
---|---|
packagePath? | string |
#
Returnsany
#
Defined in#
reloadApplication▸ reloadApplication(): void
危险:仅供测试使用
#
Returnsvoid
#
Defined in#
runner▸ runner(job_list?
, ctx?
, verbose?
): Promise
<unknown
>
#
ParametersName | Type |
---|---|
job_list? | string |
ctx? | Object |
verbose? | boolean |
#
ReturnsPromise
<unknown
>