pub struct ProjectGenerator { /* private fields */ }Implementations§
Source§impl ProjectGenerator
impl ProjectGenerator
Sourcepub fn discover(start: impl AsRef<Path>) -> Result<Self, ScaffoldError>
pub fn discover(start: impl AsRef<Path>) -> Result<Self, ScaffoldError>
Locate the Phoenix project containing start.
§Errors
Returns an error when no parent contains the expected Phoenix layout.
pub fn root(&self) -> &Path
Sourcepub fn refresh_types(&self) -> Result<bool, ScaffoldError>
pub fn refresh_types(&self) -> Result<bool, ScaffoldError>
Refresh generated TypeScript contracts after a Rust generator runs.
Returns Ok(false) before JavaScript dependencies are installed; Vite
will still generate the files when development starts.
§Errors
Returns an error when the installed Phoenix Vite generator fails.
Sourcepub fn controller(
&self,
name: &str,
options: ControllerOptions,
) -> Result<Vec<PathBuf>, ScaffoldError>
pub fn controller( &self, name: &str, options: ControllerOptions, ) -> Result<Vec<PathBuf>, ScaffoldError>
Generate a controller and optionally its conventional resource route.
§Errors
Returns an error for invalid names, conflicts, or malformed managed files.
Sourcepub fn model(
&self,
name: &str,
options: ModelOptions,
) -> Result<Vec<PathBuf>, ScaffoldError>
pub fn model( &self, name: &str, options: ModelOptions, ) -> Result<Vec<PathBuf>, ScaffoldError>
Generate a Toasty model and any requested companion artifacts.
--all creates the currently supported cohesive business slice: model,
migration, request, API resource, resource controller/route, and index page.
§Errors
Returns an error for invalid names, conflicts, or malformed managed files.
Sourcepub fn migration(
&self,
name: &str,
options: GenerateOptions,
) -> Result<Vec<PathBuf>, ScaffoldError>
pub fn migration( &self, name: &str, options: GenerateOptions, ) -> Result<Vec<PathBuf>, ScaffoldError>
Generate one migration and register it in database/migrations/mod.rs.
§Errors
Returns an error for invalid names, conflicts, time, or managed files.
Sourcepub fn request(
&self,
name: &str,
options: GenerateOptions,
) -> Result<Vec<PathBuf>, ScaffoldError>
pub fn request( &self, name: &str, options: GenerateOptions, ) -> Result<Vec<PathBuf>, ScaffoldError>
Generate a validated request DTO and update its Rust module.
§Errors
Returns an error for invalid names, conflicts, or malformed managed files.
Sourcepub fn resource(
&self,
name: &str,
options: GenerateOptions,
) -> Result<Vec<PathBuf>, ScaffoldError>
pub fn resource( &self, name: &str, options: GenerateOptions, ) -> Result<Vec<PathBuf>, ScaffoldError>
Generate a browser-safe API resource and update its Rust module.
§Errors
Returns an error for invalid names, conflicts, or malformed managed files.
Sourcepub fn middleware(
&self,
name: &str,
options: GenerateOptions,
) -> Result<Vec<PathBuf>, ScaffoldError>
pub fn middleware( &self, name: &str, options: GenerateOptions, ) -> Result<Vec<PathBuf>, ScaffoldError>
Generate a pass-through middleware ready for application logic.
§Errors
Returns an error for invalid names, conflicts, or malformed managed files.
Sourcepub fn page(
&self,
name: &str,
options: GenerateOptions,
) -> Result<Vec<PathBuf>, ScaffoldError>
pub fn page( &self, name: &str, options: GenerateOptions, ) -> Result<Vec<PathBuf>, ScaffoldError>
Generate a React page plus its Rust Page Props contract.
§Errors
Returns an error for invalid names, conflicts, or malformed managed files.
Sourcepub fn island(
&self,
name: &str,
options: GenerateOptions,
) -> Result<Vec<PathBuf>, ScaffoldError>
pub fn island( &self, name: &str, options: GenerateOptions, ) -> Result<Vec<PathBuf>, ScaffoldError>
Generate a React Island component.
§Errors
Returns an error for invalid names, conflicts, or file-system failures.
Sourcepub fn command(
&self,
name: &str,
options: GenerateOptions,
) -> Result<Vec<PathBuf>, ScaffoldError>
pub fn command( &self, name: &str, options: GenerateOptions, ) -> Result<Vec<PathBuf>, ScaffoldError>
Generate a console command and register it in app/commands/mod.rs.
§Errors
Returns an error for invalid names, conflicts, or malformed managed files.
Sourcepub fn add_feature(
&self,
feature: ProjectFeature,
) -> Result<FeatureAddResult, ScaffoldError>
pub fn add_feature( &self, feature: ProjectFeature, ) -> Result<FeatureAddResult, ScaffoldError>
Enable one official Feature in an existing Phoenix project.
The command writes only the requested Feature’s TOML starter, preserves
existing environment examples, and refreshes the generated FeatureSet
assembly only when the project already opted into that scaffold pattern.
§Errors
Returns an error when project metadata or Cargo.toml cannot be read or written.
Sourcepub fn auth(
&self,
options: GenerateOptions,
) -> Result<Vec<PathBuf>, ScaffoldError>
pub fn auth( &self, options: GenerateOptions, ) -> Result<Vec<PathBuf>, ScaffoldError>
Generate the authentication starter kit (px make:auth).
Creates named login / logout / register / password-reset routes with a
stricter rate limit, an AuthController, validated request contracts,
browser-safe resources, page props, and React form pages.
§Errors
Returns an error for conflicts or malformed managed files.
Sourcepub fn update_core(
&self,
options: &UpdateProjectOptions,
) -> Result<Vec<PathBuf>, ScaffoldError>
pub fn update_core( &self, options: &UpdateProjectOptions, ) -> Result<Vec<PathBuf>, ScaffoldError>
Refresh framework-owned core files without touching business code.
Updates src/lib.rs / src/main.rs, Vite/TS config, config schemas, dependency
pins for phoenixrs / @apizero/*, and (when the project uses a database)
src/bin/phoenix-manage.rs. Leaves controllers, routes, pages, and user TOML alone.
§Errors
Returns an error for invalid local framework roots, I/O failures, or npm failures.