@amimpact/willy-utils 5.0.0 โ 5.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.vscode/settings.json +3 -0
- package/bitbucket-pipelines.yml +13 -0
- package/package.json +4 -7
- package/scripts/publish-npm.sh +71 -0
package/package.json
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@amimpact/willy-utils",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.1",
|
|
4
4
|
"description": "Javascript utils",
|
|
5
5
|
"scripts": {
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
"publish:preminor": "npm version preminor --preid beta && npm publish --tag beta",
|
|
10
|
-
"publish:minor": "npm version minor && npm publish",
|
|
11
|
-
"postpublish": "git push origin --all; git push origin --tags"
|
|
6
|
+
"version:patch": "npm version patch",
|
|
7
|
+
"version:minor": "npm version minor",
|
|
8
|
+
"postversion": "git push origin HEAD && git push origin --tags"
|
|
12
9
|
},
|
|
13
10
|
"repository": {
|
|
14
11
|
"type": "git",
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
|
|
3
|
+
set -e
|
|
4
|
+
|
|
5
|
+
# Zorg dat de .npmrc ALTIJD wordt verwijderd bij afsluiten of crash
|
|
6
|
+
cleanup() {
|
|
7
|
+
if [ -f .npmrc ]; then
|
|
8
|
+
rm .npmrc
|
|
9
|
+
echo "๐งน Tijdelijke .npmrc netjes opgeruimd."
|
|
10
|
+
fi
|
|
11
|
+
}
|
|
12
|
+
trap cleanup EXIT
|
|
13
|
+
|
|
14
|
+
# 1. Veiligheidscheck: Bestaat de token?
|
|
15
|
+
if [ -z "${NPM_TOKEN_PUBLISH}" ]; then
|
|
16
|
+
echo "ERROR: NPM_TOKEN_PUBLISH is not set. Cannot authenticate against the npm registry."
|
|
17
|
+
exit 1
|
|
18
|
+
fi
|
|
19
|
+
|
|
20
|
+
echo "Generating .npmrc with authentication for registry.npmjs.org..."
|
|
21
|
+
echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN_PUBLISH}" > .npmrc
|
|
22
|
+
|
|
23
|
+
# 2. Package gegevens ophalen
|
|
24
|
+
PACKAGE_NAME="$(node -p "require('./package.json').name")"
|
|
25
|
+
PACKAGE_VERSION="$(node -p "require('./package.json').version")"
|
|
26
|
+
|
|
27
|
+
if [ -z "${PACKAGE_NAME}" ] || [ -z "${PACKAGE_VERSION}" ]; then
|
|
28
|
+
echo "ERROR: Could not read package name or version from package.json."
|
|
29
|
+
exit 1
|
|
30
|
+
fi
|
|
31
|
+
|
|
32
|
+
echo "Package: ${PACKAGE_NAME}"
|
|
33
|
+
echo "Version: ${PACKAGE_VERSION}"
|
|
34
|
+
|
|
35
|
+
# 3. Check of deze versie al op NPM staat
|
|
36
|
+
EXISTING_VERSION="$(npm view "${PACKAGE_NAME}@${PACKAGE_VERSION}" version 2>/dev/null || true)"
|
|
37
|
+
|
|
38
|
+
if [ -n "${EXISTING_VERSION}" ]; then
|
|
39
|
+
echo "Version ${PACKAGE_VERSION} of ${PACKAGE_NAME} is already published on npm. Skipping publish."
|
|
40
|
+
exit 0
|
|
41
|
+
fi
|
|
42
|
+
|
|
43
|
+
# 4. Veiligheidscheck: Is dit gestart door een Tag?
|
|
44
|
+
if [ -z "${BITBUCKET_TAG}" ]; then
|
|
45
|
+
echo "ERROR: BITBUCKET_TAG is not set. This script must be run from a tag trigger."
|
|
46
|
+
exit 1
|
|
47
|
+
fi
|
|
48
|
+
|
|
49
|
+
echo "Current Git Tag: ${BITBUCKET_TAG}"
|
|
50
|
+
|
|
51
|
+
# 5. DE MAGIE: Haal remote info op en check op welke branch deze tag leeft
|
|
52
|
+
echo "Fetching remote branch information..."
|
|
53
|
+
git fetch origin --quiet
|
|
54
|
+
|
|
55
|
+
# We kijken of 'origin/master' of 'origin/main' voorkomt in de branches die deze tag bevatten
|
|
56
|
+
IS_ON_MASTER="$(git branch -r --contains HEAD | grep -E 'origin/(master|main)' || true)"
|
|
57
|
+
|
|
58
|
+
if [ -n "${IS_ON_MASTER}" ]; then
|
|
59
|
+
echo "๐ Tag is part of the master/main branch. Publishing as 'latest'..."
|
|
60
|
+
npm publish
|
|
61
|
+
exit 0
|
|
62
|
+
fi
|
|
63
|
+
|
|
64
|
+
# 6. Als de tag niet op master staat, is het een oudere release branch
|
|
65
|
+
# We pakken de Major.Minor van de versie (bijv. 4.14.3 -> 4.14) om de npm-tag te bepalen
|
|
66
|
+
MAJOR_MINOR="$(echo "${PACKAGE_VERSION}" | cut -d. -f1,2)"
|
|
67
|
+
NPM_TAG="release-${MAJOR_MINOR}"
|
|
68
|
+
|
|
69
|
+
echo "๐ฆ Tag is on a release branch. Publishing with tag '${NPM_TAG}'..."
|
|
70
|
+
npm publish --tag "${NPM_TAG}"
|
|
71
|
+
exit 0
|