lan-low-code-cli 2.4.0 → 2.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +118 -0
- package/dist/api/formDefine.js +31 -1
- package/dist/api/operation.js +27 -0
- package/dist/api/template.js +76 -0
- package/dist/api/view.js +23 -0
- package/dist/commands/form.js +181 -1
- package/dist/commands/operation.js +730 -0
- package/dist/commands/template.js +541 -0
- package/dist/index.js +9 -1
- package/package.json +2 -1
- package/skills/lan-low-code-cli/SKILL.md +264 -0
- package/skills/lan-low-code-cli/SKILL.zh-CN.md +247 -0
- package/skills/lan-low-code-cli/references/cli-contract.md +233 -0
- package/skills/lan-low-code-cli/references/cli-contract.zh-CN.md +223 -0
- package/skills/lan-low-code-cli/references/existing-app-flows.md +88 -0
- package/skills/lan-low-code-cli/references/existing-app-flows.zh-CN.md +86 -0
- package/skills/lan-low-code-cli/references/mkxform-api.md +2653 -0
- package/skills/lan-low-code-cli/references/operation-script-context.md +220 -0
- package/skills/lan-low-code-cli/scripts/self-update.mjs +252 -0
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: lan-low-code-cli
|
|
3
|
+
version: 2.6.0
|
|
4
|
+
author: Pig George
|
|
5
|
+
description: Operate the Landray low-code form engine through the `llc` CLI. Use when the user asks to create, inspect, modify, publish, or delete low-code apps and forms; generate field configs; configure layouts (grid/tabs), field permissions, options, i18n, or control actions (onChange/onLoad); or run pre-publish validation. Also use for troubleshooting form loading/rendering errors.
|
|
6
|
+
tags:
|
|
7
|
+
- low-code
|
|
8
|
+
- llc
|
|
9
|
+
- form
|
|
10
|
+
- landray
|
|
11
|
+
- cli
|
|
12
|
+
allowed-tools:
|
|
13
|
+
- Bash(llc:*)
|
|
14
|
+
- Bash(npx lan-low-code-cli:*)
|
|
15
|
+
- Bash(node scripts/self-update.mjs:*)
|
|
16
|
+
- Read
|
|
17
|
+
- Grep
|
|
18
|
+
- Glob
|
|
19
|
+
user-invocable: true
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
# llc CLI — low-code form engine operations
|
|
24
|
+
|
|
25
|
+
`llc` is a CLI that drives the Landray sys-modeling / sys-xform HTTP APIs to manage
|
|
26
|
+
business apps and form definitions **as data** (no UI required). This skill describes
|
|
27
|
+
how to use it correctly and what invariants must be preserved.
|
|
28
|
+
|
|
29
|
+
## 0. Prerequisites
|
|
30
|
+
|
|
31
|
+
### Install the CLI
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
npm i -g lan-low-code-cli # global install, provides the `llc` command
|
|
35
|
+
# mirror users: append --registry https://registry.npmjs.org/ (npm mirror syncs with ~10min delay)
|
|
36
|
+
# or without a global install: npx lan-low-code-cli <command>
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Verify: `llc -v` should print the version.
|
|
40
|
+
|
|
41
|
+
### Version check before upgrading
|
|
42
|
+
|
|
43
|
+
Before upgrading (and whenever `llc -v` does not match this skill), compare the **major** version of the
|
|
44
|
+
installed CLI with this skill's frontmatter `version:` (currently `2.4.1`):
|
|
45
|
+
|
|
46
|
+
| CLI version vs skill | Action |
|
|
47
|
+
|---|---|
|
|
48
|
+
| Same major (`2.4.1` → e.g. `2.6.0`) | **Upgrade directly**: `npm i -g lan-low-code-cli@latest`. Non-major releases keep the flags in this skill valid. |
|
|
49
|
+
| CLI major is higher (`2.x` skill vs `3.x` CLI) | A **major** version has been crossed: **this skill may be out of date**. Do not assume its flags/fields still exist — tell the user the skill may be stale and update it (see **Self-update** below) before running write operations. |
|
|
50
|
+
| CLI major is lower | The CLI is older than the skill: upgrade the CLI first (`npm i -g lan-low-code-cli@latest`); never downgrade the skill. |
|
|
51
|
+
|
|
52
|
+
When versions disagree, `llc <command> --help` wins over this file; the option list is in
|
|
53
|
+
[references/cli-contract.md](references/cli-contract.md).
|
|
54
|
+
|
|
55
|
+
### Self-update
|
|
56
|
+
|
|
57
|
+
The skill ships a zero-dependency updater (`scripts/self-update.mjs`) that keeps the skill and CLI in sync:
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
node scripts/self-update.mjs # check only (default): exit 0 compatible, 2 stale/older
|
|
61
|
+
node scripts/self-update.mjs --apply --from ./lan-low-code-cli-skill-<version>.tgz # from a skill package
|
|
62
|
+
node scripts/self-update.mjs --apply --from <dir> # from an unpacked skill directory
|
|
63
|
+
node scripts/self-update.mjs --apply --from-cli # from the installed CLI package (skills/ ships with npm)
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
- Flow: `npm i -g lan-low-code-cli@latest` → `node scripts/self-update.mjs --apply --from-cli`
|
|
67
|
+
(the npm package bundles `skills/`; older CLI versions need the upgrade first) → confirm the `version:`
|
|
68
|
+
in `SKILL.md` and re-read this file.
|
|
69
|
+
- The updater backs up the current skill to `<skill>.backup-<old>-<timestamp>` next to the folder, keeps
|
|
70
|
+
files absent from the new version (and reports them), and refuses a source lacking `SKILL.md` or with a
|
|
71
|
+
different `name`.
|
|
72
|
+
- Ask the user before `--apply` (it rewrites the skill files) and never update mid-task: finish or abort
|
|
73
|
+
the current operation first, since option names may change.
|
|
74
|
+
- Sources: `--from` accepts a `.tgz`/`.tar.gz` skill package (`lan-low-code-cli-skill-<version>.tgz`, which
|
|
75
|
+
already has a `lan-low-code-cli/` top-level folder) or an unpacked directory; `LLC_CLI` overrides the
|
|
76
|
+
`llc` executable (a `.js` entry-script path also works).
|
|
77
|
+
|
|
78
|
+
### Configure credentials
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
llc config set --base-url http://<host>/data --token <X-AUTH-TOKEN> # once
|
|
83
|
+
# or per-invocation / per environment:
|
|
84
|
+
# --base-url / --token flags, or LLC_BASE_URL / LLC_TOKEN env vars
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
Always run `llc <command> --help` before inventing flags — the CLI is the source of truth.
|
|
88
|
+
|
|
89
|
+
## 1. Command map
|
|
90
|
+
|
|
91
|
+
| Command | Purpose |
|
|
92
|
+
|---|---|
|
|
93
|
+
| `llc app list / create / forms / delete / delete-data` | business apps (`--code` allows letters/digits/hyphen only, **no underscore**) |
|
|
94
|
+
| `llc form create / list / get / publish / autofill / delete / delete-data` | form lifecycle; `create --type category\|simpleCategory` builds a category form (no business fields; templates are created in the platform designer) |
|
|
95
|
+
| `llc field list / gen-key / library` | available fields |
|
|
96
|
+
| `llc operation list / get / create / update / delete / attach / detach` | form business operations (link, script, dialog), including attaching to list/view pages |
|
|
97
|
+
| `llc template list / create / add-fields / delete` | category-form templates: create/append/delete templates, porting fields/views/permissions from an existing form (auto category node, bypasses official init) |
|
|
98
|
+
| `llc control list / show` | controls installed in the environment (basis for `--add-field` third segment) |
|
|
99
|
+
| `llc locale list` | languages with translations available (from control i18n resources) |
|
|
100
|
+
| `llc config set / show / clear` | global credentials and defaults |
|
|
101
|
+
|
|
102
|
+
> Full per-command options, spec-string syntax and exit codes: **§7 CLI contract**. When in doubt, `llc <command> --help` is authoritative.
|
|
103
|
+
>
|
|
104
|
+
> Runtime `context` of operation scripts (selected rows, list refresh, query, navigation, event bus,
|
|
105
|
+
> `window.MKXFORM`) is documented in [references/operation-script-context.md](references/operation-script-context.md) (Chinese).
|
|
106
|
+
|
|
107
|
+
## 2. Core workflow
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
# 1. create app (returns appId)
|
|
111
|
+
llc app create --name 客户管理 --code crm
|
|
112
|
+
|
|
113
|
+
# 2. create form, generate field config, publish
|
|
114
|
+
llc form create --name 客户信息 --app-id <appId> --publish \
|
|
115
|
+
--add-field "fd_col_name:客户名称" \
|
|
116
|
+
--add-field "fd_col_level:客户等级:select" \
|
|
117
|
+
--option "fd_col_level=A级,B级,C级" \
|
|
118
|
+
--detail "联系人明细=fd_pname:姓名,fd_pphone:电话:phoneNumber" \
|
|
119
|
+
--layout tabs --tabs "基本信息:fd_col_name,fd_col_level" --tab-layout grid --grid-columns 3 \
|
|
120
|
+
--required "fd_col_name" --readonly "fd_col_code" --hidden "fd_col_inner"
|
|
121
|
+
|
|
122
|
+
# 3. iterate (all layout options are optional — see §3)
|
|
123
|
+
llc form autofill --id <fdId> --apply --publish
|
|
124
|
+
|
|
125
|
+
# 4. verify
|
|
126
|
+
llc app forms --id <appId>
|
|
127
|
+
llc form get --id <fdId> --with-config
|
|
128
|
+
|
|
129
|
+
# 5. rollback / cleanup (both need --yes)
|
|
130
|
+
llc form delete --id <fdId> --yes
|
|
131
|
+
llc app delete --id <appId> --yes
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### Modifying an existing app / adding forms
|
|
135
|
+
|
|
136
|
+
Working on apps/forms that already exist (inspect, add a form under an existing app,
|
|
137
|
+
iterate a form, adjust permissions, backfill i18n, rollback) follows the same commands —
|
|
138
|
+
read [references/existing-app-flows.md](references/existing-app-flows.md) before doing so.
|
|
139
|
+
|
|
140
|
+
## 3. Invariants and pitfalls (violating these breaks forms in the designer)
|
|
141
|
+
|
|
142
|
+
1. **Layout preservation**. `form autofill` WITHOUT `--layout` reuses the existing
|
|
143
|
+
`viewModel` untouched (grid/tabs layouts survive). Only an explicit `--layout`
|
|
144
|
+
rebuilds the render tree. Fields added via `--add-field` are NOT in the old layout —
|
|
145
|
+
the CLI warns; pass `--layout` (e.g. `--layout grid --grid-columns 3`) to place them.
|
|
146
|
+
2. **Draft regression**. Saving via autofill sets the form to draft state. Add
|
|
147
|
+
`--publish` to keep it official. `llc form publish --id <fdId>` publishes later.
|
|
148
|
+
3. **messageKey format**. i18n keys must be `!{<base36>}` (no hyphens) — the designer
|
|
149
|
+
matches them with `/\!\{([\w\.]*)\}/`. The CLI generates correct keys; never invent keys manually.
|
|
150
|
+
4. **Default value mode**. New fields use `defaultValueType: "null"`. NEVER write
|
|
151
|
+
`"formula"` without also providing `defaultValueFormulaVO`
|
|
152
|
+
(`{script, type:'Eval', vo:{mode:'formula', content}}` in `fdFontExtendData`) —
|
|
153
|
+
the designer blocks submit with a required prompt.
|
|
154
|
+
5. **Pre-publish validation**. CLI validates required control props before save/publish
|
|
155
|
+
(aligned with the designer, including conditional requireds like
|
|
156
|
+
`defaultValueType='formula'` → `defaultValueFormulaVO`). Failures abort with exit 1;
|
|
157
|
+
`--force` skips. Prefer fixing values over forcing.
|
|
158
|
+
6. **Labels default to horizontal layout** (`labelProps.layout: 'horizontal'`).
|
|
159
|
+
7. **Data-dictionary options** (`messageKey` like `${sys-xform:enum.*}`) are static
|
|
160
|
+
i18n resources — never rewrite them into `lang`.
|
|
161
|
+
8. **Deleting** requires `--yes`; `form delete` removes the data model too (irreversible).
|
|
162
|
+
|
|
163
|
+
## 4. i18n
|
|
164
|
+
|
|
165
|
+
```bash
|
|
166
|
+
llc form autofill --id <fdId> --apply --publish --locale all --lang-file ./lang.json
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
- `--locale` is comma-separated; **first entry is the primary language** (`all` = `Cn,Us,Tw`).
|
|
170
|
+
- `lang.json`: `{ "Us": { "姓名": "Name" }, "Tw": { "金额": "金額" } }` —
|
|
171
|
+
matched by field label, then field name; for options also `fdName#value`.
|
|
172
|
+
- Missing translations fall back to the primary text (never blank).
|
|
173
|
+
- `llc locale list` shows which languages actually have translations in the environment.
|
|
174
|
+
|
|
175
|
+
## 5. Control actions (onChange / onLoad / …)
|
|
176
|
+
|
|
177
|
+
```bash
|
|
178
|
+
llc form autofill --id <fdId> --apply --publish \
|
|
179
|
+
--action "fd_col_a:onChange:function onChange(value){ MKXFORM.setValue('表名.fd_col_b', value) }" \
|
|
180
|
+
--action-file ./actions.json
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
- Target is the field `fdName`; `$global` targets form-level events
|
|
184
|
+
(`onLoad` / `onBeforeSubmit` / `onAfterSubmit` only).
|
|
185
|
+
- **Which events a control supports**: the CLI has no whitelist and does not validate them (any identifier
|
|
186
|
+
is accepted), so an unsupported event saves fine but never fires. Confirm in this order: the designer's
|
|
187
|
+
"控件动作" event dropdown (authoritative) → `llc control show --element <pkg> --json`, i.e. event
|
|
188
|
+
declarations in `meta` if the package has any (not shown in human output) → the keys of
|
|
189
|
+
`controlAction.control['<table>.<uuid>']` on an existing form. See §8 of
|
|
190
|
+
[references/cli-contract.md](references/cli-contract.md).
|
|
191
|
+
- `source` is function **source code** (evaluated via
|
|
192
|
+
`new Function('MKXFORM', 'return (fn)')`); `@path` reads it from a file.
|
|
193
|
+
- Storage: `fdConfig.attribute.formAttr.controlAction.control['<table>.<uuid>'][<event>]`.
|
|
194
|
+
- Existing actions (and form rules) are preserved on autofill.
|
|
195
|
+
- **Naming convention**: control-level actions must not use bare event names (`onChange`, …) —
|
|
196
|
+
the CLI auto-renames them to `onChange_<fdName>` and rewrites the function declaration in the source.
|
|
197
|
+
`$global` actions keep the bare event name (e.g. `onLoad`). Provide suffixed names directly to avoid the warning.
|
|
198
|
+
- **Full runtime API reference**: see [references/mkxform-api.md](references/mkxform-api.md) (Chinese) — setValue/getValue, detail-table APIs, events, modals, ajax, org/flow helpers, etc.
|
|
199
|
+
|
|
200
|
+
## 6. Control types (including advanced controls)
|
|
201
|
+
|
|
202
|
+
**Always inspect the environment first**: `llc control list` (desktop/mobile packages, data type,
|
|
203
|
+
registered / option support), `llc control show --type <type>` for property defaults.
|
|
204
|
+
|
|
205
|
+
`--add-field "fdName:label[:dataType][:controlType]"` — put the control type in the 3rd/4th token:
|
|
206
|
+
|
|
207
|
+
```bash
|
|
208
|
+
llc form autofill --id <fdId> --apply --publish \
|
|
209
|
+
--add-field "fd_note:Description:desc" \
|
|
210
|
+
--add-field "fd_tag:Tags:tags" \
|
|
211
|
+
--add-field "fd_code:Platform No.:mechnumber"
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
- 64 of the environment's 67 `kind=control` controls are registered (`CONTROL_TYPE_MAP`):
|
|
215
|
+
base controls plus advanced ones (`desc`/`interval`/`button`/`html`/`iframe`/`review`/`timeAxis`/
|
|
216
|
+
`associatedFields`/`serial-number`, numbering `mechnumber`/`manualNumber`/`reserveNumber`,
|
|
217
|
+
data `association`/`mdm`/`cfg`/`dynamic`/`tags`/`location`/`area`/`calculate`/`fileEdit`/
|
|
218
|
+
`invoice`/`ocr`/`template`/`ikm-*`, …).
|
|
219
|
+
- **Org / people fields use `address`** — the **address book** control (person / org / dept / post /
|
|
220
|
+
user-group picker), *not* a plain address text field. It stores `fdDataType=address` with
|
|
221
|
+
`fdDictType=orgElementDict`; defaults are “all range + person only + single select”.
|
|
222
|
+
`org.orgTypeArr` is a code array: `1` org, `2` dept, `4` post, `8` person, `16` user group,
|
|
223
|
+
`256` person identity (only when the platform enables multiple identities). **Set the selectable
|
|
224
|
+
types with `--org-type`** (`"field=部门,个人"`; codes `1/2/4/8/16/256`, English aliases and `all`
|
|
225
|
+
also work); `multi` toggles multi-select, `range` selects the scope (`all` / `custom`).
|
|
226
|
+
Its settings live in both `controlProps` and `fdFontExtendData`, which the CLI keeps in sync.
|
|
227
|
+
- **Related-data controls**: `relation` (**business relation**) is marked **deprecated** by the
|
|
228
|
+
platform (`xform.group=deprecated`). Its property panel is assembled by the designer (the control
|
|
229
|
+
package ships no required props), and the mandatory items are **关联表单 / business object**
|
|
230
|
+
(`relationCfg`) plus **datasource display columns** (`datasource.columns`), with card / navigation /
|
|
231
|
+
tree-level rules for those render modes — the CLI now validates these and blocks a bare skeleton
|
|
232
|
+
(exit code 1); prefer `association`. **Configure it with `--relation`**, which resolves the business
|
|
233
|
+
object / display value / display columns and writes `relationCfg` + `datasource`:
|
|
234
|
+
`llc form autofill --id <fdId> --apply --publish --relation "fd_x=TargetFormName[:显示值=field][:显示项=field1,field2]"`. `relationQuery` (needs `tabs`),
|
|
235
|
+
`association` (needs `xlistColumn`), `foreignKey` (needs `mappedType`), `refTemplate` and
|
|
236
|
+
`associatedFields` all require picking a business object / datasource in the designer (the CLI only
|
|
237
|
+
creates the skeleton; once configured, `autofill` preserves those settings).
|
|
238
|
+
`llc control list` marks them `已废弃` / `需设计器配置`.
|
|
239
|
+
- **Placeholder (prompt text)**: the CLI fills a default per control — the lang resource key differs
|
|
240
|
+
by widget (`@elem/xform-datetime`/`timepicker` use `pleaseEnter` → 请选择日期/请选择时间,
|
|
241
|
+
`m-datetime` uses `enter`, `area` uses `pleaseSelect`, others use `placeholder` → 请输入/请选择).
|
|
242
|
+
An existing placeholder (designer-customised text plus its `lang` entry) is **kept as is**.
|
|
243
|
+
- **Element** controls (`desc`/`html`/`interval`/…) have `fdIsStored=false`: they are written into
|
|
244
|
+
`dataModel` but create no physical column.
|
|
245
|
+
- **Containers** (`detail`/`bigDetail`/`paged`) are not data fields: use `--detail` for detail tables;
|
|
246
|
+
the other two are unsupported (no usage samples in the environment).
|
|
247
|
+
- Controls that need **designer configuration** (association range, master data, config item,
|
|
248
|
+
numbering rule, OCR type, …) are created as skeletons only: the CLI warns, and pre-publish
|
|
249
|
+
validation blocks unless fixed (`--force` skips it, but the control still needs configuration).
|
|
250
|
+
`associatedFields` is special: no required props, yet publishing **fails with HTTP 500** until its
|
|
251
|
+
associated source field is set in the designer.
|
|
252
|
+
- **Unregistered controls are protected**: a platform-added/custom widget package is no longer
|
|
253
|
+
downgraded to a text input by `autofill` — the CLI restores the package from the field's existing
|
|
254
|
+
attribute and keeps `fdType`.
|
|
255
|
+
|
|
256
|
+
## 7. CLI contract
|
|
257
|
+
|
|
258
|
+
Full command tree, options, spec-string syntax, config precedence and exit codes live in a dedicated file:
|
|
259
|
+
[references/cli-contract.md](references/cli-contract.md).
|
|
260
|
+
|
|
261
|
+
Quick facts: `llc <group> <subcommand> [options]`; multi-level help `llc help form create`;
|
|
262
|
+
credentials precedence `--base-url`/`--token` > `LLC_BASE_URL`/`LLC_TOKEN` > project `lcode.config.json` >
|
|
263
|
+
global `~/.lcode/config.json`; exit codes `0` success / `1` failure; delete commands need `--yes`;
|
|
264
|
+
`form autofill` without `--apply` only previews.
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: lan-low-code-cli
|
|
3
|
+
version: 2.6.0
|
|
4
|
+
author: Pig George
|
|
5
|
+
description: 通过 `llc` CLI 操作蓝凌低代码表单引擎。适用于:创建、查看、修改、发布或删除低代码应用与表单;生成字段配置;配置布局(栅格/页签)、字段权限、选项、多语言、控件动作(onChange/onLoad);或执行发布前校验、排查表单加载/渲染报错。
|
|
6
|
+
tags:
|
|
7
|
+
- low-code
|
|
8
|
+
- llc
|
|
9
|
+
- form
|
|
10
|
+
- landray
|
|
11
|
+
- cli
|
|
12
|
+
allowed-tools:
|
|
13
|
+
- Bash(llc:*)
|
|
14
|
+
- Bash(npx lan-low-code-cli:*)
|
|
15
|
+
- Bash(node scripts/self-update.mjs:*)
|
|
16
|
+
- Read
|
|
17
|
+
- Grep
|
|
18
|
+
- Glob
|
|
19
|
+
user-invocable: true
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
# llc CLI —— 低代码表单引擎操作
|
|
24
|
+
|
|
25
|
+
`llc` 是驱动蓝凌 sys-modeling / sys-xform HTTP 接口的命令行工具,
|
|
26
|
+
以**数据方式**管理业务应用与表单定义(无需 UI)。本文件说明如何正确使用,
|
|
27
|
+
以及哪些不变量必须保持。
|
|
28
|
+
|
|
29
|
+
## 0. 前置条件
|
|
30
|
+
|
|
31
|
+
### 安装 CLI
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
npm i -g lan-low-code-cli # 全局安装,获得 `llc` 命令
|
|
35
|
+
# 镜像用户:追加 --registry https://registry.npmjs.org/(npm 镜像同步延迟约 10 分钟)
|
|
36
|
+
# 或不全局安装,直接用:npx lan-low-code-cli <命令>
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
验证:`llc -v` 应输出版本号。
|
|
40
|
+
|
|
41
|
+
### 升级前的版本校验
|
|
42
|
+
|
|
43
|
+
升级前(以及 `llc -v` 与本 skill 版本不一致时),先用 CLI 的**大版本**对比本文件 frontmatter 的
|
|
44
|
+
`version:`:
|
|
45
|
+
|
|
46
|
+
| CLI 版本 vs skill | 处理 |
|
|
47
|
+
|---|---|
|
|
48
|
+
| 同一大版本(`2.4.1` → 如 `2.6.0`) | **直接升级**:`npm i -g lan-low-code-cli@latest`。非大版本升级不影响本 skill 的参数与写法。 |
|
|
49
|
+
| CLI 大版本更高(skill `2.x` vs CLI `3.x`) | 已**跨大版本**:**本 skill 可能已过期**。不要假设其中的参数/字段仍然有效——告知用户 skill 可能过期,按下方**自更新**更新后再执行写操作。 |
|
|
50
|
+
| CLI 大版本更低 | CLI 比 skill 旧:先升级 CLI(`npm i -g lan-low-code-cli@latest`),不要把 skill 降级。 |
|
|
51
|
+
|
|
52
|
+
版本不一致时,以 `llc <command> --help` 为准;完整选项见
|
|
53
|
+
[references/cli-contract.zh-CN.md](references/cli-contract.zh-CN.md)。
|
|
54
|
+
|
|
55
|
+
### 自更新
|
|
56
|
+
|
|
57
|
+
技能自带零依赖更新脚本(`scripts/self-update.mjs`),用于让技能与 CLI 保持同版本:
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
node scripts/self-update.mjs # 仅检查(默认):0 一致,2 过期/落后
|
|
61
|
+
node scripts/self-update.mjs --apply --from ./lan-low-code-cli-skill-<version>.tgz # 用技能发行包更新
|
|
62
|
+
node scripts/self-update.mjs --apply --from <目录> # 用已解压的技能目录更新
|
|
63
|
+
node scripts/self-update.mjs --apply --from-cli # 从已安装的 CLI 包内取(npm 包已内置 skills/)
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
- 流程:`npm i -g lan-low-code-cli@latest` → `node scripts/self-update.mjs --apply --from-cli`
|
|
67
|
+
(npm 包已随包分发 `skills/`,旧版本需先升级 CLI)→ 确认 `SKILL.md` 的 `version:` 并重新读取本文件。
|
|
68
|
+
- 更新脚本会把当前技能备份到同级目录 `<技能目录>.backup-<旧版本>-<时间戳>`;新版本中不存在的文件
|
|
69
|
+
**保留并提示**;来源缺少 `SKILL.md` 或 `name` 不一致时拒绝执行。
|
|
70
|
+
- 执行 `--apply` 前先征得用户同意(会改写技能文件);不要在任务中途更新——先完成或放弃当前操作,
|
|
71
|
+
避免参数变更导致半途失败。
|
|
72
|
+
- 来源:`--from` 支持 `.tgz`/`.tar.gz` 技能包(`lan-low-code-cli-skill-<version>.tgz`,包内顶层目录为
|
|
73
|
+
`lan-low-code-cli/`)或已解压目录;`LLC_CLI` 可指定 `llc` 可执行文件或 CLI 入口脚本路径。
|
|
74
|
+
|
|
75
|
+
### 配置凭据
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
llc config set --base-url http://<host>/data --token <X-AUTH-TOKEN> # 一次即可
|
|
80
|
+
# 或按次/按环境覆盖:
|
|
81
|
+
# --base-url / --token 参数,或 LLC_BASE_URL / LLC_TOKEN 环境变量
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
使用前先执行 `llc <command> --help` 查看可用参数——CLI 本身是唯一事实来源。
|
|
85
|
+
|
|
86
|
+
## 1. 命令一览
|
|
87
|
+
|
|
88
|
+
| 命令 | 用途 |
|
|
89
|
+
|---|---|
|
|
90
|
+
| `llc app list / create / forms / delete / delete-data` | 业务应用(`--code` 仅允许字母/数字/连字符,**不允许下划线**) |
|
|
91
|
+
| `llc form create / list / get / publish / autofill / delete / delete-data` | 表单生命周期;`create --type category\|simpleCategory` 建分类表单(无业务字段,模板需在平台设计器创建) |
|
|
92
|
+
| `llc field list / gen-key / library` | 可用字段 |
|
|
93
|
+
| `llc operation list / get / create / update / delete / attach / detach` | 表单业务操作(链接、脚本、对话框),含挂载到列表/查看视图 |
|
|
94
|
+
| `llc template list / create / add-fields / delete` | 分类表单模板:创建模板并把既有表单的字段/视图/权限移植进来,追加字段,或清理模板(自动建分类节点、跳过官方 init) |
|
|
95
|
+
| `llc control list / show` | 环境已安装控件(`--add-field` 第三段的取值依据) |
|
|
96
|
+
| `llc locale list` | 环境中有现成译文的语言(来自控件多语言资源) |
|
|
97
|
+
| `llc config set / show / clear` | 全局凭据与默认值 |
|
|
98
|
+
|
|
99
|
+
> 每个命令的完整参数、规格字符串语法与退出码见**第 7 节 CLI 契约**;不确定时以 `llc <命令> --help` 为准。
|
|
100
|
+
>
|
|
101
|
+
> 业务操作「脚本模式」的运行时 `context`(选中数据、刷新列表、查询、跳转、事件总线、`window.MKXFORM`)
|
|
102
|
+
> 见 [references/operation-script-context.md](references/operation-script-context.md)。
|
|
103
|
+
|
|
104
|
+
## 2. 核心流程
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
# 1. 创建应用(返回 appId)
|
|
108
|
+
llc app create --name 客户管理 --code crm
|
|
109
|
+
|
|
110
|
+
# 2. 创建表单、生成字段配置并发布
|
|
111
|
+
llc form create --name 客户信息 --app-id <appId> --publish \
|
|
112
|
+
--add-field "fd_col_name:客户名称" \
|
|
113
|
+
--add-field "fd_col_level:客户等级:select" \
|
|
114
|
+
--option "fd_col_level=A级,B级,C级" \
|
|
115
|
+
--detail "联系人明细=fd_pname:姓名,fd_pphone:电话:phoneNumber" \
|
|
116
|
+
--layout tabs --tabs "基本信息:fd_col_name,fd_col_level" --tab-layout grid --grid-columns 3 \
|
|
117
|
+
--required "fd_col_name" --readonly "fd_col_code" --hidden "fd_col_inner"
|
|
118
|
+
|
|
119
|
+
# 3. 迭代调整(布局参数可选——见第 3 节)
|
|
120
|
+
llc form autofill --id <fdId> --apply --publish
|
|
121
|
+
|
|
122
|
+
# 4. 校验
|
|
123
|
+
llc app forms --id <appId>
|
|
124
|
+
llc form get --id <fdId> --with-config
|
|
125
|
+
|
|
126
|
+
# 5. 回滚 / 清理(均需 --yes)
|
|
127
|
+
llc form delete --id <fdId> --yes
|
|
128
|
+
llc app delete --id <appId> --yes
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### 修改现有应用 / 增加表单
|
|
132
|
+
|
|
133
|
+
对已存在的应用与表单做改动(查看、向既有应用加表单、迭代修改表单、调整权限、补齐多语言、回滚清理)
|
|
134
|
+
使用同一批命令——动手前先阅读 [references/existing-app-flows.zh-CN.md](references/existing-app-flows.zh-CN.md)。
|
|
135
|
+
|
|
136
|
+
## 3. 不变量与易错点(违反会导致设计器中表单异常)
|
|
137
|
+
|
|
138
|
+
1. **布局保护**。`form autofill` **不带 `--layout`** 时原样沿用现有 `viewModel`
|
|
139
|
+
(栅格/页签布局不动);只有显式传 `--layout` 才重建渲染树。
|
|
140
|
+
`--add-field` 新增的字段不在旧布局中——CLI 会告警;
|
|
141
|
+
需展示时传 `--layout`(如 `--layout grid --grid-columns 3`)。
|
|
142
|
+
2. **草稿回归**。autofill 保存后表单变为草稿态,加 `--publish` 保持发布态;
|
|
143
|
+
也可稍后用 `llc form publish --id <fdId>` 单独发布。
|
|
144
|
+
3. **messageKey 格式**。多语言 key 必须是 `!{<base36>}`(不含连字符)——
|
|
145
|
+
设计器用 `/\!\{([\w\.]*)\}/` 匹配。CLI 会生成合法 key,禁止手工拼 key。
|
|
146
|
+
4. **初始值模式**。新建字段默认 `defaultValueType: "null"`。禁止只写 `"formula"`
|
|
147
|
+
而不提供 `defaultValueFormulaVO`(`fdFontExtendData` 中的
|
|
148
|
+
`{script, type:'Eval', vo:{mode:'formula', content}}`)——设计器提交会被必填拦截。
|
|
149
|
+
5. **发布前校验**。CLI 在保存/发布前校验控件必填属性(对齐设计器,
|
|
150
|
+
含条件必填:`defaultValueType='formula'` → `defaultValueFormulaVO`)。
|
|
151
|
+
失败即中止(退出码 1);`--force` 可跳过,但应优先修正属性值。
|
|
152
|
+
6. **标题默认左右布局**(`labelProps.layout: 'horizontal'`)。
|
|
153
|
+
7. **数据字典选项**(`messageKey` 形如 `${sys-xform:enum.*}`)走平台静态多语言,
|
|
154
|
+
禁止改写入 `lang`。
|
|
155
|
+
8. **删除**需 `--yes`;`form delete` 连同数据模型一并删除(不可逆)。
|
|
156
|
+
|
|
157
|
+
## 4. 多语言
|
|
158
|
+
|
|
159
|
+
```bash
|
|
160
|
+
llc form autofill --id <fdId> --apply --publish --locale all --lang-file ./lang.json
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
- `--locale` 逗号分隔,**第一个为主语言**(`all` = `Cn,Us,Tw`)。
|
|
164
|
+
- `lang.json`:`{ "Us": { "姓名": "Name" }, "Tw": { "金额": "金額" } }`——
|
|
165
|
+
按「字段标题」再按「字段名」匹配;选项支持 `字段名#选项值` 精确匹配。
|
|
166
|
+
- 未命中的翻译回落主语言文案(不会出现空白标题)。
|
|
167
|
+
- `llc locale list` 查看环境中实际有译文的语言。
|
|
168
|
+
|
|
169
|
+
## 5. 控件动作(onChange / onLoad / …)
|
|
170
|
+
|
|
171
|
+
```bash
|
|
172
|
+
llc form autofill --id <fdId> --apply --publish \
|
|
173
|
+
--action "fd_col_a:onChange:function onChange(value){ MKXFORM.setValue('表名.fd_col_b', value) }" \
|
|
174
|
+
--action-file ./actions.json
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
- 目标为字段物理名;`$global` 表示表单级事件
|
|
178
|
+
(仅 `onLoad` / `onBeforeSubmit` / `onAfterSubmit`)。
|
|
179
|
+
- **控件支持哪些事件**:CLI 不内置白名单、也不校验(只要求标识符),写错不会报错但不会触发。
|
|
180
|
+
按序确认:设计器「控件动作」事件下拉(权威)→ `llc control show --element <pkg> --json` 的 `meta`
|
|
181
|
+
(若包内声明了事件;人类可读输出不展示)→ 已有表单 `controlAction.control['<表名>.<uuid>']` 的键名。
|
|
182
|
+
详见 [references/cli-contract.zh-CN.md](references/cli-contract.zh-CN.md) 第 8 节。
|
|
183
|
+
- `source` 是函数**源码**(运行时经 `new Function('MKXFORM', 'return (fn)')` 求值);
|
|
184
|
+
`@路径` 表示从文件读取。
|
|
185
|
+
- 落库位置:`fdConfig.attribute.formAttr.controlAction.control['<表名>.<uuid>'][<事件>]`。
|
|
186
|
+
- autofill 会保留已有动作与表单规则。
|
|
187
|
+
- **命名规范**:控件级动作禁止裸事件名(`onChange` 等)——CLI 自动规范为
|
|
188
|
+
`onChange_<控件id>` 并同步重写函数源码声明;`$global` 全局动作保持裸事件名(如 `onLoad`)。
|
|
189
|
+
直接带后缀命名可避免告警。
|
|
190
|
+
- **完整运行时 API 参考**:见 [references/mkxform-api.md](references/mkxform-api.md) ——setValue/getValue、明细表系列 API、事件、弹窗、ajax、组织/流程助手等。
|
|
191
|
+
|
|
192
|
+
## 6. 控件类型(含高级控件)
|
|
193
|
+
|
|
194
|
+
**先查环境再选控件**:`llc control list`(含桌面/移动端包、数据项类型、是否已登记、是否支持选项),
|
|
195
|
+
`llc control show --type <类型>` 看属性面板默认值。
|
|
196
|
+
|
|
197
|
+
`--add-field "字段名:标题[:数据项类型][:控件类型]"` 第三/四个 token 写控件类型即可创建高级控件:
|
|
198
|
+
|
|
199
|
+
```bash
|
|
200
|
+
llc form autofill --id <fdId> --apply --publish \
|
|
201
|
+
--add-field "fd_note:说明文字:desc" \
|
|
202
|
+
--add-field "fd_tag:标签:tags" \
|
|
203
|
+
--add-field "fd_code:平台编码:mechnumber"
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
- 环境 67 个 `kind=control` 控件中 **64 个已登记**(`CONTROL_TYPE_MAP`):
|
|
207
|
+
基础控件 + 高级控件(`desc`/`interval`/`button`/`html`/`iframe`/`review`/`timeAxis`/
|
|
208
|
+
`associatedFields`/`serial-number`、编号类 `mechnumber`/`manualNumber`/`reserveNumber`、
|
|
209
|
+
数据类 `association`/`mdm`/`cfg`/`dynamic`/`tags`/`location`/`area`/`calculate`/`fileEdit`/
|
|
210
|
+
`invoice`/`ocr`/`template`/`ikm-*` …)。
|
|
211
|
+
- **组织人员字段用 `address`(地址本)**——它不是「地址文本」,而是选人/选组织/部门/岗位的
|
|
212
|
+
控件(`fdDictType=orgElementDict`,落库 `fdDataType=address`)。默认「全部范围 + 仅个人 + 单选」;
|
|
213
|
+
`org.orgTypeArr` 是编码数组:`1`机构、`2`部门、`4`岗位、`8`个人、`16`常用群组、`256`人员身份
|
|
214
|
+
(仅开启「多身份」时可选)。**用 `--org-type` 指定可选类型**(`"字段名=部门,个人"`,也支持编码
|
|
215
|
+
`1/2/4/8/16/256`、英文别名与 `all`);`multi` 控制多选、`range` 控制范围(`all`/`custom`)。
|
|
216
|
+
这类字段的配置在 `controlProps` 与 `fdFontExtendData` 两处并存,CLI 会同步维护。
|
|
217
|
+
- **关联类控件**:`relation`(**业务关联**)被平台标记**废弃**(`xform.group=deprecated`),
|
|
218
|
+
其属性面板由设计器拼装(控件包无必填属性),**必填项为「关联表单(业务对象)」+「数据源显示项」**
|
|
219
|
+
(另有卡片/导航/树层级按显示方式要求)——CLI 已按设计器规则做语义校验,裸字段会被拦截(退出码 1),
|
|
220
|
+
新表单建议改用 `association`;
|
|
221
|
+
**用 `--relation` 可直接配置**(自动解析业务对象/显示值/显示项并写入 `relationCfg`+`datasource`):
|
|
222
|
+
`llc form autofill --id <fdId> --apply --publish --relation "fd_x=目标表单名[:显示值=字段][:显示项=字段1,字段2]"`;
|
|
223
|
+
`relationQuery`(需 `tabs`)、`association`(需 `xlistColumn`)、`foreignKey`(需 `mappedType`)、
|
|
224
|
+
`refTemplate`、`associatedFields` 都必须在设计器里选好业务对象/数据源(CLI 只建骨架,
|
|
225
|
+
选了之后 `autofill` 会原样保留)。`llc control list` 的 `备注` 会标注「已废弃」「需设计器配置」。
|
|
226
|
+
- **提示文字(placeholder)**:CLI 会按控件的资源键补默认文案(资源键因控件而异——
|
|
227
|
+
`@elem/xform-datetime`/`timepicker` 用 `pleaseEnter`→「请选择日期/请选择时间」、
|
|
228
|
+
`m-datetime` 用 `enter`、`area` 用 `pleaseSelect`、其余用 `placeholder`→「请输入/请选择」);
|
|
229
|
+
字段已有提示文字(含设计器自定义文案与其 `lang` 条目)会**原样保留**。
|
|
230
|
+
- **元素类**控件(`desc`/`html`/`interval`…)`fdIsStored=false`:写入 `dataModel` 但不建物理列。
|
|
231
|
+
- **容器类**(`detail`/`bigDetail`/`paged`)不是数据项:明细表用 `--detail`,
|
|
232
|
+
另两个暂不支持(环境无使用样例)。
|
|
233
|
+
- **需设计器补配置**的控件(关联范围、主数据、配置项、编号规则、识别类型…)CLI 只建骨架:
|
|
234
|
+
生成时会提示,发布前校验会拦截(`--force` 可跳过,但控件仍需人工补配置)。
|
|
235
|
+
特例 `associatedFields`:无必填属性,但未配置关联源时**后端发布会 500**。
|
|
236
|
+
- **未登记控件受保护**:平台新增/定制控件包不会被 `autofill` 降级成输入框——
|
|
237
|
+
CLI 从字段已有属性还原控件包并保留 `fdType`。
|
|
238
|
+
|
|
239
|
+
## 7. CLI 契约
|
|
240
|
+
|
|
241
|
+
完整命令树、选项、规格字符串语法、配置优先级与退出码单独维护:
|
|
242
|
+
[references/cli-contract.zh-CN.md](references/cli-contract.zh-CN.md)。
|
|
243
|
+
|
|
244
|
+
速记:`llc <命令组> <子命令> [选项]`;多级帮助 `llc help form create`;凭据优先级
|
|
245
|
+
`--base-url`/`--token` > `LLC_BASE_URL`/`LLC_TOKEN` > 项目 `lcode.config.json` > 全局 `~/.lcode/config.json`;
|
|
246
|
+
退出码 `0` 成功、`1` 失败;删除类命令需 `--yes`;`form autofill` 不加 `--apply` 只预览。
|
|
247
|
+
|