Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ufazien-cli-js/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion ufazien-cli-js/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ufazien-cli",
"version": "0.2.1",
"version": "0.3.0",
"type": "module",
"main": "dist/cli.js",
"bin": {
Expand Down
104 changes: 65 additions & 39 deletions ufazien-cli-js/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
createConfigFile,
createEnvFile,
createGitignore,
createReadmeSection,
createUfazienignore,
createPhpProjectStructure,
createStaticProjectStructure,
Expand Down Expand Up @@ -339,12 +340,25 @@ program
}
}

// Create project structure
process.stdout.write(chalk.green('\nCreating project structure...'));
if (websiteType === 'php') {
const hasDb = database !== null && database.status === 'active';
createPhpProjectStructure(projectDir, name, hasDb);
// Ask if user wants to create project structure
const createStructureAnswer = await inquirer.prompt([
{
type: 'confirm',
name: 'createStructure',
message: 'Create project structure?',
default: true,
},
]);
const createStructure = createStructureAnswer.createStructure;

// Always create essential files (regardless of create_structure choice)
process.stdout.write(chalk.green('\nCreating essential files...'));
// Always create .gitignore and README.md (append if exists)
createGitignore(projectDir);
createReadmeSection(projectDir, websiteType, name, buildFolder);

if (websiteType === 'php') {
// For PHP: create .env (if database) and .ufazienignore
if (database) {
const username = database.username || '';
const password = database.password || '';
Expand All @@ -356,49 +370,61 @@ program
username,
password,
});
createConfigFile(projectDir, {
name: database.name,
host: database.host || 'mysql.ufazien.com',
port: database.port || 3306,
username,
password,
});
console.log(chalk.green('\n✓ Created .env file with database credentials'));
console.log(chalk.green('✓ Created config.php'));
} else {
console.log(chalk.yellow('\n⚠ Skipping .env file creation - database credentials not yet available'));
console.log(chalk.dim('Please create .env manually with database credentials once provisioning completes.'));
createConfigFile(projectDir, {
name: database.name,
host: database.host || 'mysql.ufazien.com',
port: database.port || 3306,
username: '',
password: '',
});
}
}
} else if (websiteType === 'build') {
createBuildProjectStructure(projectDir, name);
} else {
createStaticProjectStructure(projectDir, name);
}

createGitignore(projectDir);
// .ufazienignore not needed for build projects (we zip only the build folder)
if (websiteType !== 'build') {
createUfazienignore(projectDir);
} else if (websiteType === 'static') {
// For Static: create .ufazienignore
createUfazienignore(projectDir);
}
// For Build: no .ufazienignore needed

if (websiteType === 'build') {
console.log(chalk.green('✓ Created project files:'));
console.log(' • README.md (deployment instructions)');
console.log(' • .gitignore');
console.log(' • .ufazien.json');
console.log(chalk.yellow(`\nℹ Build Project Setup:`));
console.log(` 1. Build your project (creates ${buildFolder} folder)`);
console.log(` 2. Run ${chalk.cyan('ufazienjs deploy')} to deploy the ${buildFolder} folder`);
} else {
console.log(chalk.green('✓ Created essential files'));

// Create optional boilerplate files (only if user wants project structure)
if (createStructure) {
process.stdout.write(chalk.green('\nCreating project structure...'));
if (websiteType === 'php') {
const hasDb = database !== null && database.status === 'active';
createPhpProjectStructure(projectDir, name, hasDb);

if (database) {
const username = database.username || '';
const password = database.password || '';
if (username && password) {
createConfigFile(projectDir, {
name: database.name,
host: database.host || 'mysql.ufazien.com',
port: database.port || 3306,
username,
password,
});
console.log(chalk.green('✓ Created config.php'));
} else {
createConfigFile(projectDir, {
name: database.name,
host: database.host || 'mysql.ufazien.com',
port: database.port || 3306,
username: '',
password: '',
});
}
}
} else if (websiteType === 'static') {
createStaticProjectStructure(projectDir, name);
}
// Build projects don't need boilerplate files

console.log(chalk.green('✓ Created project structure'));

if (websiteType === 'build') {
console.log(chalk.yellow(`\nℹ Build Project Setup:`));
console.log(` 1. Build your project (creates ${buildFolder} folder)`);
console.log(` 2. Run ${chalk.cyan('ufazienjs deploy')} to deploy the ${buildFolder} folder`);
}
}

// Save config
Expand Down
110 changes: 110 additions & 0 deletions ufazien-cli-js/src/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,116 @@ build/
}
}

