Skip to content

feat: create new project based on templates - #160

Open
felipesantos2 wants to merge 7 commits into
flock-php:mainfrom
felipesantos2:main
Open

felipesantos2 wants to merge 7 commits into
flock-php:mainfrom
felipesantos2:main

Conversation

@felipesantos2

@felipesantos2 felipesantos2 commented Nov 11, 2026 •

Copy link
Copy Markdown

Quick Create Project (Windows-first)

Issue #150


Added a quick way to start new projects in Flock from both the terminal and the Windows app, inspired by Laragon's simplicity. Instead of hardcoding project setups, templates live in a plain apps.conf file that's easy to extend or customize.

From the terminal (flock app create)

  • flock app create my-app -- creates a starter PHP project (index.php) and links my-app.test
  • flock app create my-app --type blank -- creates an empty folder and links it
  • flock app create my-app --type wordpress -- downloads and extracts WordPress, creates a database in your running MySQL or MariaDB, fills in wp-config.php, and links the site
  • flock app create my-app --type wordpress --db-service mariadb -- lets you pick MySQL or MariaDB explicitly (also supports --db, --php, and --secure)

You can add new templates or override download links without rebuilding by placing an apps.conf file in Flock's data folder (%AppData%\Flock\apps.conf on Windows).

From the Windows app

  • Added a New App… button under Sites that opens a simple dialog to choose the project name, template, target folder, database option, and HTTPS.
  • This release is Windows-first for the desktop UI, so the macOS and Linux apps were left untouched for now.

Pending: UI for Mac and Linux


Personal Note:

Please review the DIFF, and let me know if you have any questions.

@lukas-frey

Copy link
Copy Markdown
Member

Hi @felipesantos2, thanks for the PR!

We only merge features once they're in all three apps, so this also needs the Mac and Linux UI. Happy to keep it open until those are added, by you or someone else. :)

@felipesantos2

felipesantos2 commented Nov 11, 2026 •

Copy link
Copy Markdown
Author

Ok, I'll take care of the Linux version first and then look into what needs to be done for Mac.

felipesantos2 and others added 2 commits November 15, 2026 19:24
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

@onairmarc onairmarc left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

windows daemon tests are failing

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Unresolved creation conflicts and concurrency races can leave projects partially configured, replace existing directories, and overwrite concurrent site or settings changes.

5 open issues
What changed in this PR

Adds template-based project creation to Flock, addressing issue #150 with configurable starters, optional database setup, and automatic site linking.

Changes:

  • Adds flock app create, shared creation logic, and API endpoints backed by customizable apps.conf templates.
  • Adds New App dialogs and client support on Windows, macOS, and Linux.
  • Adds creation and client tests, CLI documentation, and Linux development instructions.
File Description
windows/​Flock.Tray/​Settings/​SitesPane.xaml.cs Adds the creation dialog and progress handling.
windows/​Flock.Tray/​Settings/​SitesPane.xaml Adds New App buttons and progress indicators.
windows/​Flock.Tray/​Features/​Sites/​SitesService.cs Connects template loading and creation to UI operations.
windows/​Flock.Kit/​Models.cs Adds template response models.
windows/​Flock.Kit/​FlockClient.cs Adds template and creation API calls.
windows/​Flock.Kit.Tests/​ClientTests.cs Tests requests, payloads, and creation timeout.
README.md Expands Linux build, test, and run instructions.
macos/​Tests/​FlockKitTests/​ClientTests.swift Tests template loading and creation requests.
macos/​Sources/​FlockUI/​Settings/​SitesPane.swift Adds the New App sheet and creation flow.
macos/​Sources/​FlockKit/​Models.swift Adds template and creation request models.
macos/​Sources/​FlockKit/​Client.swift Adds template and creation API calls.
linux/​src/​panes/​sites.rs Adds the creation dialog, progress, and helper tests.
linux/​src/​api.rs Adds API methods, models, and serialization tests.
internal/​cli/​root.go Registers the app command.
internal/​cli/​passthrough_linux_test.go Checks app commands bypass PHP passthrough.
internal/​cli/​app.go Implements flock app create and its options.
internal/​cli/​app_test.go Tests creation, validation, conflicts, and database handling.
internal/​apps/​apps.go Implements templates, project creation, and WordPress configuration.
internal/​apps/​apps.conf Defines blank, PHP, and WordPress templates.
internal/​apps/​apps_test.go Tests template parsing, overrides, and WordPress configuration.
internal/​api/​appsapi.go Exposes template listing and project creation endpoints.
internal/​api/​appsapi_test.go Tests endpoint success and rejection cases.
internal/​api/​api.go Registers the application endpoints.
docs/​cli.md Documents creation commands and template customization.

