POSIX scripting and other tools are a viable alternative as well. Though despite knowing all of the commands you’ve mentioned, and regularly sharing/applying git patches, I think I would still have difficulty renaming FileA to FileB in a tarball or patch prior to unpacking or applying it.
The declarative approach seems like a nice feature that greatly reduces the cognitive friction there. But as a single feature, it’s not clear whether it’s worth a tool change.
cat >README <<'EOF'
This is a README
EOF
# This is a comment
mkdir -p myProject
cat >myproject/index.js <<'EOF'
console.log("Hello world")
EOF
it does not require any tools to extract either.
(and if you omit quotes around EOF, you can do substitutions) MY_EMAIL=put-your-email-here
cat >config <<EOF
email=$MY_EMAIL
EOFThere are two caveats:
First, if there's any chance at all that the heredoc may contain a $, or a `, or possibly some other shell-magical characters, then you have to use a single-quoted heredoc:
cat <<'EOF'...
This means that if you want to do variable interpolation, like you're doing, then you need something that looks like: cat <<'EOF' | sed -e "s/\\\$username/$username/g" -e "s/\\\$my_email/$my_email/g" ...
It looks yucky and unwieldy at first, but I've found that it's nice to be able to see at the top of the heredoc exactly what's getting replaced and what values it needs.Second, if root privileges are required to write the file, then you need to use `tee`, because you can't sudo an output redirection:
cat <<'EOF' | sed -e "s/\\\$username/$username/g" | sudo tee /path/to/file >/dev/null
After using it for a while, I've found I really like this pattern for managing configuration file templates.You're right though that something like Stamp could be built using standard shell tools if someone were so inclined.
https://github.com/benibela/nasty-files
You probably cannot clone the repo on Windows. It works well on Linux. But in KDE you could not delete it after checkout
You could imagine using this as a development dependency, to standardize the creation of new (anything) that follows a predictable pattern. Check in your stamp file, and any junior dev who creates a new [anything] in your project can get all the custom boilerplate and best-practices right away.
I can’t tell from the article, but if it allowed “unstamp -“ and then simply copy-pasting into stdin from a site, that would be great.
Like `patch`, then?
I actually think I added the ability to "compile" a Stamp file to bash. I at least remember starting that, don't think I finished it.
I think the important thing here is not the library and node stuff, but the simple declarative format, which could be implemented in any language.
Though of course JS and Node are very popular, so I will do my best to make this work great.
As for the solution not existing yet - as people pointed out there is tar, zip, git, and shar which all seem to accomplish the same thing
I have no idea how someone could read such a thorough README and say "this sounds like a solution looking for a problem" with a straight face.
Is visibility into what's being created a problem?
The listed problems like "everytime the template changes, author has to rezip and reupload the folder" don't seem to be solved with stamp to me, it seems like the problem is now shifted to controlling a version of this new format and still distributing it somehow (probably through git) at which point you ask yourself why can't the git repo already have the structure? If somebody wants to rename something they do this really easily, no need for var substitution.
If there was a migration mechanism that would move files from an old template to a new one I would see value added.
It makes find and replace across all files trivial with your editor, whereas that would be less fluid with a zip.
While this of course sound like a cool project and my comment might be the most Hacker News-y thing [1] I think it's aimed at developers and so it fits.
I don't agree with the zip downsides listed in the repo since firstly `unzip -l` exists to see what's in a zip and secondly the argument with reuploading the zip doesn't work in favor of a different format since you also need to update it in a remote when changed.
Secondly I am kind of amused about this format when `touch`, `mkdir -p` and `echo` are available in every POSIX compliant system which can be combined to create a nice coherent shell script which without dependencies would cover the functionality of this project as far as I understand.
I don't want to sound condescending but I'm a feeling a little left-pad [2] on this one.
[1]: https://news.ycombinator.com/item?id=9224
[2]: https://www.davidhaney.io/npm-left-pad-have-we-forgotten-how...