create-uk-node-server 1.0.7 → 1.0.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/README.md +8 -1
- package/createPackageJsonFile.js +60 -0
- package/index.js +6 -2
- package/package.json +1 -1
package/README.md
CHANGED
@@ -53,7 +53,14 @@ your-project/
|
|
53
53
|
2. Choose your language preference
|
54
54
|
3. Enter your project name
|
55
55
|
4. Navigate to your project directory
|
56
|
-
5.
|
56
|
+
5. Create `.env` file
|
57
|
+
|
58
|
+
```
|
59
|
+
APP_ENV=development
|
60
|
+
APP_PORT=3000
|
61
|
+
APP_URL=http://localhost:3000
|
62
|
+
DB_URL=mongodb://localhost:27017/your-database
|
63
|
+
```
|
57
64
|
6. Run `npm start` to start your server
|
58
65
|
|
59
66
|
## License
|
@@ -0,0 +1,60 @@
|
|
1
|
+
export default function createPackageJsonFile(projectPath, projectName, language) {
|
2
|
+
let packageJson = `
|
3
|
+
{
|
4
|
+
"name": "${projectName}",
|
5
|
+
"version": "1.0.0",
|
6
|
+
"description": "",
|
7
|
+
"main": "index.js",
|
8
|
+
"scripts": {
|
9
|
+
"start": "node index.js",
|
10
|
+
"dev": "nodemon index.js",
|
11
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
12
|
+
},
|
13
|
+
"keywords": [],
|
14
|
+
"author": "",
|
15
|
+
"license": "ISC",
|
16
|
+
"type": "module",
|
17
|
+
"dependencies": {
|
18
|
+
"bcrypt": "^6.0.0",
|
19
|
+
"dotenv": "^16.5.0",
|
20
|
+
"express": "^5.1.0",
|
21
|
+
"mongoose": "^8.15.0",
|
22
|
+
"nodemon": "^3.1.10"
|
23
|
+
}
|
24
|
+
}
|
25
|
+
`
|
26
|
+
// if language is typescript
|
27
|
+
if (language === "typescript") {
|
28
|
+
packageJson = `
|
29
|
+
{
|
30
|
+
"name": "${projectName}",
|
31
|
+
"version": "1.0.0",
|
32
|
+
"description": "TypeScript server template",
|
33
|
+
"main": "dist/index.js",
|
34
|
+
"scripts": {
|
35
|
+
"start": "node dist/index.js",
|
36
|
+
"dev": "ts-node src/index.ts",
|
37
|
+
"build": "tsc",
|
38
|
+
"watch": "tsc --watch"
|
39
|
+
},
|
40
|
+
"dependencies": {
|
41
|
+
"express": "^4.18.2",
|
42
|
+
"dotenv": "^16.3.1",
|
43
|
+
"cors": "^2.8.5",
|
44
|
+
"mongoose": "^8.0.3"
|
45
|
+
},
|
46
|
+
"devDependencies": {
|
47
|
+
"@types/express": "^4.17.21",
|
48
|
+
"@types/node": "^20.10.0",
|
49
|
+
"@types/cors": "^2.8.17",
|
50
|
+
"typescript": "^5.3.2",
|
51
|
+
"ts-node": "^10.9.1"
|
52
|
+
},
|
53
|
+
"keywords": [],
|
54
|
+
"author": "",
|
55
|
+
"license": "ISC"
|
56
|
+
}
|
57
|
+
`
|
58
|
+
}
|
59
|
+
fs.writeFileSync(path.join(projectPath, "package.json"), packageJson)
|
60
|
+
}
|
package/index.js
CHANGED
@@ -26,10 +26,14 @@ async function main() {
|
|
26
26
|
|
27
27
|
fs.copy(templatePath, projectPath, err => {
|
28
28
|
if (err) return console.error(err)
|
29
|
+
const pkgPath = path.join(projectPath, "package.json");
|
30
|
+
const pkg = fs.readJsonSync(pkgPath);
|
31
|
+
pkg.name = answers.projectName;
|
32
|
+
fs.writeJsonSync(pkgPath, pkg, { spaces: 2 });
|
33
|
+
execSync(`cd ${projectPath} && npm install`);
|
29
34
|
console.log('success!')
|
35
|
+
console.log(`cd ${answers.projectName} and change DB connection in .env file and run npm start`)
|
30
36
|
})
|
31
|
-
|
32
|
-
console.log(`cd ${answers.projectName} and change DB connection in .env file and run npm start`)
|
33
37
|
}
|
34
38
|
|
35
39
|
export default main;
|