@geekmidas/cli 1.10.34 → 1.10.35

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,11 @@
1
1
  # @geekmidas/cli
2
2
 
3
+ ## 1.10.35
4
+
5
+ ### Patch Changes
6
+
7
+ - ✨ [`b1de1e0`](https://github.com/geekmidas/toolbox/commit/b1de1e01e1181ea5c3edcf7e23dcf3a5128fc0f3) Thanks [@geekmidas](https://github.com/geekmidas)! - Add different framework support
8
+
3
9
  ## 1.10.34
4
10
 
5
11
  ### Patch Changes
package/dist/index.cjs CHANGED
@@ -35,7 +35,7 @@ const prompts = require_chunk.__toESM(require("prompts"));
35
35
 
36
36
  //#region package.json
37
37
  var name = "@geekmidas/cli";
38
- var version = "1.10.33";
38
+ var version = "1.10.34";
39
39
  var description = "CLI tools for building Lambda handlers, server applications, and generating OpenAPI specs";
40
40
  var private$1 = false;
41
41
  var type = "module";
@@ -1453,38 +1453,111 @@ function checkPortConflicts(workspace) {
1453
1453
  }
1454
1454
  return conflicts;
1455
1455
  }
1456
+ const FRONTEND_FRAMEWORKS = {
1457
+ nextjs: {
1458
+ displayName: "Next.js",
1459
+ configFiles: [
1460
+ "next.config.js",
1461
+ "next.config.ts",
1462
+ "next.config.mjs",
1463
+ "next.config.cjs"
1464
+ ],
1465
+ dependency: "next",
1466
+ installCommand: "pnpm add next react react-dom"
1467
+ },
1468
+ remix: {
1469
+ displayName: "Remix",
1470
+ configFiles: [
1471
+ "remix.config.js",
1472
+ "remix.config.mjs",
1473
+ "remix.config.ts",
1474
+ "vite.config.js",
1475
+ "vite.config.ts",
1476
+ "vite.config.mjs",
1477
+ "vite.config.cjs"
1478
+ ],
1479
+ dependency: "@remix-run/dev",
1480
+ installCommand: "pnpm add -D @remix-run/dev"
1481
+ },
1482
+ vite: {
1483
+ displayName: "Vite",
1484
+ configFiles: [
1485
+ "vite.config.js",
1486
+ "vite.config.ts",
1487
+ "vite.config.mjs",
1488
+ "vite.config.cjs"
1489
+ ],
1490
+ dependency: "vite",
1491
+ installCommand: "pnpm add -D vite"
1492
+ }
1493
+ };
1456
1494
  /**
1457
- * Next.js config file patterns to check.
1495
+ * Auto-detect the frontend framework by scanning package.json deps and config
1496
+ * files. Dependency match wins over config file match because deps are more
1497
+ * distinctive (a Remix app has both vite.config.ts AND @remix-run/dev).
1458
1498
  */
1459
- const NEXTJS_CONFIG_FILES = [
1460
- "next.config.js",
1461
- "next.config.ts",
1462
- "next.config.mjs"
1463
- ];
1499
+ function detectFrontendFramework(fullPath, deps) {
1500
+ const order = [
1501
+ "nextjs",
1502
+ "remix",
1503
+ "vite"
1504
+ ];
1505
+ for (const name$1 of order) if (deps[FRONTEND_FRAMEWORKS[name$1].dependency]) return name$1;
1506
+ for (const name$1 of order) {
1507
+ const hasConfig = FRONTEND_FRAMEWORKS[name$1].configFiles.some((file) => (0, node_fs.existsSync)((0, node_path.join)(fullPath, file)));
1508
+ if (hasConfig) return name$1;
1509
+ }
1510
+ return void 0;
1511
+ }
1464
1512
  /**
1465
- * Validate a frontend (Next.js) app configuration.
1466
- * Checks for Next.js config file and dependency.
1513
+ * Validate a frontend app configuration.
1514
+ *
1515
+ * If `framework` is provided, validates strictly against that framework's
1516
+ * expected config file and dependency. Otherwise auto-detects the framework
1517
+ * from package.json and config files. If no recognized framework is found, the
1518
+ * app is allowed through with a warning provided it has a `dev` script.
1519
+ *
1467
1520
  * @internal Exported for testing
1468
1521
  */
