<|start_filename|>data/_utils/pkg.js<|end_filename|>
/**
 * package.json
 */

// Node.js
var path = require('path');

// node_modules
var grunt = require('grunt');
var _ = require('lodash');

// Config
var cwd = path.join.bind(null, __dirname, '../');

var githubApi = require('github');
var github = new githubApi({
  version: '3.0.0',
  timeout: 5000
});

var getPackageFile = function (dest, callback) {

  // Get package.json
  github.repos.getContent({
    user: 'less',
    repo: 'less.js',
    path: 'package.json'
  },

  function (err, resp, cb) {
    if (err) {
      console.log('error: ' + err);
      callback(err, null);
    } else {
      var b = new Buffer(resp.content, 'base64');
      var pkg = {
        name: resp.name,
        text: b.toString()
      };
      var contents = JSON.parse(pkg.text, 'utf-8');
      grunt.log.ok('Saved:'.yellow, dest);

      // Extend package.json with custom properties
      contents = _.extend(contents, require('./extend-pkg'));
      grunt.file.write(dest, JSON.stringify(contents, null, 2));
    }
  });
};

getPackageFile(cwd('less.json'));


<|start_filename|>data/_utils/extend-pkg.js<|end_filename|>
module.exports = {
  repo: "https://github.com/less/less.js.git",
  issues: "https://github.com/less/less.js/issues",
  master: "https://github.com/less/less.js/blob/master/",
  rawmaster: "https://raw.github.com/less/less.js/master/dist/",
  sourcearchive: "https://github.com/less/less.js/archive/v"
};


<|start_filename|>templates/_helpers/rename.js<|end_filename|>
/**
 * Handlebars Helpers
 * Copyright (c) 2014 <NAME>
 * Licensed under the MIT License (MIT).
 */
'use strict';

var path = require('path');


module.exports.register = function (Handlebars, options, params) {



  /**
   * JavaScript's replace function exposed in a helper.
   *
   * @param   {String}  str          The string to evaluate
   * @param   {RegExp}  pattern      The regex or string pattern to replace
   * @param   {String}  replacement  The replacement value
   * @param   {String}  flags        Optional regex flags to use.
   * @return  {String}
   */
  Handlebars.registerHelper('replace', function (str, pattern, replacement, flags) {
    flags = flags || 'gi';
    return str.replace(new RegExp(pattern, flags), replacement);
  });


  /**
   * This helper is used in the `source-link` popovers to
   * rename, say `helper-foo` to `"{{foo}}"` or, if not a
   * helper, rename `bar` to `"bar"`
   *
   * @param   {String}  basename   The string to rename.
   * @return  {String}             The {{renamed}} string
   */

  Handlebars.registerHelper('rename', function (name) {
    if(/helper-/.test(name)) {
      return '{{' + name.split(/\W/)[1] + '}}';
    }
    return new Handlebars.SafeString('"' + name + '"');
  });


  /**
   * Used in the source-link popovers to modify
   * the message based on the file extension.
   *
   * @param   {String}  filepath
   * @return  {String}
   */

  Handlebars.registerHelper('filetype', function (filepath) {
    switch (path.extname(filepath)) {
      case '.md':
        return 'markdown source';
      case '.hbs':
      case '.tmpl':
      case '.html':
        return 'source template';
      default:
        return 'source file';
    }
  });
};


<|start_filename|>data/_utils/utils.js<|end_filename|>
const url = require('url');
const file = require('fs-utils');
const origin = require('remote-origin-url');
const branch = require('git-branch');
const repoUrl = require('github-repo-url');
const ghUsername = require('git-username');
const ghRepoName = require('git-repo-name');


/**
 * Get the current branch for a local git repository
 */

exports.uppercase = function(str) {
  return str.toUpperCase();
};


/**
 * Get the current branch for a local git repository
 */

exports.origin = origin.url;


/**
 * Get the current branch for a local git repository
 */

exports.branch = function () {
  return branch;
};


/**
 * Get the remote origin url for a local git repository
 */

exports.repo_url = function () {
  return repoUrl;
};


/**
 * Get the username from the GitHub remote origin URL
 */

exports.username = function () {
  return ghUsername;
};


/**
 * Get the repo name from the GitHub remote origin URL
 */

exports.repo_name = function () {
  return ghRepoName;
};


/**
 * Count the number of files returned from the
 * given glob pattern.
 */

exports.fileCount = function(str) {
  return file.expand(str).length;
};


/**
 * Get the hostname of a URL
 * @param   {String}  str  The full URL to parse
 * @return  {String}       The hostname only
 * @example
 *   <%= _.hostname('https://assemble.io') %>
 *   => assemble.io
 */

exports.hostname = function(str) {
  return url.parse(str).hostname;
};


/**
 * Strip `.git` from the end of a URL, so the URL
 * can be used and extended in config values.
 *
 * @param {String} str
 * @return  {String}
 * @example
 *   <%= _.stripGit('https://github.com/assemble/assemble.io.git') %>
 *   => https://github.com/assemble/assemble.io
 */

exports.stripGit = function(url) {
  var git = /\.git$/;
  if (git.test(url)) {
    return url.replace(git, '');
  }
  return url;
};




/**
 * Date functions used in _.date() mixin
 *
 * @name formatDate
 * @param  {Object} dateobj The date object to format.
 * @param  {String} structure The structure to use, e.g. 'YYYY-MM-DD'.
 *
 * @return {String} The formatted date.
 * @api public
 */

exports.date = function(structure) {
  /* jshint unused: false */

  var dateobj = new Date();

  var year    = dateobj.getFullYear();
  var month   = ('0' + (dateobj.getMonth() + 1)).slice(-2);
  var date    = ('0' + dateobj.getDate()).slice(-2);
  var hours   = ('0' + dateobj.getHours()).slice(-2);
  var minutes = ('0' + dateobj.getMinutes()).slice(-2);
  var seconds = ('0' + dateobj.getSeconds()).slice(-2);
  var day     = dateobj.getDay();

  var months  = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
  var dates   = ['Sunday', 'Monday', 'Tuesday', 'Wendesday', 'Thursday', 'Friday', 'Saturday'];
  var output  = '';

  structure = structure || 'YYYY-MMM-DD DDD';
  switch (structure) {
  case 'YYYY-MM-DD':
    output = year + '-' + month + '-' + date;
    break;
  case 'YYYY':
    output = year;
    break;
  case 'full':
    output = dates[parseInt(day)] + ', ' + months[parseInt(month) - 1] + ' ' + date + ', ' + year;
    break;
  }
  return output;
};


<|start_filename|>data/_utils/dates.js<|end_filename|>
var path = require('path');

var re = /(\d{4})-(\d{2})-(\d{2})-(.+)/;

var extname = function(str) {
  return path.basename(str, path.extname(str));
};

var year = exports.year = function(str) {
  return extname(str).replace(re, '$1');
};

var month = exports.month = function(str) {
  return extname(str).replace(re, '$2');
};

var day = exports.day = function(str) {
  return extname(str).replace(re, '$3');
};

var slug = exports.slug = function(str) {
  return extname(str).replace(re, '$4');
};

exports.toPost = function(str) {
  return extname(str).replace(re, '$1/$2/$3/$4');
};
