Commit 2b769685 authored by Xunnamius (Gitlab)'s avatar Xunnamius (Gitlab) 👾

incomplete changes to Gruntfile for newsite

parent 7edf09d2
......@@ -22,6 +22,43 @@ module.exports = function(grunt)
grunt.log.debug("apacheConfigFileAvailable: " + apacheConfigFileAvailable);
grunt.log.debug("apacheConfigFileEnabled: " + apacheConfigFileEnabled);
var gitlab = {
_connectobj: null,
_namespaces: [{ name: '(default)', value: 'default' }],
_populated: false,
connect: function()
{
if(!gitlab._connectobj)
{
gitlab._connectobj = require('gitlab')({
url: config.gitlab.url,
token: config.gitlab.token
});
}
return gitlab._connectobj;
},
getDefaultNamespace: function()
{
if(!gitlab._populated)
gitlab.getNamespaces();
return gitlab._namespaces[0].value;
},
getNamespaces: function()
{
if(!gitlab._populated)
{
gitlab.connect().
}
return gitlab._namespaces;
}
};
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
......@@ -108,7 +145,7 @@ module.exports = function(grunt)
message: 'Choose a template:',
default: 'zf2',
choices: [
{ name: 'ZF2 Skeleton Application (custom)', value: 'zf2' },
{ name: 'ZF2 Skeleton (requires Apache reverse-proxy destination)', value: 'zf2' },
{ name: 'Nodejs Project', value: 'nodejs' },
{ name: 'Wait, I actually don\'t wanna load a template!', value: null }
],
......@@ -118,7 +155,7 @@ module.exports = function(grunt)
config: 'ns.apache.useAsReverseProxy',
type: 'confirm',
default: true,
message: 'Wanna use Apache as a reverse-proxy?'
message: 'Wanna use Apache as a reverse-proxy destination?'
},
{
config: 'ns.apache.allowOverrideAll',
......@@ -130,8 +167,8 @@ module.exports = function(grunt)
{
config: 'ns.ssl',
type: 'confirm',
default: false,
message: 'Are you gonna use SSL? (ignored for now)'
default: true,
message: 'Are you gonna use TLS?'
},
{
config: 'ns.source.confirm',
......@@ -169,6 +206,14 @@ module.exports = function(grunt)
],
when: function(answers){ return answers['ns.source.selection'] == 'gitlab'; }
},
{
config: 'ns.source.gitlab.namespace',
type: 'list',
message: 'Choose the namespace of the new gitlab repository:',
default: gitlab.getDefaultNamespace(),
choices: gitlab.getNamespaces(),
when: function(answers){ return answers['ns.source.selection'] == 'gitlab'; }
},
{
config: 'ns.source.ftp.newuser.confirm',
type: 'confirm',
......@@ -193,8 +238,24 @@ module.exports = function(grunt)
{
config: 'ns.publicFolder',
type: 'input',
message: 'Name your site\'s web visible root folder (edit postrec.json rm rules manually if not "public"!):',
default: 'public'
message: 'Name your site\'s web visible root folder:',
default: 'public',
validate: function(value){ return force ? true : (value.length > 0 && !value.contains('/') && !value.contains('\0')); }
},
{
config: 'ns.postrec.confirm',
type: 'confirm',
default: true,
message: 'Wanna generate a postrec.json file to enable web pushing with gitlab?',
when: function(answers){ return answers['ns.source.selection'] == 'gitlab'; }
},
{
config: 'ns.postrec.branch',
type: 'input',
message: 'Specify a branch as the web push target:',
default: 'master',
when: function(answers){ return answers['ns.postrec.confirm']; },
validate: function(value){ return force ? true : (value.length > 0); }
}
]
}
......@@ -310,12 +371,9 @@ module.exports = function(grunt)
shell.exec('chown git:{1} "{0}"'.substitute([webpath, webgroup]));
// Interact with gitlab API to create repo
var gitlab = require('gitlab')({
url: config.gitlab.url,
token: config.gitlab.token
});
var gl = gitlab.connect();
gitlab.projects.create({
gl.projects.create({
name: ns.fqdn,
visibility_level: ns.source.gitlab.visibilityLevel
}, function(repo)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment