Skip to content

Commit 966c540

Browse files
committed
[FEAT] Add empty project structure for already existing projects
1 parent 73d3d57 commit 966c540

File tree

8 files changed

+340
-76
lines changed

8 files changed

+340
-76
lines changed

ufazien-cli-js/package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ufazien-cli-js/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ufazien-cli",
3-
"version": "0.2.1",
3+
"version": "0.3.0",
44
"type": "module",
55
"main": "dist/cli.js",
66
"bin": {

ufazien-cli-js/src/cli.ts

Lines changed: 65 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import {
2323
createConfigFile,
2424
createEnvFile,
2525
createGitignore,
26+
createReadmeSection,
2627
createUfazienignore,
2728
createPhpProjectStructure,
2829
createStaticProjectStructure,
@@ -339,12 +340,25 @@ program
339340
}
340341
}
341342

342-
// Create project structure
343-
process.stdout.write(chalk.green('\nCreating project structure...'));
344-
if (websiteType === 'php') {
345-
const hasDb = database !== null && database.status === 'active';
346-
createPhpProjectStructure(projectDir, name, hasDb);
343+
// Ask if user wants to create project structure
344+
const createStructureAnswer = await inquirer.prompt([
345+
{
346+
type: 'confirm',
347+
name: 'createStructure',
348+
message: 'Create project structure?',
349+
default: true,
350+
},
351+
]);
352+
const createStructure = createStructureAnswer.createStructure;
347353

354+
// Always create essential files (regardless of create_structure choice)
355+
process.stdout.write(chalk.green('\nCreating essential files...'));
356+
// Always create .gitignore and README.md (append if exists)
357+
createGitignore(projectDir);
358+
createReadmeSection(projectDir, websiteType, name, buildFolder);
359+
360+
if (websiteType === 'php') {
361+
// For PHP: create .env (if database) and .ufazienignore
348362
if (database) {
349363
const username = database.username || '';
350364
const password = database.password || '';
@@ -356,49 +370,61 @@ program
356370
username,
357371
password,
358372
});
359-
createConfigFile(projectDir, {
360-
name: database.name,
361-
host: database.host || 'mysql.ufazien.com',
362-
port: database.port || 3306,
363-
username,
364-
password,
365-
});
366373
console.log(chalk.green('\n✓ Created .env file with database credentials'));
367-
console.log(chalk.green('✓ Created config.php'));
368374
} else {
369375
console.log(chalk.yellow('\n⚠ Skipping .env file creation - database credentials not yet available'));
370-
console.log(chalk.dim('Please create .env manually with database credentials once provisioning completes.'));
371-
createConfigFile(projectDir, {
372-
name: database.name,
373-
host: database.host || 'mysql.ufazien.com',
374-
port: database.port || 3306,
375-
username: '',
376-
password: '',
377-
});
378376
}
379377
}
380-
} else if (websiteType === 'build') {
381-
createBuildProjectStructure(projectDir, name);
382-
} else {
383-
createStaticProjectStructure(projectDir, name);
384-
}
385-
386-
createGitignore(projectDir);
387-
// .ufazienignore not needed for build projects (we zip only the build folder)
388-
if (websiteType !== 'build') {
378+
createUfazienignore(projectDir);
379+
} else if (websiteType === 'static') {
380+
// For Static: create .ufazienignore
389381
createUfazienignore(projectDir);
390382
}
383+
// For Build: no .ufazienignore needed
391384

392-
if (websiteType === 'build') {
393-
console.log(chalk.green('✓ Created project files:'));
394-
console.log(' • README.md (deployment instructions)');
395-
console.log(' • .gitignore');
396-
console.log(' • .ufazien.json');
397-
console.log(chalk.yellow(`\nℹ Build Project Setup:`));
398-
console.log(` 1. Build your project (creates ${buildFolder} folder)`);
399-
console.log(` 2. Run ${chalk.cyan('ufazienjs deploy')} to deploy the ${buildFolder} folder`);
400-
} else {
385+
console.log(chalk.green('✓ Created essential files'));
386+
387+
// Create optional boilerplate files (only if user wants project structure)
388+
if (createStructure) {
389+
process.stdout.write(chalk.green('\nCreating project structure...'));
390+
if (websiteType === 'php') {
391+
const hasDb = database !== null && database.status === 'active';
392+
createPhpProjectStructure(projectDir, name, hasDb);
393+
394+
if (database) {
395+
const username = database.username || '';
396+
const password = database.password || '';
397+
if (username && password) {
398+
createConfigFile(projectDir, {
399+
name: database.name,
400+
host: database.host || 'mysql.ufazien.com',
401+
port: database.port || 3306,
402+
username,
403+
password,
404+
});
405+
console.log(chalk.green('✓ Created config.php'));
406+
} else {
407+
createConfigFile(projectDir, {
408+
name: database.name,
409+
host: database.host || 'mysql.ufazien.com',
410+
port: database.port || 3306,
411+
username: '',
412+
password: '',
413+
});
414+
}
415+
}
416+
} else if (websiteType === 'static') {
417+
createStaticProjectStructure(projectDir, name);
418+
}
419+
// Build projects don't need boilerplate files
420+
401421
console.log(chalk.green('✓ Created project structure'));
422+
423+
if (websiteType === 'build') {
424+
console.log(chalk.yellow(`\nℹ Build Project Setup:`));
425+
console.log(` 1. Build your project (creates ${buildFolder} folder)`);
426+
console.log(` 2. Run ${chalk.cyan('ufazienjs deploy')} to deploy the ${buildFolder} folder`);
427+
}
402428
}
403429

404430
// Save config

ufazien-cli-js/src/project.ts

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,116 @@ build/
164164
}
165165
}
166166

