Skip to content

Commit 2b720b6

Browse files
Merge pull request #281 from wttech/tools-upgrade
Tools upgrade
2 parents b07580b + 1095209 commit 2b720b6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+1586
-989
lines changed

README.md

Lines changed: 12 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -138,31 +138,29 @@ Supported project types:
138138

139139
---
140140

141-
Run command below to initialize the AEM Compose tool in your project:
141+
Run command below to install the AEM Compose tool in your project:
142142

143143
```shell
144-
curl https://raw.githubusercontent.com/wttech/aemc/main/project-init.sh | sh
144+
curl https://raw.githubusercontent.com/wttech/aemc/main/project-install.sh | sh
145145
```
146146

147-
and then:
148-
149-
```shell
150-
sh aemw init
151-
```
152-
153-
After successful initialization, remember to always use the tool via wrapper script in the following way:
147+
After successful installation, remember to always use the tool via wrapper script in the following way:
154148

155149
```shell
156150
sh aemw [command]
157151
```
158152

159-
For example:
153+
Next scaffold the AEM Compose files in the project:
160154

161155
```shell
162-
sh aemw version
156+
sh aemw project scaffold
163157
```
164158

165-
Project initialization sets up ready-to-use tasks powered by [Task tool](https://taskfile.dev/) which are aggregating one or many AEM Compose CLI commands into useful procedures.
159+
Project scaffolding:
160+
161+
- sets up ready-to-use tasks powered by [Task tool](https://taskfile.dev/), which aggregate one or many AEM Compose CLI commands into useful procedures.
162+
- provides configuration for provisioning AEM instances (installing service pack, setting replication agents, etc.).
163+
- provides configuration for running AEM Dispatcher on [Podman](https://podman-desktop.io/) or [Docker](https://www.docker.com/products/docker-desktop/).
166164

167165
To list all available tasks, run:
168166

@@ -176,19 +174,6 @@ For example:
176174
sh taskw setup
177175
```
178176

179-
Some tasks like `aem:build` may accept parameters.
180-
For example, to build AEM application with:
181-
182-
- Applying frontend development mode Maven profile
183-
- Unit tests skipping
184-
- UI tests skipping
185-
186-
Simply run command with appending [task variable](https://taskfile.dev/usage/#variables) to the end:
187-
188-
```shell
189-
sh taskw aem:build AEM_BUILD_ARGS="-PfedDev -DskipTests -pl '!ui.tests'"
190-
```
191-
192177
## IaaC Providers
193178

194179
The tool is designed to be used in Infrastructure as a Code (IaaC) solutions such as [Terraform](https://www.terraform.io/) or [Pulumi](https://www.pulumi.com/).
@@ -378,7 +363,7 @@ instance:
378363

379364
# Oak Run tool options (offline instance management)
380365
oak_run:
381-
download_url: "https://repo1.maven.org/maven2/org/apache/jackrabbit/oak-run/1.44.0/oak-run-1.44.0.jar"
366+
download_url: "https://repo1.maven.org/maven2/org/apache/jackrabbit/oak-run/1.72.0/oak-run-1.72.0.jar"
382367
store_path: "crx-quickstart/repository/segmentstore"
383368

384369
# Source files
@@ -458,7 +443,7 @@ java:
458443
# Auto-installed JDK options
459444
download:
460445
# Source URL with template vars support
461-
url: "https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.18%2B10/OpenJDK11U-jdk_[[.Arch]]_[[.Os]]_hotspot_11.0.18_10.[[.ArchiveExt]]"
446+
url: "https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.25%2B9/OpenJDK11U-jdk_[[.Arch]]_[[.Os]]_hotspot_11.0.25_9.[[.ArchiveExt]]"
462447
# Map source URL template vars to be compatible with Adoptium Java
463448
replacements:
464449
# Var 'Os' (GOOS)
@@ -471,9 +456,6 @@ java:
471456
"arm64": "x64"
472457
"aarch64": "x64"
473458

474-
vault:
475-
"download_url": "https://repo1.maven.org/maven2/org/apache/jackrabbit/vault/vault-cli/3.7.2/vault-cli-3.7.2-bin.tar.gz"
476-
477459
base:
478460
# Location of temporary files (downloaded AEM packages, etc)
479461
tmp_dir: aem/home/tmp

cmd/aem/crypto.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package main
33
import (
44
"github.com/spf13/cobra"
55
"github.com/wttech/aemc/pkg"
6-
"github.com/wttech/aemc/pkg/common"
76
"github.com/wttech/aemc/pkg/common/mapsx"
87
)
98

@@ -59,8 +58,9 @@ func (c *CLI) cryptoSetupCmd() *cobra.Command {
5958
}
6059
},
6160
}
62-
cmd.Flags().String("hmac-file", common.LibDir+"/crypto/data/hmac", "Path to file 'hmac'")
63-
cmd.Flags().String("master-file", common.LibDir+"/crypto/data/master", "Path to file 'master'")
61+
libDir := c.config.Values().GetString("base.lib_dir")
62+
cmd.Flags().String("hmac-file", libDir+"/crypto/data/hmac", "Path to file 'hmac'")
63+
cmd.Flags().String("master-file", libDir+"/crypto/data/master", "Path to file 'master'")
6464
return cmd
6565
}
6666

cmd/aem/instance.go

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ func (c *CLI) instanceCmd() *cobra.Command {
2323
cmd.AddCommand(c.instanceListCmd())
2424
cmd.AddCommand(c.instanceAwaitCmd())
2525
cmd.AddCommand(c.instanceBackupCmd())
26-
cmd.AddCommand(c.instanceInitCmd())
2726
cmd.AddCommand(c.instanceImportCmd())
2827
return cmd
2928
}
@@ -334,34 +333,3 @@ func (c *CLI) instanceListCmd() *cobra.Command {
334333
},
335334
}
336335
}
337-
338-
func (c *CLI) instanceInitCmd() *cobra.Command {
339-
return &cobra.Command{
340-
Use: "init",
341-
Aliases: []string{"initialize"},
342-
Short: "Init prerequisites for AEM instance(s)",
343-
Run: func(cmd *cobra.Command, args []string) {
344-
if err := c.aem.InstanceManager().LocalOpts.Initialize(); err != nil {
345-
c.Error(err)
346-
return
347-
}
348-
349-
javaHome, err := c.aem.JavaOpts().FindHomeDir()
350-
if err != nil {
351-
c.Error(err)
352-
return
353-
}
354-
c.SetOutput("javaHome", javaHome)
355-
356-
javaExecutable, err := c.aem.JavaOpts().Executable()
357-
if err != nil {
358-
c.Error(err)
359-
return
360-
}
361-
c.SetOutput("javaExecutable", javaExecutable)
362-
363-
c.SetOutput("initialized", true)
364-
c.Changed("initialized prerequisites for instance(s)")
365-
},
366-
}
367-
}

cmd/aem/project.go

Lines changed: 68 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,26 @@ import (
77
"strings"
88
)
99

10+
func (c *CLI) projectCmd() *cobra.Command {
11+
cmd := &cobra.Command{
12+
Use: "project",
13+
Short: "Manage project files",
14+
Aliases: []string{"prj"},
15+
}
16+
cmd.AddCommand(c.projectInitCmd())
17+
cmd.AddCommand(c.projectScaffoldCmd())
18+
19+
return cmd
20+
}
21+
1022
const projectKindFlag = "project-kind"
1123

12-
func (c *CLI) initCmd() *cobra.Command {
24+
func (c *CLI) projectScaffoldCmd() *cobra.Command {
1325
cmd := &cobra.Command{
14-
Use: "init",
15-
Aliases: []string{"initialize"},
16-
Short: "Initializes AEMC in the project",
26+
Use: "scaffold",
27+
Aliases: []string{"setup"},
28+
Short: "Scaffold required files in the project",
1729
Run: func(cmd *cobra.Command, args []string) {
18-
if err := c.aem.Project().EnsureDirs(); err != nil {
19-
c.Error(err)
20-
return
21-
}
2230
kindName, _ := cmd.Flags().GetString(projectKindFlag)
2331
kind, err := c.aem.Project().KindDetermine(kindName)
2432
if err != nil {
@@ -29,24 +37,72 @@ func (c *CLI) initCmd() *cobra.Command {
2937
c.Fail(fmt.Sprintf("project kind cannot be determined; specify it with flag '--%s=[%s]'", projectKindFlag, strings.Join(project.KindStrings(), "|")))
3038
return
3139
}
32-
changed, err := c.aem.Project().InitializeWithChanged(kind)
40+
41+
changed, err := c.aem.Project().ScaffoldWithChanged(kind)
42+
if err != nil {
43+
c.Error(err)
44+
return
45+
}
46+
47+
c.SetOutput("gettingStarted", c.aem.Project().ScaffoldGettingStarted())
48+
49+
if changed {
50+
c.Changed("project files scaffolded")
51+
} else {
52+
c.Ok("project files already scaffolded")
53+
}
54+
},
55+
}
56+
cmd.Flags().String(projectKindFlag, project.KindAuto, fmt.Sprintf("Type of AEM to work with (%s)", strings.Join(project.KindStrings(), "|")))
57+
return cmd
58+
}
59+
60+
func (c *CLI) projectInitCmd() *cobra.Command {
61+
cmd := &cobra.Command{
62+
Use: "init",
63+
Aliases: []string{"initialize"},
64+
Short: "Initializes AEMC in the project",
65+
Run: func(cmd *cobra.Command, args []string) {
66+
if !c.aem.Project().IsScaffolded() {
67+
c.Fail(fmt.Sprintf("project need to be scaffolded before running initialization"))
68+
return
69+
}
70+
71+
changed := false
72+
73+
c.SetOutput("gettingStarted", c.aem.Project().InitGettingStartedError())
74+
75+
baseChanged, err := c.aem.BaseOpts().PrepareWithChanged()
76+
changed = changed || baseChanged
3377
if err != nil {
3478
c.Error(err)
3579
return
3680
}
37-
gettingStarted, err := c.aem.Project().GettingStarted(kind)
81+
c.SetOutput("baseChanged", baseChanged)
82+
83+
// Download and prepare vendor tools (including JDK and AEM SDK)
84+
vendorPrepared, err := c.aem.VendorManager().PrepareWithChanged()
85+
changed = changed || vendorPrepared
3886
if err != nil {
3987
c.Error(err)
4088
return
4189
}
42-
c.SetOutput("gettingStarted", gettingStarted)
90+
c.SetOutput("vendorPrepared", vendorPrepared)
91+
92+
// Validate AEM instance files and prepared SDK
93+
if err := c.aem.InstanceManager().LocalOpts.Validate(); err != nil {
94+
c.Error(err)
95+
return
96+
}
97+
98+
c.SetOutput("gettingStarted", c.aem.Project().InitGettingStartedSuccess())
99+
43100
if changed {
44101
c.Changed("project initialized")
45102
} else {
46103
c.Ok("project already initialized")
47104
}
48105
},
49106
}
50-
cmd.Flags().String(projectKindFlag, project.KindAuto, fmt.Sprintf("Type of AEM to work with (%s)", strings.Join(project.KindStrings(), "|")))
51107
return cmd
52108
}

cmd/aem/root.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ func (c *CLI) rootCmd() *cobra.Command {
1919
},
2020
}
2121
cmd.AddCommand(c.versionCmd())
22-
cmd.AddCommand(c.initCmd())
22+
cmd.AddCommand(c.projectCmd())
23+
cmd.AddCommand(c.vendorCmd())
2324
cmd.AddCommand(c.configCmd())
2425
cmd.AddCommand(c.instanceCmd())
2526
cmd.AddCommand(c.osgiCmd())
@@ -33,8 +34,9 @@ func (c *CLI) rootCmd() *cobra.Command {
3334
cmd.AddCommand(c.fileCmd())
3435
cmd.AddCommand(c.authCmd())
3536
cmd.AddCommand(c.contentCmd())
36-
cmd.AddCommand(c.vaultCmd())
37+
3738
c.rootFlags(cmd)
39+
3840
return cmd
3941
}
4042

cmd/aem/vault.go

Lines changed: 0 additions & 30 deletions
This file was deleted.

cmd/aem/vendor.go

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
package main
2+
3+
import (
4+
log "github.com/sirupsen/logrus"
5+
"github.com/spf13/cobra"
6+
"os"
7+
)
8+
9+
func (c *CLI) vendorCmd() *cobra.Command {
10+
cmd := &cobra.Command{
11+
Use: "vendor",
12+
Short: "Supportive tools management",
13+
Aliases: []string{"ven"},
14+
}
15+
cmd.AddCommand(c.vendorListCmd())
16+
cmd.AddCommand(c.vendorPrepareCmd())
17+
18+
return cmd
19+
}
20+
21+
func (c *CLI) vendorListCmd() *cobra.Command {
22+
cmd := &cobra.Command{
23+
Use: "list",
24+
Short: "List vendor tools available",
25+
Aliases: []string{"ls"},
26+
Run: func(cmd *cobra.Command, args []string) {
27+
verbose, _ := cmd.Flags().GetBool("verbose")
28+
29+
javaHome, err := c.aem.VendorManager().JavaManager().FindHomeDir()
30+
if err != nil {
31+
javaHome = os.Getenv("JAVA_HOME")
32+
if verbose {
33+
log.Warnf("java home not available: %s", err)
34+
}
35+
}
36+
c.SetOutput("javaHome", javaHome)
37+
38+
javaExecutable, err := c.aem.VendorManager().JavaManager().Executable()
39+
if err != nil {
40+
if verbose {
41+
log.Warnf("java executable not available: %s", err)
42+
}
43+
}
44+
c.SetOutput("javaExecutable", javaExecutable)
45+
46+
oakRunJar := c.aem.VendorManager().OakRun().JarFile()
47+
c.setOutput("oakRunJar", oakRunJar)
48+
49+
c.Ok("vendor tools listed")
50+
},
51+
}
52+
cmd.Flags().BoolP("verbose", "v", false, "Log errors")
53+
return cmd
54+
}
55+
56+
func (c *CLI) vendorPrepareCmd() *cobra.Command {
57+
cmd := &cobra.Command{
58+
Use: "prepare",
59+
Short: "Prepare vendor tools",
60+
Aliases: []string{"prep", "download", "dw"},
61+
Run: func(cmd *cobra.Command, args []string) {
62+
changed, err := c.aem.VendorManager().PrepareWithChanged()
63+
if err != nil {
64+
c.Error(err)
65+
return
66+
}
67+
68+
if changed {
69+
c.Changed("vendor tools prepared")
70+
} else {
71+
c.Ok("vendor tools already prepared")
72+
}
73+
},
74+
}
75+
return cmd
76+
}

0 commit comments

Comments
 (0)