start-it-cli 1.0.0

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/dist/cli.js ADDED
@@ -0,0 +1,143 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ var __importDefault = (this && this.__importDefault) || function (mod) {
4
+ return (mod && mod.__esModule) ? mod : { "default": mod };
5
+ };
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ const chalk_1 = __importDefault(require("chalk"));
8
+ const inquirer_1 = __importDefault(require("inquirer"));
9
+ const generator_1 = require("./generator");
10
+ const FRAMEWORKS = [
11
+ "Go",
12
+ "Flutter",
13
+ "React Native",
14
+ "Spring Boot",
15
+ "Node.js",
16
+ "Python",
17
+ ];
18
+ async function main() {
19
+ console.log(chalk_1.default.bold.cyan("\n🚀 Welcome to start-it!\n"));
20
+ console.log(chalk_1.default.gray("Create a new project with ease.\n"));
21
+ try {
22
+ const answers = await inquirer_1.default.prompt([
23
+ {
24
+ type: "list",
25
+ name: "framework",
26
+ message: "What type of project would you like to create?",
27
+ choices: FRAMEWORKS,
28
+ },
29
+ {
30
+ type: "input",
31
+ name: "projectName",
32
+ message: "Project name:",
33
+ default: "my-app",
34
+ validate: (input) => {
35
+ if (!input.trim()) {
36
+ return "Project name cannot be empty";
37
+ }
38
+ if (!/^[a-zA-Z0-9_-]+$/.test(input)) {
39
+ return "Project name can only contain letters, numbers, hyphens, and underscores";
40
+ }
41
+ return true;
42
+ },
43
+ },
44
+ ]);
45
+ const config = {
46
+ framework: answers.framework,
47
+ projectName: answers.projectName,
48
+ projectPath: process.cwd(),
49
+ };
50
+ // Get framework-specific options
51
+ const frameworkOptions = await getFrameworkOptions(config.framework);
52
+ config.options = frameworkOptions;
53
+ const generator = new generator_1.ProjectGenerator(config);
54
+ await generator.generate();
55
+ console.log(chalk_1.default.bold.green(`\n✓ Project "${config.projectName}" created successfully!\n`));
56
+ console.log(chalk_1.default.cyan(`Next steps:`));
57
+ console.log(chalk_1.default.gray(` cd ${config.projectName}`));
58
+ console.log(chalk_1.default.gray(` Follow the README.md for further instructions\n`));
59
+ }
60
+ catch (error) {
61
+ if (error instanceof Error) {
62
+ console.error(chalk_1.default.bold.red(`\n✗ Error: ${error.message}\n`));
63
+ }
64
+ else {
65
+ console.error(chalk_1.default.bold.red("\n✗ An unexpected error occurred\n"));
66
+ }
67
+ process.exit(1);
68
+ }
69
+ }
70
+ async function getFrameworkOptions(framework) {
71
+ const options = {};
72
+ switch (framework) {
73
+ case "Go":
74
+ const goTemplate = await inquirer_1.default.prompt([
75
+ {
76
+ type: "list",
77
+ name: "template",
78
+ message: "Select Go template:",
79
+ choices: ["Basic CLI", "Web API", "Microservice"],
80
+ },
81
+ ]);
82
+ options.template = goTemplate.template;
83
+ break;
84
+ case "Flutter":
85
+ const flutterTemplate = await inquirer_1.default.prompt([
86
+ {
87
+ type: "list",
88
+ name: "template",
89
+ message: "Select Flutter template:",
90
+ choices: ["Mobile App", "Web App", "Desktop App"],
91
+ },
92
+ ]);
93
+ options.template = flutterTemplate.template;
94
+ break;
95
+ case "React Native":
96
+ const rnTemplate = await inquirer_1.default.prompt([
97
+ {
98
+ type: "list",
99
+ name: "template",
100
+ message: "Select React Native template:",
101
+ choices: ["Expo", "Bare React Native"],
102
+ },
103
+ ]);
104
+ options.template = rnTemplate.template;
105
+ break;
106
+ case "Spring Boot":
107
+ const sbTemplate = await inquirer_1.default.prompt([
108
+ {
109
+ type: "list",
110
+ name: "template",
111
+ message: "Select Spring Boot template:",
112
+ choices: ["REST API", "Web Application", "Microservice"],
113
+ },
114
+ ]);
115
+ options.template = sbTemplate.template;
116
+ break;
117
+ case "Node.js":
118
+ const nodeTemplate = await inquirer_1.default.prompt([
119
+ {
120
+ type: "list",
121
+ name: "template",
122
+ message: "Select Node.js template:",
123
+ choices: ["Express API", "Next.js", "TypeScript Project"],
124
+ },
125
+ ]);
126
+ options.template = nodeTemplate.template;
127
+ break;
128
+ case "Python":
129
+ const pyTemplate = await inquirer_1.default.prompt([
130
+ {
131
+ type: "list",
132
+ name: "template",
133
+ message: "Select Python template:",
134
+ choices: ["Django", "Flask", "FastAPI"],
135
+ },
136
+ ]);
137
+ options.template = pyTemplate.template;
138
+ break;
139
+ }
140
+ return options;
141
+ }
142
+ main();
143
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.ProjectGenerator = void 0;
7
+ const path_1 = __importDefault(require("path"));
8
+ const fs_extra_1 = __importDefault(require("fs-extra"));
9
+ const ora_1 = __importDefault(require("ora"));
10
+ const templates_1 = require("./templates");
11
+ class ProjectGenerator {
12
+ constructor(config) {
13
+ this.config = config;
14
+ }
15
+ async generate() {
16
+ const projectPath = path_1.default.join(this.config.projectPath, this.config.projectName);
17
+ // Check if directory already exists
18
+ if (fs_extra_1.default.existsSync(projectPath)) {
19
+ throw new Error(`Directory "${this.config.projectName}" already exists`);
20
+ }
21
+ const spinner = (0, ora_1.default)("Creating project structure...").start();
22
+ try {
23
+ // Create project directory
24
+ await fs_extra_1.default.ensureDir(projectPath);
25
+ // Get template for the framework
26
+ const template = (0, templates_1.getTemplate)(this.config.framework, this.config.options?.template || "");
27
+ // Create all files from template
28
+ for (const file of template.files) {
29
+ const filePath = path_1.default.join(projectPath, file.path);
30
+ await fs_extra_1.default.ensureDir(path_1.default.dirname(filePath));
31
+ await fs_extra_1.default.writeFile(filePath, file.content);
32
+ if (file.isExecutable) {
33
+ await fs_extra_1.default.chmod(filePath, 0o755);
34
+ }
35
+ }
36
+ spinner.succeed("Project structure created");
37
+ }
38
+ catch (error) {
39
+ spinner.fail("Failed to create project");
40
+ // Clean up on error
41
+ if (fs_extra_1.default.existsSync(projectPath)) {
42
+ await fs_extra_1.default.remove(projectPath);
43
+ }
44
+ throw error;
45
+ }
46
+ }
47
+ }
48
+ exports.ProjectGenerator = ProjectGenerator;
49
+ //# sourceMappingURL=generator.js.map