167+
export function createReadmeSection(
168+
projectDir: string,
169+
websiteType: string,
170+
websiteName: string,
171+
buildFolder?: string
172+
): void {
173+
const readmePath = path.join(projectDir, 'README.md');
174+
175+
if (websiteType === 'build') {
176+
if (!fs.existsSync(readmePath)) {
177+
const readmeContent = `# ${websiteName}
178+
179+
This project is configured for deployment to Ufazien Hosting.
180+
181+
## Build and Deploy
182+
183+
1. Build your project (this will create a \`dist\` or \`build\` folder):
184+
\`\`\`bash
185+
npm run build
186+
# or
187+
yarn build
188+
# or
189+
pnpm build
190+
\`\`\`
191+
192+
2. Deploy to Ufazien:
193+
\`\`\`bash
194+
ufazienjs deploy
195+
\`\`\`
196+
197+
The deployment will automatically upload the contents of your build folder.
198+
`;
199+
fs.writeFileSync(readmePath, readmeContent);
200+
} else {
201+
const existingContent = fs.readFileSync(readmePath, 'utf-8');
202+
if (!existingContent.includes('Ufazien Hosting')) {
203+
const ufazienSection = `
204+
205+
---
206+
207+
## Ufazien Deployment
208+
209+
This project is configured for deployment to Ufazien Hosting.
210+
211+
### Build and Deploy
212+
213+
1. Build your project (this will create a \`dist\` or \`build\` folder):
214+
\`\`\`bash
215+
npm run build
216+
# or
217+
yarn build
218+
# or
219+
pnpm build
220+
\`\`\`
221+
222+
2. Deploy to Ufazien:
223+
\`\`\`bash
224+
ufazienjs deploy
225+
\`\`\`
226+
227+
The deployment will automatically upload the contents of your build folder.
228+
`;
229+
fs.appendFileSync(readmePath, ufazienSection);
230+
}
231+
}
232+
} else {
233+
// For PHP and Static projects
234+
if (!fs.existsSync(readmePath)) {
235+
const readmeContent = `# ${websiteName}
236+
237+
This project is configured for deployment to Ufazien Hosting.
238+
239+
## Deploy
240+
241+
Deploy your website to Ufazien:
242+
243+
\`\`\`bash
244+
ufazienjs deploy
245+
\`\`\`
246+
247+
Your website will be available at your configured subdomain.
248+
`;
249+
fs.writeFileSync(readmePath, readmeContent);
250+
} else {
251+
const existingContent = fs.readFileSync(readmePath, 'utf-8');
252+
if (!existingContent.includes('Ufazien Hosting')) {
253+
const ufazienSection = `
254+
255+
---
256+
257+
## Ufazien Deployment
258+
259+
This project is configured for deployment to Ufazien Hosting.
260+
261+
### Deploy
262+
263+
Deploy your website to Ufazien:
264+
265+
\`\`\`bash
266+
ufazienjs deploy
267+
\`\`\`
268+
269+
Your website will be available at your configured subdomain.
270+
`;
271+
fs.appendFileSync(readmePath, ufazienSection);
272+
}
273+
}
274+
}
275+
}
276+
167277
export function createUfazienignore(projectDir: string): void {
168278
const ufazienignoreContent = `# Files and directories to exclude from deployment
169279
.git/

ufazien-cli-py/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "ufazien-cli"
7-
version = "0.2.1"
7+
version = "0.3.0"
88
description = "Command-line interface for deploying web applications on Ufazien platform"
99
readme = "README.md"
1010
requires-python = ">=3.8"

ufazien-cli-py/src/ufazien/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Ufazien CLI - Command-line interface for deploying web applications on Ufazien platform.
33
"""
44

5-
__version__ = "0.2.1"
5+
__version__ = "0.3.0"
66

77
from ufazien.client import UfazienAPIClient
88

ufazien-cli-py/src/ufazien/cli.py

Lines changed: 47 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
create_config_file,
2929
create_env_file,
3030
create_gitignore,
31+
create_readme_section,
3132
create_ufazienignore,
3233
create_php_project_structure,
3334
create_static_project_structure,
@@ -273,12 +274,17 @@ def create(
273274
console.print(f"[red]✗ Error creating database: {e}[/red]")
274275
console.print("[dim]You can create a database later from the web dashboard.[/dim]")
275276

276-
# Create project structure
277-
with console.status("[bold green]Creating project structure...", spinner="dots"):
277+
# Ask if user wants to create project structure
278+
create_structure = Confirm.ask("\nCreate project structure?", default=True)
279+
280+
# Always create essential files (regardless of create_structure choice)
281+
with console.status("[bold green]Creating essential files...", spinner="dots"):
282+
# Always create .gitignore and README.md (append if exists)
283+
create_gitignore(project_dir)
284+
create_readme_section(project_dir, website_type, name, build_folder)
285+
278286
if website_type == 'php':
279-
has_db = database_obj is not None and database_obj.get('status') == 'active'
280-
create_php_project_structure(project_dir, name, has_database=has_db)
281-
287+
# For PHP: create .env (if database) and .ufazienignore
282288
if database_obj:
283289
username = database_obj.get('username', '')
284290
password = database_obj.get('password', '')
@@ -290,39 +296,48 @@ def create(
290296
'username': username,
291297
'password': password
292298
})
293-
create_config_file(project_dir, database_obj)
294299
console.print("[green]✓ Created .env file with database credentials[/green]")
295-
console.print("[green]✓ Created config.php[/green]")
296300
else:
297301
console.print("[yellow]⚠ Skipping .env file creation - database credentials not yet available[/yellow]")
298-
console.print("[dim]Please create .env manually with database credentials once provisioning completes.[/dim]")
299-
create_config_file(project_dir, {
300-
'host': database_obj.get('host', 'mysql.ufazien.com'),
301-
'port': database_obj.get('port', 3306),
302-
'name': database_obj.get('name', ''),
303-
'username': '',
304-
'password': ''
305-
})
306-
elif website_type == 'build':
307-
create_build_project_structure(project_dir, name)
308-
else:
309-
create_static_project_structure(project_dir, name)
310-
311-
create_gitignore(project_dir)
312-
# .ufazienignore not needed for build projects (we zip only the build folder)
313-
if website_type != 'build':
314302
create_ufazienignore(project_dir)
303+
elif website_type == 'static':
304+
# For Static: create .ufazienignore
305+
create_ufazienignore(project_dir)
306+
# For Build: no .ufazienignore needed
315307

316-
if website_type == 'build':
317-
console.print("[green]✓ Created project files:[/green]")
318-
console.print(" • README.md (deployment instructions)")
319-
console.print(" • .gitignore")
320-
console.print(" • .ufazien.json")
321-
console.print(f"\n[yellow]ℹ Build Project Setup:[/yellow]")
322-
console.print(f" 1. Build your project (creates {build_folder} folder)")
323-
console.print(f" 2. Run [cyan]ufazien deploy[/cyan] to deploy the {build_folder} folder")
324-
else:
308+
console.print("[green]✓ Created essential files[/green]")
309+
310+
# Create optional boilerplate files (only if user wants project structure)
311+
if create_structure:
312+
with console.status("[bold green]Creating project structure...", spinner="dots"):
313+
if website_type == 'php':
314+
has_db = database_obj is not None and database_obj.get('status') == 'active'
315+
create_php_project_structure(project_dir, name, has_database=has_db)
316+
317+
if database_obj:
318+
username = database_obj.get('username', '')
319+
password = database_obj.get('password', '')
320+
if username and password:
321+
create_config_file(project_dir, database_obj)
322+
console.print("[green]✓ Created config.php[/green]")
323+
else:
324+
create_config_file(project_dir, {
325+
'host': database_obj.get('host', 'mysql.ufazien.com'),
326+
'port': database_obj.get('port', 3306),
327+
'name': database_obj.get('name', ''),
328+
'username': '',
329+
'password': ''
330+
})
331+
elif website_type == 'static':
332+
create_static_project_structure(project_dir, name)
333+
# Build projects don't need boilerplate files
334+
325335
console.print("[green]✓ Created project structure[/green]")
336+
337+
if website_type == 'build':
338+
console.print(f"\n[yellow]ℹ Build Project Setup:[/yellow]")
339+
console.print(f" 1. Build your project (creates {build_folder} folder)")
340+
console.print(f" 2. Run [cyan]ufazien deploy[/cyan] to deploy the {build_folder} folder")
326341

327342
# Save config
328343
config = {

0 commit comments

Comments
 (0)