summaryrefslogtreecommitdiffstats
path: root/toolkit/components/nimbus/schemas/vendor.sh
blob: de0f5b5ca6463ebe6c62db0792851d7ea5530e17 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/bin/bash
set -euo pipefail

 # Path to mach relative to toolkit/components/nimbus/schemas/
MACH=$(realpath "../../../../mach")

if [[ $(uname -a) == *MSYS* ]]; then
  MACH="python ${MACH}"
fi

NPM="${MACH} npm"

# Strip the leading v from the tag to get the version number.
TAG="$1"
VERSION="${TAG:1}"
NAMESPACE="@mozilla/"
PACKAGE="nimbus-shared"
URL="https://registry.npmjs.org/${NAMESPACE}${PACKAGE}/-/${PACKAGE}-${VERSION}.tgz"

mkdir -p tmp
cd tmp

curl --proto '=https' --tlsv1.2 -sSf "${URL}" | tar -xzf - --strip-components 1

cp "schemas/experiments/NimbusExperiment.json" "../NimbusExperiment.schema.json"
cd ..

# Ensure the generated file ends with a newline
sed -i -e '$a\' NimbusExperiment.schema.json

rm -rf tmp