@intra-mart/accel 0.5.0-dev.202608040843 → 0.5.0-next.202608070519
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/deployer.d.ts +1 -0
- package/dist/asset/deployer.js +7 -1
- package/dist/asset/git-provider.d.ts +1 -0
- package/dist/asset/git-provider.js +9 -5
- package/dist/asset/updater.d.ts +7 -1
- package/dist/asset/updater.js +3 -1
- package/dist/commands/asset-provider.d.ts +1 -1
- package/dist/commands/asset-provider.js +2 -2
- package/dist/commands/attach.js +11 -19
- package/dist/commands/cache.js +11 -16
- package/dist/commands/deploy.d.ts +23 -2
- package/dist/commands/deploy.js +112 -72
- package/dist/commands/detach.js +4 -4
- package/dist/commands/init.d.ts +32 -0
- package/dist/commands/init.js +117 -98
- package/dist/commands/login.d.ts +2 -0
- package/dist/commands/login.js +16 -9
- package/dist/commands/preset.js +26 -33
- package/dist/commands/run-wrapper.d.ts +1 -0
- package/dist/commands/run-wrapper.js +16 -0
- package/dist/commands/switch.d.ts +26 -0
- package/dist/commands/switch.js +190 -173
- package/dist/commands/update.d.ts +53 -0
- package/dist/commands/update.js +334 -283
- package/dist/core/constants.d.ts +0 -1
- package/dist/core/constants.js +0 -3
- package/dist/core/errors.d.ts +6 -0
- package/dist/core/errors.js +16 -0
- package/dist/core/logger.d.ts +15 -0
- package/dist/core/logger.js +1 -0
- package/dist/core/paths.d.ts +6 -0
- package/dist/core/paths.js +22 -0
- package/dist/core/validation.d.ts +34 -0
- package/dist/core/validation.js +87 -0
- package/dist/deploy/api-client.d.ts +1 -0
- package/dist/deploy/api-client.js +7 -1
- package/dist/git/http.d.ts +2 -2
- package/dist/git/http.js +11 -6
- package/dist/git/smart-http.d.ts +3 -2
- package/dist/git/smart-http.js +5 -5
- package/dist/index.js +2 -2
- package/dist/interactive/asset-messages.d.ts +2 -1
- package/dist/interactive/asset-messages.js +4 -4
- package/dist/interactive/clack-logger.d.ts +2 -0
- package/dist/interactive/clack-logger.js +11 -0
- package/dist/interactive/credential-auth.d.ts +2 -0
- package/dist/interactive/credential-auth.js +7 -6
- package/dist/interactive/credentials-prompts.js +8 -5
- package/dist/interactive/next-steps.d.ts +2 -1
- package/dist/interactive/next-steps.js +3 -3
- package/dist/interactive/progress.d.ts +2 -1
- package/dist/interactive/progress.js +8 -8
- package/dist/interactive/prompts.d.ts +3 -33
- package/dist/interactive/prompts.js +23 -111
- package/dist/interactive/summary.d.ts +2 -1
- package/dist/interactive/summary.js +3 -3
- package/dist/juggling/resolve.d.ts +7 -0
- package/dist/juggling/resolve.js +18 -0
- package/dist/lib.d.ts +29 -0
- package/dist/lib.js +24 -0
- package/dist/utils/args.d.ts +1 -0
- package/dist/utils/args.js +1 -0
- package/dist/utils/githooks-sync.d.ts +3 -1
- package/dist/utils/githooks-sync.js +6 -8
- package/dist/utils/mcp-sync.d.ts +3 -1
- package/dist/utils/mcp-sync.js +2 -2
- package/package.json +8 -1
package/dist/asset/deployer.d.ts
CHANGED
package/dist/asset/deployer.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { writeFile, mkdir, stat } from "node:fs/promises";
|
|
2
2
|
import { join, dirname, resolve, sep } from "node:path";
|
|
3
3
|
import { buildEvalContext } from "../core/eval-context.js";
|
|
4
|
+
import { normalizeAbort } from "../core/errors.js";
|
|
4
5
|
import { walkAssetRepo } from "./walker.js";
|
|
5
6
|
import { createMessageCollector } from "./messages.js";
|
|
6
7
|
import { renderAssetContent } from "./renderer.js";
|
|
@@ -55,7 +56,7 @@ const groupSections = (entries) => {
|
|
|
55
56
|
return [...groups.values()];
|
|
56
57
|
};
|
|
57
58
|
export const deployAssets = async (options) => {
|
|
58
|
-
const { projectDir, settings, provider, noInstall, skipExistingFiles, onExistingFile, progress, } = options;
|
|
59
|
+
const { projectDir, settings, provider, noInstall, skipExistingFiles, onExistingFile, progress, signal, } = options;
|
|
59
60
|
try {
|
|
60
61
|
progress?.onFetchStart?.();
|
|
61
62
|
const repoDir = await provider.fetch();
|
|
@@ -79,6 +80,7 @@ export const deployAssets = async (options) => {
|
|
|
79
80
|
}
|
|
80
81
|
return true;
|
|
81
82
|
});
|
|
83
|
+
signal?.throwIfAborted();
|
|
82
84
|
progress?.onDownloadStart?.();
|
|
83
85
|
await provider.materialize([
|
|
84
86
|
...new Set(entries.map((e) => e.sourceRelPath)),
|
|
@@ -110,6 +112,7 @@ export const deployAssets = async (options) => {
|
|
|
110
112
|
}
|
|
111
113
|
toDeploy.push(entry);
|
|
112
114
|
}
|
|
115
|
+
signal?.throwIfAborted();
|
|
113
116
|
const hashEntries = await mapWithConcurrency(toDeploy, FS_CONCURRENCY, async (entry) => {
|
|
114
117
|
const targetPath = entry.relativePath;
|
|
115
118
|
const destPath = join(projectDir, targetPath);
|
|
@@ -144,6 +147,9 @@ export const deployAssets = async (options) => {
|
|
|
144
147
|
}
|
|
145
148
|
return { deployedFiles, hashEntries, skippedFiles, overwrittenFiles };
|
|
146
149
|
}
|
|
150
|
+
catch (err) {
|
|
151
|
+
throw normalizeAbort(err, signal);
|
|
152
|
+
}
|
|
147
153
|
finally {
|
|
148
154
|
await provider.cleanup().catch(() => { });
|
|
149
155
|
}
|
|
@@ -11,5 +11,6 @@ export type GitAssetProvider = AssetProvider & {
|
|
|
11
11
|
};
|
|
12
12
|
export type GitAssetProviderOptions = {
|
|
13
13
|
locale?: string;
|
|
14
|
+
signal?: AbortSignal;
|
|
14
15
|
};
|
|
15
16
|
export declare const createGitAssetProvider: (repoUrl: string, ref: string, options?: GitAssetProviderOptions) => GitAssetProvider;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isAbortError } from "../core/errors.js";
|
|
1
2
|
import { getMessage } from "../i18n/index.js";
|
|
2
3
|
import { isGitAuthError, isGitObjectMissingError, isGitServerUnsupportedError, } from "../git/errors.js";
|
|
3
4
|
import { createObjectStore, } from "../git/object-store.js";
|
|
@@ -15,7 +16,7 @@ const isHttpUrl = (url) => {
|
|
|
15
16
|
}
|
|
16
17
|
};
|
|
17
18
|
export const createGitAssetProvider = (repoUrl, ref, options = {}) => {
|
|
18
|
-
const { locale = "en" } = options;
|
|
19
|
+
const { locale = "en", signal } = options;
|
|
19
20
|
let store = null;
|
|
20
21
|
let commit = null;
|
|
21
22
|
const withHint = (message, cause) => {
|
|
@@ -62,7 +63,7 @@ export const createGitAssetProvider = (repoUrl, ref, options = {}) => {
|
|
|
62
63
|
missing.push(oid);
|
|
63
64
|
}
|
|
64
65
|
for (let i = 0; i < missing.length; i += MAX_WANTS_PER_REQUEST) {
|
|
65
|
-
const pack = await fetchPack(repoUrl, missing.slice(i, i + MAX_WANTS_PER_REQUEST));
|
|
66
|
+
const pack = await fetchPack(repoUrl, missing.slice(i, i + MAX_WANTS_PER_REQUEST), { signal });
|
|
66
67
|
await store.writePack(pack, "blobs");
|
|
67
68
|
}
|
|
68
69
|
};
|
|
@@ -110,15 +111,18 @@ export const createGitAssetProvider = (repoUrl, ref, options = {}) => {
|
|
|
110
111
|
const pack = await fetchPack(repoUrl, [oid], {
|
|
111
112
|
deepenOne: true,
|
|
112
113
|
filterBlobNone: true,
|
|
114
|
+
signal,
|
|
113
115
|
});
|
|
114
116
|
await store.writePack(pack, label);
|
|
115
117
|
}
|
|
116
118
|
await listRootFilesAt(oid);
|
|
117
119
|
};
|
|
118
120
|
const rethrowWithServerDiagnosis = async (original) => {
|
|
119
|
-
if (!isGitAuthError(original)
|
|
121
|
+
if (!isGitAuthError(original) &&
|
|
122
|
+
!isAbortError(original) &&
|
|
123
|
+
signal?.aborted !== true) {
|
|
120
124
|
try {
|
|
121
|
-
assertServerSupported(repoUrl, await fetchCapabilities(repoUrl));
|
|
125
|
+
assertServerSupported(repoUrl, await fetchCapabilities(repoUrl, signal));
|
|
122
126
|
}
|
|
123
127
|
catch (diagErr) {
|
|
124
128
|
if (isGitServerUnsupportedError(diagErr))
|
|
@@ -150,7 +154,7 @@ export const createGitAssetProvider = (repoUrl, ref, options = {}) => {
|
|
|
150
154
|
const opened = await ensureStore();
|
|
151
155
|
try {
|
|
152
156
|
try {
|
|
153
|
-
const resolved = await resolveRef(repoUrl, ref);
|
|
157
|
+
const resolved = await resolveRef(repoUrl, ref, signal);
|
|
154
158
|
if (!resolved) {
|
|
155
159
|
throw new Error(`ref not found on server: ${ref}`);
|
|
156
160
|
}
|
package/dist/asset/updater.d.ts
CHANGED
|
@@ -35,6 +35,12 @@ export declare const classifySwitch: (states: FileState[]) => UpdateAction[];
|
|
|
35
35
|
export declare const classifyAll: (states: FileState[], merge: MergeFn, fallback?: {
|
|
36
36
|
keepEdited: boolean;
|
|
37
37
|
}) => Promise<UpdateAction[]>;
|
|
38
|
+
export type UpdaterProgressCallbacks = {
|
|
39
|
+
onRenderStart?: (side: "theirs" | "base") => void;
|
|
40
|
+
onClassifyStart?: (fileCount: number) => void;
|
|
41
|
+
onApplyStart?: (changeCount: number) => void;
|
|
42
|
+
onFileApplied?: (relativePath: string, outcome: UpdateAction["outcome"]) => void;
|
|
43
|
+
};
|
|
38
44
|
export type UpdateSummary = {
|
|
39
45
|
updated: string[];
|
|
40
46
|
merged: string[];
|
|
@@ -51,7 +57,7 @@ export type UpdateSummary = {
|
|
|
51
57
|
skippedSwitch: string[];
|
|
52
58
|
changedFileCount: number;
|
|
53
59
|
};
|
|
54
|
-
export declare const applyUpdateActions: (projectDir: string, actions: UpdateAction[]) => Promise<UpdateSummary>;
|
|
60
|
+
export declare const applyUpdateActions: (projectDir: string, actions: UpdateAction[], progress?: UpdaterProgressCallbacks) => Promise<UpdateSummary>;
|
|
55
61
|
export declare const buildUpdatedRecords: (oldEntries: HashsumEntry[], actions: UpdateAction[]) => {
|
|
56
62
|
hashEntries: HashsumEntry[];
|
|
57
63
|
deployedAssets: Record<string, string>;
|
package/dist/asset/updater.js
CHANGED
|
@@ -296,7 +296,8 @@ export const classifyAll = async (states, merge, fallback) => {
|
|
|
296
296
|
}
|
|
297
297
|
return actions;
|
|
298
298
|
};
|
|
299
|
-
export const applyUpdateActions = async (projectDir, actions) => {
|
|
299
|
+
export const applyUpdateActions = async (projectDir, actions, progress) => {
|
|
300
|
+
progress?.onApplyStart?.(actions.filter((a) => a.op !== "none").length);
|
|
300
301
|
const summary = {
|
|
301
302
|
updated: [],
|
|
302
303
|
merged: [],
|
|
@@ -324,6 +325,7 @@ export const applyUpdateActions = async (projectDir, actions) => {
|
|
|
324
325
|
for (const action of actions) {
|
|
325
326
|
if (action.op !== "none") {
|
|
326
327
|
summary.changedFileCount++;
|
|
328
|
+
progress?.onFileApplied?.(action.relativePath, action.outcome);
|
|
327
329
|
}
|
|
328
330
|
switch (action.outcome) {
|
|
329
331
|
case "updated":
|
|
@@ -4,4 +4,4 @@ export type AssetProviderArgs = {
|
|
|
4
4
|
assetServerUrl?: string;
|
|
5
5
|
assetRef?: string;
|
|
6
6
|
};
|
|
7
|
-
export declare const selectAssetProvider: (args: AssetProviderArgs, locale: string) => Promise<AssetProvider>;
|
|
7
|
+
export declare const selectAssetProvider: (args: AssetProviderArgs, locale: string, signal?: AbortSignal) => Promise<AssetProvider>;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { DEFAULT_ASSET_REPO_URL, DEFAULT_ASSET_REF, } from "../core/constants.js";
|
|
2
2
|
import { createFileAssetProvider } from "../asset/file-provider.js";
|
|
3
3
|
import { createGitAssetProvider } from "../asset/git-provider.js";
|
|
4
|
-
export const selectAssetProvider = async (args, locale) => {
|
|
4
|
+
export const selectAssetProvider = async (args, locale, signal) => {
|
|
5
5
|
if (args.assetSource) {
|
|
6
6
|
return createFileAssetProvider(args.assetSource);
|
|
7
7
|
}
|
|
8
|
-
return createGitAssetProvider(args.assetServerUrl ?? DEFAULT_ASSET_REPO_URL, args.assetRef ?? DEFAULT_ASSET_REF, { locale });
|
|
8
|
+
return createGitAssetProvider(args.assetServerUrl ?? DEFAULT_ASSET_REPO_URL, args.assetRef ?? DEFAULT_ASSET_REF, { locale, signal });
|
|
9
9
|
};
|
package/dist/commands/attach.js
CHANGED
|
@@ -2,10 +2,12 @@ import { defineCommand } from "citty";
|
|
|
2
2
|
import * as p from "@clack/prompts";
|
|
3
3
|
import { stat } from "node:fs/promises";
|
|
4
4
|
import { basename, join } from "node:path";
|
|
5
|
-
import {
|
|
5
|
+
import { getCliVersion } from "../core/paths.js";
|
|
6
6
|
import { runPrompts } from "../interactive/prompts.js";
|
|
7
7
|
import { deployAssets, } from "../asset/deployer.js";
|
|
8
8
|
import { selectAssetProvider } from "./asset-provider.js";
|
|
9
|
+
import { createCancelledError } from "../core/errors.js";
|
|
10
|
+
import { withExitCode } from "./run-wrapper.js";
|
|
9
11
|
import { getMessage } from "../i18n/index.js";
|
|
10
12
|
import { detectLocale } from "../utils/locale-detect.js";
|
|
11
13
|
import { printSummary } from "../interactive/summary.js";
|
|
@@ -101,15 +103,12 @@ export const attachCommand = defineCommand({
|
|
|
101
103
|
description: "(debug) Local asset source directory",
|
|
102
104
|
},
|
|
103
105
|
},
|
|
104
|
-
run: async ({ args }) => {
|
|
106
|
+
run: withExitCode(async ({ args }) => {
|
|
105
107
|
const locale = args.locale ?? detectLocale();
|
|
106
108
|
const projectDir = process.cwd();
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
process.exit(1);
|
|
111
|
-
}
|
|
112
|
-
catch {
|
|
109
|
+
const accelExists = await stat(join(projectDir, ".accel")).then(() => true, () => false);
|
|
110
|
+
if (accelExists) {
|
|
111
|
+
throw new Error(getMessage("error.accelExists", locale));
|
|
113
112
|
}
|
|
114
113
|
const moduleArg = args.module;
|
|
115
114
|
const modules = moduleArg
|
|
@@ -140,16 +139,9 @@ export const attachCommand = defineCommand({
|
|
|
140
139
|
noInteraction: args["non-interactive"],
|
|
141
140
|
isInit: false,
|
|
142
141
|
};
|
|
143
|
-
|
|
144
|
-
try {
|
|
145
|
-
resolved = await runPrompts(promptOpts);
|
|
146
|
-
}
|
|
147
|
-
catch (err) {
|
|
148
|
-
p.log.error(err instanceof Error ? err.message : String(err));
|
|
149
|
-
process.exit(1);
|
|
150
|
-
}
|
|
142
|
+
const resolved = await runPrompts(promptOpts);
|
|
151
143
|
const settings = {
|
|
152
|
-
cliVersion:
|
|
144
|
+
cliVersion: getCliVersion(),
|
|
153
145
|
createdAt: new Date().toISOString(),
|
|
154
146
|
name: resolved.name,
|
|
155
147
|
artifactId: resolved.artifactId,
|
|
@@ -212,7 +204,7 @@ export const attachCommand = defineCommand({
|
|
|
212
204
|
],
|
|
213
205
|
});
|
|
214
206
|
if (p.isCancel(choice))
|
|
215
|
-
|
|
207
|
+
throw createCancelledError();
|
|
216
208
|
if (choice === "all") {
|
|
217
209
|
sticky = "all";
|
|
218
210
|
return "overwrite";
|
|
@@ -256,5 +248,5 @@ export const attachCommand = defineCommand({
|
|
|
256
248
|
isInit: false,
|
|
257
249
|
locale,
|
|
258
250
|
});
|
|
259
|
-
},
|
|
251
|
+
}),
|
|
260
252
|
});
|
package/dist/commands/cache.js
CHANGED
|
@@ -5,6 +5,7 @@ import { cacheReposDir, directorySize, listCacheRepos, resolveCacheRoot, } from
|
|
|
5
5
|
import { getMessage } from "../i18n/index.js";
|
|
6
6
|
import { detectLocale } from "../utils/locale-detect.js";
|
|
7
7
|
import { sanitizeDisplayText } from "../utils/sanitize-text.js";
|
|
8
|
+
import { withExitCode } from "./run-wrapper.js";
|
|
8
9
|
const formatBytes = (bytes) => {
|
|
9
10
|
if (bytes >= 1024 ** 3)
|
|
10
11
|
return `${(bytes / 1024 ** 3).toFixed(1)} GB`;
|
|
@@ -19,7 +20,7 @@ const infoCommand = defineCommand({
|
|
|
19
20
|
name: "info",
|
|
20
21
|
description: "Show the asset cache location and disk usage",
|
|
21
22
|
},
|
|
22
|
-
run: async () => {
|
|
23
|
+
run: withExitCode(async () => {
|
|
23
24
|
const locale = detectLocale();
|
|
24
25
|
const root = resolveCacheRoot();
|
|
25
26
|
let dirLine = getMessage("cache.info.dir", locale, { path: root });
|
|
@@ -37,30 +38,24 @@ const infoCommand = defineCommand({
|
|
|
37
38
|
for (const repo of repos) {
|
|
38
39
|
p.log.info(` ${sanitizeDisplayText(repo.url ?? repo.dir)} — ${formatBytes(repo.size)}`);
|
|
39
40
|
}
|
|
40
|
-
},
|
|
41
|
+
}),
|
|
41
42
|
});
|
|
42
43
|
const clearCommand = defineCommand({
|
|
43
44
|
meta: {
|
|
44
45
|
name: "clear",
|
|
45
46
|
description: "Delete the asset cache (it will be re-downloaded on demand)",
|
|
46
47
|
},
|
|
47
|
-
run: async () => {
|
|
48
|
+
run: withExitCode(async () => {
|
|
48
49
|
const locale = detectLocale();
|
|
49
50
|
const reposDir = cacheReposDir(resolveCacheRoot());
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
await rm(reposDir, { recursive: true, force: true });
|
|
57
|
-
p.log.success(getMessage("cache.clear.done", locale, { size: formatBytes(size) }));
|
|
58
|
-
}
|
|
59
|
-
catch (err) {
|
|
60
|
-
p.log.error(err instanceof Error ? err.message : String(err));
|
|
61
|
-
process.exit(1);
|
|
51
|
+
const size = await directorySize(reposDir);
|
|
52
|
+
if (size === 0) {
|
|
53
|
+
p.log.info(getMessage("cache.clear.empty", locale));
|
|
54
|
+
return;
|
|
62
55
|
}
|
|
63
|
-
|
|
56
|
+
await rm(reposDir, { recursive: true, force: true });
|
|
57
|
+
p.log.success(getMessage("cache.clear.done", locale, { size: formatBytes(size) }));
|
|
58
|
+
}),
|
|
64
59
|
});
|
|
65
60
|
export const cacheCommand = defineCommand({
|
|
66
61
|
meta: {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { AccelCredentials, SampleSetupConfigResponse, SetupConfigResponse, StagingResponse } from "../core/types.js";
|
|
1
|
+
import type { AccelCredentials, DeploymentCreateResponse, SampleSetupConfigResponse, SetupConfigResponse, StagingResponse } from "../core/types.js";
|
|
2
|
+
import type { Logger } from "../core/logger.js";
|
|
2
3
|
import { type ApiClient } from "../deploy/api-client.js";
|
|
3
4
|
import { type DeployFile } from "../deploy/deploy-files.js";
|
|
4
5
|
export type ConfirmInfo = {
|
|
@@ -6,6 +7,24 @@ export type ConfirmInfo = {
|
|
|
6
7
|
stagingId: string;
|
|
7
8
|
files: DeployFile[];
|
|
8
9
|
};
|
|
10
|
+
export type SetupRunOutcome = {
|
|
11
|
+
status: "executed";
|
|
12
|
+
} | {
|
|
13
|
+
status: "skippedNoConfig";
|
|
14
|
+
} | {
|
|
15
|
+
status: "failed";
|
|
16
|
+
message?: string;
|
|
17
|
+
};
|
|
18
|
+
export type DeployRunResult = {
|
|
19
|
+
deployId: string;
|
|
20
|
+
stagingId: string;
|
|
21
|
+
status: DeploymentCreateResponse["status"];
|
|
22
|
+
createDate: number;
|
|
23
|
+
shortcutUrl?: string;
|
|
24
|
+
tenantSetup?: SetupRunOutcome;
|
|
25
|
+
sampleSetup?: SetupRunOutcome;
|
|
26
|
+
};
|
|
27
|
+
export declare const hasFlagSetupFailure: (result: DeployRunResult | undefined) => boolean;
|
|
9
28
|
export type DeployPrompts = {
|
|
10
29
|
selectStaging: (stagings: StagingResponse[], locale: string) => Promise<string>;
|
|
11
30
|
selectZip: (zips: string[], locale: string) => Promise<string>;
|
|
@@ -40,8 +59,10 @@ export type RunDeployDeps = {
|
|
|
40
59
|
scanTargets?: (projectDir: string) => Promise<string[]>;
|
|
41
60
|
apiClientFactory?: (endpoint: string, apiKey: string) => ApiClient;
|
|
42
61
|
prompts?: DeployPrompts;
|
|
62
|
+
logger?: Logger;
|
|
63
|
+
signal?: AbortSignal;
|
|
43
64
|
};
|
|
44
|
-
export declare const runDeploy: (deps: RunDeployDeps) => Promise<
|
|
65
|
+
export declare const runDeploy: (deps: RunDeployDeps) => Promise<DeployRunResult | undefined>;
|
|
45
66
|
export declare const deployCommand: import("citty").CommandDef<{
|
|
46
67
|
endpoint: {
|
|
47
68
|
type: "string";
|