Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function main() {
const args = parseArgs()
log.setDefaultLevel('info')
if (args.logfile) {
try {
fs.writeFileSync(args.logfile, 'timestamp,src_ip,question_type,question,answer\n')
log.info(c.gray('[*]') + ` logging CSV data to ${args.logfile}`)
} catch (err) {
log.error(c.red('[!]') + ` error writing to --logfile ${args.logfile}:`)
log.error(err)
log.error(c.red('[!]') + ' exiting.')
process.exit(1)
}
}
const domains = {}
const orderedDomains = new Set()
server.on('request', (request, response) => {
request.question.forEach(question => {
// only handle A queries for now
you'll want to ensure 2 main things:
1. You use a different port than the default port (27017).
2. You use authentication with a username and password to connect.
Wherever you are running MongoDB in production you'll want to
create a new user in the \`admin\` database. SSH into your machine
and you can add a user from the Mongo console like so:
${chalk.bold('// Use the `admin` database.')}
${chalk.cyan('use admin')}
${chalk.bold('// Create a user with the appropriate roles.')}
${chalk.blue('const')} ${chalk.cyan('user')} = {
${chalk.cyan('user:')} ${chalk.yellow(`'myUserName'`)}, ${chalk.gray('// Make sure to change this!')}
${chalk.cyan('pw:')} ${chalk.yellow(`'myPassword'`)}, ${chalk.gray('// Make sure to change this!')}
${chalk.cyan('roles:')} [
{ ${chalk.cyan('role:')} ${chalk.yellow(`'userAdminAnyDatabase'`)}, ${chalk.cyan('db:')} ${chalk.yellow(`'admin'`)} },
${chalk.yellow(`'readWriteAnyDatabase'`)}
]
}
${chalk.bold('// Save that user to the `admin` database.')}
${chalk.cyan('db')}.${chalk.yellow('createUser')}(${chalk.cyan('user')})
See ${chalk.blue('http://bit.ly/2UTn484')} for more details.
Mongo-specific variables will be setup in the \`.env\` file.
If you used the guided process, these variables will contain the
${chalk.bold('default values')} and ${chalk.bold('should be changed')} before deploying to production.
// Local dev - same as global
const reactStatic = require.resolve('react-static/bin/react-static')
const reactStaticWorkDir = path.join(__dirname, '../..')
// commands:
// serve (port, version)
// build (version, output)
// init (@config) (create /doc, /docs/public, docs.json, etc)
yargs // eslint-disable-line
.version()
.usage('Usage: gitdocs [options]')
.command({
command: 'serve [path]',
alias: 's',
desc: chalk.gray('serve'),
builder: yargs =>
yargs.options({
output: {
alias: 'o',
default: 'docs-dist',
desc: chalk.gray('build.output'),
nargs: 1,
requiresArg: true,
type: 'string',
},
port: {
alias: 'P',
default: 3000,
desc: chalk.gray('Port to use. Only applies if a path is specified.'),
nargs: 1,
requiresArg: true,
combined = combined.map(function (lines) {
const lineLength = strip(lines[0]).length;
for (let i = lines.length; i < longest; ++i) {
lines.push(self.pad('', lineLength));
}
const numRealLines = lines.filter(function (line) {
return (strip(line).trim() !== '');
}).length;
// If we've exceeded the max height and have
// content, do a fancy `...` and cut the rest
// of the content.
if (numRealLines > maxHeight && String(lines[maxHeight - 1]).trim() !== '') {
let ellip = `${(numRealLines - maxHeight)} more ...`;
ellip = chalk.gray((ellip.length > lineLength) ? '...' : ellip);
lines = lines.slice(0, maxHeight - 1);
lines.push(self.pad(ellip, lineLength));
}
return lines;
});
if (testData.left.code.indexOf('.') !== -1) {
const bits = testData.left.code.split('.');
bits.pop();
leftIndex += bits.join('.').length + 1;
}
let rightIndex = -1;
if (testData.right) {
rightIndex = testData.right.range[0];
if (looksTheSame(testData.right.code, testData.right.value)) {
rightIndex = -1;
}
}
if (leftIndex > -1) {
console.log(`${chalk.yellow(formatLine(lineNumber + 1, lineWidth))} ${indent}${spaces(leftIndex)}${chalk.gray('|')}${rightIndex > -1 ? spaces(rightIndex - leftIndex - 1) + chalk.gray('|') : ''}`);
if (rightIndex > -1) {
console.log(`${spaces(lineWidth)} ${indent}${spaces(leftIndex)}${chalk.gray('|')}${rightIndex > -1 ? spaces(rightIndex - leftIndex - 1) + syntaxHighlight(JSON.stringify(testData.right.value)) : ''}`);
}
console.log(`${spaces(lineWidth)} ${indent}${spaces(leftIndex)}${syntaxHighlight(JSON.stringify(testData.left.value))}\n`);
}
}
const logDivider = () => {
console.log(
chalk.gray('------------------------------------------------------------------------')
);
};
export = (jay: Jay) => {
console.log(wrapAnsi(chalk.gray(
'Type',
`\`${(chalk.blue('> jay.help()'))}\``,
'in the prompt for more information.'
), process.stdout.columns || Infinity))
Object.defineProperty(jay, 'help', {
value() {
open(packageJson.homepage)
}
})
}
function validateNewConfig(projectConfig, projectInfo){
let srcDirPath = path.normalize(path.join(projectInfo.ProjectPath, projectConfig.SourceDir))
if(!fs.existsSync(srcDirPath)){
console.log()
console.log(chalk.bgYellow.bold('Warning:') +
' the projects\'s source directory you specified: ' +
chalk.blue(srcDirPath) + ' does not exist.')
console.log(' awsmobile-cli gathers this information for two reasons: ')
console.log(' - awsmobile-cli copies the latest ' + chalk.blue(awsmobilejsConstant.AWSExportFileName) + ' file into that folder')
console.log(' so the backend awsmobile project\'s resources can be easily accessed by your code')
console.log(' - awsmobile-cli checks the last modification time of the files in the project\'s source directory')
console.log(' so awsmobile-cli knows if to run the build command before it publishes your application')
console.log()
console.log(chalk.gray(' # to change the settings'))
console.log(' $ awsmobile configure project')
}
}
function extractPackages({title, url}) {
const extracted = /(?:U|u)pdate(?: dependency)? ([\w-,` ./@]+?) (?:monorepo )?to /.exec(title);
if (!extracted) {
log.warn(`Failed to extract package from: ${title} ${colors.gray(url)}`);
return [];
}
return extracted[1].replace(/`/g, "").split(/, and |, | and /);
}
, render: function (first) {
if (first) this.out.write(esc.cursorHide)
let prompt = [
ui.symbol(this.done, this.aborted)
, chalk.bold(this.msg)
, this.done ? '' : chalk.gray(this.hint)
].join(' ')
if (!this.done) {
const c = this.cursor
prompt += '\n' + this.value.map((v, i) =>
(v.selected ? chalk.green(figures.tick) : ' ') + ' '
+ (c === i ? chalk.cyan.underline(v.title) : v.title)
).join('\n')
}
this.out.write(ui.clear(this.lastRendered) + prompt)
this.lastRendered = prompt
}
}