@foundrykit/cli 2.0.2 → 2.0.3
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/CHANGELOG.md +6 -0
- package/dist/cli.js +94 -34
- package/dist/cli.js.map +1 -1
- package/dist/index.js +94 -34
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/commands/update.ts +107 -36
package/CHANGELOG.md
CHANGED
package/dist/cli.js
CHANGED
|
@@ -1586,35 +1586,55 @@ import inquirer3 from "inquirer";
|
|
|
1586
1586
|
import fs4 from "fs-extra";
|
|
1587
1587
|
import path4 from "path";
|
|
1588
1588
|
function updateCommand() {
|
|
1589
|
-
return new Command4("update").description("Update installed components").argument("[id]", "Component or block ID (omit to update all installed)").option(
|
|
1589
|
+
return new Command4("update").description("Update installed components").argument("[id]", "Component or block ID (omit to update all installed)").option(
|
|
1590
|
+
"-o",
|
|
1591
|
+
"--opt",
|
|
1592
|
+
"interactively select which components to update, showing available upgrades"
|
|
1593
|
+
).option("-f, --force", "bypass cache and fetch fresh data from registry").option("-p, --path <path>", "Custom installation path").action(async (id, options) => {
|
|
1590
1594
|
if (id) {
|
|
1591
1595
|
try {
|
|
1592
1596
|
console.log(chalk5.blue(`\u{1F504} Updating ${id}...`));
|
|
1593
|
-
await addSingleComponent(id, {
|
|
1597
|
+
await addSingleComponent(id, {
|
|
1598
|
+
...options,
|
|
1599
|
+
overwrite: true,
|
|
1600
|
+
force: true
|
|
1601
|
+
});
|
|
1594
1602
|
} catch (error) {
|
|
1595
1603
|
console.error(chalk5.red(`\u274C Failed to update ${id}:`));
|
|
1596
|
-
console.error(
|
|
1604
|
+
console.error(
|
|
1605
|
+
chalk5.red(error instanceof Error ? error.message : String(error))
|
|
1606
|
+
);
|
|
1597
1607
|
process.exit(1);
|
|
1598
1608
|
}
|
|
1599
1609
|
return;
|
|
1600
1610
|
}
|
|
1601
1611
|
const configPath = path4.join(process.cwd(), "foundrykit.config.json");
|
|
1602
1612
|
if (!fs4.existsSync(configPath)) {
|
|
1603
|
-
console.error(
|
|
1613
|
+
console.error(
|
|
1614
|
+
chalk5.red(
|
|
1615
|
+
'\u274C FoundryKit not initialized. Run "foundrykit init" first.'
|
|
1616
|
+
)
|
|
1617
|
+
);
|
|
1604
1618
|
process.exit(1);
|
|
1605
1619
|
}
|
|
1606
1620
|
const config = await fs4.readJson(configPath);
|
|
1607
1621
|
let installed = config.installedComponents ?? {};
|
|
1608
1622
|
let installedIds = Object.keys(installed);
|
|
1609
1623
|
if (installedIds.length === 0) {
|
|
1610
|
-
console.log(
|
|
1624
|
+
console.log(
|
|
1625
|
+
chalk5.gray(
|
|
1626
|
+
"No install tracking found. Scanning filesystem for installed components..."
|
|
1627
|
+
)
|
|
1628
|
+
);
|
|
1611
1629
|
const registry = getRegistry();
|
|
1612
1630
|
let allComponents;
|
|
1613
1631
|
try {
|
|
1614
1632
|
allComponents = await registry.getComponents();
|
|
1615
1633
|
} catch (error) {
|
|
1616
1634
|
console.error(chalk5.red("\u274C Failed to fetch registry:"));
|
|
1617
|
-
console.error(
|
|
1635
|
+
console.error(
|
|
1636
|
+
chalk5.red(error instanceof Error ? error.message : String(error))
|
|
1637
|
+
);
|
|
1618
1638
|
process.exit(1);
|
|
1619
1639
|
}
|
|
1620
1640
|
for (const component of allComponents) {
|
|
@@ -1632,13 +1652,25 @@ function updateCommand() {
|
|
|
1632
1652
|
}
|
|
1633
1653
|
installedIds = Object.keys(installed);
|
|
1634
1654
|
if (installedIds.length === 0) {
|
|
1635
|
-
console.log(
|
|
1655
|
+
console.log(
|
|
1656
|
+
chalk5.yellow(
|
|
1657
|
+
'No installed components found. Use "foundrykit add" to install components.'
|
|
1658
|
+
)
|
|
1659
|
+
);
|
|
1636
1660
|
return;
|
|
1637
1661
|
}
|
|
1638
|
-
console.log(
|
|
1662
|
+
console.log(
|
|
1663
|
+
chalk5.gray(
|
|
1664
|
+
`Found ${installedIds.length} installed component(s) via filesystem scan.`
|
|
1665
|
+
)
|
|
1666
|
+
);
|
|
1639
1667
|
}
|
|
1640
1668
|
if (options.opt) {
|
|
1641
|
-
console.log(
|
|
1669
|
+
console.log(
|
|
1670
|
+
chalk5.blue(
|
|
1671
|
+
`\u{1F50D} Checking for updates across ${installedIds.length} installed component(s)...`
|
|
1672
|
+
)
|
|
1673
|
+
);
|
|
1642
1674
|
const registry = getRegistry();
|
|
1643
1675
|
const withUpdates = [];
|
|
1644
1676
|
const upToDate = [];
|
|
@@ -1650,39 +1682,55 @@ function updateCommand() {
|
|
|
1650
1682
|
const hasUpdate = latestVersion !== null && installedVersion !== null && latestVersion !== installedVersion;
|
|
1651
1683
|
const unknownVersion = installedVersion === null || latestVersion === null;
|
|
1652
1684
|
if (hasUpdate || unknownVersion) {
|
|
1653
|
-
withUpdates.push({
|
|
1685
|
+
withUpdates.push({
|
|
1686
|
+
id: compId,
|
|
1687
|
+
installed: installedVersion,
|
|
1688
|
+
latest: latestVersion
|
|
1689
|
+
});
|
|
1654
1690
|
} else {
|
|
1655
1691
|
upToDate.push(compId);
|
|
1656
1692
|
}
|
|
1657
1693
|
} catch {
|
|
1658
|
-
withUpdates.push({
|
|
1694
|
+
withUpdates.push({
|
|
1695
|
+
id: compId,
|
|
1696
|
+
installed: installed[compId]?.version ?? null,
|
|
1697
|
+
latest: null
|
|
1698
|
+
});
|
|
1659
1699
|
}
|
|
1660
1700
|
}
|
|
1661
1701
|
if (upToDate.length > 0) {
|
|
1662
|
-
console.log(
|
|
1663
|
-
|
|
1702
|
+
console.log(
|
|
1703
|
+
chalk5.gray(`
|
|
1704
|
+
\u2713 Already up to date: ${upToDate.join(", ")}`)
|
|
1705
|
+
);
|
|
1664
1706
|
}
|
|
1665
1707
|
if (withUpdates.length === 0) {
|
|
1666
1708
|
console.log(chalk5.green("\n\u2705 All components are up to date."));
|
|
1667
1709
|
return;
|
|
1668
1710
|
}
|
|
1669
|
-
const choices = withUpdates.map(
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1711
|
+
const choices = withUpdates.map(
|
|
1712
|
+
({ id: compId, installed: inst, latest }) => {
|
|
1713
|
+
let versionLabel;
|
|
1714
|
+
if (inst === null && latest === null) {
|
|
1715
|
+
versionLabel = chalk5.gray("(version unknown)");
|
|
1716
|
+
} else if (latest === null) {
|
|
1717
|
+
versionLabel = chalk5.gray(
|
|
1718
|
+
`(installed: ${inst} \u2014 registry version unknown)`
|
|
1719
|
+
);
|
|
1720
|
+
} else if (inst === null) {
|
|
1721
|
+
versionLabel = chalk5.cyan(
|
|
1722
|
+
`(latest: ${latest} \u2014 install version not tracked)`
|
|
1723
|
+
);
|
|
1724
|
+
} else {
|
|
1725
|
+
versionLabel = chalk5.cyan(`(${inst} \u2192 ${latest})`);
|
|
1726
|
+
}
|
|
1727
|
+
return {
|
|
1728
|
+
name: `${compId} ${versionLabel}`,
|
|
1729
|
+
value: compId,
|
|
1730
|
+
checked: true
|
|
1731
|
+
};
|
|
1679
1732
|
}
|
|
1680
|
-
|
|
1681
|
-
name: `${compId} ${versionLabel}`,
|
|
1682
|
-
value: compId,
|
|
1683
|
-
checked: true
|
|
1684
|
-
};
|
|
1685
|
-
});
|
|
1733
|
+
);
|
|
1686
1734
|
const { selectedIds } = await inquirer3.prompt([
|
|
1687
1735
|
{
|
|
1688
1736
|
type: "checkbox",
|
|
@@ -1698,7 +1746,11 @@ function updateCommand() {
|
|
|
1698
1746
|
}
|
|
1699
1747
|
await runUpdates(selectedIds, options);
|
|
1700
1748
|
} else {
|
|
1701
|
-
console.log(
|
|
1749
|
+
console.log(
|
|
1750
|
+
chalk5.blue(
|
|
1751
|
+
`\u{1F504} Updating all ${installedIds.length} installed component(s)...`
|
|
1752
|
+
)
|
|
1753
|
+
);
|
|
1702
1754
|
await runUpdates(installedIds, options);
|
|
1703
1755
|
}
|
|
1704
1756
|
});
|
|
@@ -1709,10 +1761,16 @@ async function runUpdates(ids, options) {
|
|
|
1709
1761
|
try {
|
|
1710
1762
|
console.log(chalk5.blue(`
|
|
1711
1763
|
\u{1F504} Updating ${compId}...`));
|
|
1712
|
-
await addSingleComponent(compId, {
|
|
1764
|
+
await addSingleComponent(compId, {
|
|
1765
|
+
...options,
|
|
1766
|
+
overwrite: true,
|
|
1767
|
+
force: true
|
|
1768
|
+
});
|
|
1713
1769
|
} catch (error) {
|
|
1714
1770
|
console.error(chalk5.red(`\u274C Failed to update ${compId}:`));
|
|
1715
|
-
console.error(
|
|
1771
|
+
console.error(
|
|
1772
|
+
chalk5.red(error instanceof Error ? error.message : String(error))
|
|
1773
|
+
);
|
|
1716
1774
|
failed++;
|
|
1717
1775
|
}
|
|
1718
1776
|
}
|
|
@@ -1721,8 +1779,10 @@ async function runUpdates(ids, options) {
|
|
|
1721
1779
|
\u26A0 ${failed} component(s) failed to update.`));
|
|
1722
1780
|
process.exit(1);
|
|
1723
1781
|
} else {
|
|
1724
|
-
console.log(
|
|
1725
|
-
|
|
1782
|
+
console.log(
|
|
1783
|
+
chalk5.green(`
|
|
1784
|
+
\u2705 ${ids.length} component(s) updated successfully!`)
|
|
1785
|
+
);
|
|
1726
1786
|
}
|
|
1727
1787
|
}
|
|
1728
1788
|
|