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

set -e
set -u

find_replace () {
  git ls-files -z | xargs -0 sed -i "$1"
}

check_env () {
  test -d .git || (echo 'This is not a Git repository. Exiting.' && exit 1)
  for cmd in ${1}; do
    command -v ${cmd} >/dev/null 2>&1 || \
      (echo "Could not find '$cmd' which is required to continue." && exit 2)
  done
  echo
  echo 'Ready to bootstrap your new project!'
  echo
}

stage_env () {
  echo
  git rm -f makenew.sh
  echo
  echo 'Staging changes.'
  git add --all
  echo
  echo 'Done!'
  echo
}

makenew () {
  read -p '> Package title: ' mk_title
  read -p '> Package name (slug): ' mk_slug
  read -p '> Short package description: ' mk_description
  read -p '> Version number: ' mk_version
  read -p '> Author name: ' mk_author
  read -p '> Author email: ' mk_email
  read -p '> Copyright owner: ' mk_owner
  read -p '> Copyright year: ' mk_year
  read -p '> GitHub user or organization name: ' mk_user
  read -p '> GitHub repository name: ' mk_repo

  sed -i -e '11,100d;157,160d' README.md
  sed -i -e "11i ${mk_description}" README.md

  find_replace "s/version\": \".*\"/version\": \"${mk_version}\"/g"
  find_replace "s/0\.0\.0\.\.\./${mk_version}.../g"
  find_replace "s/npm Package Skeleton/${mk_title}/g"
  find_replace "s/npm package skeleton\./${mk_description}/g"
  find_replace "s/2016 <NAME>/${mk_year} ${mk_owner}/g"
  find_replace "s/<NAME>/${mk_author}/g"
  find_replace "s/<EMAIL>\.<EMAIL>/${mk_email}/g"
  find_replace "s/makenew\/npm-package/${mk_user}\/${mk_repo}/g"
  find_replace "s/makenew-npm-package/${mk_slug}/g"

  echo
  echo 'Replacing boilerplate.'
}

check_env 'git read sed xargs'
makenew
stage_env
exit
<commit_msg>Add attribution to README<commit_after>#!/usr/bin/env sh

set -e
set -u

find_replace () {
  git ls-files -z | xargs -0 sed -i "$1"
}

check_env () {
  test -d .git || (echo 'This is not a Git repository. Exiting.' && exit 1)
  for cmd in ${1}; do
    command -v ${cmd} >/dev/null 2>&1 || \
      (echo "Could not find '$cmd' which is required to continue." && exit 2)
  done
  echo
  echo 'Ready to bootstrap your new project!'
  echo
}

stage_env () {
  echo
  git rm -f makenew.sh
  echo
  echo 'Staging changes.'
  git add --all
  echo
  echo 'Done!'
  echo
}

makenew () {
  read -p '> Package title: ' mk_title
  read -p '> Package name (slug): ' mk_slug
  read -p '> Short package description: ' mk_description
  read -p '> Version number: ' mk_version
  read -p '> Author name: ' mk_author
  read -p '> Author email: ' mk_email
  read -p '> Copyright owner: ' mk_owner
  read -p '> Copyright year: ' mk_year
  read -p '> GitHub user or organization name: ' mk_user
  read -p '> GitHub repository name: ' mk_repo

  sed -i -e '11,100d;157,160d' README.md
  sed -i -e "11i ${mk_description}" README.md

  find_replace "s/version\": \".*\"/version\": \"${mk_version}\"/g"
  find_replace "s/0\.0\.0\.\.\./${mk_version}.../g"
  find_replace "s/npm Package Skeleton/${mk_title}/g"
  find_replace "s/npm package skeleton\./${mk_description}/g"
  find_replace "s/2016 <NAME>/${mk_year} ${mk_owner}/g"
  find_replace "s/<NAME>/${mk_author}/g"
  find_replace "s/<EMAIL>/${mk_email}/g"
  find_replace "s/makenew\/npm-package/${mk_user}\/${mk_repo}/g"
  find_replace "s/makenew-npm-package/${mk_slug}/g"

  mk_attribution='> Built from [makenew/npm-package](https://github.com/makenew/npm-package).'
  sed -i -e "9i ${mk_attribution}\n" README.md

  echo
  echo 'Replacing boilerplate.'
}

check_env 'git read sed xargs'
makenew
stage_env
exit

{'fraction_non_alphanumeric': 0.16723259762308998, 'fraction_numerical': 0.0155631013016412, 'mean_word_length': 3.11046511627907, 'pattern_counts': {'":': 4, '<': 10, '<?xml version=': 0, '>': 35, 'https://': 1, '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': '3452796', 'n_tokens_mistral': 1419, 'n_tokens_neox': 1359, 'n_words': 381}