Skip to content
This repository was archived by the owner on Oct 5, 2020. It is now read-only.

Commit 8f4d0d6

Browse files
Nishad BakshiNishad Bakshi
authored andcommitted
adjusted code style
1 parent 364eb0a commit 8f4d0d6

File tree

1 file changed

+85
-43
lines changed

1 file changed

+85
-43
lines changed

app/templates/gulpfile.js

Lines changed: 85 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,12 @@ var $ = require('gulp-load-plugins')({
2020
/* jshint ignore:end */
2121

2222
var _s = require('underscore.string'),
23-
q = require('q'),
24-
spawn = require('child_process').spawn;
23+
q = require('q'),
24+
spawn = require('child_process').spawn;
25+
26+
var encoding = {
27+
encoding: 'utf8'
28+
};
2529

2630
/**
2731
* yargs variables can be passed in to alter the behavior, when present.
@@ -244,9 +248,7 @@ gulp.task('init-prod', function(done) {
244248
gulp.task('add-deploy-target', function(done) {
245249
log('Update ecosystem.json targets or create new ones!');
246250

247-
var properties = fs.readFileSync('deploy/build.properties', {
248-
encoding: 'utf8'
249-
});
251+
var properties = fs.readFileSync('deploy/build.properties', encoding);
250252

251253
var name = properties.match(/app-name=(.*)/)[1];
252254
var gitUrl = 'https://github.com/';
@@ -360,9 +362,7 @@ function ecosystemMustExist(ecosystem, name) {
360362

361363
var configString = JSON.stringify(configJSON, null, 2) + '\n';
362364

363-
fs.writeFileSync(ecosystem, configString, {
364-
encoding: 'utf8'
365-
});
365+
fs.writeFileSync(ecosystem, configString, encoding);
366366
} catch (e) {
367367
console.log('failed to write ecosystem.json: ' + e.message);
368368
}
@@ -436,15 +436,12 @@ gulp.task('optimize', ['inject', 'test'], function() {
436436
log('Optimizing the js, css, and html');
437437

438438
// Filters are named for the gulp-useref path
439-
var cssFilter = $.filter('**/*.css', {
440-
restore: true
441-
});
442-
var jsAppFilter = $.filter('**/' + config.optimized.app, {
443-
restore: true
444-
});
445-
var jslibFilter = $.filter('**/' + config.optimized.lib, {
439+
var restore = {
446440
restore: true
447-
});
441+
};
442+
var cssFilter = $.filter('**/*.css', restore);
443+
var jsAppFilter = $.filter('**/' + config.optimized.app, restore);
444+
var jslibFilter = $.filter('**/' + config.optimized.lib, restore);
448445

449446
var templateCache = config.temp + config.templateCache.file;
450447