Review effort: Balanced

Comment thread internal/api/appsapi.go Resolved
Comment thread internal/apps/apps.go
return err
}
_ = os.Chmod(tmpDir, 0o755)
if err := os.Rename(tmpDir, path); err != nil {
Comment thread internal/cli/app.go Outdated
Comment on lines +61 to +64
if err := s.cfg.Upsert(site); err != nil {
return err
}
if err := s.commit(ctx, cmd.ErrOrStderr()); err != nil {
Allow SaveSite to overwrite the parked entry discovered at the newly created path while still rejecting linked sites or entries at other paths, and add a parked-parent test.
Reload config.json after template download/setup before checking conflicts and committing, avoiding overwriting concurrent changes.
Return a success boolean from SettingsStore.perform and preserve any mutation error after refresh(), gating New App selection on that outcome.
Catch AppTemplatesAsync failures in NewAppAsync and show a ContentDialog instead of failing silently.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread internal/cli/app.go
Comment on lines +65 to +67
if existing, ok := latest.FindSite(site.Name); ok && (!existing.Parked || filepath.Clean(existing.Path) != filepath.Clean(site.Path)) {
return fmt.Errorf("project created at %s, but a site named %q already exists", site.Path, site.Name)
}
Comment thread linux/src/panes/sites.rs
Comment on lines +406 to +417
let this = self.clone();
glib::spawn_future_local(async move {
let templates = match gio::spawn_blocking(|| Client.app_templates()).await.expect("templates request") {
Ok(list) if !list.is_empty() => list,
Err(Error::Server { status: 404, .. }) | Ok(_) => default_app_templates(),
Err(e) => {
report(&this.banner, Some(e.to_string()));
return;
}
};
this.show_new_app_dialog(templates);
});
Comment thread linux/src/panes/sites.rs
Comment on lines +474 to +478
let (name, folder, template_row) = (name.clone(), folder.clone(), template_row.clone());
let (db_row, db_service_row, secured_row) = (db_row.clone(), db_service_row.clone(), secured_row.clone());
let tld = tld.clone();
move || {
let Some(dialog) = weak.upgrade() else { return };
Comment on lines +1297 to +1298
guard !creatingAppState.wrappedValue else { return }
Task {
Comment on lines +391 to +393
var scheme = securedCheck.IsChecked == true ? "https" : "http";
preview.Text = dialog.IsPrimaryButtonEnabled
? $"{Path.Combine(rawFolder, rawName)} → {scheme}://{rawName.ToLowerInvariant().Replace(' ', '-')}.{tld}"

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread internal/apps/apps.go
Comment on lines +159 to +161
if folder == "" || folder == "." || folder == ".." ||
strings.ContainsAny(folder, `/\:`) || strings.TrimSpace(folder) != folder ||
strings.HasSuffix(folder, ".") || name == "" || len(name) > 63 {
Comment on lines +79 to +81
Button("New App…") { openNewAppSheet() }
.disabled(creatingAppState.wrappedValue)
.help("Create a new project from a template and link it as a site")
…Windows

Tested and verified with the full Go test suite on Windows (PowerShell):

- Increase freePort retry limit from 20 to 500 in daemon and web tests so sequential ephemeral TCP port allocation can step past 100-port Hyper-V/WSL excluded UDP/TCP port ranges on Windows.

- Close the done channel in startDaemon and increase readiness timeout to 15s to prevent cleanup deadlocks on early daemon exit and false timeouts when netstat/tasklist run under parallel test load on Windows.

- Call requireSymlinks(t) in TestCloneTreeCopiesFilesModesAndSymlinks so the test skips cleanly on Windows when Developer Mode or admin privileges are not enabled.

- Register t.Cleanup(m.StopAll) in TestManagerRunsOneSetupPerWorktreeAndJoinsIt so worktree log files are closed before TempDir removal on Windows.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants