@foundrykit/cli 1.0.16 → 1.1.0
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/.turbo/turbo-build.log +20 -0
- package/.turbo/turbo-test.log +42 -0
- package/.turbo/turbo-type-check.log +4 -0
- package/CHANGELOG.md +6 -0
- package/README.md +29 -311
- package/dist/cli.js +105 -10
- package/dist/cli.js.map +1 -1
- package/dist/index.js +105 -10
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/src/commands/add.ts +17 -13
- package/src/commands/doctor.ts +117 -1
- package/src/commands/update.ts +20 -3
- package/src/lib/constants.ts +1 -1
- package/src/lib/registry.ts +19 -6
- package/tests/dependency-resolution.test.ts +9 -9
package/dist/index.js
CHANGED
|
@@ -16,7 +16,7 @@ import { exec } from "child_process";
|
|
|
16
16
|
import { promisify } from "util";
|
|
17
17
|
|
|
18
18
|
// src/lib/constants.ts
|
|
19
|
-
var CLI_VERSION = "1.0.
|
|
19
|
+
var CLI_VERSION = "1.0.16";
|
|
20
20
|
var DEFAULT_REGISTRY_URL = "https://foundry.umiflow.com";
|
|
21
21
|
var CACHE_TTL = 24 * 60 * 60 * 1e3;
|
|
22
22
|
var CACHE_DIR = ".foundrykit";
|
|
@@ -760,6 +760,13 @@ Try again later or check your internet connection.`
|
|
|
760
760
|
if (this.isSpecialDependency(id)) {
|
|
761
761
|
return this.createSpecialDependency(id);
|
|
762
762
|
}
|
|
763
|
+
const cache = await this.loadCache();
|
|
764
|
+
const cachedComponent = cache?.componentData?.[id];
|
|
765
|
+
const hasValidCache = cache ? this.isCacheValid(cache) : false;
|
|
766
|
+
if (cachedComponent && hasValidCache) {
|
|
767
|
+
console.log(chalk2.gray(`Using cached data for component: ${id}`));
|
|
768
|
+
return cachedComponent;
|
|
769
|
+
}
|
|
763
770
|
try {
|
|
764
771
|
const url = `${this.config.registryUrl}/registry/${id}`;
|
|
765
772
|
console.log(chalk2.gray(`Fetching component: ${url}`));
|
|
@@ -776,10 +783,9 @@ Try again later or check your internet connection.`
|
|
|
776
783
|
await this.cacheComponent(component);
|
|
777
784
|
return component;
|
|
778
785
|
} catch (error) {
|
|
779
|
-
|
|
780
|
-
if (cache?.componentData?.[id]) {
|
|
786
|
+
if (cachedComponent) {
|
|
781
787
|
console.log(chalk2.yellow(`Using cached data for component: ${id}`));
|
|
782
|
-
return
|
|
788
|
+
return cachedComponent;
|
|
783
789
|
}
|
|
784
790
|
throw new Error(
|
|
785
791
|
`Failed to fetch component "${id}": ${error instanceof Error ? error.message : "Unknown error"}
|
|
@@ -913,10 +919,15 @@ export function cn(...inputs: ClassValue[]) {
|
|
|
913
919
|
*/
|
|
914
920
|
async cacheComponent(component) {
|
|
915
921
|
try {
|
|
916
|
-
const cache = await this.loadCache()
|
|
917
|
-
|
|
922
|
+
const cache = await this.loadCache() ?? {
|
|
923
|
+
version: "1.0.0",
|
|
924
|
+
lastUpdated: (/* @__PURE__ */ new Date()).toISOString(),
|
|
925
|
+
components: [],
|
|
926
|
+
componentData: {}
|
|
927
|
+
};
|
|
918
928
|
cache.componentData[component.id] = component;
|
|
919
929
|
cache.lastUpdated = (/* @__PURE__ */ new Date()).toISOString();
|
|
930
|
+
await fs2.ensureDir(this.config.cacheDir);
|
|
920
931
|
await fs2.writeJson(this.cacheFile, cache, { spaces: 2 });
|
|
921
932
|
} catch (error) {
|
|
922
933
|
console.log(chalk2.gray("Failed to cache component"));
|
|
@@ -1559,19 +1570,103 @@ function getImportPath(componentData, config) {
|
|
|
1559
1570
|
import { Command as Command4 } from "commander";
|
|
1560
1571
|
import chalk5 from "chalk";
|
|
1561
1572
|
function updateCommand() {
|
|
1562
|
-
return new Command4("update").description("Update an existing component or block").argument("<id>", "Component or block ID").action(async (id) => {
|
|
1563
|
-
|
|
1564
|
-
|
|
1573
|
+
return new Command4("update").description("Update an existing component or block").argument("<id>", "Component or block ID").option("-p, --path <path>", "Custom installation path").action(async (id, options) => {
|
|
1574
|
+
try {
|
|
1575
|
+
console.log(chalk5.blue(`\u{1F504} Updating ${id}...`));
|
|
1576
|
+
await addSingleComponent(id, {
|
|
1577
|
+
...options,
|
|
1578
|
+
overwrite: true
|
|
1579
|
+
});
|
|
1580
|
+
} catch (error) {
|
|
1581
|
+
console.error(chalk5.red(`\u274C Failed to update ${id}:`));
|
|
1582
|
+
console.error(
|
|
1583
|
+
chalk5.red(error instanceof Error ? error.message : String(error))
|
|
1584
|
+
);
|
|
1585
|
+
process.exit(1);
|
|
1586
|
+
}
|
|
1565
1587
|
});
|
|
1566
1588
|
}
|
|
1567
1589
|
|
|
1568
1590
|
// src/commands/doctor.ts
|
|
1569
1591
|
import { Command as Command5 } from "commander";
|
|
1570
1592
|
import chalk6 from "chalk";
|
|
1593
|
+
import fs4 from "fs-extra";
|
|
1594
|
+
import path4 from "path";
|
|
1571
1595
|
function doctorCommand() {
|
|
1572
1596
|
return new Command5("doctor").description("Check project health and configuration").action(async () => {
|
|
1573
1597
|
console.log(chalk6.blue("\u{1F50D} Checking project health..."));
|
|
1574
|
-
|
|
1598
|
+
const results = [];
|
|
1599
|
+
const packageJsonPath = path4.join(process.cwd(), "package.json");
|
|
1600
|
+
const hasPackageJson = await fs4.pathExists(packageJsonPath);
|
|
1601
|
+
results.push({
|
|
1602
|
+
label: "package.json",
|
|
1603
|
+
ok: hasPackageJson,
|
|
1604
|
+
detail: hasPackageJson ? "Project manifest found" : "Run this command in a project root"
|
|
1605
|
+
});
|
|
1606
|
+
let packageJson2 = null;
|
|
1607
|
+
if (hasPackageJson) {
|
|
1608
|
+
packageJson2 = await fs4.readJson(packageJsonPath);
|
|
1609
|
+
}
|
|
1610
|
+
const hasNext = !!packageJson2 && !!(packageJson2.dependencies?.next || packageJson2.devDependencies?.next);
|
|
1611
|
+
results.push({
|
|
1612
|
+
label: "Framework",
|
|
1613
|
+
ok: hasNext,
|
|
1614
|
+
detail: hasNext ? "Next.js dependency detected" : "FoundryKit currently expects a Next.js project"
|
|
1615
|
+
});
|
|
1616
|
+
const configPath = path4.join(process.cwd(), "foundrykit.config.json");
|
|
1617
|
+
const hasConfig = await fs4.pathExists(configPath);
|
|
1618
|
+
results.push({
|
|
1619
|
+
label: "FoundryKit config",
|
|
1620
|
+
ok: hasConfig,
|
|
1621
|
+
detail: hasConfig ? "foundrykit.config.json found" : 'Run "foundrykit init" to create the configuration file'
|
|
1622
|
+
});
|
|
1623
|
+
let config = null;
|
|
1624
|
+
if (hasConfig) {
|
|
1625
|
+
try {
|
|
1626
|
+
config = await loadConfig();
|
|
1627
|
+
const hasRequiredPaths = !!config.paths?.utils && !!config.paths?.primitives && !!config.paths?.components && !!config.paths?.blocks && !!config.paths?.animations;
|
|
1628
|
+
results.push({
|
|
1629
|
+
label: "Config shape",
|
|
1630
|
+
ok: hasRequiredPaths,
|
|
1631
|
+
detail: hasRequiredPaths ? "Required install paths are configured" : "Configuration is missing one or more required install paths"
|
|
1632
|
+
});
|
|
1633
|
+
const registryUrl = config.registry || DEFAULT_REGISTRY_URL;
|
|
1634
|
+
try {
|
|
1635
|
+
const response = await fetch(`${registryUrl}/registry`, {
|
|
1636
|
+
headers: { Accept: "application/json" }
|
|
1637
|
+
});
|
|
1638
|
+
results.push({
|
|
1639
|
+
label: "Registry",
|
|
1640
|
+
ok: response.ok,
|
|
1641
|
+
detail: response.ok ? `Registry reachable at ${registryUrl}` : `Registry returned ${response.status} ${response.statusText}`
|
|
1642
|
+
});
|
|
1643
|
+
} catch (error) {
|
|
1644
|
+
results.push({
|
|
1645
|
+
label: "Registry",
|
|
1646
|
+
ok: false,
|
|
1647
|
+
detail: `Unable to reach ${registryUrl}: ${error instanceof Error ? error.message : "Unknown error"}`
|
|
1648
|
+
});
|
|
1649
|
+
}
|
|
1650
|
+
} catch (error) {
|
|
1651
|
+
results.push({
|
|
1652
|
+
label: "Config shape",
|
|
1653
|
+
ok: false,
|
|
1654
|
+
detail: `Failed to read foundrykit.config.json: ${error instanceof Error ? error.message : "Unknown error"}`
|
|
1655
|
+
});
|
|
1656
|
+
}
|
|
1657
|
+
}
|
|
1658
|
+
for (const result of results) {
|
|
1659
|
+
const icon = result.ok ? chalk6.green("\u2705") : chalk6.red("\u274C");
|
|
1660
|
+
console.log(`${icon} ${result.label}: ${result.detail}`);
|
|
1661
|
+
}
|
|
1662
|
+
const hasFailures = results.some((result) => !result.ok);
|
|
1663
|
+
if (hasFailures) {
|
|
1664
|
+
console.log(
|
|
1665
|
+
chalk6.yellow("\n\u26A0\uFE0F Found issues that should be resolved before continuing.")
|
|
1666
|
+
);
|
|
1667
|
+
process.exit(1);
|
|
1668
|
+
}
|
|
1669
|
+
console.log(chalk6.green("\n\u2705 All checks passed!"));
|
|
1575
1670
|
});
|
|
1576
1671
|
}
|
|
1577
1672
|
|