@ghl-ai/aw 0.1.63 → 0.1.64
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/commands/push.mjs +44 -12
- package/package.json +1 -1
package/commands/push.mjs
CHANGED
|
@@ -307,16 +307,6 @@ function resolveAwDocsPublishConfig(projectRoot) {
|
|
|
307
307
|
};
|
|
308
308
|
}
|
|
309
309
|
|
|
310
|
-
function isOnlyUntrackedAwSymlink(status, cloneDir) {
|
|
311
|
-
const lines = status.trim().split('\n').filter(Boolean);
|
|
312
|
-
if (lines.length !== 1 || !/^\?\?\s+\.aw\/?$/.test(lines[0])) return false;
|
|
313
|
-
try {
|
|
314
|
-
return lstatSync(join(cloneDir, '.aw')).isSymbolicLink();
|
|
315
|
-
} catch {
|
|
316
|
-
return false;
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
|
|
320
310
|
async function removeTrackedAwSymlink(cloneDir) {
|
|
321
311
|
try {
|
|
322
312
|
if (!lstatSync(join(cloneDir, '.aw')).isSymbolicLink()) return false;
|
|
@@ -340,6 +330,49 @@ async function removeTrackedAwSymlink(cloneDir) {
|
|
|
340
330
|
return true;
|
|
341
331
|
}
|
|
342
332
|
|
|
333
|
+
function parseStatusPaths(status) {
|
|
334
|
+
return status
|
|
335
|
+
.split('\n')
|
|
336
|
+
.filter(line => line.trim())
|
|
337
|
+
.flatMap(line => line.slice(3).trim().split(' -> '));
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
function isManagedAwCachePath(path) {
|
|
341
|
+
return path === '.aw' || path.startsWith('.aw/');
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
function isOnlyManagedAwCacheDirtiness(status) {
|
|
345
|
+
const paths = parseStatusPaths(status);
|
|
346
|
+
return paths.length > 0 && paths.every(isManagedAwCachePath);
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
async function hasTrackedAwCachePaths(cloneDir) {
|
|
350
|
+
const { stdout } = await execFile('git', ['ls-files', '--', '.aw'], {
|
|
351
|
+
cwd: cloneDir,
|
|
352
|
+
encoding: 'utf8',
|
|
353
|
+
});
|
|
354
|
+
return stdout.trim().length > 0;
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
async function selfHealManagedAwCacheDirtiness(cloneDir, status) {
|
|
358
|
+
if (!isOnlyManagedAwCacheDirtiness(status)) return false;
|
|
359
|
+
|
|
360
|
+
rmSync(join(cloneDir, '.aw'), { recursive: true, force: true });
|
|
361
|
+
await execFile('git', ['clean', '-fd', '--', '.aw'], {
|
|
362
|
+
cwd: cloneDir,
|
|
363
|
+
encoding: 'utf8',
|
|
364
|
+
});
|
|
365
|
+
|
|
366
|
+
if (await hasTrackedAwCachePaths(cloneDir)) {
|
|
367
|
+
await execFile('git', ['restore', '--staged', '--worktree', '--', '.aw'], {
|
|
368
|
+
cwd: cloneDir,
|
|
369
|
+
encoding: 'utf8',
|
|
370
|
+
});
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
return true;
|
|
374
|
+
}
|
|
375
|
+
|
|
343
376
|
async function getGitStatus(repoDir) {
|
|
344
377
|
const { stdout } = await execFile('git', ['status', '--porcelain'], {
|
|
345
378
|
cwd: repoDir,
|
|
@@ -397,8 +430,7 @@ async function ensureAwDocsRepoClone(home, publishConfig) {
|
|
|
397
430
|
}
|
|
398
431
|
|
|
399
432
|
let status = await getGitStatus(cloneDir);
|
|
400
|
-
if (status.trim() &&
|
|
401
|
-
rmSync(join(cloneDir, '.aw'), { force: true });
|
|
433
|
+
if (status.trim() && await selfHealManagedAwCacheDirtiness(cloneDir, status)) {
|
|
402
434
|
status = await getGitStatus(cloneDir);
|
|
403
435
|
}
|
|
404
436
|
if (status.trim()) {
|