swiftlang / vscode-swift

Visual Studio Code Extension for Swift
https://marketplace.visualstudio.com/items?itemName=sswg.swift-lang
Apache License 2.0
743 stars 51 forks source link

Create new project command #754

Closed matthewbastien closed 5 months ago

matthewbastien commented 5 months ago

Is your feature request related to a problem? Please describe. This isn't related to a specific problem per-se. However, extensions for other languages such as Dart provide commands as a nice entry point into creating a new project. E.g. for Dart you can run the command Dart: New Project which will take you through a set of steps to create a new project based on a specific template:

dart_new_project_wizard

VSCode's built-in git integration has a similar workflow for cloning repositories from GitHub using Git: Clone.

Describe the solution you'd like The Swift extension could provide a command to create a new project. The command would require the user to select a project template, a folder to create the project in, and a name for the project. It would then use Swift Package Manager to create the actual project on disk and open it within VSCode automatically.

Describe alternatives you've considered The only alternative would be to invoke Swift Package Manager manually in the terminal.

Additional context Swift Package Manager provides a command that can initialize a new project:

swift package init --type <type> --name <name>

The list of project types is available via the --help option:

❯ swift package init --help
OVERVIEW: Initialize a new package

USAGE: swift package init [--type <type>] [--name <name>]

OPTIONS:
  --type <type>           Package type: (default: library)
        library           - A package with a library.
        executable        - A package with an executable.
        tool              - A package with an executable that uses
                            Swift Argument Parser. Use this template if you
                            plan to have a rich set of command-line arguments.
        build-tool-plugin - A package that vends a build tool plugin.
        command-plugin    - A package that vends a command plugin.
        macro             - A package that vends a macro.
        empty             - An empty package with a Package.swift manifest.
  --name <name>           Provide custom package name
  --version               Show the version.
  -h, -help, --help       Show help information.
adam-fowler commented 5 months ago

Sounds good.

I have a little helper which might help with constructing of the menus https://github.com/swift-server/vscode-swift/blob/main/src/ui/QuickPick.ts