blocklet / blocklet-specification

Blocklet Specification Documents
Apache License 2.0
1 stars 0 forks source link

[Thread] How to define blocklet scripts #3

Open wangshijun opened 4 years ago

wangshijun commented 4 years ago

问题来源

https://github.com/blocklet/blocklet-specification/pull/1

问题描述

Blocklet 不同环境下、不同平台下需要 abtnode 帮其执行的脚本可能会有所不同,如何标准化定义?

解决方案

scripts:
    - name: "dev"
      command: "npm run dev"
    - name: "run"
      command: "/path/to/executable-linux"
      platform: "linux"
    - name: "run"
      command: "/path/to/executable-mac"
      platform: "mac"
    - name: "serve"
      command: "/path/to/executable-mac"
    - name: "build"
      command: "npm run build"
    - name: "bundle"
      command: "abtnode bundle --zip"

这么设计是为了跨平台,而如果 scripts 本身就是跨平台的,那么可以简写成:

scripts:
    dev: "npm run dev"
    run: "/path/to/executable"
    build: "npm run build"
    bundle: "abtnode bundle --zip"
    serve: "/path/to/static-folder"

之所以设计 runserve 是想把原来的 groupmain 字段给废弃掉,这样 run 就是执行这个 blocklet,而 serve 就是通过内置的 web-server 去提供静态内容。

wangshijun commented 4 years ago

https://github.com/ArcBlock/abt-node/issues/1575

mave99a commented 4 years ago

Let's keep it simple, assume all script should work across platforms.

mave99a commented 4 years ago

script is shell script, so it's possible to use environment variables, or combined commands (similar to npm, or gitpod.yml)

linchen1987 commented 4 years ago

我觉得 runserve 可以统一,当需要提供静态内容时可以采用以下两种思路

这样不但可以统一run 和 serve,在dev时也可以通过比如 dev: an serve /path/to/static-folder" 去启动dev环境

wangshijun commented 3 years ago

本周的 sprint 里面先把 scripts 和 hooks merge 起来了,engine 先保持独立,因为 engine 里面会设计到跨平台的东西,以及启动参数