var cmd = require('node-cmd');
var gulp = require('gulp');
const fs = require('fs');
var shell = require('shelljs');
var silentState = shell.config.silent;
shell.config.silent = true;
shell.config.async = false;
var tld;

/*
* Update domain for laravel valet
* */
function setModuleDomain(module_dir_name) {
    shell.cd(module_dir_name)
    tld = shell.exec('valet domain', '-n').stdout.replace("n", '');
    shell.sed('-i', 'VALET_DOMAIN', tld, '.env');
}

/*
* Admin Setup
* */
gulp.task('admin', async function() {
    // - Setp 1 - IM Core Application
    shell.exec('git clone git@gitlab.com:PROJECTPATH.git;');
    shell.cd('FOLDER NAME');
    shell.exec('composer install; php artisan migrate; npm install; valet link {FOLDER NAME Without tld}; valet link {FOLDER NAME Without tld}; valet links secure {FOLDER NAME Without tld};');
    shell.cd('..');
    shell.echo('App setup complete.');
    shell.echo('domains setup complete');
});

/*
* Setup Frontend or Other Application Modules
* */

/*
* Task Runner - Gulp
* */
gulp.task('default',  gulp.series('admin', 'otherTasks'), function(){
    shell.echo('Application Modules setup complete');
});