<commit_before>#!/usr/bin/env bash

NODE_BIN=${NODE_BIN:-node_modules/.bin}
CONTAINER_NAME=${CONTAINER_NAME:-magic-localhost}
MAGIC_DIR=${MAGIC_DIR:-node_modules/magic-root}
MAGIC_BIN=${MAGIC_BIN:-node_modules/magic-root/bin}
NODEJS_SRC_FILES=${NODEJS_FILES:-"src"}
NODEJS_DIST_DIR=${NODEJS_DIST_DIR:-"dist"}

DIST_DIR=${DIST_DIR:-dist}

function dev() {
  echo "start dev environment"
  build-src

  export NODE_ENV=development;
  $NODE_BIN/nodemon \
    --exec "$NODE_BIN/babel-node src/index.js" \
    --watch ./src
}

function build() {
  echo "start building $CONTAINER_NAME docker container"

  docker build \
  --tag $CONTAINER_NAME \
  --build-arg NODE_ENV=production \
    . # dot!

  echo "finished building docker container"
}

function build-root() {
  echo "start building magic-root"

  ${MAGIC_DIR}/cli.sh docker-build

  echo "finished building magic-root"
}

function build-src() {
  build-node-js
  build-express-dirs
}

function build-node-js() {
  echo "start building nodejs"

  mkdir -p $DIST_DIR/

  $NODE_BIN/babel \
    --out-dir $NODEJS_DIST_DIR \
    $NODEJS_SRC_FILES # order is important

  echo "finished building nodejs"
}

function build-express-dirs() {
  echo "start copying express views and public dir"

  mkdir -p $DIST_DIR/

  cp -r \
    src/public src/views \
    $DIST_DIR/

  echo "finished copying express views and public dir"
}

function run() {
  docker-rm

  echo "start docker container"
  docker run \
    --name $CONTAINER_NAME \
    --detach \
    $CONTAINER_NAME

  ip
}

function ip() {
  echo "gather ip"
  ip=$(python $MAGIC_BIN/ip.py $CONTAINER_NAME)
  echo "container $CONTAINER_NAME started with ip: $ip"<commit_msg>change ip dir<commit_after>#!/usr/bin/env bash

NODE_BIN=${NODE_BIN:-node_modules/.bin}
CONTAINER_NAME=${CONTAINER_NAME:-magic-localhost}
MAGIC_DIR=${MAGIC_DIR:-node_modules/magic-root}
MAGIC_BIN=${MAGIC_BIN:-node_modules/magic-root/bin}
NODEJS_SRC_FILES=${NODEJS_FILES:-"src"}
NODEJS_DIST_DIR=${NODEJS_DIST_DIR:-"dist"}

DIST_DIR=${DIST_DIR:-dist}

function dev() {
  echo "start dev environment"
  build-src

  export NODE_ENV=development;
  $NODE_BIN/nodemon \
    --exec "$NODE_BIN/babel-node src/index.js" \
    --watch ./src
}

function build() {
  echo "start building $CONTAINER_NAME docker container"

  docker build \
  --tag $CONTAINER_NAME \
  --build-arg NODE_ENV=production \
    . # dot!

  echo "finished building docker container"
}

function build-root() {
  echo "start building magic-root"

  ${MAGIC_DIR}/cli.sh docker-build

  echo "finished building magic-root"
}

function build-src() {
  build-node-js
  build-express-dirs
}

function build-node-js() {
  echo "start building nodejs"

  mkdir -p $DIST_DIR/

  $NODE_BIN/babel \
    --out-dir $NODEJS_DIST_DIR \
    $NODEJS_SRC_FILES # order is important

  echo "finished building nodejs"
}

function build-express-dirs() {
  echo "start copying express views and public dir"

  mkdir -p $DIST_DIR/

  cp -r \
    src/public src/views \
    $DIST_DIR/

  echo "finished copying express views and public dir"
}

function run() {
  docker-rm

  echo "start docker container"
  docker run \
    --name $CONTAINER_NAME \
    --detach \
    $CONTAINER_NAME

  ip
}

function ip() {
  echo "gather ip"
  ip=$(python ./bin/ip.py $CONTAINER_NAME)
  echo "container $CONTAINER_NAME started with ip: $ip"
{'fraction_non_alphanumeric': 0.12772958420580316, 'fraction_numerical': 0.0, 'mean_word_length': 3.5250338294993235, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, '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': '5744824', 'n_tokens_mistral': 1278, 'n_tokens_neox': 1177, 'n_words': 271}