Skip to content

Conversation

@AllanRegush
Copy link

@AllanRegush AllanRegush commented Oct 9, 2025

resolves issue #486.

Takes into consideration most of the concerns in the issue. Feedback is welcome.

  • Moved preprocess logic to new
  • .vapor-template is now located in the home directory
  • Only clone template when not using the default otherwise check for updates via git pull
  • Load manifest on "start up" if available for vapor new -h flag generation
  • Check that git is installed/found otherwise print error and exit
  • Only clone the repo with latest commit

Results:

M1 MacBook Air 2020 8GB - on power saving mode

$ time ./vapor -h
OVERVIEW: Vapor Toolbox (Server-side Swift web framework)

USAGE: vapor <subcommand>

OPTIONS:
  --version               Show the version.
  -h, --help              Show help information.

SUBCOMMANDS:
  new (default)           Generates a new app.

  See 'vapor help <subcommand>' for detailed help.
./vapor -h  0.01s user 0.02s system 53% cpu 0.055 total

Reflection generated arguments.

$ time ./vapor new -h 
OVERVIEW: Generates a new app.

USAGE: vapor new [<options>] <name> --fluent --fluent.db <db> --leaf

ARGUMENTS:
  <name>                  Name of project and folder.

BUILD OPTIONS:
  -t, --template <url>    The URL of a Git repository to use as a template. (default:
                          https://github.com/vapor/template)
  --branch <branch>       Template repository branch to use.
  --manifest <file>       The path of the manifest file. (default: manifest.yml)
  -o, --output <path>     The directory to place the new project in.
  --no-commit             Skips adding a first commit to the newly created repo.
  --no-git                Skips adding a Git repository to the project folder.
  -n, --no                Automatically answer no to all questions.
  -v, --verbose           Prints additional information.

OPTIONS:
  --fluent/--no-fluent    Would you like to use Fluent (ORM)?
  --fluent.db <db>        Which database would you like to use? (values: Postgres (Recommended), MySQL, SQLite)
  --leaf/--no-leaf        Would you like to use Leaf (templating)?
  --version               Show the version.
  -h, --help              Show help information.

./vapor new -h  0.01s user 0.04s system 52% cpu 0.090 total

Happy path already cloned

$ time ./vapor new testing -n  
Would you like to use Fluent (ORM)? (--fluent/--no-fluent)
y/n> no
fluent: No
Would you like to use Leaf (templating)? (--leaf/--no-leaf)
y/n> no
leaf: No
Generating project files
Creating git repository
Adding first commit
Project testing has been created!
Use cd 'testing' to enter the project directory
Then open your project, for example if using Xcode type open Package.swift or code . if using VSCode
./vapor new testing -n  0.10s user 0.14s system 18% cpu 1.341 total

New not specified

$ time ./vapor testing12 -n 
Would you like to use Fluent (ORM)? (--fluent/--no-fluent)
y/n> no
fluent: No
Would you like to use Leaf (templating)? (--leaf/--no-leaf)
y/n> no
leaf: No
Generating project files
Creating git repository
Adding first commit
Project testing12 has been created!
Use cd 'testing12' to enter the project directory
Then open your project, for example if using Xcode type open Package.swift or code . if using VSCode
./vapor testing12 -n  0.10s user 0.11s system 30% cpu 0.707 total

Cloning template with only the latest commit

$ time ./vapor new test -n
Cloning template...
Would you like to use Fluent (ORM)? (--fluent/--no-fluent)
y/n> no
fluent: No
Would you like to use Leaf (templating)? (--leaf/--no-leaf)
y/n> no
leaf: No
Generating project files
Creating git repository
Adding first commit
Project test has been created!
Use cd 'test' to enter the project directory
Then open your project, for example if using Xcode type open Package.swift or code . if using VSCode
./vapor new test -n  0.10s user 0.14s system 29% cpu 0.772 total

@codecov
Copy link

codecov bot commented Oct 9, 2025

Codecov Report

❌ Patch coverage is 53.73134% with 31 lines in your changes missing coverage. Please review.
✅ Project coverage is 38.10%. Comparing base (909be1b) to head (aa545a2).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
Sources/VaporToolbox/New.swift 60.00% 24 Missing ⚠️
Sources/VaporToolbox/Vapor.swift 0.00% 6 Missing ⚠️
Sources/VaporToolbox/TemplateRenderer.swift 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #487      +/-   ##
==========================================
- Coverage   39.81%   38.10%   -1.72%     
==========================================
  Files           7        7              
  Lines         648      664      +16     
==========================================
- Hits          258      253       -5     
- Misses        390      411      +21     
Files with missing lines Coverage Δ
Sources/VaporToolbox/TemplateRenderer.swift 10.71% <0.00%> (ø)
Sources/VaporToolbox/Vapor.swift 37.83% <0.00%> (-35.85%) ⬇️
Sources/VaporToolbox/New.swift 14.45% <60.00%> (+14.45%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@fpseverino
Copy link
Member

Hi, thanks for the PR! Unfortunately the CI is failing because we absolutely need the manifest before any code from ArgumentParser is run

There is also an async/await refactor in the works, so it might be worth waiting for that to land as it changes a lot of the functions this PR is touching (and uses the much nicer swift-subprocess APIs)

@AllanRegush
Copy link
Author

Hello,

Sure, we can wait until the other PR lands. Should we close for the time being?

@fpseverino
Copy link
Member

Should we close for the time being?

As you prefer, it's not necessary for me

@fpseverino
Copy link
Member

Hello! Version 20.0.0 has been released, so if you are still interested, you can update the PR. Thank you!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants