@intra-mart/accel 0.4.0-dev.202607140628 → 0.4.0-dev.202607210732
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 +17 -0
- package/assets/githooks/.githooks/.gitattributes +2 -0
- package/assets/githooks/.githooks/pre-commit/_meta.json +24 -0
- package/assets/githooks/.githooks/pre-commit/pre-commit_en +268 -0
- package/assets/githooks/.githooks/pre-commit/pre-commit_ja +255 -0
- package/assets/githooks/.githooks/pre-commit/pre-commit_zh_CN +255 -0
- package/dist/asset/asset-tree.d.ts +2 -1
- package/dist/asset/asset-tree.js +1 -0
- package/dist/asset/deployer.js +42 -29
- package/dist/asset/file-provider.js +1 -0
- package/dist/asset/git-provider.d.ts +3 -2
- package/dist/asset/git-provider.js +57 -64
- package/dist/asset/updater.d.ts +1 -1
- package/dist/asset/updater.js +1 -5
- package/dist/asset/walker.d.ts +1 -0
- package/dist/asset/walker.js +14 -3
- package/dist/commands/update.js +14 -4
- package/dist/core/types.d.ts +5 -3
- package/dist/git/object-store.d.ts +4 -2
- package/dist/git/object-store.js +109 -27
- package/dist/i18n/en.js +5 -0
- package/dist/i18n/ja.js +5 -0
- package/dist/i18n/zh_CN.js +5 -0
- package/dist/interactive/prompts.js +19 -8
- package/dist/utils/concurrency.d.ts +1 -0
- package/dist/utils/concurrency.js +30 -0
- package/dist/utils/githooks-sync.d.ts +1 -0
- package/dist/utils/githooks-sync.js +91 -0
- package/dist/utils/mcp-sync.js +6 -0
- package/package.json +3 -2
package/dist/asset/walker.js
CHANGED
|
@@ -89,7 +89,7 @@ const walkDirectory = async (tree, vtree, dir, baseDir, parentMeta, context) =>
|
|
|
89
89
|
return [];
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
|
-
const relativeOf = (p) => p === baseDir ? "" : p.slice(baseDir.length + 1);
|
|
92
|
+
const relativeOf = (p) => p === baseDir ? "" : baseDir === "" ? p : p.slice(baseDir.length + 1);
|
|
93
93
|
if (ownMeta?.type === "file") {
|
|
94
94
|
const parentRelative = relativeOf(dirnamePosix(dir));
|
|
95
95
|
if (ownMeta.rename && ownMeta.rename.length > 0) {
|
|
@@ -151,10 +151,21 @@ const deduplicateByPath = (entries) => {
|
|
|
151
151
|
}
|
|
152
152
|
return [...byPath.values()];
|
|
153
153
|
};
|
|
154
|
-
export const
|
|
154
|
+
export const walkAssetDir = async (tree, context) => {
|
|
155
155
|
const files = await tree.listFiles();
|
|
156
156
|
const vtree = buildVirtualTree(files);
|
|
157
|
-
const
|
|
157
|
+
const meta = await readMetaJson(tree, vtree, "");
|
|
158
|
+
const entries = await walkDirectory(tree, vtree, "", "", meta, context);
|
|
159
|
+
return deduplicateByPath(entries);
|
|
160
|
+
};
|
|
161
|
+
export const walkAssetRepo = async (tree, targetSemver, context) => {
|
|
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);
|
|
168
|
+
const vtree = buildVirtualTree(files);
|
|
158
169
|
const allEntries = [];
|
|
159
170
|
for (const versionDir of versionDirs) {
|
|
160
171
|
const meta = await readMetaJson(tree, vtree, versionDir);
|
package/dist/commands/update.js
CHANGED
|
@@ -10,7 +10,7 @@ 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
12
|
import { mergeFile } from "../utils/merge-file.js";
|
|
13
|
-
import { runInstallBuild } from "../asset/installer.js";
|
|
13
|
+
import { getInstallCmds, runInstallBuild } from "../asset/installer.js";
|
|
14
14
|
import { readSettingsSafe, readHashsum, writeSettings, writeHashsum, } from "../utils/settings-io.js";
|
|
15
15
|
import { getMessage } from "../i18n/index.js";
|
|
16
16
|
import { detectLocale } from "../utils/locale-detect.js";
|
|
@@ -101,7 +101,7 @@ const resolveInteractiveSettings = async (promptOpts, cliOnlyOpts, releaseIdFall
|
|
|
101
101
|
})
|
|
102
102
|
: runPrompts({ ...promptOpts, skipIntro: true });
|
|
103
103
|
};
|
|
104
|
-
const printResult = (summary, locale) => {
|
|
104
|
+
const printResult = (summary, locale, installGuide) => {
|
|
105
105
|
const lines = [
|
|
106
106
|
[summary.updated, "update.result.updated"],
|
|
107
107
|
[summary.merged, "update.result.merged"],
|
|
@@ -147,6 +147,9 @@ const printResult = (summary, locale) => {
|
|
|
147
147
|
p.log.warning(`${getMessage("update.conflictSummary", locale, {
|
|
148
148
|
count: String(summary.conflicts.length),
|
|
149
149
|
})}\n${list}`);
|
|
150
|
+
if (installGuide) {
|
|
151
|
+
p.log.warning(getMessage("update.installSkippedConflict", locale, installGuide));
|
|
152
|
+
}
|
|
150
153
|
}
|
|
151
154
|
if (summary.skippedEdited.length > 0) {
|
|
152
155
|
const list = summary.skippedEdited.map((c) => ` - ${c}`).join("\n");
|
|
@@ -422,10 +425,17 @@ export const updateCommand = defineCommand({
|
|
|
422
425
|
};
|
|
423
426
|
await writeSettings(projectDir, updatedSettings);
|
|
424
427
|
await writeHashsum(projectDir, hashEntries);
|
|
425
|
-
|
|
428
|
+
const skipInstall = args["skip-install"];
|
|
429
|
+
const hasConflicts = summary.conflicts.length > 0;
|
|
430
|
+
if (summary.changedFileCount > 0 && !hasConflicts && !skipInstall) {
|
|
426
431
|
runInstallBuild(projectDir, newSettings.packageManager, buildProgressCallbacks(locale));
|
|
427
432
|
}
|
|
428
|
-
|
|
433
|
+
let installGuide;
|
|
434
|
+
if (hasConflicts && !skipInstall) {
|
|
435
|
+
const [installCommand, buildCommand] = getInstallCmds(newSettings.packageManager);
|
|
436
|
+
installGuide = { installCommand, buildCommand };
|
|
437
|
+
}
|
|
438
|
+
printResult(summary, locale, installGuide);
|
|
429
439
|
}
|
|
430
440
|
catch (err) {
|
|
431
441
|
p.log.error(err instanceof Error ? err.message : String(err));
|
package/dist/core/types.d.ts
CHANGED
|
@@ -56,7 +56,7 @@ export type ForeachReplacement = {
|
|
|
56
56
|
};
|
|
57
57
|
export type Replacement = TextReplacement | SectionReplacement | RegexReplacement | ForeachReplacement;
|
|
58
58
|
export type RenameRule = {
|
|
59
|
-
condition
|
|
59
|
+
condition?: Condition;
|
|
60
60
|
from: string;
|
|
61
61
|
to: string;
|
|
62
62
|
};
|
|
@@ -100,6 +100,7 @@ export type AccelSettings = {
|
|
|
100
100
|
javascript: boolean;
|
|
101
101
|
locale: string;
|
|
102
102
|
packageManager: string;
|
|
103
|
+
gitHooks?: boolean;
|
|
103
104
|
jugglingProject: string | null;
|
|
104
105
|
assetSource?: AssetSourceInfo;
|
|
105
106
|
deployedAssets: Record<string, string>;
|
|
@@ -117,8 +118,9 @@ export type AssetSourceInfo = {
|
|
|
117
118
|
};
|
|
118
119
|
export type AssetProvider = {
|
|
119
120
|
fetch: () => Promise<string>;
|
|
120
|
-
|
|
121
|
-
|
|
121
|
+
listRootEntries: () => Promise<string[]>;
|
|
122
|
+
listFiles: (underDirs?: string[]) => Promise<string[]>;
|
|
123
|
+
materialize: (files: string[]) => Promise<void>;
|
|
122
124
|
readFile: (relPath: string) => Promise<string>;
|
|
123
125
|
cleanup: () => Promise<void>;
|
|
124
126
|
sourceInfo: () => AssetSourceInfo;
|
|
@@ -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
|
@@ -36,6 +36,9 @@ export const messages = {
|
|
|
36
36
|
"warning.moduleMismatch": "Specified modules differ from juggling.im. Using specified values.",
|
|
37
37
|
"warning.gitNotFound": "git command not found. Skipping Git initialization.",
|
|
38
38
|
"warning.fileExists": "File already exists, skipping: {path}",
|
|
39
|
+
"warning.gitHooksUserFile": "Skipped placing the pre-commit hook because {path} is not managed by the CLI. To keep the token-leak check, integrate it into your existing hook manually.",
|
|
40
|
+
"warning.gitHooksPathConflict": "Skipped enabling the pre-commit hook because git core.hooksPath is set to {current}. Integrate the token-leak check (.githooks/pre-commit) into your existing hook setup manually.",
|
|
41
|
+
"warning.gitHooksForeignFiles": "Skipped setting core.hooksPath because .githooks contains files not managed by the CLI ({files}). After confirming they are safe, run git config core.hooksPath .githooks manually.",
|
|
39
42
|
"attach.skipSummary": "{count} file(s) were skipped because they already exist.",
|
|
40
43
|
"attach.overwritePrompt": "{path} already exists. Overwrite?",
|
|
41
44
|
"attach.overwritePrompt.yes": "Yes (overwrite this file)",
|
|
@@ -73,6 +76,7 @@ export const messages = {
|
|
|
73
76
|
"update.upToDate": "Everything is up to date. Nothing to update.",
|
|
74
77
|
"update.complete": "Update complete. Updated {updated}, kept {kept}, deleted {deleted} file(s).",
|
|
75
78
|
"update.conflictSummary": "{count} conflict(s) found. Review the markers (<<<<<<<) and resolve them manually:",
|
|
79
|
+
"update.installSkippedConflict": "install / build were skipped. After resolving the conflicts, run:\n {installCommand} && {buildCommand}",
|
|
76
80
|
"update.error.keepEditedWithoutAllow": "--keep-edited can only be used together with --allow-missing-base.",
|
|
77
81
|
"update.error.baseFetchHint": "To continue in fallback mode, pass --allow-missing-base (add --keep-edited to keep edited files and skip them). If the asset repository moved, point to the new location with --asset-server-url / --asset-ref. As a last resort, run accel detach and re-run init.",
|
|
78
82
|
"update.fallback.editedCount": "Without the base commit, upstream changes to edited files cannot be detected. Edited files that differ from upstream: {count}",
|
|
@@ -89,6 +93,7 @@ export const messages = {
|
|
|
89
93
|
"error.accelExists": ".accel directory already exists",
|
|
90
94
|
"error.accelNotFound": ".accel directory not found",
|
|
91
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)",
|
|
92
97
|
"error.invalidVersion": "Invalid iAP version: {version}",
|
|
93
98
|
"error.invalidModule": "Invalid module (not in release {release}): {module}",
|
|
94
99
|
"error.invalidFeature": "Invalid feature (not in release {release}): {feature}",
|
package/dist/i18n/ja.js
CHANGED
|
@@ -36,6 +36,9 @@ export const messages = {
|
|
|
36
36
|
"warning.moduleMismatch": "指定されたモジュールとjuggling.imのモジュールが異なります。指定値を優先します。",
|
|
37
37
|
"warning.gitNotFound": "gitコマンドが見つかりません。Git初期化をスキップします。",
|
|
38
38
|
"warning.fileExists": "既存ファイルのためスキップ: {path}",
|
|
39
|
+
"warning.gitHooksUserFile": "{path} はCLI管理外のファイルのため、pre-commitフックの配置をスキップしました。トークン漏洩防止のチェックが必要な場合は、既存のフックへ手動で組み込んでください。",
|
|
40
|
+
"warning.gitHooksPathConflict": "gitのcore.hooksPathが {current} に設定されているため、pre-commitフックの有効化をスキップしました。トークン漏洩防止のチェック (.githooks/pre-commit) を既存のフック機構へ手動で組み込んでください。",
|
|
41
|
+
"warning.gitHooksForeignFiles": ".githooks 配下にCLI管理外のファイル ({files}) が存在するため、core.hooksPathの自動設定をスキップしました。内容に問題がないことを確認した上で、git config core.hooksPath .githooks を手動で実行してください。",
|
|
39
42
|
"attach.skipSummary": "{count}件のファイルは既に存在したためスキップしました。",
|
|
40
43
|
"attach.overwritePrompt": "{path} は既に存在します。上書きしますか?",
|
|
41
44
|
"attach.overwritePrompt.yes": "Yes (このファイルを上書き)",
|
|
@@ -73,6 +76,7 @@ export const messages = {
|
|
|
73
76
|
"update.upToDate": "すべて最新の状態です。更新はありません。",
|
|
74
77
|
"update.complete": "updateが完了しました。{updated}件を更新、{kept}件を保持、{deleted}件を削除しました。",
|
|
75
78
|
"update.conflictSummary": "{count}件のコンフリクトがあります。マーカー(<<<<<<<)を確認して手動で解決してください:",
|
|
79
|
+
"update.installSkippedConflict": "install / build はスキップされました。コンフリクト解決後に以下を実行してください:\n {installCommand} && {buildCommand}",
|
|
76
80
|
"update.error.keepEditedWithoutAllow": "--keep-edited は --allow-missing-base と併用する場合のみ指定できます。",
|
|
77
81
|
"update.error.baseFetchHint": "フォールバックモードで続行するには --allow-missing-base を指定してください(--keep-edited 併用で編集済みファイルを保持してスキップ)。資材リポジトリが移転した場合は --asset-server-url / --asset-ref で取得元を変更できます。最終手段として accel detach 後に再度 init する方法もあります。",
|
|
78
82
|
"update.fallback.editedCount": "基準コミット(base)なしで続行する場合、編集済みファイルの上流変更は判定できません。上流と差分のある編集済みファイル: {count}件",
|
|
@@ -89,6 +93,7 @@ export const messages = {
|
|
|
89
93
|
"error.accelExists": ".accelディレクトリが既に存在します",
|
|
90
94
|
"error.accelNotFound": ".accelディレクトリが見つかりません",
|
|
91
95
|
"error.missingRequiredOptions": "以下の必須オプションが指定されていません: {options}",
|
|
96
|
+
"error.initNameArgumentMissing": "プロジェクト名が指定されていません。引数で指定してください(例: accel init my-project)",
|
|
92
97
|
"error.invalidVersion": "無効なiAPバージョンです: {version}",
|
|
93
98
|
"error.invalidModule": "無効なモジュールです(リリース {release} に存在しません): {module}",
|
|
94
99
|
"error.invalidFeature": "無効な機能です(リリース {release} に存在しません): {feature}",
|
package/dist/i18n/zh_CN.js
CHANGED
|
@@ -36,6 +36,9 @@ export const messages = {
|
|
|
36
36
|
"warning.moduleMismatch": "指定的模块与juggling.im不同。将使用指定值。",
|
|
37
37
|
"warning.gitNotFound": "未找到git命令。跳过Git初始化。",
|
|
38
38
|
"warning.fileExists": "文件已存在,跳过: {path}",
|
|
39
|
+
"warning.gitHooksUserFile": "由于 {path} 不是由 CLI 管理的文件,已跳过 pre-commit 钩子的部署。如需保留防止令牌泄露的检查,请手动将其集成到现有钩子中。",
|
|
40
|
+
"warning.gitHooksPathConflict": "由于 git 的 core.hooksPath 已设置为 {current},已跳过 pre-commit 钩子的启用。请手动将防止令牌泄露的检查(.githooks/pre-commit)集成到现有的钩子机制中。",
|
|
41
|
+
"warning.gitHooksForeignFiles": "由于 .githooks 下存在不由 CLI 管理的文件({files}),已跳过 core.hooksPath 的自动设置。请确认其内容没有问题后,手动执行 git config core.hooksPath .githooks。",
|
|
39
42
|
"attach.skipSummary": "{count}个文件已存在,已跳过。",
|
|
40
43
|
"attach.overwritePrompt": "{path} 已存在。要覆盖吗?",
|
|
41
44
|
"attach.overwritePrompt.yes": "Yes (覆盖此文件)",
|
|
@@ -73,6 +76,7 @@ export const messages = {
|
|
|
73
76
|
"update.upToDate": "已是最新状态,无需更新。",
|
|
74
77
|
"update.complete": "update完成。更新{updated}个、保留{kept}个、删除{deleted}个文件。",
|
|
75
78
|
"update.conflictSummary": "发现{count}个冲突。请检查标记(<<<<<<<)并手动解决:",
|
|
79
|
+
"update.installSkippedConflict": "已跳过 install / build。解决冲突后请执行以下命令:\n {installCommand} && {buildCommand}",
|
|
76
80
|
"update.error.keepEditedWithoutAllow": "--keep-edited 仅可与 --allow-missing-base 一起使用。",
|
|
77
81
|
"update.error.baseFetchHint": "要以回退模式继续,请指定 --allow-missing-base(同时指定 --keep-edited 可保留并跳过已编辑的文件)。如果资源仓库已迁移,可通过 --asset-server-url / --asset-ref 更改获取源。作为最后手段,可执行 accel detach 后重新 init。",
|
|
78
82
|
"update.fallback.editedCount": "在没有基准提交(base)的情况下继续时,无法判定已编辑文件的上游变更。与上游存在差异的已编辑文件: {count}个",
|
|
@@ -89,6 +93,7 @@ export const messages = {
|
|
|
89
93
|
"error.accelExists": ".accel目录已存在",
|
|
90
94
|
"error.accelNotFound": "未找到.accel目录",
|
|
91
95
|
"error.missingRequiredOptions": "以下必需选项未指定: {options}",
|
|
96
|
+
"error.initNameArgumentMissing": "未指定项目名称。请作为参数指定(例如: accel init my-project)",
|
|
92
97
|
"error.invalidVersion": "无效的iAP版本: {version}",
|
|
93
98
|
"error.invalidModule": "无效的模块(不存在于发行版 {release}): {module}",
|
|
94
99
|
"error.invalidFeature": "无效的功能(不存在于发行版 {release}): {feature}",
|
|
@@ -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
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const syncGitHooks: (projectDir: string) => Promise<void>;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import { access, chmod, mkdir, readdir, readFile, writeFile, } from "node:fs/promises";
|
|
3
|
+
import { dirname, join } from "node:path";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
import git from "isomorphic-git";
|
|
6
|
+
import * as p from "@clack/prompts";
|
|
7
|
+
import { createFsAssetTree } from "../asset/asset-tree.js";
|
|
8
|
+
import { walkAssetDir } from "../asset/walker.js";
|
|
9
|
+
import { emptyEvalContext } from "../core/eval-context.js";
|
|
10
|
+
import { getMessage } from "../i18n/index.js";
|
|
11
|
+
import { detectLocale } from "./locale-detect.js";
|
|
12
|
+
import { readSettingsSafe } from "./settings-io.js";
|
|
13
|
+
const MANAGED_MARKER = "@accel-cli-managed";
|
|
14
|
+
const HOOKS_PATH = ".githooks";
|
|
15
|
+
const HOOK_FILE_REL = ".githooks/pre-commit";
|
|
16
|
+
const ASSETS_GITHOOKS_ROOT = fileURLToPath(new URL("../../assets/githooks", import.meta.url));
|
|
17
|
+
const readFileSafe = async (filePath) => {
|
|
18
|
+
try {
|
|
19
|
+
return await readFile(filePath, "utf-8");
|
|
20
|
+
}
|
|
21
|
+
catch {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
const listForeignFiles = async (hooksDir) => {
|
|
26
|
+
const foreign = [];
|
|
27
|
+
for (const entry of await readdir(hooksDir, { withFileTypes: true })) {
|
|
28
|
+
if (!entry.isFile()) {
|
|
29
|
+
foreign.push(entry.name);
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
const content = await readFileSafe(join(hooksDir, entry.name));
|
|
33
|
+
if (content === null || !content.includes(MANAGED_MARKER)) {
|
|
34
|
+
foreign.push(entry.name);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return foreign;
|
|
38
|
+
};
|
|
39
|
+
export const syncGitHooks = async (projectDir) => {
|
|
40
|
+
const settings = await readSettingsSafe(projectDir);
|
|
41
|
+
if (settings?.gitHooks === false)
|
|
42
|
+
return;
|
|
43
|
+
try {
|
|
44
|
+
await access(join(projectDir, ".git"));
|
|
45
|
+
}
|
|
46
|
+
catch {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
const locale = settings?.locale ?? detectLocale();
|
|
50
|
+
const tree = createFsAssetTree(ASSETS_GITHOOKS_ROOT);
|
|
51
|
+
const entries = await walkAssetDir(tree, emptyEvalContext({ locale }));
|
|
52
|
+
for (const entry of entries) {
|
|
53
|
+
const destPath = join(projectDir, entry.relativePath);
|
|
54
|
+
const existing = await readFileSafe(destPath);
|
|
55
|
+
if (existing !== null && !existing.includes(MANAGED_MARKER)) {
|
|
56
|
+
p.log.warning(getMessage("warning.gitHooksUserFile", locale, {
|
|
57
|
+
path: entry.relativePath,
|
|
58
|
+
}));
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
const content = (await tree.readFile(entry.sourceRelPath)).replace(/\r\n/g, "\n");
|
|
62
|
+
await mkdir(dirname(destPath), { recursive: true });
|
|
63
|
+
await writeFile(destPath, content, "utf-8");
|
|
64
|
+
if (entry.relativePath === HOOK_FILE_REL) {
|
|
65
|
+
await chmod(destPath, 0o755);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
const current = (await git.getConfig({
|
|
69
|
+
fs,
|
|
70
|
+
dir: projectDir,
|
|
71
|
+
path: "core.hooksPath",
|
|
72
|
+
}));
|
|
73
|
+
if (current === undefined) {
|
|
74
|
+
const foreign = await listForeignFiles(join(projectDir, HOOKS_PATH));
|
|
75
|
+
if (foreign.length > 0) {
|
|
76
|
+
p.log.warning(getMessage("warning.gitHooksForeignFiles", locale, {
|
|
77
|
+
files: foreign.join(", "),
|
|
78
|
+
}));
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
await git.setConfig({
|
|
82
|
+
fs,
|
|
83
|
+
dir: projectDir,
|
|
84
|
+
path: "core.hooksPath",
|
|
85
|
+
value: HOOKS_PATH,
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
else if (current !== HOOKS_PATH) {
|
|
89
|
+
p.log.warning(getMessage("warning.gitHooksPathConflict", locale, { current }));
|
|
90
|
+
}
|
|
91
|
+
};
|
package/dist/utils/mcp-sync.js
CHANGED
|
@@ -2,6 +2,7 @@ import { readFile, writeFile } from "node:fs/promises";
|
|
|
2
2
|
import { join } from "node:path";
|
|
3
3
|
import { parse as parseToml, stringify as stringifyToml } from "smol-toml";
|
|
4
4
|
import { persistCredentials } from "./credentials.js";
|
|
5
|
+
import { syncGitHooks } from "./githooks-sync.js";
|
|
5
6
|
import { readSettingsSafe } from "./settings-io.js";
|
|
6
7
|
const AUTHORIZATION_HEADER = "Authorization";
|
|
7
8
|
export const matchesEndpoint = (url, endpoint) => {
|
|
@@ -94,4 +95,9 @@ export const persistCredentialsAndSyncMcp = async (projectDir, creds) => {
|
|
|
94
95
|
}
|
|
95
96
|
catch {
|
|
96
97
|
}
|
|
98
|
+
try {
|
|
99
|
+
await syncGitHooks(projectDir);
|
|
100
|
+
}
|
|
101
|
+
catch {
|
|
102
|
+
}
|
|
97
103
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intra-mart/accel",
|
|
3
|
-
"version": "0.4.0-dev.
|
|
3
|
+
"version": "0.4.0-dev.202607210732",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "CLI tool for intra-mart Accel Platform development",
|
|
6
6
|
"author": "NTT DATA INTRAMART",
|
|
@@ -19,7 +19,8 @@
|
|
|
19
19
|
"accel": "./dist/index.js"
|
|
20
20
|
},
|
|
21
21
|
"files": [
|
|
22
|
-
"dist"
|
|
22
|
+
"dist",
|
|
23
|
+
"assets"
|
|
23
24
|
],
|
|
24
25
|
"engines": {
|
|
25
26
|
"node": ">=24.0.0"
|