@@ -699,7 +696,7 @@ function init(env, done) {
699696

700697
var properties = JSON.parse(output).properties || {};
701698

702-
var mlVersion = ['8','7', '6', '5'].indexOf(localMlVersion || properties['ml.server-version'] || '8');
699+
var mlVersion = ['8', '7', '6', '5'].indexOf(localMlVersion || properties['ml.server-version'] || '8');
703700
var marklogicHost = properties['ml.' + env + '-server'] || localMlHost || 'localhost';
704701
var marklogicAdminUser = properties['ml.user'] || localMlAdminUser || 'admin';
705702
var appName = properties['ml.app-name'] || localAppName;
@@ -708,28 +705,75 @@ function init(env, done) {
708705
var appPort = localMlHttpPort || properties['ml.app-port'] || 8040;
709706
var xccPort = localMlXccPort || properties['ml.xcc-port'] || 8041;
710707

711-
var prompts = [
712-
{type: 'list', name: 'mlVersion', message: 'MarkLogic version?', choices: ['8','7', '6', '5'], default: mlVersion > 0 ? mlVersion : 0 },
713-
{type: 'input', name: 'marklogicHost', message: 'MarkLogic Host?', default: marklogicHost},
714-
{type: 'input', name: 'marklogicAdminUser', message: 'MarkLogic Admin User?', default: marklogicAdminUser},
715-
{type: 'input', name: 'marklogicAdminPass', message: 'Note: consider keeping the following blank, ' +
716-
'you will be asked to enter it at appropriate commands.\n? MarkLogic Admin Password?', default: ''},
717-
{type: 'input', name: 'appPort', message: 'MarkLogic App/Rest port?', default: appPort},
718-
{type: 'input', name: 'xccPort', message: 'XCC port?', default: xccPort, when: function(answers) {
708+
var prompts = [{
709+
type: 'list',
710+
name: 'mlVersion',
711+
message: 'MarkLogic version?',
712+
choices: ['8', '7', '6', '5'],
713+
default: mlVersion > 0 ? mlVersion : 0
714+
}, {
715+
type: 'input',
716+
name: 'marklogicHost',
717+
message: 'MarkLogic Host?',
718+
default: marklogicHost
719+
}, {
720+
type: 'input',
721+
name: 'marklogicAdminUser',
722+
message: 'MarkLogic Admin User?',
723+
default: marklogicAdminUser
724+
}, {
725+
type: 'input',
726+
name: 'marklogicAdminPass',
727+
message: 'Note: consider keeping the following blank, ' +
728+
'you will be asked to enter it at appropriate commands.\n? MarkLogic Admin Password?',
729+
default: ''
730+
}, {
731+
type: 'input',
732+
name: 'appPort',
733+
message: 'MarkLogic App/Rest port?',
734+
default: appPort
735+
}, {
736+
type: 'input',
737+
name: 'xccPort',
738+
message: 'XCC port?',
739+
default: xccPort,
740+
when: function(answers) {
719741
return answers.mlVersion < 8;
720-
}},
721-
{type: 'input', name: 'nodePort', message: 'Node app port?', default: localNodePort},
722-
{type: 'list', name: 'guestAccess', message: 'Allow anonymous users to search data?', choices: ['false', 'true'], default: localGuestAccess > 0 ? localGuestAccess : 0},
723-
{type: 'list', name: 'disallowUpdates', message: 'Disallow proxying update requests?', choices: ['false', 'true'], default: localDisallowUpdates > 0 ? localDisallowUpdates : 0},
724-
{type: 'list', name: 'appUsersOnly', message: 'Only allow access to users created for this app? Note: disallows admin users.', choices: ['false', 'true'], default: localAppUsersOnly > 0 ? localAppUsersOnly : 0}
725-
];
742+
}
743+
}, {
744+
type: 'input',
745+
name: 'nodePort',
746+
message: 'Node app port?',
747+
default: localNodePort
748+
}, {
749+
type: 'list',
750+
name: 'guestAccess',
751+
message: 'Allow anonymous users to search data?',
752+
choices: ['false', 'true'],
753+
default: localGuestAccess > 0 ? localGuestAccess : 0
754+
}, {
755+
type: 'list',
756+
name: 'disallowUpdates',
757+
message: 'Disallow proxying update requests?',
758+
choices: ['false', 'true'],
759+
default: localDisallowUpdates > 0 ? localDisallowUpdates : 0
760+
}, {
761+
type: 'list',
762+
name: 'appUsersOnly',
763+
message: 'Only allow access to users created for this app? Note: disallows admin users.',
764+
choices: ['false', 'true'],
765+
default: localAppUsersOnly > 0 ? localAppUsersOnly : 0
766+
}];
726767

727768
if (typeof appName === 'undefined') {
728-
prompts.unshift(
729-
{type: 'input', name: 'name', message: 'Name for the app?'});
769+
prompts.unshift({
770+
type: 'input',
771+
name: 'name',
772+
message: 'Name for the app?'
773+
});
730774
}
731775

732-
inquirer.prompt(prompts, function (settings) {
776+
inquirer.prompt(prompts, function(settings) {
733777
if (typeof appName === 'undefined') {
734778
settings.nameDashed = _s.slugify(settings.name);
735779
} else {
@@ -757,7 +801,7 @@ function init(env, done) {
757801
configJSON['appusers-only'] = settings.appUsersOnly;
758802

759803
var configString = JSON.stringify(configJSON, null, 2) + '\n';
760-
fs.writeFileSync(env + '.json', configString, { encoding: 'utf8' });
804+
fs.writeFileSync(env + '.json', configString, encoding);
761805
log('Created ' + env + '.json.');
762806

763807
if (fs.existsSync('deploy/' + env + '.properties')) {
@@ -776,12 +820,10 @@ function init(env, done) {
776820
'app-port=' + settings.appPort + '\n';
777821
if (settings.mlVersion < 8) {
778822
envProperties += 'xcc-port=' + settings.xccPort + '\n';
779-
}
780-
else
781-
{
823+
} else {
782824
envProperties += '# Taking advantage of not needing a XCC Port for ML8\n' +
783-
'xcc-port=${app-port}\n' +
784-
'install-xcc=false\n';
825+
'xcc-port=${app-port}\n' +
826+
'install-xcc=false\n';
785827
}
786828

787829
envProperties += '\n' +
@@ -799,7 +841,7 @@ function init(env, done) {
799841
'user=' + settings.marklogicAdminUser + '\n' +
800842
'password=' + settings.marklogicAdminPass + '\n';
801843

802-
fs.writeFileSync('deploy/' + env + '.properties', envProperties, {encoding: 'utf8'});
844+
fs.writeFileSync('deploy/' + env + '.properties', envProperties, encoding);
803845
log('Created deploy/' + env + '.properties.');
804846
}
805847
done();
@@ -1128,14 +1170,14 @@ function run(cmd, args, verbose) {
11281170
d.resolve(output);
11291171
});
11301172

1131-
child.stdout.on('data', function (chunk) {
1173+
child.stdout.on('data', function(chunk) {
11321174
if (verbose) {
11331175
console.log(chunk.toString());
11341176
}
11351177
output += chunk.toString();
11361178
});
11371179

1138-
child.stderr.on('data', function (data) {
1180+
child.stderr.on('data', function(data) {
11391181
console.log(data.toString());
11401182
});
11411183

0 commit comments

Comments
 (0)