@ifecodes/backend-template 1.0.9 → 1.0.10

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.
@@ -47,6 +47,24 @@ export const getProjectConfig = async () => {
47
47
  message: "Project name",
48
48
  initial: "my-backend",
49
49
  },
50
+ {
51
+ type: isInMicroserviceProject || hasCliArgs || isCI ? null : "text",
52
+ name: "description",
53
+ message: "Project description (optional)",
54
+ initial: "",
55
+ },
56
+ {
57
+ type: isInMicroserviceProject || hasCliArgs || isCI ? null : "text",
58
+ name: "author",
59
+ message: "Author (optional)",
60
+ initial: "",
61
+ },
62
+ {
63
+ type: isInMicroserviceProject || hasCliArgs || isCI ? null : "text",
64
+ name: "keywords",
65
+ message: "Keywords (comma-separated, optional)",
66
+ initial: "",
67
+ },
50
68
  {
51
69
  type: isInMicroserviceProject || (hasCliArgs && cliProjectType) || isCI ? null : "select",
52
70
  name: "projectType",
@@ -301,10 +301,41 @@ await connectDB();`
301
301
  // Update package.json
302
302
  const packageJsonPath = path.join(serviceRoot, "package.json");
303
303
  const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
304
- packageJson.name = serviceName || res.sanitizedName;
304
+
305
+ // Create new package.json with name at the top
306
+ const orderedPackageJson = {
307
+ name: serviceName || res.sanitizedName,
308
+ version: packageJson.version,
309
+ description: res.description || packageJson.description,
310
+ ...packageJson,
311
+ };
312
+
313
+ // Remove duplicate keys that were moved to the top
314
+ delete orderedPackageJson.name;
315
+ delete orderedPackageJson.version;
316
+ delete orderedPackageJson.description;
317
+
318
+ // Re-add them at the top in correct order
319
+ const finalPackageJson = {
320
+ name: serviceName || res.sanitizedName,
321
+ version: packageJson.version,
322
+ description: res.description || packageJson.description,
323
+ ...orderedPackageJson,
324
+ };
325
+
326
+ // Add author if provided
327
+ if (res.author) {
328
+ finalPackageJson.author = res.author;
329
+ }
330
+
331
+ // Add keywords if provided
332
+ if (res.keywords && res.keywords.trim()) {
333
+ finalPackageJson.keywords = res.keywords.split(',').map(k => k.trim()).filter(Boolean);
334
+ }
335
+
305
336
  fs.writeFileSync(
306
337
  packageJsonPath,
307
- JSON.stringify(packageJson, null, 2) + "\n"
338
+ JSON.stringify(finalPackageJson, null, 2) + "\n"
308
339
  );
309
340
 
310
341
  // Install dependencies
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ifecodes/backend-template",
3
- "version": "1.0.9",
3
+ "version": "1.0.10",
4
4
  "description": "Production-ready Express + TypeScript backend generator with optional features and microservice support",
5
5
  "bin": {
6
6
  "ifecodes-template": "bin/cli.js"
@@ -1,4 +1,7 @@
1
1
  {
2
+ "version": "1.0.0",
3
+ "description": "",
4
+ "main": "index.js",
2
5
  "scripts": {
3
6
  "dev": "ts-node-dev --respawn --transpile-only -r tsconfig-paths/register src/server.ts",
4
7
  "start": "node dist/server.js",
@@ -8,6 +11,10 @@
8
11
  "check-format": "prettier --check \"src/**/*.{ts,json}\"",
9
12
  "prepare": "husky"
10
13
  },
14
+ "keywords": [],
15
+ "author": "",
16
+ "license": "ISC",
17
+ "type": "commonjs",
11
18
  "dependencies": {
12
19
  "dotenv": "^16.3.1",
13
20
  "express": "^5.2.1",
@@ -4,29 +4,30 @@ function format(tag: string, args: unknown[]) {
4
4
  return [`%c[${tag}]`, "color:#6366f1;font-weight:600", ...args];
5
5
  }
6
6
 
7
- const environment =
8
- ENV.NODE_ENV === "development" || ENV.NODE_ENV === "staging"
7
+ function getEnvironment() {
8
+ return ENV.NODE_ENV === "development" || ENV.NODE_ENV === "staging"
9
9
  ? "development"
10
10
  : ENV.NODE_ENV;
11
+ }
11
12
 
12
13
  const logger = {
13
14
  log(tag: string, ...args: unknown[]) {
14
- if (environment !== "development") return;
15
+ if (getEnvironment() !== "development") return;
15
16
  console.log(...format(tag, args));
16
17
  },
17
18
 
18
19
  info(tag: string, ...args: unknown[]) {
19
- if (environment !== "development") return;
20
+ if (getEnvironment() !== "development") return;
20
21
  console.info(...format(tag, args));
21
22
  },
22
23
 
23
24
  warn(tag: string, ...args: unknown[]) {
24
- if (environment !== "development") return;
25
+ if (getEnvironment() !== "development") return;
25
26
  console.warn(...format(tag, args));
26
27
  },
27
28
 
28
29
  error(tag: string, ...args: unknown[]) {
29
- if (environment !== "development") return;
30
+ if (getEnvironment() !== "development") return;
30
31
  console.error(...format(tag, args));
31
32
  },
32
33
  };