Skip to content

Commit

Permalink
fix: init and new command minor fixes (#3806)
Browse files Browse the repository at this point in the history
Also add a readme to help people get started with the project.
  • Loading branch information
stuartwdouglas authored Dec 18, 2024
1 parent 55c0654 commit b9f8209
Show file tree
Hide file tree
Showing 39 changed files with 62 additions and 10 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ diff -u <(
mkdir myproject
cd myproject
ftl init myproject .
ftl new go . alice
ftl new go alice
```

### Build and deploy the module
Expand Down
6 changes: 3 additions & 3 deletions docs/content/docs/getting-started/quick-start/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ Now that you have an FTL project, create a new module:

<!-- go -->
```
ftl new go . alice
ftl new go alice
```
This will place the code for the new module `alice` in `myproject/alice/alice.go`:

Expand Down Expand Up @@ -114,7 +114,7 @@ Each module is its own Go module.

<!-- kotlin -->
```
ftl new kotlin . alice
ftl new kotlin alice
```

This will create a new Maven `pom.xml` based project in the directory `alice` and create new example code in `alice/src/main/kotlin/com/example/EchoVerb.kt`:
Expand All @@ -132,7 +132,7 @@ fun echo(req: String): String = "Hello, $req!"
```
<!-- java -->
```
ftl new java . alice
ftl new java alice
```
This will create a new Maven `pom.xml` based project in the directory `alice` and create new example code in `alice/src/main/java/com/example/EchoVerb.java`:

Expand Down
8 changes: 7 additions & 1 deletion frontend/cli/cmd_init.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (

type initCmd struct {
Name string `arg:"" help:"Name of the project."`
Hermit bool `help:"Include Hermit language-specific toolchain binaries." negatable:""`
Hermit bool `help:"Include Hermit language-specific toolchain binaries." negatable:"" default:"true"`
Dir string `arg:"" help:"Directory to initialize the project in." default:"." required:""`
ModuleDirs []string `help:"Child directories of existing modules."`
ModuleRoots []string `help:"Root directories of existing modules."`
Expand Down Expand Up @@ -80,6 +80,12 @@ func (i initCmd) Run(
if err := maybeGitAdd(ctx, i.Dir, ".ftl-project"); err != nil {
return fmt.Errorf("git add .ftl-project: %w", err)
}
if err := maybeGitAdd(ctx, i.Dir, "ftl-project.toml"); err != nil {
return fmt.Errorf("git add ftl-project.toml: %w", err)
}
if err := maybeGitAdd(ctx, i.Dir, "README.md"); err != nil {
return fmt.Errorf("git add README.md: %w", err)
}
}
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion frontend/cli/cmd_new.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ import (

type newCmd struct {
Language string `arg:"" help:"Language of the module to create."`
Dir string `arg:"" help:"Directory to initialize the module in."`
Name string `arg:"" help:"Name of the FTL module to create underneath the base directory."`
Dir string `arg:"" help:"Directory to initialize the module in." default:"${gitroot}"`
}

// prepareNewCmd adds language specific flags to kong
Expand Down
2 changes: 1 addition & 1 deletion internal/integration/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ func Build(modules ...string) Action {
// FtlNew creates a new FTL module
func FtlNew(language, name string) Action {
return func(t testing.TB, ic TestContext) {
err := ftlexec.Command(ic, log.Debug, ic.workDir, "ftl", "new", language, ic.workDir, name).RunBuffered(ic)
err := ftlexec.Command(ic, log.Debug, ic.workDir, "ftl", "new", language, name, ic.workDir).RunBuffered(ic)
assert.NoError(t, err)
}
}
Expand Down
14 changes: 14 additions & 0 deletions internal/projectinit/scaffolding/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Welcome to your new FTL Project!

Now you have a project you can start to add modules.
You can add a new Kotlin module called `hello` by running one of the
language specific commands below:

```shell
ftl new kotlin hello
ftl new go hello
ftl new java hello
```

For more information on how to get started and what to do next please
checkout the [FTL documentation](https://block.github.io/ftl/).
1 change: 1 addition & 0 deletions internal/projectinit/scaffolding/bin/.maven-3.9.9.pkg
1 change: 1 addition & 0 deletions internal/projectinit/scaffolding/bin/[email protected]
1 change: 1 addition & 0 deletions internal/projectinit/scaffolding/bin/jar
1 change: 1 addition & 0 deletions internal/projectinit/scaffolding/bin/jarsigner
1 change: 1 addition & 0 deletions internal/projectinit/scaffolding/bin/java
1 change: 1 addition & 0 deletions internal/projectinit/scaffolding/bin/javac
1 change: 1 addition & 0 deletions internal/projectinit/scaffolding/bin/javadoc
1 change: 1 addition & 0 deletions internal/projectinit/scaffolding/bin/javap
1 change: 1 addition & 0 deletions internal/projectinit/scaffolding/bin/jcmd
1 change: 1 addition & 0 deletions internal/projectinit/scaffolding/bin/jconsole
1 change: 1 addition & 0 deletions internal/projectinit/scaffolding/bin/jdb
1 change: 1 addition & 0 deletions internal/projectinit/scaffolding/bin/jdeprscan
1 change: 1 addition & 0 deletions internal/projectinit/scaffolding/bin/jdeps
1 change: 1 addition & 0 deletions internal/projectinit/scaffolding/bin/jfr
1 change: 1 addition & 0 deletions internal/projectinit/scaffolding/bin/jhsdb
1 change: 1 addition & 0 deletions internal/projectinit/scaffolding/bin/jimage
1 change: 1 addition & 0 deletions internal/projectinit/scaffolding/bin/jinfo
1 change: 1 addition & 0 deletions internal/projectinit/scaffolding/bin/jlink
1 change: 1 addition & 0 deletions internal/projectinit/scaffolding/bin/jmap
1 change: 1 addition & 0 deletions internal/projectinit/scaffolding/bin/jmod
1 change: 1 addition & 0 deletions internal/projectinit/scaffolding/bin/jpackage
1 change: 1 addition & 0 deletions internal/projectinit/scaffolding/bin/jps
1 change: 1 addition & 0 deletions internal/projectinit/scaffolding/bin/jrunscript
1 change: 1 addition & 0 deletions internal/projectinit/scaffolding/bin/jshell
1 change: 1 addition & 0 deletions internal/projectinit/scaffolding/bin/jstack
1 change: 1 addition & 0 deletions internal/projectinit/scaffolding/bin/jstat
1 change: 1 addition & 0 deletions internal/projectinit/scaffolding/bin/jstatd
1 change: 1 addition & 0 deletions internal/projectinit/scaffolding/bin/keytool
1 change: 1 addition & 0 deletions internal/projectinit/scaffolding/bin/mvn
1 change: 1 addition & 0 deletions internal/projectinit/scaffolding/bin/mvnDebug
1 change: 1 addition & 0 deletions internal/projectinit/scaffolding/bin/rmiregistry
1 change: 1 addition & 0 deletions internal/projectinit/scaffolding/bin/serialver
6 changes: 3 additions & 3 deletions jvm-runtime/jvm_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ func TestLifecycleJVM(t *testing.T) {
in.WithDevMode(),
in.GitInit(),
in.Exec("rm", "ftl-project.toml"),
in.Exec("ftl", "init", "test", "."),
in.IfLanguage("java", in.Exec("ftl", "new", "java", ".", "echo")),
in.IfLanguage("kotlin", in.Exec("ftl", "new", "kotlin", ".", "echo")),
in.Exec("ftl", "init", "test"),
in.IfLanguage("java", in.Exec("ftl", "new", "java", "echo")),
in.IfLanguage("kotlin", in.Exec("ftl", "new", "kotlin", "echo")),
in.WaitWithTimeout("echo", time.Minute),
in.VerifyControllerStatus(func(ctx context.Context, t testing.TB, status *ftlv1.StatusResponse) {
assert.Equal(t, 1, len(status.Deployments))
Expand Down

0 comments on commit b9f8209

Please sign in to comment.