'use strict';

require('dotenv').load();

var pkg = require('./package.json'),
    path = require('path');

var gulp = require('gulp'),
    gutil = require('gulp-util'),
    plumber = require('gulp-plumber'),
    pgbuild = require('gulp-phonegap-build');

var dir = {
    out: path.join(__dirname, './out'),
    dist: path.join(__dirname, './dist'),
    assets: path.join(__dirname, './public'),
};

gulp.task('default', ['build'], function () {
    gutil.log('Building... This might take a while.');
});

gulp.task('build', function () {
    gulp.src(dir.assets + '/**')
        .pipe(plumber())
        .pipe(pgbuild({
            appId: process.env.PG_BUILD_APP_ID,
            download: {
                android: dir.out + '/onesquare-' + pkg.version + '.apk'
            },
            user: {
                token: process.env.PG_BUILD_AUTH_TOKEN
            }
        }));
});

@@ -159,24 +159,61 @@
 ulp-util'),%0A
+    inject = require('gulp-inject'),%0A
     plumber 
@@ -283,16 +283,62 @@
 -build')
+,%0A    bowerFiles = require('main-bower-files')
 ;%0A%0Avar d
@@ -958,12 +958,335 @@
    %7D));%0A%7D);%0A
+%0Agulp.task('inject', function () %7B%0A    var sources = %5B%0A        dir.assets + '/lib/**/*.html'%0A    %5D;%0A%0A    return gulp.src(dir.assets + '/index.html')%0A        .pipe(inject(gulp.src(sources, %7Bread: false%7D)))%0A        .pipe(inject(gulp.src(bowerFiles(), %7Bread: false%7D), %7Bname: 'bower'%7D))%0A        .pipe(gulp.dest(dir.dist));%0A%7D);%0A

Add Gulp inject task.