How to use generatePlist method in Cypress

Best JavaScript code snippet using cypress

FileUtils.js

Source:FileUtils.js Github

copy

Full Screen

...8    path = require('path');9const { BaseConfig, ServerConfig } = require('./config');10const { gen_plist } = require('./plist');11const { printLog } = require('./utils');12async function generatePlist(filePath,fileName,ipa_download_url){13    let packageName,version,appName='';14    return new Promise((resolve,reject) =>{15        let temp_fileName = fileName;16        if(temp_fileName.includes('.ipa')){17            temp_fileName = temp_fileName.replace('.ipa','')+'.plist';//去掉.ipa 后缀名,加上.plist后缀名18        }else{19            temp_fileName = temp_fileName+'.plist';20        }21        if(checkFile(filePath,temp_fileName)){22            resolve({23                fileName:temp_fileName 24            });25        }26        const parser = new AppInfoParser(path.join(filePath,fileName)) // or xxx.ipa27        parser.parse().then(result => {28                // console.log('app info ----> ', result)29                packageName = result.CFBundleIdentifier||'';30                version = result.CFBundleShortVersionString||'';31                appName = result.CFBundleName||'';32                if(fileName.includes('.ipa')){33                    fileName = fileName.replace('.ipa','')+'.plist';//去掉.ipa 后缀名,加上.plist后缀名34                }else{35                    fileName = fileName+'.plist';36                }37                if(checkFile(filePath,fileName)){38                    resolve({39                        fileName:fileName 40                    });41                }else{42                    if(packageName==''||version==""||appName==''){43                        console.log(`${fileName} gen plist is err ----> ,packageName || version || appName is null `);44                        resolve(-1);45                    }46                    let opt = {47                        url:ipa_download_url,48                        packageName : packageName,49                        version:version,50                        appName:appName51                    }52                    fs.writeFile(path.join(filePath,fileName),gen_plist(opt),'utf8',async function(error){53                        if(error){54                            console.log(`生成${fileName}文件失败, err:${error}`);55                            resolve(-1);56                        }57                        resolve( {58                            fileName:fileName59                        });60                    })61                }62            }).catch(err => {63                console.log(`${fileName} gen plist is err ----> ,${err} `);64                resolve(-1);65        })66        // console.log(fileName);67        // resolve({68        //     fileName:fileName69        // });70    });71}72async function generateFileTree(){73    let filePath = getFilesListPath();74    if(!filePath){75        console.log('获取文件目录失败,请检查BaseConfig配置');76        return -1;77    }78    let basePath = path.dirname(filePath);79    let fileName = path.basename(filePath);80    let obj = await fileTree(basePath,fileName,fileName);81    // console.log(JSON.stringify(obj));82    return obj;83}84async function fileTree(basepath,fileName,relativePath){85    let filePath = path.join(basepath,fileName);86    let files;87    try{88        files = fs.readdirSync(filePath);89    }catch(e){90        console.log(`读取目录路径: ${filePath} 失败`);91        return -1;92    }93    let children_nodes = [];94    if(files.length){95        files.sort(function(a, b) {96            let stats_a = fs.statSync(path.join(filePath,a));97            let stats_b = fs.statSync(path.join(filePath,b))98            if(stats_a.isFile() && !stats_b.isFile()){99                return -1;100            }else if(stats_b.isFile() && !stats_a.isFile()){101                return 0;102            }else if(stats_b.isFile() && stats_a.isFile()){103                return stats_b.ctime.getTime() - stats_a.ctime.getTime();104            }else{105                return stats_a.ctime.getTime() - stats_b.ctime.getTime();106            }107        });108        for(let file of files){109            let child_file_path = path.join(filePath,file);110            let stats = fs.statSync(child_file_path);111            let p =  path.join(relativePath,file);112            if(stats.isDirectory()){113                let obj = await fileTree(filePath,file,p);114                children_nodes.push(obj);115            }else{116                let file_download_path ='';117                let origin_file_download_path = BaseConfig.isUseNginx?  getBaseUrl() + '/' +url.format(path.join(relativePath,file)) :getBaseUrl() + '/list/download?filename='+ url.format(path.join(relativePath,file));118                if(file.includes('.ipa')){119                    let ipa_base_url = getBaseUrl();120                    if(!ipa_base_url.includes('https')){121                        file_download_path='';122                    }else{123                        let ipa_download_url = BaseConfig.isUseNginx?ipa_base_url+'/'+url.format(path.join(relativePath,file)) : ipa_base_url+'/list/download?filename='+url.format(path.join(relativePath,file));124                        let plist_obj = await generatePlist(filePath,file,ipa_download_url);125                        if(plist_obj==-1){126                            file_download_path='';127                        }else{128                            file_download_path = BaseConfig.isUseNginx? 129                            'itms-services://?action=download-manifest&url='+ipa_base_url+'/'+url.format(path.join(relativePath,plist_obj.fileName)) :130                            'itms-services://?action=download-manifest&url='+ipa_base_url+'/list/download?filename='+url.format(path.join(relativePath,plist_obj.fileName));131                        }132                    }133                }else{134                    let apk_base_url ='';135                    apk_base_url = getBaseUrl();136                    file_download_path = BaseConfig.isUseNginx? apk_base_url + '/' +url.format(path.join(relativePath,file)) :apk_base_url + '/list/download?filename='+ url.format(path.join(relativePath,file));137                }138                children_nodes.push(139                    {140                        name:file,141                        toggled:false,142                        download_path:origin_file_download_path,143                        urlPath:file_download_path,144                        relativePath:path.join(relativePath,file),145                        createTime:dateFormat(stats.mtimeMs),146                        size:getfilesize(stats.size),147                    }148                );149            }150        }151        // files.map(async file =>{152        // });153        return {154            name:fileName,155            toggled:false,156            urlPath:relativePath==fileName?'':relativePath,157            relativePath:relativePath==fileName?'':relativePath,158            children:children_nodes,159        }160    }else{161        return {162            name:fileName,163            toggled:false,164            relativePath:relativePath==fileName?'':relativePath,165            urlPath:relativePath==fileName?'':relativePath,166            children:children_nodes,167        }168    }169}170function getBaseUrl(){171    if(BaseConfig.protocol && BaseConfig.domain && BaseConfig.port){172        return BaseConfig.protocol+'://'+BaseConfig.domain+':'+BaseConfig.port173    }else{174        return 'http://'+getIP()+':'+ServerConfig.server_port;175    }176}177function getFilesListPath(){178    return BaseConfig.filePath!='' && BaseConfig.filePath!=void 0 ? BaseConfig.filePath : path.join(__dirname,'..','testFile');179}180function getIP(){181    return ip.address();182}183function checkFile(filePath,target_fileName){184    let files = fs.readdirSync(filePath);185    for(file of files){186      let stat = fs.statSync(path.join(filePath,file));187      if(file==target_fileName && stat.isFile){188        return true;189      }190    }191    return false;192}193function i_wait(time){194    return new Promise((resolve,reject) =>{195        setTimeout(()=>{196            resolve('1');197        },time);198    });199}200function dateFormat(timeMs){201	moment.locale('zh-cn');202	var formDate = moment(timeMs).format('YYYY-MM-DD HH:mm:ss');203	return formDate;204}205function getfilesize(size) {206    if (!size)207        return "";208    var num = 1024.00; //byte209    if (size < num)210        return size + "B";211    if (size < Math.pow(num, 2))212        return (size / num).toFixed(2) + "K"; //kb213    if (size < Math.pow(num, 3))214        return (size / Math.pow(num, 2)).toFixed(2) + "M"; //M215    if (size < Math.pow(num, 4))216        return (size / Math.pow(num, 3)).toFixed(2) + "G"; //G217    return (size / Math.pow(num, 4)).toFixed(2) + "T"; //T218}219// (async() =>{220//     // let f_path = path.join(__dirname,'..','files');221//     // let arr =[1];222//     // arr.map(async item =>{223//     //     let obj = await generatePlist(f_path,'usedcar4s.ipa','itms-services://?action=download-manifest&url=');224//     //     console.log(obj);225//     //     console.log('------');226//     // });227//     let obj = await generateFileTree();228//     console.log(obj);229// })();230// obj.then(data =>{231//     console.log(data);232// });233// generateFileTree();234// console.log(getBaseUrl());235// console.log(getIP());236module.exports ={237    generateFileTree,...

Full Screen

Full Screen

exportMcToCocosCreator.jsfl

Source:exportMcToCocosCreator.jsfl Github

copy

Full Screen

...102		bitDepth: 32,103		backgroundColor: "#00000000"104	};105	c.exportSpriteSheet(a, d, true);106	funcs.generatePlist(a, e, e, c.sheetWidth, c.sheetHeight, true, true);107	return true108};109funcs.exportEveryFrame = function (g, e, n) {110	var o = funcs.mulPngAnimXml_beginExport();111	var b = g.libraryItem.timeline.frameCount;112	for (var h = 0; h < b; h++) {113		var a = new SpriteSheetExporter();114		a.addSymbol(g, "", h, h + 1);115		funcs.setSpriteSheetExporter(a);116		if (a.overflowed) {117			var k = "Error: frame " + (h + 1) + " of '" + n + "' exceeds the texture size limit of " + a.maxSheetWidth + "x" + a.maxSheetHeight + " cancelled";118			fl.trace(k);119			alert(k);120			return false121		}122	}123	for (var h = 0; h < b; h++) {124		var l = h + "";125		if (l.length < 4) {126			const m = 4 - l.length;127			for (var d = 0; d < m; d++) {128				l = "0" + l129			}130		}131		const c = e + "/" + n + l;132		funcs.deleteOldFile(c);133		var a = new SpriteSheetExporter();134		a.addSymbol(g, "", h, h + 1);135		funcs.setSpriteSheetExporter(a);136		var f = {137			format: "png",138			bitDepth: 32,139			backgroundColor: "#00000000"140		};141		a.exportSpriteSheet(c, f, true);142		funcs.generatePlist(c, n + l, n, a.sheetWidth, a.sheetHeight, true, false);143		o += funcs.mulPngAnimXml_frameExport(n + l)144	}145	o += funcs.mulPngAnimXml_EndExport();146	FLfile.write(e + "/" + n + ".multipleImageAnim", o);147	return true148};149funcs.mulPngAnimXml_beginExport = function () {150	var a = '<?xml version="1.0" encoding="utf-8"?>\n';151	a += "<root>\n";152	return a153};154funcs.mulPngAnimXml_frameExport = function (a) {155	var b = "\t<name>" + a + "</name>\n";156	return b...

Full Screen

Full Screen

webServer.js

Source:webServer.js Github

copy

Full Screen

...134  let stats = fs.statSync(path.join(filesDir,file));135  if(file.includes('ipa')){136    if(getBaseUrl().includes('https')){137      if(BaseConfig.isUseNginx){138        let obj = await generatePlist(filesDir,file,getBaseUrl()+'/'+url.format(path.join(nginx_download_relative_path,file)));139        if(obj==-1){140          return {fileName:''};141        }142        return {143          fileName:file,144          qrCodeUrl:'itms-services://?action=download-manifest&url='+getBaseUrl()+'/'+url.format(path.join(nginx_download_relative_path,obj.fileName)),145          createTime:dateFormat(stats.mtimeMs)146        }147      }else{148        let obj = await generatePlist(filesDir,file,getBaseUrl()+'/download?filename='+file);149        if(obj==-1){150          return {fileName:''};151        }152        console.log(obj);153        return {154          fileName:file,155          qrCodeUrl:'itms-services://?action=download-manifest&url='+getBaseUrl()+'/download?filename='+obj.fileName,156          createTime:dateFormat(stats.mtimeMs)157        }158      }159    }160    return {161      fileName:'未配置https,无法提供ipa文件下载',162      qrCodeUrl:'https://www.baidu.com',...

Full Screen

Full Screen

pack.ios.js

Source:pack.ios.js Github

copy

Full Screen

...46                    title: task.project.name,47                },48            }],49        };50        await generatePlist(manifestJson);51        logger.log('info', 'Generate manifest.plist success');52        const uploadPlistData = await upload(config.server.upload, 'manifest.plist', 'text/xml');53        logger.log('info', 'Upload manifest.plist success');54        task.targetUrl = uploadPlistData.url;55        await task.save();56        logger.log('info', 'Save manifest.plist to database success');57        process.chdir('..');58        task.status.code = 'success';59        await task.save();60        logger.log('info', 'Save task.status.code = "success" to database success');61        if (task.release) {62            // TODO 此处没有考虑android或者其他更改63            const lastReleaseIos = {64                taskId: task.id,...

Full Screen

Full Screen

build.js

Source:build.js Github

copy

Full Screen

1const FS = require('fs')2const XMLBUILDER = require('xmlbuilder')3const PLIST = require('plist')4const GLYPHNAMES = require('smufl/metadata/glyphnames.json')5const RANGES = require('smufl/metadata/ranges.json')6const GLYPH2RANGEMAP = Object.values(RANGES).reduce((map, range) => {7  range.glyphs.forEach(glyph => { map[glyph] = range.description })8  return map9}, {})10const ATTLIST = [11  { att: 'unicode' },12  { att: 'unicodeLegecy' },13  { att: 'name', req: true },14  { att: 'sortName' },15  { att: 'sortNameKeep' },16  { att: 'category', req: true },17  { att: 'subCategory' },18  { att: 'script' },19  { att: 'description' },20  { att: 'production' },21  { att: 'altNames' },22  { att: 'decompose' },23  { att: 'anchors' },24  { att: 'accents' }25]26/**27 * Main function generating GlyphData.xml28 * @return {String} An XML string29 */30function generateGlyphData () {31  let xml = XMLBUILDER.create(32    'glyphData',33    { version: '1.0', encoding: 'UTF-8' }34  )35  let dtd = xml.dtd()36    .ele('glyphData', '(glyph)+')37    .ele('glyph', 'EMPTY')38  ATTLIST.forEach(item => {39    dtd.att('glyph', item.att, 'CDATA', item.req ? '#REQUIRED' : '#IMPLIED')40  })41  for (let name in GLYPHNAMES) {42    let glyph = GLYPHNAMES[name]43    let codepoint = glyph.codepoint.replace('U+', '')44    xml.ele('glyph', {45      name: name,46      sortName: `SMuFL.${name}`,47      description: glyph.description.toUpperCase(),48      category: 'SMuFL',49      subCategory: GLYPH2RANGEMAP[name],50      unicode: codepoint,51      production: `uni${codepoint}`,52      script: 'musical'53    })54  }55  return xml.end({ pretty: true })56}57/**58 * Main function generating Groups.plist59 * @return {String} An XML string following the PropertyList DTD60 */61function generatePList () {62  let subGroups = Object.keys(RANGES).map(key => {63    let range = RANGES[key]64    return {65      name: range.description,66      coverage: range.glyphs67    }68  })69  let plist = {70    categories: [71      {72        name: 'SMuFL',73        icon: 'MusicTemplate',74        subGroup: subGroups75      }76    ]77  }78  return PLIST.build(plist)79}80FS.writeFile('dist/GlyphData.xml', generateGlyphData(), err => {81  if (err) {82    console.error(err)83  } else {84    console.log('Saved GlyphData.xml to disk')85  }86})87FS.writeFile('dist/Groups.plist', generatePList(), err => {88  if (err) {89    console.error(err)90  } else {91    console.log('Saved Groups.plist to disk')92  }...

Full Screen

Full Screen

plist.js

Source:plist.js Github

copy

Full Screen

1const pre = `<?xml version="1.0" encoding="UTF-8"?>2<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">3<!-- Generated by: Themeweaver                         -->4<!-- ============================================      -->5<!-- app:  http://themeweaver.dev                      -->6<!-- code: https://github.com/dbanksdesign/themeweaver -->7<plist version="1.0">\n`;8const post = `\n</plist>`;9const generatePlistRecursive = (obj, indent = `\t`) => {10	const newIndent = indent + `\t`;11	12	switch (Object.prototype.toString.call(obj)) {13		case '[object Array]':14			return `${indent}<array>\n` +15					obj.map(val => generatePlistRecursive(val, newIndent))16						.join('\n') +17					`${indent}</array>`;18		case '[object Object]':19			return `${indent}<dict>\n` +20					Object.keys(obj).map(key => {21					const val = obj[key];22					return `${newIndent}<key>${key}</key>\n${generatePlistRecursive(val, newIndent)}`;23				}).join('\n') +24				`\n${indent}</dict>`;25		default:26			return `${indent}<string>${obj}</string>`;27	}28}29const generatePlist = (obj) => {30	return pre + generatePlistRecursive(obj) + post;31}...

Full Screen

Full Screen

createTmPlist.js

Source:createTmPlist.js Github

copy

Full Screen

...14		lineHighlight: allTokens[`application.editor.lineHighlightBackground`].computedValue,15		selection: allTokens[`application.editor.selectionBackground`].computedValue,16	}17	18	return generatePlist({19		name: name,20		settings: [settings].concat(tmTokens),21		// uuid: ``,22		colorSpaceName: `sRGB`,23		// semanticClass: ``24	});25}...

Full Screen

Full Screen

index.js

Source:index.js Github

copy

Full Screen

1import archive from './archive/index';2import ipa from './ipa/index';3import svn from './svn/index';4import changeInfoPlist from './changeInfoPlist/index';5import upload from './upload/index';6import imp from './installMobileProvision/index';7import generatePlist from './generatePlist/index';8import Logger from './logger/index';9import updateProject from './updateProject/index';10import fileExist from './fileExist/index';11import getPlistValue from './getPlistValue/index';12export {13    svn,14    archive,15    ipa,16    changeInfoPlist,17    upload,18    imp,19    generatePlist,20    Logger,21    updateProject,22    fileExist,23    getPlistValue,...

Full Screen

Full Screen

Cypress Tutorial

Cypress is a renowned Javascript-based open-source, easy-to-use end-to-end testing framework primarily used for testing web applications. Cypress is a relatively new player in the automation testing space and has been gaining much traction lately, as evidenced by the number of Forks (2.7K) and Stars (42.1K) for the project. LambdaTest’s Cypress Tutorial covers step-by-step guides that will help you learn from the basics till you run automation tests on LambdaTest.

Chapters:

  1. What is Cypress? -
  2. Why Cypress? - Learn why Cypress might be a good choice for testing your web applications.
  3. Features of Cypress Testing - Learn about features that make Cypress a powerful and flexible tool for testing web applications.
  4. Cypress Drawbacks - Although Cypress has many strengths, it has a few limitations that you should be aware of.
  5. Cypress Architecture - Learn more about Cypress architecture and how it is designed to be run directly in the browser, i.e., it does not have any additional servers.
  6. Browsers Supported by Cypress - Cypress is built on top of the Electron browser, supporting all modern web browsers. Learn browsers that support Cypress.
  7. Selenium vs Cypress: A Detailed Comparison - Compare and explore some key differences in terms of their design and features.
  8. Cypress Learning: Best Practices - Take a deep dive into some of the best practices you should use to avoid anti-patterns in your automation tests.
  9. How To Run Cypress Tests on LambdaTest? - Set up a LambdaTest account, and now you are all set to learn how to run Cypress tests.

Certification

You can elevate your expertise with end-to-end testing using the Cypress automation framework and stay one step ahead in your career by earning a Cypress certification. Check out our Cypress 101 Certification.

YouTube

Watch this 3 hours of complete tutorial to learn the basics of Cypress and various Cypress commands with the Cypress testing at LambdaTest.

Run Cypress 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