diff --git a/README.md b/README.md index 46610c0..e40907d 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Patternizer -![Version: 2.0.0](https://img.shields.io/badge/Version-2.0.0-informational?style=flat-square) +![Version: 2.1.0](https://img.shields.io/badge/Version-2.1.0-informational?style=flat-square) [![Quay Repository](https://img.shields.io/badge/Quay.io-patternizer-blue?logo=quay)](https://quay.io/repository/validatedpatterns/patternizer) [![CI Pipeline](https://github.com/validatedpatterns/patternizer/actions/workflows/build-push.yaml/badge.svg?branch=main)](https://github.com/validatedpatterns/patternizer/actions/workflows/build-push.yaml) @@ -16,6 +16,7 @@ - [**Initialize without secrets:**](#initialize-without-secrets) - [**Initialize with secrets support:**](#initialize-with-secrets-support) - [**Upgrade an existing pattern repository:**](#upgrade-an-existing-pattern-repository) + - [**Shell alias (optional):**](#shell-alias-optional) - [Understanding Secrets Management](#understanding-secrets-management) - [Generated Files](#generated-files) - [AI Coding Skills](#ai-coding-skills) @@ -106,6 +107,21 @@ podman run --pull=newer -v "$PWD:$PWD:z" -w "$PWD" quay.io/validatedpatterns/pat podman run --pull=newer -v "$PWD:$PWD:z" -w "$PWD" quay.io/validatedpatterns/patternizer upgrade --replace-makefile ``` +#### **Shell alias (optional):** + +You can shorten the patternizer command by adding a shell function to your shell's startup file (e.g. `~/.bashrc` or `~/.zshrc`): + +```bash +pattern() { + podman run --pull=newer \ + -v "$PWD:$PWD:z" \ + -w "$PWD" \ + quay.io/validatedpatterns/patternizer "$@" +} +``` + +Then run commands as `pattern init`, `pattern upgrade`, etc. + What upgrade does: - Removes the `common/` directory if it exists diff --git a/src/cmd/init_test.go b/src/cmd/init_test.go index 1f6d9fe..3b8b392 100644 --- a/src/cmd/init_test.go +++ b/src/cmd/init_test.go @@ -272,6 +272,22 @@ var _ = Describe("patternizer init", func() { }) }) + for _, alias := range []string{"create", "bootstrap"} { + alias := alias + Context("using the "+alias+" alias on an empty directory", Ordered, func() { + var tempDir string + + BeforeAll(func() { + tempDir = createTestDir() + _ = runCLI(tempDir, alias) + }) + + It("should produce the same result as init", func() { + verifyScaffoldFilesCopied(tempDir) + }) + }) + } + Context("on a directory with singleArgoCD explicitly set to false", Ordered, func() { var tempDir string diff --git a/src/cmd/root.go b/src/cmd/root.go index 4464d0a..bd9fc4f 100644 --- a/src/cmd/root.go +++ b/src/cmd/root.go @@ -21,8 +21,9 @@ values-global.yaml, values-.yaml, and optional secrets configurati } var initCmd = &cobra.Command{ - Use: "init", - Short: "Initialize pattern files", + Use: "init", + Aliases: []string{"create", "bootstrap"}, + Short: "Initialize pattern files", Long: `Initialize pattern files creates or updates the necessary YAML configuration files for a validated pattern, including values-global.yaml and values-.yaml. @@ -41,8 +42,9 @@ configures the pattern.sh script for secrets usage.`, rootCmd.AddCommand(initCmd) var upgradeCmd = &cobra.Command{ - Use: "upgrade", - Short: "Upgrade an existing pattern repository", + Use: "upgrade", + Aliases: []string{"update"}, + Short: "Upgrade an existing pattern repository", Long: `Upgrade an existing pattern repository by refreshing common assets. This will remove the legacy common/ directory and pattern.sh symlink if present, diff --git a/src/cmd/upgrade_test.go b/src/cmd/upgrade_test.go index 0005f3c..2721a3f 100644 --- a/src/cmd/upgrade_test.go +++ b/src/cmd/upgrade_test.go @@ -97,6 +97,24 @@ var _ = Describe("patternizer upgrade", func() { }) }) +var _ = Describe("patternizer update (upgrade alias)", func() { + Context("on a repo using common", Ordered, func() { + var tempDir string + + BeforeAll(func() { + tempDir = createTestDir() + cloneMCGWithCommon(tempDir) + _ = runCLI(tempDir, "update") + }) + + It("should produce the same result as upgrade", func() { + verifyPattenShCopied(tempDir) + verifyMakefileCommonCopied(tempDir) + verifyAnsibleCfgCopied(tempDir) + }) + }) +}) + var _ = Describe("patternizer upgrade --replace-makefile", func() { Context("on a repo using common", Ordered, func() { var tempDir string