Best JavaScript code snippet using stryker-parent
npm-crawl.js
Source:npm-crawl.js
1var utils = require("./npm-utils");2var SemVer = require('./semver');3/**4 * @module {{}} system-npm/crawl5 * Exports helpers used for crawling package.json6 */7var crawl = {8 /**9 * Adds the properties read from a package's source to the `pkg` object.10 * @param {Object} context11 * @param {NpmPackage} pkg - 12 * @param {String} source13 * @return {NpmPackage}14 */15 processPkgSource: function(context, pkg, source) {16 var packageJSON = JSON.parse(source);17 utils.extend(pkg, packageJSON);18 context.packages.push(pkg);19 return pkg;20 },21 /**22 * Crawls the packages dependencies23 * @param {Object} context24 * @param {NpmPackage} pkg25 * @param {Boolean} [isRoot] If the root module's dependencies shoudl be crawled.26 * @return {Promise} A promise when all packages have been loaded27 */28 deps: function(context, pkg, isRoot) {29 30 var deps = crawl.getDependencies(context.loader, pkg, isRoot);31 return Promise.all(utils.filter(utils.map(deps, function(childPkg){32 // if a peer dependency, and not isRoot33 if(childPkg._isPeerDependency && !isRoot ) {34 // check one node_module level higher35 childPkg.origFileUrl = nodeModuleAddress(pkg.fileUrl)+"/"+childPkg.name+"/package.json";36 } else {37 childPkg.origFileUrl = utils.path.depPackage(pkg.fileUrl, childPkg.name);38 }39 40 // check if childPkg matches a parent's version ... if it does ... do nothing41 if(crawl.hasParentPackageThatMatches(context, childPkg)) {42 return;43 }44 45 if(crawl.isSameRequestedVersionFound(context, childPkg)) {46 return;47 }48 49 // otherwise go get child ... but don't process dependencies until all of these dependencies have finished50 return npmLoad(context, childPkg).then(function(source){51 if(source) {52 return crawl.processPkgSource(context, childPkg, source);53 } // else if there's no source, it's likely because this dependency has been found elsewhere54 });55 56 }), truthy)).then(function(packages){57 // at this point all dependencies of pkg have been loaded, it's ok to get their children58 59 return Promise.all(utils.filter(utils.map(packages, function(childPkg){60 if(childPkg) {61 return crawl.deps(context, childPkg);62 } 63 }), truthy));64 });65 },66 /**67 * Returns an array of the dependency names that should be crawled.68 * @param {Object} loader69 * @param {NpmPackage} packageJSON70 * @param {Boolean} [isRoot]71 * @return {Array<String>}72 */73 getDependencies: function(loader, packageJSON, isRoot){74 var deps = crawl.getDependencyMap(loader, packageJSON, isRoot);75 76 var dependencies = [];77 for(var name in deps) {78 dependencies.push(deps[name]);79 }80 81 return dependencies;82 },83 /**84 * Returns a map of the dependencies and their ranges.85 * @param {Object} loader86 * @param {Object} packageJSON87 * @param {Boolean} isRoot88 * @return {Object<String,Range>} A map of dependency names and requested version ranges.89 */90 getDependencyMap: function(loader, packageJSON, isRoot){91 var system = packageJSON.system;92 // convert npmIgnore93 var npmIgnore = system && system.npmIgnore;94 function convertToMap(arr) {95 var npmMap = {};96 for(var i = 0; i < arr.length; i++) {97 npmMap[arr[i]] = true;98 }99 return npmMap;100 }101 if(npmIgnore && typeof npmIgnore.length === 'number') {102 npmIgnore = packageJSON.system.npmIgnore = convertToMap(npmIgnore);103 }104 // convert npmDependencies105 var npmDependencies = system && system.npmDependencies;106 if(npmDependencies && typeof npmDependencies.length === "number") {107 packageJSON.system.npmDependencies = convertToMap(npmDependencies);108 }109 npmIgnore = npmIgnore || {};110 111 var deps = {};112 addDeps(packageJSON, packageJSON.peerDependencies || {}, deps,113 "peerDependencies", {_isPeerDependency: true});114 addDeps(packageJSON, packageJSON.dependencies || {}, deps, "dependencies");115 if(isRoot) {116 addDeps(packageJSON, packageJSON.devDependencies || {}, deps,117 "devDependencies");118 }119 return deps;120 },121 isSameRequestedVersionFound: function(context, childPkg) {122 if(!context.versions[childPkg.name]) {123 context.versions[childPkg.name] = {};124 }125 var versions = context.versions[childPkg.name];126 127 var requestedRange = childPkg.version;128 129 if( !SemVer.validRange(childPkg.version) ) {130 131 if(/^[\w_\-]+\/[\w_\-]+(#[\w_\-]+)?$/.test(requestedRange) ) {132 133 requestedRange = "git+https://github.com/"+requestedRange;134 if(!/(#[\w_\-]+)?$/.test(requestedRange)) {135 requestedRange += "#master";136 }137 }138 }139 var version = versions[requestedRange];140 141 if(!version) {142 versions[requestedRange] = childPkg;143 } else {144 // add a placeholder at this path145 context.paths[childPkg.origFileUrl] = version;146 return true;147 }148 },149 hasParentPackageThatMatches: function(context, childPkg){150 // check paths151 var parentAddress = utils.path.parentNodeModuleAddress(childPkg.origFileUrl);152 while( parentAddress ) {153 var packageAddress = parentAddress+"/"+childPkg.name+"/package.json";154 var parentPkg = context.paths[packageAddress];155 if(parentPkg) {156 if(SemVer.satisfies(parentPkg.version, childPkg.version)) {157 return parentPkg;158 }159 }160 parentAddress = utils.path.parentNodeModuleAddress(packageAddress);161 }162 },163 matchedVersion: function(context, packageName, requestedVersion){164 var versions = context.versions[packageName], pkg;165 for(v in versions) {166 pkg = versions[v];167 if(SemVer.satisfies(pkg.version, requestedVersion)) {168 return pkg;169 }170 }171 }172};173module.exports = crawl;174function nodeModuleAddress(address) {175 var nodeModules = "/node_modules/",176 nodeModulesIndex = address.lastIndexOf(nodeModules);177 if(nodeModulesIndex >= 0) {178 return address.substr(0, nodeModulesIndex+nodeModules.length - 1 );179 }180}181function truthy(x) {182 return x;183}184var alwaysIgnore = {"steal": 1,"steal-tools":1,"bower":1,"grunt":1, "grunt-cli": 1};185function addDeps(packageJSON, dependencies, deps, type, defaultProps){186 // convert an array to a map187 var npmIgnore = packageJSON.system && packageJSON.system.npmIgnore;188 var npmDependencies = packageJSON.system && packageJSON.system.npmDependencies;189 var ignoreType = npmIgnore && npmIgnore[type];190 function includeDep(name) {191 if(alwaysIgnore[name]) return false;192 if(!npmIgnore && npmDependencies) {193 return !!npmDependencies[name];194 }195 if(npmIgnore && npmDependencies) {196 return ignoreType ? !!npmDependencies[name] : !npmIgnore[name];197 }198 if(ignoreType) return false;199 return !!(!npmIgnore || !npmIgnore[name]);200 }201 202 for(var name in dependencies) {203 if(includeDep(name)) {204 deps[name] = utils.extend(defaultProps || {}, {name: name, version: dependencies[name]});205 }206 }207}208// Loads package.json209// if it finds one, it sets that package in paths210// so it won't be loaded twice.211function npmLoad(context, pkg, fileUrl){212 fileUrl = fileUrl || pkg.origFileUrl;213 return System.fetch({214 address: fileUrl,215 name: fileUrl,216 metadata: {}217 }).then(function(source){218 context.paths[fileUrl || pkg.origFileUrl] = pkg;219 pkg.fileUrl = fileUrl;220 return source;221 },function(ex){222 return npmTraverseUp(context, pkg, fileUrl);223 });224};225function npmTraverseUp(context, pkg, fileUrl) {226 // make sure we aren't loading something we've already loaded227 var parentAddress = utils.path.parentNodeModuleAddress(fileUrl);228 if(!parentAddress) {229 throw new Error('Did not find ' + pkg.origFileUrl);230 }231 var nodeModuleAddress = parentAddress+"/"+pkg.name+"/package.json";232 if(context.paths[nodeModuleAddress]) {233 // already processed234 return;235 } else {236 return npmLoad(context, pkg, nodeModuleAddress);237 }...
prepare-version-info.js
Source:prepare-version-info.js
1require('shelljs/global');2require('./exec-command');3var fs = require('fs'), appDependencyList, appInfo = {compileTimeDependencies: {}}, appPackageJSON, k, getDependencyHash,4 appBowerJSON = JSON.parse(fs.readFileSync('bower.json')), uiFoundationAddons = {}, appPackageJSONSource = JSON.parse(fs.readFileSync('package.json'));5function renameDependenciesHashIntoChildrenArray(dependenciesHash) {6 var i, j, k;7 if (dependenciesHash.dependencies != null) {8 dependenciesHash._children = dependenciesHash.dependencies;9 for (k in dependenciesHash._children) {10 dependenciesHash._children[k].name = k;11 }12 delete dependenciesHash.dependencies;13 dependenciesHash._children = dependenciesHash._children;14 for (j in dependenciesHash._children) {15 if (dependenciesHash._children[j].dependencies != null) {16 renameDependenciesHashIntoChildrenArray(dependenciesHash._children[j]);17 }18 }19 dependenciesHash._children = convertObjectIntoArray(dependenciesHash._children);20 } else {21 for (i in dependenciesHash) {22 dependenciesHash[i].name = i;23 if (dependenciesHash[i].dependencies != null) {24 renameDependenciesHashIntoChildrenArray(dependenciesHash[i]);25 }26 }27 }28}29function prepareNpmDependencies(npmDependencyHash) {30 renameDependenciesHashIntoChildrenArray(npmDependencyHash);31 var i, dependencies = appPackageJSONSource.dependencies;32 for (i in npmDependencyHash) {33 if (i.indexOf('wb-ui-') !== -1) {34 if (dependencies[i] !== undefined) {35 uiFoundationAddons[i] = npmDependencyHash[i];36 }37 delete npmDependencyHash[i];38 }39 }40 return {41 name: 'NPM Dependencies',42 _children: convertObjectIntoArray(npmDependencyHash)43 };44}45function prepareBowerDependencies(dependencyHash) {46 var formattedDependencyHash = {}, k, formattedDependencyArray;47 for (k in dependencyHash) {48 formattedDependencyHash[k] = {49 name: k,50 version: dependencyHash[k]51 }52 }53 formattedDependencyArray = convertObjectIntoArray(formattedDependencyHash);54 return {55 name: 'Bower Dependencies',56 _children: formattedDependencyArray57 };58}59function convertObjectIntoArray(object) {60 return Object.keys(object).map(function (key) {61 return object[key];62 });63}64execCmd('npm ls --prod --json --loglevel silent > tmp/dependencies-hash.json', true);65appPackageJSON = JSON.parse(fs.readFileSync('tmp/dependencies-hash.json'));66fs.unlink('tmp/dependencies-hash.json');67appInfo.name = appPackageJSON.name;68appInfo.version = appPackageJSON.version;69appInfo.compileTimeDependencies = {name: 'Compile Time Dependencies', npmDependencies: appPackageJSON.dependencies};70appInfo.compileTimeDependencies.bowerDependencies = prepareBowerDependencies(appBowerJSON.dependencies);71appInfo.runTimeUIDependencies = {name: "UI Modules Dependency", _children: [{72 name: 'UI Runtime Modules',73 toBeLoaded: true,74 nodeType: 'uiModules'75}]};76appInfo.apiDependencies = {toBeLoaded: true, name: "Server Side Dependencies"};77for (k in appInfo.compileTimeDependencies.npmDependencies) {78 if (k.indexOf('wb-ui-') != -1) {79 appInfo.compileTimeDependencies.npmDependencies[k].version = appInfo.compileTimeDependencies.npmDependencies[k].resolved.split('#')[1] || 'master';80 }81}82appInfo.compileTimeDependencies.npmDependencies = prepareNpmDependencies(appInfo.compileTimeDependencies.npmDependencies);83appInfo.compileTimeDependencies._children = [appInfo.compileTimeDependencies.bowerDependencies, appInfo.compileTimeDependencies.npmDependencies];84delete appInfo.compileTimeDependencies.bowerDependencies;85delete appInfo.compileTimeDependencies.npmDependencies;86appInfo.runTimeUIDependencies._children.push({87 name: 'UI Foundation Addons',88 _children: convertObjectIntoArray(uiFoundationAddons)89});90appInfo._children = [appInfo.compileTimeDependencies, appInfo.runTimeUIDependencies, appInfo.apiDependencies];91delete appInfo.compileTimeDependencies;92delete appInfo.runTimeUIDependencies;93delete appInfo.apiDependencies;94fs.writeFileSync('app-version-info.json', JSON.stringify(appInfo));...
Using AI Code Generation
1var stryker = require('stryker-parent');2console.log(stryker.npmDependencies());3var stryker = require('stryker-parent');4console.log(stryker.npmDependencies());5var stryker = require('stryker-parent');6console.log(stryker.npmDependencies());7var stryker = require('stryker-parent');8console.log(stryker.npmDependencies());9var stryker = require('stryker-parent');10console.log(stryker.npmDependencies());11var stryker = require('stryker-parent');12console.log(stryker.npmDependencies());13var stryker = require('stryker-parent');14console.log(stryker.npmDependencies());15var stryker = require('stryker-parent');16console.log(stryker.npmDependencies());17var stryker = require('stryker-parent');18console.log(stryker.npmDependencies());19var stryker = require('stryker-parent');20console.log(stryker.npmDependencies());21var stryker = require('stryker-parent');22console.log(stryker.npmDependencies());23var stryker = require('stryker-parent');24console.log(stryker.npmDependencies());25var stryker = require('stryker-parent');26console.log(stryker.npmDependencies());
Using AI Code Generation
1const strykerParent = require('stryker-parent')2strykerParent.npmDependencies()3const strykerParent = require('stryker-parent')4strykerParent.npmDependencies()5const strykerParent = require('stryker-parent')6strykerParent.npmDependencies()7const strykerParent = require('stryker-parent')8strykerParent.npmDependencies()9const strykerParent = require('stryker-parent')10strykerParent.npmDependencies()11const strykerParent = require('stryker-parent')12strykerParent.npmDependencies()13const strykerParent = require('stryker-parent')14strykerParent.npmDependencies()15const strykerParent = require('stryker-parent')16strykerParent.npmDependencies()17const strykerParent = require('stryker-parent')18strykerParent.npmDependencies()19const strykerParent = require('stryker-parent')20strykerParent.npmDependencies()21const strykerParent = require('stryker-parent')22strykerParent.npmDependencies()23const strykerParent = require('stryker-parent')24strykerParent.npmDependencies()25const strykerParent = require('stryker-parent')26strykerParent.npmDependencies()
Using AI Code Generation
1const strykerParent = require('stryker-parent');2const npmDependencies = strykerParent.npmDependencies();3console.log(npmDependencies);4const strykerParent = require('stryker-parent');5const npmDependencies = strykerParent.npmDependencies();6console.log(npmDependencies);7const strykerParent = require('stryker-parent');8const npmDependencies = strykerParent.npmDependencies();9console.log(npmDependencies);10const strykerParent = require('stryker-parent');11const npmDependencies = strykerParent.npmDependencies();12console.log(npmDependencies);13const strykerParent = require('stryker-parent');14const npmDependencies = strykerParent.npmDependencies();15console.log(npmDependencies);16const strykerParent = require('stryker-parent');17const npmDependencies = strykerParent.npmDependencies();18console.log(npmDependencies);19const strykerParent = require('stryker-parent');20const npmDependencies = strykerParent.npmDependencies();21console.log(npmDependencies);22const strykerParent = require('stryker-parent');23const npmDependencies = strykerParent.npmDependencies();24console.log(npmDependencies);25const strykerParent = require('stryker-parent');26const npmDependencies = strykerParent.npmDependencies();27console.log(npmDependencies);28const strykerParent = require('stryker-parent');29const npmDependencies = strykerParent.npmDependencies();30console.log(npmDependencies);31const strykerParent = require('stry
Using AI Code Generation
1const stryker = require('stryker-parent');2stryker.npmDependencies();3stryker.npmDependencies();4const stryker = require('stryker-parent');5stryker.npmDependencies();6stryker.npmDependencies();7const stryker = require('stryker-parent');8stryker.npmDependencies();9stryker.npmDependencies();10const stryker = require('stryker-parent');11stryker.npmDependencies();12stryker.npmDependencies();13const stryker = require('stryker-parent');14stryker.npmDependencies();15stryker.npmDependencies();16const stryker = require('stryker-parent');17stryker.npmDependencies();18stryker.npmDependencies();19const stryker = require('stryker-parent');20stryker.npmDependencies();21stryker.npmDependencies();22const stryker = require('stryker-parent');
Using AI Code Generation
1import { npmDependencies } from 'stryker-parent';2import { npmDependencies } from 'stryker-parent';3import { npmDependencies } from 'stryker-parent';4import { npmDependencies } from 'stryker-parent';5import { npmDependencies } from 'stryker-parent';6import { npmDependencies } from 'stryker-parent';7import { npmDependencies } from 'stryker-parent';8import { npmDependencies } from 'stryker-parent';9import { npmDependencies } from 'stryker-parent';10import { npmDependencies } from 'stryker-parent';11import { npmDependencies } from 'stryker-parent';12import { npmDependencies } from 'stryker-parent';13import { npmDependencies } from 'stryker-parent';14import { npmDependencies } from 'stryker-parent';
Using AI Code Generation
1var parent = require('stryker-parent');2parent.npmDependencies(function (err, dependencies) {3});4var parent = require('stryker-parent');5parent.npmDependencies(function (err, dependencies) {6});7var parent = require('stryker-parent');8parent.npmDependencies(function (err, dependencies) {9});10var parent = require('stryker-parent');11parent.npmDependencies(function (err, dependencies) {12});13var parent = require('stryker-parent');14parent.npmDependencies(function (err, dependencies) {15});16var parent = require('stryker-parent');17parent.npmDependencies(function (err, dependencies) {18});19var parent = require('stryker-parent');20parent.npmDependencies(function (err, dependencies) {21});22var parent = require('stryker-parent');23parent.npmDependencies(function (err, dependencies) {24});25var parent = require('stryker-parent');26parent.npmDependencies(function (err, dependencies) {27});28var parent = require('stryker-parent');29parent.npmDependencies(function (err, dependencies) {30});31var parent = require('stryker-parent');32parent.npmDependencies(function (err, dependencies) {33});
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!!