@dhruvinjs/appinit 1.0.2 → 1.0.4

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/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @dhruvinjs/appinit
2
2
 
3
- Backend project generator CLI.
3
+ Express backend starter with optional WebSocket, DB, and Docker support.
4
4
 
5
5
  This package creates an Express-based backend starter with optional WebSocket support (`ws` or `socket.io`), optional DB setup (`mongo` or `postgresql_prisma`), and optional Dockerfile generation.
6
6
 
package/dist/index.js CHANGED
@@ -150,6 +150,23 @@ Examples:
150
150
  console.error(`❌ Error: Invalid package manager "${options.pm}". Use: npm, pnpm, or yarn`);
151
151
  process.exit(1);
152
152
  }
153
+ // Check if the specified package manager is installed
154
+ if (!(await isToolInstalled(options.pm))) {
155
+ const fallbackPm = await inquirer.prompt([
156
+ {
157
+ type: "confirm",
158
+ name: "useFallback",
159
+ message: `⚠️ Package manager "${options.pm}" is not installed. Would you like to use npm instead?`,
160
+ default: true,
161
+ },
162
+ ]);
163
+ if (!fallbackPm.useFallback) {
164
+ console.log("❌ Cancelled: Please install the required package manager and try again.");
165
+ process.exit(0);
166
+ }
167
+ // Use npm as fallback
168
+ options.pm = "npm";
169
+ }
153
170
  }
154
171
  // Commander negated options can set defaults implicitly.
155
172
  // Only treat docker as explicitly configured when the user passed a docker flag.
@@ -293,6 +310,22 @@ Examples:
293
310
  if (fullConfig.docker && !(await isToolInstalled("docker"))) {
294
311
  console.warn('Warning: "docker" is not installed. Dockerfile will be generated, but you cannot build/run containers until Docker is installed.');
295
312
  }
313
+ let resolvedPm = options.pm || fullConfig.packageManager || "npm";
314
+ if (!(await isToolInstalled(resolvedPm))) {
315
+ const fallbackPm = await inquirer.prompt([
316
+ {
317
+ type: "confirm",
318
+ name: "useFallback",
319
+ message: `Package manager "${resolvedPm}" is not installed. Would you like to use npm instead?`,
320
+ default: true,
321
+ },
322
+ ]);
323
+ if (!fallbackPm.useFallback) {
324
+ console.log("❌ Cancelled: Please install the required package manager and try again.");
325
+ process.exit(0);
326
+ }
327
+ resolvedPm = "npm";
328
+ }
296
329
  await setup_restApi_project({
297
330
  db: fullConfig.database,
298
331
  path: project_path,
@@ -302,7 +335,7 @@ Examples:
302
335
  websocket_package: fullConfig.websocket_package,
303
336
  Dockerfile: fullConfig.docker,
304
337
  skipGit: options.git === false,
305
- packageManager: options.pm || fullConfig.packageManager || "npm",
338
+ packageManager: resolvedPm,
306
339
  });
307
340
  }
308
341
  catch (error) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@dhruvinjs/appinit",
3
- "version": "1.0.2",
4
- "description": "",
3
+ "version": "1.0.4",
4
+ "description": "Express backend starter with optional WebSocket, DB, and Docker support.",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
7
7
  "bin": {
@@ -23,7 +23,7 @@
23
23
  "jsonwebtoken": "^9.0.3",
24
24
  "ora": "^9.1.0",
25
25
  "unique-names-generator": "^4.7.1",
26
- "appinit-templates": "1.0.1"
26
+ "appinit-templates": "1.0.2"
27
27
  },
28
28
  "author": "dhruvinjs",
29
29
  "license": "MIT",
@@ -35,7 +35,7 @@
35
35
  },
36
36
  "scripts": {
37
37
  "test": "echo \"Error: no test specified\" && exit 1",
38
- "build": "npx tsc -b",
39
- "dev": "tsc -b && node dist/index.js"
38
+ "dev": "tsc -b && node dist/index.js",
39
+ "build": "tsc -b"
40
40
  }
41
41
  }