@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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nestjs-ssr/react",
3
- "version": "0.1.8",
3
+ "version": "0.1.9",
4
4
  "description": "React SSR for NestJS that respects Clean Architecture. Proper DI, SOLID principles, clear separation of concerns.",
5
5
  "keywords": [
6
6
  "nestjs",
package/src/cli/init.ts CHANGED
@@ -3,6 +3,7 @@
3
3
  import { existsSync, readFileSync, writeFileSync, mkdirSync, copyFileSync } from 'fs';
4
4
  import { join, resolve, dirname } from 'path';
5
5
  import { fileURLToPath } from 'url';
6
+ import { execSync } from 'child_process';
6
7
  import { consola } from 'consola';
7
8
  import { defineCommand, runMain } from 'citty';
8
9
 
@@ -26,6 +27,11 @@ const main = defineCommand({
26
27
  description: 'Views directory path',
27
28
  default: 'src/views',
28
29
  },
30
+ 'skip-install': {
31
+ type: 'boolean',
32
+ description: 'Skip automatic dependency installation',
33
+ default: false,
34
+ },
29
35
  },
30
36
  async run({ args }) {
31
37
  const cwd = process.cwd();
@@ -244,6 +250,53 @@ export default defineConfig({
244
250
  writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2) + '\n');
245
251
  consola.success(`Updated build script to: "${newBuildScript}"`);
246
252
  }
253
+
254
+ // 7. Check and install dependencies
255
+ if (!args['skip-install']) {
256
+ consola.start('Checking dependencies...');
257
+ const requiredDeps = {
258
+ 'react': '^19.0.0',
259
+ 'react-dom': '^19.0.0',
260
+ 'vite': '^7.0.0',
261
+ '@vitejs/plugin-react': '^4.0.0'
262
+ };
263
+
264
+ const missingDeps: string[] = [];
265
+ const allDeps = { ...packageJson.dependencies, ...packageJson.devDependencies };
266
+
267
+ for (const [dep, version] of Object.entries(requiredDeps)) {
268
+ if (!allDeps[dep]) {
269
+ missingDeps.push(`${dep}@${version}`);
270
+ }
271
+ }
272
+
273
+ if (missingDeps.length > 0) {
274
+ consola.info(`Missing dependencies: ${missingDeps.join(', ')}`);
275
+
276
+ // Detect package manager
277
+ let packageManager = 'npm';
278
+ if (existsSync(join(cwd, 'pnpm-lock.yaml'))) packageManager = 'pnpm';
279
+ else if (existsSync(join(cwd, 'yarn.lock'))) packageManager = 'yarn';
280
+
281
+ const installCmd = packageManager === 'npm'
282
+ ? `npm install ${missingDeps.join(' ')}`
283
+ : `${packageManager} add ${missingDeps.join(' ')}`;
284
+
285
+ try {
286
+ consola.start(`Installing dependencies with ${packageManager}...`);
287
+ execSync(installCmd, {
288
+ cwd,
289
+ stdio: 'inherit'
290
+ });
291
+ consola.success('Dependencies installed!');
292
+ } catch (error) {
293
+ consola.error('Failed to install dependencies:', error);
294
+ consola.info(`Please manually run: ${installCmd}`);
295
+ }
296
+ } else {
297
+ consola.success('All required dependencies are already installed');
298
+ }
299
+ }
247
300
  } catch (error) {
248
301
  consola.error('Failed to update package.json:', error);
249
302
  }