sk-test-node-deploy 1.0.0 → 1.0.1
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 +59 -10
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -25,7 +25,6 @@ async function createProject(projectName) {
|
|
|
25
25
|
const copySpinner = ora("Copying template files...").start();
|
|
26
26
|
await fs.copy(templatePath, targetPath, {
|
|
27
27
|
filter: (src) => {
|
|
28
|
-
// Exclude unwanted files/folders
|
|
29
28
|
const excludes = ["node_modules", ".git", "dist", "build", ".env"];
|
|
30
29
|
return !excludes.some((exclude) => src.includes(exclude));
|
|
31
30
|
},
|
|
@@ -49,46 +48,92 @@ async function createProject(projectName) {
|
|
|
49
48
|
const packageManager = detectPackageManager();
|
|
50
49
|
console.log(chalk.gray(`Using package manager: ${packageManager}\n`));
|
|
51
50
|
|
|
52
|
-
// Step 4: Install production dependencies
|
|
51
|
+
// Step 4: Install production dependencies
|
|
53
52
|
console.log(chalk.blue("📦 Installing dependencies...\n"));
|
|
54
53
|
const installSpinner = ora("Installing production dependencies...").start();
|
|
55
54
|
|
|
56
55
|
try {
|
|
57
|
-
const
|
|
56
|
+
const prodDeps = [
|
|
57
|
+
"bcryptjs",
|
|
58
|
+
"compression",
|
|
59
|
+
"cors",
|
|
60
|
+
"dotenv",
|
|
61
|
+
"express",
|
|
62
|
+
"helmet",
|
|
63
|
+
"joi",
|
|
64
|
+
"jsonwebtoken",
|
|
65
|
+
"mongoose",
|
|
66
|
+
"socket.io",
|
|
67
|
+
"multer",
|
|
68
|
+
];
|
|
69
|
+
|
|
70
|
+
const installCmd = packageManager === "npm" ? "install" : "add";
|
|
71
|
+
const prodCmd = `${packageManager} ${installCmd} ${prodDeps.join(" ")}`;
|
|
72
|
+
|
|
58
73
|
execSync(prodCmd, {
|
|
59
74
|
cwd: targetPath,
|
|
60
|
-
stdio: "
|
|
75
|
+
stdio: "pipe",
|
|
61
76
|
shell: true,
|
|
77
|
+
windowsHide: true,
|
|
62
78
|
});
|
|
63
79
|
installSpinner.succeed(chalk.green("Production dependencies installed!"));
|
|
64
80
|
} catch (error) {
|
|
65
81
|
installSpinner.fail(
|
|
66
82
|
chalk.red("Failed to install production dependencies"),
|
|
67
83
|
);
|
|
84
|
+
console.error(chalk.red(error.message));
|
|
68
85
|
throw error;
|
|
69
86
|
}
|
|
70
87
|
|
|
71
|
-
// Step 5: Install dev dependencies
|
|
88
|
+
// Step 5: Install dev dependencies
|
|
72
89
|
const devInstallSpinner = ora("Installing dev dependencies...").start();
|
|
73
90
|
|
|
74
91
|
try {
|
|
75
|
-
const
|
|
92
|
+
const devDeps = [
|
|
93
|
+
"typescript",
|
|
94
|
+
"ts-node",
|
|
95
|
+
"@types/node",
|
|
96
|
+
"@types/express",
|
|
97
|
+
"@types/bcryptjs",
|
|
98
|
+
"@types/compression",
|
|
99
|
+
"@types/cors",
|
|
100
|
+
"@types/jsonwebtoken",
|
|
101
|
+
"@types/mongoose",
|
|
102
|
+
"@types/socket.io",
|
|
103
|
+
"@types/multer",
|
|
104
|
+
"nodemon",
|
|
105
|
+
];
|
|
106
|
+
|
|
107
|
+
const devFlag = packageManager === "npm" ? "install -D" : "add -D";
|
|
108
|
+
const devCmd = `${packageManager} ${devFlag} ${devDeps.join(" ")}`;
|
|
109
|
+
|
|
76
110
|
execSync(devCmd, {
|
|
77
111
|
cwd: targetPath,
|
|
78
|
-
stdio: "
|
|
112
|
+
stdio: "pipe",
|
|
79
113
|
shell: true,
|
|
114
|
+
windowsHide: true,
|
|
80
115
|
});
|
|
81
116
|
devInstallSpinner.succeed(chalk.green("Dev dependencies installed!"));
|
|
82
117
|
} catch (error) {
|
|
83
118
|
devInstallSpinner.fail(chalk.red("Failed to install dev dependencies"));
|
|
119
|
+
console.error(chalk.red(error.message));
|
|
84
120
|
throw error;
|
|
85
121
|
}
|
|
86
122
|
|
|
87
123
|
// Step 6: Initialize git (optional)
|
|
88
124
|
const gitSpinner = ora("Initializing git repository...").start();
|
|
89
125
|
try {
|
|
90
|
-
execSync("git --version", {
|
|
91
|
-
|
|
126
|
+
execSync("git --version", {
|
|
127
|
+
stdio: "ignore",
|
|
128
|
+
shell: true,
|
|
129
|
+
windowsHide: true,
|
|
130
|
+
});
|
|
131
|
+
execSync("git init", {
|
|
132
|
+
cwd: targetPath,
|
|
133
|
+
stdio: "ignore",
|
|
134
|
+
shell: true,
|
|
135
|
+
windowsHide: true,
|
|
136
|
+
});
|
|
92
137
|
gitSpinner.succeed(chalk.green("Git repository initialized!"));
|
|
93
138
|
} catch (error) {
|
|
94
139
|
gitSpinner.warn(chalk.yellow("Git not found or initialization skipped"));
|
|
@@ -124,7 +169,11 @@ async function createProject(projectName) {
|
|
|
124
169
|
// Detect which package manager is available
|
|
125
170
|
function detectPackageManager() {
|
|
126
171
|
try {
|
|
127
|
-
execSync("yarn --version", {
|
|
172
|
+
execSync("yarn --version", {
|
|
173
|
+
stdio: "ignore",
|
|
174
|
+
shell: true,
|
|
175
|
+
windowsHide: true,
|
|
176
|
+
});
|
|
128
177
|
return "yarn";
|
|
129
178
|
} catch {
|
|
130
179
|
return "npm";
|