Skip to content

Commit

Permalink
Chore: Automatically replace package version in readme file to current
Browse files Browse the repository at this point in the history
  • Loading branch information
literat committed Nov 4, 2021
1 parent e2c3c4f commit 97454e1
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 7 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ The package is a wrapper around [Cookie Consent] by [Orest Bida].
Load the script and initialize the plugin right before ending `</body>` tag:

```html
<script defer src="https://cdn.jsdelivr.net/npm/@lmc-eu/cookie-consent-manager@v0.1.0/init.js"></script>
<script defer src="https://cdn.jsdelivr.net/npm/@lmc-eu/cookie-consent-manager@v0.3.0/init.js"></script>
<script>
window.addEventListener('load', function () {
initLmcCookieConsentManager();
Expand All @@ -29,7 +29,7 @@ This will load the plugin from CDN and initialize the plugin with default settin
You can load the plugin from a CDN, as in the basic example above.

```html
<script defer src="https://cdn.jsdelivr.net/npm/@lmc-eu/cookie-consent-manager@v0.1.0/init.js"></script>
<script defer src="https://cdn.jsdelivr.net/npm/@lmc-eu/cookie-consent-manager@v0.3.0/init.js"></script>
```

Alternatively, you can also download the latest version from the [Releases page](https://github.com/lmc-eu/cookie-consent-manager/releases).
Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,10 @@
"changelog:from-tag": "conventional-changelog -p @lmc-eu/conventional-changelog-lmc-bitbucket -i CHANGELOG.md -s",
"changelog:from-beginning": "conventional-changelog -p @lmc-eu/conventional-changelog-lmc-bitbucket -i CHANGELOG.md -s -r 0",
"preversion": "yarn build",
"version": "yarn changelog && git status && git add CHANGELOG.md package.json ./dist && git status",
"version": "yarn changelog && yarn replace-version && git status && git add CHANGELOG.md README.md package.json ./dist && git status",
"postversion": "echo 'Check and push: `git push --set-upstream origin main && git push --tags`'",
"release": "yarn version --`./bin/ci/semver.sh`"
"release": "yarn version --`./bin/ci/semver.sh`",
"replace-version": "node scripts/readme-replace-version.js"
},
"dependencies": {
"@lmc-eu/spirit-design-tokens": "^0.2.0",
Expand All @@ -72,6 +73,7 @@
"postcss": "^8.3.6",
"postcss-cli": "^8.3.1",
"prettier": "^2.4.1",
"replace-in-file": "^6.3.2",
"sass": "^1.43.2",
"stylelint": "^13.13.1",
"stylelint-order": "^4.1.0"
Expand Down
15 changes: 15 additions & 0 deletions scripts/readme-replace-version.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const replace = require('replace-in-file');
const packageJson = require('../package.json');
const options = {
files: 'README.md',
from: /cookie-consent-manager@v([0-9]\.[0-9]\.[0-9])/gm,
to: `cookie-consent-manager@v${packageJson.version}`,
};

replace(options)
.then((results) => {
console.log('Replacement results:', results);
})
.catch((error) => {
console.error('Error occurred:', error);
});
15 changes: 12 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,7 @@ chalk@^2.0.0, chalk@^2.4.1:
escape-string-regexp "^1.0.5"
supports-color "^5.3.0"

chalk@^4.0.0, chalk@^4.1.0, chalk@^4.1.1:
chalk@^4.0.0, chalk@^4.1.0, chalk@^4.1.1, chalk@^4.1.2:
version "4.1.2"
resolved "https://registry.yarnpkg.com/chalk/-/chalk-4.1.2.tgz#aac4e2b7734a740867aeb16bf02aad556a1e7a01"
integrity sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==
Expand Down Expand Up @@ -1481,7 +1481,7 @@ glob-parent@^5.1.2, glob-parent@~5.1.2:
dependencies:
is-glob "^4.0.1"

glob@^7.1.3, glob@^7.1.6:
glob@^7.1.3, glob@^7.1.6, glob@^7.2.0:
version "7.2.0"
resolved "https://registry.yarnpkg.com/glob/-/glob-7.2.0.tgz#d15535af7732e02e948f4c41628bd910293f6023"
integrity sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q==
Expand Down Expand Up @@ -2774,6 +2774,15 @@ repeat-string@^1.0.0:
resolved "https://registry.yarnpkg.com/repeat-string/-/repeat-string-1.6.1.tgz#8dcae470e1c88abc2d600fff4a776286da75e637"
integrity sha1-jcrkcOHIirwtYA//Sndihtp15jc=

replace-in-file@^6.3.2:
version "6.3.2"
resolved "https://registry.yarnpkg.com/replace-in-file/-/replace-in-file-6.3.2.tgz#0f19835137177c89932f45df319f3539a019484f"
integrity sha512-Dbt5pXKvFVPL3WAaEB3ZX+95yP0CeAtIPJDwYzHbPP5EAHn+0UoegH/Wg3HKflU9dYBH8UnBC2NvY3P+9EZtTg==
dependencies:
chalk "^4.1.2"
glob "^7.2.0"
yargs "^17.2.1"

require-directory@^2.1.1:
version "2.1.1"
resolved "https://registry.yarnpkg.com/require-directory/-/require-directory-2.1.1.tgz#8c64ad5fd30dab1c976e2344ffe7f792a6a6df42"
Expand Down Expand Up @@ -3477,7 +3486,7 @@ yargs@^16.0.0, yargs@^16.2.0:
y18n "^5.0.5"
yargs-parser "^20.2.2"

yargs@^17.0.0:
yargs@^17.0.0, yargs@^17.2.1:
version "17.2.1"
resolved "https://registry.yarnpkg.com/yargs/-/yargs-17.2.1.tgz#e2c95b9796a0e1f7f3bf4427863b42e0418191ea"
integrity sha512-XfR8du6ua4K6uLGm5S6fA+FIJom/MdJcFNVY8geLlp2v8GYbOXD4EB1tPNZsRn4vBzKGMgb5DRZMeWuFc2GO8Q==
Expand Down

0 comments on commit 97454e1

Please sign in to comment.