创世纪基金会
这回波包含我们的 基础 cli 用于遵循最佳做法的快速码脚手架工具.
应用塔克
种子可以在 .genx/tasks.json。 。 。 .
一个任务包含一个或多个步骤,可以执行各种命令.
{
"tasks": {
"hello": {
"name": "hello",
"description": "Sample task",
"steps": [
{
"say": "hello"
}
]
}
}
}
运行 foundation-cli app 查看可用任务 :
$ foundation-cli app
$ foundation-cli app <task>
Apps: Apps are seed instances. Tasks are commands provided by a seed.
$ foundation-cli app List all tasks
$ foundation-cli app hello Sample task
运行 foundation-cli app hello数字 :
$ foundation-cli app hello
hello | hello
执行命令
您可以按以下步骤执行命令:
"exec": "gradle assemble"运行程序或脚本"spawn": "taskname"执行另一项任务(见下文)"builtin": "hello"运行由 CLI 提供的内置任务。 现有任务在 任务文件夹。 。 。 ."say": "text"打印输出
使用时 exec 检查您的命令在不同平台( Windows, Linux, OS X) 上工作.
目录
你可以提供 cwd 选项设置任务或虚拟任务步骤的工作目录.
{
"tasks": {
"build": {
"name": "build",
"description": "Build project",
"cwd": ".genx/generated",
"steps": [
{
"exec": "gradle assemble"
},
{
"exec": "npm run build"
},
{
"say": "all done"
}
]
}
}
}
环境变量
您可以为某项任务或单个步骤设定环境变量.
您可以添加 requiredEnv 矩阵到任务以指定它运行时必须设置的环境变量.
说明:在这个例子中,我们本可以简单地做到 "exec": "git branch --show-current" 相反,它只是说明环境的可变用途.
{
"tasks": {
"env": {
"name": "env",
"description": "Print current branch",
"env": {
"BRANCH": "$(git branch --show-current)"
},
"steps": [
{
"exec": "node -e \"console.log(process.env.BRANCH)\""
}
]
}
}
}
$ foundation-cli app env
env | node -e "console.log(process.env.BRANCH)"
master
条件
您可以定义一个条件来确定是否应该执行任务 。 如果它返回一个零退出代码,步骤会被执行,否则跳过.
{
"tasks": {
"diff": {
"name": "diff",
"description": "Detect changes",
"steps": [
{
"exec": "echo 'working tree contains changes'"
}
],
"condition": "git diff --exit-code"
}
}
}
注:我们本可以做到的 git diff --exit-code > /dev/null 关闭 Linux/ OS X 上的 Git 输出, 但Windows 上不支持.
假设我们在工作目录中有一些变化,这些变化还没有被添加到 Git 中:
$ foundation-cli app diff
diff | condition: git diff --exit-code
# ... git diff output
diff | condition exited with non-zero - skipping
运行 Git 后添加命令 :
$ foundation-cli app diff
diff | condition: git diff --exit-code
diff | echo 'working tree contains changes'
working tree contains changes
依赖性任务
您可以定义依赖性任务 :
{
"tasks": {
"first": {
"name": "first",
"description": "First task",
"steps": [
{
"say": "first"
}
]
},
"second": {
"name": "second",
"description": "Second task",
"steps": [
{
"spawn": "first"
},
{
"say": "second"
}
]
}
}
}
$ foundation-cli app second
second » first | first
second | second
安装
要在应用程序中启用此模块, 请遵循以下步骤 .
- 添加
@genesislcap/foundation-cli作为你package.json文档。 当您改变您的项目的依赖性时, 请确保您运行$ npm run bootstrap再次指挥。 您可以在 软件包.json 基础 页 次.
{
...
"dependencies": {
...
"@genesislcap/foundation-cli": "latest"
...
},
...
}
API 文档
许可证
注:该项目提供前端依赖性,并使用下一节所列许可部件;因此,开发期间需要对这些部件发放许可证。 联系人 创世纪全球 更多细节.
许可组件
创世纪低码平台