1469
- async function validateFrontendApp(appName, appPath, workspaceRoot) {
1522
+ async function validateFrontendApp(appName, appPath, workspaceRoot, framework) {
1470
1523
  const errors = [];
1471
1524
  const warnings = [];
1472
1525
  const fullPath = (0, node_path.join)(workspaceRoot, appPath);
1473
- const hasConfigFile = NEXTJS_CONFIG_FILES.some((file) => (0, node_fs.existsSync)((0, node_path.join)(fullPath, file)));
1474
- if (!hasConfigFile) errors.push(`Next.js config file not found. Expected one of: ${NEXTJS_CONFIG_FILES.join(", ")}`);
1475
1526
  const packageJsonPath = (0, node_path.join)(fullPath, "package.json");
1476
- if ((0, node_fs.existsSync)(packageJsonPath)) try {
1477
- const pkg$1 = require(packageJsonPath);
1478
- const deps = {
1479
- ...pkg$1.dependencies,
1480
- ...pkg$1.devDependencies
1527
+ if (!(0, node_fs.existsSync)(packageJsonPath)) {
1528
+ errors.push(`package.json not found at ${appPath}. Run: pnpm init in the app directory.`);
1529
+ return {
1530
+ appName,
1531
+ valid: false,
1532
+ errors,
1533
+ warnings
1481
1534
  };
1482
- if (!deps.next) errors.push("Next.js not found in dependencies. Run: pnpm add next react react-dom");
1483
- if (!pkg$1.scripts?.dev) warnings.push("No \"dev\" script found in package.json. Turbo expects a \"dev\" script to run.");
1535
+ }
1536
+ let pkg$1;
1537
+ try {
1538
+ pkg$1 = require(packageJsonPath);
1484
1539
  } catch {
1485
1540
  errors.push(`Failed to read package.json at ${packageJsonPath}`);
1541
+ return {
1542
+ appName,
1543
+ valid: false,
1544
+ errors,
1545
+ warnings
1546
+ };
1486
1547
  }
1487
- else errors.push(`package.json not found at ${appPath}. Run: pnpm init in the app directory.`);
1548
+ const deps = {
1549
+ ...pkg$1.dependencies,
1550
+ ...pkg$1.devDependencies
1551
+ };
1552
+ const resolvedFramework = framework ?? detectFrontendFramework(fullPath, deps);
1553
+ if (resolvedFramework) {
1554
+ const spec = FRONTEND_FRAMEWORKS[resolvedFramework];
1555
+ const hasConfig = spec.configFiles.some((file) => (0, node_fs.existsSync)((0, node_path.join)(fullPath, file)));
1556
+ if (!hasConfig) errors.push(`${spec.displayName} config file not found. Expected one of: ${spec.configFiles.join(", ")}`);
1557
+ if (!deps[spec.dependency]) errors.push(`${spec.displayName} not found in dependencies. Run: ${spec.installCommand}`);
1558
+ } else warnings.push("No recognized frontend framework detected (Next.js, Vite, Remix). The app will run via its \"dev\" script. Set `framework` in your app config to enable strict validation.");
1559
+ if (!pkg$1.scripts?.dev) if (resolvedFramework) warnings.push("No \"dev\" script found in package.json. Turbo expects a \"dev\" script to run.");
1560
+ else errors.push("No \"dev\" script found in package.json. Without a recognized framework or a dev script, there is nothing to run.");
1488
1561
  return {
1489
1562
  appName,
1490
1563
  valid: errors.length === 0,
@@ -1500,7 +1573,7 @@ async function validateFrontendApp(appName, appPath, workspaceRoot) {
1500
1573
  async function validateFrontendApps(workspace) {
1501
1574
  const results = [];
1502
1575
  for (const [appName, app] of Object.entries(workspace.apps)) if (app.type === "frontend") {
1503
- const result = await validateFrontendApp(appName, app.path, workspace.root);
1576
+ const result = await validateFrontendApp(appName, app.path, workspace.root, app.framework);
1504
1577
  results.push(result);
1505
1578
  }
1506
1579
  return results;
@@ -6851,7 +6924,7 @@ const GEEKMIDAS_VERSIONS = {
6851
6924
  "@geekmidas/storage": "~2.0.2",
6852
6925
  "@geekmidas/studio": "~1.0.0",
6853
6926
  "@geekmidas/telescope": "~1.0.0",
6854
- "@geekmidas/testkit": "~1.0.5",
6927
+ "@geekmidas/testkit": "~1.0.6",
6855
6928
  "@geekmidas/cli": CLI_VERSION
6856
6929
  };
6857
6930