Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
(async function () {
makeDir('screenshots');
makeDir(`screenshots/${argv.runType}`);
const appiumCaps = require('./appium.capabilities.json')[argv.runType];
let args = new NsCapabilities({
port: 4723,
isSauceLab: argv.sauceLab || false,
runType: argv.runType,
appPath: argv.appPath, //'nativescriptvueuitests-debug.apk',
appiumCaps: appiumCaps,
verbose: argv.verbose || false,
validateArgs: () => {},
})
// Hack to fix a `Cannot read property 'token' of undefined` error
// See https://github.com/NativeScript/nativescript-dev-appium/issues/142
if (args.isAndroid) {
args.device = DeviceManager.getDefaultDevice(args, appiumCaps.avd);
} else {
args.device = DeviceManager.getDefaultDevice(args);
}
AppiumDriver.createAppiumDriver(args)
.then(driver => run(driver))
.then(() => console.log('Buh-Bye...'))
.catch((err) => console.log(err));
})();
module.exports = function config(projectDir, projectName, baseDir, {overrides = {}} = {}) {
// Define all static or simple condition settings here.
let settings = {
BASE_DIR: baseDir,
BUILD_OPTIMIZED: argv.optimized ? true : (process.env.NODE_ENV === 'production'),
BUILD_TARGET: argv.target ? argv.target : 'pwa',
BUILD_TARGETS: ['pwa', 'node'],
BUILD_VERBOSE: argv.verbose ? true : false,
DEBUG_MODE: process.env.DEBUG === '1' ? true : false,
// Default loglevel is info.
LOG_LEVEL: (argv.L && argv.L.length <= 4) ? argv.L.length : 3,
LOG_LEVELS: ['error', 'warning', 'info', 'debug'],
NODE_ENVS: ['development', 'production'],
// Safest default deploy target is `alpha`.
PROJECT_DIR: projectDir,
// Generate screenshots during browser tests?
SIZE_OPTIONS: {showFiles: true, showTotal: true},
}
// Mix config file in settings and apply overrides.
rc('ca11', settings)
Object.assign(settings, overrides)
return writeFile(targetFilePath, minified).then((err) => {
if (err) {
logger('error', `Error minifying "${srcFilePath}": ${err}`);
return;
}
// Only log if not in --verbose mode (file logger has more detailed results)
if (!commandLineArgs.verbose) {
logger('success', `Successfully minified "${targetFilePath}"`);
}
});
}
export default async function startLocalServer() {
console.info(chalk.grey("No server found. Starting one now."));
return yawn(`${testEnv} wildcat`, {
resolveWhenLineIncludes: SERVER_AVAILABLE_STRING,
printStdout: argv.verbose
});
}
var log = function() {
if (argv.verbose) console.log.apply(console, arguments);
}
function serve(isDev, specRunner) {
var debugMode = '--debug';
var nodeOptions = getNodeOptions(isDev);
nodeOptions.nodeArgs = [debugMode + '=5858'];
if (args.verbose) {
console.log(nodeOptions);
}
return $.nodemon(nodeOptions)
.on('restart', ['vet'], function(ev) {
log('*** nodemon restarted');
log('files changed:\n' + ev);
setTimeout(function() {
browserSync.notify('reloading now ...');
browserSync.reload({ stream: false });
}, config.browserReloadDelay);
})
.on('start', function() {
log('*** nodemon started');
startBrowserSync(isDev, specRunner);
})
gulp.task('templatecache', ['clean-code'], function() {
log('Creating an AngularJS $templateCache');
return gulp
.src(config.htmltemplates)
.pipe($.if(args.verbose, $.bytediff.start()))
.pipe($.minifyHtml({empty: true}))
.pipe($.if(args.verbose, $.bytediff.stop(bytediffFormatter)))
.pipe($.angularTemplatecache(
config.templateCache.file,
config.templateCache.options
))
.pipe(gulp.dest(config.temp));
});
gulp.task('vet', function() {
log('Analyzing source with JSHint and JSCS');
return gulp
.src(config.alljs)
.pipe($.if(args.verbose, $.print()))
.pipe($.jshint())
.pipe($.jshint.reporter('jshint-stylish', { verbose: true }))
.pipe($.jshint.reporter('fail'))
.pipe($.jscs());
});
gulp.task('vet', function() {
log('Analyzing source with JSHint and JSCS');
return gulp
.src(config.alljs)
.pipe($.if(args.verbose, $.print()))
.pipe($.jscs())
.pipe($.jshint())
.pipe($.jshint.reporter('jshint-stylish', {verbose: true}))
.pipe($.jshint.reporter('fail'));
});
function argOptions() {
return {
rev: !!(args.rev || args.production),
minify: !!(args.minify || args.production),
production: !!args.production,
verbose: !!(args.verbose || args.v),
startServer: !!args.startServer,
debug: !!(args.debug || args.debugBrk),
debugBrk: !!args.debugBrk,
nosync: !!args.nosync,
type: args.type,
version: args.version
};
}