@intra-mart/accel 0.4.0-dev.202607210732 → 0.4.0-dev.202607280237

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 CHANGED
@@ -234,6 +234,14 @@ accel deploy
234
234
  4. 実行結果を一覧表示
235
235
  - **注意**: セットアップの実行はステージング分離されず、実テナントのデータベースに反映されます
236
236
  - セットアップの成否はデプロイの終了コードに影響しません(デプロイ成功 = 正常終了)
237
+ - テナント環境セットアップに続けて、iAP からサンプルデータセットアップ設定が返ってきた場合は、対話的にサンプルデータセットアップの実行を提案します:
238
+ - 流れはテナント環境セットアップと同様です(設定の情報表示 → 実行確認 → 一括実行 or 複数選択して順次実行 → 結果一覧表示)
239
+ - **テナント環境セットアップの実行有無・成否に関わらず提案します**(サンプルデータセットアップのみを実行したいケースに対応するため)
240
+ - サーバー側の仕様として、**前処理の失敗のみ致命的**(以降の実行を中断)として扱われます。中断が発生した場合はその旨を警告表示します
241
+ - テナント環境セットアップと同様、実行はステージング分離されず実テナントのデータベースに反映されます。成否はデプロイの終了コードに影響しません
242
+ - `--tenant-setup` / `--sample-setup` フラグを指定すると、対象のセットアップ(テナント環境セットアップ/サンプルデータセットアップ)を**確認プロンプトなしで一括実行**します(対話・非対話共通):
243
+ - フラグ指定により実行したセットアップが失敗した場合は、デプロイ自体は成功している旨を表示した上で**非0終了**します(CI での失敗検知を想定)
244
+ - フラグを指定したがセットアップ設定が資材に存在しない場合は、警告を表示して正常終了します
237
245
 
238
246
  #### 非対話モード
239
247
 
@@ -257,7 +265,7 @@ ACCEL_API_KEY=*** accel deploy \
257
265
  - `--file` 未指定の場合は対話モードと同じ自動特定(`<artifactId>-<projectVersion>.zip` 完全一致)を試みます。**自動特定できない場合**(settings 無し/完全一致無し/複数候補)は `--file` 指定が必要な旨を表示してエラー終了します。`./target/` に zip が 1 件も無い場合は、ビルド未実行の旨(`mvn package` 等の実行を促す)を表示してエラー終了します。
258
266
  - `--additional-file` は任意です。指定した場合は各パスの存在・拡張子(`.imm` / `.zip`)・重複を検証し、違反があればエラー終了します。デプロイ順は「`--additional-file` の指定順 → ビルド成果物(最後)」で固定です(順番確認プロンプトは出しません)。
259
267
  - `--description` は任意です。最終確認プロンプトは出さず、即デプロイします。
260
- - **テナント環境セットアップは実行しません**(対話が必要なため)。自動ログイン付きURLはデプロイ結果に含めて表示します。
268
+ - **フラグ未指定時、テナント環境セットアップ/サンプルデータセットアップは実行しません**(対話が必要なため)。`--tenant-setup` / `--sample-setup` を指定した場合のみ、デプロイ成功後に対象のセットアップを一括実行します(両指定時はテナント環境セットアップ → サンプルデータセットアップの順。テナント側が失敗してもサンプル側は実行します)。セットアップが失敗した場合は、デプロイ自体は成功している旨を表示した上で非0終了します。自動ログイン付きURLはデプロイ結果に含めて表示します。
261
269
  - フラグ/環境変数で渡した接続情報は **`.accel/credentials.json` に保存しません**(CIランナーにシークレット情報を残さないため)。
262
270
 
263
271
  #### オプション一覧
@@ -270,6 +278,8 @@ ACCEL_API_KEY=*** accel deploy \
270
278
  | `--file` | string | デプロイする zip のパス(`./target/` 配下に限定しない) | 自動特定 / 対話で選択 |
271
279
  | `--additional-file` | string(複数指定可) | 追加でデプロイするアーカイブファイルのパス(`.imm` / `.zip`。指定順にビルド成果物より先に展開) | なし |
272
280
  | `--description` | string | デプロイメントの説明 | `""` |
281
+ | `--tenant-setup` | boolean | テナント環境セットアップを確認なしで一括実行(失敗時は非0終了) | `false` |
282
+ | `--sample-setup` | boolean | サンプルデータセットアップを確認なしで一括実行(失敗時は非0終了) | `false` |
273
283
  | `--non-interactive` | boolean | 非対話モード(プロンプトを出さず、失敗時は非0終了) | `false` |
274
284
 
275
285
  #### 接続情報ファイル `.accel/credentials.json`
@@ -1,4 +1,5 @@
1
1
  import type { AssetProvider, AccelSettings, HashsumEntry } from "../core/types.js";
2
+ import { type AssetMessage } from "./messages.js";
2
3
  export { getInstallCmds } from "./installer.js";
3
4
  export type OverwriteDecision = "overwrite" | "skip";
4
5
  export type ExistingFileHandler = (relativePath: string) => Promise<OverwriteDecision>;
@@ -6,6 +7,7 @@ export type ProgressCallbacks = {
6
7
  onFetchStart?: () => void;
7
8
  onDownloadStart?: () => void;
8
9
  onSectionDeploy?: (section: string, files: string[]) => void;
10
+ onMessages?: (messages: AssetMessage[]) => void;
9
11
  onInstallStart?: (command: string) => void;
10
12
  onBuildStart?: (command: string) => void;
11
13
  };
