kintone-migrator 0.9.1 → 0.10.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 +11 -0
  2. package/dist/index.mjs +65 -42
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -92,9 +92,14 @@ Applies schema file changes to the kintone form. Displays the diff and prompts f
92
92
  ```bash
93
93
  kintone-migrator migrate
94
94
 
95
+ # Skip confirmation prompts (for CI/CD)
96
+ kintone-migrator migrate --yes
97
+ kintone-migrator migrate -y
98
+
95
99
  # Multi-app mode
96
100
  kintone-migrator migrate --app customer
97
101
  kintone-migrator migrate --all
102
+ kintone-migrator migrate --all --yes
98
103
  ```
99
104
 
100
105
  ### `override`
@@ -104,12 +109,17 @@ Overwrites the entire kintone form with the schema file contents. Fields not def
104
109
  ```bash
105
110
  kintone-migrator override
106
111
 
112
+ # Skip confirmation prompts (for CI/CD)
113
+ kintone-migrator override --yes
114
+ kintone-migrator override -y
115
+
107
116
  # Reset form: delete all custom fields (no schema file needed)
108
117
  kintone-migrator override --reset
109
118
 
110
119
  # Multi-app mode
111
120
  kintone-migrator override --all
112
121
  kintone-migrator override --reset --all
122
+ kintone-migrator override --all --yes
113
123
  ```
114
124
 
115
125
  #### Override-specific arguments
@@ -117,6 +127,7 @@ kintone-migrator override --reset --all
117
127
  | CLI Argument | Description |
118
128
  |---------|------|
