added support for custom smtp server in setup script

This commit is contained in:
David Baldwynn 2017-11-21 09:58:44 -08:00
parent 2993c6e4f8
commit 7107bab614
18 changed files with 321 additions and 79 deletions

View file

@ -1,6 +1,44 @@
'use strict';
module.exports = {
nodemailer_providers: [
'1und1',
'AOL',
'DebugMail.io',
'DynectEmail',
'FastMail',
'GandiMail',
'Gmail',
'Godaddy',
'GodaddyAsia',
'GodaddyEurope',
'hot.ee',
'Hotmail',
'iCloud',
'mail.ee',
'Mail.ru',
'Mailgun',
'Mailjet',
'Mandrill',
'Naver',
'OpenMailBox',
'Postmark',
'QQ',
'QQex',
'SendCloud',
'SendGrid',
'SES',
'SES-US-EAST-1',
'SES-US-WEST-1',
'SES-EU-WEST-1',
'Sparkpost',
'Yahoo',
'Yandex',
'Zoho'
],
extraneousFormFieldProps: [
'validFieldTypes',
'disabled',

View file

@ -232,7 +232,6 @@ module.exports = function(db) {
// CookieParser should be above session
app.use(cookieParser());
debugger;
// Express MongoDB session storage
app.use(session({
saveUninitialized: true,

5
package-lock.json generated
View file

@ -9857,6 +9857,11 @@
"resolved": "https://registry.npmjs.org/nodemailer/-/nodemailer-4.0.1.tgz",
"integrity": "sha1-uVhksH+s7oKH6CMu/9bx1W7HWrI="
},
"nodemailer-wellknown": {
"version": "0.2.3",
"resolved": "https://registry.npmjs.org/nodemailer-wellknown/-/nodemailer-wellknown-0.2.3.tgz",
"integrity": "sha1-ZA7SBKAWYnZD+Yc5qU+O+dOcoKk="
},
"nodemon": {
"version": "1.12.1",
"resolved": "https://registry.npmjs.org/nodemon/-/nodemon-1.12.1.tgz",

View file

@ -10,7 +10,8 @@ var config = require('../config/config'),
inquirer = require('inquirer'),
envfile = require('envfile'),
fs = require('fs-extra'),
chalk = require('chalk');
chalk = require('chalk'),
_ = require('lodash');
// Bootstrap db connection
var db = mongoose.connect(config.db.uri, config.db.options, function(err) {
@ -34,6 +35,7 @@ var User = mongoose.model('User');
require('../app/models/user.server.model.js');
var nodemailer_providers = [
'Custom Mailserver',
'1und1',
'AOL',
'DebugMail.io',
@ -69,16 +71,20 @@ var nodemailer_providers = [
'Zoho'
];
var bool_options = [
"TRUE",
"FALSE"
];
var questions = [
{
var replaceENVQuestion = {
type: 'confirm',
name: 'shouldContinue',
message: 'Do you wish to configure your deployment now?'
name: 'replaceENVFile',
message: 'An older .env file already exists. Do you want to replace it?',
default: false
};
var questionsPart1 = [
{
type: 'list',
name: 'NODE_ENV',
message: 'What mode do you want to run TellForm in?',
choices: ['development', 'production', 'test'],
default: 'development'
},
{
type: 'input',
@ -90,26 +96,63 @@ var questions = [
name: 'APP_DESC',
message: 'Describe your project (for SEO) (optional)'
},
{
type: 'input',
name: 'APP_KEYWORDS',
message: 'What keywords are relevant to your project (seperate by commas) (optional)'
},
{
type: 'confirm',
name: 'SIGNUP_DISABLED',
message: 'Do you want to disable signups?'
message: 'Do you want to disable signups?',
default: false
},
{
type: 'confirm',
name: 'SUBDOMAINS_DISABLED',
message: 'Do you want to have subdomains? (i.e. are you using a custom domain)'
message: 'Do you want to disable subdomains? (i.e. are you using a custom domain)'
},
{
type: 'list',
name: 'MAILER_SERVICE_PROVIDER',
message: 'What email service provider are you using?',
choices: nodemailer_providers
}
]
var mailerWellKnownQuestions = [
{
type: 'input',
name: 'MAILER_EMAIL_ID',
message: 'What is your SMTP username?'
},
{
type: 'password',
name: 'MAILER_PASSWORD',
message: 'What is your SMTP password?'
},
{
type: 'input',
name: 'MAILER_FROM',
message: 'What do you want the default "from" email address to be?'
}
];
var mailerCustomQuestions = [
{
type: 'input',
name: 'MAILER_SMTP_HOST',
message: 'What is your SMTP server url?'
},
{
type: 'input',
name: 'MAILER_SMTP_PORT',
message: 'What is your SMTP server port?'
},
{
type: 'confirm',
name: 'MAILER_SMTP_SECURE',
message: 'Is your SMTP server using SSL/TLS?'
},
{
type: 'input',
name: 'MAILER_SMTP_HOST',
message: 'What is your SMTP host domain?'
},
{
type: 'input',
@ -125,11 +168,26 @@ var questions = [
type: 'input',
name: 'MAILER_FROM',
message: 'What do you want the default "from" email address to be?'
}
];
var questionsPart2 = [
{
type: 'input',
name: 'MONGODB_URI',
message: 'What is the URI of your Mongo database?',
default: 'mongodb://localhost/mean'
},
{
type: 'input',
name: 'MONGODB_URI',
message: 'What is the URI of your Redis installation?',
default: 'redis://127.0.0.1:6379'
},
{
type: 'input',
name: 'BASE_URL',
message: 'What is the url your TellForm will be hosted at?',
message: 'What is the (root) url your TellForm will be hosted at?',
default: 'localhost'
},
{
@ -138,26 +196,6 @@ var questions = [
message: 'What port should the TellForm server run on?',
default: '3000'
},
{
type: 'input',
name: 'GOOGLE_ANALYTICS_ID',
message: 'What is your Google Analytics Tag? (optional)'
},
{
type: 'input',
name: 'RAVEN_DSN',
message: 'What is your Private Raven DSN key? (optional)'
},
{
type: 'input',
name: 'PRERENDER_TOKEN',
message: 'What is your Prerender.io token? (optional)'
},
{
type: 'input',
name: 'COVERALLS_REPO_TOKEN',
message: 'What is your Coveralls.io token? (optional)'
},
{
type: 'input',
name: 'email',
@ -175,16 +213,30 @@ var questions = [
}
];
if(!fs.existsSync('./\.env')) {
console.log(chalk.green('\n\nHi, welcome to TellForm Setup'));
var exitProcess = function() {
console.log(chalk.green('Have fun using TellForm!'));
process.exit(1);
}
console.log(chalk.green('You should only run this the first time you run TellForm\n--------------------------------------------------\n\n'));
var removeENVFile = function(){
fs.unlinkSync('./\.env')
}
inquirer.prompt([questions[0]]).then(function (confirmAns) {
if (confirmAns['shouldContinue']) {
var createENVFile = function() {
inquirer.prompt(questionsPart1).then(function (answersPart1) {
var nextQuestions = mailerWellKnownQuestions.concat(questionsPart2);
if(answersPart1['MAILER_SERVICE_PROVIDER'] === 'Custom Mailserver'){
nextQuestions = mailerCustomQuestions.concat(questionsPart2);
}
inquirer.prompt(questions.slice(1)).then(function (answers) {
answers['NODE_ENV'] = 'production';
inquirer.prompt(nextQuestions).then(function (answersPart2) {
var answers = _.extend(answersPart1, answersPart2);
answers = _.mapValues(answers, function(val){
if(_.isBoolean(val)){
return val ? 'TRUE' : 'FALSE';
}
return val;
});
var email = answers['email'];
var username = answers['username'];
@ -218,17 +270,26 @@ if(!fs.existsSync('./\.env')) {
console.log(chalk.green('Successfully created user'));
console.log(chalk.green('Have fun using TellForm!'));
process.exit(1);
exitProcess();
});
});
});
});
}
console.log(chalk.green('\n\nWelcome to TellForm Setup'));
console.log(chalk.green('You should only need to run this script the first time you run TellForm\n------------------------------------------------------------------------\n\n'));
if(fs.existsSync('./\.env')) {
inquirer.prompt([replaceENVQuestion]).then(function (envAnswer) {
if (envAnswer['replaceENVFile']) {
removeENVFile();
createENVFile();
} else {
console.log(chalk.green('Have fun using TellForm!'));
process.exit(1);
exitProcess();
}
});
} else {
console.log(chalk.red('You already have a .env file'));
process.exit(1);
createENVFile();
}

17
selenium/.editorconfig Normal file
View file

@ -0,0 +1,17 @@
# EditorConfig helps developers define and maintain consistent
# coding styles between different editors and IDEs
# editorconfig.org
root = true
# Apply for all files
[*]
charset = utf-8
indent_style = space
indent_size = 4
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

9
selenium/.gitignore vendored Normal file
View file

@ -0,0 +1,9 @@
.DS_Store
.idea
node_modules
npm-debug.log
uirecorder.log
reports
screenshots/**/*.png
screenshots/**/*.html
screenshots/**/*.json

27
selenium/.vscode/launch.json vendored Normal file
View file

@ -0,0 +1,27 @@
{
// Use IntelliSense to learn about possible Node.js debug attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Debug UIRecorder Local",
"program": "${workspaceRoot}/node_modules/mocha/bin/_mocha",
"cwd": "${workspaceRoot}",
"args": ["--reporter", "mochawesome-uirecorder", "${file}"],
"env": {
"webdriver": "127.0.0.1"
}
},
{
"type": "node",
"request": "launch",
"name": "Debug UIRecorder Default",
"program": "${workspaceRoot}/node_modules/mocha/bin/_mocha",
"cwd": "${workspaceRoot}",
"args": ["--reporter", "mochawesome-uirecorder", "${file}"]
}
]
}

28
selenium/README.md Normal file
View file

@ -0,0 +1,28 @@
UI Recorder test sample project
================
It's a UI Recorder test sample project.
Save your test code here.
Get more info: [http://uirecorder.com/](http://uirecorder.com/)
How to run test case?
================
1. npm install
2. source run.sh ( Linux|Mac ) or run.bat ( Windows )
How to dock jenkins?
================
1. Add commands
source ./install.sh
source ./run.sh
2. Add reports
> JUnit: reports/index.xml
> HTML: reports/

View file

@ -0,0 +1 @@
Please save common test case here.

14
selenium/config.json Normal file
View file

@ -0,0 +1,14 @@
{
"webdriver": {
"host": "127.0.0.1",
"port": "4444",
"browsers": "chrome"
},
"vars": {},
"recorder": {
"pathAttrs": "data-id,data-name,type,data-type,role,data-role,data-value",
"attrValueBlack": "",
"classValueBlack": "",
"hideBeforeExpect": ""
}
}

0
selenium/hosts Normal file
View file

4
selenium/install.sh Normal file
View file

@ -0,0 +1,4 @@
ls ~/nvm || git clone https://github.com/creationix/nvm.git ~/nvm
source ~/nvm/nvm.sh
nvm install v7.10.0
npm install

25
selenium/package.json Normal file
View file

@ -0,0 +1,25 @@
{
"name": "uirecorderTest",
"version": "1.0.0",
"description": "",
"main": "",
"dependencies": {
"chai": "3.5.0",
"jwebdriver": "2.2.4",
"mocha": "3.1.2",
"mocha-parallel-tests": "1.2.4",
"mochawesome-uirecorder": "1.5.22",
"resemblejs-node": "1.0.0",
"selenium-standalone": "6.x.x"
},
"devDependencies": {
},
"scripts": {
"installdriver": "./node_modules/.bin/selenium-standalone install --drivers.firefox.baseURL=http://npm.taobao.org/mirrors/geckodriver --baseURL=http://npm.taobao.org/mirrors/selenium --drivers.chrome.baseURL=http://npm.taobao.org/mirrors/chromedriver --drivers.ie.baseURL=http://npm.taobao.org/mirrors/selenium",
"server": "./node_modules/.bin/selenium-standalone start",
"test": "./node_modules/.bin/mocha \"*/**/*.spec.js\" --reporter mochawesome-uirecorder --bail",
"singletest": "./node_modules/.bin/mocha --reporter mochawesome-uirecorder --bail",
"paralleltest": "./node_modules/.bin/mocha-parallel-tests \"*/**/*.spec.js\" --reporter mochawesome-uirecorder --max-parallel 5 --bail"
},
"author": ""
}

7
selenium/run.bat Normal file
View file

@ -0,0 +1,7 @@
@echo off
if "%1" neq "" (
npm run singletest %1 %2
) else (
npm run paralleltest
)

5
selenium/run.sh Normal file
View file

@ -0,0 +1,5 @@
if [ "$1" = "" ]; then
npm run paralleltest
else
npm run singletest $1 $2
fi

View file

@ -0,0 +1 @@
Test screenshots saved here.

View file

@ -0,0 +1 @@
Please save upload files here.