sk-test-node-deploy 1.0.1 → 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 +32 -24
- 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!`));
|
|
@@ -70,12 +79,19 @@ async function createProject(projectName) {
|
|
|
70
79
|
const installCmd = packageManager === "npm" ? "install" : "add";
|
|
71
80
|
const prodCmd = `${packageManager} ${installCmd} ${prodDeps.join(" ")}`;
|
|
72
81
|
|
|
73
|
-
|
|
82
|
+
// Windows-specific execution options
|
|
83
|
+
const execOptions = {
|
|
74
84
|
cwd: targetPath,
|
|
75
|
-
stdio: "
|
|
85
|
+
stdio: "inherit",
|
|
76
86
|
shell: true,
|
|
77
|
-
|
|
78
|
-
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
// Add Windows-specific options
|
|
90
|
+
if (os.platform() === "win32") {
|
|
91
|
+
execOptions.windowsVerbatimArguments = false;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
execSync(prodCmd, execOptions);
|
|
79
95
|
installSpinner.succeed(chalk.green("Production dependencies installed!"));
|
|
80
96
|
} catch (error) {
|
|
81
97
|
installSpinner.fail(
|
|
@@ -107,12 +123,17 @@ async function createProject(projectName) {
|
|
|
107
123
|
const devFlag = packageManager === "npm" ? "install -D" : "add -D";
|
|
108
124
|
const devCmd = `${packageManager} ${devFlag} ${devDeps.join(" ")}`;
|
|
109
125
|
|
|
110
|
-
|
|
126
|
+
const execOptions = {
|
|
111
127
|
cwd: targetPath,
|
|
112
|
-
stdio: "
|
|
128
|
+
stdio: "inherit",
|
|
113
129
|
shell: true,
|
|
114
|
-
|
|
115
|
-
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
if (os.platform() === "win32") {
|
|
133
|
+
execOptions.windowsVerbatimArguments = false;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
execSync(devCmd, execOptions);
|
|
116
137
|
devInstallSpinner.succeed(chalk.green("Dev dependencies installed!"));
|
|
117
138
|
} catch (error) {
|
|
118
139
|
devInstallSpinner.fail(chalk.red("Failed to install dev dependencies"));
|
|
@@ -123,17 +144,8 @@ async function createProject(projectName) {
|
|
|
123
144
|
// Step 6: Initialize git (optional)
|
|
124
145
|
const gitSpinner = ora("Initializing git repository...").start();
|
|
125
146
|
try {
|
|
126
|
-
execSync("git --version", {
|
|
127
|
-
|
|
128
|
-
shell: true,
|
|
129
|
-
windowsHide: true,
|
|
130
|
-
});
|
|
131
|
-
execSync("git init", {
|
|
132
|
-
cwd: targetPath,
|
|
133
|
-
stdio: "ignore",
|
|
134
|
-
shell: true,
|
|
135
|
-
windowsHide: true,
|
|
136
|
-
});
|
|
147
|
+
execSync("git --version", { stdio: "ignore", shell: true });
|
|
148
|
+
execSync("git init", { cwd: targetPath, stdio: "ignore", shell: true });
|
|
137
149
|
gitSpinner.succeed(chalk.green("Git repository initialized!"));
|
|
138
150
|
} catch (error) {
|
|
139
151
|
gitSpinner.warn(chalk.yellow("Git not found or initialization skipped"));
|
|
@@ -169,11 +181,7 @@ async function createProject(projectName) {
|
|
|
169
181
|
// Detect which package manager is available
|
|
170
182
|
function detectPackageManager() {
|
|
171
183
|
try {
|
|
172
|
-
execSync("yarn --version", {
|
|
173
|
-
stdio: "ignore",
|
|
174
|
-
shell: true,
|
|
175
|
-
windowsHide: true,
|
|
176
|
-
});
|
|
184
|
+
execSync("yarn --version", { stdio: "ignore", shell: true });
|
|
177
185
|
return "yarn";
|
|
178
186
|
} catch {
|
|
179
187
|
return "npm";
|
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){}\""
|