kintone-migrator 0.4.1 → 0.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 +271 -4
- package/dist/index.mjs +1552 -211
- package/package.json +11 -8
package/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# kintone-migrator
|
|
2
2
|
|
|
3
|
-
A CLI tool for migrating kintone form schemas.
|
|
3
|
+
A CLI tool for migrating kintone form schemas and seed data.
|
|
4
4
|
|
|
5
|
-
Compares a YAML-defined schema file against an actual kintone app form, providing diff detection, migration, schema capture, and more.
|
|
5
|
+
Compares a YAML-defined schema file against an actual kintone app form, providing diff detection, migration, schema capture, seed data management, and more.
|
|
6
6
|
|
|
7
7
|
## Installation
|
|
8
8
|
|
|
@@ -16,6 +16,8 @@ Requires Node.js 22 or later.
|
|
|
16
16
|
|
|
17
17
|
Connection details for kintone can be specified via CLI arguments or environment variables. CLI arguments take precedence.
|
|
18
18
|
|
|
19
|
+
### kintone Connection
|
|
20
|
+
|
|
19
21
|
| CLI Argument | Environment Variable | Description |
|
|
20
22
|
|---------|----------|------|
|
|
21
23
|
| `--domain`, `-d` | `KINTONE_DOMAIN` | kintone domain (e.g., `example.cybozu.com`) |
|
|
@@ -26,6 +28,22 @@ Connection details for kintone can be specified via CLI arguments or environment
|
|
|
26
28
|
| `--guest-space-id`, `-g` | `KINTONE_GUEST_SPACE_ID` | kintone guest space ID |
|
|
27
29
|
| `--schema-file`, `-f` | `SCHEMA_FILE_PATH` | Schema file path (default: `schema.yaml`) |
|
|
28
30
|
|
|
31
|
+
### Multi-App Options
|
|
32
|
+
|
|
33
|
+
These options are available on **all commands** (diff, migrate, override, capture, dump, validate, seed) and enable multi-app mode via a project config file.
|
|
34
|
+
|
|
35
|
+
| CLI Argument | Description |
|
|
36
|
+
|---------|------|
|
|
37
|
+
| `--app <name>` | Target a specific app by name (from project config) |
|
|
38
|
+
| `--all` | Run all apps in dependency order |
|
|
39
|
+
| `--config`, `-c` | Project config file path (default: `kintone-migrator.yaml`) |
|
|
40
|
+
|
|
41
|
+
**Mutual exclusion rules:**
|
|
42
|
+
|
|
43
|
+
- `--app` and `--all` cannot be used together
|
|
44
|
+
- `--app-id` and `--app` cannot be used together
|
|
45
|
+
- `--app-id` and `--all` cannot be used together
|
|
46
|
+
|
|
29
47
|
### Authentication
|
|
30
48
|
|
|
31
49
|
Two authentication methods are supported:
|
|
@@ -61,14 +79,22 @@ Detects differences between the schema file and the current kintone form.
|
|
|
61
79
|
```bash
|
|
62
80
|
kintone-migrator diff
|
|
63
81
|
kintone-migrator diff -d example.cybozu.com -a 123
|
|
82
|
+
|
|
83
|
+
# Multi-app mode
|
|
84
|
+
kintone-migrator diff --app customer
|
|
85
|
+
kintone-migrator diff --all
|
|
64
86
|
```
|
|
65
87
|
|
|
66
88
|
### `migrate`
|
|
67
89
|
|
|
68
|
-
Applies schema file changes to the kintone form. Displays the diff and prompts for confirmation before execution.
|
|
90
|
+
Applies schema file changes to the kintone form. Displays the diff and prompts for confirmation before execution. Only detected differences are applied (add, update, delete).
|
|
69
91
|
|
|
70
92
|
```bash
|
|
71
93
|
kintone-migrator migrate
|
|
94
|
+
|
|
95
|
+
# Multi-app mode
|
|
96
|
+
kintone-migrator migrate --app customer
|
|
97
|
+
kintone-migrator migrate --all
|
|
72
98
|
```
|
|
73
99
|
|
|
74
100
|
### `override`
|
|
@@ -77,8 +103,21 @@ Overwrites the entire kintone form with the schema file contents. Fields not def
|
|
|
77
103
|
|
|
78
104
|
```bash
|
|
79
105
|
kintone-migrator override
|
|
106
|
+
|
|
107
|
+
# Reset form: delete all custom fields (no schema file needed)
|
|
108
|
+
kintone-migrator override --reset
|
|
109
|
+
|
|
110
|
+
# Multi-app mode
|
|
111
|
+
kintone-migrator override --all
|
|
112
|
+
kintone-migrator override --reset --all
|
|
80
113
|
```
|
|
81
114
|
|
|
115
|
+
#### Override-specific arguments
|
|
116
|
+
|
|
117
|
+
| CLI Argument | Description |
|
|
118
|
+
|---------|------|
|
|
119
|
+
| `--reset` | Reset form by deleting all custom fields. Cannot be used with `--schema-file`. In multi-app mode (`--all`), apps are reset in reverse dependency order. |
|
|
120
|
+
|
|
82
121
|
### `capture`
|
|
83
122
|
|
|
84
123
|
Saves the current kintone form schema to a file.
|
|
@@ -86,6 +125,10 @@ Saves the current kintone form schema to a file.
|
|
|
86
125
|
```bash
|
|
87
126
|
kintone-migrator capture
|
|
88
127
|
kintone-migrator capture -f my-schema.yaml
|
|
128
|
+
|
|
129
|
+
# Multi-app mode
|
|
130
|
+
kintone-migrator capture --app customer
|
|
131
|
+
kintone-migrator capture --all
|
|
89
132
|
```
|
|
90
133
|
|
|
91
134
|
### `dump`
|
|
@@ -94,9 +137,53 @@ Dumps kintone form field definitions and layout in JSON format. For debugging pu
|
|
|
94
137
|
|
|
95
138
|
```bash
|
|
96
139
|
kintone-migrator dump
|
|
140
|
+
|
|
141
|
+
# Multi-app mode
|
|
142
|
+
kintone-migrator dump --app customer
|
|
143
|
+
kintone-migrator dump --all
|
|
97
144
|
```
|
|
98
145
|
|
|
99
|
-
`fields.json` and `layout.json` will be output to the current directory.
|
|
146
|
+
`fields.json` and `layout.json` will be output to the current directory. In multi-app mode, files are prefixed with the app name (e.g., `customer_fields.json`).
|
|
147
|
+
|
|
148
|
+
### `validate`
|
|
149
|
+
|
|
150
|
+
Validates the schema file locally without connecting to kintone. Checks for structural issues such as empty labels, missing selection options, invalid lookup configurations, and more.
|
|
151
|
+
|
|
152
|
+
```bash
|
|
153
|
+
kintone-migrator validate
|
|
154
|
+
kintone-migrator validate -f my-schema.yaml
|
|
155
|
+
|
|
156
|
+
# Multi-app mode
|
|
157
|
+
kintone-migrator validate --app customer
|
|
158
|
+
kintone-migrator validate --all
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
### `seed`
|
|
162
|
+
|
|
163
|
+
Applies seed data (records) to a kintone app using upsert (insert or update based on a key field). Can also capture existing records from an app to a seed file.
|
|
164
|
+
|
|
165
|
+
```bash
|
|
166
|
+
# Apply seed data to a single app
|
|
167
|
+
kintone-migrator seed
|
|
168
|
+
kintone-migrator seed -s my-seed.yaml
|
|
169
|
+
|
|
170
|
+
# Capture records from a kintone app
|
|
171
|
+
kintone-migrator seed --capture --key-field customer_code
|
|
172
|
+
kintone-migrator seed --capture --key-field customer_code -s seeds/customer.yaml
|
|
173
|
+
|
|
174
|
+
# Multi-app mode
|
|
175
|
+
kintone-migrator seed --all
|
|
176
|
+
kintone-migrator seed --capture --key-field code --all
|
|
177
|
+
kintone-migrator seed --app customer
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
#### Seed-specific arguments
|
|
181
|
+
|
|
182
|
+
| CLI Argument | Description |
|
|
183
|
+
|---------|------|
|
|
184
|
+
| `--capture` | Capture mode: fetch records from kintone and save to seed file |
|
|
185
|
+
| `--key-field`, `-k` | Key field code for upsert (required for `--capture`) |
|
|
186
|
+
| `--seed-file`, `-s` | Seed file path (default: `seed.yaml`) |
|
|
100
187
|
|
|
101
188
|
## Schema File
|
|
102
189
|
|
|
@@ -125,12 +212,192 @@ layout:
|
|
|
125
212
|
size: { width: "400" }
|
|
126
213
|
```
|
|
127
214
|
|
|
215
|
+
### Lookup Fields
|
|
216
|
+
|
|
217
|
+
`SINGLE_LINE_TEXT`, `NUMBER`, and `LINK` fields can be configured as lookup fields by adding a `lookup` property. Lookups are not a separate field type in kintone; they are a property of these field types.
|
|
218
|
+
|
|
219
|
+
```yaml
|
|
220
|
+
- code: customer_code
|
|
221
|
+
type: SINGLE_LINE_TEXT
|
|
222
|
+
label: 顧客コード
|
|
223
|
+
size: { width: "200" }
|
|
224
|
+
lookup:
|
|
225
|
+
relatedApp: { app: "10" }
|
|
226
|
+
relatedKeyField: code
|
|
227
|
+
fieldMappings:
|
|
228
|
+
- { field: customer_name, relatedField: name }
|
|
229
|
+
- { field: email, relatedField: contact_email }
|
|
230
|
+
lookupPickerFields: [code, name, contact_email]
|
|
231
|
+
filterCond: 'status in ("active")'
|
|
232
|
+
sort: "code asc"
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
### Reference Tables
|
|
236
|
+
|
|
237
|
+
`REFERENCE_TABLE` fields display related records from another app.
|
|
238
|
+
|
|
239
|
+
```yaml
|
|
240
|
+
- code: related_orders
|
|
241
|
+
type: REFERENCE_TABLE
|
|
242
|
+
label: 関連注文
|
|
243
|
+
size: { width: "600" }
|
|
244
|
+
referenceTable:
|
|
245
|
+
relatedApp: { app: "42" }
|
|
246
|
+
condition: { field: customer_name, relatedField: name }
|
|
247
|
+
filterCond: 'status in ("active")'
|
|
248
|
+
displayFields: [name, email, phone]
|
|
249
|
+
sort: "name asc"
|
|
250
|
+
size: "5"
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
### Supported Field Types
|
|
254
|
+
|
|
255
|
+
| Type | Description |
|
|
256
|
+
|------|-------------|
|
|
257
|
+
| `SINGLE_LINE_TEXT` | Single-line text |
|
|
258
|
+
| `MULTI_LINE_TEXT` | Multi-line text |
|
|
259
|
+
| `RICH_TEXT` | Rich text editor |
|
|
260
|
+
| `NUMBER` | Number |
|
|
261
|
+
| `CALC` | Calculated field |
|
|
262
|
+
| `CHECK_BOX` | Checkbox (multi-select) |
|
|
263
|
+
| `RADIO_BUTTON` | Radio button (single-select) |
|
|
264
|
+
| `MULTI_SELECT` | Multi-select |
|
|
265
|
+
| `DROP_DOWN` | Dropdown (single-select) |
|
|
266
|
+
| `DATE` | Date |
|
|
267
|
+
| `TIME` | Time |
|
|
268
|
+
| `DATETIME` | Date and time |
|
|
269
|
+
| `LINK` | Link (URL, phone, email) |
|
|
270
|
+
| `USER_SELECT` | User selection |
|
|
271
|
+
| `ORGANIZATION_SELECT` | Organization selection |
|
|
272
|
+
| `GROUP_SELECT` | Group selection |
|
|
273
|
+
| `FILE` | File attachment |
|
|
274
|
+
| `GROUP` | Field group (collapsible) |
|
|
275
|
+
| `SUBTABLE` | Subtable |
|
|
276
|
+
| `REFERENCE_TABLE` | Reference table |
|
|
277
|
+
|
|
128
278
|
For the full specification and all supported field types, see:
|
|
129
279
|
|
|
130
280
|
- [Schema Specification](./spec/schema.md) — format reference for all field types, layout items, decoration elements, and validation rules
|
|
131
281
|
- [Sample Schema (YAML)](./spec/sample_schema.yaml) — comprehensive example covering all field types
|
|
132
282
|
- [Sample Schema (JSON)](./spec/sample_schema.json) — equivalent example in JSON format
|
|
133
283
|
|
|
284
|
+
## Seed Data File
|
|
285
|
+
|
|
286
|
+
Seed data files define records to be upserted into a kintone app. The `key` field specifies which field to use for matching existing records (must have the "Prohibit duplicate values" setting enabled in kintone).
|
|
287
|
+
|
|
288
|
+
```yaml
|
|
289
|
+
key: customer_code
|
|
290
|
+
records:
|
|
291
|
+
- customer_code: "C001"
|
|
292
|
+
customer_name: "Test Corp"
|
|
293
|
+
priority: "high"
|
|
294
|
+
tags:
|
|
295
|
+
- "VIP"
|
|
296
|
+
- "long-term"
|
|
297
|
+
assignee:
|
|
298
|
+
- code: "user1"
|
|
299
|
+
start_date: "2025-01-15"
|
|
300
|
+
order_items:
|
|
301
|
+
- product_name: "Product A"
|
|
302
|
+
quantity: "1"
|
|
303
|
+
price: "1000"
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
### Seed Field Value Types
|
|
307
|
+
|
|
308
|
+
| kintone Field Type | YAML Representation | Example |
|
|
309
|
+
|------|-------------|---------|
|
|
310
|
+
| `SINGLE_LINE_TEXT`, `MULTI_LINE_TEXT`, `RICH_TEXT` | string | `"text"` |
|
|
311
|
+
| `NUMBER` | string | `"1000"` |
|
|
312
|
+
| `RADIO_BUTTON`, `DROP_DOWN` | string | `"high"` |
|
|
313
|
+
| `CHECK_BOX`, `MULTI_SELECT` | string[] | `["VIP", "long-term"]` |
|
|
314
|
+
| `DATE` | string (YYYY-MM-DD) | `"2025-01-15"` |
|
|
315
|
+
| `TIME` | string (HH:mm) | `"09:00"` |
|
|
316
|
+
| `DATETIME` | string (ISO 8601) | `"2025-01-15T09:00:00Z"` |
|
|
317
|
+
| `LINK` | string | `"https://example.com"` |
|
|
318
|
+
| `USER_SELECT`, `ORGANIZATION_SELECT`, `GROUP_SELECT` | object[] with `code` | `[{code: "user1"}]` |
|
|
319
|
+
| `SUBTABLE` | object[] | `[{field1: "val1"}]` |
|
|
320
|
+
|
|
321
|
+
For the full specification, see:
|
|
322
|
+
|
|
323
|
+
- [Seed Data Specification](./spec/seed.md) — format reference, field type mappings, and validation rules
|
|
324
|
+
|
|
325
|
+
## Multi-App Project Config
|
|
326
|
+
|
|
327
|
+
A project config file (`kintone-migrator.yaml`) enables managing multiple kintone apps with dependency ordering. All commands (diff, migrate, override, capture, dump, validate, seed) support multi-app mode.
|
|
328
|
+
|
|
329
|
+
```yaml
|
|
330
|
+
# Shared connection settings (can be overridden per app)
|
|
331
|
+
domain: example.cybozu.com
|
|
332
|
+
auth:
|
|
333
|
+
apiToken: "shared-token"
|
|
334
|
+
# guestSpaceId: "456"
|
|
335
|
+
|
|
336
|
+
# App definitions
|
|
337
|
+
apps:
|
|
338
|
+
customer:
|
|
339
|
+
appId: "10"
|
|
340
|
+
schemaFile: schemas/customer.yaml
|
|
341
|
+
seedFile: seeds/customer.yaml
|
|
342
|
+
order:
|
|
343
|
+
appId: "20"
|
|
344
|
+
schemaFile: schemas/order.yaml
|
|
345
|
+
seedFile: seeds/order.yaml
|
|
346
|
+
dependsOn:
|
|
347
|
+
- customer
|
|
348
|
+
invoice:
|
|
349
|
+
appId: "30"
|
|
350
|
+
dependsOn:
|
|
351
|
+
- order
|
|
352
|
+
- customer
|
|
353
|
+
```
|
|
354
|
+
|
|
355
|
+
### App Configuration Fields
|
|
356
|
+
|
|
357
|
+
| Field | Required | Description |
|
|
358
|
+
|-------|----------|-------------|
|
|
359
|
+
| `appId` | Yes | kintone app ID |
|
|
360
|
+
| `schemaFile` | No | Schema file path (default: `schemas/<appName>.yaml`) |
|
|
361
|
+
| `seedFile` | No | Seed file path (default: `seeds/<appName>.yaml`) |
|
|
362
|
+
| `domain` | No | App-specific kintone domain (overrides top-level) |
|
|
363
|
+
| `auth` | No | App-specific authentication (overrides top-level) |
|
|
364
|
+
| `guestSpaceId` | No | App-specific guest space ID |
|
|
365
|
+
| `dependsOn` | No | List of app names this app depends on |
|
|
366
|
+
|
|
367
|
+
### Configuration Merge Priority (high to low)
|
|
368
|
+
|
|
369
|
+
1. CLI arguments (`--domain`, `--api-token`, etc.)
|
|
370
|
+
2. Environment variables (`KINTONE_DOMAIN`, `KINTONE_API_TOKEN`, etc.)
|
|
371
|
+
3. App-level settings (per `apps.<name>`)
|
|
372
|
+
4. Top-level settings
|
|
373
|
+
|
|
374
|
+
### Authentication in Config File
|
|
375
|
+
|
|
376
|
+
```yaml
|
|
377
|
+
# API Token authentication
|
|
378
|
+
auth:
|
|
379
|
+
apiToken: "your-token"
|
|
380
|
+
|
|
381
|
+
# Username/Password authentication
|
|
382
|
+
auth:
|
|
383
|
+
username: "your-username"
|
|
384
|
+
password: "your-password"
|
|
385
|
+
```
|
|
386
|
+
|
|
387
|
+
### Dependency Resolution
|
|
388
|
+
|
|
389
|
+
Apps are executed in topological order based on `dependsOn` declarations. Same-level apps are sorted alphabetically for deterministic ordering. Circular dependencies are detected and reported as errors.
|
|
390
|
+
|
|
391
|
+
### Execution Behavior
|
|
392
|
+
|
|
393
|
+
- **`--all`**: Executes all apps in dependency order. Stops on first failure (fail-fast). Remaining apps are skipped.
|
|
394
|
+
- **`--app <name>`**: Executes only the specified app.
|
|
395
|
+
- **`--reset --all`**: Resets apps in **reverse** dependency order (dependent apps first) to avoid reference integrity issues.
|
|
396
|
+
|
|
397
|
+
For the full specification, see:
|
|
398
|
+
|
|
399
|
+
- [Project Config Specification](./spec/projectConfig.md) — format reference, validation rules, and dependency resolution
|
|
400
|
+
|
|
134
401
|
## License
|
|
135
402
|
|
|
136
403
|
MIT
|