<commit_before>#!/bin/bash

# version
VERSION=$(node -pe "require('./package.json').version")

# Current branch
CUR_BRANCH=$(git rev-parse --abbrev-ref HEAD)

# folder to be pushed
DIST_FOLDER=release

# destination folder
DEST_FOLDER=release

# destination remote name
if [[ $TRAVIS == "true" ]]; then
  DEST_REMOTE=origin
else
  DEST_REMOTE=upstream
fi

# commit message string
COMMIT_MESSAGE="skip:$VERSION-release"

echo "*** Releasing docs for ${VERSION} on ${CUR_BRANCH} --> ${DEST_REMOTE} ***"

# create release directory
rm -rf release && mkdir -p release/$VERSION

# build & copy to release path
npm run jsdoc && cp -r doc dist release/$VERSION/

# if this is the @next release channel, also deploy docs to in latest folder
if [[ $CUR_BRANCH == "next" ]]; then
  DIST_TAG=next
else
  DIST_TAG=latest
fi

mkdir release/$DIST_TAG
cp -r doc dist release/$DIST_TAG

# push to github pages
# Use fixed gh-pages version, due to the bug from the latest 2.1.0
# https://travis-ci.org/naver/billboard.js/jobs/568700732#L1172
# https://github.com/tschaub/gh-pages/issues/308
npx gh-pages@2.0.1 --dist $DIST_FOLDER --dest $DEST_FOLDER --add --remote $DEST_REMOTE --message $COMMIT_MESSAGE<commit_msg>chore(release): Update deploy script<commit_after>#!/bin/bash

setup() {
  # version
  VERSION=$(node -pe "require('./package.json').version")

  # Current branch
  CUR_BRANCH=$(git rev-parse --abbrev-ref HEAD)

  # folder to be pushed
  DIST_FOLDER=release

  # destination folder
  DEST_FOLDER=release

  # destination remote name
  if [[ $TRAVIS == "true" ]]; then
    DEST_REMOTE=origin
  else
    DEST_REMOTE=upstream
  fi

  # if this is the @next release channel, also deploy docs to in latest folder
  if [[ $CUR_BRANCH == "next" ]]; then
    DIST_TAG=next
  else
    DIST_TAG=latest
  fi
}

build() {
  # commit message string
  COMMIT_MESSAGE="skip:$VERSION-release"

  echo "*** Releasing docs for ${VERSION} on ${CUR_BRANCH} --> ${DEST_REMOTE} ***"

  # create release directory
  rm -rf release && mkdir -p release/$VERSION

  # build & copy to release path
  npm run build && npm run jsdoc
  cp -r doc dist release/$VERSION/

  # copy built files to dist_tag folder
  mkdir release/$DIST_TAG
  cp -r doc dist release/$DIST_TAG
}

push() {
  git config --global user.email "<EMAIL>"
  git config --global user.name "<NAME>"

  # Remove existing remote
  git remote rm ${DEST_REMOTE}

  # Add new remote with access token in the git URL for authentication
  git remote add ${DEST_REMOTE} https://netil:${GH_TOKEN}@github.com/naver/billboard.js.git > /dev/null 2>&1

  # push to github pages
  # Use fixed gh-pages version, due to the bug from the latest 2.1.0
  # https://travis-ci.org/naver/billboard.js/jobs/568700732#L1172
  # https://github.com/tschaub/gh-pages/issues/308
  npx gh-pages@2.0.1 --dist $DIST_FOLDER --dest $DEST_FOLDER --add --remote $DEST_REMOTE --message $COMMIT_MESSAGE --silent
}

setup
build
push
{'fraction_non_alphanumeric': 0.12696245733788397, 'fraction_numerical': 0.015699658703071672, 'mean_word_length': 3.765853658536585, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 5, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '181140', 'n_tokens_mistral': 1099, 'n_tokens_neox': 1001, 'n_words': 298}