castle-web-cli 0.4.215 → 0.4.216
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/api.d.ts +14 -0
- package/dist/api.js +31 -0
- package/dist/cloudGit.d.ts +112 -1
- package/dist/cloudGit.js +1442 -73
- package/dist/cloudGitServe.js +2 -2
- package/dist/gitRemote.d.ts +1 -0
- package/dist/gitRemote.js +1 -0
- package/dist/ide.js +2 -2
- package/dist/index.js +25 -4
- package/dist/shell/assets/{index-DIRq6YrV.js → index-BZebTIjR.js} +2 -2
- package/dist/shell/index.html +1 -1
- package/package.json +1 -1
package/dist/cloudGitServe.js
CHANGED
|
@@ -2,7 +2,7 @@ import { spawn } from 'child_process';
|
|
|
2
2
|
import * as fs from 'fs';
|
|
3
3
|
import * as path from 'path';
|
|
4
4
|
import { fileURLToPath } from 'url';
|
|
5
|
-
import { AGENT_MARKER_FILES, cloudGitModeAsync, CONFLICT_MARKER_FILE, DEADLINE_ENV, EXIT_CONFLICT, EXIT_NOT_ENABLED,
|
|
5
|
+
import { AGENT_MARKER_FILES, cloudGitModeAsync, CONFLICT_MARKER_FILE, DEADLINE_ENV, EXIT_CONFLICT, EXIT_NOT_ENABLED, mergeWaiting, readLeavePending, readMergeState, setDeckBusy, } from './cloudGit.js';
|
|
6
6
|
// The serve's half of git in the cloud sandbox (castle-sandboxes docs/git-remotes-phase2.md):
|
|
7
7
|
// - `commit --reason turn` when the router settles with the task board idle,
|
|
8
8
|
// - `commit --reason task` when the task board goes idle,
|
|
@@ -218,7 +218,7 @@ export function createServeGitHooks(opts) {
|
|
|
218
218
|
// A commit was refused because a merge still waits, and no resolver is working on it: ask
|
|
219
219
|
// again, at most every REASK_MS, so a merge an earlier turn left unresolved is not stuck.
|
|
220
220
|
function reraiseUnresolvedMerge() {
|
|
221
|
-
if (resolverInFlight || now() - lastRaisedAt < REASK_MS || !
|
|
221
|
+
if (resolverInFlight || now() - lastRaisedAt < REASK_MS || !mergeWaiting(opts.deckDir))
|
|
222
222
|
return;
|
|
223
223
|
const state = readMergeState(opts.deckDir);
|
|
224
224
|
const leave = readLeavePending(opts.deckDir);
|
package/dist/gitRemote.d.ts
CHANGED
|
@@ -36,6 +36,7 @@ export declare function isOnPath(name: string, env?: NodeJS.ProcessEnv, platform
|
|
|
36
36
|
export declare function runGit(args: string[], cwd: string, opts?: {
|
|
37
37
|
env?: NodeJS.ProcessEnv;
|
|
38
38
|
timeoutMs?: number;
|
|
39
|
+
input?: string;
|
|
39
40
|
}): GitResult;
|
|
40
41
|
export declare function cloudKitFor(castleJson: Record<string, unknown> | null): CloudDeckKit;
|
|
41
42
|
export declare const PENDING_INIT_FILE: string;
|
package/dist/gitRemote.js
CHANGED
|
@@ -101,6 +101,7 @@ export function runGit(args, cwd, opts = {}) {
|
|
|
101
101
|
env: { ...(opts.env ?? process.env), LC_ALL: 'C', LANGUAGE: 'C' },
|
|
102
102
|
timeout: opts.timeoutMs,
|
|
103
103
|
maxBuffer: 64 * 1024 * 1024,
|
|
104
|
+
...(opts.input !== undefined ? { input: opts.input } : {}),
|
|
104
105
|
});
|
|
105
106
|
return {
|
|
106
107
|
status: result.status,
|
package/dist/ide.js
CHANGED
|
@@ -512,9 +512,9 @@ async function handleVersionsList(deckDir, res) {
|
|
|
512
512
|
if (await cloudGitModeAsync(deckDir)) {
|
|
513
513
|
// With git on, the history is the git log and "pending" is git status. The old
|
|
514
514
|
// store's versions stay listed as older versions: readable, never imported.
|
|
515
|
-
const { versions, pending } = await gitVersionHistory(deckDir);
|
|
515
|
+
const { versions, pending, loading } = await gitVersionHistory(deckDir);
|
|
516
516
|
const older = versionSummaries(deckDir).map((v) => ({ ...v, later: false, older: true }));
|
|
517
|
-
return sendJson(res, 200, { git: true, versions: [...versions, ...older], pending });
|
|
517
|
+
return sendJson(res, 200, { git: true, versions: [...versions, ...older], pending, ...(loading ? { loading: true } : {}) });
|
|
518
518
|
}
|
|
519
519
|
// The history and what is outstanding against it, together: the panel shows
|
|
520
520
|
// them as one picture, and two calls could disagree about the moment.
|
package/dist/index.js
CHANGED
|
@@ -172,6 +172,7 @@ function usage() {
|
|
|
172
172
|
castle-web git credential get|store|erase (git's credential helper for git.castle.xyz; git init sets it up)
|
|
173
173
|
castle-web git attach <dir> --remote <url> (cloud sandbox only: makes the deck a clone of its Castle repo)
|
|
174
174
|
castle-web git sync [--dir DIR] (cloud sandbox only: commit, merge the remote's main, push)
|
|
175
|
+
castle-web git rehydrate [--dir DIR] (cloud sandbox only: rebuild git history missing after a cold resume)
|
|
175
176
|
castle-web commit [-m MESSAGE] [--reason turn|task|leave|manual|sync] [--resolve] [paths...] [--dir DIR] (cloud sandbox only)
|
|
176
177
|
castle-web login
|
|
177
178
|
castle-web whoami
|
|
@@ -234,7 +235,7 @@ async function gitCommand() {
|
|
|
234
235
|
process.stdout.write(answer.stdout);
|
|
235
236
|
return;
|
|
236
237
|
}
|
|
237
|
-
if (sub === 'attach' || sub === 'sync') {
|
|
238
|
+
if (sub === 'attach' || sub === 'sync' || sub === 'rehydrate') {
|
|
238
239
|
await cloudGitCommand(sub);
|
|
239
240
|
return;
|
|
240
241
|
}
|
|
@@ -290,7 +291,12 @@ function parseCloudArgs(from, valueFlags, booleanFlags = []) {
|
|
|
290
291
|
}
|
|
291
292
|
async function cloudGitDeps() {
|
|
292
293
|
const cloudGit = await import('./cloudGit.js');
|
|
293
|
-
return {
|
|
294
|
+
return {
|
|
295
|
+
cloudGit,
|
|
296
|
+
deps: cloudGit.defaultCloudGitDeps(() => api.whoAmI(), {
|
|
297
|
+
mirrorState: (deckId, opts) => api.gitMirrorState(deckId, opts.includeBundles, opts.timeoutMs),
|
|
298
|
+
}),
|
|
299
|
+
};
|
|
294
300
|
}
|
|
295
301
|
function reportSync(sync, syncError) {
|
|
296
302
|
if (syncError)
|
|
@@ -313,6 +319,19 @@ function reportSync(sync, syncError) {
|
|
|
313
319
|
async function cloudGitCommand(sub) {
|
|
314
320
|
const { cloudGit, deps } = await cloudGitDeps();
|
|
315
321
|
const { flags, positionals } = parseCloudArgs(2, ['--remote', '--dir']);
|
|
322
|
+
if (sub === 'rehydrate') {
|
|
323
|
+
const dir = positionals[0] ?? flags.get('--dir') ?? '.';
|
|
324
|
+
console.log(`[${new Date().toISOString()}] git rehydrate ${path.resolve(dir)}`);
|
|
325
|
+
try {
|
|
326
|
+
const outcome = await cloudGit.cloudRehydrate(dir, deps);
|
|
327
|
+
console.log(outcome === 'complete' ? 'rehydrate finished: history already complete' : 'rehydrate finished: rebuilt');
|
|
328
|
+
}
|
|
329
|
+
catch (e) {
|
|
330
|
+
console.error(`rehydrate finished: failed: ${e instanceof Error ? e.message : String(e)}`);
|
|
331
|
+
throw e;
|
|
332
|
+
}
|
|
333
|
+
return;
|
|
334
|
+
}
|
|
316
335
|
if (sub === 'attach') {
|
|
317
336
|
const remote = flags.get('--remote');
|
|
318
337
|
const dir = positionals[0] ?? flags.get('--dir');
|
|
@@ -372,7 +391,8 @@ async function gitVersionCommand(name) {
|
|
|
372
391
|
cloudGit.printGitShow(dir, target);
|
|
373
392
|
}
|
|
374
393
|
else if (name === 'restore-version' && target) {
|
|
375
|
-
const
|
|
394
|
+
const { deps } = await cloudGitDeps();
|
|
395
|
+
const outcome = await cloudGit.cloudRestore(dir, target, deps);
|
|
376
396
|
console.log(outcome.sha ? `Restored ${target} as commit ${outcome.sha}` : `Already at ${target}.`);
|
|
377
397
|
reportSync(outcome.sync, outcome.syncError);
|
|
378
398
|
}
|
|
@@ -588,6 +608,7 @@ async function main() {
|
|
|
588
608
|
main().catch((e) => {
|
|
589
609
|
console.error(e instanceof Error ? e.message : String(e));
|
|
590
610
|
// Only the cloud git commands' own errors carry an exit code (2: not enabled here, 3: a
|
|
591
|
-
// merge waiting on the agent); anything else is a plain
|
|
611
|
+
// merge waiting on the agent, 4: git history not available yet); anything else is a plain
|
|
612
|
+
// failure.
|
|
592
613
|
process.exit(e instanceof CloudGitError ? e.exitCode : 1);
|
|
593
614
|
});
|