awslabs / green-boost

Build Full Stack Cloud Native Web Apps on AWS Fast
https://awslabs.github.io/green-boost/
Apache License 2.0
70 stars 8 forks source link

the `gboost create` git check erroneously fails for many versions of git #234

Closed firxworx closed 1 year ago

firxworx commented 1 year ago

I can push up a PR for this one, the fix is trivial. Creating an issue first.

Issue Summary

The gboost cli create command uses git -v to check for git: this will fail for many versions with error message "unknown option".

e.g. on a WSL2 Ubuntu dev machine running git v2.34.1

pnpm dlx gboost create acme
.../share/pnpm/store/v3/tmp/dlx-325355   | +141 ++++++++++++++
.../share/pnpm/store/v3/tmp/dlx-325355   | Progress: resolved 163, reused 118, downloaded 23, added 141, done
The integrity of 1023 files was checked. This might have caused installation to take longer.
unknown option: -v
usage: git [--version] [--help] [-C <path>] [-c <name>=<value>]
           [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
           [-p | --paginate | -P | --no-pager] [--no-replace-objects] [--bare]
           [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]
           [--super-prefix=<path>] [--config-env=<name>=<envvar>]
           <command> [<args>]
Command not found: git. Please install: https://git-scm.com
node:internal/errors:857
  const err = new Error(message);
              ^

Error: Command failed: git -v
unknown option: -v

The trivial fix is to use git --version.

In general I've found the long form of options can be more reliable for scripting and clearer in terms of communicating intent.

Context

Apparently there was discussion among contributors that -v could be confusing/ambiguous: "verbose" vs. "version".

There should be no issue with the latest versions of git however old versions are common.

A top search hit when investigating the context: (search for "unknown option" at this link: https://lore.kernel.org/git/20220330190956.21447-1-garrit@slashdev.space/t/)