create-uk-node-server 1.0.9 → 1.0.11
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/index.js +4 -1
- package/package.json +1 -1
- package/createPackageJsonFile.js +0 -60
package/index.js
CHANGED
@@ -2,6 +2,7 @@ import inquirer from "inquirer";
|
|
2
2
|
import path from "path";
|
3
3
|
import fs from "fs-extra";
|
4
4
|
import { fileURLToPath } from "url";
|
5
|
+
import { execSync } from "child_process";
|
5
6
|
|
6
7
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
7
8
|
|
@@ -30,9 +31,11 @@ async function main() {
|
|
30
31
|
const pkg = fs.readJsonSync(pkgPath);
|
31
32
|
pkg.name = answers.projectName;
|
32
33
|
fs.writeJsonSync(pkgPath, pkg, { spaces: 2 });
|
34
|
+
console.log("Installing dependencies...")
|
33
35
|
execSync(`cd ${projectPath} && npm install`);
|
34
36
|
console.log('success!')
|
35
|
-
console.log(`
|
37
|
+
console.log(`create .env file and add DB_URL = "your-db-connection-string"`)
|
38
|
+
console.log(`run npm start`)
|
36
39
|
})
|
37
40
|
}
|
38
41
|
|
package/package.json
CHANGED
package/createPackageJsonFile.js
DELETED
@@ -1,60 +0,0 @@
|
|
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
|
-
}
|