frontend-hamroun 1.2.29 → 1.2.30
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/bin/cli.js +24 -38
- package/package.json +1 -1
- package/bin/banner.js +0 -0
- package/bin/cli-utils.js +0 -0
package/bin/cli.js
CHANGED
@@ -41,7 +41,6 @@ const createSection = (title) => {
|
|
41
41
|
// Helper for checking dependencies
|
42
42
|
async function checkDependencies() {
|
43
43
|
const spinner = createSpinner('Checking dependencies...').start();
|
44
|
-
|
45
44
|
try {
|
46
45
|
await execAsync('npm --version');
|
47
46
|
spinner.success({ text: 'Dependencies verified' });
|
@@ -56,14 +55,12 @@ async function checkDependencies() {
|
|
56
55
|
// Choose template interactively
|
57
56
|
async function chooseTemplate() {
|
58
57
|
const templatesPath = path.join(__dirname, '..', 'templates');
|
59
|
-
const templates = fs.readdirSync(templatesPath).filter(file =>
|
58
|
+
const templates = fs.readdirSync(templatesPath).filter(file =>
|
60
59
|
fs.statSync(path.join(templatesPath, file)).isDirectory()
|
61
60
|
);
|
62
|
-
|
63
|
-
// Create template descriptions
|
61
|
+
|
64
62
|
const templateOptions = templates.map(template => {
|
65
63
|
let description = '';
|
66
|
-
|
67
64
|
switch (template) {
|
68
65
|
case 'basic-app':
|
69
66
|
description = 'Simple client-side application with minimal setup';
|
@@ -77,23 +74,22 @@ async function chooseTemplate() {
|
|
77
74
|
default:
|
78
75
|
description = 'Application template';
|
79
76
|
}
|
80
|
-
|
81
77
|
return {
|
82
|
-
name: `${template} - ${chalk.dim(description)}`,
|
78
|
+
name: `${chalk.bold(template)} - ${chalk.dim(description)}`,
|
83
79
|
value: template
|
84
80
|
};
|
85
81
|
});
|
86
|
-
|
82
|
+
|
87
83
|
const answers = await inquirer.prompt([
|
88
84
|
{
|
89
85
|
type: 'list',
|
90
86
|
name: 'template',
|
91
|
-
message: 'Select a project template:',
|
87
|
+
message: chalk.green('Select a project template:'),
|
92
88
|
choices: templateOptions,
|
93
89
|
loop: false
|
94
90
|
}
|
95
91
|
]);
|
96
|
-
|
92
|
+
|
97
93
|
return answers.template;
|
98
94
|
}
|
99
95
|
|
@@ -101,69 +97,59 @@ async function chooseTemplate() {
|
|
101
97
|
async function createProject(projectName, options) {
|
102
98
|
console.log(banner);
|
103
99
|
createSection('Project Setup');
|
104
|
-
|
105
|
-
// Validate project name
|
100
|
+
|
106
101
|
if (!projectName) {
|
107
102
|
const answers = await inquirer.prompt([
|
108
103
|
{
|
109
104
|
type: 'input',
|
110
105
|
name: 'projectName',
|
111
|
-
message: 'What is your project name?',
|
106
|
+
message: chalk.green('What is your project name?'),
|
112
107
|
default: 'my-frontend-app',
|
113
|
-
validate: input =>
|
108
|
+
validate: input =>
|
109
|
+
/^[a-z0-9-_]+$/.test(input)
|
110
|
+
? true
|
111
|
+
: 'Project name can only contain lowercase letters, numbers, hyphens, and underscores'
|
114
112
|
}
|
115
113
|
]);
|
116
114
|
projectName = answers.projectName;
|
117
115
|
}
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
// Choose template if not specified
|
125
|
-
let template = options.template;
|
126
|
-
if (!template) {
|
127
|
-
template = await chooseTemplate();
|
128
|
-
}
|
129
|
-
|
130
|
-
// Create project directory
|
116
|
+
|
117
|
+
if (!await checkDependencies()) return;
|
118
|
+
|
119
|
+
let template = options.template || await chooseTemplate();
|
120
|
+
|
131
121
|
const targetDir = path.resolve(projectName);
|
132
122
|
const templateDir = path.join(__dirname, '..', 'templates', template);
|
133
|
-
|
123
|
+
|
134
124
|
if (fs.existsSync(targetDir)) {
|
135
125
|
const answers = await inquirer.prompt([
|
136
126
|
{
|
137
127
|
type: 'confirm',
|
138
128
|
name: 'overwrite',
|
139
|
-
message: `Directory ${projectName} already exists.
|
129
|
+
message: chalk.yellow(`Directory ${projectName} already exists. Overwrite?`),
|
140
130
|
default: false
|
141
131
|
}
|
142
132
|
]);
|
143
|
-
|
144
133
|
if (!answers.overwrite) {
|
145
|
-
console.log(chalk.
|
134
|
+
console.log(chalk.red('✖ Operation cancelled'));
|
146
135
|
return;
|
147
136
|
}
|
148
137
|
}
|
149
|
-
|
150
|
-
// Copy template
|
138
|
+
|
151
139
|
const spinner = createSpinner('Creating project...').start();
|
152
140
|
try {
|
153
141
|
await fs.ensureDir(targetDir);
|
154
142
|
await fs.copy(templateDir, targetDir, { overwrite: true });
|
155
|
-
|
156
|
-
// Create package.json with project name
|
143
|
+
|
157
144
|
const pkgJsonPath = path.join(targetDir, 'package.json');
|
158
145
|
if (fs.existsSync(pkgJsonPath)) {
|
159
146
|
const pkgJson = await fs.readJson(pkgJsonPath);
|
160
147
|
pkgJson.name = projectName;
|
161
148
|
await fs.writeJson(pkgJsonPath, pkgJson, { spaces: 2 });
|
162
149
|
}
|
163
|
-
|
150
|
+
|
164
151
|
spinner.success({ text: `Project created successfully at ${chalk.green(targetDir)}` });
|
165
|
-
|
166
|
-
// Show next steps
|
152
|
+
|
167
153
|
createSection('Next Steps');
|
168
154
|
console.log(`${chalk.bold.green('✓')} Run the following commands to get started:\n`);
|
169
155
|
console.log(` ${chalk.cyan('cd')} ${projectName}`);
|
package/package.json
CHANGED
package/bin/banner.js
DELETED
File without changes
|
package/bin/cli-utils.js
DELETED
File without changes
|