#!/bin/bash

npm install yarn

export NODE_OPTIONS=--openssl-legacy-provider

version=$(cat version.txt)
version=$(( $version + 1 ))
echo -n $version > ./version.txt

echo New version: $version

(
  sed -i "s/\"version\": \"2.9.*\"/\"version\": \"2.9.$version\"/" package.json
  npm run build
  npm publish --access=public
)

sleep 15
(
  echo "Building app"
  cd ../cms/application
  sed -i "s/formula\": \"^2.9.*\"/formula\": \"^2.9.$version\"/" package.json

  npm install
)
