@nestjs-ssr/react 0.1.8 → 0.1.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/dist/cli/init.mjs CHANGED
@@ -7,6 +7,7 @@ import { WriteStream } from 'tty';
7
7
  import { existsSync, mkdirSync, copyFileSync, writeFileSync, readFileSync } from 'fs';
8
8
  import { dirname, sep, resolve, join } from 'path';
9
9
  import { fileURLToPath } from 'url';
10
+ import { execSync } from 'child_process';
10
11
 
11
12
  var __defProp = Object.defineProperty;
12
13
  var __getOwnPropNames = Object.getOwnPropertyNames;
@@ -2421,6 +2422,11 @@ var main = defineCommand({
2421
2422
  type: "string",
2422
2423
  description: "Views directory path",
2423
2424
  default: "src/views"
2425
+ },
2426
+ "skip-install": {
2427
+ type: "boolean",
2428
+ description: "Skip automatic dependency installation",
2429
+ default: false
2424
2430
  }
2425
2431
  },
2426
2432
  async run({ args }) {
@@ -2598,6 +2604,45 @@ export default defineConfig({
2598
2604
  writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2) + "\n");
2599
2605
  consola.success(`Updated build script to: "${newBuildScript}"`);
2600
2606
  }
2607
+ if (!args["skip-install"]) {
2608
+ consola.start("Checking dependencies...");
2609
+ const requiredDeps = {
2610
+ "react": "^19.0.0",
2611
+ "react-dom": "^19.0.0",
2612
+ "vite": "^7.0.0",
2613
+ "@vitejs/plugin-react": "^4.0.0"
2614
+ };
2615
+ const missingDeps = [];
2616
+ const allDeps = {
2617
+ ...packageJson.dependencies,
2618
+ ...packageJson.devDependencies
2619
+ };
2620
+ for (const [dep, version] of Object.entries(requiredDeps)) {
2621
+ if (!allDeps[dep]) {
2622
+ missingDeps.push(`${dep}@${version}`);
2623
+ }
2624
+ }
2625
+ if (missingDeps.length > 0) {
2626
+ consola.info(`Missing dependencies: ${missingDeps.join(", ")}`);
2627
+ let packageManager = "npm";
2628
+ if (existsSync(join(cwd, "pnpm-lock.yaml"))) packageManager = "pnpm";
2629
+ else if (existsSync(join(cwd, "yarn.lock"))) packageManager = "yarn";
2630
+ const installCmd = packageManager === "npm" ? `npm install ${missingDeps.join(" ")}` : `${packageManager} add ${missingDeps.join(" ")}`;
2631
+ try {
2632
+ consola.start(`Installing dependencies with ${packageManager}...`);
2633
+ execSync(installCmd, {
2634
+ cwd,
2635
+ stdio: "inherit"
2636
+ });
2637
+ consola.success("Dependencies installed!");
2638
+ } catch (error) {
2639
+ consola.error("Failed to install dependencies:", error);
2640
+ consola.info(`Please manually run: ${installCmd}`);
2641
+ }
2642
+ } else {
2643
+ consola.success("All required dependencies are already installed");
2644
+ }
2645
+ }
2601
2646
  } catch (error) {
2602
2647
  consola.error("Failed to update package.json:", error);
2603
2648
  }