Skip to content

Commit 0bbdc0a

Browse files
authored
Merge pull request #183 from dafyddj/add-README
Improve reusability
2 parents 995bf20 + 39889ce commit 0bbdc0a

File tree

4 files changed

+37
-2
lines changed

4 files changed

+37
-2
lines changed

.rubocop.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,7 @@ Metrics/LineLength:
88
Max: 88
99

1010
# Any offenses that should be fixed, e.g. collected via. `rubocop --auto-gen-config`
11+
# <REMOVEME
1112
Metrics/BlockLength:
1213
Max: 36
14+
# REMOVEME>

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ jobs:
100100
# - env: INSTANCE=default-amazonlinux-2-2017-7-py2
101101
# - env: INSTANCE=default-arch-base-latest-2017-7-py2
102102

103+
# <REMOVEME
103104
# Test the conversion of `template-formula` into another formula
104105
# ready for development
105106
- env: 'Conversion'
@@ -110,7 +111,7 @@ jobs:
110111
- DEBUG=true bin/convert-formula.sh converted
111112
- '[ $(git rev-list HEAD --count) -eq 2 ]'
112113
- bin/kitchen verify default-debian-10-2019-2-py3
113-
114+
# REMOVEME>
114115
## Define the release stage that runs `semantic-release`
115116
- stage: 'release'
116117
language: 'node_js'

bin/convert-formula.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@ convert_formula() {
4343
git mv TEMPLATE "${NEW_NAME}"
4444
grep --recursive --files-with-matches --exclude-dir=.git TEMPLATE . \
4545
| xargs -L 1 ex -u NONE -sc '%s/TEMPLATE/'"${NEW_NAME}"'/g|x'
46+
# Searching across multiple lines.
47+
# See https://vim.fandom.com/wiki/Search_across_multiple_lines
48+
ex -u NONE -sc '%s/^.. <REMOVEME\_.\{-}.. REMOVEME>/None/g|x' docs/README.rst
49+
ex -u NONE -sc '%s/^\s*# <REMOVEME\_.\{-}# REMOVEME>\n//g|x' .travis.yml
50+
ex -u NONE -sc '%s/^\s*# <REMOVEME\_.\{-}# REMOVEME>\n//g|x' .rubocop.yml
51+
ex -u NONE -sc '%s/^\(version:\).*/\1 1.0.0/g|x' FORMULA
4652
# shellcheck disable=SC2016 # Expressions don't expand in single quotes
4753
git commit --quiet --all \
4854
--message 'feat: convert `template-formula` to `'"${NEW_NAME}"'-formula`' \

docs/README.rst

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,33 @@ Please see `How to contribute <https://github.com/saltstack-formulas/.github/blo
4545
Special notes
4646
-------------
4747

48-
None
48+
.. <REMOVEME
49+
50+
Using this template
51+
^^^^^^^^^^^^^^^^^^^
52+
53+
The easiest way to use this template formula as a base for a new formula is to use GitHub's **Use this template** button to create a new repository. For consistency with the rest of the formula ecosystem, name your formula repository following the pattern ``<formula theme>-formula``, where ``<formula theme>`` consists of lower-case alphabetic characters and numbers.
54+
55+
In the rest of this example we'll use ``example`` as the ``<formula theme>``.
56+
57+
Follow these steps to complete the conversion from ``template-formula`` to ``example-formula``. ::
58+
59+
$ git clone [email protected]:YOUR-USERNAME/example-formula.git
60+
$ cd example-formula/
61+
$ bin/convert-formula.sh example
62+
$ git push --force
63+
64+
Alternatively, it's possible to clone ``template-formula`` into a new repository and perform the conversion there. For example::
65+
66+
$ git clone https://github.com/saltstack-formulas/template-formula example-formula
67+
$ cd example-formula/
68+
$ bin/convert-formula.sh example
69+
70+
To take advantage of `semantic-release <https://github.com/semantic-release/semantic-release>`_ for automated changelog generation and release tagging, you will need a GitHub `Personal Access Token <https://help.github.com/en/github/authenticating-to-github/creating-a-personal-access-token-for-the-command-line>`_ with at least the **public_repo** scope.
71+
72+
In the Travis repository settings for your new repository, create an `environment variable <https://docs.travis-ci.com/user/environment-variables/#defining-variables-in-repository-settings>`_ named ``GH_TOKEN`` with the personal access token as value, restricted to the ``master`` branch for security.
73+
74+
.. REMOVEME>
4975
5076
Available states
5177
----------------

0 commit comments

Comments
 (0)