kintone-migrator 0.4.0 → 0.5.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.
Files changed (3) hide show
  1. package/README.md +76 -2
  2. package/dist/index.mjs +1331 -216
  3. package/package.json +10 -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
 
@@ -23,6 +23,7 @@ Connection details for kintone can be specified via CLI arguments or environment
23
23
  | `--username`, `-u` | `KINTONE_USERNAME` | kintone username |
24
24
  | `--password`, `-p` | `KINTONE_PASSWORD` | kintone password |
25
25
  | `--app-id`, `-a` | `KINTONE_APP_ID` | kintone app ID |
26
+ | `--guest-space-id`, `-g` | `KINTONE_GUEST_SPACE_ID` | kintone guest space ID |
26
27
  | `--schema-file`, `-f` | `SCHEMA_FILE_PATH` | Schema file path (default: `schema.yaml`) |
27
28
 
28
29
  ### Authentication
@@ -47,6 +48,7 @@ KINTONE_USERNAME=your_username
47
48
  KINTONE_PASSWORD=your_password
48
49
 
49
50
  KINTONE_APP_ID=123
51
+ # KINTONE_GUEST_SPACE_ID=456
50
52
  SCHEMA_FILE_PATH=schema.yaml
51
53
  ```
52
54
 
@@ -96,6 +98,33 @@ kintone-migrator dump
96
98
 
97
99
  `fields.json` and `layout.json` will be output to the current directory.
98
100
 
101
+ ### `seed`
102
+
103
+ 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.
104
+
105
+ ```bash
106
+ # Apply seed data to a single app
107
+ kintone-migrator seed
108
+ kintone-migrator seed -s my-seed.yaml
109
+
110
+ # Capture records from a kintone app
111
+ kintone-migrator seed --capture --key-field customer_code
112
+ kintone-migrator seed --capture --key-field customer_code -s seeds/customer.yaml
113
+
114
+ # Multi-app mode
115
+ kintone-migrator seed --all
116
+ kintone-migrator seed --capture --key-field code --all
117
+ kintone-migrator seed --app customer
118
+ ```
119
+
120
+ #### Seed-specific arguments
121
+
122
+ | CLI Argument | Description |
123
+ |---------|------|
124
+ | `--capture` | Capture mode: fetch records from kintone and save to seed file |
125
+ | `--key-field`, `-k` | Key field code for upsert (required for `--capture`) |
126
+ | `--seed-file`, `-s` | Seed file path (default: `seed.yaml`) |
127
+
99
128
  ## Schema File
100
129
 
101
130
  Schema files define the desired kintone form configuration in YAML format. The `layout` key at the root describes form rows, groups, subtables, and field definitions.
@@ -129,6 +158,51 @@ For the full specification and all supported field types, see:
129
158
  - [Sample Schema (YAML)](./spec/sample_schema.yaml) — comprehensive example covering all field types
130
159
  - [Sample Schema (JSON)](./spec/sample_schema.json) — equivalent example in JSON format
131
160
 
161
+ ## Seed Data File
162
+
163
+ 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).
164
+
165
+ ```yaml
166
+ key: customer_code
167
+ records:
168
+ - customer_code: "C001"
169
+ customer_name: "Test Corp"
170
+ priority: "high"
171
+ tags:
172
+ - "VIP"
173
+ - "long-term"
174
+ assignee:
175
+ - code: "user1"
176
+ start_date: "2025-01-15"
177
+ order_items:
178
+ - product_name: "Product A"
179
+ quantity: "1"
180
+ price: "1000"
181
+ ```
182
+
183
+ For the full specification, see:
184
+
185
+ - [Seed Data Specification](./spec/seed.md) — format reference, field type mappings, and validation rules
186
+
187
+ ## Multi-App Project Config
188
+
189
+ When using a project config file (`kintone-migrator.yaml`), seed files can be configured per app via the `seedFile` option:
190
+
191
+ ```yaml
192
+ apps:
193
+ customer:
194
+ appId: "10"
195
+ schemaFile: schemas/customer.yaml
196
+ seedFile: seeds/customer.yaml
197
+ order:
198
+ appId: "20"
199
+ seedFile: seeds/order.yaml
200
+ dependsOn:
201
+ - customer
202
+ ```
203
+
204
+ If `seedFile` is omitted, it defaults to `seeds/<appName>.yaml`.
205
+
132
206
  ## License
133
207
 
134
208
  MIT