How to use defaultConfig method in istanbul

Best JavaScript code snippet using istanbul

RadarComponent.react.js

Source:RadarComponent.react.js Github

copy

Full Screen

1import React, { Component } from 'react';2import { PropTypes } from 'prop-types';3import d3 from 'd3';4const RadarChart = {5 draw: (_id, _legend, _d, _options) => {6 console.log('RadarChart.draw', _id, _legend, _d, _options);7 // Set the defaults8 let defaultConfig = {9 defaultColor: 'grey',10 defaultFontFamily: 'sans-serif',11 defaultFontSize: '12px',12 title: '',13 radius: 5,14 15 width: 500,16 height: 500,17 factor: 1,18 factorLegend: 0.85,19 maxValue: 1,20 radians: 2 * Math.PI,21 toRight: 5,22 translateX: 100,23 translateY: 90,24 extraWidthX: 100,25 extraWidthY: 100,26 color: d3.scale.category10(),27 titleX: 0,28 titleY: 50,29 titleFontSize: '18px',30 titleFontFamily: '',31 titleColor: '',32 legendRight: '150',33 legendTop: '40',34 legendFontSize: '',35 legendFontFamily: '',36 legendColor: '',37 legendSquareSize: 10,38 levels: 10,39 levelsStrokeColor: 'grey',40 levelsStrokeOpacity: '0.7',41 levelsStrokeWidth: '1',42 axisTickFontFamily: '',43 axisTickFontSize: '',44 axisTickColor: '',45 axisLabelFontFamily: '',46 axisLabelFontSize: '',47 axisLabelColor: '',48 axisLabelTextAnchor: 'middle',49 axisStrokeColor: '#000000',50 axisStrokeWidth: '1',51 tooltipFontFamily: '',52 tooltipFontSize: '',53 tooltipColor: '',54 areaBorderWidth: '2px',55 areaOpacity: '0.5',56 areaOpacityAreaHover: '0.7',57 areaOtherOpacityAreaHover: '0.1',58 areaOpacityNodeHover: '0.7',59 areaOtherOpacityNodeHover: '0.1',60 nodeOpacity: '0.7'61 };62 if (!_d || _d.length === 0 || _d[0].length === 0) {63 return;64 }65 if (!_legend) {66 _legend = [];67 }68 // Set overrides69 if ('undefined' !== typeof _options) {70 for (let i in _options) {71 if ('undefined' !== typeof _options[i]) {72 defaultConfig[i] = _options[i];73 }74 }75 }76 defaultConfig.maxValue = Math.max(defaultConfig.maxValue, d3.max(_d, (i) => {77 return d3.max(i.map((o) => {78 return o.value;79 }));80 }));81 // Make assumption that d[0].length === d[n].length for all n between 0 and (d.length - 1).82 let allAxis = (_d[0].map((i) => {83 return i.axis;84 }));85 let total = allAxis.length;86 let radius = defaultConfig.factor * Math.min(defaultConfig.width / 2, defaultConfig.height / 2);87 let Format = d3.format('%');88 // Cleanup89 d3.select(_id)90 .select('svg')91 .remove();92 // Create the svg container and the base g tag93 let g = d3.select(_id)94 .append('svg')95 .attr('width', defaultConfig.width + defaultConfig.extraWidthX)96 .attr('height', defaultConfig.height + defaultConfig.extraWidthY)97 .append('g')98 .attr('transform', 'translate(' + defaultConfig.translateX + ',' + defaultConfig.translateY + ')');99 // Tooltip100 let tooltip = g.append('text')101 .style('opacity', 0)102 .attr('fill', defaultConfig.tooltipColor || defaultConfig.defaultColor)103 .style('font-family', defaultConfig.tooltipFontFamily || defaultConfig.defaultFontFamily)104 .style('font-size', defaultConfig.tooltipFontSize || defaultConfig.defaultFontSize);105 // Circular segments106 for (let j = 0; j < defaultConfig.levels - 1; j++) {107 const levelFactor = defaultConfig.factor * radius * ((j + 1) / defaultConfig.levels);108 g.selectAll('.levels')109 .data(allAxis)110 .enter()111 .append('svg:line')112 .attr('x1', (d, i) => {113 return levelFactor * (1 - defaultConfig.factor * Math.sin(i * defaultConfig.radians / total));114 })115 .attr('y1', (d, i) => {116 return levelFactor * (1 - defaultConfig.factor * Math.cos(i * defaultConfig.radians / total));117 })118 .attr('x2', (d, i) => {119 return levelFactor * (1 - defaultConfig.factor * Math.sin((i + 1) * defaultConfig.radians / total));120 })121 .attr('y2', (d, i) => {122 return levelFactor * (1 - defaultConfig.factor * Math.cos((i + 1) * defaultConfig.radians / total));123 })124 .attr('class', 'line')125 .style('stroke', defaultConfig.levelsStrokeColor)126 .style('stroke-opacity', defaultConfig.levelsStrokeOpacity)127 .style('stroke-width', defaultConfig.levelsStrokeWidth)128 .attr('transform', 'translate(' + (defaultConfig.width / 2 - levelFactor) + ', ' + (defaultConfig.height / 2 - levelFactor) + ')');129 }130 // Text indicating at what % each level is131 for (let j = 0; j < defaultConfig.levels; j++) {132 let levelFactor = defaultConfig.factor * radius * ((j + 1) / defaultConfig.levels);133 g.selectAll('.levels')134 .data([1]) // dummy data135 .enter()136 .append('svg:text')137 .attr('x', levelFactor * (1 - defaultConfig.factor * Math.sin(0)))138 .attr('y', levelFactor * (1 - defaultConfig.factor * Math.cos(0)))139 .attr('class', 'legend')140 .style('font-family', defaultConfig.axisTickFontFamily || defaultConfig.defaultFontFamily)141 .style('font-size', defaultConfig.axisTickFontSize || defaultConfig.defaultFontSize)142 .attr('transform', 'translate(' + (defaultConfig.width / 2 - levelFactor + defaultConfig.toRight) + ', ' + (defaultConfig.height / 2 - levelFactor) + ')')143 .attr('fill', defaultConfig.axisTickColor || defaultConfig.defaultColor)144 .text(Format((j + 1) * defaultConfig.maxValue / defaultConfig.levels));145 }146 let series = 0;147 let axis = g.selectAll('.axis')148 .data(allAxis)149 .enter()150 .append('g')151 .attr('class', 'axis');152 axis.append('line')153 .attr('x1', defaultConfig.width / 2)154 .attr('y1', defaultConfig.height / 2)155 .attr('x2', (d, i) => {156 return defaultConfig.width / 2 * (1 - defaultConfig.factor * Math.sin(i * defaultConfig.radians / total));157 })158 .attr('y2', (d, i) => {159 return defaultConfig.height / 2 * (1 - defaultConfig.factor * Math.cos(i * defaultConfig.radians / total));160 })161 .attr('class', 'line')162 .style('stroke', defaultConfig.axisStrokeColor)163 .style('stroke-width', defaultConfig.axisStrokeWidth);164 axis.append('text')165 .attr('class', 'legend')166 .text((d) => {167 return d;168 })169 .attr('fill', defaultConfig.axisLabelColor || defaultConfig.defaultColor)170 .style('font-family', defaultConfig.axisLabelFontFamily || defaultConfig.defaultFontFamily)171 .style('font-size', defaultConfig.axisLabelFontSize || defaultConfig.defaultFontSize)172 .attr('text-anchor', defaultConfig.axisLabelTextAnchor)173 .attr('dy', '1.5em')174 .attr('transform', () => {175 return 'translate(0, -10)';176 })177 .attr('x', (d, i) => {178 return defaultConfig.width / 2 * (1 - defaultConfig.factorLegend * Math.sin(i * defaultConfig.radians / total)) - 60 * Math.sin(i * defaultConfig.radians / total);179 })180 .attr('y', (d, i) => {181 return defaultConfig.height / 2 * (1 - Math.cos(i * defaultConfig.radians / total)) - 20 * Math.cos(i * defaultConfig.radians / total);182 });183 _d.forEach((y) => {184 g.selectAll('.nodes')185 .data(y)186 .enter()187 .append('svg:circle')188 .attr('class', 'radar-chart-serie' + series)189 .attr('r', defaultConfig.radius)190 .attr('alt', (j) => {191 return Math.max(j.value, 0);192 })193 .attr('cx', (j, i) => {194 return defaultConfig.width / 2 * (1 - (Math.max(j.value, 0) / defaultConfig.maxValue) * defaultConfig.factor * Math.sin(i * defaultConfig.radians / total));195 })196 .attr('cy', (j, i) => {197 return defaultConfig.height / 2 * (1 - (Math.max(j.value, 0) / defaultConfig.maxValue) * defaultConfig.factor * Math.cos(i * defaultConfig.radians / total));198 })199 .attr('data-id', (j) => {200 return j.axis;201 })202 .style('fill', defaultConfig.color(series)).style('fill-opacity', defaultConfig.nodeOpacity)203 .on('mouseover', function (d) {204 let newX = parseFloat(d3.select(this).attr('cx')) - 10;205 let newY = parseFloat(d3.select(this).attr('cy')) - 5;206 tooltip.attr('x', newX)207 .attr('y', newY)208 .text(Format(d.value))209 .transition(300)210 .style('opacity', 1);211 let z = 'polygon.' + d3.select(this).attr('class');212 g.selectAll('polygon')213 .transition(300)214 .style('fill-opacity', defaultConfig.areaOtherOpacityNodeHover);215 g.selectAll(z)216 .transition(300)217 .style('fill-opacity', defaultConfig.areaOpacityNodeHover);218 })219 .on('mouseout', () => {220 tooltip.transition(300)221 .style('opacity', 0);222 223 g.selectAll('polygon')224 .transition(300)225 .style('fill-opacity', defaultConfig.areaOpacity);226 })227 .append('svg:title')228 .text((j) => {229 return Math.max(j.value, 0);230 });231 let dataValuesArea = [];232 g.selectAll('.nodes')233 .data(y, (j, i) => {234 dataValuesArea.push([235 defaultConfig.width / 2 * (1 - (parseFloat(Math.max(j.value, 0)) / defaultConfig.maxValue) * defaultConfig.factor * Math.sin(i * defaultConfig.radians / total)),236 defaultConfig.height / 2 * (1 - (parseFloat(Math.max(j.value, 0)) / defaultConfig.maxValue) * defaultConfig.factor * Math.cos(i * defaultConfig.radians / total))237 ]);238 });239 dataValuesArea.push(dataValuesArea[0]);240 g.selectAll('.area')241 .data([dataValuesArea])242 .enter()243 .append('polygon')244 .attr('class', 'radar-chart-serie-' + series)245 .style('stroke-width', defaultConfig.areaBorderWidth)246 .style('stroke', defaultConfig.color(series))247 .attr('points', (d) => {248 let str = '';249 for (let pti = 0; pti < d.length; pti++) {250 str = str + d[pti][0] + ',' + d[pti][1] + ' ';251 }252 return str;253 })254 .style('fill', () => {255 return defaultConfig.color(series);256 })257 .style('fill-opacity', defaultConfig.areaOpacity)258 .on('mouseover', function () {259 let z = 'polygon.' + d3.select(this).attr('class');260 g.selectAll('polygon')261 .transition(300)262 .style('fill-opacity', defaultConfig.areaOtherOpacityAreaHover);263 g.selectAll(z)264 .transition(300)265 .style('fill-opacity', defaultConfig.areaOpacityAreaHover);266 })267 .on('mouseout', () => {268 g.selectAll('polygon')269 .transition(300)270 .style('fill-opacity', defaultConfig.areaOpacity);271 });272 series++;273 });274 const svg = d3.select(_id)275 .selectAll('svg')276 .append('svg')277 .attr('width', defaultConfig.width + defaultConfig.extraWidthX)278 .attr('height', defaultConfig.height + defaultConfig.extraWidthY);279 svg.append('text')280 .attr('class', 'title')281 .attr('transform', 'translate(90,0)')282 .attr('x', defaultConfig.titleX)283 .attr('y', defaultConfig.titleY)284 .attr('font-size', defaultConfig.titleFontSize || defaultConfig.defaultFontSize)285 .attr('font-family', defaultConfig.titleFontFamily || defaultConfig.defaultFontFamily)286 .attr('fill', defaultConfig.titleColor || defaultConfig.defaultColor)287 .text(defaultConfig.title);288 const legend = svg.append('g')289 .attr('class', '__legend')290 .attr('height', 100)291 .attr('width', 200)292 .attr('transform', `translate(0, ${defaultConfig.legendTop})`);293 legend.selectAll('rect')294 .data(_legend)295 .enter()296 .append('rect')297 .attr('x', defaultConfig.width + defaultConfig.extraWidthX - defaultConfig.legendRight)298 .attr('y', (d, i) => {299 return i * 20;300 })301 .attr('width', defaultConfig.legendSquareSize)302 .attr('height', defaultConfig.legendSquareSize)303 .style('fill', (d, i) => {304 return defaultConfig.color(i);305 });306 legend.selectAll('text')307 .data(_legend)308 .enter()309 .append('text')310 .attr('x', defaultConfig.width + defaultConfig.extraWidthX - defaultConfig.legendRight + 20)311 .attr('y', (d, i) => {312 return i * 20 + 9;313 })314 .attr('font-size', defaultConfig.legendFontSize || defaultConfig.defaultFontSize)315 .attr('font-family', defaultConfig.legendFontFamily || defaultConfig.defaultFontFamily)316 .attr('fill', defaultConfig.legendColor || defaultConfig.defaultColor)317 .text((d) => {318 return d;319 });320 }321};322/**323 * RadarGraph is an radar graph component.324 */325export default class RadarGraph extends Component {326 plot(props) {327 console.log('plot', this.props);328 const {id, config} = props;329 if (!config || !config.data || config.data.length === 0 || config.data[0].length === 0) {330 return;331 }332 if (config.maxValue) {333 config.maxValue /= 100;334 }335 if (config.color) {336 console.log(d3.scale.category10());337 console.log(config.color);338 339 const colours = config.color.map((v) => {340 return `rgba(${v[0]*255}, ${v[1]*255}, ${v[2]*255}, ${v[3]})`;341 });342 config.color = function(i) {343 return colours[i];344 };345 }346 const parsedData = config.data.map((v) => {347 return v.map((_v) => {348 _v.value /= 100;349 return _v;350 });351 });352 RadarChart.draw(`#${id}`, config.legend, parsedData, config);353 }354 componentDidMount() {355 console.log('componentDidMount', this.props);356 this.plot(this.props);357 }358 componentWillUnmount() {359 console.log('componentWillUnmount', this.props);360 if (this.eventEmitter) {361 this.eventEmitter.removeAllListeners();362 }363 }364 shouldComponentUpdate(nextProps) {365 console.log('shouldComponentUpdate', this.props);366 return (367 (this.props.id !== nextProps.id) || (JSON.stringify(this.props.style) !== JSON.stringify(nextProps.style))368 );369 }370 componentWillReceiveProps(nextProps) {371 console.log('componentWillReceiveProps', this.props);372 const idChanged = (this.props.id !== nextProps.id);373 if (idChanged) {374 /*375 * then the dom needs to get re-rendered with a new ID.376 * the graph will get updated in componentDidUpdate377 */378 return;379 }380 const configChanged = this.props.config !== nextProps.config;381 if (configChanged) {382 this.plot(nextProps);383 }384 }385 componentDidUpdate(prevProps) {386 console.log('componentDidUpdate', this.props);387 if (prevProps.id !== this.props.id) {388 this.plot(this.props);389 }390 }391 render() {392 console.log('render', this.props);393 const {id, style, className} = this.props;394 return (395 <div396 key={id}397 id={id}398 style={style}399 className={className}400 />401 );402 }403}404RadarGraph.propTypes = {405 /**406 * The ID used to identify this graph in Dash callbacks.407 */408 id: PropTypes.string.isRequired,409 /**410 * Generic style overrides on the plot div.411 */412 style: PropTypes.any,413 /**414 * className of the parent div.415 */416 className: PropTypes.string,417 /**418 * Graph configuration options.419 */420 config: PropTypes.shape({421 /**422 * A title that will be printed when this graph is rendered.423 */424 title: PropTypes.string,425 /**426 * The radar chart title's x position from the left427 */428 titleX: PropTypes.number,429 /**430 * The radar chart title's y position from the top431 */432 titleY: PropTypes.number,433 /**434 * The radar chart title's text font size435 */436 titleFontSize: PropTypes.string,437 /**438 * The radar chart title's text font family439 */440 titleFontFamily: PropTypes.string,441 /**442 * The radar chart title's text color443 */444 titleColor: PropTypes.string,445 /**446 * The radius of the nodes.447 */448 radius: PropTypes.number,449 /**450 * The width of the plot.451 */452 width: PropTypes.number,453 /**454 * The height of the plot.455 */456 height: PropTypes.number,457 /**458 * The factor459 */460 factor: PropTypes.number,461 /**462 * The factor legend463 */464 factorLegend: PropTypes.number,465 /**466 * The max % value on the radar graph axis e.g. 100 for 100%.467 */468 maxValue: PropTypes.number,469 /**470 * The radians471 */472 radians: PropTypes.number,473 /**474 * The to rightness475 */476 toRight: PropTypes.number,477 /**478 * The x translation479 */480 translateX: PropTypes.number,481 /**482 * The y translation483 */484 translateY: PropTypes.number,485 /**486 * The extra x width487 */488 extraWidthX: PropTypes.number,489 /**490 * The extra y width491 */492 extraWidthY: PropTypes.number,493 /**494 * The color array for the area plots495 */496 color: PropTypes.any,497 /**498 * The number of ticks on the radar graph axis.499 */500 levels: PropTypes.number,501 /**502 * The radar chart data503 */504 data: PropTypes.arrayOf(505 PropTypes.arrayOf(506 PropTypes.shape({507 axis: PropTypes.string.isRequired,508 value: PropTypes.number.isRequired509 })510 )511 ).isRequired,512 /**513 * The radar chart legend entries514 */515 legend: PropTypes.array,516 /**517 * The radar chart legend x position from the right of the plot518 */519 legendRight: PropTypes.number,520 /**521 * The radar chart legend y position from the top of the plot522 */523 legendTop: PropTypes.number,524 /**525 * The radar chart legend text font size526 */527 legendFontSize: PropTypes.string,528 /**529 * The radar chart legend text font family530 */531 legendFontFamily: PropTypes.string,532 /**533 * The radar chart legend text colour534 */535 legendColor: PropTypes.string,536 /**537 * The radar chart legend coloured squares size538 */539 legendSquareSize: PropTypes.number,540 /**541 * The radar chart levels stroke color542 */543 levelsStrokeColor: PropTypes.string,544 /**545 * The radar chart levels stroke opacity546 */547 levelsStrokeOpacity: PropTypes.number,548 /**549 * The radar chart levels stroke width550 */551 levelsStrokeWidth: PropTypes.number,552 /**553 * The radar chart axis text font family554 */555 axisTickFontFamily: PropTypes.string,556 /**557 * The radar chart axis text font size558 */559 axisTickFontSize: PropTypes.string,560 /**561 * The radar chart axis text colour562 */563 axisTickColor: PropTypes.string,564 /**565 * The radar chart axis label text font family566 */567 axisLabelFontFamily: PropTypes.string,568 /**569 * The radar chart axis label text font size570 */571 axisLabelFontSize: PropTypes.string,572 /**573 * The radar chart axis label text font colour574 */575 axisLabelColor: PropTypes.string,576 /**577 * The radar chart axis label text anchor position578 */579 axisLabelTextAnchor: PropTypes.string,580 /**581 * The radar chart axis stroke colour582 */583 axisStrokeColor: PropTypes.string,584 /**585 * The radar chart axis stroke width586 */587 axisStrokeWidth: PropTypes.numnber,588 /**589 * The radar chart tooltip text font family590 */591 tooltipFontFamily: PropTypes.string,592 /**593 * The radar chart tooltip text font size594 */595 tooltipFontSize: PropTypes.string,596 /**597 * The radar chart tooltip text colour598 */599 tooltipColor: PropTypes.string,600 /**601 * The radar chart areas' border widths602 */603 areaBorderWidth: PropTypes.string,604 /**605 * The radar chart areas' default opacity606 */607 areaOpacity: PropTypes.number,608 /**609 * A radar chart area's opacity when being hovered over610 */611 areaOpacityAreaHover: PropTypes.number,612 /**613 * The radar chart other areas' opacity when another area is being hovered over614 */615 areaOtherOpacityAreaHover: PropTypes.number,616 /**617 * A radar chart area's opacity when one of it's nodes is being hovered over618 */619 areaOpacityNodeHover: PropTypes.number,620 /**621 * The radar chart other areas' opacity when another a node from a different area is being hovered over622 */623 areaOtherOpacityNodeHover: PropTypes.number,624 /**625 * The radar chart nodes' default opacity626 */627 nodeOpacity: PropTypes.number628 }),629 /**630 * Dash-assigned callback that should be called whenever any of the631 * properties change.632 */633 setProps: PropTypes.func634};635RadarGraph.defaultProps = {636 config: {637 title: 'Demo Radar Graph',638 data: [639 [640 {641 axis: 'Demo Axis 1', 642 value: 10643 },644 {645 axis: 'Demo Axis 2', 646 value: 20647 },648 {649 axis: 'Demo Axis 3', 650 value: 40651 },652 {653 axis: 'Demo Axis 4', 654 value: 60655 },656 {657 axis: 'Demo Axis 5', 658 value: 90659 }660 ],661 [662 {663 axis: 'Demo Axis 1', 664 value: 80665 },666 {667 axis: 'Demo Axis 2', 668 value: 70669 },670 {671 axis: 'Demo Axis 3', 672 value: 60673 },674 {675 axis: 'Demo Axis 4', 676 value: 50677 },678 {679 axis: 'Demo Axis 5', 680 value: 40681 }682 ]683 ],684 legend: [685 'Demo Legend 1',686 'Demo Legend 2'687 ]688 }...

Full Screen

Full Screen

export-flags.js

Source:export-flags.js Github

copy

Full Screen

1/*!2* Contentstack Export3* Copyright (c) 2019 Contentstack LLC4* MIT Licensed5*/6let defaultConfig = require('../../config/default')7let message = require('../../../messages/index.json')8let {initial} = require('../../app')9let path = require('path')10const helper = require('../util/helper');11let _ = require('lodash')12const {cli} = require('cli-ux')13exports.configWithMToken = function (config, managementTokens, host, contentTypes, branchName, securedAssets) {14 let externalConfig = require(config)15 defaultConfig.securedAssets = securedAssets16 defaultConfig.management_token = managementTokens.token17 defaultConfig.host = host.cma18 defaultConfig.cdn = host.cda19 defaultConfig.branchName = branchName20 if (moduleName) {21 defaultConfig.moduleName = moduleName22 // Specfic content type setting is only for entries module23 if (24 moduleName === 'entries' &&25 Array.isArray(contentTypes) &&26 contentTypes.length > 027 ) {28 defaultConfig.contentTypes = contentTypes29 }30 }31 defaultConfig = _.merge(defaultConfig, externalConfig)32 initial(defaultConfig)33}34exports.parameterWithMToken = function (managementTokens, data, moduleName, host, _authToken, contentTypes, branchName, securedAssets) {35 defaultConfig.management_token = managementTokens.token36 defaultConfig.auth_token = _authToken37 defaultConfig.host = host.cma38 defaultConfig.cdn = host.cda39 defaultConfig.branchName = branchName40 defaultConfig.securedAssets = securedAssets41 if (moduleName) {42 defaultConfig.moduleName = moduleName43 // Specfic content type setting is only for entries module44 if (45 moduleName === 'entries' &&46 Array.isArray(contentTypes) &&47 contentTypes.length > 048 ) {49 defaultConfig.contentTypes = contentTypes50 }51 }52 defaultConfig.source_stack = managementTokens.apiKey53 defaultConfig.data = data54 initial(defaultConfig)55}56// using ManagementToken57exports.withoutParameterMToken = async (managementTokens, moduleName, host, _authToken, contentTypes, branchName, securedAssets) => {58 const stackUid = managementTokens.apiKey59 const pathOfExport = await cli.prompt(message.promptMessageList.promptPathStoredData)60 defaultConfig.management_token = managementTokens.token61 defaultConfig.host = host.cma62 defaultConfig.cdn = host.cda63 defaultConfig.branchName = branchName64 defaultConfig.auth_token = _authToken65 defaultConfig.securedAssets = securedAssets66 if (moduleName) {67 defaultConfig.moduleName = moduleName68 // Specfic content type setting is only for entries module69 if (70 moduleName === 'entries' &&71 Array.isArray(contentTypes) &&72 contentTypes.length > 073 ) {74 defaultConfig.contentTypes = contentTypes75 }76 }77 defaultConfig.source_stack = stackUid78 defaultConfig.data = pathOfExport79 initial(defaultConfig)80}81exports.configWithAuthToken = function (config, _authToken, moduleName, host, contentTypes, branchName, securedAssets) {82 let externalConfig = helper.readFile(path.resolve(config))83 defaultConfig.auth_token = _authToken84 defaultConfig.host = host.cma85 defaultConfig.cdn = host.cda86 defaultConfig.branchName = branchName87 defaultConfig.securedAssets = securedAssets88 if (moduleName) {89 defaultConfig.moduleName = moduleName90 // Specfic content type setting is only for entries module91 if (92 moduleName === 'entries' &&93 Array.isArray(contentTypes) &&94 contentTypes.length > 095 ) {96 defaultConfig.contentTypes = contentTypes97 }98 }99 defaultConfig = _.merge(defaultConfig, externalConfig)100 initial(defaultConfig)101}102exports.parametersWithAuthToken = function (_authToken, sourceStack, data, moduleName, host, contentTypes, branchName, securedAssets) {103 return new Promise(async(resolve, reject) => {104 defaultConfig.auth_token = _authToken105 defaultConfig.source_stack = sourceStack106 if (moduleName) {107 defaultConfig.moduleName = moduleName108 // Specfic content type setting is only for entries module109 if (110 moduleName === 'entries' &&111 Array.isArray(contentTypes) &&112 contentTypes.length > 0113 ) {114 defaultConfig.contentTypes = contentTypes115 }116 }117 defaultConfig.branchName = branchName118 defaultConfig.host = host.cma119 defaultConfig.cdn = host.cda120 defaultConfig.data = data121 defaultConfig.securedAssets = securedAssets122 var exportStart = initial(defaultConfig)123 exportStart.then(() => {124 return resolve()125 }).catch((error) => {126 return reject(error)127 })128 })129}130exports.withoutParametersWithAuthToken = async (_authToken, moduleName, host, contentTypes, branchName, securedAssets) => {131 const stackUid = await cli.prompt(message.promptMessageList.promptSourceStack)132 const pathOfExport = await cli.prompt(message.promptMessageList.promptPathStoredData)133 defaultConfig.auth_token = _authToken134 defaultConfig.source_stack = stackUid135 defaultConfig.securedAssets = securedAssets136 if (moduleName) {137 defaultConfig.moduleName = moduleName138 // Specfic content type setting is only for entries module139 if (140 moduleName === 'entries' &&141 Array.isArray(contentTypes) &&142 contentTypes.length > 0143 ) {144 defaultConfig.contentTypes = contentTypes145 }146 }147 defaultConfig.branchName = branchName148 defaultConfig.data = pathOfExport149 defaultConfig.host = host.cma150 defaultConfig.cdn = host.cda151 initial(defaultConfig)...

Full Screen

Full Screen

client.js

Source:client.js Github

copy

Full Screen

1// @flow2import { Axios } from 'axios';3import type { $AxiosXHRConfig, $AxiosXHRConfigBase, $AxiosXHR } from 'axios';4import RequestQueue from './requestQueue';5export default class GigwalkAxios extends Axios {6 defaults: {7 headers: {8 common: {9 Authorization: string10 }11 }12 };13 constructor(defaultConfig?: $AxiosXHRConfigBase<*> = {}) {14 let adapter;15 // Copied from axios/core/dispatchRequest.js16 if (typeof XMLHttpRequest !== 'undefined') {17 // For browsers use XHR adapter18 adapter = require('axios/lib/adapters/xhr'); // eslint-disable-line global-require19 } else if (typeof process !== 'undefined') {20 // For node use HTTP adapter21 adapter = require('axios/lib/adapters/http'); // eslint-disable-line global-require22 }23 const requestQueue = new RequestQueue(adapter);24 // FlowIssue - Can't suppress this error because it generates an error on line 0 of this file25 // See https://github.com/facebook/flow/issues/2167. Using destructuring on types26 // that implement an interface doesn't work with properties that are maybe types27 /*28 const config: $AxiosXHRConfigBase<*> = {29 baseURL: 'https://api.app.gigwalk.com',30 ...defaultConfig,31 // Use a custom adapter which adds the request to a RequestQueue32 adapter(requestConfig: $AxiosXHRConfig<any>): Promise<$AxiosXHR<any>> {33 return requestQueue.add(requestConfig);34 }35 };36 */37 const config: $AxiosXHRConfigBase<*> = {};38 config.baseURL = defaultConfig.baseURL ? defaultConfig.baseURL : 'https://api.app.gigwalk.com';39 config.adapter = (requestConfig: $AxiosXHRConfig<any>): Promise<$AxiosXHR<any>> => requestQueue.add(requestConfig);40 // Note: To pass type checking, manual assignment of maybe types is required. See above FlowIssue41 if (defaultConfig.auth) config.auth = defaultConfig.auth;42 if (defaultConfig.progress) config.progress = defaultConfig.progress;43 if (defaultConfig.maxContentLength) config.maxContentLength = defaultConfig.maxContentLength;44 if (defaultConfig.maxRedirects) config.maxRedirects = defaultConfig.maxRedirects;45 if (defaultConfig.headers) config.headers = defaultConfig.headers;46 if (defaultConfig.params) config.params = defaultConfig.params;47 if (defaultConfig.paramsSerializer) config.paramsSerializer = defaultConfig.paramsSerializer;48 if (defaultConfig.responseType) config.responseType = defaultConfig.responseType;49 if (defaultConfig.transformResponse) config.transformResponse = defaultConfig.transformResponse;50 if (defaultConfig.transformRequest) config.transformRequest = defaultConfig.transformRequest;51 if (defaultConfig.timeout) config.timeout = defaultConfig.timeout;52 if (defaultConfig.validateStatus) config.validateStatus = defaultConfig.validateStatus;53 if (defaultConfig.withCredentials) config.withCredentials = defaultConfig.withCredentials;54 if (defaultConfig.xsrfCookieName) config.xsrfCookieName = defaultConfig.xsrfCookieName;55 if (defaultConfig.xsrfHeaderName) config.xsrfHeaderName = defaultConfig.xsrfHeaderName;56 if (defaultConfig.httpAgent) config.httpAgent = defaultConfig.httpAgent;57 if (defaultConfig.httpsAgent) config.httpsAgent = defaultConfig.httpsAgent;58 super(config);59 }...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var istanbul = require('istanbul');2var instrumenter = new istanbul.Instrumenter();3var istanbul = require('istanbul');4var instrumenter = new istanbul.Instrumenter();5var defaultConfig = istanbul.config.loadFile();6instrumenter.instrumentSync('var x = 1;', 'test.js', defaultConfig);7var istanbul = require('istanbul');8var instrumenter = new istanbul.Instrumenter();9var defaultConfig = istanbul.config.loadFile();10instrumenter.instrumentSync('var x = 1;', 'test.js', defaultConfig);11var istanbul = require('istanbul');12var instrumenter = new istanbul.Instrumenter();13var defaultConfig = istanbul.config.loadFile();14instrumenter.instrumentSync('var x = 1;', 'test.js', defaultConfig);15var istanbul = require('istanbul');16var instrumenter = new istanbul.Instrumenter();17var defaultConfig = istanbul.config.loadFile();18instrumenter.instrumentSync('var x = 1;', 'test.js', defaultConfig);19var istanbul = require('istanbul');20var instrumenter = new istanbul.Instrumenter();21var defaultConfig = istanbul.config.loadFile();22instrumenter.instrumentSync('var x = 1;', 'test.js', defaultConfig);23var istanbul = require('istanbul');24var instrumenter = new istanbul.Instrumenter();25var defaultConfig = istanbul.config.loadFile();26instrumenter.instrumentSync('var x = 1;', 'test.js', defaultConfig);27var istanbul = require('istanbul');28var instrumenter = new istanbul.Instrumenter();29var defaultConfig = istanbul.config.loadFile();30instrumenter.instrumentSync('var x = 1;',

Full Screen

Using AI Code Generation

copy

Full Screen

1var istanbul = require('istanbul');2var collector = new istanbul.Collector();3var reporter = new istanbul.Reporter();4collector.add(__dirname + '/coverage/coverage.json');5if (sync) {6 reporter.write(collector, true, function () { console.log('done'); });7} else {8 reporter.write(collector, true, function () { console.log('done'); });9}

Full Screen

Using AI Code Generation

copy

Full Screen

1var istanbul = require('istanbul');2var config = istanbul.config.loadFile('config.json');3var api = istanbul.api;4var defaultConfig = api.getDefaultConfig();5var collector = new istanbul.Collector();6var reporter = new istanbul.Reporter();7reporter.addAll([ 'text', 'lcov' ]);8collector.add(defaultConfig.instrumenter.getFinalCoverage());9reporter.write(collector, true, function () {10 console.log('All reports generated');11});12{13 "instrumenter": {14 "config": {15 }16 }17}18{19 "instrumenter": {20 "config": {21 }22 }23}24var istanbul = require('istanbul');25var config = istanbul.config.loadFile('config.json');26var api = istanbul.api;27var defaultConfig = api.getDefaultConfig();28var collector = new istanbul.Collector();29var reporter = new istanbul.Reporter();30reporter.addAll([ 'text', 'lcov' ]);31collector.add(defaultConfig.instrumenter.getFinalCoverage());32reporter.write(collector, true, function () {33 console.log('All reports generated');34});35var istanbul = require('istanbul');36var config = istanbul.config.loadFile('config.json');37var api = istanbul.api;38var defaultConfig = api.getDefaultConfig();

Full Screen

Using AI Code Generation

copy

Full Screen

1var istanbulApi = require('istanbul-api');2var defaultConfig = istanbulApi.getDefaultConfig();3defaultConfig.reporting.dir = 'myCoverageFolder';4istanbulApi.writeReports(defaultConfig, {});5var istanbulCoverage = require('istanbul-lib-coverage');6var map = istanbulCoverage.createCoverageMap({});7#### `getDefaultConfig()`8Returns an [istanbul-lib-coverage](

Full Screen

Using AI Code Generation

copy

Full Screen

1var istanbulMiddleware = require('istanbul-middleware');2istanbulMiddleware.defaultConfig();3{4 rootDirectory: process.cwd()5}6istanbulMiddleware.configure({7 rootDirectory: process.cwd()8});9istanbulMiddleware.middleware(app);10istanbulMiddleware.coverageHandler(app);11istanbulMiddleware.createHandler({12 rootDirectory: process.cwd()13});14[MIT](LICENSE)

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run istanbul automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful