@intra-mart/accel 0.4.0-dev.202607170346 → 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/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/core/types.d.ts +2 -1
- package/dist/git/object-store.d.ts +4 -2
- package/dist/git/object-store.js +109 -27
- package/dist/i18n/en.js +1 -0
- package/dist/i18n/ja.js +1 -0
- package/dist/i18n/zh_CN.js +1 -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
|
@@ -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);
|
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>;
|
|
@@ -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}",
|
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}",
|
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}",
|
|
@@ -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
|
+
};
|