How to use versions.text method in Puppeteer

Best JavaScript code snippet using puppeteer

push_to_bintray_modal.js

Source:push_to_bintray_modal.js Github

copy

Full Screen

1import TOOLTIP from '../../constants/artifact_tooltip.constant';2export class PushToBintrayModal {3 constructor($stateParams, $rootScope, $q, ArtifactoryModal, PushToBintrayDao, ArtifactoryNotifications) {4 this.ArtifactoryNotifications = ArtifactoryNotifications;5 this.$rootScope = $rootScope;6 this.$stateParams = $stateParams;7 this.$q = $q;8 this.modal = ArtifactoryModal;9 this.ptbDao = PushToBintrayDao;10 }11 _getBuildBintrayRepositories() {12 this.ptbDao.getBuildRepos().$promise.then((data) => {13 this.modalScope.data.bintrayRepos = _.map(data.binTrayRepositories,(repo) => {return {text:repo ,value: repo}});14 })15 .catch((err) => {16 if (err.data && err.data.feedbackMsg && err.data.feedbackMsg.error) {17 let msg = err.data.feedbackMsg.error;18 this.ArtifactoryNotifications.create({error: msg});19 }20 });21 }22 _getBuildBintrayPackages() {23 this.ptbDao.getBuildPacks({key: this.modalScope.selection.bintrayRepo}).$promise.then((data) => {24 data.binTrayPackages = _.filter(data.binTrayPackages,(pack) => {return pack!=='_'});25 this.modalScope.data.bintrayPackages = _.map(data.binTrayPackages,(pack) => {return {text:pack ,value: pack}});26 if (data.binTrayPackages && data.binTrayPackages.length) {27 if (!this.modalScope.selection.bintrayPackageName) this.modalScope.selection.bintrayPackageName = data.binTrayPackages[0];28 }29 if (this.modalScope.selection.bintrayPackageName) {30 this._getBuildBintrayVersions();31 }32 else {33 this.modalScope.data.bintrayPackageVersions = [{text:'1.0' ,value: '1.0'}];34 this.modalScope.selection.bintrayPackageVersion = '1.0';35 }36 });37 }38 _getBuildBintrayVersions() {39 this.ptbDao.getBuildVersions({40 key: this.modalScope.selection.bintrayRepo,41 id: this.modalScope.selection.bintrayPackageName42 }).$promise.then((data) => {43 this.modalScope.data.bintrayPackageVersions = _.map(data.binTrayVersions,(ver) => {return {text:ver ,value: ver}});44 if (data.binTrayVersions && data.binTrayVersions.length && !this.modalScope.selection.bintrayPackageVersion) {45 this.modalScope.selection.bintrayPackageVersion = data.binTrayVersions[0];46 }47 })48 .catch(()=>{49 this.modalScope.data.bintrayPackageVersions = [{text:'1.0' ,value: '1.0'}];50 this.modalScope.selection.bintrayPackageVersion = '1.0';51 })52 }53 _pushBuildToBintray(backgroundPush) {54 let payload = {55 buildName: this.$stateParams.buildName,56 buildNumber: this.$stateParams.buildNumber,57 buildTime: this.$stateParams.startTime,58 bintrayParams: {59 useExistingProps: this.modalScope.selection.useSpecificProperties,60 notify: this.modalScope.selection.sendEmail,61 repo: this.modalScope.selection.bintrayRepo,62 packageId: this.modalScope.selection.bintrayPackageName,63 version: this.modalScope.selection.bintrayPackageVersion64 }65 };66 this.ptbDao.pushBuildToBintray({background: backgroundPush}, payload).$promise.then((response)=> {67 this.createPushToBintrayResponse(response);68 }).finally(() => this.modalInstance.close());69 }70 _pushArtifactToBintray() {71 let payload = {72 bintrayParams: this.bintrayParams73 };74 payload.bintrayParams.repo = this.modalScope.selection.bintrayRepo;75 payload.bintrayParams.packageId = this.modalScope.selection.bintrayPackageName;76 payload.bintrayParams.version = this.modalScope.selection.bintrayPackageVersion;77 payload.bintrayParams.path = this.modalScope.selection.filePath;78 this.ptbDao.pushArtifactToBintray({79 repoKey: this.params.repoKey,80 path: this.params.path81 }, payload).$promise.then((response)=> {82 this.createPushToBintrayResponse(response);83 }).finally(() => this.modalInstance.close());84 }85 _getArtifactBintrayData() {86 this.ptbDao.getArtifactData({repoKey: this.params.repoKey, path: this.params.path}).$promise.then((data) => {87 this.bintrayParams = data.bintrayParams;88 this.modalScope.selection.bintrayRepo = data.bintrayParams.repo;89 this.modalScope.selection.bintrayPackageName = data.bintrayParams.packageId;90 this.modalScope.selection.filePath = data.bintrayParams.path;91 this.modalScope.selection.bintrayPackageVersion = data.bintrayParams.version;92 this.modalScope.data.bintrayRepos = _.map(data.binTrayRepositories, (repo) => {93 return {text: repo, value: repo}94 });//data.binTrayRepositories;95 if (data.bintrayParams.packageId) this.modalScope.data.bintrayPackages = [data.bintrayParams.packageId];96 if (data.bintrayParams.version) this.modalScope.data.bintrayPackageVersions = [{97 text: data.bintrayParams.version,98 value: data.bintrayParams.version99 }];100 if (this.modalScope.selection.bintrayRepo) this._getBuildBintrayPackages();101 })102 .catch((err) => {103 if (err.data && err.data.feedbackMsg && err.data.feedbackMsg.error) {104 let msg = err.data.feedbackMsg.error;105 this.ArtifactoryNotifications.create({error: msg});106 }107 });108 }109 launchModal(type, params) {110 let deferred = this.$q.defer();111 this.modalScope = this.$rootScope.$new();112 this.modalScope.selection = {};113 this.modalScope.data = {};114 this.modalScope.tooltip = TOOLTIP.artifacts.pushToBintray;115 this.modalScope.cancel = () => {116 this.modalInstance.close();117 deferred.reject();118 };119 this.modalScope.onRepoSelect = () => {120 this._getBuildBintrayPackages();121 };122 this.modalScope.onPackageSelect = () => {123 this._getBuildBintrayVersions();124 };125 this.modalScope.selectizeConfig = {126 sortField: 'number',127 create: true,128 maxItems: 1129 };130 this.modalScope.pushType = type;131 if (type === 'build') {132 this.modalScope.push = () => {133 this._pushBuildToBintray(false);134 };135 this.modalScope.backgroundPush = () => {136 this._pushBuildToBintray(true);137 };138 this._getBuildBintrayRepositories();139 }140 else if (type === 'artifact') {141 this.modalScope.push = () => {142 this._pushArtifactToBintray(false);143 };144 let repoPath = params.repoPath;145 let arr = repoPath.split(':');146 let repoKey = arr[0];147 let path = arr[1];148 this.params = {repoKey: repoKey, path: path};149 this._getArtifactBintrayData();150 }151 this.modalInstance = this.modal.launchModal("push_to_bintray", this.modalScope);152 return deferred.promise;153 }154 createPushToBintrayResponse(response) {155 if (response.data.error) {156 this.createPushToBintrayErrorResponse(response.data);157 return;158 }159 let artifactBintrayUrl = response.data.url;160 if (artifactBintrayUrl) {161 this.ArtifactoryNotifications.createMessageWithHtml({162 type: 'success',163 body: `${response.data.info} <a href="${artifactBintrayUrl}" target="_blank">${artifactBintrayUrl}</a>`164 });165 }166 }167 createPushToBintrayErrorResponse(response) {168 if (response.error) {169 this.ArtifactoryNotifications.create(response);170 }171 }...

Full Screen

Full Screen

index.test.js

Source:index.test.js Github

copy

Full Screen

1const compareText = require('./index.js');2describe('Diff - same sentence', () => {3 // same text - expecting wer == 0, and delete == 04 const optionsSame = {5 baseText: 'Call me Ishmael. Some years ago—never mind how long', 6 baseName: 'original text',7 // // can compare base text against multiple versions8 textToCompare : [9 {10 hypothesisText: 'Call me Ishmael. Some years ago—never mind how long',11 hypothesisName: 'HP title'12 }13 ]14 };15 let diff = compareText(optionsSame);16 test('matched', () => {17 // 9 words in sample sentence18 expect(diff[0].stats.matches).toBe(9);19 })20 test('deleted', () => {21 expect(diff[0].stats.deleted).toBe(0);22 })23 test('inserted', () => {24 expect(diff[0].stats.inserted).toBe(0);25 })26 test('substitutions', () => {27 expect(diff[0].stats.substitutions).toBe(0);28 })29})30describe('Diff - one extra word in hypothesis text ', () => {31 // same text - expecting wer == 0, and delete == 032 const optionsOneExtra = {33 baseText: 'Call me Ishmael. Some years ago—never mind how long', 34 baseName: 'original text',35 // // can compare base text against multiple versions36 textToCompare : [37 {38 hypothesisText: 'Call me Ishmael. Some EXTRAWORD years ago—never mind how long',39 hypothesisName: 'HP title'40 }41 ]42 };43 let diff = compareText(optionsOneExtra);44 test('matches', () => {45 expect(diff[0].stats.matches).toBe(9);46 })47 xtest('substitutions', () => {48 expect(diff[0].stats.substitutions).toBe(0);49 })50 test('deleted', () => {51 expect(diff[0].stats.deleted).toBe(0);52 })53 test('inserted', () => {54 expect(diff[0].stats.inserted).toBe(1);55 })56})57describe('Diff - one delete word in hypothesis ', () => {58 // same text - expecting wer == 0, and delete == 059 const optionsOneExtra = {60 baseText: 'Call me Ishmael. Some years ago—never mind how long', 61 baseName: 'original text',62 // // can compare base text against multiple versions63 textToCompare : [64 {65 hypothesisText: 'Call me Ishmael. years ago—never mind how long',66 hypothesisName: 'HP title'67 }68 ]69 };70 let diff = compareText(optionsOneExtra);71 test('matches', () => {72 expect(diff[0].stats.matches).toBe(8);73 })74 xtest('substitutions', () => {75 expect(diff[0].stats.substitutions).toBe(0);76 })77 test('deleted', () => {78 expect(diff[0].stats.deleted).toBe(1);79 })80 test('inserted', () => {81 expect(diff[0].stats.inserted).toBe(0);82 })83})84describe('Diff - one substituion word in hypothesis ', () => {85 // same text - expecting wer == 0, and delete == 086 const optionsOneExtra = {87 baseText: 'Call me Ishmael. Some years ago—never mind how long', 88 baseName: 'original text',89 // // can compare base text against multiple versions90 textToCompare : [91 {92 hypothesisText: 'Call me Ishmael. MANY years ago—never mind how long',93 hypothesisName: 'HP title'94 }95 ]96 };97 let diff = compareText(optionsOneExtra);98 test('matches', () => {99 expect(diff[0].stats.matches).toBe(8);100 })101 xtest('substitutions', () => {102 expect(diff[0].stats.substitutions).toBe(1);103 })104 test('deleted', () => {105 expect(diff[0].stats.deleted).toBe(0);106 })107 test('inserted', () => {108 expect(diff[0].stats.inserted).toBe(0);109 })110})111describe('Diff - two substituion and one deletion in hypothesis ', () => {112 // same text - expecting wer == 0, and delete == 0113 const optionsOneExtra = {114 baseText: 'Call me Ishmael. Some years ago—never mind how long', 115 baseName: 'original text',116 // // can compare base text against multiple versions117 textToCompare : [118 {119 hypothesisText: 'Call me Ishmael. MANY GEARS mind how long',120 hypothesisName: 'HP title'121 }122 ]123 };124 let diff = compareText(optionsOneExtra);125 test('matches', () => {126 expect(diff[0].stats.matches).toBe(6);127 })128 test('substitutions', () => {129 expect(diff[0].stats.substitutions).toBe(2);130 })131 test('deleted', () => {132 expect(diff[0].stats.deleted).toBe(1);133 })134 test('inserted', () => {135 expect(diff[0].stats.inserted).toBe(0);136 })137})138describe('Diff - one substituion and two deletion in hypothesis ', () => {139 // same text - expecting wer == 0, and delete == 0140 const optionsOneExtra = {141 baseText: 'Call me Ishmael. Some years ago—never mind how long', 142 baseName: 'original text',143 // // can compare base text against multiple versions144 textToCompare : [145 {146 hypothesisText: 'Call me Ishmael. RANDOM mind how long',147 hypothesisName: 'HP title'148 }149 ]150 };151 let diff = compareText(optionsOneExtra);152 test('matches', () => {153 expect(diff[0].stats.matches).toBe(6);154 })155 test('substitutions', () => {156 expect(diff[0].stats.substitutions).toBe(1);157 })158 test('deleted', () => {159 expect(diff[0].stats.deleted).toBe(2);160 })161 test('inserted', () => {162 expect(diff[0].stats.inserted).toBe(0);163 })...

Full Screen

Full Screen

FileVersions.js

Source:FileVersions.js Github

copy

Full Screen

1Ext.define('Phlexible.mediamanager.view.FileVersions', {2 extend: 'Ext.panel.Panel',3 requires: [4 'Phlexible.mediamanager.model.FileVersion'5 ],6 xtype: 'mediamanager.file-versions',7 iconCls: Phlexible.Icon.get('edit-number'),8 layout: 'fit',9 autoScroll: true,10 fileId: null,11 fileVersion: null,12 versionsText: '_versionsText',13 downloadFileVersionText: '_downloadFileVersionText',14 /**15 * @event versionChange16 */17 /**18 * @event versionSelect19 */20 /**21 *22 */23 initComponent: function () {24 this.initMyTemplates();25 this.initMyStore();26 this.initMyItems();27 this.initMyContextMenu();28 this.callParent(arguments);29 },30 initMyStore: function() {31 this.store = Ext.create('Ext.data.Store', {32 model: 'Phlexible.mediamanager.model.FileVersion',33 data: this.fileVersions || [],34 proxy: {35 type: 'ajax',36 url: '',37 simpleSortMode: true,38 reader: {39 type: 'json',40 rootProperty: 'detail',41 idProperty: 'uid',42 totalProperty: 'count'43 },44 extraParams: this.storeExtraParams45 },46 listeners: {47 load: function (store, records) {48 if (!records.length) {49 this.setTitle(this.versionsText);50 }51 else {52 this.setTitle(this.versionsText + ' [' + records.length + ']');53 if (this.fileVersion) {54 var index = store.find('version', this.fileVersion);55 this.getComponent(0).select(index);56 } else {57 this.getComponent(0).select(0);58 }59 }60 },61 scope: this62 }63 });64 },65 initMyTemplates: function() {66 this.fileVersionsTpl = new Ext.XTemplate(67 '<tpl for=".">',68 '<div class="version-wrap" id="version-{version}">',69 '<div class="thumb"><img src="{[Phlexible.Router.generate(\"mediamanager_media\", {fileId: values.id, templateKey: \"_mm_medium\", fileVersion: values.version})]}" width="48" height="48"></div>',70 '<div class="text">',71 '<span><b qtip="{name}">{[values.name.shorten(25)]}</b></span><br />',72 //'<span>[v{version}] {[Phlexible.mediatype.MediaTypes.getText(values.mediaType)]}, {[Phlexible.Format.size(values.size)]}</span><br />',73 //'<span>Create User: {create_user_id}</span><br />',74 '<span>{create_time}</span><br />',75 '</div>',76 '<div class="x-clear"></div>',77 '</div>',78 '</tpl>'79 );80 },81 initMyItems: function() {82 this.items = [83 {84 xtype: 'dataview',85 cls: 'p-mediamanager-file-versions',86 store: this.store,87 tpl: this.fileVersionsTpl,88 autoHeight: true,89 singleSelect: true,90 overItemCls: 'x-view-over',91 itemSelector: 'div.version-wrap',92 emptyText: 'No versions to display',93 listeners: {94 click: this.versionSelect,95 dblclick: this.versionSelect,96 contextmenu: this.onContextMenu,97 scope: this.contextMenu98 }99 }100 ];101 },102 initMyContextMenu: function() {103 this.contextMenu = Ext.create('Ext.menu.Menu', {104 items: [105 {106 text: this.downloadFileVersionText,107 iconCls: Phlexible.Icon.get('drive-download'),108 handler: function (btn) {109 this.fireEvent('versionDownload', btn.parentMenu.fileId, btn.parentMenu.fileVersion);110 },111 scope: this112 }113 ]114 });115 },116 onDestroy: function() {117 this.contextMenu.destroy();118 this.callParent(arguments);119 },120 versionSelect: function (view, rowIndex, node, e) {121 e.stopEvent();122 var record = view.store.getAt(rowIndex);123 this.fireEvent('versionSelect', record);124 },125 loadVersions: function(versions) {126 this.getComponent(0).getStore().loadData(versions);127 },128 loadFile: function (fileId, fileVersion) {129 this.fileId = fileId;130 if (fileVersion) {131 this.fileVersion = fileVersion;132 } else {133 this.fileVersion = null;134 }135 // TODO: fix136 return;137 this.getComponent(0).getStore().getProxy().setUrl(Phlexible.Router.generate('mediamanager_file_detail', {fileId: this.fileId}));138 this.getComponent(0).getStore().load();139 },140 empty: function () {141 this.getComponent(0).store.removeAll();142 },143 onContextMenu: function (view, rowIndex, node, event) {144 event.stopEvent();145 this.fileId = view.store.getAt(rowIndex).data.id;146 this.fileVersion = view.store.getAt(rowIndex).data.version;147 var coords = event.getXY();148 this.showAt([coords[0], coords[1]]);149 }...

Full Screen

Full Screen

2ecea2d8451bac9883ddbc2159300b089fb812f2.svn-base

Source:2ecea2d8451bac9883ddbc2159300b089fb812f2.svn-base Github

copy

Full Screen

1#!/usr/bin/env node2"use strict";3const os = require('os');4const path = require('path');5const fs = require('fs');6const spawnSync = require('child_process').spawnSync;7const versions = ['0.12', '4', '6'];8const tmpdir = os.tmpdir();9function directoryExists(file) {10 try {11 var stat = fs.lstatSync(file);12 return stat.isDirectory();13 } catch (err) {14 return false;15 }16}17function fileExists(file) {18 try {19 var stat = fs.lstatSync(file);20 return stat.isFile();21 } catch (err) {22 return false;23 }24}25function removeFolder(dir) {26 if (!fs.existsSync(dir)) return;27 fs.readdirSync(dir).forEach((file) => {28 let curPath = dir + path.sep + file;29 if (fs.lstatSync(curPath).isDirectory())30 removeFolder(curPath);31 else32 fs.unlinkSync(curPath);33 });34 fs.rmdirSync(dir);35}36let tempInstallPath = path.resolve(tmpdir, 'chromedriver-test');37if (directoryExists(tempInstallPath)) {38 console.log(`Deleting directory '${tempInstallPath}'.`);39 removeFolder(tempInstallPath);40}41fs.mkdirSync(tempInstallPath);42function checkSpawn(spawnInfo) {43 if (spawnInfo.stdout) {44 if (typeof (spawnInfo.stdout) !== 'string')45 console.log(spawnInfo.stdout.toString('utf8'));46 else47 console.log(spawnInfo.stdout);48 }49 if (spawnInfo.stderr) {50 if (typeof (spawnInfo.error) !== 'string')51 console.error(spawnInfo.stderr.toString('utf8'));52 else53 console.error(spawnInfo.stderr);54 }55 if (spawnInfo.status !== 0 || spawnInfo.error) {56 console.error('Failed when spawning.');57 process.exit(1);58 }59 if (typeof (spawnInfo.stdout) !== 'string')60 return spawnInfo.stdout.toString('utf8');61 else62 return spawnInfo.stdout;63}64function nvmUse(version) {65 if (os.platform() === 'win32')66 var versionsText = checkSpawn(spawnSync('nvm', ['list']));67 else68 var versionsText = checkSpawn(spawnSync('/bin/bash', ['-c', 'source $HOME/.nvm/nvm.sh && nvm list']));69 const versionsAvailable = versionsText.split('\n').map(v => v.match(/\d+\.\d+\.\d+/)).filter(v => v).map(v => v[0]);70 var largestMatch = versionsAvailable.filter(v => v.match(`^${version}\.`)).map(v => v.match(/\d+\.(\d+)\.\d+/)).reduce(((max, v) => max[1] > v[1] ? max : v), [null, 0]);71 if (largestMatch.length === 0) {72 console.error(`Version '${version}' not found.`);73 process.exit(3);74 }75 var largestMatchingVersion = largestMatch.input;76 console.log(`Found version '${largestMatchingVersion}'.`);77 if (os.platform() === 'win32')78 checkSpawn(spawnSync('nvm', ['use', largestMatchingVersion]));79 else80 checkSpawn(spawnSync('/bin/bash', ['-c', `source $HOME/.nvm/nvm.sh && nvm use ${largestMatchingVersion}`]));81}82function sleep(milliseconds) {83 const inAFewMilliseconds = new Date(new Date().getTime() + 2000);84 while (inAFewMilliseconds > new Date()) { }85}86for (let version of versions) {87 console.log(`Testing version ${version}...`);88 let tempInstallPathForVersion = path.resolve(tmpdir, 'chromedriver-test', version);89 fs.mkdirSync(tempInstallPathForVersion);90 nvmUse(version);91 if (os.platform() === 'win32') {92 sleep(2000); // wait 2 seconds until everything is in place93 checkSpawn(spawnSync('cmd.exe', ['/c', `npm i ${__dirname}`], { cwd: tempInstallPathForVersion }));94 } else {95 checkSpawn(spawnSync('npm', ['i', `${__dirname}`], { cwd: tempInstallPathForVersion }));96 }97 let executable = path.resolve(tempInstallPathForVersion, 'node_modules', 'chromedriver', 'lib', 'chromedriver', `chromedriver${os.platform() === 'win32' ? '.exe' : ''}`);98 if (fileExists(executable)) {99 console.log(`Version ${version} installed fine.`);100 }101 else {102 console.error(`Version ${version} did not install correctly, file '${executable}' was not found.`);103 process.exit(2);104 }105}106try {107 removeFolder(tempInstallPath);108} catch (err) {109 console.error(`Could not delete folder '${tempInstallPath}'.`);...

Full Screen

Full Screen

releasenotes.js

Source:releasenotes.js Github

copy

Full Screen

1/**2 * Modules3 * Node4 * @constant5 */6'use strict';7const fs = require('fs-extra');8const json2md = require('json2md');9const os = require('os');10const path = require('path');11/**12 * Modules13 * External14 * @constant15 */16const _ = require('lodash');17const appRootPath = require('app-root-path')['path'];18/**19 * Modules20 * Internal21 * @constant22 */23const logger = require(path.join(appRootPath, 'lib', 'logger'))({ timestamp: false });24const packageJson = require(path.join(appRootPath, 'package.json'));25/**26 * Filesystem27 * @constant28 * @default29 */30const filename = 'RELEASENOTES';31const inputFilepath = path.join(appRootPath, `${filename}.json`);32const outputFilepath = path.join(appRootPath, `${filename}.md`);33/**34 * Release Notes Template35 * @constant36 * @default37 */38const releasenotesTemplate = {39 'features': [],40 'bugfixes': [],41 'documentation': [],42 'internals': []43};44/**45 * Transform Release Notes Object to markdown46 * @param {Object} releasenotesObject - Release Notes object47 * @returns {Array} - Markdown lines48 */49let transformToMarkdown = (releasenotesObject) => {50 logger.debug('transformToMarkdown');51 let markdownList = [];52 Object.keys(releasenotesObject).forEach((value) => {53 markdownList.push(json2md({ h4: _.startCase(value) }));54 let entryContent = { ul: [] };55 releasenotesObject[value].forEach((note) => {56 entryContent.ul.push(note);57 });58 markdownList.push(json2md(entryContent) + os.EOL);59 });60 return markdownList;61};62/**63 * Write release notes to disk64 *65 * @public66 */67let updateFile = () => {68 logger.debug('writeReleasenotes');69 let notesVersionsList = [];70 let notesVersionsObject = {};71 let notesVersionsText;72 // Read from RELEASENOTES.json73 try {74 notesVersionsObject = JSON.parse(fs.readFileSync(inputFilepath).toString());75 } catch (err) {76 logger.error(`release notes file read error:`, inputFilepath);77 return;78 }79 // Parse RELEASENOTES.json80 Object.keys(notesVersionsObject).forEach((version) => {81 notesVersionsList.push(json2md({ h2: version }) + os.EOL);82 notesVersionsList = notesVersionsList.concat(transformToMarkdown(notesVersionsObject[version]));83 });84 notesVersionsText = notesVersionsList.join(os.EOL);85 // Write to RELEASENOTES.md86 fs.writeFileSync(outputFilepath, notesVersionsText);87 logger.info('release notes updated:', outputFilepath);88};89/**90 * Get latest Release Notes91 * @returns {String} - Release notes text92 *93 * @public94 */95let getLatest = () => {96 logger.debug('getReleasenotes');97 let notesList = [];98 let notesVersionsObject = {};99 let notesText;100 // Read from CHANGELOG.json101 try {102 notesVersionsObject = JSON.parse(fs.readFileSync(inputFilepath).toString());103 } catch (err) {104 logger.error(`release notes file read error:`, inputFilepath);105 }106 if (notesVersionsObject.hasOwnProperty(packageJson.version)) {107 notesList = transformToMarkdown(notesVersionsObject[packageJson.version]);108 logger.info('release notes found for:', `v${packageJson.version}`);109 } else {110 notesList = transformToMarkdown(releasenotesTemplate);111 logger.warn('release notes missing for:', `v${packageJson.version}`);112 }113 notesText = json2md(notesList);114 return notesText;115};116/**117 * Main118 */119if (require.main === module) {120 updateFile();121}122/**123 * @exports124 */125module.exports = {126 getLatest: getLatest,127 update: updateFile...

Full Screen

Full Screen

index.js

Source:index.js Github

copy

Full Screen

1const url = require('url');2const path = require('path');3const fs = require("fs");4const got = require('got');5const Spinnies = require('spinnies');6const AdmZip = require('adm-zip');7const async = require('async');8const spinnies = new Spinnies();9const GOT_OPTIONS = {10 headers: {11 Origin: 'https://fontawesome.com',12 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36'13 }14};15const FA_RELEASES_PAGE = 'https://github.com/FortAwesome/Font-Awesome/releases';16const FA_PRO_ASSET_BASE = 'https://kit-pro.fontawesome.com';17const fontUrlRegex = /url\((.*?)\)/gm;18const githubSpansRegex = /<div class="f1 flex-auto min-width-0 text-normal">(.+?)<\/div>/gms;19const githubReleasesRegex =/>(.*?)</;20main();21async function main() {22 spinnies.add('loading-versions', { text: 'Loading Font Awesome 5 versions' });23 const versions = await getFA5Versions();24 if (!versions || !versions[0]) {25 spinnies.fail('loading-versions', { text: 'Failed to load Font Awesome 5 versions' });26 return;27 }28 spinnies.succeed('loading-versions', { text: 'Loaded Font Awesome 5 versions' });29 const latestVersion = versions[0];30 31 spinnies.add('ripping-start', { text: `Ripping FA5 v${latestVersion}` });32 const zip = new AdmZip();33 const css = await got.get(`${FA_PRO_ASSET_BASE}/releases/v${latestVersion}/css/pro.min.css`, GOT_OPTIONS);34 GOT_OPTIONS.headers.Referer = `${FA_PRO_ASSET_BASE}/releases/v${latestVersion}/css/pro.min.css`;35 GOT_OPTIONS.encoding = null;36 const fontUrls = css.body37 .match(fontUrlRegex).map(url => url.replace('url(', '').replace(')', '').replace('../../..', FA_PRO_ASSET_BASE));;38 const cssFile = css.body39 .replace(/https:\/\/kit-free.fontawesome.com\/algo\/1/g, '..')40 .replace(/..\/..\/..\/algo\/1/g, '..')41 .replace(/webfonts/g, 'fonts');42 zip.addFile('css/all.css', Buffer.from(cssFile));43 async.each(fontUrls, (fontUrl, callback) => {44 45 const fileName = path.basename(url.parse(fontUrl).pathname);46 got(fontUrl, GOT_OPTIONS)47 .then(response => {48 zip.addFile(`fonts/${fileName}`, response.body);49 callback();50 })51 .catch(() => {52 callback();53 });54 }, () => {55 fs.writeFileSync(`${__dirname}/fa5-v${latestVersion}.zip`, zip.toBuffer());56 spinnies.succeed('ripping-start', { text: `Ripped FA5 v${latestVersion}. Saved to ${__dirname}/fa5-v${latestVersion}.zip` });57 });58}59async function getFA5Versions() {60 // I decided to use RegEx on HTML rather than use the API to try and get around ratelimits61 // This will break if GH changes the html layout62 const response = await got(FA_RELEASES_PAGE);63 const html = response.body;64 const spans = html.match(githubSpansRegex);65 const versions = spans.map(span => {66 return span.match(githubReleasesRegex)[1].replace('Release', '').trim();67 });68 return versions;...

Full Screen

Full Screen

header.js

Source:header.js Github

copy

Full Screen

1/**2 * Created by lizhuo on 2017/6/12.3 */4import { Link } from 'react-router'5import { judgeAppStatus } from 'config/appStatus'6export const Header = (props) => {7 let8 { data, editUrl, onChangeVersion, latestVersion } = props,9 /*10 * getAppStatus => Function 根据props获取组建的版本信息11 * appStatus => Array 调用getAppStatus的返回值12 * latesVersions , preVersions => Object 包含版本号和相应文本的对象13 * */14 getAppStatus = (app) => {15 const { versions, adminUnshelved, devUnshelved } = app16 return versions.slice(0, 2).map((v) => {17 const vInfo = judgeAppStatus({18 adminUnshelved,19 devUnshelved,20 publishStatus: v.publishStatus,21 reviewStatus: v.reviewStatus22 })23 return {24 ...vInfo,25 codeVersion: v.codeVersion26 }27 })28 },29 appStatus = getAppStatus(data),30 latestVersions = appStatus[0],31 preVersions = appStatus[1],32 len = appStatus.length,33 hidePreCode = [...5,6,7] === latestVersions.codeVersion === preVersions.codeVersion;34 if (appStatus.length > 1 && appStatus[0].status === appStatus[1].status) {35 appStatus.pop()36 }37 return (38 /*39 * 根据知否未开发者来渲染相应头部信息模版40 * */41 data && data.mine === 1 && len > 0 &&42 <div className='tab-nav'>43 <ul className='tab-list'>44 { (preVersions.codeVersion && !hidePreCode) &&45 <li className={preVersions.codeVersion === latestVersion.codeVersion && 'active' || ''}46 onClick={() => { onChangeVersion && onChangeVersion(preVersions, data.versions[1]) }}>47 <a>48 <div className='text'>{preVersions.codeVersion}</div>49 <div className='text'>{preVersions.text}</div>50 </a>51 </li>52 }53 <li className={latestVersions.codeVersion === latestVersion.codeVersion && 'active' || ''}54 onClick={() => { onChangeVersion && onChangeVersion(latestVersions, data.versions[0]) }}>55 <a>56 <div className='text'>{latestVersions.codeVersion}</div>57 <div className='text'>{latestVersions.text}</div>58 </a>59 </li>60 </ul>61 </div>62 )...

Full Screen

Full Screen

menuLinks.js

Source:menuLinks.js Github

copy

Full Screen

1export default [2 {3 text: 'CMS API Reference',4 },5 {6 text: 'Authentication',7 },8 {9 text: 'Meta',10 },11 {12 text: 'Sites',13 },14 {15 text: 'Domains',16 },17 {18 text: 'Collections',19 items: [20 {21 text: 'Model',22 },23 {24 text: 'List Collections',25 },26 {27 text: 'Get Collections',28 },29 ],30 },31 {32 text: 'Fields',33 },34 {35 text: 'Items',36 },37 {38 text: 'Images',39 },40 {41 text: 'Webhooks',42 },43 {44 text: 'Errors',45 },46 {47 text: 'Rate Limits',48 },49 {50 text: 'API Versions',51 },52 {53 text: 'Changelog',54 },...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const puppeteer = require('puppeteer');2(async () => {3 const browser = await puppeteer.launch();4 const page = await browser.newPage();5 await page.screenshot({path: 'example.png'});6 await browser.close();7})();8const puppeteer = require('puppeteer-core');9(async () => {10 const browser = await puppeteer.launch({11 });12 const page = await browser.newPage();13 await page.screenshot({path: 'example.png'});14 await browser.close();15})();16const puppeteer = require('puppeteer-core');17(async () => {18 const browser = await puppeteer.launch({19 });20 const page = await browser.newPage();21 await page.screenshot({path: 'example.png'});22 await browser.close();23})();24const puppeteer = require('puppeteer-core');25(async () => {26 const browser = await puppeteer.launch({27 });28 const page = await browser.newPage();29 await page.screenshot({path: 'example.png'});30 await browser.close();31})();32const puppeteer = require('puppeteer-core');33(async () => {34 const browser = await puppeteer.launch({35 });36 const page = await browser.newPage();37 await page.screenshot({path: 'example.png'});38 await browser.close();39})();40const puppeteer = require('puppeteer-core');41(async () => {42 const browser = await puppeteer.launch({43 });44 const page = await browser.newPage();

Full Screen

Using AI Code Generation

copy

Full Screen

1const puppeteer = require('puppeteer');2const fs = require('fs');3(async () => {4 const browser = await puppeteer.launch();5 const page = await browser.newPage();6 const version = await browser.version();7 const userAgent = await page.evaluate(() => navigator.userAgent);8 console.log(version);9 console.log(userAgent);10 await browser.close();11 fs.writeFile('versions.txt', version + '12' + userAgent, function (err) {13 if (err) {14 return console.log(err);15 }16 console.log('The file was saved!');17 });18})();

Full Screen

Using AI Code Generation

copy

Full Screen

1const puppeteer = require('puppeteer');2(async () => {3const browser = await puppeteer.launch();4const page = await browser.newPage();5await page.screenshot({path: 'example.png'});6await browser.close();7})();8{9 "scripts": {10 },11 "dependencies": {12 }13}

Full Screen

Using AI Code Generation

copy

Full Screen

1const puppeteer = require('puppeteer');2const fs = require('fs');3const util = require('util');4const writeFile = util.promisify(fs.writeFile);5(async () => {6 const browser = await puppeteer.launch();7 const page = await browser.newPage();8 const versions = await browser.versions();9 await writeFile('versions.txt', JSON.stringify(versions, null, 2));10 await browser.close();11})();12{13}

Full Screen

Using AI Code Generation

copy

Full Screen

1const { puppeteer } = require("puppeteer");2const browser = await puppeteer.launch();3const page = await browser.newPage();4await page.screenshot({ path: "example.png" });5await browser.close();6const { chromium } = require("playwright");7const browser = await chromium.launch();8const page = await browser.newPage();9await page.screenshot({ path: "example.png" });10await browser.close();11const { Builder } = require("selenium-webdriver");12const driver = new Builder().forBrowser("chrome").build();13await driver.takeScreenshot("example.png");14await driver.quit();15const cypress = require("cypress");16cypress.run({17});18const createTestCafe = require("testcafe");19let testcafe = null;20createTestCafe("localhost", 1337, 1338)21 .then((tc) => {22 testcafe = tc;23 const runner = testcafe.createRunner();24 .src("test.js")25 .browsers("chrome")26 .screenshots("reports/screenshots/", true)27 .run();28 })29 .then((failedCount) => {30 console.log("Tests failed: " + failedCount);31 testcafe.close();32 });33const { browser } = require("protractor");34browser.takeScreenshot("example.png");35const { client } = require("nightwatch-api");36client.saveScreenshot("example.png");37const { codeceptjs } = require("codeceptjs");38codeceptjs.run({39});40const { gauge } = require("gauge

Full Screen

Using AI Code Generation

copy

Full Screen

1const versions = require('puppeteer/package.json').versions;2console.log('Versions', versions);3const { version } = require('puppeteer/package.json');4console.log('Version', version);5const { version } = require('puppeteer');6console.log('Version', version);7const { version } = require('puppeteer-core');8console.log('Version', version);9const { version } = require('puppeteer-core/package.json');10console.log('Version', version);11const { version } = require('puppeteer/package.json');12console.log('Version', version);13const { version } = require('puppeteer-core/package.json');14console.log('Version', version);15const { version } = require('puppeteer-core/package.json');16console.log('Version', version);17const { version } = require('puppeteer-core/package.json');18console.log('Version', version);19const { version } = require('puppeteer-core/package.json');20console.log('Version', version);21const { version } = require('puppeteer

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 Puppeteer 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