repository: function() {              
            var done = this.async();
            this.log(yosay(chalk.yellow('End -> Repository')));
            // clone repository or get joomla master
            if (this.options.repository === 'existing')
            {
                Git.clone({
                    repo: this.options.repository,
                    dir: this.options.joomla.root
                }, done);

            }
            else
            {
                var download = new Download({extract: true, strip: 1, mode: '755'})
                    .get('https://github.com/joomla/joomla-cms/archive/master.zip')
                    .dest(this.destinationPath(this.options.joomla.root))
                    .use(progress());

                download.run(done);
            }
        },
Example #2
0
    fse.remove(module_home+"/"+name, function(){
      Repo.clone({
        repo: url ,
        dir: module_home+"/"+name,
      }, function( error, repo ){

        console.log("error", error);
        console.log("repo", repo);

        var plugin = new Plugin({url: url, name: name})

        Plugin.create(plugin, function(err, newPlugin){
          Plugin.mount(name, function(err, result){
            result.plugin = newPlugin
            app.models.Route.createTestData(newPlugin, function(){
              cb(err, result);
            })
          })
        });


      });
    })
Example #3
0
    function install(cV, mod) {
        var versionPath =  bibleDirectory + "/" + mod;

        BibleJS.languages[cV.language] = {
            version: cV
          , path: versionPath
        };

        if (Fs.existsSync(versionPath)) {
            if (++complete === howMany) {
                return callback(null, versions);
            }
            return;
        }

        // Clone BibleJS version
        Git.clone({
            repo: cV.source
          , dir: versionPath
          , depth: 1
        }, function (err, repository) {
            if (err) { return callback(err); }

            // Set version/branch
            repository.exec("checkout", cV.version, function (err, output) {
                if (err) { return callback(err); }

                Exec("npm install", {
                    cwd: versionPath
                }, function (err) {
                    if (err) { return callback(err); }
                    if (++complete !== howMany) { return; }
                    callback(null, versions);
                });
            });
        });
    }
		clone: function() {

			var params = this.config.getAll();

			this.log(yosay(	chalk.yellow('Acquiring Joomla CMS files')));

			this.finished = function() {

				this.log(yosay(chalk.yellow('Initializing GIT repository and commiting initial code...')));

				var initializeGitRepository = function()
				{

					cp.exec('git init', { cwd: this.path }, function(err, stdout, stderr) {

						if (err)
						{
							throw err;
						}

						this.log('Initialized GIT repository...');

					}.bind(this));

				}.bind(this);

				var addRemoteOrigin = function()
				{
					cp.exec('git remote add origin ' + this.repositoryUrl, { cwd: this.path }, function(err, stdout, stderr) {

						if (err)
						{
							throw err;
						}

						this.log('Added remote origin...');

					}.bind(this));

				}.bind(this);

				var commitReadMe = function()
				{
					cp.exec('git commit -m \'Initial commit with README.md\'', { cwd: this.path }, function(err, stdout, stderr) {

						if (err)
						{
							throw err;
						}

						this.log('Committed README.md...');

					}.bind(this));

				}.bind(this);


				var pushReadMe = function()
				{
					cp.exec('git push -u origin master', { cwd: this.path }, function(err, stdout, stderr) {

						if (err)
						{
							throw err;
						}

						this.log('Pushed README.md to origin...');

					}.bind(this));

				}.bind(this);


				var pushCodeBase = function()
				{
					cp.exec('git push --all', { cwd: this.path }, function(err, stdout, stderr) {

						if (err)
						{
							throw err;
						}

					}.bind(this));

					this.log('Pushed entire code package to repository...');

				}.bind(this);

				async.series([
						//initializeGitRepository(),
						//addRemoteOrigin(),
						//commitReadMe(),
						//pushReadMe(),
						//pushCodeBase()
					]);


				open(this.config.get('url') + '/administrator');

			}.bind(this);

			this.createUserCallBack = function(err, stdout, stderr) {

				if (err)
				{
					console.log(err);
					return false;
				}

				this.log(yosay(chalk.yellow('Administrator\'s Account Created')));

				var connection = mysql.createConnection({
					host: this.db_host,
					user: this.db_user,
					password: this.db_password,
					database: this.db_database
				});

				connection.connect();

				var activateUser = function()
				{
					connection.query('UPDATE `' + this.db_prefix + 'users` SET block=0,activation="" WHERE id=1', function(err, rows, fields) {
						if (err)
						{
							console.log(err);
							return false;
						}
					});

				}.bind(this);

				var updateUserGroup = function ()
				{
					connection.query('UPDATE `' + this.db_prefix + 'user_usergroup_map` SET group_id=8 WHERE user_id=1', function(err, rows, fields) {
						if (err)
						{
							console.log(err);
							return false;
						}
					});

				}.bind(this);

				var processTemplate = function(err, rows, fields) {

					if (err)
					{
						console.log(err);
						return false;
					}

					var values = {
						prefix: this.db_prefix,
						fields: rows[0]
					};

					console.log('Path: ', this.path);
					console.log('Template Path: ', this.templatePath());
					console.log('Destination Path: ', this.destinationPath());
					console.log('Values: ', values);

					this.fs.copyTpl(
						this.templatePath('_superuser.sql'),
						this.destinationPath('database/superuser.sql'),
						values
					);

				}.bind(this);

				var generateSuperUserScript = function()
				{
					connection.query('SELECT * FROM `' + this.db_prefix + 'users`', processTemplate);

				}.bind(this);

				async.series(
					[
						activateUser(),
						updateUserGroup(),
						generateSuperUserScript()
					]
				);

				connection.end();

				this.finished();

			}.bind(this);

			this.updateUserRegistrationSettingCallback = function() {

				this.log(yosay(chalk.yellow('User Self Registration Setting Adjusted')));

				cp.exec('casperjs installation.js --password=' + base.encode(this.websitePassword) + ' --email=' + this.websiteEmail + ' --url=' + this.url, { cwd: this.templatePath("tasks/scripts") }, this.createUserCallBack);

			}.bind(this);

			this.deleteInstallationDirectoryCallBack = function(err) {

				if (err)
				{
					console.log(err);
					return false;
				}

				this.log(yosay(chalk.yellow('Installation Folder Removed')));

				var connection = mysql.createConnection({
					host: this.db_host,
					user: this.db_user,
					password: this.db_password,
					database: this.db_database
				});

				connection.connect();

				connection.query('SELECT extension_id, params FROM `' + this.db_prefix + 'extensions` WHERE name="com_users"', function(err, rows, fields) {
					if (err)
					{
						console.log(err);
						return false;
					}

					var userParams = JSON.parse(rows[0].params);
					userParams.allowUserRegistration = '1';
					userParams = JSON.stringify(userParams);
					var extension_id = rows[0].extension_id;

					connection.query("UPDATE `" + this.db_prefix + "extensions` SET params='" + userParams + "' WHERE extension_id=" + extension_id, function(err, rows, fields) {

						if (err)
						{
							console.log(err);
							return false;
						}

						connection.end();

						this.updateUserRegistrationSettingCallback();

					}.bind(this));

				}.bind(this));

			}.bind(this);

			this.importCallBack = function(err) {

				if (err)
				{
					console.log(err);
					return false;
				}

				this.log(yosay(chalk.yellow('Database import complete')));

				rimraf(this.destinationRoot() + '/' + this.joomlaFolder + '/installation/', this.deleteInstallationDirectoryCallBack);

			}.bind(this);

			this.writeCallBack = function(err) {

				if (err)
				{
					console.log(err);
					return false;
					//done(err);
				}

				this.log(yosay(chalk.yellow('Running database script...')));

				cp.exec('mysql --user=' + this.db_user + ' --password=' + this.db_password + ' ' + this.db_database + ' < ' + 'joomla.sql',  { cwd: this.destinationPath + "/database" }, this.importCallBack);

			}.bind(this);

			this.replaceCallBack = function(err, data) {
				this.log(yosay(chalk.yellow('Replacing sql file prefixes with ' + this.db_prefix + '...')));

				if (err)
				{
					console.log(err);
					return false;
					//done(err);
				}

				data = data.replace(/#__/g, this.db_prefix);

				fs.writeFile('./database/joomla.sql', data, 'utf-8', this.writeCallBack);

			}.bind(this);

			this.cloneCallBack = function(err, repo) {

				if (err)
				{
					console.log(err);
					return false;
					//done(err);
				}

				this.log(yosay(chalk.yellow('Joomla CMS files acquired...')));

				var params = this.config.getAll();

				this.fs.copyTpl(
					this.templatePath('_configuration.php'),
					this.destinationPath(this.joomlaFolder + '/configuration.php'),
					params
				);

				this.fs.copy(
					this.templatePath('_htaccess.txt'),
					this.destinationPath(this.joomlaFolder + '/.htaccess')
				);

				fs.readFile('./' + this.joomlaFolder + '/installation/sql/mysql/joomla.sql', 'utf-8', this.replaceCallBack);

			}.bind(this);

			if (this.repositoryExisting)
			{

				Git.clone({
					repo: this.repositoryUrl,
					dir: this.joomlaFolder
				}, this.cloneCallBack);

			}
			else
			{

				var download = new Download({ extract: true, strip: 1, mode: '755' })
					.get('https://github.com/joomla/joomla-cms/archive/master.zip')
					.dest(this.destinationPath(this.joomlaFolder))
					.use(progress());

				download.run(function (err, files, stream) {

					if (err) {
						console.log(err);
						return false
						//done(err);
					}

					this.log(yosay(chalk.yellow('Joomla Files downloaded successfully!')));

					this.cloneCallBack(false, {});

				}.bind(this));
			}
		}