<commit_before>require 'json'

def write_configuration
  config = {}
  if File.exist?('configuration')
    config = JSON.parse(File.read('configuration'))
    config['accessKeyId'] ||= ENV['AWS_ACCESS_KEY_ID']
    config['secretAccessKey'] ||= ENV['AWS_SECRET_ACCESS_KEY']
  end
  File.open('test/configuration.js', 'w') do |f|
    config_json = JSON.generate(config).inspect
    f.puts "module.exports = JSON.parse(#{config_json});"
  end
end

def sdk_version
  JSON.parse(File.read('package.json'))['version']
end

namespace :browser do
  $BUILDER = "./vendor/dist-tools/browser-builder.js"
  $BROWSERIFY = "./vendor/dist-tools/node_modules/.bin/browserify"
  $BROWSERIFY_DIST = "dist/aws-sdk-#{sdk_version}.js"
  $BROWSERIFY_DIST_LATEST = "dist/aws-sdk.js"
  $BROWSERIFY_TEST = "test/browser/build/tests.js"

  task :all => [:build, :test]

  task :setup_dist_tools do
    unless File.directory?("vendor/dist-tools")
      sh "git clone git://github.com/aws/aws-sdk-js-dist-tools vendor/dist-tools"
      sh "cd vendor/dist-tools && npm install"
    end
  end

  desc 'Builds browser distributable (SERVICES=s3,dynamodb,...)'
  task :build => :build_complete do
    sh "MINIFY=1 #{$BUILDER} > #{$BROWSERIFY_DIST.sub('.js', '.min.js')}"
  end

  task :build_complete => [:setup_dist_tools, :dist_path] do
    sh "MINIFY='' #{$BUILDER} > #{$BROWSERIFY_DIST}"
    cp $BROWSERIFY_DIST, $BROWSERIFY_DIST_LATEST
  end

  task :build_all => [:setup_dist_tools, :dist_path] do
    sh "MINIFY='' #{$BUILDER} all > dist/aws-sdk-all.js"
  end

<commit_msg>Don't need to npm install devDependencies in dist-tools<commit_after>require 'json'

def write_configuration
  config = {}
  if File.exist?('configuration')
    config = JSON.parse(File.read('configuration'))
    config['accessKeyId'] ||= ENV['AWS_ACCESS_KEY_ID']
    config['secretAccessKey'] ||= ENV['AWS_SECRET_ACCESS_KEY']
  end
  File.open('test/configuration.js', 'w') do |f|
    config_json = JSON.generate(config).inspect
    f.puts "module.exports = JSON.parse(#{config_json});"
  end
end

def sdk_version
  JSON.parse(File.read('package.json'))['version']
end

namespace :browser do
  $BUILDER = "./vendor/dist-tools/browser-builder.js"
  $BROWSERIFY = "./vendor/dist-tools/node_modules/.bin/browserify"
  $BROWSERIFY_DIST = "dist/aws-sdk-#{sdk_version}.js"
  $BROWSERIFY_DIST_LATEST = "dist/aws-sdk.js"
  $BROWSERIFY_TEST = "test/browser/build/tests.js"

  task :all => [:build, :test]

  task :setup_dist_tools do
    unless File.directory?("vendor/dist-tools")
      sh "git clone git://github.com/aws/aws-sdk-js-dist-tools vendor/dist-tools"
      sh "cd vendor/dist-tools && npm install --production"
    end
  end

  desc 'Builds browser distributable (SERVICES=s3,dynamodb,...)'
  task :build => :build_complete do
    sh "MINIFY=1 #{$BUILDER} > #{$BROWSERIFY_DIST.sub('.js', '.min.js')}"
  end

  task :build_complete => [:setup_dist_tools, :dist_path] do
    sh "MINIFY='' #{$BUILDER} > #{$BROWSERIFY_DIST}"
    cp $BROWSERIFY_DIST, $BROWSERIFY_DIST_LATEST
  end

  task :build_all => [:setup_dist_tools, :dist_path] do
    sh "MINIFY='' #{$BUILDER} all > dist/aws-sdk-all.js"
  end


{'fraction_non_alphanumeric': 0.16502697556331322, 'fraction_numerical': 0.0012694382735639479, 'mean_word_length': 4.218543046357616, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 17, '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': '6300164', 'n_tokens_mistral': 1211, 'n_tokens_neox': 1172, 'n_words': 212}