119
129
  | `--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. |
130
+ | `--yes`, `-y` | Skip confirmation prompts. Also available on `migrate`. |
120
131
 
121
132
  ### `capture`
122
133
 
package/dist/index.mjs CHANGED
@@ -130,6 +130,11 @@ const kintoneArgs = {
130
130
  description: "Schema file path (default: schema.yaml)"
131
131
  }
132
132
  };
133
+ const confirmArgs = { yes: {
134
+ type: "boolean",
135
+ short: "y",
136
+ description: "Skip confirmation prompts"
137
+ } };
133
138
  const multiAppArgs = {
134
139
  app: {
135
140
  type: "string",
@@ -1090,11 +1095,13 @@ function printMultiAppResult(result) {
1090
1095
  break;
1091
1096
  }
1092
1097
  }
1093
- async function promptDeploy(container) {
1094
- const shouldDeploy = await p.confirm({ message: "運用環境に反映しますか?" });
1095
- if (p.isCancel(shouldDeploy) || !shouldDeploy) {
1096
- p.log.warn("テスト環境に反映済みですが、運用環境には反映されていません。");
1097
- return;
1098
+ async function promptDeploy(container, skipConfirm) {
1099
+ if (!skipConfirm) {
1100
+ const shouldDeploy = await p.confirm({ message: "運用環境に反映しますか?" });
1101
+ if (p.isCancel(shouldDeploy) || !shouldDeploy) {
1102
+ p.log.warn("テスト環境に反映済みですが、運用環境には反映されていません。");
1103
+ return;
1104
+ }
1098
1105
  }
1099
1106
  const ds = p.spinner();
1100
1107
  ds.start("運用環境に反映しています...");
@@ -2276,7 +2283,7 @@ async function executeMigration({ container }) {
2276
2283
 
2277
2284
  //#endregion
2278
2285
  //#region src/cli/commands/migrate.ts
2279
- async function runSingleMigrate(container) {
2286
+ async function runSingleMigrate(container, skipConfirm) {
2280
2287
  const s = p.spinner();
2281
2288
  s.start("Detecting changes...");
2282
2289
  const result = await detectDiff({ container });
@@ -2286,33 +2293,37 @@ async function runSingleMigrate(container) {
2286
2293
  return;
2287
2294
  }
2288
2295
  printDiffResult(result);
2289
- const shouldContinue = await p.confirm({ message: "Apply these changes?" });
2290
- if (p.isCancel(shouldContinue) || !shouldContinue) {
2291
- p.cancel("Migration cancelled.");
2292
- process.exit(0);
2296
+ if (!skipConfirm) {
2297
+ const shouldContinue = await p.confirm({ message: "Apply these changes?" });
2298
+ if (p.isCancel(shouldContinue) || !shouldContinue) {
2299
+ p.cancel("Migration cancelled.");
2300
+ process.exit(0);
2301
+ }
2293
2302
  }
2294
2303
  const ms = p.spinner();
2295
2304
  ms.start("Applying migration...");
2296
2305
  await executeMigration({ container });
2297
2306
  ms.stop("Migration applied.");
2298
2307
  p.log.success("Migration completed successfully.");
2299
- await promptDeploy(container);
2308
+ await promptDeploy(container, skipConfirm);
2300
2309
  }
2301
2310
  var migrate_default = define({
2302
2311
  name: "migrate",
2303
2312
  description: "Apply schema changes to kintone form",
2304
2313
  args: {
2305
2314
  ...kintoneArgs,
2306
- ...multiAppArgs
2315
+ ...multiAppArgs,
2316
+ ...confirmArgs
2307
2317
  },
2308
2318
  run: async (ctx) => {
2309
2319
  try {
2320
+ const skipConfirm = ctx.values.yes === true;
2310
2321
  await routeMultiApp(ctx.values, {
2311
2322
  singleLegacy: async () => {
2312
- await runSingleMigrate(createCliContainer(resolveConfig(ctx.values)));
2323
+ await runSingleMigrate(createCliContainer(resolveConfig(ctx.values)), skipConfirm);
2313
2324
  },
2314
2325
  singleApp: async (app, projectConfig) => {
2315
- await runSingleMigrate(createCliContainer(resolveAppCliConfig(app, projectConfig, ctx.values)));
2326
+ await runSingleMigrate(createCliContainer(resolveAppCliConfig(app, projectConfig, ctx.values)), skipConfirm);
2316
2327
  },
2317
2328
  multiApp: async (plan, projectConfig) => {
2318
2329
  const appContainers = [];
@@ -2334,10 +2345,12 @@ var migrate_default = define({
2334
2345
  p.log.success("No changes detected in any app. All forms are up to date.");
2335
2346
  return;
2336
2347
  }
2337
- const shouldContinue = await p.confirm({ message: "Apply these changes to all apps?" });
2338
- if (p.isCancel(shouldContinue) || !shouldContinue) {
2339
- p.cancel("Migration cancelled.");
2340
- process.exit(0);
2348
+ if (!skipConfirm) {
2349
+ const shouldContinue = await p.confirm({ message: "Apply these changes to all apps?" });
2350
+ if (p.isCancel(shouldContinue) || !shouldContinue) {
2351
+ p.cancel("Migration cancelled.");
2352
+ process.exit(0);
2353
+ }
2341
2354
  }
2342
2355
  await runMultiAppWithFailCheck(plan, async (app) => {
2343
2356
  const entry = appContainers.find((a) => a.app.name === app.name);
@@ -2407,34 +2420,38 @@ async function resetForm({ container }) {
2407
2420
 
2408
2421
  //#endregion
2409
2422
  //#region src/cli/commands/override.ts
2410
- async function runSingleOverride(container) {
2423
+ async function runSingleOverride(container, skipConfirm) {
2411
2424
  p.log.warn(`${pc.bold(pc.red("WARNING:"))} This will replace the entire form with the declared schema.`);
2412
2425
  p.log.warn("Fields not defined in the schema will be deleted.");
2413
- const shouldContinue = await p.confirm({ message: "Are you sure you want to force override?" });
2414
- if (p.isCancel(shouldContinue) || !shouldContinue) {
2415
- p.cancel("Force override cancelled.");
2416
- process.exit(0);
2426
+ if (!skipConfirm) {
2427
+ const shouldContinue = await p.confirm({ message: "Are you sure you want to force override?" });
2428
+ if (p.isCancel(shouldContinue) || !shouldContinue) {
2429
+ p.cancel("Force override cancelled.");
2430
+ process.exit(0);
2431
+ }
2417
2432
  }
2418
2433
  const s = p.spinner();
2419
2434
  s.start("Force overriding form...");
2420
2435
  await forceOverrideForm({ container });
2421
2436
  s.stop("Force override applied.");
2422
2437
  p.log.success("Force override completed successfully.");
2423
- await promptDeploy(container);
2438
+ await promptDeploy(container, skipConfirm);
2424
2439
  }
2425
- async function runSingleReset(container) {
2440
+ async function runSingleReset(container, skipConfirm) {
2426
2441
  p.log.warn(`${pc.bold(pc.red("WARNING:"))} This will delete ALL custom fields, resetting the form to empty.`);
2427
- const shouldContinue = await p.confirm({ message: "Are you sure you want to reset the form?" });
2428
- if (p.isCancel(shouldContinue) || !shouldContinue) {
2429
- p.cancel("Reset cancelled.");
2430
- process.exit(0);
2442
+ if (!skipConfirm) {
2443
+ const shouldContinue = await p.confirm({ message: "Are you sure you want to reset the form?" });
2444
+ if (p.isCancel(shouldContinue) || !shouldContinue) {
2445
+ p.cancel("Reset cancelled.");
2446
+ process.exit(0);
2447
+ }
2431
2448
  }
2432
2449
  const s = p.spinner();
2433
2450
  s.start("Resetting form...");
2434
2451
  await resetForm({ container });
2435
2452
  s.stop("Form reset applied.");
2436
2453
  p.log.success("Reset completed successfully.");
2437
- await promptDeploy(container);
2454
+ await promptDeploy(container, skipConfirm);
2438
2455
  }
2439
2456
  var override_default = define({
2440
2457
  name: "override",
@@ -2442,6 +2459,7 @@ var override_default = define({
2442
2459
  args: {
2443
2460
  ...kintoneArgs,
2444
2461
  ...multiAppArgs,
2462
+ ...confirmArgs,
2445
2463
  reset: {
2446
2464
  type: "boolean",
2447
2465
  description: "Reset form by deleting all custom fields"
@@ -2450,25 +2468,28 @@ var override_default = define({
2450
2468
  run: async (ctx) => {
2451
2469
  try {
2452
2470
  const isReset = ctx.values.reset === true;
2471
+ const skipConfirm = ctx.values.yes === true;
2453
2472
  if (isReset && ctx.values["schema-file"]) throw new ValidationError(ValidationErrorCode.InvalidInput, "--reset and --schema-file cannot be used together");
2454
2473
  await routeMultiApp(ctx.values, {
2455
2474
  singleLegacy: async () => {
2456
2475
  const container = createCliContainer(resolveConfig(ctx.values));
2457
- if (isReset) await runSingleReset(container);
2458
- else await runSingleOverride(container);
2476
+ if (isReset) await runSingleReset(container, skipConfirm);
2477
+ else await runSingleOverride(container, skipConfirm);
2459
2478
  },
2460
2479
  singleApp: async (app, projectConfig) => {
2461
2480
  const container = createCliContainer(resolveAppCliConfig(app, projectConfig, ctx.values));
2462
- if (isReset) await runSingleReset(container);
2463
- else await runSingleOverride(container);
2481
+ if (isReset) await runSingleReset(container, skipConfirm);
2482
+ else await runSingleOverride(container, skipConfirm);
2464
2483
  },
2465
2484
  multiApp: async (plan, projectConfig) => {
2466
2485
  if (isReset) {
2467
2486
  p.log.warn(`${pc.bold(pc.red("WARNING:"))} This will delete ALL custom fields from ALL apps, resetting them to empty.`);
2468
- const shouldContinue = await p.confirm({ message: "Are you sure you want to reset all apps?" });
2469
- if (p.isCancel(shouldContinue) || !shouldContinue) {
2470
- p.cancel("Reset cancelled.");
2471
- process.exit(0);
2487
+ if (!skipConfirm) {
2488
+ const shouldContinue = await p.confirm({ message: "Are you sure you want to reset all apps?" });
2489
+ if (p.isCancel(shouldContinue) || !shouldContinue) {
2490
+ p.cancel("Reset cancelled.");
2491
+ process.exit(0);
2492
+ }
2472
2493
  }
2473
2494
  await runMultiAppWithFailCheck({ orderedApps: [...plan.orderedApps].reverse() }, async (app) => {
2474
2495
  const container = createCliContainer(resolveAppCliConfig(app, projectConfig, ctx.values));
@@ -2485,10 +2506,12 @@ var override_default = define({
2485
2506
  } else {
2486
2507
  p.log.warn(`${pc.bold(pc.red("WARNING:"))} This will replace the entire form for ALL apps with their declared schemas.`);
2487
2508
  p.log.warn("Fields not defined in each schema will be deleted.");
2488
- const shouldContinue = await p.confirm({ message: "Are you sure you want to force override all apps?" });
2489
- if (p.isCancel(shouldContinue) || !shouldContinue) {
2490
- p.cancel("Force override cancelled.");
2491
- process.exit(0);
2509
+ if (!skipConfirm) {
2510
+ const shouldContinue = await p.confirm({ message: "Are you sure you want to force override all apps?" });
2511
+ if (p.isCancel(shouldContinue) || !shouldContinue) {
2512
+ p.cancel("Force override cancelled.");
2513
+ process.exit(0);
2514
+ }
2492
2515
  }
2493
2516
  await runMultiAppWithFailCheck(plan, async (app) => {
2494
2517
  const container = createCliContainer(resolveAppCliConfig(app, projectConfig, ctx.values));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kintone-migrator",
3
- "version": "0.9.1",
3
+ "version": "0.10.0",
4
4
  "description": "kintone form schema migration tool",
5
5
  "license": "MIT",
6
6
  "author": "Hikaru Otabe",