@intra-mart/accel 0.4.0-dev.202607170346 → 0.4.0-dev.202607270235
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 +11 -1
- package/dist/asset/asset-tree.d.ts +2 -1
- package/dist/asset/asset-tree.js +1 -0
- package/dist/asset/deployer.js +41 -24
- package/dist/asset/file-provider.js +1 -0
- package/dist/asset/git-provider.d.ts +2 -1
- package/dist/asset/git-provider.js +52 -24
- package/dist/asset/walker.js +6 -2
- package/dist/commands/deploy.d.ts +16 -1
- package/dist/commands/deploy.js +190 -15
- package/dist/core/types.d.ts +21 -1
- package/dist/deploy/api-client.d.ts +3 -1
- package/dist/deploy/api-client.js +18 -0
- package/dist/git/object-store.d.ts +4 -2
- package/dist/git/object-store.js +109 -27
- package/dist/i18n/en.js +13 -0
- package/dist/i18n/ja.js +13 -0
- package/dist/i18n/zh_CN.js +13 -0
- package/dist/interactive/prompts.js +19 -8
- package/dist/utils/concurrency.d.ts +1 -0
- package/dist/utils/concurrency.js +30 -0
- package/package.json +1 -1
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
|
-
-
|
|
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,5 +1,6 @@
|
|
|
1
1
|
export type AssetTree = {
|
|
2
|
-
|
|
2
|
+
listRootEntries: () => Promise<string[]>;
|
|
3
|
+
listFiles: (underDirs?: string[]) => Promise<string[]>;
|
|
3
4
|
readFile: (relPath: string) => Promise<string>;
|
|
4
5
|
};
|
|
5
6
|
export declare const createFsAssetTree: (rootDir: string) => AssetTree;
|
package/dist/asset/asset-tree.js
CHANGED
|
@@ -2,6 +2,7 @@ import { readFile } from "node:fs/promises";
|
|
|
2
2
|
import { join } from "node:path";
|
|
3
3
|
import { listFilesUnder } from "../utils/fs-list.js";
|
|
4
4
|
export const createFsAssetTree = (rootDir) => ({
|
|
5
|
+
listRootEntries: () => listFilesUnder(rootDir),
|
|
5
6
|
listFiles: () => listFilesUnder(rootDir),
|
|
6
7
|
readFile: (relPath) => readFile(join(rootDir, relPath), "utf-8"),
|
|
7
8
|
});
|
package/dist/asset/deployer.js
CHANGED
|
@@ -5,6 +5,7 @@ import { walkAssetRepo } from "./walker.js";
|
|
|
5
5
|
import { renderAssetContent } from "./renderer.js";
|
|
6
6
|
import { runInstallBuild } from "./installer.js";
|
|
7
7
|
import { computeSha1 } from "../utils/hash.js";
|
|
8
|
+
import { mapWithConcurrency } from "../utils/concurrency.js";
|
|
8
9
|
import { writeSettings, writeHashsum } from "../utils/settings-io.js";
|
|
9
10
|
export { getInstallCmds } from "./installer.js";
|
|
10
11
|
const fileExists = async (path) => {
|
|
@@ -39,13 +40,28 @@ const fileLabelOf = (relativePath, section) => {
|
|
|
39
40
|
return relativePath;
|
|
40
41
|
return relativePath.slice(section.length);
|
|
41
42
|
};
|
|
43
|
+
const DEPLOY_CONCURRENCY = 64;
|
|
44
|
+
const groupSections = (entries) => {
|
|
45
|
+
const groups = new Map();
|
|
46
|
+
for (const entry of entries) {
|
|
47
|
+
const section = sectionOf(entry.relativePath);
|
|
48
|
+
let group = groups.get(section);
|
|
49
|
+
if (!group) {
|
|
50
|
+
group = { section, files: [] };
|
|
51
|
+
groups.set(section, group);
|
|
52
|
+
}
|
|
53
|
+
group.files.push(fileLabelOf(entry.relativePath, section));
|
|
54
|
+
}
|
|
55
|
+
return [...groups.values()];
|
|
56
|
+
};
|
|
42
57
|
export const deployAssets = async (options) => {
|
|
43
58
|
const { projectDir, settings, provider, noInstall, skipExistingFiles, onExistingFile, progress, } = options;
|
|
44
59
|
try {
|
|
45
60
|
progress?.onFetchStart?.();
|
|
46
61
|
const repoDir = await provider.fetch();
|
|
47
62
|
const tree = {
|
|
48
|
-
|
|
63
|
+
listRootEntries: () => provider.listRootEntries(),
|
|
64
|
+
listFiles: (underDirs) => provider.listFiles(underDirs),
|
|
49
65
|
readFile: (relPath) => provider.readFile(relPath),
|
|
50
66
|
};
|
|
51
67
|
const semver = settings.accelplatformVersion.semver;
|
|
@@ -66,27 +82,18 @@ export const deployAssets = async (options) => {
|
|
|
66
82
|
await provider.materialize([
|
|
67
83
|
...new Set(entries.map((e) => e.sourceRelPath)),
|
|
68
84
|
]);
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
85
|
+
if (progress?.onSectionDeploy) {
|
|
86
|
+
for (const group of groupSections(entries)) {
|
|
87
|
+
progress.onSectionDeploy(group.section, group.files);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
const existsFlags = await mapWithConcurrency(entries, DEPLOY_CONCURRENCY, (entry) => fileExists(join(projectDir, entry.relativePath)));
|
|
72
91
|
const skippedFiles = [];
|
|
73
92
|
const overwrittenFiles = [];
|
|
74
|
-
|
|
75
|
-
for (const entry of entries) {
|
|
93
|
+
const toDeploy = [];
|
|
94
|
+
for (const [index, entry] of entries.entries()) {
|
|
76
95
|
const targetPath = entry.relativePath;
|
|
77
|
-
|
|
78
|
-
const section = sectionOf(targetPath);
|
|
79
|
-
if (section !== currentSection) {
|
|
80
|
-
currentSection = section;
|
|
81
|
-
if (progress?.onSectionDeploy) {
|
|
82
|
-
const sectionFiles = entries
|
|
83
|
-
.filter((e) => sectionOf(e.relativePath) === section)
|
|
84
|
-
.map((e) => fileLabelOf(e.relativePath, section));
|
|
85
|
-
progress.onSectionDeploy(section, sectionFiles);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
const exists = await fileExists(destPath);
|
|
89
|
-
if (exists) {
|
|
96
|
+
if (existsFlags[index]) {
|
|
90
97
|
let decision = "overwrite";
|
|
91
98
|
if (skipExistingFiles) {
|
|
92
99
|
decision = "skip";
|
|
@@ -100,15 +107,25 @@ export const deployAssets = async (options) => {
|
|
|
100
107
|
}
|
|
101
108
|
overwrittenFiles.push(targetPath);
|
|
102
109
|
}
|
|
110
|
+
toDeploy.push(entry);
|
|
111
|
+
}
|
|
112
|
+
const hashEntries = await mapWithConcurrency(toDeploy, DEPLOY_CONCURRENCY, async (entry) => {
|
|
113
|
+
const targetPath = entry.relativePath;
|
|
114
|
+
const destPath = join(projectDir, targetPath);
|
|
103
115
|
const raw = await tree.readFile(entry.sourceRelPath);
|
|
104
116
|
const content = renderAssetContent(raw, targetPath, collectReplacements(entry), context);
|
|
105
117
|
await mkdir(dirname(destPath), { recursive: true });
|
|
106
118
|
await writeFile(destPath, content, "utf-8");
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
119
|
+
return {
|
|
120
|
+
filePath: targetPath,
|
|
121
|
+
version: entry.meta?.version ?? "0.0.0",
|
|
122
|
+
sha1: computeSha1(content),
|
|
123
|
+
};
|
|
124
|
+
});
|
|
125
|
+
const deployedFiles = hashEntries.map((h) => h.filePath);
|
|
126
|
+
const deployedAssets = {};
|
|
127
|
+
for (const h of hashEntries) {
|
|
128
|
+
deployedAssets[h.filePath] = h.version;
|
|
112
129
|
}
|
|
113
130
|
const updatedSettings = {
|
|
114
131
|
...settings,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { AssetProvider } from "../core/types.js";
|
|
2
2
|
export type CommitTree = {
|
|
3
|
-
|
|
3
|
+
listRootEntries: () => Promise<string[]>;
|
|
4
|
+
listFiles: (underDirs?: string[]) => Promise<string[]>;
|
|
4
5
|
readFile: (relPath: string) => Promise<string>;
|
|
5
6
|
materialize: (files: string[]) => Promise<void>;
|
|
6
7
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getMessage } from "../i18n/index.js";
|
|
2
2
|
import { isGitAuthError, isGitObjectMissingError, isGitServerUnsupportedError, } from "../git/errors.js";
|
|
3
|
-
import { createObjectStore } from "../git/object-store.js";
|
|
3
|
+
import { createObjectStore, } from "../git/object-store.js";
|
|
4
4
|
import { assertServerSupported, fetchCapabilities, fetchPack, isValidOid, resolveRef, } from "../git/smart-http.js";
|
|
5
5
|
const MAX_WANTS_PER_REQUEST = 1000;
|
|
6
6
|
const META_FILENAME = "_meta.json";
|
|
@@ -41,7 +41,7 @@ export const createGitAssetProvider = (repoUrl, ref, options = {}) => {
|
|
|
41
41
|
if (seen.has(oid))
|
|
42
42
|
continue;
|
|
43
43
|
seen.add(oid);
|
|
44
|
-
if (!
|
|
44
|
+
if (!store.hasObject(oid))
|
|
45
45
|
missing.push(oid);
|
|
46
46
|
}
|
|
47
47
|
for (let i = 0; i < missing.length; i += MAX_WANTS_PER_REQUEST) {
|
|
@@ -64,16 +64,28 @@ export const createGitAssetProvider = (repoUrl, ref, options = {}) => {
|
|
|
64
64
|
if (files.length === 0)
|
|
65
65
|
return;
|
|
66
66
|
const { store } = requireRepo();
|
|
67
|
-
const
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
67
|
+
const targets = [];
|
|
68
|
+
for (const file of files) {
|
|
69
|
+
const blobOid = await store.getBlobOid(oid, file);
|
|
70
|
+
if (blobOid !== undefined)
|
|
71
|
+
targets.push(blobOid);
|
|
72
|
+
}
|
|
72
73
|
await fetchMissingBlobs(targets);
|
|
73
74
|
};
|
|
74
|
-
const
|
|
75
|
+
const metaOidsOf = (entries) => entries
|
|
76
|
+
.filter((e) => e.path === META_FILENAME || e.path.endsWith(`/${META_FILENAME}`))
|
|
77
|
+
.map((e) => e.oid);
|
|
78
|
+
const listRootFilesAt = async (oid) => {
|
|
79
|
+
const { store } = requireRepo();
|
|
80
|
+
const entries = await store.listRootBlobEntries(oid);
|
|
81
|
+
await fetchMissingBlobs(metaOidsOf(entries));
|
|
82
|
+
return entries.map((e) => e.path);
|
|
83
|
+
};
|
|
84
|
+
const listFilesAt = async (oid, underDirs) => {
|
|
75
85
|
const { store } = requireRepo();
|
|
76
|
-
|
|
86
|
+
const entries = await store.listBlobEntries(oid, underDirs);
|
|
87
|
+
await fetchMissingBlobs(metaOidsOf(entries));
|
|
88
|
+
return entries.map((e) => e.path);
|
|
77
89
|
};
|
|
78
90
|
const fetchTreesFor = async (oid, label) => {
|
|
79
91
|
const { store } = requireRepo();
|
|
@@ -82,14 +94,23 @@ export const createGitAssetProvider = (repoUrl, ref, options = {}) => {
|
|
|
82
94
|
filterBlobNone: true,
|
|
83
95
|
});
|
|
84
96
|
await store.writePack(pack, label);
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
97
|
+
await listRootFilesAt(oid);
|
|
98
|
+
};
|
|
99
|
+
const rethrowWithServerDiagnosis = async (original) => {
|
|
100
|
+
if (!isGitAuthError(original)) {
|
|
101
|
+
try {
|
|
102
|
+
assertServerSupported(repoUrl, await fetchCapabilities(repoUrl));
|
|
103
|
+
}
|
|
104
|
+
catch (diagErr) {
|
|
105
|
+
if (isGitServerUnsupportedError(diagErr))
|
|
106
|
+
throw diagErr;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
throw original;
|
|
90
110
|
};
|
|
91
111
|
const commitTreeOf = (oid) => ({
|
|
92
|
-
|
|
112
|
+
listRootEntries: () => listRootFilesAt(oid),
|
|
113
|
+
listFiles: (underDirs) => listFilesAt(oid, underDirs),
|
|
93
114
|
readFile: (relPath) => readFileAt(oid, relPath),
|
|
94
115
|
materialize: (files) => materializeAt(oid, files),
|
|
95
116
|
});
|
|
@@ -100,14 +121,17 @@ export const createGitAssetProvider = (repoUrl, ref, options = {}) => {
|
|
|
100
121
|
}
|
|
101
122
|
store = await createObjectStore();
|
|
102
123
|
try {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
124
|
+
try {
|
|
125
|
+
const resolved = await resolveRef(repoUrl, ref);
|
|
126
|
+
if (!resolved) {
|
|
127
|
+
throw new Error(`ref not found on server: ${ref}`);
|
|
128
|
+
}
|
|
129
|
+
commit = resolved.oid;
|
|
130
|
+
await fetchTreesFor(commit, "trees-head");
|
|
131
|
+
}
|
|
132
|
+
catch (inner) {
|
|
133
|
+
await rethrowWithServerDiagnosis(inner);
|
|
108
134
|
}
|
|
109
|
-
commit = resolved.oid;
|
|
110
|
-
await fetchTreesFor(commit, "trees-head");
|
|
111
135
|
}
|
|
112
136
|
catch (err) {
|
|
113
137
|
const reason = err instanceof Error ? err.message : String(err);
|
|
@@ -115,9 +139,13 @@ export const createGitAssetProvider = (repoUrl, ref, options = {}) => {
|
|
|
115
139
|
}
|
|
116
140
|
return store.dir;
|
|
117
141
|
},
|
|
118
|
-
|
|
142
|
+
listRootEntries: () => {
|
|
143
|
+
const { commit: oid } = requireRepo();
|
|
144
|
+
return listRootFilesAt(oid);
|
|
145
|
+
},
|
|
146
|
+
listFiles: (underDirs) => {
|
|
119
147
|
const { commit: oid } = requireRepo();
|
|
120
|
-
return listFilesAt(oid);
|
|
148
|
+
return listFilesAt(oid, underDirs);
|
|
121
149
|
},
|
|
122
150
|
readFile: (relPath) => {
|
|
123
151
|
const { commit: oid } = requireRepo();
|
package/dist/asset/walker.js
CHANGED
|
@@ -159,9 +159,13 @@ export const walkAssetDir = async (tree, context) => {
|
|
|
159
159
|
return deduplicateByPath(entries);
|
|
160
160
|
};
|
|
161
161
|
export const walkAssetRepo = async (tree, targetSemver, context) => {
|
|
162
|
-
const
|
|
162
|
+
const rootFiles = await tree.listRootEntries();
|
|
163
|
+
const rootVtree = buildVirtualTree(rootFiles);
|
|
164
|
+
const versionDirs = await findMatchingVersionDirs(tree, rootVtree, targetSemver);
|
|
165
|
+
if (versionDirs.length === 0)
|
|
166
|
+
return [];
|
|
167
|
+
const files = await tree.listFiles(versionDirs);
|
|
163
168
|
const vtree = buildVirtualTree(files);
|
|
164
|
-
const versionDirs = await findMatchingVersionDirs(tree, vtree, targetSemver);
|
|
165
169
|
const allEntries = [];
|
|
166
170
|
for (const versionDir of versionDirs) {
|
|
167
171
|
const meta = await readMetaJson(tree, vtree, versionDir);
|
|
@@ -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;
|
package/dist/commands/deploy.js
CHANGED
|
@@ -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:
|
|
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
|
-
|
|
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
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
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(
|
|
571
|
+
p.log.success(getMessage(`${keyPrefix}.resultSuccess`, locale));
|
|
409
572
|
}
|
|
410
573
|
else {
|
|
411
|
-
p.log.warn(getMessage(
|
|
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 {
|
package/dist/core/types.d.ts
CHANGED
|
@@ -118,7 +118,8 @@ export type AssetSourceInfo = {
|
|
|
118
118
|
};
|
|
119
119
|
export type AssetProvider = {
|
|
120
120
|
fetch: () => Promise<string>;
|
|
121
|
-
|
|
121
|
+
listRootEntries: () => Promise<string[]>;
|
|
122
|
+
listFiles: (underDirs?: string[]) => Promise<string[]>;
|
|
122
123
|
materialize: (files: string[]) => Promise<void>;
|
|
123
124
|
readFile: (relPath: string) => Promise<string>;
|
|
124
125
|
cleanup: () => Promise<void>;
|
|
@@ -180,9 +181,14 @@ export type SetupConfigResponse = {
|
|
|
180
181
|
configNumber: number;
|
|
181
182
|
sections: string[];
|
|
182
183
|
};
|
|
184
|
+
export type SampleSetupConfigResponse = {
|
|
185
|
+
moduleId: string;
|
|
186
|
+
sections: string[];
|
|
187
|
+
};
|
|
183
188
|
export type DeploymentCreateResponse = DeploymentResponse & {
|
|
184
189
|
shortcutUrl?: string | null;
|
|
185
190
|
setupConfigs?: SetupConfigResponse[] | null;
|
|
191
|
+
sampleSetupConfigs?: SampleSetupConfigResponse[] | null;
|
|
186
192
|
};
|
|
187
193
|
export type SetupExecuteResultResponse = {
|
|
188
194
|
configNumber: number;
|
|
@@ -197,6 +203,20 @@ export type SetupExecuteResponse = {
|
|
|
197
203
|
totalCount: number;
|
|
198
204
|
results: SetupExecuteResultResponse[];
|
|
199
205
|
};
|
|
206
|
+
export type SampleSetupExecuteResultResponse = {
|
|
207
|
+
moduleId: string;
|
|
208
|
+
section: string;
|
|
209
|
+
label: string;
|
|
210
|
+
target: string;
|
|
211
|
+
success: boolean;
|
|
212
|
+
message?: string | null;
|
|
213
|
+
};
|
|
214
|
+
export type SampleSetupExecuteResponse = {
|
|
215
|
+
success: boolean;
|
|
216
|
+
aborted: boolean;
|
|
217
|
+
totalCount: number;
|
|
218
|
+
results: SampleSetupExecuteResultResponse[];
|
|
219
|
+
};
|
|
200
220
|
export type ApiSuccess<T> = {
|
|
201
221
|
error: false;
|
|
202
222
|
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
|
};
|
|
@@ -5,9 +5,11 @@ export type BlobEntry = {
|
|
|
5
5
|
export type ObjectStore = {
|
|
6
6
|
dir: string;
|
|
7
7
|
writePack: (pack: Buffer, label: string) => Promise<void>;
|
|
8
|
-
|
|
8
|
+
listRootBlobEntries: (commitOid: string) => Promise<BlobEntry[]>;
|
|
9
|
+
listBlobEntries: (commitOid: string, underDirs?: string[]) => Promise<BlobEntry[]>;
|
|
10
|
+
getBlobOid: (commitOid: string, filepath: string) => Promise<string | undefined>;
|
|
9
11
|
readBlobAtPath: (commitOid: string, filepath: string) => Promise<string>;
|
|
10
|
-
hasObject: (oid: string) =>
|
|
12
|
+
hasObject: (oid: string) => boolean;
|
|
11
13
|
cleanup: () => Promise<void>;
|
|
12
14
|
};
|
|
13
15
|
export declare const createObjectStore: () => Promise<ObjectStore>;
|
package/dist/git/object-store.js
CHANGED
|
@@ -4,18 +4,43 @@ import { tmpdir } from "node:os";
|
|
|
4
4
|
import { join } from "node:path";
|
|
5
5
|
import git, { Errors } from "isomorphic-git";
|
|
6
6
|
import { createGitObjectMissingError } from "./errors.js";
|
|
7
|
+
const topSegmentOf = (filepath) => {
|
|
8
|
+
const slash = filepath.indexOf("/");
|
|
9
|
+
return slash === -1 ? filepath : filepath.slice(0, slash);
|
|
10
|
+
};
|
|
7
11
|
export const createObjectStore = async () => {
|
|
8
12
|
const dir = await mkdtemp(join(tmpdir(), "accel-assets-"));
|
|
9
13
|
await git.init({ fs, dir, defaultBranch: "main" });
|
|
10
14
|
await mkdir(join(dir, ".git", "objects", "pack"), { recursive: true });
|
|
11
15
|
const cache = {};
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
if (
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
const indexByCommit = new Map();
|
|
17
|
+
const knownOids = new Set();
|
|
18
|
+
const indexOf = (commitOid) => {
|
|
19
|
+
let index = indexByCommit.get(commitOid);
|
|
20
|
+
if (!index) {
|
|
21
|
+
index = {
|
|
22
|
+
oidByPath: new Map(),
|
|
23
|
+
entries: [],
|
|
24
|
+
rootDirs: new Set(),
|
|
25
|
+
rootHierarchyWalked: false,
|
|
26
|
+
walkedDirs: new Set(),
|
|
27
|
+
fullyWalked: false,
|
|
28
|
+
};
|
|
29
|
+
indexByCommit.set(commitOid, index);
|
|
30
|
+
}
|
|
31
|
+
return index;
|
|
32
|
+
};
|
|
33
|
+
const addBlob = (index, path, oid) => {
|
|
34
|
+
if (index.oidByPath.has(path))
|
|
35
|
+
return;
|
|
36
|
+
index.oidByPath.set(path, oid);
|
|
37
|
+
index.entries.push({ path, oid });
|
|
38
|
+
};
|
|
39
|
+
const ensureRootHierarchy = async (commitOid) => {
|
|
40
|
+
const index = indexOf(commitOid);
|
|
41
|
+
if (index.rootHierarchyWalked)
|
|
42
|
+
return index;
|
|
43
|
+
await git.walk({
|
|
19
44
|
fs,
|
|
20
45
|
dir,
|
|
21
46
|
cache,
|
|
@@ -23,30 +48,95 @@ export const createObjectStore = async () => {
|
|
|
23
48
|
map: async (filepath, [entry]) => {
|
|
24
49
|
if (!entry || filepath === ".")
|
|
25
50
|
return undefined;
|
|
26
|
-
|
|
51
|
+
const type = await entry.type();
|
|
52
|
+
if (type === "blob") {
|
|
53
|
+
addBlob(index, filepath, await entry.oid());
|
|
54
|
+
return undefined;
|
|
55
|
+
}
|
|
56
|
+
if (type !== "tree")
|
|
57
|
+
return null;
|
|
58
|
+
if (filepath.indexOf("/") === -1) {
|
|
59
|
+
index.rootDirs.add(filepath);
|
|
27
60
|
return undefined;
|
|
28
|
-
|
|
61
|
+
}
|
|
62
|
+
return null;
|
|
29
63
|
},
|
|
30
|
-
})
|
|
31
|
-
|
|
32
|
-
return
|
|
64
|
+
});
|
|
65
|
+
index.rootHierarchyWalked = true;
|
|
66
|
+
return index;
|
|
67
|
+
};
|
|
68
|
+
const ensureDirsWalked = async (commitOid, dirNames) => {
|
|
69
|
+
const index = await ensureRootHierarchy(commitOid);
|
|
70
|
+
const pending = new Set();
|
|
71
|
+
for (const name of dirNames) {
|
|
72
|
+
if (index.fullyWalked || index.walkedDirs.has(name))
|
|
73
|
+
continue;
|
|
74
|
+
if (index.rootDirs.has(name))
|
|
75
|
+
pending.add(name);
|
|
76
|
+
index.walkedDirs.add(name);
|
|
77
|
+
}
|
|
78
|
+
if (pending.size === 0)
|
|
79
|
+
return index;
|
|
80
|
+
await git.walk({
|
|
81
|
+
fs,
|
|
82
|
+
dir,
|
|
83
|
+
cache,
|
|
84
|
+
trees: [git.TREE({ ref: commitOid })],
|
|
85
|
+
map: async (filepath, [entry]) => {
|
|
86
|
+
if (!entry || filepath === ".")
|
|
87
|
+
return undefined;
|
|
88
|
+
if (!pending.has(topSegmentOf(filepath)))
|
|
89
|
+
return null;
|
|
90
|
+
if ((await entry.type()) === "blob") {
|
|
91
|
+
addBlob(index, filepath, await entry.oid());
|
|
92
|
+
}
|
|
93
|
+
return undefined;
|
|
94
|
+
},
|
|
95
|
+
});
|
|
96
|
+
return index;
|
|
97
|
+
};
|
|
98
|
+
const normalizeDirName = (name) => name.replace(/\/+$/, "");
|
|
99
|
+
const listRootBlobEntries = async (commitOid) => {
|
|
100
|
+
const index = await ensureRootHierarchy(commitOid);
|
|
101
|
+
return index.entries.filter((e) => e.path.split("/").length <= 2);
|
|
102
|
+
};
|
|
103
|
+
const listBlobEntries = async (commitOid, underDirs) => {
|
|
104
|
+
let index = await ensureRootHierarchy(commitOid);
|
|
105
|
+
if (underDirs === undefined) {
|
|
106
|
+
if (!index.fullyWalked) {
|
|
107
|
+
index = await ensureDirsWalked(commitOid, index.rootDirs);
|
|
108
|
+
index.fullyWalked = true;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
index = await ensureDirsWalked(commitOid, underDirs.map(normalizeDirName));
|
|
113
|
+
}
|
|
114
|
+
return index.entries;
|
|
33
115
|
};
|
|
34
116
|
const getBlobOid = async (commitOid, filepath) => {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
117
|
+
const index = await ensureRootHierarchy(commitOid);
|
|
118
|
+
const hit = index.oidByPath.get(filepath);
|
|
119
|
+
if (hit !== undefined)
|
|
120
|
+
return hit;
|
|
121
|
+
const slash = filepath.indexOf("/");
|
|
122
|
+
if (slash > 0) {
|
|
123
|
+
await ensureDirsWalked(commitOid, [filepath.slice(0, slash)]);
|
|
124
|
+
return index.oidByPath.get(filepath);
|
|
39
125
|
}
|
|
40
|
-
return
|
|
126
|
+
return undefined;
|
|
41
127
|
};
|
|
42
128
|
return {
|
|
43
129
|
dir,
|
|
44
130
|
writePack: async (pack, label) => {
|
|
45
131
|
const rel = join(".git", "objects", "pack", `pack-${label}.pack`);
|
|
46
132
|
await writeFile(join(dir, rel), pack);
|
|
47
|
-
await git.indexPack({ fs, dir, filepath: rel });
|
|
133
|
+
const { oids } = await git.indexPack({ fs, dir, filepath: rel });
|
|
134
|
+
for (const oid of oids)
|
|
135
|
+
knownOids.add(oid);
|
|
48
136
|
},
|
|
137
|
+
listRootBlobEntries,
|
|
49
138
|
listBlobEntries,
|
|
139
|
+
getBlobOid,
|
|
50
140
|
readBlobAtPath: async (commitOid, filepath) => {
|
|
51
141
|
const blobOid = await getBlobOid(commitOid, filepath);
|
|
52
142
|
if (blobOid === undefined) {
|
|
@@ -63,15 +153,7 @@ export const createObjectStore = async () => {
|
|
|
63
153
|
throw err;
|
|
64
154
|
}
|
|
65
155
|
},
|
|
66
|
-
hasObject:
|
|
67
|
-
try {
|
|
68
|
-
await git.expandOid({ fs, dir, cache, oid });
|
|
69
|
-
return true;
|
|
70
|
-
}
|
|
71
|
-
catch {
|
|
72
|
-
return false;
|
|
73
|
-
}
|
|
74
|
-
},
|
|
156
|
+
hasObject: (oid) => knownOids.has(oid),
|
|
75
157
|
cleanup: async () => {
|
|
76
158
|
await rm(dir, { recursive: true, force: true }).catch(() => { });
|
|
77
159
|
},
|
package/dist/i18n/en.js
CHANGED
|
@@ -93,6 +93,7 @@ export const messages = {
|
|
|
93
93
|
"error.accelExists": ".accel directory already exists",
|
|
94
94
|
"error.accelNotFound": ".accel directory not found",
|
|
95
95
|
"error.missingRequiredOptions": "The following required options are missing: {options}",
|
|
96
|
+
"error.initNameArgumentMissing": "Project name is not specified. Provide it as an argument (e.g., accel init my-project)",
|
|
96
97
|
"error.invalidVersion": "Invalid iAP version: {version}",
|
|
97
98
|
"error.invalidModule": "Invalid module (not in release {release}): {module}",
|
|
98
99
|
"error.invalidFeature": "Invalid feature (not in release {release}): {feature}",
|
|
@@ -198,4 +199,16 @@ export const messages = {
|
|
|
198
199
|
"deploy.setup.resultHeader.section": "Section",
|
|
199
200
|
"deploy.setup.resultHeader.target": "Target",
|
|
200
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.",
|
|
201
214
|
};
|
package/dist/i18n/ja.js
CHANGED
|
@@ -93,6 +93,7 @@ export const messages = {
|
|
|
93
93
|
"error.accelExists": ".accelディレクトリが既に存在します",
|
|
94
94
|
"error.accelNotFound": ".accelディレクトリが見つかりません",
|
|
95
95
|
"error.missingRequiredOptions": "以下の必須オプションが指定されていません: {options}",
|
|
96
|
+
"error.initNameArgumentMissing": "プロジェクト名が指定されていません。引数で指定してください(例: accel init my-project)",
|
|
96
97
|
"error.invalidVersion": "無効なiAPバージョンです: {version}",
|
|
97
98
|
"error.invalidModule": "無効なモジュールです(リリース {release} に存在しません): {module}",
|
|
98
99
|
"error.invalidFeature": "無効な機能です(リリース {release} に存在しません): {feature}",
|
|
@@ -198,4 +199,16 @@ export const messages = {
|
|
|
198
199
|
"deploy.setup.resultHeader.section": "セクション",
|
|
199
200
|
"deploy.setup.resultHeader.target": "対象",
|
|
200
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": "サンプルデータセットアップ設定が資材内に見つかりませんでした。実行をスキップします。",
|
|
201
214
|
};
|
package/dist/i18n/zh_CN.js
CHANGED
|
@@ -93,6 +93,7 @@ export const messages = {
|
|
|
93
93
|
"error.accelExists": ".accel目录已存在",
|
|
94
94
|
"error.accelNotFound": "未找到.accel目录",
|
|
95
95
|
"error.missingRequiredOptions": "以下必需选项未指定: {options}",
|
|
96
|
+
"error.initNameArgumentMissing": "未指定项目名称。请作为参数指定(例如: accel init my-project)",
|
|
96
97
|
"error.invalidVersion": "无效的iAP版本: {version}",
|
|
97
98
|
"error.invalidModule": "无效的模块(不存在于发行版 {release}): {module}",
|
|
98
99
|
"error.invalidFeature": "无效的功能(不存在于发行版 {release}): {feature}",
|
|
@@ -198,4 +199,16 @@ export const messages = {
|
|
|
198
199
|
"deploy.setup.resultHeader.section": "部分",
|
|
199
200
|
"deploy.setup.resultHeader.target": "对象",
|
|
200
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": "在部署的资材中未找到示例数据配置。跳过执行。",
|
|
201
214
|
};
|
|
@@ -23,13 +23,26 @@ const resolveJuggling = async (jugglingPath, locale) => {
|
|
|
23
23
|
return { release, baseVersion: extractVersion(data), modules };
|
|
24
24
|
};
|
|
25
25
|
export const validateNonInteractive = (opts) => {
|
|
26
|
+
const mode = opts.mode ?? (opts.isInit ? "init" : "attach");
|
|
27
|
+
const errors = [];
|
|
26
28
|
const missing = [];
|
|
27
|
-
if (!opts.name)
|
|
28
|
-
|
|
29
|
+
if (!opts.name) {
|
|
30
|
+
if (mode === "init") {
|
|
31
|
+
errors.push(getMessage("error.initNameArgumentMissing", opts.locale));
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
missing.push("--name");
|
|
35
|
+
}
|
|
36
|
+
}
|
|
29
37
|
if (!opts.jugglingProject && !opts.accelplatformVersion) {
|
|
30
38
|
missing.push("--accelplatform-version");
|
|
31
39
|
}
|
|
32
|
-
|
|
40
|
+
if (missing.length > 0) {
|
|
41
|
+
errors.push(getMessage("error.missingRequiredOptions", opts.locale, {
|
|
42
|
+
options: missing.join(", "),
|
|
43
|
+
}));
|
|
44
|
+
}
|
|
45
|
+
return errors;
|
|
33
46
|
};
|
|
34
47
|
const collectFormatErrors = (opts, validators) => {
|
|
35
48
|
const errors = [];
|
|
@@ -94,11 +107,9 @@ export const runPrompts = async (opts) => {
|
|
|
94
107
|
if (!opts.skipValidation)
|
|
95
108
|
validateCliValues(opts, validators);
|
|
96
109
|
if (opts.noInteraction) {
|
|
97
|
-
const
|
|
98
|
-
if (
|
|
99
|
-
throw new Error(
|
|
100
|
-
options: missing.join(", "),
|
|
101
|
-
}));
|
|
110
|
+
const errors = validateNonInteractive(opts);
|
|
111
|
+
if (errors.length > 0) {
|
|
112
|
+
throw new Error(errors.join("\n"));
|
|
102
113
|
}
|
|
103
114
|
let jugglingRelease = null;
|
|
104
115
|
let jugglingModules = [];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const mapWithConcurrency: <T, R>(items: readonly T[], limit: number, fn: (item: T, index: number) => Promise<R>) => Promise<R[]>;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export const mapWithConcurrency = async (items, limit, fn) => {
|
|
2
|
+
if (!(limit >= 1)) {
|
|
3
|
+
throw new RangeError(`limit must be >= 1, got ${limit}`);
|
|
4
|
+
}
|
|
5
|
+
const results = new Array(items.length);
|
|
6
|
+
let next = 0;
|
|
7
|
+
let failed = false;
|
|
8
|
+
let firstError;
|
|
9
|
+
const worker = async () => {
|
|
10
|
+
while (!failed) {
|
|
11
|
+
const index = next++;
|
|
12
|
+
if (index >= items.length)
|
|
13
|
+
return;
|
|
14
|
+
try {
|
|
15
|
+
results[index] = await fn(items[index], index);
|
|
16
|
+
}
|
|
17
|
+
catch (error) {
|
|
18
|
+
if (!failed) {
|
|
19
|
+
failed = true;
|
|
20
|
+
firstError = error;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
const workerCount = Math.min(limit, items.length);
|
|
26
|
+
await Promise.all(Array.from({ length: workerCount }, () => worker()));
|
|
27
|
+
if (failed)
|
|
28
|
+
throw firstError;
|
|
29
|
+
return results;
|
|
30
|
+
};
|