darling/rig

命令行实用工具,旨在帮助使用Roady进行开发

维护者

详细信息

github.com/sevidmusic/rig

源代码

问题

安装: 953

依赖项: 0

建议者: 0

安全性: 0

星星: 1

关注者: 2

分支: 0

类型:命令行实用工具

v2.0.0-alpha-13 2024-05-04 12:40 UTC

README

 ____  _
|  _ \(_) ____
| |_) | |/ _` |
|  _ <| | (_| |
|_| \_\_|\__, |
         |___/

rig 是一个命令行实用工具,旨在帮助使用 Roady php 框架进行开发。

安装

rig 可以通过以下安装方法之一进行安装

通过 composer 安装

composer require darling/rig

注意:如果通过 composer 安装 rig,则 rigrig.phpsetupRig.sh 脚本将可在 vendor/bin 中找到。

通过 git 安装

git clone https://github.com/sevidmusic/rig

安装 rig 后,在 ~/.local/bin 中创建 rig 的符号链接是有帮助的。

为了使这更简单,rig 提供了一个 setupRig.sh 脚本,它将执行此操作。

如果使用 composer require darling/rig 安装了 rig,请在 vendor/bin 中运行设置脚本

./vendor/bin/setupRig.sh

如果使用 git clone 安装了 rig,请在 rig 的根目录中运行设置脚本

./setupRig.sh

注意

setupRig.sh 默认不会覆盖现有的 rig 符号链接。

要强制 setupRig.sh 覆盖现有的 rig 符号链接,请使用 --force 标志

# For composer installation
./vendor/bin/setupRig.sh --force
# For git installation
./setupRig.sh --force

入门

要确保 rig 已安装并可调用,请运行以下命令

rig --version

如果成功了,那么 rig 已正确安装。

创建一个模块

rig 可以用于为 Roady 项目创建新的模块。

例如,要创建一个名为 hello-world 的模块,请运行以下命令

rig --new-module \
    --module-name "hello-world"

这将创建一个名为 hello-world 的模块,在当前 Roady 项目的 modules 目录中。

modules/hello-world

它还将创建以下文件

modules/hello-world/output/hello-world.html

modules/hello-world/localhost.8080.json

要使用此模块,通过 rig --start-servers --open-in-browserlocalhost:8080 上启动开发服务器。

注意:如果 localhost:8080 无法在浏览器中自动打开,则手动打开一个网页浏览器并导航到 localhost:8080

如果一切正常,则新模块的输出,Hello hello-world,应显示在浏览器中。

附加文档

以下可以找到与 rig 的各个命令相关的文档。

有关如何使用 rigRoady 一起构建网站的更详细的文档可以在 RoadyREADME.md 中找到。

命令

rig --help

显示有关 rigrig 的某个命令的文档。

参数

[TOPIC]

示例

rig --help

rig --help about

rig --help delete-route

rig --help getting-started

rig --help help

rig --help installation

rig --help list-routes

rig --help new-module

rig --help new-route

rig --help start-servers

rig --help update-route

rig --help version

rig --help view-action-log

rig --help view-readme

rig --delete-route

删除分配了指定路由哈希的路由。

注意:路由哈希在 rig --list-routes 的输出中显示。

参数

--path-to-roady-project     The path to the relevant Roady project's
                            root directory.

                            Defaults to current directory: ./

--route-hash                The hash of the Route to delete.

示例

rig --delete-route \
--route-hash "016bbd46d3a3fc25c"

rig --delete-route \
--path-to-roady-project "./" \
--route-hash "6591c3e1ed38ed5eb"

rig --list-routes

列出由现有模块配置的路由。

注意:如果没有指定参数,所有现有模块定义的所有路由都将包含在列表中。

参数

--defined-for-authorities     If specified, only list Routes
                              that are defined for one of the
                              specified Authorities.

--defined-for-modules         If specified, only list Routes
                              that are defined by one of the
                              specified Modules.

--defined-for-requests        If specified, only list the
                              Routes that respond to one of
                              the specified Requests.

--defined-for-named-positions If specified, only list Routes that
                              are defined for one of the specified
                              Named Positions.

--defined-for-positions       If specified, only list Routes
                              that are defined for one of the
                              specified Positions.

--defined-for-files           If specified, only list Routes that
                              are defined for one of the specified
                              files.

--path-to-roady-project       The path to the relevant Roady project's
                              root directory.

                              Defaults to current directory: ./

示例

rig --list-routes

rig --list-routes --defined-for-modules "hello-world" "hello-universe"

rig --list-routes --defined-for-requests "homepage" "global"

rig --list-routes --defined-for-named-positions "roady-ui-header"

rig --list-routes --defined-for-positions "0" "3"

rig --list-routes --defined-for-files "homepage.html" "global.css"

也可以指定多个参数以进一步过滤结果。

rig --list-routes \
    --defined-for-modules "hello-world" "hello-universe" \
    --defined-for-requests "homepage" "global" \
    --defined-for-named-positions "roady-ui-header" \
    --defined-for-positions "0" "3" \
    --defined-for-files "homepage.html" "global.css"

rig --list-routes 的输出将类似于以下内容

  # Routes

 ┌───────────────────┬─────────────────────────────────────────────────────┐
 │ route-hash:       │ 016bbd46d3a3fc25c                                   │
 ├───────────────────┼─────────────────────────────────────────────────────┤
 │ defined-by-module │ hello-world                                         │
 │ responds-to       │ homepage                                            │
 │ named-positions   │ [{"position-name":"roady-ui-footer","position":10}] │
 │ relative-path     │ output/hello-world.html                             │
 └───────────────────┴─────────────────────────────────────────────────────┘


 ┌───────────────────┬────────────────────────────────────────────────────┐
 │ route-hash:       │ 6591c3e1ed38ed5eb                                  │
 ├───────────────────┼────────────────────────────────────────────────────┤
 │ defined-by-module │ hello-world                                        │
 │ responds-to       │ hello-universe, hello-world, homepage              │
 │ named-positions   │ [{"position-name":"roady-ui-header","position":3}] │
 │ relative-path     │ output/header.html                                 │
 └───────────────────┴────────────────────────────────────────────────────┘

rig --new-module

在当前 Roady 项目的 modules 目录中创建一个新的模块。

如果未指定 --no-boilerplate 标志,则将为新模块创建以下初始文件和目录。

注意:名称 NEW_MODULE_NAME 将被替换为新模块的实际名称。

localhost.8080.json
output/NEW_MODULE_NAME.html

为新建模块创建的初始文件内容为

  • output/NEW_MODULE_NAME.html
<p>Hello NEW_MODULE_NAME</p>
  • localhost.8080.json

    注意:示例 json 中的字符串 NEW_MODULE_NAME 将被替换为新模块的实际名称。

[
    {
        "module-name": "NEW_MODULE_NAME",
        "responds-to": [
            "homepage"
        ],
        "named-positions": [
            {
                "position-name": "roady-ui-main-content",
                "position": 0
            }
        ],
        "relative-path": "output\/NEW_MODULE_NAME.html"
    }
]

参数

--for-authority             If specified, create an initial Route
                            configuration file for the specified
                            domain authority.

                            Note: If the --for-authority flag is
                            not specified then an initial Route
                            configuration file will be created
                            for the authority:

                            localhost:8000

                            Note: If the --no-boilerplate flag is
                            specified and the --for-authority flag
                            is not specified then an initial Route
                            configuration file will not be created.

--no-boilerplate            If specified, do not create any
                            initial files and directories for
                            the new Module.

--module-name               The name to assign to the new Module.

--path-to-roady-project     The path to the relevant Roady project's
                            root directory.

                            Defaults to current directory: ./

示例

rig --new-module \
    --module-name hello-world

rig --new-module \
    --module-name hello-universe \
    --for-authority "www.example.com"

rig --new-module \
    --module-name hello-multiverse \
    --for-authority "localhost:8888" \
    --no-boilerplate \
    --path-to-roady-project "./"

rig --new-route

为现有模块定义一个新路由。

参数

--module-name               The name of the Module to define the new
                            Route for.

--named-positions           A json string that represents an array
                            of arrays of named positons.

                            For example:

                            [{"position-name":"roady-ui-footer","position":10}]

--path-to-roady-project     The path to the relevant Roady project's
                            root directory.

                            Defaults to current directory: ./

--relative-path             The path to the file served by the Route,
                            relative to the Module's root directory.

--responds-to               The names of the Requests the Route will
                            respond to.

示例

rig --new-route \
--module-name "hello-world" \
--named-positions '[{"position-name":"roady-ui-footer","position":10}]' \
--relative-path "output/hello-world.html" \
--responds-to "homepage" "hello-world"

rig --start-servers

在指定的端口启动一个或多个本地服务器。

如果没有指定端口,则将在端口 8080 上启动本地服务器。

服务器将在 localhost:PORT 可用,例如,使用 rig --start-server 8888 将启动一个在 localhost:8888 可访问的本地服务器。

参数

--ports           The ports to start servers on.

--open-in-browser If specified, attempt to automatically open
                  the running servers in a browser.

示例

# start server on localhost:8080
rig --start-servers

# start server on localhost:8888 and localhost:8017
rig --start-servers --ports 8888 8017

# start server on localhost:8420 and open it in a browser
rig --start-servers --ports 8420 --open-in-browser

rig --update-route

使用指定的标准更新分配给指定路由哈希的路由。

注意:路由哈希在 rig --list-routes 生成的表中显示。

参数

--module-name               The name of the Module the Route is
                            defined for.

--named-positions           A json string that represents an array
                            of arrays of named positons.

                            For example:

                            [{"position-name":"roady-ui-footer","position":10}]

--path-to-roady-project     The path to the relevant Roady project's
                            root directory.

                            Defaults to current directory: ./

--relative-path             The path to the file served by the Route,
                            relative to the Module's root directory.

--responds-to               The names of the additional Requests
                            the Route will respond to.

--route-hash                The hash of the Route to update.

示例

rig --update-route \
--module-name "hello-world" \
--named-positions '[{"position-name":"roady-ui-footer","position":10}]' \
--relative-path "output/hello-world.html" \
--responds-to "homepage" "hello-world"

rig --version

显示 rig 的版本。

注意:如果 rig 没有更新到最新版本,将显示警告信息。

示例

rig --version

rig --view-action-log

查看由 rig 运行的命令所采取的 Actions 的日志。

示例

rig --view-action-log