Best JavaScript code snippet using appium-base-driver
runBuildScript.js
Source:runBuildScript.js
1const path = require("path");2const chalk = require("chalk");3const pm2 = require("pm2");4// const arg = require("arg");5const fs = require("fs");6const log = console.log;7let buildScripts = ["start", "stop", "delete", "status", "restart", "flush", "startup", "list"];8// const processPm_id = "kvell-scripts-app";9const runBuildScript = (script, nodeArgs) => {10 let buildScript;11 for (let index = 0; index < nodeArgs.length; index++) {12 if (buildScripts.indexOf(nodeArgs[index]) !== -1) {13 buildScript = nodeArgs[index];14 nodeArgs.splice(index, 1);15 break;16 }17 }18 if (buildScript) {19 // let scriptsArray = nodeArgs.concat(buildScript);20 const scriptPath = require.resolve(path.join("..", "..", "scripts", script));21 let processPID,22 processPm_id,23 delimeter = "%____%",24 fileExists = false;25 try {26 const pathToPid = path.join(process.cwd(), "logs", "build-logs", "build_pm.pid");27 if (fs.existsSync(pathToPid)) {28 [processPID, processPm_id] = fs.readFileSync(pathToPid, "utf-8").split(delimeter);29 if (30 fs.existsSync(path.join(process.cwd(), "logs", "build-logs", `build-${processPm_id}.pid`))31 ) {32 fileExists = true;33 }34 }35 } catch (err) {36 fileExists = false;37 }38 // Append the file path only if it is needed by the pm2 api39 // if (buildScript === "start" || buildScript === "stop" || buildScript === "restart") {40 // scriptsArray = scriptsArray.concat(scriptPath);41 // }42 // const nodeCommand = "pm2";43 // const args = arg(44 // {45 // "--name": String46 // },47 // {48 // argv: nodeArgs,49 // permissive: false50 // }51 // );52 // const processName = args["--name"];53 // To-do: simplify the condition :|54 if (55 (!fileExists &&56 (processPm_id ||57 buildScript === "start" ||58 buildScript === "startup" ||59 buildScript === "list")) ||60 (fileExists && buildScript !== "start")61 ) {62 pm2.connect(function (err) {63 if (err) {64 console.error(err);65 process.exit(2);66 }67 if (buildScript === "start") {68 log(chalk.green("Starting production server...\n"));69 const logDirPaths = {70 output: path.join(process.cwd(), "logs", "build-logs", "build_output.log"),71 error: path.join(process.cwd(), "logs", "build-logs", "build_errors.log"),72 pid: path.join(process.cwd(), "logs", "build-logs", "build.pid"),73 pm_id: path.join(process.cwd(), "logs", "build-logs", "build_pm.pid"),74 };75 pm2.start(76 {77 // name: processPm_id,78 script: scriptPath,79 cwd: process.cwd(),80 output: logDirPaths.output,81 error: logDirPaths.error,82 pid: logDirPaths.pid,83 // exec_mode: "cluster", // Allows your app to be clustered84 // instances: 4, // Optional: Scales your app by 485 // max_memory_restart: "100M" // Optional: Restarts your app if it reaches 100Mo86 },87 function (err, proc) {88 pm2.disconnect(); // Disconnects from PM289 if (err) {90 throw err;91 }92 fs.writeFileSync(93 `${logDirPaths.pm_id}`,94 `${proc[0].pid}${delimeter}${proc[0].pm2_env.pm_id}`95 );96 log("Process details:\n");97 log(proc);98 log();99 log(chalk.green("Production server started.\n"));100 log("You can check the logs in the following paths:\n");101 log(102 chalk.yellow(103 `Output logs: ${logDirPaths.output}\nError logs: ${logDirPaths.error}\nPid Logs: ${logDirPaths.pid}\n`104 )105 );106 }107 );108 } else if (buildScript === "status") {109 log(chalk.green("Loading status for production server...\n"));110 pm2.describe(processPm_id, function (err, proc) {111 pm2.disconnect(); // Disconnects from PM2112 if (err) {113 throw err;114 }115 console.log(proc);116 if (proc && proc[0]) {117 const processStatus = proc[0].pm2_env.status;118 let chalkColor = "whiteBright";119 if (processStatus === "online") {120 chalkColor = "greenBright";121 } else if (processStatus === "stopped" || processStatus === "stopping") {122 chalkColor = "redBright";123 }124 log(proc);125 log();126 log(`Server status: ${chalk[chalkColor](processStatus)}\n`);127 } else {128 log(129 `${chalk.bgRedBright.whiteBright("ERROR!")} ${chalk.redBright(130 `No build processes found with the id ${processPm_id}\n`131 )}`132 );133 }134 });135 } else if (buildScript === "stop") {136 log(chalk.green("Stopping the production server...\n"));137 pm2.stop(processPm_id, (err, proc) => {138 pm2.disconnect(); // Disconnects from PM2139 if (err) {140 throw err;141 }142 log(proc);143 log();144 log(`Successfully stopped the server.\n`);145 });146 } else if (buildScript === "delete") {147 log(chalk.green("Deleting pm2 process for production server...\n"));148 pm2.delete(processPm_id, function (err, proc) {149 pm2.disconnect(); // Disconnects from PM2150 if (err) {151 throw err;152 }153 const pm_idFile = path.join(process.cwd(), "logs", "build-logs", "build_pm.pid");154 fs.unlinkSync(pm_idFile);155 log(proc);156 log();157 log("Successfully deleted the pm2 process\n");158 });159 } else if (buildScript === "restart") {160 log(chalk.green("Restarting the production server...\n"));161 pm2.restart(processPm_id, (err, proc) => {162 pm2.disconnect(); // Disconnects from PM2163 if (err) {164 throw err;165 }166 log(proc);167 log();168 log(`Successfully restarted the server.\n`);169 });170 // } else if (buildScript === "reload") {171 // log(chalk.green("Restarting the production server...\n"));172 // pm2.reload(processPm_id, (err, proc) => {173 // pm2.disconnect(); // Disconnects from PM2174 // if (err) {175 // throw err;176 // }177 // log(proc);178 // log();179 // log(`Successfully restarted the server.\n`);180 // });181 } else if (buildScript === "startup") {182 // log(chalk.green("Restarting the production server...\n"));183 log("Startup scripts are not available yet.");184 pm2.disconnect(); // Disconnects from PM2185 // pm2.startup(nodeArgs[0], (err) => {186 // console.log("here");187 // pm2.disconnect(); // Disconnects from PM2188 // if (err) {189 // throw err;190 // }191 // });192 } else if (buildScript === "flush") {193 log(chalk.yellow("Flushing all the logs...\n"));194 pm2.flush(processPm_id, function (err, result) {195 pm2.disconnect(); // Disconnects from PM2196 if (err) {197 throw err;198 }199 log(result);200 log(chalk.green("Logs flushed successfully!\n"));201 });202 } else if (buildScript === "list") {203 log(chalk.green("Getting all the running build processes...\n"));204 pm2.list((err, processDescriptionList) => {205 pm2.disconnect(); // Disconnects from PM2206 if (err) {207 throw err;208 }209 log("Current running processes:\n");210 log(processDescriptionList);211 log();212 log(`Total running processes: ${processDescriptionList.length}\n`);213 });214 }215 });216 } else {217 if (fileExists && buildScript === "start") {218 log(219 `${chalk.bgRedBright.whiteBright("ERROR!")} ${chalk.redBright(220 "Production server already running with pid: ",221 processPID222 )}\n`223 );224 } else if (!fileExists && (buildScript !== "startup" || buildScript !== "list")) {225 log(226 `${chalk.bgRedBright.whiteBright("ERROR!")} ${chalk.redBright(227 "No build process exists for this application."228 )}\n`229 );230 } else {231 log(232 `${chalk.bgRedBright.whiteBright("ERROR!")} ${chalk.redBright(233 "There was an error while executing " + buildScript + " script."234 // "Please provide a process name with the --name option"235 )}\n`236 );237 }238 }239 } else {240 log(241 `${chalk.bgRedBright.whiteBright("ERROR!")} ${chalk.redBright(242 "Invalid options passed to build script. Please provide valid options to build script.\n"243 )}`244 );245 log("Valid options include:\n");246 log(buildScripts.reduce((result, script, index) => `${result}${index + 1}. ${script}\n`, ""));247 }248};...
buildScript.ts
Source:buildScript.ts
1#!/usr/bin/env node2import * as path from 'path';3import { promises as fs } from 'fs';4import { LOGGER } from './log';5import { parse } from './clParser';6import { runTypescript } from './external/typescript';7import { Config } from './config/index';8import { promiseResolves } from './util';9import { runBin } from './scriptLoader';10enum BuildscriptExitCode11{12 SUCCESS = 0,13 CANNOT_LOAD_BUILDSCRIPT = 100,14 NO_SCRIPT_ARGUMENT = 101,15 SCRIPT_NOT_FOUND = 102,16 SCRIPT_EXITED_WITH_ERROR = 103,17 SCRIPT_THROWN_NON_ERROR = 10418}19interface IBuildScript20{21 buildScripts?: {[name: string]:()=>unknown};22 scriptDirectory?: string;23 scriptOutDirectory?: string;24}25async function buildScriptDirectoriy(26 scriptDirectory: string,27 scriptOutDirectory: string,28): Promise<void> {29 const scriptConfigDirectory = path.join(scriptOutDirectory, 'config');30 LOGGER.verbose(31 'Setting 2 directories:\n',32 `* scriptDirectory = '${scriptDirectory}\n`,33 `* scriptOutDirectory = '${scriptOutDirectory}'`,34 );35 await fs.mkdir(scriptConfigDirectory, { recursive: true });36 const tsConfigPath = path.join(scriptConfigDirectory, 'tsconfig.json');37 const tsConfig = new Config(tsConfigPath);38 tsConfig.set<string[]>('include', [path.join(39 path.relative(scriptConfigDirectory, scriptDirectory),40 '**/*',41 )]);42 tsConfig.set<string[]>('exclude', ['node_modules', '**/*.spec.ts']);43 tsConfig.set<string>('compilerOptions.module', 'commonjs');44 tsConfig.set<string>('compilerOptions.target', 'ES2019');45 tsConfig.set<boolean>('compilerOptions.sourceMap', true);46 tsConfig.set<string>('compilerOptions.outDir', '../compiled');47 await tsConfig.save();48 await runTypescript(tsConfigPath);49}50async function setupScriptDirectories(buildscriptFile: IBuildScript): Promise<void> {51 const { scriptDirectory, scriptOutDirectory } = buildscriptFile;52 const tasks: Promise<void>[] = [];53 if (typeof scriptDirectory === 'string' && typeof scriptOutDirectory === 'string') {54 tasks.push(buildScriptDirectoriy(scriptDirectory, scriptOutDirectory));55 }56 await Promise.all(tasks);57}58async function main() {59 const typescriptBuildscriptPath = path.join(process.cwd(), 'buildscript.ts');60 if (await promiseResolves(fs.stat(typescriptBuildscriptPath))) {61 await runBin('tsc', [62 typescriptBuildscriptPath,63 '--target', 'ES2019',64 '--module', 'commonjs',65 ], {});66 }67 // eslint falsely flags this function even though a return statement would be unreachable68 // eslint-disable-next-line consistent-return69 const buildscriptFile: IBuildScript = (() => {70 try {71 // todo(#136): wrap dynamic loader into a function72 // eslint-disable-next-line global-require, import/no-dynamic-require73 return require(path.join(process.cwd(), 'buildscript.js'));74 } catch (error) {75 LOGGER.error('error loading buildscript.config.js:');76 LOGGER.error(error);77 process.exit(BuildscriptExitCode.CANNOT_LOAD_BUILDSCRIPT);78 }79 })();80 const args = parse(process.argv.slice(2))81 .option('target', 1)82 .option('print-error', 1);83 if (args.hasOption('print-error')) {84 const [error] = args.getOption('print-error');85 const errorNumber = parseInt(error, 10);86 if (errorNumber in BuildscriptExitCode) {87 LOGGER.error(`error (${errorNumber}) = ${BuildscriptExitCode[errorNumber]}`);88 } else {89 LOGGER.error(`error (${errorNumber}) is not recoginized`);90 }91 return;92 }93 const [script] = args.positional;94 if (!script) {95 LOGGER.error('no script passed through cli');96 process.exit(BuildscriptExitCode.NO_SCRIPT_ARGUMENT);97 }98 await setupScriptDirectories(buildscriptFile);99 if (typeof buildscriptFile.buildScripts === 'undefined' || !(script in buildscriptFile.buildScripts)) {100 LOGGER.error(`script '${script}' not found!`);101 process.exit(BuildscriptExitCode.SCRIPT_NOT_FOUND);102 }103 try {104 const result = await Promise.resolve(buildscriptFile.buildScripts[script]());105 LOGGER.log(`\n\nCompleted Running Buildscript '${script}'`);106 if (typeof result === 'number' && result !== 0) {107 LOGGER.error(`script exited with exit code: '${result}'`);108 process.exit(result);109 }110 if (result instanceof Error) {111 LOGGER.error(`script exited with error:\n'${result.message}'`);112 process.exit(BuildscriptExitCode.SCRIPT_EXITED_WITH_ERROR);113 }114 // anything except for errors and numbers is silently ignored115 process.exit(0);116 } catch (error) {117 if (!(error instanceof Error)) {118 LOGGER.error('script has thrown an error, but it is not an instance of \'Error\'');119 process.exit(BuildscriptExitCode.SCRIPT_THROWN_NON_ERROR);120 }121 LOGGER.error(`script has thrown an error:\n'${error.message}'`);122 process.exit(BuildscriptExitCode.SCRIPT_EXITED_WITH_ERROR);123 }124}...
Builder.object.js
Source:Builder.object.js
1/*2* Author: Nik Cross3* Description: Processes a build json file to create a versioned script from a list of parts and optionally documentation4*/5function Builder(JSON,file) {6 var Build = function(JSON,file) {7 var result = "";8 var HR = "//==============================================================================================================//\n";9 var buildScript = {};10 this.loadBuildScript = function(fileName) {11 buildScript = this.JSON.parse( this.file.getAttachment("",""+fileName) );12 };13 this.setBuildParameter = function(key,value) {14 if(value===null) return;15 buildScript[key] = ""+value;16 };17 this.getBuildParameter = function(key) {18 return buildScript[key];19 };20 this.build = function() {21 var script = HR;22 buildScript.date = new Date();23 script += "/* Version "+buildScript.version+"*/\n";24 script += "/* Built on " + new Date() + " */\n";25 script += "/* Built by /OpenForum/Javascript/Builder.*/\n";26 script += "/* Do not edit as changes may be overwritten */\n";27 script += HR;28 for(var i in buildScript.steps) {29 var step = buildScript.steps[i];30 if(step.action==="append") {31 script += HR;32 script += "/* Source: "+step.file+"*/\n";33 script += HR;34 script += this.file.getAttachment("",step.file);35 script += "\n/* End of: "+step.file+"*/\n\n";36 script += HR;37 } else if(step.action==="replace") {38 if(step.replaceWith.charAt(0)==="$") {39 step.replaceWith = buildScript[step.replaceWith.substring(1)];40 }41 script = script.replace( new RegExp(step.searchFor,"g"),step.replaceWith);42 }43 }44 this.file.saveAttachment("",buildScript.targetFile,script);45 var HelpPageGenerator = js.getObject("/OpenForum/Javascript/DocumentationGenerator","HelpPageGenerator.js");46 for(var i in buildScript.steps) {47 var step = buildScript.steps[i];48 if(step.action==="document") {49 if(this.file.attachmentExists(step.helpPageName,step.helpScriptFileName)===false) {50 eval(script);51 var helpScript = "/* Built "+new Date()+"*/\n";52 var objectName = step.objectName.split(",");53 for(var o=0; o<objectName.length;o++) {54 var object = eval(objectName[o]);55 if(typeof(object)=="function") {56 try{57 object = new object();58 } catch(e){59 continue;60 };61 }62 helpScript += "\n"+HelpPageGenerator.setObjectName(objectName[o]).setObject(object).generateHelpScript();63 }64 this.file.saveAttachment(step.helpPageName,step.helpScriptFileName,helpScript);65 } else {66 var helpScript = this.file.getAttachment(step.helpPageName,step.helpScriptFileName);67 eval(script+"\n"+helpScript);68 var helpContent = "!!";69 var objectName = step.objectName.split(",");70 for(var o=0; o<objectName.length;o++) {71 var object = eval(objectName[o]);72 if(typeof(object)=="function") {73 try{74 object = new object();75 } catch(e){76 continue;77 };78 }79 80 helpContent += "\n\n !!"+HelpPageGenerator.setObjectName(objectName[o]).setObject(object).generateHelpPage()+"\n\n----\n\n";81 }82 helpContent ="<div class=\"large-6 columns\">"+helpContent+"<br/>''Built "+new Date()+"''</div><div class=\"large-6 columns\">"+"{{{"+script+"}}} </div>";83 this.file.saveAttachment(step.helpPageName,step.helpContentFileName,helpContent);84 }85 }86 }87 var versionedTargetFile = buildScript.versionFile.substring(0,buildScript.versionFile.indexOf("."))+"-";88 versionedTargetFile += buildScript.version.replace(/\./g,"-");89 versionedTargetFile += buildScript.targetFile.substring(buildScript.targetFile.indexOf("."));90 buildScript.versionedTargetFile = versionedTargetFile;91 this.file.saveAttachment("",versionedTargetFile,script);92 };93 };94 this.getBuild = function() {95 return new Build(JSON,file);96 };...
build_project.js
Source:build_project.js
1console.log('Building Kipling');2var errorCatcher = require('./error_catcher');3var fs = require('fs');4var fse = require('fs-extra');5var path = require('path');6var cwd = process.cwd();7var async = require('async');8var child_process = require('child_process');9// Figure out what OS we are building for10var buildOS = {11 'darwin': 'darwin',12 'win32': 'win32'13}[process.platform];14if(typeof(buildOS) === 'undefined') {15 buildOS = 'linux';16}17var mac_notarize = false;18// The LabJack macOS installer builder signs Kipling files, so we actually don't19// want to sign here.20if(process.argv.some((arg)=>{return process.argv.indexOf('mac_sign') > 0;})) {21 mac_notarize = true;22 console.log('**************************\n ****Signing ****\n**************************');23} else {24 console.log('**************************\n**** Not Signing ****\n**************************');25}26var BUILD_SCRIPTS_DIR = 'build_scripts';27var commands = {};28var buildScripts = [29 {'script': 'prepare_build', 'text': 'Preparing Build'},30 {'script': 'publish_locally', 'text': 'Publish Locally'},31 {'script': 'gather_project_files', 'text': 'Gathering Project Files'},32 {'script': 'edit_k3_startup_settings', 'text': 'Edit K3 Startup Settings'},33 {'script': 'install_production_dependencies', 'text': 'Installing production dependencies'},34 {'script': 'validate_internal_dependencies', 'text': 'Validating there are no duplicate internal dependencies'},35 {'script': 'rebuild_native_modules', 'text': 'Rebuilding Native Modules (ffi & ref)'},36 {'script': 'clean_project', 'text': 'Cleaning Project'},37]38var conditionalMacBuildSteps = [39 {'script': 'sign_mac_build_before_compression', 'text': 'Signing Mac OS Build.'},40];41if((buildOS === 'darwin') && mac_notarize) {42 buildScripts = buildScripts.concat(conditionalMacBuildSteps);43}44var buildScriptsSecondary = [45 {'script': 'organize_project_files', 'text': 'Organizing Project Files & compress into packages.'},46 {'script': 'brand_project', 'text': 'Branding Project Files'},47 {'script': 'compress_output', 'text': 'Compressing Output and renaming'},48];49buildScripts = buildScripts.concat(buildScriptsSecondary);50var conditionalMacBuildStepsActerCompression = [51 {'script': 'sign_mac_build_after_compression', 'text': 'Signing Mac OS Build.'},52];53if((buildOS === 'darwin') && mac_notarize) {54 buildScripts = buildScripts.concat(conditionalMacBuildStepsActerCompression);55}56var finalBuildSteps = [57 {'script': 'compress_output', 'text': 'Compressing Output and renaming'},58];59buildScripts = buildScripts.concat(finalBuildSteps);60buildScripts.forEach(function(buildScript) {61 buildScript.scriptPath = path.normalize(path.join(62 BUILD_SCRIPTS_DIR, buildScript.script + '.js'63 ));64 buildScript.cmd = 'node ' + buildScript.scriptPath;65 buildScript.isFinished = false;66 buildScript.isSuccessful = false;67});68// Synchronous version of executing scripts69// buildScripts.forEach(function(buildScript) {70// try {71// console.log('Starting Step:', buildScript.text);72// var execOutput = child_process.execSync(buildScript.cmd);73// console.log('execOutput: ' , execOutput.toString());74// } catch(err) {75// console.log('Error Executing', buildScript.script, buildScript.text);76// process.exit(1);77// }78// });79// Asynchronous version of executing scripts80async.eachSeries(81 buildScripts,82 function(buildScript, cb) {83 console.log('Starting Step:', buildScript.text);84 child_process.exec(buildScript.cmd, function(error, stdout, stderr) {85 if (error) {86 console.error('Error Executing', error);87 console.error(buildScript.script, buildScript.text);88 cb(error);89 }90 console.log('stdout: ',stdout);91 console.log('stderr: ',stderr);92 cb();93 })94 },95 function(err) {96 if(err) {97 console.log('Error Executing Build Scripts...', err);98 process.exit(1);99 }...
rebuild_native_modules.js
Source:rebuild_native_modules.js
1console.log('Building Kipling');2var errorCatcher = require('./error_catcher');3var fs = require('fs');4var fse = require('fs-extra');5var path = require('path');6var cwd = process.cwd();7var child_process = require('child_process');8var async = require('async');9var commands = {};10var NATIVE_MODULES_BASE_LOCATION = path.normalize(path.join(11 'temp_project_files',12 'ljswitchboard-io_manager',13 'node_modules'14 // 'labjack-nodejs',15 // 'node_modules'16));17var buildScripts = [18 {'lib': 'ffi', 'text': 'Building ffi'},19 {'lib': 'ref', 'text': 'Building ref'},20];21var buildCommands = [];22buildScripts.forEach(function(buildScript) {23 buildScript.libPath = path.normalize(path.join(24 cwd, NATIVE_MODULES_BASE_LOCATION, buildScript.lib25 ));26 var cleanProject = [27 'node-gyp',28 'clean'29 ].join(' ');30 var buildOS = {31 'darwin': 'darwin',32 'win32': 'win32'33 }[process.platform];34 if(typeof(buildOS) === 'undefined') {35 buildOS = 'linux';36 }37 // Project configurations38 var configureProject = {39 'win32': [40 'node-gyp',41 'configure',42 '--msvs_version=2008',43 '--arch=' + process.arch,44 '--target=' + process.versions.node45 ],46 'darwin': [47 'node-gyp',48 'configure',49 '--arch=' + process.arch,50 '--target=' + process.versions.node51 ],52 'linux': [53 'node-gyp',54 'configure',55 '--arch=' + process.arch,56 '--target=' + process.versions.node,57 ]58 }[buildOS].join(' ');59 var buildProject = [60 'node-gyp',61 'build'62 ].join(' ');63 buildScript.cmds = [64 // cleanProject,65 configureProject,66 buildProject,67 ];68 buildScript.isFinished = false;69 buildScript.isSuccessful = false;70});71console.log('buildScripts', buildScripts);72// var executeBuildStepAsync = function(buildStep, cb) {73// console.log('Executing CMD', buildStep);74// // var execOutput = child_process.execSync(buildStep);75// child_process.exec(76// buildStep,77// function(error, stdout, stderr) {78// console.log('stdout: ' + stdout);79// console.log('stderr: ' + stderr);80// if (error !== null) {81// console.log('exec error: ' + error);82// }83// cb();84// });85// };86// async.eachSeries(87// buildScripts,88// function(buildScript, cb) {89// // Change Directories90// process.chdir(buildScript.libPath);91// console.log('Current Dir', process.cwd());92// try {93// console.log('Starting Step:', buildScript.text);94// // buildScript.cmds.forEach(executeBuildStep);95// async.eachSeries(buildScript.cmds, executeBuildStep, function(err) {96// // Restoring to starting directory97// process.chdir(cwd);98// cb();99// });100// } catch(err) {101// console.log('Error Executing', buildScript.text);102// // Restoring to starting directory103// process.chdir(cwd);104// cb();105// }106// }, function(err) {107// });108var executeBuildStep = function(buildStep) {109 console.log('Executing CMD', buildStep);110 var execOutput = child_process.execSync(buildStep);111};112buildScripts.forEach(function(buildScript) {113 // Change Directories114 process.chdir(buildScript.libPath);115 console.log('Current Dir', process.cwd());116 try {117 console.log('Starting Step:', buildScript.text);118 buildScript.cmds.forEach(executeBuildStep);119 } catch(err) {120 console.log('Error Executing', buildScript.text);121 }122 // Restoring to starting directory123 process.chdir(cwd);...
buildscriptDependency.js
Source:buildscriptDependency.js
1"use strict";2Object.defineProperty(exports, "__esModule", { value: true });3exports.setBuildscriptDependency = exports.withBuildscriptDependency = void 0;4const config_plugins_1 = require("@expo/config-plugins");5const constants_1 = require("./constants");6/**7 * Update `<project>/build.gradle` by adding google-services dependency to buildscript8 */9const withBuildscriptDependency = (config, { installPerfMonitoring, installCrashlytics }) => {10 return config_plugins_1.withProjectBuildGradle(config, (config) => {11 if (config.modResults.language === "groovy") {12 config.modResults.contents = setBuildscriptDependency(config.modResults.contents, installPerfMonitoring !== null && installPerfMonitoring !== void 0 ? installPerfMonitoring : false, installCrashlytics !== null && installCrashlytics !== void 0 ? installCrashlytics : false);13 }14 else {15 config_plugins_1.WarningAggregator.addWarningAndroid("android-google-services", `Cannot automatically configure project build.gradle if it's not groovy`);16 }17 return config;18 });19};20exports.withBuildscriptDependency = withBuildscriptDependency;21function setBuildscriptDependency(buildGradle, installPerfMonitoring, installCrashlytics) {22 let newBuildGradle = buildGradle;23 if (!newBuildGradle.includes(constants_1.googleServicesClassPath)) {24 // TODO: Find a more stable solution for this25 newBuildGradle = newBuildGradle.replace(/dependencies\s?{/, `dependencies {26 classpath '${constants_1.googleServicesClassPath}:${constants_1.googleServicesVersion}'`);27 }28 if (installPerfMonitoring &&29 !newBuildGradle.includes(constants_1.perfMonitoringClassPath)) {30 newBuildGradle = newBuildGradle.replace(/dependencies\s?{/, `dependencies {31 classpath '${constants_1.perfMonitoringClassPath}:${constants_1.perfMonitoringVersion}'`);32 }33 if (installCrashlytics && !newBuildGradle.includes(constants_1.crashlyticsClassPath)) {34 newBuildGradle = newBuildGradle.replace(/dependencies\s?{/, `dependencies {35 classpath '${constants_1.crashlyticsClassPath}:${constants_1.crashlyticsVersion}'`);36 }37 return newBuildGradle;38}...
build-script.js
Source:build-script.js
...7const banner = require( './constants/banner' );8const fs = require( 'fs' ).promises;9const zlib = require( 'zlib' );10const name = 'splide';11async function buildScript( compress, type = 'default' ) {12 const file = `./dist/js/${ name }${ type !== 'default' ? `-${ type }` : '' }${ compress ? '.min' : '' }.js`;13 const bundle = await rollup( {14 input: `./src/js/build/${ type }.ts`,15 plugins: [16 resolve(),17 esbuild( { minify: false } ),18 babel.getBabelOutputPlugin( {19 configFile: path.resolve( __dirname, '../.babelrc' ),20 allowAllFormats: true,21 } ),22 compress ? minify() : false,23 ]24 } );25 await bundle.write( {26 banner,27 file,28 format : 'umd',29 name : type === 'default' ? 'Splide' : 'SplideRenderer',30 sourcemap: ! compress,31 } );32 if ( compress && type === 'default' ) {33 await fs.readFile( file ).then( content => {34 return new Promise( ( resolve, reject ) => {35 zlib.gzip( content, ( err, binary ) => {36 if ( err ) {37 return reject( err );38 }39 fs.writeFile( `${ file }.gz`, binary ).then( resolve, reject );40 } );41 } );42 } );43 }44}45Promise.all( [46 buildScript(),47 buildScript( true ),48 buildScript( true, 'renderer' ),49] ).catch( e => console.error( e ) );50exports.buildJs = () => buildScript();51exports.buildMin = () => buildScript( true );...
quick_build_project.js
Source:quick_build_project.js
1console.log('Building Kipling');2var errorCatcher = require('./error_catcher');3var fs = require('fs');4var fse = require('fs-extra');5var path = require('path');6var cwd = process.cwd();7var child_process = require('child_process');8var BUILD_SCRIPTS_DIR = 'build_scripts';9var commands = {};10var buildScripts = [11 {'script': 'prepare_build', 'text': 'Preparing Build'},12 {'script': 'organize_project_files', 'text': 'Organizing Project Files'},13 {'script': 'brand_project', 'text': 'Branding Project Files'},14];15buildScripts.forEach(function(buildScript) {16 buildScript.scriptPath = path.normalize(path.join(17 BUILD_SCRIPTS_DIR, buildScript.script + '.js'18 ));19 buildScript.cmd = 'node ' + buildScript.scriptPath;20 buildScript.isFinished = false;21 buildScript.isSuccessful = false;22});23buildScripts.forEach(function(buildScript) {24 try {25 console.log('Starting Step:', buildScript.text);26 var execOutput = child_process.execSync(buildScript.cmd);27 } catch(err) {28 console.log('Error Executing', buildScript.script, buildScript.text);29 }...
Using AI Code Generation
1var appiumBaseDriver = require('appium-base-driver');2var buildScript = appiumBaseDriver.buildScript;3var execute = appiumBaseDriver.execute;4var executeAtom = appiumBaseDriver.executeAtom;5var executeAtomAsync = appiumBaseDriver.executeAtomAsync;6var executeScript = appiumBaseDriver.executeScript;7var executeAsync = appiumBaseDriver.executeAsync;8var executeJwp = appiumBaseDriver.executeJwp;9var executeJwpAsync = appiumBaseDriver.executeJwpAsync;10var executeMobile = appiumBaseDriver.executeMobile;11var executeMobileAsync = appiumBaseDriver.executeMobileAsync;12var executeMobileAtom = appiumBaseDriver.executeMobileAtom;13var executeMobileAtomAsync = appiumBaseDriver.executeMobileAtomAsync;14var executeCustom = appiumBaseDriver.executeCustom;15var executeCustomAsync = appiumBaseDriver.executeCustomAsync;16var executeCustomAtom = appiumBaseDriver.executeCustomAtom;17var executeCustomAtomAsync = appiumBaseDriver.executeCustomAtomAsync;18var executeCustomJwp = appiumBaseDriver.executeCustomJwp;19var executeCustomJwpAsync = appiumBaseDriver.executeCustomJwpAsync;
Using AI Code Generation
1var AppiumBaseDriver = require('appium-base-driver');2var appiumBaseDriver = new AppiumBaseDriver();3var script = appiumBaseDriver.buildScript('test.js');4console.log(script);5'use strict';6var AppiumBaseDriver = require('appium-base-driver');7var appiumBaseDriver = new AppiumBaseDriver();8var script = appiumBaseDriver.buildScript('test.js');9console.log(script);10'use strict';11var AppiumBaseDriver = require('appium-base-driver');12var appiumBaseDriver = new AppiumBaseDriver();13var script = appiumBaseDriver.buildScript('test.js');14console.log(script);15'use strict';16var AppiumBaseDriver = require('appium-base-driver');17var appiumBaseDriver = new AppiumBaseDriver();18var script = appiumBaseDriver.buildScript('test.js');19console.log(script);20'use strict';21var AppiumBaseDriver = require('appium-base-driver');22var appiumBaseDriver = new AppiumBaseDriver();23var script = appiumBaseDriver.buildScript('test.js');24console.log(script);25'use strict';26var AppiumBaseDriver = require('appium-base-driver');
Using AI Code Generation
1var AppiumBaseDriver = require('appium-base-driver');2var driver = new AppiumBaseDriver();3var script = driver.buildScript('alert("Hello");');4console.log(script);5var AppiumAndroidDriver = require('appium-android-driver');6var driver = new AppiumAndroidDriver();7var script = driver.buildScript('alert("Hello");');8console.log(script);9var AppiumIosDriver = require('appium-ios-driver');10var driver = new AppiumIosDriver();11var script = driver.buildScript('alert("Hello");');12console.log(script);13var AppiumWindowsDriver = require('appium-windows-driver');14var driver = new AppiumWindowsDriver();15var script = driver.buildScript('alert("Hello");');16console.log(script);17var AppiumMacDriver = require('appium-mac-driver');18var driver = new AppiumMacDriver();19var script = driver.buildScript('alert("Hello");');20console.log(script);21var AppiumSelendroidDriver = require('appium-selendroid-driver');22var driver = new AppiumSelendroidDriver();23var script = driver.buildScript('alert("Hello");');24console.log(script);25var AppiumYouiEngineDriver = require('appium-youiengine-driver');26var driver = new AppiumYouiEngineDriver();27var script = driver.buildScript('alert("Hello");');28console.log(script);29var AppiumTizenDriver = require('appium-tizen-driver');30var driver = new AppiumTizenDriver();31var script = driver.buildScript('alert("Hello");');32console.log(script);33var AppiumWebDriver = require('appium-webdriver');
Using AI Code Generation
1const { AppiumBaseDriver } = require('appium-base-driver');2let adb = new AppiumBaseDriver();3adb.buildScript('test.js', 'test');4const { AppiumBaseDriver } = require('appium-base-driver');5let adb = new AppiumBaseDriver();6adb.buildScript('test.js', 'test');
Using AI Code Generation
1var appiumBaseDriver = require('appium-base-driver');2var driver = new appiumBaseDriver();3var script = driver.buildScript('alert("Hello World");', 'javascript');4console.log(script);5{ type: 'text/javascript',6 value: 'alert("Hello World");' }
Using AI Code Generation
1const { buildScript } = require('appium-base-driver');2const { fs } = require('appium-support');3const path = require('path');4(async () => {5 const script = await buildScript();6 const installScript = path.resolve(__dirname, 'install_appium-uiautomator2-driver.sh');7 await fs.writeFile(installScript, script, 'utf8');8 console.log(`Script to install appium-uiautomator2-driver written to ${installScript}`);9})();
Using AI Code Generation
1var myScript = buildScript('path/to/my/script.js');2driver.execute(myScript);3var myScript = function() {4}5driver.execute('path/to/my/script.js');6driver.execute('path/to/my/script.js');7driver.execute('path/to/my/script.js');8driver.execute('path/to/my/script.js');9driver.execute('path/to/my/script.js');10driver.execute('path/to/my/script.js');
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!