@@ -2,6 +2,7 @@ import { writeFile, mkdir, stat } from "node:fs/promises";
2
2
  import { join, dirname, resolve, sep } from "node:path";
3
3
  import { buildEvalContext } from "../core/eval-context.js";
4
4
  import { walkAssetRepo } from "./walker.js";
5
+ import { createMessageCollector } from "./messages.js";
5
6
  import { renderAssetContent } from "./renderer.js";
6
7
  import { runInstallBuild } from "./installer.js";
7
8
  import { computeSha1 } from "../utils/hash.js";
@@ -66,7 +67,8 @@ export const deployAssets = async (options) => {
66
67
  };
67
68
  const semver = settings.accelplatformVersion.semver;
68
69
  const context = buildEvalContext(settings);
69
- const allEntries = await walkAssetRepo(tree, semver, context);
70
+ const messageCollector = createMessageCollector();
71
+ const allEntries = await walkAssetRepo(tree, semver, context, messageCollector.collect);
70
72
  const entries = allEntries.filter((entry) => {
71
73
  if (!isWithinDir(projectDir, join(projectDir, entry.relativePath))) {
72
74
  console.warn(`Warning: skipping asset with path escaping project directory: ${entry.relativePath}`);
@@ -134,6 +136,10 @@ export const deployAssets = async (options) => {
134
136
  };
135
137
  await writeSettings(projectDir, updatedSettings);
136
138
  await writeHashsum(projectDir, hashEntries);
139
+ const assetMessages = messageCollector.drain();
140
+ if (assetMessages.length > 0) {
141
+ progress?.onMessages?.(assetMessages);
142
+ }
137
143
  if (!noInstall) {
138
144
  runInstallBuild(projectDir, settings.packageManager, progress);
139
145
  }
@@ -0,0 +1,11 @@
1
+ import type { EvalContext, Message, MessageLevel } from "../core/types.js";
2
+ export type AssetMessage = {
3
+ level: MessageLevel;
4
+ text: string;
5
+ };
6
+ export type MessageSink = (messages: Message[], context: EvalContext) => void;
7
+ export type MessageCollector = {
8
+ collect: MessageSink;
9
+ drain: () => AssetMessage[];
10
+ };
11
+ export declare const createMessageCollector: () => MessageCollector;
@@ -0,0 +1,29 @@
1
+ import { evaluateCondition } from "../core/condition-evaluator.js";
2
+ import { interpolateVariables } from "../core/variable-interpolator.js";
3
+ export const createMessageCollector = () => {
4
+ const collected = [];
5
+ const seen = new Set();
6
+ const collect = (messages, context) => {
7
+ if (!Array.isArray(messages))
8
+ return;
9
+ for (const message of messages) {
10
+ if (typeof message?.text !== "string")
11
+ continue;
12
+ const { condition } = message;
13
+ if (condition != null) {
14
+ if (typeof condition !== "object")
15
+ continue;
16
+ if (!evaluateCondition(condition, context))
17
+ continue;
18
+ }
19
+ const level = message.level === "warn" ? "warn" : "info";
20
+ const text = interpolateVariables(message.text, context);
21
+ const key = `${level}\n${text}`;
22
+ if (seen.has(key))
23
+ continue;
24
+ seen.add(key);
25
+ collected.push({ level, text });
26
+ }
27
+ };
28
+ return { collect, drain: () => [...collected] };
29
+ };
@@ -1,5 +1,6 @@
1
1
  import type { AccelSettings, HashsumEntry } from "../core/types.js";
2
2
  import type { AssetTree } from "./asset-tree.js";
3
+ import type { MessageSink } from "./messages.js";
3
4
  import type { MergeFn } from "../utils/merge-file.js";
4
5
  export type RenderedAsset = {
5
6
  relativePath: string;
@@ -8,7 +9,7 @@ export type RenderedAsset = {
8
9
  sha1: string;
9
10
  };
10
11
  export type RenderedPlan = Map<string, RenderedAsset>;
11
- export declare const buildRenderedPlan: (tree: AssetTree, settings: AccelSettings, materialize?: (files: string[]) => Promise<void>) => Promise<RenderedPlan>;
12
+ export declare const buildRenderedPlan: (tree: AssetTree, settings: AccelSettings, materialize?: (files: string[]) => Promise<void>, collect?: MessageSink) => Promise<RenderedPlan>;
12
13
  export type FileState = {
13
14
  relativePath: string;
14
15
  base: RenderedAsset | null;
@@ -5,9 +5,9 @@ import { walkAssetRepo } from "./walker.js";
5
5
  import { renderAssetContent } from "./renderer.js";
6
6
  import { computeSha1 } from "../utils/hash.js";
7
7
  const isSafeRelPath = (p) => !p.startsWith("/") && !p.split("/").includes("..");
8
- export const buildRenderedPlan = async (tree, settings, materialize) => {
8
+ export const buildRenderedPlan = async (tree, settings, materialize, collect) => {
9
9
  const context = buildEvalContext(settings);
10
- const entries = await walkAssetRepo(tree, settings.accelplatformVersion.semver, context);
10
+ const entries = await walkAssetRepo(tree, settings.accelplatformVersion.semver, context, collect);
11
11
  const safeEntries = entries.filter((entry) => {
12
12
  if (!isSafeRelPath(entry.relativePath) || !isSafeRelPath(entry.sourceRelPath)) {
13
13
  console.warn(`Warning: skipping asset with unsafe path: ${entry.relativePath} (source: ${entry.sourceRelPath})`);
@@ -1,9 +1,10 @@
1
1
  import type { MetaJson, EvalContext } from "../core/types.js";
2
2
  import type { AssetTree } from "./asset-tree.js";
3
+ import type { MessageSink } from "./messages.js";
3
4
  export type AssetEntry = {
4
5
  sourceRelPath: string;
5
6
  relativePath: string;
6
7
  meta: MetaJson | null;
7
8
  };
8
9
  export declare const walkAssetDir: (tree: AssetTree, context: EvalContext) => Promise<AssetEntry[]>;
9
- export declare const walkAssetRepo: (tree: AssetTree, targetSemver: string, context: EvalContext) => Promise<AssetEntry[]>;
10
+ export declare const walkAssetRepo: (tree: AssetTree, targetSemver: string, context: EvalContext, collect?: MessageSink) => Promise<AssetEntry[]>;
@@ -77,7 +77,7 @@ const findMatchingVersionDirs = async (tree, vtree, targetSemver) => {
77
77
  }
78
78
  return matched;
79
79
  };
80
- const walkDirectory = async (tree, vtree, dir, baseDir, parentMeta, context) => {
80
+ const walkDirectory = async (tree, vtree, dir, baseDir, parentMeta, context, collect) => {
81
81
  const entries = [];
82
82
  const node = vtree.get(dir);
83
83
  if (!node)
@@ -89,6 +89,9 @@ const walkDirectory = async (tree, vtree, dir, baseDir, parentMeta, context) =>
89
89
  return [];
90
90
  }
91
91
  }
92
+ if (collect && ownMeta?.messages) {
93
+ collect(ownMeta.messages, context);
94
+ }
92
95
  const relativeOf = (p) => p === baseDir ? "" : baseDir === "" ? p : p.slice(baseDir.length + 1);
93
96
  if (ownMeta?.type === "file") {
94
97
  const parentRelative = relativeOf(dirnamePosix(dir));
@@ -122,7 +125,7 @@ const walkDirectory = async (tree, vtree, dir, baseDir, parentMeta, context) =>
122
125
  }
123
126
  const fullPath = joinPosix(dir, name);
124
127
  if (node.subdirs.has(name)) {
125
- const children = await walkDirectory(tree, vtree, fullPath, baseDir, effectiveMeta, context);
128
+ const children = await walkDirectory(tree, vtree, fullPath, baseDir, effectiveMeta, context, collect);
126
129
  entries.push(...children);
127
130
  }
128
131
  else {
@@ -158,7 +161,7 @@ export const walkAssetDir = async (tree, context) => {
158
161
  const entries = await walkDirectory(tree, vtree, "", "", meta, context);
159
162
  return deduplicateByPath(entries);
160
163
  };
161
- export const walkAssetRepo = async (tree, targetSemver, context) => {
164
+ export const walkAssetRepo = async (tree, targetSemver, context, collect) => {
162
165
  const rootFiles = await tree.listRootEntries();
163
166
  const rootVtree = buildVirtualTree(rootFiles);
164
167
  const versionDirs = await findMatchingVersionDirs(tree, rootVtree, targetSemver);
@@ -169,7 +172,7 @@ export const walkAssetRepo = async (tree, targetSemver, context) => {
169
172
  const allEntries = [];
170
173
  for (const versionDir of versionDirs) {
171
174
  const meta = await readMetaJson(tree, vtree, versionDir);
172
- const entries = await walkDirectory(tree, vtree, versionDir, versionDir, meta, context);
175
+ const entries = await walkDirectory(tree, vtree, versionDir, versionDir, meta, context, collect);
173
176
  allEntries.push(...entries);
174
177
  }
175
178
  return deduplicateByPath(allEntries);
@@ -1,4 +1,4 @@
1
- import type { AccelCredentials, SetupConfigResponse, StagingResponse } from "../core/types.js";
1
+ import type { AccelCredentials, SampleSetupConfigResponse, SetupConfigResponse, StagingResponse } from "../core/types.js";
2
2
  import { type ApiClient } from "../deploy/api-client.js";
3
3
  import { type DeployFile } from "../deploy/deploy-files.js";
4
4
  export type ConfirmInfo = {
@@ -16,6 +16,9 @@ export type DeployPrompts = {
16
16
  confirmSetup: (configs: SetupConfigResponse[], locale: string) => Promise<boolean>;
17
17
  confirmSetupAll: (locale: string) => Promise<boolean>;
18
18
  selectSetupConfigs: (configs: SetupConfigResponse[], locale: string) => Promise<SetupConfigResponse[]>;
19
+ confirmSampleSetup: (configs: SampleSetupConfigResponse[], locale: string) => Promise<boolean>;
20
+ confirmSampleSetupAll: (locale: string) => Promise<boolean>;
21
+ selectSampleSetupConfigs: (configs: SampleSetupConfigResponse[], locale: string) => Promise<SampleSetupConfigResponse[]>;
19
22
  };
20
23
  export type RunDeployDeps = {
21
24
  projectDir: string;
@@ -27,6 +30,8 @@ export type RunDeployDeps = {
27
30
  file?: string;
28
31
  additionalFiles?: string[];
29
32
  description?: string;
33
+ tenantSetup?: boolean;
34
+ sampleSetup?: boolean;
30
35
  env?: Record<string, string | undefined>;
31
36
  ensureCredentials?: (projectDir: string, locale: string, seed?: Partial<AccelCredentials>) => Promise<AccelCredentials>;
32
37
  repromptCredentials?: (current: AccelCredentials, locale: string) => Promise<AccelCredentials>;
@@ -62,6 +67,16 @@ export declare const deployCommand: import("citty").CommandDef<{
62
67
  type: "string";
63
68
  description: string;
64
69
  };
70
+ "tenant-setup": {
71
+ type: "boolean";
72
+ description: string;
73
+ default: false;
74
+ };
75
+ "sample-setup": {
76
+ type: "boolean";
77
+ description: string;
78
+ default: false;
79
+ };
65
80
  "non-interactive": {
66
81
  type: "boolean";
67
82
  description: string;
@@ -21,6 +21,8 @@ const ADDITIONAL_FILE_ERROR_KEY = {
21
21
  duplicate: "deploy.error.additionalFileDuplicate",
22
22
  };
23
23
  const setupConfigKey = (c) => `${c.moduleId}\u0000${c.configNumber}`;
24
+ const setupConfigLabel = (c) => `#${c.configNumber} ${c.moduleId} [${c.sections.join(", ")}]`;
25
+ const sampleSetupConfigLabel = (c) => `${c.moduleId} [${c.sections.join(", ")}]`;
24
26
  const defaultPrompts = {
25
27
  selectStaging: async (stagings, locale) => {
26
28
  const res = await p.select({
@@ -93,9 +95,7 @@ const defaultPrompts = {
93
95
  return res;
94
96
  },
95
97
  confirmSetup: async (configs, locale) => {
96
- p.note(configs
97
- .map((c) => `#${c.configNumber} ${c.moduleId} [${c.sections.join(", ")}]`)
98
- .join("\n"), getMessage("deploy.setup.heading", locale));
98
+ p.note(configs.map(setupConfigLabel).join("\n"), getMessage("deploy.setup.heading", locale));
99
99
  const res = await p.confirm({
100
100
  message: getMessage("deploy.setup.confirm", locale),
101
101
  initialValue: true,
@@ -118,7 +118,7 @@ const defaultPrompts = {
118
118
  message: getMessage("deploy.setup.selectConfigs", locale),
119
119
  options: configs.map((c) => ({
120
120
  value: setupConfigKey(c),
121
- label: `#${c.configNumber} ${c.moduleId} [${c.sections.join(", ")}]`,
121
+ label: setupConfigLabel(c),
122
122
  })),
123
123
  required: true,
124
124
  });
@@ -127,6 +127,39 @@ const defaultPrompts = {
127
127
  const selected = new Set(res);
128
128
  return configs.filter((c) => selected.has(setupConfigKey(c)));
129
129
  },
130
+ confirmSampleSetup: async (configs, locale) => {
131
+ p.note(configs.map(sampleSetupConfigLabel).join("\n"), getMessage("deploy.sampleSetup.heading", locale));
132
+ const res = await p.confirm({
133
+ message: getMessage("deploy.sampleSetup.confirm", locale),
134
+ initialValue: true,
135
+ });
136
+ if (p.isCancel(res))
137
+ process.exit(0);
138
+ return res;
139
+ },
140
+ confirmSampleSetupAll: async (locale) => {
141
+ const res = await p.confirm({
142
+ message: getMessage("deploy.sampleSetup.confirmAll", locale),
143
+ initialValue: true,
144
+ });
145
+ if (p.isCancel(res))
146
+ process.exit(0);
147
+ return res;
148
+ },
149
+ selectSampleSetupConfigs: async (configs, locale) => {
150
+ const res = await p.multiselect({
151
+ message: getMessage("deploy.sampleSetup.selectConfigs", locale),
152
+ options: configs.map((c) => ({
153
+ value: c.moduleId,
154
+ label: sampleSetupConfigLabel(c),
155
+ })),
156
+ required: true,
157
+ });
158
+ if (p.isCancel(res))
159
+ process.exit(0);
160
+ const selected = new Set(res);
161
+ return configs.filter((c) => selected.has(c.moduleId));
162
+ },
130
163
  };
131
164
  const resolveLocale = async (projectDir) => {
132
165
  try {
@@ -165,6 +198,11 @@ const formatDeployError = (err, locale) => {
165
198
  });
166
199
  }
167
200
  };
201
+ const describeError = (err, locale) => isDeployError(err)
202
+ ? formatDeployError(err, locale)
203
+ : err instanceof Error
204
+ ? err.message
205
+ : String(err);
168
206
  const resolveZipPath = async (opts) => {
169
207
  const { projectDir, locale, nonInteractive, fileArg, scan, selectZip } = opts;
170
208
  if (fileArg && fileArg.length > 0) {
@@ -307,22 +345,62 @@ export const runDeploy = async (deps) => {
307
345
  `${getMessage("deploy.result.createDate", locale)}: ${formatEpochMillis(result.createDate, locale)}`,
308
346
  ];
309
347
  p.note(resultLines.join("\n"));
310
- if (!nonInteractive && result.setupConfigs && result.setupConfigs.length > 0) {
348
+ let flagSetupFailed = false;
349
+ if (deps.tenantSetup) {
350
+ const ok = await runBulkSetupForFlag({
351
+ configs: result.setupConfigs,
352
+ configLines: () => (result.setupConfigs ?? []).map(setupConfigLabel),
353
+ keyPrefix: "deploy.setup",
354
+ execute: () => api.executeSetup(stagingId),
355
+ locale,
356
+ spin,
357
+ });
358
+ if (!ok)
359
+ flagSetupFailed = true;
360
+ }
361
+ else if (!nonInteractive &&
362
+ result.setupConfigs &&
363
+ result.setupConfigs.length > 0) {
311
364
  try {
312
365
  await runSetup(api, stagingId, result.setupConfigs, locale, prompts, spin);
313
366
  }
314
367
  catch (err) {
315
- const msg = isDeployError(err)
316
- ? formatDeployError(err, locale)
317
- : err instanceof Error
318
- ? err.message
319
- : String(err);
320
- p.log.error(getMessage("deploy.setup.error", locale, { message: msg }));
368
+ p.log.error(getMessage("deploy.setup.error", locale, {
369
+ message: describeError(err, locale),
370
+ }));
371
+ }
372
+ }
373
+ if (deps.sampleSetup) {
374
+ const ok = await runBulkSetupForFlag({
375
+ configs: result.sampleSetupConfigs,
376
+ configLines: () => (result.sampleSetupConfigs ?? []).map(sampleSetupConfigLabel),
377
+ keyPrefix: "deploy.sampleSetup",
378
+ execute: () => api.executeSampleSetup(stagingId),
379
+ locale,
380
+ spin,
381
+ });
382
+ if (!ok)
383
+ flagSetupFailed = true;
384
+ }
385
+ else if (!nonInteractive &&
386
+ result.sampleSetupConfigs &&
387
+ result.sampleSetupConfigs.length > 0) {
388
+ try {
389
+ await runSampleSetup(api, stagingId, result.sampleSetupConfigs, locale, prompts, spin);
390
+ }
391
+ catch (err) {
392
+ p.log.error(getMessage("deploy.sampleSetup.error", locale, {
393
+ message: describeError(err, locale),
394
+ }));
321
395
  }
322
396
  }
323
397
  if (result.shortcutUrl) {
324
398
  p.log.info(`${getMessage("deploy.result.shortcutUrl", locale)}: ${result.shortcutUrl}`);
325
399
  }
400
+ if (flagSetupFailed) {
401
+ p.log.error(getMessage("deploy.setup.failedButDeployed", locale));
402
+ throw new Error("setup failed");
403
+ }
326
404
  p.outro(getMessage("deploy.success", locale));
327
405
  };
328
406
  const reorderFiles = async (files, prompts, locale) => {
@@ -376,9 +454,94 @@ const runSetup = async (api, stagingId, configs, locale, prompts, spin) => {
376
454
  results: allResults,
377
455
  };
378
456
  }
379
- showSetupResults(setupResult, locale);
457
+ showSetupResults(setupResult, locale, "deploy.setup");
458
+ };
459
+ const runSampleSetup = async (api, stagingId, configs, locale, prompts, spin) => {
460
+ const doSetup = await prompts.confirmSampleSetup(configs, locale);
461
+ if (!doSetup)
462
+ return;
463
+ const doAll = await prompts.confirmSampleSetupAll(locale);
464
+ let setupResult;
465
+ if (doAll) {
466
+ const progress = getMessage("deploy.sampleSetup.executing", locale, {
467
+ config: "all",
468
+ });
469
+ spin.start(progress);
470
+ try {
471
+ setupResult = await api.executeSampleSetup(stagingId);
472
+ }
473
+ finally {
474
+ spin.stop(progress);
475
+ }
476
+ }
477
+ else {
478
+ const selected = await prompts.selectSampleSetupConfigs(configs, locale);
479
+ const selectedIds = new Set(selected.map((c) => c.moduleId));
480
+ const ordered = configs.filter((c) => selectedIds.has(c.moduleId));
481
+ const allResults = [];
482
+ let allSuccess = true;
483
+ let anyAborted = false;
484
+ for (const config of ordered) {
485
+ const progress = getMessage("deploy.sampleSetup.executing", locale, {
486
+ config: config.moduleId,
487
+ });
488
+ spin.start(progress);
489
+ let partial;
490
+ try {
491
+ partial = await api.executeSampleSetupConfig(stagingId, config.moduleId);
492
+ }
493
+ finally {
494
+ spin.stop(progress);
495
+ }
496
+ allResults.push(...partial.results);
497
+ if (!partial.success)
498
+ allSuccess = false;
499
+ if (partial.aborted)
500
+ anyAborted = true;
501
+ }
502
+ setupResult = {
503
+ success: allSuccess,
504
+ aborted: anyAborted,
505
+ totalCount: allResults.length,
506
+ results: allResults,
507
+ };
508
+ }
509
+ showSetupResults(setupResult, locale, "deploy.sampleSetup");
510
+ if (setupResult.aborted) {
511
+ p.log.warn(getMessage("deploy.sampleSetup.aborted", locale));
512
+ }
513
+ };
514
+ const runBulkSetupForFlag = async (opts) => {
515
+ const { configs, keyPrefix, locale, spin } = opts;
516
+ if (!configs || configs.length === 0) {
517
+ p.log.warn(getMessage(`${keyPrefix}.noneFound`, locale));
518
+ return true;
519
+ }
520
+ p.note(opts.configLines().join("\n"), getMessage(`${keyPrefix}.heading`, locale));
521
+ const progress = getMessage(`${keyPrefix}.executing`, locale, {
522
+ config: "all",
523
+ });
524
+ spin.start(progress);
525
+ let result;
526
+ try {
527
+ result = await opts.execute();
528
+ }
529
+ catch (err) {
530
+ p.log.error(getMessage(`${keyPrefix}.error`, locale, {
531
+ message: describeError(err, locale),
532
+ }));
533
+ return false;
534
+ }
535
+ finally {
536
+ spin.stop(progress);
537
+ }
538
+ showSetupResults(result, locale, keyPrefix);
539
+ if (result.aborted) {
540
+ p.log.warn(getMessage("deploy.sampleSetup.aborted", locale));
541
+ }
542
+ return result.success && !result.aborted;
380
543
  };
381
- const showSetupResults = (result, locale) => {
544
+ const showSetupResults = (result, locale, keyPrefix) => {
382
545
  if (result.results.length === 0)
383
546
  return;
384
547
  const sectionHeader = getMessage("deploy.setup.resultHeader.section", locale);
@@ -405,10 +568,10 @@ const showSetupResults = (result, locale) => {
405
568
  const lines = rows.map((r) => formatRow(r));
406
569
  p.note([header, separator, ...lines].join("\n"));
407
570
  if (result.success) {
408
- p.log.success(getMessage("deploy.setup.resultSuccess", locale));
571
+ p.log.success(getMessage(`${keyPrefix}.resultSuccess`, locale));
409
572
  }
410
573
  else {
411
- p.log.warn(getMessage("deploy.setup.resultPartialFailure", locale));
574
+ p.log.warn(getMessage(`${keyPrefix}.resultPartialFailure`, locale));
412
575
  }
413
576
  };
414
577
  const logAndRethrow = (err, locale) => {
@@ -450,6 +613,16 @@ export const deployCommand = defineCommand({
450
613
  type: "string",
451
614
  description: "Deployment description",
452
615
  },
616
+ "tenant-setup": {
617
+ type: "boolean",
618
+ description: "Bulk-run tenant environment setup after deploy without confirmation (non-zero exit on failure)",
619
+ default: false,
620
+ },
621
+ "sample-setup": {
622
+ type: "boolean",
623
+ description: "Bulk-run sample data setup after deploy without confirmation (non-zero exit on failure)",
624
+ default: false,
625
+ },
453
626
  "non-interactive": {
454
627
  type: "boolean",
455
628
  description: "Non-interactive mode (no prompts; exits non-zero on failure)",
@@ -467,6 +640,8 @@ export const deployCommand = defineCommand({
467
640
  file: lastFlagValue(args.file),
468
641
  additionalFiles: allFlagValues(args["additional-file"]),
469
642
  description: lastFlagValue(args.description),
643
+ tenantSetup: args["tenant-setup"],
644
+ sampleSetup: args["sample-setup"],
470
645
  });
471
646
  }
472
647
  catch {
@@ -9,6 +9,8 @@ import { runPrompts, collectSettingsErrors, printIntro, } from "../interactive/p
9
9
  import { withHint } from "../interactive/format.js";
10
10
  import { createGitAssetProvider } from "../asset/git-provider.js";
11
11
  import { buildRenderedPlan, collectFileStates, classifyAll, applyUpdateActions, buildUpdatedRecords, } from "../asset/updater.js";
12
+ import { createMessageCollector } from "../asset/messages.js";
13
+ import { printAssetMessages } from "../interactive/asset-messages.js";
12
14
  import { mergeFile } from "../utils/merge-file.js";
13
15
  import { getInstallCmds, runInstallBuild } from "../asset/installer.js";
14
16
  import { readSettingsSafe, readHashsum, writeSettings, writeHashsum, } from "../utils/settings-io.js";
@@ -380,7 +382,8 @@ export const updateCommand = defineCommand({
380
382
  from: shortSha(source.commit),
381
383
  to: shortSha(newCommit),
382
384
  }));
383
- const theirsPlan = await buildRenderedPlan(provider.asTree(), newSettings, provider.materialize);
385
+ const messageCollector = createMessageCollector();
386
+ const theirsPlan = await buildRenderedPlan(provider.asTree(), newSettings, provider.materialize, messageCollector.collect);
384
387
  let baseTree = null;
385
388
  let baseError = null;
386
389
  try {
@@ -425,6 +428,7 @@ export const updateCommand = defineCommand({
425
428
  };
426
429
  await writeSettings(projectDir, updatedSettings);
427
430
  await writeHashsum(projectDir, hashEntries);
431
+ printAssetMessages(messageCollector.drain());
428
432
  const skipInstall = args["skip-install"];
429
433
  const hasConflicts = summary.conflicts.length > 0;
430
434
  if (summary.changedFileCount > 0 && !hasConflicts && !skipInstall) {
@@ -60,12 +60,19 @@ export type RenameRule = {
60
60
  from: string;
61
61
  to: string;
62
62
  };
63
+ export type MessageLevel = "info" | "warn";
64
+ export type Message = {
65
+ condition?: Condition;
66
+ level?: MessageLevel;
67
+ text: string;
68
+ };
63
69
  export type MetaJson = {
64
70
  version: string;
65
71
  type: "file" | "directory";
66
72
  conditions?: Condition;
67
73
  rename?: RenameRule[];
68
74
  replacements?: Replacement[];
75
+ messages?: Message[];
69
76
  };
70
77
  export type AccelplatformVersion = {
71
78
  label: string;
@@ -181,9 +188,14 @@ export type SetupConfigResponse = {
181
188
  configNumber: number;
182
189
  sections: string[];
183
190
  };
191
+ export type SampleSetupConfigResponse = {
192
+ moduleId: string;
193
+ sections: string[];
194
+ };
184
195
  export type DeploymentCreateResponse = DeploymentResponse & {
185
196
  shortcutUrl?: string | null;
186
197
  setupConfigs?: SetupConfigResponse[] | null;
198
+ sampleSetupConfigs?: SampleSetupConfigResponse[] | null;
187
199
  };
188
200
  export type SetupExecuteResultResponse = {
189
201
  configNumber: number;
@@ -198,6 +210,20 @@ export type SetupExecuteResponse = {
198
210
  totalCount: number;
199
211
  results: SetupExecuteResultResponse[];
200
212
  };
213
+ export type SampleSetupExecuteResultResponse = {
214
+ moduleId: string;
215
+ section: string;
216
+ label: string;
217
+ target: string;
218
+ success: boolean;
219
+ message?: string | null;
220
+ };
221
+ export type SampleSetupExecuteResponse = {
222
+ success: boolean;
223
+ aborted: boolean;
224
+ totalCount: number;
225
+ results: SampleSetupExecuteResultResponse[];
226
+ };
201
227
  export type ApiSuccess<T> = {
202
228
  error: false;
203
229
  data: T;
@@ -1,4 +1,4 @@
1
- import type { StagingResponse, DeploymentCreateResponse, DeployError, SetupExecuteResponse } from "../core/types.js";
1
+ import type { StagingResponse, DeploymentCreateResponse, DeployError, SetupExecuteResponse, SampleSetupExecuteResponse } from "../core/types.js";
2
2
  type FetchFn = typeof globalThis.fetch;
3
3
  export declare const makeDeployError: (kind: DeployError["kind"], extra?: {
4
4
  status?: number;
@@ -15,6 +15,8 @@ export type ApiClient = {
15
15
  createDeployment: (stagingId: string, archives: DeployArchive[], description?: string) => Promise<DeploymentCreateResponse>;
16
16
  executeSetup: (stagingId: string) => Promise<SetupExecuteResponse>;
17
17
  executeSetupConfig: (stagingId: string, moduleId: string, configNumber: number) => Promise<SetupExecuteResponse>;
18
+ executeSampleSetup: (stagingId: string) => Promise<SampleSetupExecuteResponse>;
19
+ executeSampleSetupConfig: (stagingId: string, moduleId: string) => Promise<SampleSetupExecuteResponse>;
18
20
  };
19
21
  export declare const createApiClient: (endpoint: string, apiKey: string, deps?: {
20
22
  fetch?: FetchFn;
@@ -121,11 +121,29 @@ export const createApiClient = (endpoint, apiKey, deps = {}) => {
121
121
  body: JSON.stringify({}),
122
122
  });
123
123
  };
124
+ const executeSampleSetup = async (stagingId) => {
125
+ const url = `${endpoint}${STAGING_PATH}/${encodeURIComponent(stagingId)}/sample/setup/execute`;
126
+ return request(url, {
127
+ method: "POST",
128
+ headers: { ...baseHeaders, "Content-Type": "application/json" },
129
+ body: JSON.stringify({}),
130
+ });
131
+ };
132
+ const executeSampleSetupConfig = async (stagingId, moduleId) => {
133
+ const url = `${endpoint}${STAGING_PATH}/${encodeURIComponent(stagingId)}/sample/setup/configs/${encodeURIComponent(moduleId)}/execute`;
134
+ return request(url, {
135
+ method: "POST",
136
+ headers: { ...baseHeaders, "Content-Type": "application/json" },
137
+ body: JSON.stringify({}),
138
+ });
139
+ };
124
140
  return {
125
141
  verifyToken,
126
142
  listStagings,
127
143
  createDeployment,
128
144
  executeSetup,
129
145
  executeSetupConfig,
146
+ executeSampleSetup,
147
+ executeSampleSetupConfig,
130
148
  };
131
149
  };
package/dist/i18n/en.js CHANGED
@@ -199,4 +199,16 @@ export const messages = {
199
199
  "deploy.setup.resultHeader.section": "Section",
200
200
  "deploy.setup.resultHeader.target": "Target",
201
201
  "deploy.setup.resultHeader.result": "Result",
202
+ "deploy.setup.noneFound": "No tenant environment setup configs were found in the deployed archives. Skipping execution.",
203
+ "deploy.setup.failedButDeployed": "Setup failed (the deployment itself succeeded).",
204
+ "deploy.sampleSetup.heading": "Sample Data Setup Configs",
205
+ "deploy.sampleSetup.confirm": "Run sample data setup?",
206
+ "deploy.sampleSetup.confirmAll": "Execute all?",
207
+ "deploy.sampleSetup.selectConfigs": "Select the configs to execute",
208
+ "deploy.sampleSetup.executing": "Running sample data setup... ({config})",
209
+ "deploy.sampleSetup.resultSuccess": "Sample data setup completed.",
210
+ "deploy.sampleSetup.resultPartialFailure": "Sample data setup partially failed.",
211
+ "deploy.sampleSetup.aborted": "The remaining setup steps were aborted due to a preprocessing failure.",
212
+ "deploy.sampleSetup.error": "An error occurred during sample data setup: {message}",
213
+ "deploy.sampleSetup.noneFound": "No sample data setup configs were found in the deployed archives. Skipping execution.",
202
214
  };
package/dist/i18n/ja.js CHANGED
@@ -199,4 +199,16 @@ export const messages = {
199
199
  "deploy.setup.resultHeader.section": "セクション",
200
200
  "deploy.setup.resultHeader.target": "対象",
201
201
  "deploy.setup.resultHeader.result": "結果",
202
+ "deploy.setup.noneFound": "テナント環境セットアップ設定が資材内に見つかりませんでした。実行をスキップします。",
203
+ "deploy.setup.failedButDeployed": "セットアップに失敗しました(デプロイ自体は成功しています)。",
204
+ "deploy.sampleSetup.heading": "サンプルデータセットアップ設定",
205
+ "deploy.sampleSetup.confirm": "サンプルデータセットアップを実行しますか?",
206
+ "deploy.sampleSetup.confirmAll": "全て実行しますか?",
207
+ "deploy.sampleSetup.selectConfigs": "実行する設定を選択してください",
208
+ "deploy.sampleSetup.executing": "サンプルデータセットアップを実行しています... ({config})",
209
+ "deploy.sampleSetup.resultSuccess": "サンプルデータセットアップが完了しました。",
210
+ "deploy.sampleSetup.resultPartialFailure": "サンプルデータセットアップが一部失敗しました。",
211
+ "deploy.sampleSetup.aborted": "前処理の失敗により、以降のセットアップ処理は中断されました。",
212
+ "deploy.sampleSetup.error": "サンプルデータセットアップの実行中にエラーが発生しました: {message}",
213
+ "deploy.sampleSetup.noneFound": "サンプルデータセットアップ設定が資材内に見つかりませんでした。実行をスキップします。",
202
214
  };
@@ -199,4 +199,16 @@ export const messages = {
199
199
  "deploy.setup.resultHeader.section": "部分",
200
200
  "deploy.setup.resultHeader.target": "对象",
201
201
  "deploy.setup.resultHeader.result": "结果",
202
+ "deploy.setup.noneFound": "在部署的资材中未找到租户环境配置。跳过执行。",
203
+ "deploy.setup.failedButDeployed": "配置执行失败(部署本身已成功)。",
204
+ "deploy.sampleSetup.heading": "示例数据配置设置",
205
+ "deploy.sampleSetup.confirm": "是否执行示例数据配置?",
206
+ "deploy.sampleSetup.confirmAll": "是否全部执行?",
207
+ "deploy.sampleSetup.selectConfigs": "请选择要执行的配置",
208
+ "deploy.sampleSetup.executing": "正在执行示例数据配置... ({config})",
209
+ "deploy.sampleSetup.resultSuccess": "示例数据配置已完成。",
210
+ "deploy.sampleSetup.resultPartialFailure": "示例数据配置部分失败。",
211
+ "deploy.sampleSetup.aborted": "由于预处理失败,后续配置处理已中断。",
212
+ "deploy.sampleSetup.error": "执行示例数据配置时发生错误: {message}",
213
+ "deploy.sampleSetup.noneFound": "在部署的资材中未找到示例数据配置。跳过执行。",
202
214
  };
@@ -0,0 +1,3 @@
1
+ import type { AssetMessage } from "../asset/messages.js";
2
+ export declare const buildAssetMessageLines: (messages: AssetMessage[]) => AssetMessage[];
3
+ export declare const printAssetMessages: (messages: AssetMessage[]) => void;
@@ -0,0 +1,15 @@
1
+ import * as p from "@clack/prompts";
2
+ import { sanitizeDisplayText } from "../utils/sanitize-text.js";
3
+ export const buildAssetMessageLines = (messages) => messages
4
+ .map((m) => ({ level: m.level, text: sanitizeDisplayText(m.text) }))
5
+ .filter((m) => m.text !== "");
6
+ export const printAssetMessages = (messages) => {
7
+ for (const message of buildAssetMessageLines(messages)) {
8
+ if (message.level === "warn") {
9
+ p.log.warn(message.text);
10
+ }
11
+ else {
12
+ p.log.info(message.text);
13
+ }
14
+ }
15
+ };
@@ -1,6 +1,7 @@
1
1
  import * as p from "@clack/prompts";
2
2
  import { ROOT_SECTION } from "../asset/deployer.js";
3
3
  import { getMessage } from "../i18n/index.js";
4
+ import { printAssetMessages } from "./asset-messages.js";
4
5
  const MAX_FILES_SHOWN = 3;
5
6
  const formatFileList = (files) => {
6
7
  if (files.length <= MAX_FILES_SHOWN)
@@ -17,6 +18,7 @@ export const buildProgressCallbacks = (locale) => ({
17
18
  : "progress.deploying.section";
18
19
  p.log.info(getMessage(key, locale, { section, files: filesStr }));
19
20
  },
21
+ onMessages: (messages) => printAssetMessages(messages),
20
22
  onInstallStart: (command) => p.log.info(getMessage("progress.installing", locale, { command })),
21
23
  onBuildStart: (command) => p.log.info(getMessage("progress.building", locale, { command })),
22
24
  });
@@ -0,0 +1,2 @@
1
+ export declare const MAX_DISPLAY_TEXT_LENGTH = 500;
2
+ export declare const sanitizeDisplayText: (input: string) => string;
@@ -0,0 +1,11 @@
1
+ import { stripVTControlCharacters } from "node:util";
2
+ export const MAX_DISPLAY_TEXT_LENGTH = 500;
3
+ export const sanitizeDisplayText = (input) => {
4
+ const stripped = stripVTControlCharacters(input);
5
+ const spaced = stripped.replace(/\r\n|[\n\t]/g, " ");
6
+ const cleaned = spaced.replace(/[\u0000-\u001f\u007f-\u009f]/g, "");
7
+ const codePoints = Array.from(cleaned);
8
+ if (codePoints.length <= MAX_DISPLAY_TEXT_LENGTH)
9
+ return cleaned;
10
+ return codePoints.slice(0, MAX_DISPLAY_TEXT_LENGTH).join("") + "...";
11
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intra-mart/accel",
3
- "version": "0.4.0-dev.202607210732",
3
+ "version": "0.4.0-dev.202607280237",
4
4
  "type": "module",
5
5
  "description": "CLI tool for intra-mart Accel Platform development",
6
6
  "author": "NTT DATA INTRAMART",