export function createReadmeSection(
projectDir: string,
websiteType: string,
websiteName: string,
buildFolder?: string
): void {
const readmePath = path.join(projectDir, 'README.md');

if (websiteType === 'build') {
if (!fs.existsSync(readmePath)) {
const readmeContent = `# ${websiteName}

This project is configured for deployment to Ufazien Hosting.

## Build and Deploy

1. Build your project (this will create a \`dist\` or \`build\` folder):
\`\`\`bash
npm run build
# or
yarn build
# or
pnpm build
\`\`\`

2. Deploy to Ufazien:
\`\`\`bash
ufazienjs deploy
\`\`\`

The deployment will automatically upload the contents of your build folder.
`;
fs.writeFileSync(readmePath, readmeContent);
} else {
const existingContent = fs.readFileSync(readmePath, 'utf-8');
if (!existingContent.includes('Ufazien Hosting')) {
const ufazienSection = `

---

## Ufazien Deployment

This project is configured for deployment to Ufazien Hosting.

### Build and Deploy

1. Build your project (this will create a \`dist\` or \`build\` folder):
\`\`\`bash
npm run build
# or
yarn build
# or
pnpm build
\`\`\`

2. Deploy to Ufazien:
\`\`\`bash
ufazienjs deploy
\`\`\`

The deployment will automatically upload the contents of your build folder.
`;
fs.appendFileSync(readmePath, ufazienSection);
}
}
} else {
// For PHP and Static projects
if (!fs.existsSync(readmePath)) {
const readmeContent = `# ${websiteName}

This project is configured for deployment to Ufazien Hosting.

## Deploy

Deploy your website to Ufazien:

\`\`\`bash
ufazienjs deploy
\`\`\`

Your website will be available at your configured subdomain.
`;
fs.writeFileSync(readmePath, readmeContent);
} else {
const existingContent = fs.readFileSync(readmePath, 'utf-8');
if (!existingContent.includes('Ufazien Hosting')) {
const ufazienSection = `

---

## Ufazien Deployment

This project is configured for deployment to Ufazien Hosting.

### Deploy

Deploy your website to Ufazien:

\`\`\`bash
ufazienjs deploy
\`\`\`

Your website will be available at your configured subdomain.
`;
fs.appendFileSync(readmePath, ufazienSection);
}
}
}
}

