sk-test-node-deploy 1.0.0 → 1.0.3
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/lib/index.js +66 -9
- package/package.json +6 -1
package/lib/index.js
CHANGED
|
@@ -9,6 +9,15 @@ async function createProject(projectName) {
|
|
|
9
9
|
const targetPath = path.join(process.cwd(), projectName);
|
|
10
10
|
const templatePath = path.join(__dirname, "../template");
|
|
11
11
|
|
|
12
|
+
// Debug: Check if template exists
|
|
13
|
+
if (!fs.existsSync(templatePath)) {
|
|
14
|
+
console.error(
|
|
15
|
+
chalk.red(`❌ Template directory not found at: ${templatePath}`),
|
|
16
|
+
);
|
|
17
|
+
console.error(chalk.yellow(`Looked in: ${templatePath}`));
|
|
18
|
+
process.exit(1);
|
|
19
|
+
}
|
|
20
|
+
|
|
12
21
|
// Check if directory already exists
|
|
13
22
|
if (fs.existsSync(targetPath)) {
|
|
14
23
|
console.error(chalk.red(`❌ Directory "${projectName}" already exists!`));
|
|
@@ -25,7 +34,6 @@ async function createProject(projectName) {
|
|
|
25
34
|
const copySpinner = ora("Copying template files...").start();
|
|
26
35
|
await fs.copy(templatePath, targetPath, {
|
|
27
36
|
filter: (src) => {
|
|
28
|
-
// Exclude unwanted files/folders
|
|
29
37
|
const excludes = ["node_modules", ".git", "dist", "build", ".env"];
|
|
30
38
|
return !excludes.some((exclude) => src.includes(exclude));
|
|
31
39
|
},
|
|
@@ -49,38 +57,87 @@ async function createProject(projectName) {
|
|
|
49
57
|
const packageManager = detectPackageManager();
|
|
50
58
|
console.log(chalk.gray(`Using package manager: ${packageManager}\n`));
|
|
51
59
|
|
|
52
|
-
// Step 4: Install production dependencies
|
|
60
|
+
// Step 4: Install production dependencies
|
|
53
61
|
console.log(chalk.blue("📦 Installing dependencies...\n"));
|
|
54
62
|
const installSpinner = ora("Installing production dependencies...").start();
|
|
55
63
|
|
|
56
64
|
try {
|
|
57
|
-
const
|
|
58
|
-
|
|
65
|
+
const prodDeps = [
|
|
66
|
+
"bcryptjs",
|
|
67
|
+
"compression",
|
|
68
|
+
"cors",
|
|
69
|
+
"dotenv",
|
|
70
|
+
"express",
|
|
71
|
+
"helmet",
|
|
72
|
+
"joi",
|
|
73
|
+
"jsonwebtoken",
|
|
74
|
+
"mongoose",
|
|
75
|
+
"socket.io",
|
|
76
|
+
"multer",
|
|
77
|
+
];
|
|
78
|
+
|
|
79
|
+
const installCmd = packageManager === "npm" ? "install" : "add";
|
|
80
|
+
const prodCmd = `${packageManager} ${installCmd} ${prodDeps.join(" ")}`;
|
|
81
|
+
|
|
82
|
+
// Windows-specific execution options
|
|
83
|
+
const execOptions = {
|
|
59
84
|
cwd: targetPath,
|
|
60
85
|
stdio: "inherit",
|
|
61
86
|
shell: true,
|
|
62
|
-
}
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
// Add Windows-specific options
|
|
90
|
+
if (os.platform() === "win32") {
|
|
91
|
+
execOptions.windowsVerbatimArguments = false;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
execSync(prodCmd, execOptions);
|
|
63
95
|
installSpinner.succeed(chalk.green("Production dependencies installed!"));
|
|
64
96
|
} catch (error) {
|
|
65
97
|
installSpinner.fail(
|
|
66
98
|
chalk.red("Failed to install production dependencies"),
|
|
67
99
|
);
|
|
100
|
+
console.error(chalk.red(error.message));
|
|
68
101
|
throw error;
|
|
69
102
|
}
|
|
70
103
|
|
|
71
|
-
// Step 5: Install dev dependencies
|
|
104
|
+
// Step 5: Install dev dependencies
|
|
72
105
|
const devInstallSpinner = ora("Installing dev dependencies...").start();
|
|
73
106
|
|
|
74
107
|
try {
|
|
75
|
-
const
|
|
76
|
-
|
|
108
|
+
const devDeps = [
|
|
109
|
+
"typescript",
|
|
110
|
+
"ts-node",
|
|
111
|
+
"@types/node",
|
|
112
|
+
"@types/express",
|
|
113
|
+
"@types/bcryptjs",
|
|
114
|
+
"@types/compression",
|
|
115
|
+
"@types/cors",
|
|
116
|
+
"@types/jsonwebtoken",
|
|
117
|
+
"@types/mongoose",
|
|
118
|
+
"@types/socket.io",
|
|
119
|
+
"@types/multer",
|
|
120
|
+
"nodemon",
|
|
121
|
+
];
|
|
122
|
+
|
|
123
|
+
const devFlag = packageManager === "npm" ? "install -D" : "add -D";
|
|
124
|
+
const devCmd = `${packageManager} ${devFlag} ${devDeps.join(" ")}`;
|
|
125
|
+
|
|
126
|
+
const execOptions = {
|
|
77
127
|
cwd: targetPath,
|
|
78
128
|
stdio: "inherit",
|
|
79
129
|
shell: true,
|
|
80
|
-
}
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
if (os.platform() === "win32") {
|
|
133
|
+
execOptions.windowsVerbatimArguments = false;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
execSync(devCmd, execOptions);
|
|
81
137
|
devInstallSpinner.succeed(chalk.green("Dev dependencies installed!"));
|
|
82
138
|
} catch (error) {
|
|
83
139
|
devInstallSpinner.fail(chalk.red("Failed to install dev dependencies"));
|
|
140
|
+
console.error(chalk.red(error.message));
|
|
84
141
|
throw error;
|
|
85
142
|
}
|
|
86
143
|
|
package/package.json
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sk-test-node-deploy",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "CLI tool to quickly scaffold a Node.js boilerplate project",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"bin": {
|
|
7
7
|
"sk-test-node-deploy": "bin/cli.js"
|
|
8
8
|
},
|
|
9
|
+
"files": [
|
|
10
|
+
"bin",
|
|
11
|
+
"lib",
|
|
12
|
+
"template"
|
|
13
|
+
],
|
|
9
14
|
"scripts": {
|
|
10
15
|
"test": "echo \"No tests specified\"",
|
|
11
16
|
"postinstall": "node -e \"try{const fs=require('fs');const path=require('path');const binPath=path.join(__dirname,'bin','cli.js');if(fs.existsSync(binPath)){fs.chmodSync(binPath,0o755);}}catch(e){}\""
|