<commit_before>#
# The new project generator tool
#
# Copyright (C) 2011-2012 <NAME>
#
fs       = require('fs')
lovelyrc = require('../lovelyrc')

placeholders = {}

#
# Starts the new project generation
#
# @param {String} projectname
# @param {Array} the rest of the arguments
# @return void
#
generate = (projectname, args) ->
  directory    = "#{process.cwd()}/#{projectname}"
  project_tpl  = "#{__dirname}/../project_tpl"
  use_coffee   = args.indexOf('--js')     == -1
  use_stylus   = args.indexOf('--stylus') != -1
  use_sass     = !use_stylus && args.indexOf('--css') == -1

  placeholders =
    projectname: projectname,
    projectunit: projectname.replace(/(^|-)[a-z]/g, (m)-> m.toUpperCase())
    projectfile: projectname.replace(/\-/g, '_')
    year:        new Date().getFullYear(),
    username:    lovelyrc.name || "<NAME>"


  print "Creating directory: #{projectname}"
  fs.mkdirSync(directory, 0o0755)

  # just checking if the file should be copied over
  suitable = (filename) ->
    ((use_coffee and filename != 'main.js')      or
    (!use_coffee and filename != 'main.coffee')) and
    ((use_stylus and filename != 'main.css' and filename != 'main.sass') or
    (!use_stylus and filename != 'main.styl'))   and
    ((use_sass   and filename != 'main.css' and filename != 'main.styl') or
    (!use_sass   and filename != 'main.sass'))

  for filename in fs.readdirSync(project_tpl)
    if suitable(filename)
      source = fs.readFileSync("#{project_tpl}/#{filename}").toString()

      print " - #{filename}"
      fs.writeFileSync("#{directory}/#{filename}", patch_source(source))


  print " - src/"
  fs.mkdirSync("#{directory}/src", 0o0755)

  filename = "#{placeholders.projectfile}.#{
    if use_coffee then 'coffee' else 'js'
  }"

  source = if use_coffee then """
  #
  # Project's main unit
  #
  # Copyright (C) %{year} %{username}
  #
  """ else """
  /**
   * Project's main unit
   *
   * Copyright (C) %{year} %{username}
   */
  """

  print " - src/#{filename}"
  fs.writeFileSync("#{directory}/src/#{filename}", patch_source(source))

  print " - test/"
  fs.mkdirSync("#{directory}/test", 0o0755)

  filename = "#{placeholders.projectfile}_test.#{
    if use_coffee then 'coffee' else 'js'
  }"

  source = if use_coffee then """
  #
  # Project's main unit test
  #
  # Copyright (C) %{year} %{username}
  #
  {Test, assert} = require('lovely')

  describe "%{projectunit}", ->
    %{projectunit} = window = document = null

    before Test.load module, (build, win)->
      %{projectunit} = build
      window   = win
      document = win.document

    it "should have a version", ->
      assert.ok %{projectunit}.version


  """ else """
  /**
   * Project's main unit test
   *
   * Copyright (C) %{year} %{username}
   */
  var Lovely = require('lovely');
  var Test   = Lovely.Test;
  var assert = Lovely.assert;

  describe("%{projectunit}", function() {
    var %{projectunit}, window, document;

    before(Test.load(module, function(build, win) {
      %{projectunit} = build;
      window   = win;
      document = win.document;
    }));

    it("should have a version number", function() {
      assert.ok(%{projectunit}.version);
    });
  });

  """
<commit_msg>CLI/new fixing the new projects generator<commit_after>#
# The new project generator tool
#
# Copyright (C) 2011-2012 <NAME>
#
fs       = require('fs')
lovelyrc = require('../lovelyrc')

placeholders = {}

#
# Starts the new project generation
#
# @param {String} projectname
# @param {Array} the rest of the arguments
# @return void
#
generate = (projectname, args) ->
  directory    = "#{process.cwd()}/#{projectname}"
  project_tpl  = "#{__dirname}/../project_tpl"
  use_coffee   = args.indexOf('--js')     == -1
  use_stylus   = args.indexOf('--stylus') != -1
  use_sass     = !use_stylus && args.indexOf('--css') == -1

  placeholders =
    projectname: projectname,
    projectunit: projectname.replace(/(^|-)([a-z])/g, (m,m1,m2)-> m2.toUpperCase())
    projectfile: projectname.replace(/\-/g, '_')
    year:        new Date().getFullYear(),
    username:    lovelyrc.name || "<NAME>"


  print "Creating directory: #{projectname}"
  fs.mkdirSync(directory, 0o0755)

  # just checking if the file should be copied over
  suitable = (filename) ->
    ((use_coffee and filename != 'main.js')      or
    (!use_coffee and filename != 'main.coffee')) and
    ((use_stylus and filename != 'main.css' and filename != 'main.sass') or
    (!use_stylus and filename != 'main.styl'))   and
    ((use_sass   and filename != 'main.css' and filename != 'main.styl') or
    (!use_sass   and filename != 'main.sass'))

  for filename in fs.readdirSync(project_tpl)
    if suitable(filename)
      source = fs.readFileSync("#{project_tpl}/#{filename}").toString()

      print " - #{filename}"
      fs.writeFileSync("#{directory}/#{filename}", patch_source(source))


  print " - src/"
  fs.mkdirSync("#{directory}/src", 0o0755)

  filename = "#{placeholders.projectfile}.#{
    if use_coffee then 'coffee' else 'js'
  }"

  source = if use_coffee then """
  #
  # Project's main unit
  #
  # Copyright (C) %{year} %{username}
  #
  """ else """
  /**
   * Project's main unit
   *
   * Copyright (C) %{year} %{username}
   */
  """

  print " - src/#{filename}"
  fs.writeFileSync("#{directory}/src/#{filename}", patch_source(source))

  print " - test/"
  fs.mkdirSync("#{directory}/test", 0o0755)

  filename = "#{placeholders.projectfile}_test.#{
    if use_coffee then 'coffee' else 'js'
  }"

  source = if use_coffee then """
  #
  # Project's main unit test
  #
  # Copyright (C) %{year} %{username}
  #
  {Test, assert} = require('lovely')

  describe "%{projectunit}", ->
    %{projectunit} = window = document = $ = null

    before Test.load module, (build, win)->
      %{projectunit} = build
      window   = win
      document = win.document
      $        = win.Lovely.module('dom')

    it "should have a version", ->
      assert.ok %{projectunit}.version


  """ else """
  /**
   * Project's main unit test
   *
   * Copyright (C) %{year} %{username}
   */
  var Lovely = require('lovely');
  var Test   = Lovely.Test;
  var assert = Lovely.assert;

  describe("%{projectunit}", function() {
    var %{projectunit}, window, document, $;

    before(Test.load(module, function(build, win) {
      %{projectunit} = build;
      window   = win;
      document = win.document;
      $        = win.Lovely.module('dom');
    }));

    it("should have a version number", function() {
      assert.ok(%{projectunit}.version);
    });
  });

  """

{'fraction_non_alphanumeric': 0.17556671230792636, 'fraction_numerical': 0.00836756427810741, 'mean_word_length': 3.043050430504305, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 19, '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': '4375989', 'n_tokens_mistral': 2298, 'n_tokens_neox': 2181, 'n_words': 515}