export function createUfazienignore(projectDir: string): void {
const ufazienignoreContent = `# Files and directories to exclude from deployment
.git/
Expand Down
2 changes: 1 addition & 1 deletion ufazien-cli-py/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "ufazien-cli"
version = "0.2.1"
version = "0.3.0"
description = "Command-line interface for deploying web applications on Ufazien platform"
readme = "README.md"
requires-python = ">=3.8"
Expand Down
2 changes: 1 addition & 1 deletion ufazien-cli-py/src/ufazien/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Ufazien CLI - Command-line interface for deploying web applications on Ufazien platform.
"""

__version__ = "0.2.1"
__version__ = "0.3.0"

from ufazien.client import UfazienAPIClient

Expand Down
79 changes: 47 additions & 32 deletions ufazien-cli-py/src/ufazien/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
create_config_file,
create_env_file,
create_gitignore,
create_readme_section,
create_ufazienignore,
create_php_project_structure,
create_static_project_structure,
Expand Down Expand Up @@ -273,12 +274,17 @@ def create(
console.print(f"[red]✗ Error creating database: {e}[/red]")
console.print("[dim]You can create a database later from the web dashboard.[/dim]")

# Create project structure
with console.status("[bold green]Creating project structure...", spinner="dots"):
# Ask if user wants to create project structure
create_structure = Confirm.ask("\nCreate project structure?", default=True)

# Always create essential files (regardless of create_structure choice)
with console.status("[bold green]Creating essential files...", spinner="dots"):
# Always create .gitignore and README.md (append if exists)
create_gitignore(project_dir)
create_readme_section(project_dir, website_type, name, build_folder)

if website_type == 'php':
has_db = database_obj is not None and database_obj.get('status') == 'active'
create_php_project_structure(project_dir, name, has_database=has_db)

# For PHP: create .env (if database) and .ufazienignore
if database_obj:
username = database_obj.get('username', '')
password = database_obj.get('password', '')
Expand All @@ -290,39 +296,48 @@ def create(
'username': username,
'password': password
})
create_config_file(project_dir, database_obj)
console.print("[green]✓ Created .env file with database credentials[/green]")
console.print("[green]✓ Created config.php[/green]")
else:
console.print("[yellow]⚠ Skipping .env file creation - database credentials not yet available[/yellow]")
console.print("[dim]Please create .env manually with database credentials once provisioning completes.[/dim]")
create_config_file(project_dir, {
'host': database_obj.get('host', 'mysql.ufazien.com'),
'port': database_obj.get('port', 3306),
'name': database_obj.get('name', ''),
'username': '',
'password': ''
})
elif website_type == 'build':
create_build_project_structure(project_dir, name)
else:
create_static_project_structure(project_dir, name)

create_gitignore(project_dir)
# .ufazienignore not needed for build projects (we zip only the build folder)
if website_type != 'build':
create_ufazienignore(project_dir)
elif website_type == 'static':
# For Static: create .ufazienignore
create_ufazienignore(project_dir)
# For Build: no .ufazienignore needed

if website_type == 'build':
console.print("[green]✓ Created project files:[/green]")
console.print(" • README.md (deployment instructions)")
console.print(" • .gitignore")
console.print(" • .ufazien.json")
console.print(f"\n[yellow]ℹ Build Project Setup:[/yellow]")
console.print(f" 1. Build your project (creates {build_folder} folder)")
console.print(f" 2. Run [cyan]ufazien deploy[/cyan] to deploy the {build_folder} folder")
else:
console.print("[green]✓ Created essential files[/green]")

# Create optional boilerplate files (only if user wants project structure)
if create_structure:
with console.status("[bold green]Creating project structure...", spinner="dots"):
if website_type == 'php':
has_db = database_obj is not None and database_obj.get('status') == 'active'
create_php_project_structure(project_dir, name, has_database=has_db)

if database_obj:
username = database_obj.get('username', '')
password = database_obj.get('password', '')
if username and password:
create_config_file(project_dir, database_obj)
console.print("[green]✓ Created config.php[/green]")
else:
create_config_file(project_dir, {
'host': database_obj.get('host', 'mysql.ufazien.com'),
'port': database_obj.get('port', 3306),
'name': database_obj.get('name', ''),
'username': '',
'password': ''
})
elif website_type == 'static':
create_static_project_structure(project_dir, name)
# Build projects don't need boilerplate files

console.print("[green]✓ Created project structure[/green]")

if website_type == 'build':
console.print(f"\n[yellow]ℹ Build Project Setup:[/yellow]")
console.print(f" 1. Build your project (creates {build_folder} folder)")
console.print(f" 2. Run [cyan]ufazien deploy[/cyan] to deploy the {build_folder} folder")

# Save config
config = {
Expand Down
Loading