From b9f820986c611879644351d51b316621bc10622b Mon Sep 17 00:00:00 2001 From: Stuart Douglas Date: Wed, 18 Dec 2024 15:30:34 +1100 Subject: [PATCH] fix: init and new command minor fixes (#3806) Also add a readme to help people get started with the project. --- README.md | 2 +- .../docs/getting-started/quick-start/index.md | 6 +++--- frontend/cli/cmd_init.go | 8 +++++++- frontend/cli/cmd_new.go | 2 +- internal/integration/actions.go | 2 +- internal/projectinit/scaffolding/README.md | 14 ++++++++++++++ .../projectinit/scaffolding/bin/.maven-3.9.9.pkg | 1 + .../projectinit/scaffolding/bin/.openjdk@17.pkg | 1 + internal/projectinit/scaffolding/bin/jar | 1 + internal/projectinit/scaffolding/bin/jarsigner | 1 + internal/projectinit/scaffolding/bin/java | 1 + internal/projectinit/scaffolding/bin/javac | 1 + internal/projectinit/scaffolding/bin/javadoc | 1 + internal/projectinit/scaffolding/bin/javap | 1 + internal/projectinit/scaffolding/bin/jcmd | 1 + internal/projectinit/scaffolding/bin/jconsole | 1 + internal/projectinit/scaffolding/bin/jdb | 1 + internal/projectinit/scaffolding/bin/jdeprscan | 1 + internal/projectinit/scaffolding/bin/jdeps | 1 + internal/projectinit/scaffolding/bin/jfr | 1 + internal/projectinit/scaffolding/bin/jhsdb | 1 + internal/projectinit/scaffolding/bin/jimage | 1 + internal/projectinit/scaffolding/bin/jinfo | 1 + internal/projectinit/scaffolding/bin/jlink | 1 + internal/projectinit/scaffolding/bin/jmap | 1 + internal/projectinit/scaffolding/bin/jmod | 1 + internal/projectinit/scaffolding/bin/jpackage | 1 + internal/projectinit/scaffolding/bin/jps | 1 + internal/projectinit/scaffolding/bin/jrunscript | 1 + internal/projectinit/scaffolding/bin/jshell | 1 + internal/projectinit/scaffolding/bin/jstack | 1 + internal/projectinit/scaffolding/bin/jstat | 1 + internal/projectinit/scaffolding/bin/jstatd | 1 + internal/projectinit/scaffolding/bin/keytool | 1 + internal/projectinit/scaffolding/bin/mvn | 1 + internal/projectinit/scaffolding/bin/mvnDebug | 1 + internal/projectinit/scaffolding/bin/rmiregistry | 1 + internal/projectinit/scaffolding/bin/serialver | 1 + jvm-runtime/jvm_integration_test.go | 6 +++--- 39 files changed, 62 insertions(+), 10 deletions(-) create mode 100644 internal/projectinit/scaffolding/README.md create mode 120000 internal/projectinit/scaffolding/bin/.maven-3.9.9.pkg create mode 120000 internal/projectinit/scaffolding/bin/.openjdk@17.pkg create mode 120000 internal/projectinit/scaffolding/bin/jar create mode 120000 internal/projectinit/scaffolding/bin/jarsigner create mode 120000 internal/projectinit/scaffolding/bin/java create mode 120000 internal/projectinit/scaffolding/bin/javac create mode 120000 internal/projectinit/scaffolding/bin/javadoc create mode 120000 internal/projectinit/scaffolding/bin/javap create mode 120000 internal/projectinit/scaffolding/bin/jcmd create mode 120000 internal/projectinit/scaffolding/bin/jconsole create mode 120000 internal/projectinit/scaffolding/bin/jdb create mode 120000 internal/projectinit/scaffolding/bin/jdeprscan create mode 120000 internal/projectinit/scaffolding/bin/jdeps create mode 120000 internal/projectinit/scaffolding/bin/jfr create mode 120000 internal/projectinit/scaffolding/bin/jhsdb create mode 120000 internal/projectinit/scaffolding/bin/jimage create mode 120000 internal/projectinit/scaffolding/bin/jinfo create mode 120000 internal/projectinit/scaffolding/bin/jlink create mode 120000 internal/projectinit/scaffolding/bin/jmap create mode 120000 internal/projectinit/scaffolding/bin/jmod create mode 120000 internal/projectinit/scaffolding/bin/jpackage create mode 120000 internal/projectinit/scaffolding/bin/jps create mode 120000 internal/projectinit/scaffolding/bin/jrunscript create mode 120000 internal/projectinit/scaffolding/bin/jshell create mode 120000 internal/projectinit/scaffolding/bin/jstack create mode 120000 internal/projectinit/scaffolding/bin/jstat create mode 120000 internal/projectinit/scaffolding/bin/jstatd create mode 120000 internal/projectinit/scaffolding/bin/keytool create mode 120000 internal/projectinit/scaffolding/bin/mvn create mode 120000 internal/projectinit/scaffolding/bin/mvnDebug create mode 120000 internal/projectinit/scaffolding/bin/rmiregistry create mode 120000 internal/projectinit/scaffolding/bin/serialver diff --git a/README.md b/README.md index 39b8be2af1..340d2ba190 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/docs/content/docs/getting-started/quick-start/index.md b/docs/content/docs/getting-started/quick-start/index.md index cf6178c046..dca2c9133b 100644 --- a/docs/content/docs/getting-started/quick-start/index.md +++ b/docs/content/docs/getting-started/quick-start/index.md @@ -82,7 +82,7 @@ Now that you have an FTL project, create a new module: ``` -ftl new go . alice +ftl new go alice ``` This will place the code for the new module `alice` in `myproject/alice/alice.go`: @@ -114,7 +114,7 @@ Each module is its own Go module. ``` -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`: @@ -132,7 +132,7 @@ fun echo(req: String): String = "Hello, $req!" ``` ``` -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`: diff --git a/frontend/cli/cmd_init.go b/frontend/cli/cmd_init.go index 0464ccc502..cbd5e5ac81 100644 --- a/frontend/cli/cmd_init.go +++ b/frontend/cli/cmd_init.go @@ -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."` @@ -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 } diff --git a/frontend/cli/cmd_new.go b/frontend/cli/cmd_new.go index d7b3b3c6af..d3aa389318 100644 --- a/frontend/cli/cmd_new.go +++ b/frontend/cli/cmd_new.go @@ -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 diff --git a/internal/integration/actions.go b/internal/integration/actions.go index 13e84e8047..bc2c067564 100644 --- a/internal/integration/actions.go +++ b/internal/integration/actions.go @@ -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) } } diff --git a/internal/projectinit/scaffolding/README.md b/internal/projectinit/scaffolding/README.md new file mode 100644 index 0000000000..2bc1ff92a6 --- /dev/null +++ b/internal/projectinit/scaffolding/README.md @@ -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/). \ No newline at end of file diff --git a/internal/projectinit/scaffolding/bin/.maven-3.9.9.pkg b/internal/projectinit/scaffolding/bin/.maven-3.9.9.pkg new file mode 120000 index 0000000000..383f4511d4 --- /dev/null +++ b/internal/projectinit/scaffolding/bin/.maven-3.9.9.pkg @@ -0,0 +1 @@ +hermit \ No newline at end of file diff --git a/internal/projectinit/scaffolding/bin/.openjdk@17.pkg b/internal/projectinit/scaffolding/bin/.openjdk@17.pkg new file mode 120000 index 0000000000..383f4511d4 --- /dev/null +++ b/internal/projectinit/scaffolding/bin/.openjdk@17.pkg @@ -0,0 +1 @@ +hermit \ No newline at end of file diff --git a/internal/projectinit/scaffolding/bin/jar b/internal/projectinit/scaffolding/bin/jar new file mode 120000 index 0000000000..cf7b7e07ba --- /dev/null +++ b/internal/projectinit/scaffolding/bin/jar @@ -0,0 +1 @@ +.openjdk@17.pkg \ No newline at end of file diff --git a/internal/projectinit/scaffolding/bin/jarsigner b/internal/projectinit/scaffolding/bin/jarsigner new file mode 120000 index 0000000000..cf7b7e07ba --- /dev/null +++ b/internal/projectinit/scaffolding/bin/jarsigner @@ -0,0 +1 @@ +.openjdk@17.pkg \ No newline at end of file diff --git a/internal/projectinit/scaffolding/bin/java b/internal/projectinit/scaffolding/bin/java new file mode 120000 index 0000000000..cf7b7e07ba --- /dev/null +++ b/internal/projectinit/scaffolding/bin/java @@ -0,0 +1 @@ +.openjdk@17.pkg \ No newline at end of file diff --git a/internal/projectinit/scaffolding/bin/javac b/internal/projectinit/scaffolding/bin/javac new file mode 120000 index 0000000000..cf7b7e07ba --- /dev/null +++ b/internal/projectinit/scaffolding/bin/javac @@ -0,0 +1 @@ +.openjdk@17.pkg \ No newline at end of file diff --git a/internal/projectinit/scaffolding/bin/javadoc b/internal/projectinit/scaffolding/bin/javadoc new file mode 120000 index 0000000000..cf7b7e07ba --- /dev/null +++ b/internal/projectinit/scaffolding/bin/javadoc @@ -0,0 +1 @@ +.openjdk@17.pkg \ No newline at end of file diff --git a/internal/projectinit/scaffolding/bin/javap b/internal/projectinit/scaffolding/bin/javap new file mode 120000 index 0000000000..cf7b7e07ba --- /dev/null +++ b/internal/projectinit/scaffolding/bin/javap @@ -0,0 +1 @@ +.openjdk@17.pkg \ No newline at end of file diff --git a/internal/projectinit/scaffolding/bin/jcmd b/internal/projectinit/scaffolding/bin/jcmd new file mode 120000 index 0000000000..cf7b7e07ba --- /dev/null +++ b/internal/projectinit/scaffolding/bin/jcmd @@ -0,0 +1 @@ +.openjdk@17.pkg \ No newline at end of file diff --git a/internal/projectinit/scaffolding/bin/jconsole b/internal/projectinit/scaffolding/bin/jconsole new file mode 120000 index 0000000000..cf7b7e07ba --- /dev/null +++ b/internal/projectinit/scaffolding/bin/jconsole @@ -0,0 +1 @@ +.openjdk@17.pkg \ No newline at end of file diff --git a/internal/projectinit/scaffolding/bin/jdb b/internal/projectinit/scaffolding/bin/jdb new file mode 120000 index 0000000000..cf7b7e07ba --- /dev/null +++ b/internal/projectinit/scaffolding/bin/jdb @@ -0,0 +1 @@ +.openjdk@17.pkg \ No newline at end of file diff --git a/internal/projectinit/scaffolding/bin/jdeprscan b/internal/projectinit/scaffolding/bin/jdeprscan new file mode 120000 index 0000000000..cf7b7e07ba --- /dev/null +++ b/internal/projectinit/scaffolding/bin/jdeprscan @@ -0,0 +1 @@ +.openjdk@17.pkg \ No newline at end of file diff --git a/internal/projectinit/scaffolding/bin/jdeps b/internal/projectinit/scaffolding/bin/jdeps new file mode 120000 index 0000000000..cf7b7e07ba --- /dev/null +++ b/internal/projectinit/scaffolding/bin/jdeps @@ -0,0 +1 @@ +.openjdk@17.pkg \ No newline at end of file diff --git a/internal/projectinit/scaffolding/bin/jfr b/internal/projectinit/scaffolding/bin/jfr new file mode 120000 index 0000000000..cf7b7e07ba --- /dev/null +++ b/internal/projectinit/scaffolding/bin/jfr @@ -0,0 +1 @@ +.openjdk@17.pkg \ No newline at end of file diff --git a/internal/projectinit/scaffolding/bin/jhsdb b/internal/projectinit/scaffolding/bin/jhsdb new file mode 120000 index 0000000000..cf7b7e07ba --- /dev/null +++ b/internal/projectinit/scaffolding/bin/jhsdb @@ -0,0 +1 @@ +.openjdk@17.pkg \ No newline at end of file diff --git a/internal/projectinit/scaffolding/bin/jimage b/internal/projectinit/scaffolding/bin/jimage new file mode 120000 index 0000000000..cf7b7e07ba --- /dev/null +++ b/internal/projectinit/scaffolding/bin/jimage @@ -0,0 +1 @@ +.openjdk@17.pkg \ No newline at end of file diff --git a/internal/projectinit/scaffolding/bin/jinfo b/internal/projectinit/scaffolding/bin/jinfo new file mode 120000 index 0000000000..cf7b7e07ba --- /dev/null +++ b/internal/projectinit/scaffolding/bin/jinfo @@ -0,0 +1 @@ +.openjdk@17.pkg \ No newline at end of file diff --git a/internal/projectinit/scaffolding/bin/jlink b/internal/projectinit/scaffolding/bin/jlink new file mode 120000 index 0000000000..cf7b7e07ba --- /dev/null +++ b/internal/projectinit/scaffolding/bin/jlink @@ -0,0 +1 @@ +.openjdk@17.pkg \ No newline at end of file diff --git a/internal/projectinit/scaffolding/bin/jmap b/internal/projectinit/scaffolding/bin/jmap new file mode 120000 index 0000000000..cf7b7e07ba --- /dev/null +++ b/internal/projectinit/scaffolding/bin/jmap @@ -0,0 +1 @@ +.openjdk@17.pkg \ No newline at end of file diff --git a/internal/projectinit/scaffolding/bin/jmod b/internal/projectinit/scaffolding/bin/jmod new file mode 120000 index 0000000000..cf7b7e07ba --- /dev/null +++ b/internal/projectinit/scaffolding/bin/jmod @@ -0,0 +1 @@ +.openjdk@17.pkg \ No newline at end of file diff --git a/internal/projectinit/scaffolding/bin/jpackage b/internal/projectinit/scaffolding/bin/jpackage new file mode 120000 index 0000000000..cf7b7e07ba --- /dev/null +++ b/internal/projectinit/scaffolding/bin/jpackage @@ -0,0 +1 @@ +.openjdk@17.pkg \ No newline at end of file diff --git a/internal/projectinit/scaffolding/bin/jps b/internal/projectinit/scaffolding/bin/jps new file mode 120000 index 0000000000..cf7b7e07ba --- /dev/null +++ b/internal/projectinit/scaffolding/bin/jps @@ -0,0 +1 @@ +.openjdk@17.pkg \ No newline at end of file diff --git a/internal/projectinit/scaffolding/bin/jrunscript b/internal/projectinit/scaffolding/bin/jrunscript new file mode 120000 index 0000000000..cf7b7e07ba --- /dev/null +++ b/internal/projectinit/scaffolding/bin/jrunscript @@ -0,0 +1 @@ +.openjdk@17.pkg \ No newline at end of file diff --git a/internal/projectinit/scaffolding/bin/jshell b/internal/projectinit/scaffolding/bin/jshell new file mode 120000 index 0000000000..cf7b7e07ba --- /dev/null +++ b/internal/projectinit/scaffolding/bin/jshell @@ -0,0 +1 @@ +.openjdk@17.pkg \ No newline at end of file diff --git a/internal/projectinit/scaffolding/bin/jstack b/internal/projectinit/scaffolding/bin/jstack new file mode 120000 index 0000000000..cf7b7e07ba --- /dev/null +++ b/internal/projectinit/scaffolding/bin/jstack @@ -0,0 +1 @@ +.openjdk@17.pkg \ No newline at end of file diff --git a/internal/projectinit/scaffolding/bin/jstat b/internal/projectinit/scaffolding/bin/jstat new file mode 120000 index 0000000000..cf7b7e07ba --- /dev/null +++ b/internal/projectinit/scaffolding/bin/jstat @@ -0,0 +1 @@ +.openjdk@17.pkg \ No newline at end of file diff --git a/internal/projectinit/scaffolding/bin/jstatd b/internal/projectinit/scaffolding/bin/jstatd new file mode 120000 index 0000000000..cf7b7e07ba --- /dev/null +++ b/internal/projectinit/scaffolding/bin/jstatd @@ -0,0 +1 @@ +.openjdk@17.pkg \ No newline at end of file diff --git a/internal/projectinit/scaffolding/bin/keytool b/internal/projectinit/scaffolding/bin/keytool new file mode 120000 index 0000000000..cf7b7e07ba --- /dev/null +++ b/internal/projectinit/scaffolding/bin/keytool @@ -0,0 +1 @@ +.openjdk@17.pkg \ No newline at end of file diff --git a/internal/projectinit/scaffolding/bin/mvn b/internal/projectinit/scaffolding/bin/mvn new file mode 120000 index 0000000000..ff4604c2c5 --- /dev/null +++ b/internal/projectinit/scaffolding/bin/mvn @@ -0,0 +1 @@ +.maven-3.9.9.pkg \ No newline at end of file diff --git a/internal/projectinit/scaffolding/bin/mvnDebug b/internal/projectinit/scaffolding/bin/mvnDebug new file mode 120000 index 0000000000..ff4604c2c5 --- /dev/null +++ b/internal/projectinit/scaffolding/bin/mvnDebug @@ -0,0 +1 @@ +.maven-3.9.9.pkg \ No newline at end of file diff --git a/internal/projectinit/scaffolding/bin/rmiregistry b/internal/projectinit/scaffolding/bin/rmiregistry new file mode 120000 index 0000000000..cf7b7e07ba --- /dev/null +++ b/internal/projectinit/scaffolding/bin/rmiregistry @@ -0,0 +1 @@ +.openjdk@17.pkg \ No newline at end of file diff --git a/internal/projectinit/scaffolding/bin/serialver b/internal/projectinit/scaffolding/bin/serialver new file mode 120000 index 0000000000..cf7b7e07ba --- /dev/null +++ b/internal/projectinit/scaffolding/bin/serialver @@ -0,0 +1 @@ +.openjdk@17.pkg \ No newline at end of file diff --git a/jvm-runtime/jvm_integration_test.go b/jvm-runtime/jvm_integration_test.go index eb1555d957..7fed09287b 100644 --- a/jvm-runtime/jvm_integration_test.go +++ b/jvm-runtime/jvm_integration_test.go @@ -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))