feat(cli): support --dependencies for script actions

- action add/update: new --dependencies <json> option
- parseDependencies accepts JSON, name@version shorthand, or bare names
- update is incremental; --dependencies replaces the whole array
- docs: deployment/systemd.md + skill SKILL/action-types/development
  document the npm-deps feature and the service-PATH requirement
  (spawn npm ENOENT without nvm bin dir on PATH)
This commit is contained in:
yeuimu
2026-08-11 05:51:27 +00:00
parent aff4d70b71
commit cf25c8ff93
5 changed files with 213 additions and 35 deletions
@@ -50,6 +50,21 @@ inkreach-teable action add <wfId> --type script \
inkreach-teable action add <wfId> --type script --code-file ./my-script.js --timeout 120000
```
**With npm dependencies** (installed into a sandbox cache, then `require()`-able):
```bash
# JSON form (recommended)
inkreach-teable action add <wfId> --type script \
--code-file ./sync.js \
--dependencies '[{"name":"axios","version":"1.6.0"},{"name":"dayjs","version":"1.11.10"}]'
# shorthand: name@version,name (version omitted → 'latest')
inkreach-teable action add <wfId> --type script --code-file ./sync.js --dependencies 'axios@1.6.0,dayjs'
# replace / clear deps on an existing node
inkreach-teable action update <wfId> <nodeId> --dependencies '[{"name":"axios"}]'
inkreach-teable action update <wfId> <nodeId> --dependencies '[]' # clear
```
> ⚠️ **Deployment requirement**: the backend installs deps via `spawn('npm')`, so `npm` must be on the **service** PATH. systemd user units default to a PATH that omits the nvm bin dir → scripts with deps fail with `spawn npm ENOENT`. Fix: add `Environment=PATH=<nvm-bin>:/usr/local/sbin:...` to `teable-backend.service` (see [deployment/systemd.md](../../../../deployment/systemd.md) Troubleshooting).
**Config:**
```json
{
@@ -59,7 +74,7 @@ inkreach-teable action add <wfId> --type script --code-file ./my-script.js --tim
}
```
- `timeout`: default 60000 (120000 in batch mode).
- `dependencies`: optional npm packages; `require('axios')` works in-sandbox.
- `dependencies`: optional npm packages; `require('axios')` works in-sandbox. Install is cached by `name@version` hash; first run downloads, later runs reuse. CLI accepts JSON `[{"name","version?"}]` or shorthand `name@version,name`. `update` replaces the whole array (not append).
**Output:**
```json