kintone-migrator 0.34.6 → 0.35.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 +73 -6
- package/dist/index.mjs +101 -38
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -131,16 +131,23 @@ apps:
|
|
|
131
131
|
| `guestSpaceId` | No | Guest space ID |
|
|
132
132
|
| `dependsOn` | No | List of app names this app depends on |
|
|
133
133
|
|
|
134
|
-
Multi-app CLI options (available on
|
|
134
|
+
Multi-app CLI options (available on every command except `init`):
|
|
135
135
|
|
|
136
136
|
| CLI Argument | Description |
|
|
137
137
|
|---|---|
|
|
138
138
|
| `--app <name>` | Target a specific app by name |
|
|
139
|
-
| `--all` | Run all apps in dependency order |
|
|
139
|
+
| `--all` | Run all apps in dependency order (not supported by `<domain> push` / `<domain> pull` — see below) |
|
|
140
140
|
| `--config`, `-c` | Config file path (default: `kintone-migrator.yaml`) |
|
|
141
141
|
|
|
142
142
|
Apps are executed in topological order based on `dependsOn`. Circular dependencies are detected and reported as errors. `--all` stops on first failure (fail-fast).
|
|
143
143
|
|
|
144
|
+
The per-domain `push` / `pull` commands (`schema push`, `customize push`, `customize pull`, `view pull`, ...) only run one app at a time: they accept `--app <name>` but reject `--all` with a validation error. To run every app, use the top-level aggregate `push` / `pull` commands, which cover every domain across every app in dependency order:
|
|
145
|
+
|
|
146
|
+
```bash
|
|
147
|
+
kintone-migrator push --all --yes # every domain, every app
|
|
148
|
+
kintone-migrator pull --all # every domain, every app
|
|
149
|
+
```
|
|
150
|
+
|
|
144
151
|
Configuration merge priority (high to low): CLI arguments > environment variables > app-level settings > top-level settings.
|
|
145
152
|
|
|
146
153
|
#### File Path Resolution in Multi-App Mode
|
|
@@ -183,7 +190,7 @@ Commands are organized into domain groups:
|
|
|
183
190
|
| `schema` | `override` | Overwrite entire form from schema |
|
|
184
191
|
| `schema` | `capture` | _Deprecated — use `schema pull`._ Save current form schema to file |
|
|
185
192
|
| `schema` | `validate` | Validate schema file locally |
|
|
186
|
-
| `schema` | `dump` | Dump raw field/layout JSON (
|
|
193
|
+
| `schema` | `dump` | Dump raw field/layout JSON (debugging / preview-vs-published check) |
|
|
187
194
|
| `seed` | `push` | Upsert seed data records (plain upsert; no 3-way merge) |
|
|
188
195
|
| `seed` | `apply` | _Deprecated alias for `seed push`._ |
|
|
189
196
|
| `seed` | `capture` | Capture records from kintone app |
|
|
@@ -214,7 +221,9 @@ Commands are organized into domain groups:
|
|
|
214
221
|
|
|
215
222
|
> **Deprecation notice:** the `apply`/`capture`/`migrate` commands above are deprecated in favor of their per-domain `push`/`pull` successors and will be removed in a future major version. The top-level `apply`/`capture` aggregate commands are likewise superseded by the top-level `push`/`pull` aggregate commands (which run every domain at once), not by any single `<domain> push`/`<domain> pull`. `push` writes to kintone (with a drift guard; use `--force` for the legacy overwrite behavior) and `pull` reads from kintone (with 3-way merge; `--force` for legacy overwrite). `seed` is out of scope for 3-way merge, so it has `seed push` but no `seed pull` — keep using `seed capture` to read records.
|
|
216
223
|
|
|
217
|
-
|
|
224
|
+
Every command except `init` supports `--app <name>` for [multi-app mode](#multi-app-project-config). `--all` is supported by the `apply` / `capture` / `diff` / `migrate` commands, `seed push`, and the top-level aggregate `push` / `pull`, but **not** by the per-domain `push` / `pull` commands (`schema push`, `schema pull`, `customize push`, `customize pull`, `view push`, ...) — those reject `--all` with a validation error. Run the top-level `push` / `pull` with `--all` to cover every app instead.
|
|
225
|
+
|
|
226
|
+
Commands that modify data (`schema push`, `schema override`, `seed push --clean`, `customize push`) support `--yes` / `-y` to skip confirmation prompts.
|
|
218
227
|
|
|
219
228
|
### `init` -- Project Initialization
|
|
220
229
|
|
|
@@ -249,13 +258,28 @@ Authentication settings are intentionally omitted from the generated config to a
|
|
|
249
258
|
|
|
250
259
|
#### `schema diff`
|
|
251
260
|
|
|
252
|
-
Detects differences between the schema file and the current kintone form.
|
|
261
|
+
Detects differences between the schema file and the current kintone form. The output states which form generation the comparison used.
|
|
253
262
|
|
|
254
263
|
```bash
|
|
255
264
|
kintone-migrator schema diff
|
|
256
265
|
kintone-migrator schema diff --app customer
|
|
266
|
+
kintone-migrator schema diff --published
|
|
257
267
|
```
|
|
258
268
|
|
|
269
|
+
| Option | Description |
|
|
270
|
+
|---|---|
|
|
271
|
+
| `--published` | Compare against the published (deployed) form instead of the preview (unpublished) one. |
|
|
272
|
+
|
|
273
|
+
Without `--published` the comparison is 3-way against the preview form: with a base snapshot it distinguishes local changes, remote drift, and conflicts.
|
|
274
|
+
|
|
275
|
+
With `--published` the comparison is 2-way against the deployed form. The base snapshot is not used, so drift and conflicts are not detected -- "no changes" means only that the schema file matches what is currently published.
|
|
276
|
+
|
|
277
|
+
This is the check to run after a deploy: if `schema diff --published` reports no changes, the schema file's contents are live on the published form.
|
|
278
|
+
|
|
279
|
+
`--published` requires the app to have been deployed at least once. On an app that has never been deployed, the read fails with an error that identifies it as a published read and points at the likely cause. With `--all`, a single failing app stops the whole run (fail-fast) and the remaining apps are skipped.
|
|
280
|
+
|
|
281
|
+
`--published` is accepted only by `schema dump` and `schema diff`. `schema pull`, `schema push`, `schema capture`, `schema migrate`, and `schema override` always target the preview generation, and passing `--published` to them is silently ignored.
|
|
282
|
+
|
|
259
283
|
#### `schema migrate`
|
|
260
284
|
|
|
261
285
|
> **Deprecated.** Use `schema push` (drift-guarded) or `schema push --force` (legacy overwrite) instead. `schema migrate` keeps working but will be removed in a future major version.
|
|
@@ -305,12 +329,53 @@ kintone-migrator schema validate -f my-schema.yaml
|
|
|
305
329
|
|
|
306
330
|
#### `schema dump`
|
|
307
331
|
|
|
308
|
-
Dumps raw kintone field definitions and layout as JSON. Outputs `fields.json` and `layout.json` (prefixed with app name in multi-app mode).
|
|
332
|
+
Dumps raw kintone field definitions and layout as JSON. Outputs `fields.json` and `layout.json` (prefixed with app name in multi-app mode), or their `published-` counterparts with `--published`, so both generations can be dumped side by side and compared.
|
|
309
333
|
|
|
310
334
|
```bash
|
|
311
335
|
kintone-migrator schema dump
|
|
336
|
+
kintone-migrator schema dump --published
|
|
312
337
|
```
|
|
313
338
|
|
|
339
|
+
| Option | Description |
|
|
340
|
+
|---|---|
|
|
341
|
+
| `--published` | Dump the published (deployed) form instead of the preview (unpublished) one. |
|
|
342
|
+
|
|
343
|
+
With `--published` the output file names are prefixed with `published-`, so the two generations never overwrite each other: `published-fields.json` / `published-layout.json` (in multi-app mode, `<appName>-published-fields.json` / `<appName>-published-layout.json`).
|
|
344
|
+
|
|
345
|
+
`--published` requires the app to have been deployed at least once. On an app that has never been deployed, the dump fails with an error that identifies it as a published read and points at the likely cause, and no file is written. With `--all`, a single failing app stops the whole run (fail-fast) and the remaining apps are skipped.
|
|
346
|
+
|
|
347
|
+
`--published` is accepted only by `schema dump` and `schema diff`. `schema pull`, `schema push`, `schema capture`, `schema migrate`, and `schema override` always target the preview generation, and passing `--published` to them is silently ignored.
|
|
348
|
+
|
|
349
|
+
Because the two dumps sit side by side, you can compare the preview form definition with the published one before pushing your own changes:
|
|
350
|
+
|
|
351
|
+
```bash
|
|
352
|
+
kintone-migrator schema dump # fields.json / layout.json (preview)
|
|
353
|
+
kintone-migrator schema dump --published # published-fields.json / published-layout.json
|
|
354
|
+
|
|
355
|
+
# revision can differ between generations, so exclude it from the comparison
|
|
356
|
+
diff -I '"revision"' fields.json published-fields.json
|
|
357
|
+
diff -I '"revision"' layout.json published-layout.json
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
In a multi-app project (a `kintone-migrator.yaml` is present), add `--app <name>` to both dumps -- with none of `--app`, `--all`, or `--app-id` the command only lists the available apps and writes no files. With `--app <name>` the output file names are prefixed with the app name (`--app-id` bypasses the project config and keeps the unprefixed names):
|
|
361
|
+
|
|
362
|
+
```bash
|
|
363
|
+
kintone-migrator schema dump --app customer # customer-fields.json / customer-layout.json
|
|
364
|
+
kintone-migrator schema dump --app customer --published # customer-published-fields.json / customer-published-layout.json
|
|
365
|
+
|
|
366
|
+
diff -I '"revision"' customer-fields.json customer-published-fields.json
|
|
367
|
+
diff -I '"revision"' customer-layout.json customer-published-layout.json
|
|
368
|
+
```
|
|
369
|
+
|
|
370
|
+
The `-I '"revision"'` exclusion is needed because `dump` saves the kintone response as-is: both `fields.json` and `layout.json` carry a top-level `revision`, and its value can differ between the preview and published generations even when the form contents are identical. If the comparison reports differences other than `revision` -- for example the same fields serialized in a different key order -- normalize both files before comparing:
|
|
371
|
+
|
|
372
|
+
```bash
|
|
373
|
+
diff <(jq -S 'del(.revision)' fields.json) <(jq -S 'del(.revision)' published-fields.json)
|
|
374
|
+
diff <(jq -S 'del(.revision)' layout.json) <(jq -S 'del(.revision)' published-layout.json)
|
|
375
|
+
```
|
|
376
|
+
|
|
377
|
+
No differences means the form definition in preview matches the one that is published. It does not mean that a deploy is safe in general: deploying publishes **all** pending preview settings for the app -- views, notifications, process management, the various permission settings, plugins, general settings -- while this check covers the form definition only. Someone else's undeployed work in those other areas would still go live.
|
|
378
|
+
|
|
314
379
|
### `seed` -- Seed Data Management
|
|
315
380
|
|
|
316
381
|
#### `seed push`
|
|
@@ -344,6 +409,8 @@ kintone-migrator seed capture --key-field customer_code
|
|
|
344
409
|
|
|
345
410
|
### `customize` -- JS/CSS Customization
|
|
346
411
|
|
|
412
|
+
> **Note:** `customize push` / `customize pull` handle one app per run — they accept `--app <name>` but reject `--all`. To apply customizations to every app at once, use the top-level aggregate `push` / `pull` (`kintone-migrator push --all --yes`), which runs every domain for every app in dependency order. The deprecated `customize apply` / `customize capture` still accept `--all`.
|
|
413
|
+
|
|
347
414
|
#### `customize apply`
|
|
348
415
|
|
|
349
416
|
> **Deprecated.** Use `customize push` instead (and `customize pull` in place of `customize capture`). The legacy commands keep working but will be removed in a future major version.
|
package/dist/index.mjs
CHANGED
|
@@ -1324,6 +1324,10 @@ var KintoneFileUploader = class {
|
|
|
1324
1324
|
*/
|
|
1325
1325
|
const SKIP_REVISION_CHECK = Symbol("skip-revision-check");
|
|
1326
1326
|
//#endregion
|
|
1327
|
+
//#region src/core/domain/formSchema/ports/formReadTarget.ts
|
|
1328
|
+
/** The generation read when a caller does not specify a target. */
|
|
1329
|
+
const DEFAULT_FORM_READ_TARGET = "preview";
|
|
1330
|
+
//#endregion
|
|
1327
1331
|
//#region src/lib/charValidation.ts
|
|
1328
1332
|
/** Returns true if the string contains any control characters (0x00–0x1f or 0x7f). */
|
|
1329
1333
|
function hasControlChars(s) {
|
|
@@ -1677,6 +1681,14 @@ function toKintoneLayoutItem(item) {
|
|
|
1677
1681
|
default: throw new SystemError(SystemErrorCode.ExternalApiError, `Unknown layout item type: ${item.type}`);
|
|
1678
1682
|
}
|
|
1679
1683
|
}
|
|
1684
|
+
const GET_FIELDS_FAILURE_MESSAGES = {
|
|
1685
|
+
preview: "Failed to get form fields",
|
|
1686
|
+
published: "Failed to get published form fields (the app may not be deployed yet, or the credentials may not be allowed to read it)"
|
|
1687
|
+
};
|
|
1688
|
+
const GET_LAYOUT_FAILURE_MESSAGES = {
|
|
1689
|
+
preview: "Failed to get form layout",
|
|
1690
|
+
published: "Failed to get published form layout (the app may not be deployed yet, or the credentials may not be allowed to read it)"
|
|
1691
|
+
};
|
|
1680
1692
|
var KintoneFormConfigurator = class {
|
|
1681
1693
|
revisionTracker;
|
|
1682
1694
|
constructor(client, appId, revisionTracker) {
|
|
@@ -1684,13 +1696,14 @@ var KintoneFormConfigurator = class {
|
|
|
1684
1696
|
this.appId = appId;
|
|
1685
1697
|
this.revisionTracker = revisionTracker ?? new RevisionTracker();
|
|
1686
1698
|
}
|
|
1687
|
-
async getFields() {
|
|
1699
|
+
async getFields(target = DEFAULT_FORM_READ_TARGET) {
|
|
1700
|
+
const preview = target === "preview";
|
|
1688
1701
|
try {
|
|
1689
1702
|
const { properties, revision } = await this.client.app.getFormFields({
|
|
1690
1703
|
app: this.appId,
|
|
1691
|
-
preview
|
|
1704
|
+
preview
|
|
1692
1705
|
});
|
|
1693
|
-
if (revision) this.revisionTracker.track(revision);
|
|
1706
|
+
if (revision && target === "preview") this.revisionTracker.track(revision);
|
|
1694
1707
|
const fields = /* @__PURE__ */ new Map();
|
|
1695
1708
|
for (const [code, prop] of Object.entries(properties)) {
|
|
1696
1709
|
const kintoneProp = prop;
|
|
@@ -1701,7 +1714,7 @@ var KintoneFormConfigurator = class {
|
|
|
1701
1714
|
}
|
|
1702
1715
|
return fields;
|
|
1703
1716
|
} catch (error) {
|
|
1704
|
-
throw wrapKintoneError(error,
|
|
1717
|
+
throw wrapKintoneError(error, GET_FIELDS_FAILURE_MESSAGES[target]);
|
|
1705
1718
|
}
|
|
1706
1719
|
}
|
|
1707
1720
|
async getRevision() {
|
|
@@ -1764,16 +1777,17 @@ var KintoneFormConfigurator = class {
|
|
|
1764
1777
|
throw wrapKintoneError(error, "Failed to delete form fields");
|
|
1765
1778
|
}
|
|
1766
1779
|
}
|
|
1767
|
-
async getLayout() {
|
|
1780
|
+
async getLayout(target = DEFAULT_FORM_READ_TARGET) {
|
|
1781
|
+
const preview = target === "preview";
|
|
1768
1782
|
try {
|
|
1769
1783
|
const response = await this.client.app.getFormLayout({
|
|
1770
1784
|
app: this.appId,
|
|
1771
|
-
preview
|
|
1785
|
+
preview
|
|
1772
1786
|
});
|
|
1773
|
-
if (response.revision) this.revisionTracker.track(response.revision);
|
|
1787
|
+
if (response.revision && target === "preview") this.revisionTracker.track(response.revision);
|
|
1774
1788
|
return response.layout.map(fromKintoneLayoutItem);
|
|
1775
1789
|
} catch (error) {
|
|
1776
|
-
throw wrapKintoneError(error,
|
|
1790
|
+
throw wrapKintoneError(error, GET_LAYOUT_FAILURE_MESSAGES[target]);
|
|
1777
1791
|
}
|
|
1778
1792
|
}
|
|
1779
1793
|
async updateLayout(layout, expectedRevision) {
|
|
@@ -2706,6 +2720,13 @@ function printCustomizationDiffResult(result) {
|
|
|
2706
2720
|
return `${colorize(prefix)} ${pc.dim("[")}${colorize(location)}${pc.dim("]")} ${entry.name}${pc.dim(":")} ${entry.details}`;
|
|
2707
2721
|
});
|
|
2708
2722
|
}
|
|
2723
|
+
function printSchemaDiffTarget(target) {
|
|
2724
|
+
if (target === "published") {
|
|
2725
|
+
p.log.info("Comparing against the published (deployed) form (2-way; base snapshot not used).");
|
|
2726
|
+
return;
|
|
2727
|
+
}
|
|
2728
|
+
p.log.info("Comparing against the preview (unpublished) form.");
|
|
2729
|
+
}
|
|
2709
2730
|
function printDiffResult(result) {
|
|
2710
2731
|
if (result.isEmpty) {
|
|
2711
2732
|
p.log.info("No changes detected.");
|
|
@@ -9172,11 +9193,12 @@ function toFieldDto(field) {
|
|
|
9172
9193
|
properties: fieldPropertiesToDto(field)
|
|
9173
9194
|
};
|
|
9174
9195
|
}
|
|
9175
|
-
async function detectDiff({ container }) {
|
|
9196
|
+
async function detectDiff({ container, input }) {
|
|
9197
|
+
const target = input?.target ?? "preview";
|
|
9176
9198
|
const result = await container.schemaStorage.get();
|
|
9177
9199
|
if (!result.exists) throw new ValidationError(ValidationErrorCode.InvalidInput, "Schema file not found");
|
|
9178
9200
|
const schema = parseSchemaText(container.configCodec, result.content);
|
|
9179
|
-
const [currentFields, currentLayout] = await Promise.all([container.formConfigurator.getFields(), container.formConfigurator.getLayout()]);
|
|
9201
|
+
const [currentFields, currentLayout] = await Promise.all([container.formConfigurator.getFields(target), container.formConfigurator.getLayout(target)]);
|
|
9180
9202
|
const diff = DiffDetector.detect(schema, currentFields);
|
|
9181
9203
|
const enrichedCurrentLayout = enrichLayoutWithFields(currentLayout, currentFields);
|
|
9182
9204
|
const hasLayoutChanges = DiffDetector.detectLayoutChanges(schema.layout, enrichedCurrentLayout);
|
|
@@ -17736,41 +17758,71 @@ function buildLayoutExtras(layoutConflict, layoutLocalChanged, layoutRemoteChang
|
|
|
17736
17758
|
return [];
|
|
17737
17759
|
}
|
|
17738
17760
|
//#endregion
|
|
17761
|
+
//#region src/cli/commands/schema/formReadTarget.ts
|
|
17762
|
+
/**
|
|
17763
|
+
* Shared `--published` flag for the schema commands that read a form definition
|
|
17764
|
+
* (`dump` / `diff`). Kept next to its users rather than in `src/cli/config.ts`,
|
|
17765
|
+
* which holds only domain-agnostic connection/execution-mode options.
|
|
17766
|
+
*/
|
|
17767
|
+
const formReadTargetArgs = { published: {
|
|
17768
|
+
type: "boolean",
|
|
17769
|
+
description: "Read the published (deployed) form instead of the preview (unpublished) one"
|
|
17770
|
+
} };
|
|
17771
|
+
function resolveFormReadTarget(values) {
|
|
17772
|
+
return values.published ? "published" : "preview";
|
|
17773
|
+
}
|
|
17774
|
+
//#endregion
|
|
17739
17775
|
//#region src/cli/commands/schema/diff.ts
|
|
17740
|
-
async function runDiff$2(container) {
|
|
17776
|
+
async function runDiff$2(container, target) {
|
|
17777
|
+
printSchemaDiffTarget(target);
|
|
17741
17778
|
const s = p.spinner();
|
|
17742
17779
|
s.start("Comparing schema...");
|
|
17743
17780
|
let result;
|
|
17744
17781
|
try {
|
|
17745
|
-
result =
|
|
17782
|
+
result = target === "published" ? {
|
|
17783
|
+
kind: "published",
|
|
17784
|
+
value: await detectDiff({
|
|
17785
|
+
container,
|
|
17786
|
+
input: { target }
|
|
17787
|
+
})
|
|
17788
|
+
} : {
|
|
17789
|
+
kind: "preview",
|
|
17790
|
+
value: await detectThreeWayDiff({ container })
|
|
17791
|
+
};
|
|
17746
17792
|
} catch (error) {
|
|
17747
17793
|
s.stop("Comparison failed.");
|
|
17748
17794
|
throw error;
|
|
17749
17795
|
}
|
|
17750
17796
|
s.stop("Comparison complete.");
|
|
17751
|
-
|
|
17797
|
+
if (result.kind === "published") {
|
|
17798
|
+
printDiffResult(result.value);
|
|
17799
|
+
return;
|
|
17800
|
+
}
|
|
17801
|
+
printThreeWayDiffResult(result.value, printDiffResult);
|
|
17752
17802
|
}
|
|
17753
17803
|
var diff_default$2 = define({
|
|
17754
17804
|
name: "diff",
|
|
17755
17805
|
description: "Detect differences between schema file and current kintone form",
|
|
17756
17806
|
args: {
|
|
17757
17807
|
...kintoneArgs,
|
|
17758
|
-
...multiAppArgs
|
|
17808
|
+
...multiAppArgs,
|
|
17809
|
+
...formReadTargetArgs
|
|
17759
17810
|
},
|
|
17760
17811
|
run: async (ctx) => {
|
|
17761
17812
|
try {
|
|
17813
|
+
const target = resolveFormReadTarget(ctx.values);
|
|
17762
17814
|
await routeMultiApp(ctx.values, {
|
|
17763
17815
|
singleLegacy: async () => {
|
|
17764
|
-
await runDiff$2(createCliContainer(resolveConfig(ctx.values)));
|
|
17816
|
+
await runDiff$2(createCliContainer(resolveConfig(ctx.values)), target);
|
|
17765
17817
|
},
|
|
17766
17818
|
singleApp: async (app, projectConfig) => {
|
|
17767
|
-
await runDiff$2(createCliContainer(resolveAppCliConfig(app, projectConfig, ctx.values)));
|
|
17819
|
+
await runDiff$2(createCliContainer(resolveAppCliConfig(app, projectConfig, ctx.values)), target);
|
|
17768
17820
|
},
|
|
17769
17821
|
multiApp: async (plan, projectConfig) => {
|
|
17770
17822
|
await runMultiAppWithFailCheck(plan, async (app) => {
|
|
17771
17823
|
const container = createCliContainer(resolveAppCliConfig(app, projectConfig, ctx.values));
|
|
17772
17824
|
printAppHeader(app.name, app.appId);
|
|
17773
|
-
await runDiff$2(container);
|
|
17825
|
+
await runDiff$2(container, target);
|
|
17774
17826
|
}, "All schema diffs completed successfully.");
|
|
17775
17827
|
}
|
|
17776
17828
|
});
|
|
@@ -17781,26 +17833,31 @@ var diff_default$2 = define({
|
|
|
17781
17833
|
});
|
|
17782
17834
|
//#endregion
|
|
17783
17835
|
//#region src/core/adapters/kintone/formDumpReader.ts
|
|
17836
|
+
const GET_RAW_FORM_DATA_FAILURE_MESSAGES = {
|
|
17837
|
+
preview: "Failed to fetch raw form data for dump",
|
|
17838
|
+
published: "Failed to fetch published raw form data for dump (the app may not be deployed yet, or the credentials may not be allowed to read it)"
|
|
17839
|
+
};
|
|
17784
17840
|
var KintoneFormDumpReader = class {
|
|
17785
17841
|
constructor(client, appId) {
|
|
17786
17842
|
this.client = client;
|
|
17787
17843
|
this.appId = appId;
|
|
17788
17844
|
}
|
|
17789
|
-
async getRawFormData() {
|
|
17845
|
+
async getRawFormData(target = DEFAULT_FORM_READ_TARGET) {
|
|
17846
|
+
const preview = target === "preview";
|
|
17790
17847
|
try {
|
|
17791
17848
|
const [fields, layout] = await Promise.all([this.client.app.getFormFields({
|
|
17792
17849
|
app: this.appId,
|
|
17793
|
-
preview
|
|
17850
|
+
preview
|
|
17794
17851
|
}), this.client.app.getFormLayout({
|
|
17795
17852
|
app: this.appId,
|
|
17796
|
-
preview
|
|
17853
|
+
preview
|
|
17797
17854
|
})]);
|
|
17798
17855
|
return {
|
|
17799
17856
|
fields,
|
|
17800
17857
|
layout
|
|
17801
17858
|
};
|
|
17802
17859
|
} catch (error) {
|
|
17803
|
-
throw wrapKintoneError(error,
|
|
17860
|
+
throw wrapKintoneError(error, GET_RAW_FORM_DATA_FAILURE_MESSAGES[target]);
|
|
17804
17861
|
}
|
|
17805
17862
|
}
|
|
17806
17863
|
};
|
|
@@ -17844,29 +17901,38 @@ function createDumpCliContainer(config) {
|
|
|
17844
17901
|
}
|
|
17845
17902
|
//#endregion
|
|
17846
17903
|
//#region src/core/application/formSchema/dumpForm.ts
|
|
17847
|
-
async function dumpForm({ container }) {
|
|
17848
|
-
const rawData = await container.formDumpReader.getRawFormData();
|
|
17904
|
+
async function dumpForm({ container, input }) {
|
|
17905
|
+
const rawData = await container.formDumpReader.getRawFormData(input?.target ?? "preview");
|
|
17849
17906
|
await Promise.all([container.dumpStorage.saveFields(JSON.stringify(rawData.fields, null, 2)), container.dumpStorage.saveLayout(JSON.stringify(rawData.layout, null, 2))]);
|
|
17850
17907
|
}
|
|
17851
17908
|
//#endregion
|
|
17852
17909
|
//#region src/cli/commands/schema/dump.ts
|
|
17853
|
-
async function runSingleDump(config) {
|
|
17854
|
-
const
|
|
17910
|
+
async function runSingleDump(config, basePrefix, target) {
|
|
17911
|
+
const filePrefix = `${basePrefix}${target === "published" ? "published-" : ""}`;
|
|
17912
|
+
const container = createDumpCliContainer({
|
|
17913
|
+
...config,
|
|
17914
|
+
filePrefix
|
|
17915
|
+
});
|
|
17855
17916
|
const s = p.spinner();
|
|
17856
|
-
s.start("Fetching form fields and layout...");
|
|
17857
|
-
await dumpForm({
|
|
17917
|
+
s.start(target === "published" ? "Fetching published form fields and layout..." : "Fetching form fields and layout...");
|
|
17918
|
+
await dumpForm({
|
|
17919
|
+
container,
|
|
17920
|
+
input: { target }
|
|
17921
|
+
});
|
|
17858
17922
|
s.stop("Form data fetched.");
|
|
17859
|
-
p.log.success(`Saved ${pc.cyan(`${
|
|
17923
|
+
p.log.success(`Saved ${pc.cyan(`${filePrefix}fields.json`)} and ${pc.cyan(`${filePrefix}layout.json`)}`);
|
|
17860
17924
|
}
|
|
17861
17925
|
var dump_default = define({
|
|
17862
17926
|
name: "dump",
|
|
17863
17927
|
description: "Dump current kintone form fields and layout as JSON",
|
|
17864
17928
|
args: {
|
|
17865
17929
|
...kintoneArgs,
|
|
17866
|
-
...multiAppArgs
|
|
17930
|
+
...multiAppArgs,
|
|
17931
|
+
...formReadTargetArgs
|
|
17867
17932
|
},
|
|
17868
17933
|
run: async (ctx) => {
|
|
17869
17934
|
try {
|
|
17935
|
+
const target = resolveFormReadTarget(ctx.values);
|
|
17870
17936
|
await routeMultiApp(ctx.values, {
|
|
17871
17937
|
singleLegacy: async () => {
|
|
17872
17938
|
const config = resolveConfig(ctx.values);
|
|
@@ -17874,9 +17940,8 @@ var dump_default = define({
|
|
|
17874
17940
|
baseUrl: config.baseUrl,
|
|
17875
17941
|
auth: config.auth,
|
|
17876
17942
|
appId: config.appId,
|
|
17877
|
-
guestSpaceId: config.guestSpaceId
|
|
17878
|
-
|
|
17879
|
-
});
|
|
17943
|
+
guestSpaceId: config.guestSpaceId
|
|
17944
|
+
}, "", target);
|
|
17880
17945
|
},
|
|
17881
17946
|
singleApp: async (app, projectConfig) => {
|
|
17882
17947
|
const config = resolveAppCliConfig(app, projectConfig, ctx.values);
|
|
@@ -17884,9 +17949,8 @@ var dump_default = define({
|
|
|
17884
17949
|
baseUrl: config.baseUrl,
|
|
17885
17950
|
auth: config.auth,
|
|
17886
17951
|
appId: config.appId,
|
|
17887
|
-
guestSpaceId: config.guestSpaceId
|
|
17888
|
-
|
|
17889
|
-
});
|
|
17952
|
+
guestSpaceId: config.guestSpaceId
|
|
17953
|
+
}, `${app.name}-`, target);
|
|
17890
17954
|
},
|
|
17891
17955
|
multiApp: async (plan, projectConfig) => {
|
|
17892
17956
|
await runMultiAppWithFailCheck(plan, async (app) => {
|
|
@@ -17896,9 +17960,8 @@ var dump_default = define({
|
|
|
17896
17960
|
baseUrl: config.baseUrl,
|
|
17897
17961
|
auth: config.auth,
|
|
17898
17962
|
appId: config.appId,
|
|
17899
|
-
guestSpaceId: config.guestSpaceId
|
|
17900
|
-
|
|
17901
|
-
});
|
|
17963
|
+
guestSpaceId: config.guestSpaceId
|
|
17964
|
+
}, `${app.name}-`, target);
|
|
17902
17965
|
}, "All dumps completed successfully.");
|
|
17903
17966
|
}
|
|
17904
17967
|
});
|