@foundrykit/cli 1.0.8 → 1.0.9

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 CHANGED
@@ -1,5 +1,13 @@
1
1
  # @foundrykit/cli
2
2
 
3
+ ## 1.0.9
4
+
5
+ ### Patch Changes
6
+
7
+ - Update to config version management and config paths
8
+ - Updated dependencies
9
+ - @foundrykit/types@1.0.5
10
+
3
11
  ## 1.0.8
4
12
 
5
13
  ### Patch Changes
package/dist/cli.js CHANGED
@@ -14,6 +14,14 @@ import path from "path";
14
14
  import inquirer from "inquirer";
15
15
  import { exec } from "child_process";
16
16
  import { promisify } from "util";
17
+
18
+ // src/lib/constants.ts
19
+ var CLI_VERSION = "1.0.8";
20
+ var DEFAULT_REGISTRY_URL = "https://foundry.umiflow.com";
21
+ var CACHE_TTL = 24 * 60 * 60 * 1e3;
22
+ var CACHE_DIR = ".foundrykit";
23
+
24
+ // src/commands/init.ts
17
25
  function initCommand() {
18
26
  return new Command("init").description("Initialize FoundryKit in your project").option("-f, --force", "overwrite existing files").option("--skip-install", "skip installing dependencies").option("--skip-prompts", "use default paths without prompting").action(async (options) => {
19
27
  try {
@@ -628,8 +636,8 @@ async function createConfigFile(options, structure, pathConfig) {
628
636
  return;
629
637
  }
630
638
  const config = {
631
- version: "1.0.0",
632
- registry: "https://foundry.umiflow.com",
639
+ version: CLI_VERSION,
640
+ registry: DEFAULT_REGISTRY_URL,
633
641
  paths: {
634
642
  utils: pathConfig.utils,
635
643
  primitives: pathConfig.primitives,
@@ -684,10 +692,9 @@ import path2 from "path";
684
692
  import os from "os";
685
693
  import chalk2 from "chalk";
686
694
  var DEFAULT_CONFIG = {
687
- registryUrl: process.env.FOUNDRYKIT_REGISTRY_URL || "https://foundry.umiflow.com",
688
- cacheDir: path2.join(os.homedir(), ".foundrykit", "cache"),
689
- cacheMaxAge: 1e3 * 60 * 60 * 24
690
- // 24 hours
695
+ registryUrl: process.env.FOUNDRYKIT_REGISTRY_URL || DEFAULT_REGISTRY_URL,
696
+ cacheDir: path2.join(os.homedir(), CACHE_DIR, "cache"),
697
+ cacheMaxAge: CACHE_TTL
691
698
  };
692
699
  var RegistryService = class {
693
700
  config;
@@ -1138,6 +1145,16 @@ async function addSingleComponent(id, options) {
1138
1145
  throw error;
1139
1146
  }
1140
1147
  }
1148
+ async function updateConfigVersion() {
1149
+ const configPath = path3.join(process.cwd(), "foundrykit.config.json");
1150
+ if (fs3.existsSync(configPath)) {
1151
+ const config = await fs3.readJson(configPath);
1152
+ if (config.version !== CLI_VERSION) {
1153
+ config.version = CLI_VERSION;
1154
+ await fs3.writeJson(configPath, config, { spaces: 2 });
1155
+ }
1156
+ }
1157
+ }
1141
1158
  async function validateProject2() {
1142
1159
  const packageJsonPath = path3.join(process.cwd(), "package.json");
1143
1160
  if (!fs3.existsSync(packageJsonPath)) {
@@ -1149,6 +1166,7 @@ async function validateProject2() {
1149
1166
  if (!fs3.existsSync(configPath)) {
1150
1167
  throw new Error('FoundryKit not initialized. Run "foundrykit init" first.');
1151
1168
  }
1169
+ await updateConfigVersion();
1152
1170
  }
1153
1171
  async function hasConflictingFiles(componentData, options) {
1154
1172
  const config = await loadConfig();
@@ -1194,9 +1212,11 @@ async function installComponentFiles(componentData, options) {
1194
1212
  );
1195
1213
  continue;
1196
1214
  }
1197
- await fs3.writeFile(filePath, file.content);
1198
- console.log(chalk4.green(` \u2713 ${resolvedPath}`));
1215
+ const transformedContent = transformImportsForConfig(file.content, config);
1216
+ await fs3.writeFile(filePath, transformedContent);
1217
+ console.log(chalk4.gray(` \u2713 Created ${resolvedPath}`));
1199
1218
  }
1219
+ await updateConfigVersion();
1200
1220
  }
1201
1221
  async function handlePackageDependencies(componentData) {
1202
1222
  const allDependencies = /* @__PURE__ */ new Set();
@@ -1278,6 +1298,36 @@ async function loadConfig() {
1278
1298
  }
1279
1299
  return fs3.readJson(configPath);
1280
1300
  }
1301
+ function transformImportsForConfig(content, config) {
1302
+ let transformed = content;
1303
+ const primitivesPath = config.paths.primitives.replace(/^\.\//, "").replace(/\/$/, "");
1304
+ transformed = transformed.replace(
1305
+ /@\/components\/primitives/g,
1306
+ `@/${primitivesPath}`
1307
+ );
1308
+ transformed = transformed.replace(
1309
+ /@\/components\/ui/g,
1310
+ `@/${primitivesPath}`
1311
+ );
1312
+ const componentsPath = config.paths.components.replace(/^\.\//, "").replace(/\/$/, "");
1313
+ transformed = transformed.replace(
1314
+ /@\/components\/components/g,
1315
+ `@/${componentsPath}`
1316
+ );
1317
+ const blocksPath = config.paths.blocks.replace(/^\.\//, "").replace(/\/$/, "");
1318
+ transformed = transformed.replace(
1319
+ /@\/components\/blocks/g,
1320
+ `@/${blocksPath}`
1321
+ );
1322
+ const animationsPath = config.paths.animations.replace(/^\.\//, "").replace(/\/$/, "");
1323
+ transformed = transformed.replace(
1324
+ /@\/components\/animations/g,
1325
+ `@/${animationsPath}`
1326
+ );
1327
+ const utilsPath = config.paths.utils.replace(/^\.\//, "").replace(/\/$/, "").replace(/\.(ts|js)$/, "");
1328
+ transformed = transformed.replace(/@\/lib\/utils/g, `@/${utilsPath}`);
1329
+ return transformed;
1330
+ }
1281
1331
  function resolveComponentPath(originalPath, category, config) {
1282
1332
  if (originalPath === "lib/utils.ts") {
1283
1333
  return config.paths.utils || "lib/utils.ts";
@@ -1288,12 +1338,7 @@ function resolveComponentPath(originalPath, category, config) {
1288
1338
  if (category === "primitives") {
1289
1339
  return path3.join(categoryPath, componentName, fileName);
1290
1340
  } else if (category === "components") {
1291
- return path3.join(
1292
- config.paths.components,
1293
- "components",
1294
- componentName,
1295
- fileName
1296
- );
1341
+ return path3.join(config.paths.components, componentName, fileName);
1297
1342
  } else if (category === "blocks") {
1298
1343
  return path3.join(
1299
1344
  config.paths.blocks || path3.join(config.paths.components, "blocks"),
@@ -1310,16 +1355,19 @@ function resolveComponentPath(originalPath, category, config) {
1310
1355
  return originalPath;
1311
1356
  }
1312
1357
  function getImportPath(componentData, config) {
1313
- const aliases = config.aliases || {};
1314
1358
  const componentName = path3.basename(componentData.files[0].path, ".tsx");
1315
1359
  if (componentData.category === "primitives") {
1316
- return `@/components/ui/${componentName}`;
1360
+ const primitivesPath = config.paths.primitives.replace(/^\.\//, "").replace(/\/$/, "");
1361
+ return `@/${primitivesPath}/${componentName}`;
1317
1362
  } else if (componentData.category === "components") {
1318
- return `@/components/components/${componentName}`;
1363
+ const componentsPath = config.paths.components.replace(/^\.\//, "").replace(/\/$/, "");
1364
+ return `@/${componentsPath}/${componentName}`;
1319
1365
  } else if (componentData.category === "blocks") {
1320
- return `@/components/blocks/${componentName}`;
1366
+ const blocksPath = config.paths.blocks.replace(/^\.\//, "").replace(/\/$/, "");
1367
+ return `@/${blocksPath}/${componentName}`;
1321
1368
  } else if (componentData.category === "animations") {
1322
- return `@/components/animations/${componentName}`;
1369
+ const animationsPath = config.paths.animations.replace(/^\.\//, "").replace(/\/$/, "");
1370
+ return `@/${animationsPath}/${componentName}`;
1323
1371
  }
1324
1372
  return `@/components/${componentName}`;
1325
1373
  }