@fersonull/create-npm 1.0.2 → 1.1.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/README.md +1 -1
- package/dist/cli.js +4 -6
- package/dist/utils.d.ts +1 -0
- package/dist/utils.js +26 -4
- package/package.json +1 -1
package/README.md
CHANGED
package/dist/cli.js
CHANGED
|
@@ -11,12 +11,10 @@ const path_1 = __importDefault(require("path"));
|
|
|
11
11
|
async function main() {
|
|
12
12
|
credit();
|
|
13
13
|
const args = process.argv.slice(2);
|
|
14
|
-
|
|
14
|
+
let projectName = args[0];
|
|
15
15
|
const isWindows = process.platform === "win32";
|
|
16
16
|
if (!projectName) {
|
|
17
|
-
utils_1.
|
|
18
|
-
utils_1.log.info("Usage: npx create-npm <project-name>");
|
|
19
|
-
process.exit(1);
|
|
17
|
+
projectName = await (0, utils_1.promptArgs)("Enter project name");
|
|
20
18
|
}
|
|
21
19
|
if (!/^[a-zA-Z0-9-_]+$/.test(projectName)) {
|
|
22
20
|
utils_1.log.error("Invalid project name. Use only alphanumeric characters, dashes, and underscores.");
|
|
@@ -125,10 +123,10 @@ async function main() {
|
|
|
125
123
|
utils_1.log.error("Dependency installation failed. You can manually install it later.");
|
|
126
124
|
}
|
|
127
125
|
else {
|
|
128
|
-
utils_1.log.success("
|
|
126
|
+
utils_1.log.success("Dependencies installed successfully.");
|
|
129
127
|
}
|
|
130
128
|
}
|
|
131
|
-
utils_1.log.
|
|
129
|
+
utils_1.log.info(`Project created at ${projectPath}`);
|
|
132
130
|
console.log("\nNext steps:");
|
|
133
131
|
console.log(` cd ${projectName}`);
|
|
134
132
|
console.log(" npm run dev\n");
|
package/dist/utils.d.ts
CHANGED
package/dist/utils.js
CHANGED
|
@@ -33,17 +33,17 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.promptConfirm = exports.log = void 0;
|
|
36
|
+
exports.promptArgs = exports.promptConfirm = exports.log = void 0;
|
|
37
37
|
const readline = __importStar(require("readline"));
|
|
38
38
|
exports.log = {
|
|
39
39
|
error: (message) => {
|
|
40
|
-
console.log("\x1b[31m%s\x1b[0m",
|
|
40
|
+
console.log("\x1b[31m%s\x1b[0m", `\nError: ${message}`);
|
|
41
41
|
},
|
|
42
42
|
success: (message) => {
|
|
43
|
-
console.log("\x1b[32m%s\x1b[0m", message);
|
|
43
|
+
console.log("\x1b[32m%s\x1b[0m", `\n${message}`);
|
|
44
44
|
},
|
|
45
45
|
info: (message) => {
|
|
46
|
-
console.log("\x1b[36m%s\x1b[0m", message);
|
|
46
|
+
console.log("\x1b[36m%s\x1b[0m", `\n${message}`);
|
|
47
47
|
},
|
|
48
48
|
};
|
|
49
49
|
const promptConfirm = (question) => {
|
|
@@ -69,3 +69,25 @@ const promptConfirm = (question) => {
|
|
|
69
69
|
});
|
|
70
70
|
};
|
|
71
71
|
exports.promptConfirm = promptConfirm;
|
|
72
|
+
const promptArgs = (question) => {
|
|
73
|
+
const rl = readline.createInterface({
|
|
74
|
+
input: process.stdin,
|
|
75
|
+
output: process.stdout,
|
|
76
|
+
});
|
|
77
|
+
return new Promise((resolve) => {
|
|
78
|
+
const ask = () => {
|
|
79
|
+
rl.question(`${question} → `, (answer) => {
|
|
80
|
+
if (answer.trim().length > 0) {
|
|
81
|
+
rl.close();
|
|
82
|
+
resolve(answer);
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
rl.close();
|
|
86
|
+
resolve("too-lazy-to-name");
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
};
|
|
90
|
+
ask();
|
|
91
|
+
});
|
|
92
|
+
};
|
|
93
|
+
exports.promptArgs = promptArgs;
|