@fluid-app/fluid-cli-theme-dev 0.1.23 → 0.1.25
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/index.mjs +52 -48
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
package/dist/index.mjs
CHANGED
|
@@ -2370,7 +2370,32 @@ function createNavigateCommand() {
|
|
|
2370
2370
|
});
|
|
2371
2371
|
}
|
|
2372
2372
|
//#endregion
|
|
2373
|
-
//#region src/
|
|
2373
|
+
//#region src/skills/install.ts
|
|
2374
|
+
function listSkillNames(skillsDir) {
|
|
2375
|
+
if (!existsSync(skillsDir)) return [];
|
|
2376
|
+
return readdirSync(skillsDir, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => entry.name).filter((name) => existsSync(join(skillsDir, name, "SKILL.md"))).sort();
|
|
2377
|
+
}
|
|
2378
|
+
async function installSkills(options) {
|
|
2379
|
+
const { sourceDir, targetRoot, force, confirmOverwrite, onLeftover } = options;
|
|
2380
|
+
const installed = [];
|
|
2381
|
+
const skipped = [];
|
|
2382
|
+
mkdirSync(targetRoot, { recursive: true });
|
|
2383
|
+
for (const name of listSkillNames(sourceDir)) {
|
|
2384
|
+
const from = join(sourceDir, name);
|
|
2385
|
+
const to = join(targetRoot, name);
|
|
2386
|
+
if (existsSync(to) && !force && !await confirmOverwrite(name)) {
|
|
2387
|
+
skipped.push(name);
|
|
2388
|
+
continue;
|
|
2389
|
+
}
|
|
2390
|
+
const leftover = replaceDirectory(from, to);
|
|
2391
|
+
if (leftover !== null) onLeftover(leftover);
|
|
2392
|
+
installed.push(name);
|
|
2393
|
+
}
|
|
2394
|
+
return {
|
|
2395
|
+
installed,
|
|
2396
|
+
skipped
|
|
2397
|
+
};
|
|
2398
|
+
}
|
|
2374
2399
|
/**
|
|
2375
2400
|
* Replace `target` with a fresh copy of `source` without ever leaving `target`
|
|
2376
2401
|
* missing or partially written.
|
|
@@ -2388,49 +2413,39 @@ function createNavigateCommand() {
|
|
|
2388
2413
|
*
|
|
2389
2414
|
* Not safe against a second process racing on the same `target`; intended for
|
|
2390
2415
|
* single-process CLI use.
|
|
2416
|
+
*
|
|
2417
|
+
* @returns the path of a leftover backup directory that could not be removed
|
|
2418
|
+
* after an otherwise-successful replace (the previous contents are retained
|
|
2419
|
+
* there for manual cleanup), or `null` when nothing was left behind. The caller
|
|
2420
|
+
* should surface a non-null result so the leftover isn't silently hidden.
|
|
2391
2421
|
*/
|
|
2392
2422
|
function replaceDirectory(source, target) {
|
|
2393
2423
|
const staging = reserveSiblingPath(target, "staging");
|
|
2394
2424
|
try {
|
|
2395
2425
|
cpSync(source, staging, { recursive: true });
|
|
2396
2426
|
} catch (error) {
|
|
2397
|
-
|
|
2398
|
-
recursive: true,
|
|
2399
|
-
force: true
|
|
2400
|
-
});
|
|
2427
|
+
removeQuietly(staging);
|
|
2401
2428
|
throw error;
|
|
2402
2429
|
}
|
|
2403
|
-
if (!existsSync(target))
|
|
2404
|
-
swapIntoPlace(staging, target, null);
|
|
2405
|
-
return;
|
|
2406
|
-
}
|
|
2430
|
+
if (!existsSync(target)) return swapIntoPlace(staging, target, null);
|
|
2407
2431
|
const backup = reserveSiblingPath(target, "backup");
|
|
2408
2432
|
try {
|
|
2409
2433
|
renameSync(target, backup);
|
|
2410
2434
|
} catch (error) {
|
|
2411
|
-
|
|
2412
|
-
recursive: true,
|
|
2413
|
-
force: true
|
|
2414
|
-
});
|
|
2435
|
+
removeQuietly(staging);
|
|
2415
2436
|
throw error;
|
|
2416
2437
|
}
|
|
2417
|
-
swapIntoPlace(staging, target, backup);
|
|
2438
|
+
return swapIntoPlace(staging, target, backup);
|
|
2418
2439
|
}
|
|
2419
2440
|
function swapIntoPlace(staging, target, backup) {
|
|
2420
2441
|
try {
|
|
2421
2442
|
renameSync(staging, target);
|
|
2422
2443
|
} catch (error) {
|
|
2423
|
-
rmSync(staging, {
|
|
2424
|
-
recursive: true,
|
|
2425
|
-
force: true
|
|
2426
|
-
});
|
|
2427
2444
|
if (backup !== null) restoreBackup(backup, target, error);
|
|
2445
|
+
removeQuietly(staging);
|
|
2428
2446
|
throw error;
|
|
2429
2447
|
}
|
|
2430
|
-
|
|
2431
|
-
recursive: true,
|
|
2432
|
-
force: true
|
|
2433
|
-
});
|
|
2448
|
+
return removeQuietly(backup);
|
|
2434
2449
|
}
|
|
2435
2450
|
function restoreBackup(backup, target, cause) {
|
|
2436
2451
|
try {
|
|
@@ -2439,38 +2454,24 @@ function restoreBackup(backup, target, cause) {
|
|
|
2439
2454
|
throw new Error(`Failed to replace ${target}; its previous contents are preserved at ${backup}.`, { cause });
|
|
2440
2455
|
}
|
|
2441
2456
|
}
|
|
2457
|
+
function removeQuietly(path) {
|
|
2458
|
+
if (path === null) return null;
|
|
2459
|
+
try {
|
|
2460
|
+
rmSync(path, {
|
|
2461
|
+
recursive: true,
|
|
2462
|
+
force: true
|
|
2463
|
+
});
|
|
2464
|
+
return null;
|
|
2465
|
+
} catch {
|
|
2466
|
+
return path;
|
|
2467
|
+
}
|
|
2468
|
+
}
|
|
2442
2469
|
function reserveSiblingPath(basePath, label) {
|
|
2443
2470
|
let candidate = `${basePath}.${label}`;
|
|
2444
2471
|
for (let n = 1; existsSync(candidate); n += 1) candidate = `${basePath}.${label}.${n}`;
|
|
2445
2472
|
return candidate;
|
|
2446
2473
|
}
|
|
2447
2474
|
//#endregion
|
|
2448
|
-
//#region src/skills/install.ts
|
|
2449
|
-
function listSkillNames(skillsDir) {
|
|
2450
|
-
if (!existsSync(skillsDir)) return [];
|
|
2451
|
-
return readdirSync(skillsDir, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => entry.name).filter((name) => existsSync(join(skillsDir, name, "SKILL.md"))).sort();
|
|
2452
|
-
}
|
|
2453
|
-
async function installSkills(options) {
|
|
2454
|
-
const { sourceDir, targetRoot, force, confirmOverwrite } = options;
|
|
2455
|
-
const installed = [];
|
|
2456
|
-
const skipped = [];
|
|
2457
|
-
mkdirSync(targetRoot, { recursive: true });
|
|
2458
|
-
for (const name of listSkillNames(sourceDir)) {
|
|
2459
|
-
const from = join(sourceDir, name);
|
|
2460
|
-
const to = join(targetRoot, name);
|
|
2461
|
-
if (existsSync(to) && !force && !await confirmOverwrite(name)) {
|
|
2462
|
-
skipped.push(name);
|
|
2463
|
-
continue;
|
|
2464
|
-
}
|
|
2465
|
-
replaceDirectory(from, to);
|
|
2466
|
-
installed.push(name);
|
|
2467
|
-
}
|
|
2468
|
-
return {
|
|
2469
|
-
installed,
|
|
2470
|
-
skipped
|
|
2471
|
-
};
|
|
2472
|
-
}
|
|
2473
|
-
//#endregion
|
|
2474
2475
|
//#region src/commands/skills.ts
|
|
2475
2476
|
const DEFAULT_TARGET_DIR = ".agents/skills";
|
|
2476
2477
|
function resolveBundledSkillsDir() {
|
|
@@ -2510,6 +2511,9 @@ function createSkillsCommand() {
|
|
|
2510
2511
|
initial: false
|
|
2511
2512
|
}, { onCancel: () => process.exit(130) });
|
|
2512
2513
|
return Boolean(res.overwrite);
|
|
2514
|
+
},
|
|
2515
|
+
onLeftover: (path) => {
|
|
2516
|
+
console.log(`${chalk.yellow("⚠")} kept the previous copy at ${path} (couldn't remove it — delete it manually)`);
|
|
2513
2517
|
}
|
|
2514
2518
|
});
|
|
2515
2519
|
for (const name of installed) console.log(`${chalk.green("✓")} ${name} → ${join(opts.dir, name)}`);
|