h5bp/server-configs-apache

Missing version in custom `.htaccess` builds

florianbouvot opened this issue · 8 comments

Hi, we are using custom build in our tools and I try to update to follow last update and version doesn't appear:

Capture d’écran 2022-05-11 à 10 28 32

Thanks

Thanks for raising this issue @florianbouvot.
The version is extracted from the package.json file located at the root of the repository.

version=$(grep version < "${repo_root}/package.json" | \
head -1 | awk -F: '{ print $2 }' | sed 's/[",\t ]//g')

Do you confirm the file does exist on your side?

@LeoColomb yes package.json is present.

I do the following things:

  • In the root of our project: git clone https://github.com/h5bp/server-configs-apache.git
  • Update path in my htaccess.conf (present in root project): h5bp/ to server-configs-apache/h5bp/ (never add to do that before)
  • Build using: server-configs-apache/bin/build.sh ./.htaccess ./htaccess.conf

Capture d’écran 2022-05-11 à 17 14 11

  • Build using: server-configs-apache/bin/build.sh ./.htaccess ./htaccess.conf

And this does not generate any warnings?
What is the output of the command?

@LeoColomb the output

Capture d’écran 2022-05-11 à 18 59 49

Yes, here is the reason why: realpath command is not found.
Introduced by 93d524f with #295
@tomkyle Any idea?

OK, so the command is missing on that system. Seems to me though that the realpath command is nothing new in our *nix eco systems as it stems from 2007 or 2008 [1] and also found its way into GNU coreutils 10 years ago [2].

As a quick fix for @florianbouvot I'd propose installing the realpath command (simple one-liner) [3], so he's up and running again in 5 minutes.

Because of the ages-old availability of this command I do not feel a sophisticated fallback solution is necessary. But a nicer error handling could improve screen experience, perhaps something like this:

function require  {
	command -v $1 >/dev/null 2>&1 || {
		echo >&2 "Command '${1}' is required but not installed."
		exit 1;
	}
}

require realpath

If needed I can provide PR this weekend.

[1] https://stackoverflow.com/a/284664
[2] coreutils/coreutils@77ea441
[3] https://command-not-found.com/realpath

@florianbouvot You are using MacOs which doesn't have realpath by default. If you have Homebrew installed then brew install coreutils will solve your issue.

If you don't have Homebrew installed then I would recommend installing Homebrew. 😃

@nosilleg yes I'm using macOS and of course Home-brew, it's the first time that it doesn't works.
I will try with coreutils.

EDIT: It works well, thanks you ;)