Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New project creation command #2799

Open
wants to merge 21 commits into
base: main
Choose a base branch
from

Conversation

BenPH
Copy link
Contributor

@BenPH BenPH commented Mar 23, 2022

This adds a Julia: Create New Project command that takes you through a series of prompts to get the fields needed to create a new project using PkgTemplates. This is a similar experience to calling PkgTemplates.Template(interactive=true).

Any suggestions are appreciated!

Ref #2447

Here's what running the command looks like

ProjectCreateStart.mov

Alternatively, you can choose to define the details of the template yourself

Screen.Recording.2023-02-14.at.8.24.20.AM.mov

Then after a bit of thinking PkgTemplates generates the package

ProjectCreateEnd.mov

@davidanthoff davidanthoff added this to the Next Minor milestone Mar 23, 2022
@davidanthoff
Copy link
Member

Very nice!

We handle Julia env/packages in two ways. For some things (that we consider really core) we ship all required packages as submodules, and then use a Julia environment where all non stdlib packages are deved. For those env, we never need to instantiate and there is never a need to download anything. For other things, we use more standard env, and then just instantiate them at the beginning of the Julia script, https://github.com/julia-vscode/julia-vscode/blob/master/scripts/packagedev/tagnewpackageversion.jl is an example of that.

I think this PR here introduces a mixed case, where PkgTemplates.jl is a submodule, but the env that is used still has things that we don't ship and therefore it needs to be instantiated before use. I think this should fall into either category, though. Given how many deps this whole thing has, I'm probably in favor of not doing this via the submodule route, but instead just put everything into the manifest like a normal package, and then make sure that at the beginning of the Julia script the project gets instantiated. Does that make sense?

One other thing is that we already have some limited support for the package butler stuff in the extension, and it would be nice if we would have a new project story that is coherent with that... I'm not entirely sure at the moment what the best way to do that would be... One option is probably to just add support for package butler controlled packages to PkgTemplates.jl, but I'll need to think about it a bit more.

return

// TODO: add gihub.user as placeholder
const user = await vscode.window.showInputBox({
Copy link
Member

Choose a reason for hiding this comment

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

Can we also get that from the built-in VS Code authentication stuff?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I found that you can access the global git config through vscode's git api but it requires a repository to exist already which doesn't make a lot of sense here.

const extension = vscode.extensions.getExtension<GitExtension>('vscode.git')
if (extension == null && extension.isActive) {
    const gitExtension = extension.exports
    const api = gitExtension?.getAPI(1)
    const user = await api.repositories[0].getGlobalConfig('github.user')
}

There's simple-git that does the job. Does it make sense to add a dependency?

if (user === undefined)
return

let juliaVersion = await vscode.window.showQuickPick(
Copy link
Member

Choose a reason for hiding this comment

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

Can we have a good default here?

Copy link
Contributor Author

@BenPH BenPH Mar 24, 2022

Choose a reason for hiding this comment

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

1.6? Or the user's current version? If it's left blank PkgTemplates will use whatever major version that runs the script. That could be the default.

{ label: 'GitLabCI', picked: false },
{ label: 'PkgEvalBadge', picked: false },
{ label: 'RegisterAction', picked: false },
{ label: 'TravisCI', picked: false }
Copy link
Member

Choose a reason for hiding this comment

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

Is there a way to provide more descriptions? This is probably pretty hard to understand for a newcomer.

@davidanthoff
Copy link
Member

One other thought: might it make sense to have a "short" and simple default UI path here? Say it first asks for the name of the project, and then just whether one wants to configure advanced options. If a user picks the advanced stuff, all the other questions come up, but otherwise it just goes with good defaults?

@BenPH
Copy link
Contributor Author

BenPH commented Mar 24, 2022

Given how many deps this whole thing has, I'm probably in favor of not doing this via the submodule route, but instead just put everything into the manifest like a normal package, and then make sure that at the beginning of the Julia script the project gets instantiated. Does that make sense?

That makes sense. Thanks for clearing that up.

One other thought: might it make sense to have a "short" and simple default UI path here? Say it first asks for the name of the project, and then just whether one wants to configure advanced options. If a user picks the advanced stuff, all the other questions come up, but otherwise it just goes with good defaults?

Good idea! If you call Template() with no kwargs it gives a pretty suitable default. I'll put together some changes.

drops any plugins that require it
@BenPH
Copy link
Contributor Author

BenPH commented Aug 13, 2022

@davidanthoff Could you have another look when you get the chance? I've cleaned it up with your suggestions and am pretty happy with it now.

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.

None yet

2 participants