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

Integrate ./mill init with the example projects (500USD Bounty) #3548

Closed
lihaoyi opened this issue Sep 15, 2024 · 9 comments
Closed

Integrate ./mill init with the example projects (500USD Bounty) #3548

lihaoyi opened this issue Sep 15, 2024 · 9 comments
Labels
Milestone

Comments

@lihaoyi
Copy link
Member

lihaoyi commented Sep 15, 2024


From the maintainer Li Haoyi: I'm putting a 500USD bounty on this issue, payable by bank transfer on a merged PR implementing this.


Mill's example/ folder projects are all zipped up and published for download with every release, and form a far more comprehensive and richly documented set of project templates than is available on giter8. We should update ./mill init to prioritize using these examples as getting started templates for users using ./mill init. We can continue to support giter8 if we want, but I expect the built in example templates will be what people want 99% of the time and render external giter8 templates largely unnecessary.

Success criteria:

  • When you run ./mill init without any argument, it shows the user a list of all the Mill example/ projects, grouped and organized in some meaningful way
  • The user can then select one of those example projects (e.g. by typing in its number in the list, or its path e.g. javalib/basic/1-simple) and Mill will download the project from the Mill Releases page and unpack it into the local directory
  • The user can also pass in the path of the example as an argument, and as long as it matches one of the accepted example paths, Mill will download and unpack the example zip rather than use giter8

The list of valid examples can vary between Mill versions, and should be computed at build time as a resource generator and bundled together with Mill during creation of its dist.assembly.

@lihaoyi lihaoyi changed the title Integrate ./mill init with the example projects Integrate ./mill init with the example projects (500USD Bounty) Sep 15, 2024
@lihaoyi lihaoyi added the bounty label Sep 15, 2024
@pawelsadlo
Copy link
Contributor

does it need to run interactively, prompting example number just like init is working now?
or its ok to ask user to run ./mill init [number or path of example]

@lihaoyi
Copy link
Member Author

lihaoyi commented Sep 19, 2024

@pawelsadlo no need interactivly for now, AFAIK mill init today is non interactive:

$ ./mill init
Creating a new project...
Error: Missing argument <template>
Try --help for more information.

I think it would be fine just to print out a big list of potential templates and then ask the user to copy paste the one they want for now. Once all the example templates are all wired up and in place, we can separately look at tweaking the CLI experience

@pawelsadlo
Copy link
Contributor

Ah right , the g8 template generation is interactive, not the init command.
Anyway can mill command even be interactive without running creating a subprocess?

@lihaoyi
Copy link
Member Author

lihaoyi commented Sep 19, 2024

./mill -i does allow interactive stuff, like console. Even without a subprocess you can do the same thing and read/write from stdin/stdout

@lefou
Copy link
Member

lefou commented Sep 19, 2024

For the purpose of copy-and-paste in tutorials and readmes, it would be nice when mill init can be used non-interactively.

@llvee
Copy link

llvee commented Sep 23, 2024

@pawelsadlo
Did you complete this? If not maybe I will attempt this in 24 hours from now.

@pawelsadlo
Copy link
Contributor

@llvee
it's done ,I'm just adding some tests

@llvee
Copy link

llvee commented Sep 23, 2024

@pawelsadlo let me know if you'd like some help with test writing.

lihaoyi added a commit that referenced this issue Sep 30, 2024
implements #3548 
Modifying init to fetch examples from releases page instead of using g8
template

This introduces new top-level module `initmodule`
this module generates resource `exampleList.txt` containing json with
array of pairs `(exampleId,exampleUrl)`
`exampleId` and `exampleUrl` are formed based on already present
`exampleZips` target, and `millVersion()`.

initmodule introduces external module `MillInitModule`
calls to` mill init ` are redirected to `MillInitModule.init` (basically
the same logic as it was with `Giter8Module.init`)

`MillInitModule.init` called without parameters prints message
containing `exampleids` list based on generated exampleList.txt in the
form of:

```
Run init with one of the following examples as an argument to download and extract example:
depth/cross/1-simple
depth/cross/2-cross-source-path
...
```
When called with a parameter it validates if passed parameter is in the
list, and if so, it downloads example from github releases page and
unpacks it into the directory from where the command was run.

---------

Co-authored-by: Li Haoyi <haoyi.sg@gmail.com>
@lihaoyi lihaoyi closed this as completed Sep 30, 2024
@lefou lefou added this to the 0.12.0-RC3 milestone Sep 30, 2024
@lefou
Copy link
Member

lefou commented Sep 30, 2024

I think accepting a --mill-version option to choose the version from which we take the examples from might be a good idea. This can be helpful in cases where the Mill version isn't exactly the one providing the wanted examples.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants