Gulp favicon task - gulp

I am trying to make task for creating favicon images in GULP like this
var realFavicon = require ('gulp-real-favicon');
var fs = require('fs');
// File where the favicon markups are stored
var FAVICON_DATA_FILE = 'faviconData.json';
// Generate the icons. This task takes a few seconds to complete.
// You should run it at least once to create the icons. Then,
// you should run it whenever RealFaviconGenerator updates its
// package (see the check-for-favicon-update task below).
gulp.task('generate-favicon', function(done) {
realFavicon.generateFavicon({
masterPicture: 'TODO: Path to your master picture',
dest: 'TODO: Path to the directory where to store the icons',
iconsPath: '/',
design: {
ios: {
pictureAspect: 'noChange'
},
desktopBrowser: {},
windows: {
pictureAspect: 'noChange',
backgroundColor: '#da532c',
onConflict: 'override'
},
androidChrome: {
pictureAspect: 'shadow',
themeColor: '#ffffff',
manifest: {
name: 'MyApp',
display: 'browser',
orientation: 'notSet',
onConflict: 'override'
}
},
safariPinnedTab: {
pictureAspect: 'silhouette',
themeColor: '#5bbad5'
}
},
settings: {
scalingAlgorithm: 'Mitchell',
errorOnImageTooSmall: false
},
markupFile: FAVICON_DATA_FILE
}, function() {
done();
});
});
// Inject the favicon markups in your HTML pages. You should run
// this task whenever you modify a page. You can keep this task
// as is or refactor your existing HTML pipeline.
gulp.task('inject-favicon-markups', function() {
gulp.src([ 'TODO: List of the HTML files where to inject favicon markups' ])
.pipe(realFavicon.injectFaviconMarkups(JSON.parse(fs.readFileSync(FAVICON_DATA_FILE)).favicon.html_code))
.pipe(gulp.dest('TODO: Path to the directory where to store the HTML files'));
});
// Check for updates on RealFaviconGenerator (think: Apple has just
// released a new Touch icon along with the latest version of iOS).
// Run this task from time to time. Ideally, make it part of your
// continuous integration system.
gulp.task('check-for-favicon-update', function(done) {
var currentVersion = JSON.parse(fs.readFileSync(FAVICON_DATA_FILE)).version;
realFavicon.checkForUpdates(currentVersion, function(err) {
if (err) {
throw err;
}
});
});
Only problem I have is that i dont have faviconData.json can somebody share his, txanks

You should go back to Real Favicon Generator and follow the installation steps. Basically:
Replace the "TODO" in the generated code with actual paths.
Run gulp generate-favicon. This once-in-a-while task generates your icons and also the faviconData.json file you miss. For example this file contains the HTML markups that declare the icons.
Now you are ready to run gulp inject-favicon-markups whenever you deploy your site, update one of your pages, etc.

"favicons": {
"files": {
"src": "./dist/img/logo/favicon.png",
"dest": "./dist/img/favicons/",
"html": "./templates/misc/favicons.tpl.php",
"iconsPath": "./dist/img/favicons/",
"androidManifest": null,
"browserConfig": null,
"firefoxManifest": null,
"yandexManifest": null
},
"icons": {
"android": true,
"appleIcon": true,
"appleStartup": true,
"coast": true,
"favicons": true,
"firefox": true,
"opengraph": true,
"windows": true,
"yandex": true
},
"settings": {
"appName": "name",
"appDescription": "This is the app description",
"developer": null,
"developerURL": null,
"version": 1.0,
"background": null,
"index": null,
"url": null,
"silhouette": false,
"logging": true
},
"favicon_generation": null
},
maybe you can use this, you should change the settings of course :)

Related

How Do I Run Two Different Specs at The Same Time?

I am just wondering if it is possible to run two different specs at the same time using protractor.
My protractor.config.js is below:
var browserCapabilities = [
{
browserName: 'chrome',
maxInstances: 2,
seleniumAddress: seleniumServer,
platform: 'ANY',
version: 'ANY',
chromeOptions: {
args: ['--no-sandbox', '--test-type=browser', '--lang=en', '--window-size=1680,1050'],
prefs: {
'credentials_enable_service': false,
'profile': {
'password_manager_enabled': false
},
download: {
prompt_for_download: false,
directory_upgrade: true,
default_directory: 'C:\\downloads\\'
},
},
},
loggingPrefs: { browser: 'SEVERE' }
},
];
// Protractor config
exports.config = {
baseUrl: baseUrl,
directConnect: false,
allScriptsTimeout: 25 * 1000,
jasmineNodeOpts: {
defaultTimeoutInterval: 90 * 1000
},
getPageTimeout: 120 * 1000,
suites: {
adminRoles: 'compiled/artemis/settings/adminAppRoles.scenario.js',
adminUsers: 'compiled/artemis/settings/adminUsers.scenario.js',
benchmarks: 'compiled/artemis/benchmarks/benchmark.scenario.js',
claims: 'compiled/artemis/claims/claims.scenario.js',
cohorts: 'compiled/artemis/cohorts/cohort.scenario.js',
customBD: 'compiled/artemis/dimensions/*.scenario.js',
exploreCreate: 'compiled/artemis/explorations/create.scenario.js',
exploreInMeasureFilters: 'compiled/artemis/explorations/inMeasureFilters.scenario.js',
exploreRead: 'compiled/artemis/explorations/read.scenario.js',
exploreRegFilters: 'compiled/artemis/explorations/regularFilters.scenario.js',
exploreUpdate: 'compiled/artemis/explorations/update.scenario.js',
home: 'compiled/artemis/home/home.scenario.js',
login: 'compiled/artemis/login/*.scenario.js',
mgmtConsole: 'compiled/artemis/settings/mgmtConsoleSysDef.scenario.js',
navigation: 'compiled/artemis/navigation/navigation.scenario.js',
sharing: 'compiled/artemis/sharing/sharingTests.scenario.js',
smoke: 'compiled/artemis/smokeTests/smokeTests.scenario.js',
stories: 'compiled/artemis/story/story.scenario.js',
visualizeCreate: 'compiled/artemis/visualize/visualizeCreate.scenario.js',
visualizeRead: 'compiled/artemis/visualize/visualizeRead.scenario.js',
visualizeUpdate: 'compiled/artemis/visualize/visualizeUpdate.scenario.js',
vizInMeasureFilters: 'compiled/artemis/visualize/vizInMeasureFilters.scenario.js',
vizRegFilters: 'compiled/artemis/visualize/vizRegularFilters.scenario.js',
tritonLogin: 'compiled/triton/login/*.scenario.js',
tritonCustomers: 'compiled/triton/customers/*.scenario.js',
tritonDashboard: 'compiled/triton/dashboard/*.scenario.js'
},
multiCapabilities: browserCapabilities,
framework: 'jasmine2',
onPrepare: function() {
//Set Up a JUnit XML Reporter - Makes a nice test results area and trend graph in Jenkins
var jasmineReporters = require('jasmine-reporters');
jasmine.getEnv().addReporter(new jasmineReporters.JUnitXmlReporter({
consolidateAll: true,
savePath: 'report',
filePrefix: 'xmloutput'
}));
const JasmineConsoleReporter = require('jasmine-console-reporter');
const consoleReporter = new JasmineConsoleReporter({
colors: 1,
cleanStack: 1,
verbosity: 4,
listStyle: 'indent',
activity: true,
emoji: true,
beep: true
});
//Setup screenshots
jasmine.getEnv().addReporter(screenShotReporter);
jasmine.getEnv().addReporter(consoleReporter);
browser.get(browser.baseUrl);
},
// Setup the report before any tests start
beforeLaunch: function() {
return new Promise(function(resolve) {
screenShotReporter.beforeLaunch(resolve);
});
},
// Close the report after all tests finish
afterLaunch: function(exitCode) {
return new Promise(function(resolve) {
screenShotReporter.afterLaunch(resolve.bind(this, exitCode));
});
},
};
I launch my tests with a command like this:
gulp e2e --suite suiteName --baseUrl http://myurl.com/
I would like to be able to for example launch my login suite and my navigation suite at the same time.
I have tried the maxInstances: 2 in the browserCapabilities variable, but that only launched the login suite.
I have tried doing two instances of the chrome object and then doing maxSessions: 2 but that only launched the login test twice.
I am envisioning a command like this: gulp e2e --suite login --suite navigation --baseUrl http://myurl.com and having it launch both suites simultaneously.
U can use shardTestFiles: true
// ...
capabilities: {
shardTestFiles: true,
maxInstances: 2,
// ...

Random ECONREFUSED from webdriver / chrome

We have written a bunch of e2e tests for an angular4 app, that we are developing. The problem is that I am getting random ECONNREFUSED message from webdriver / chrome, when running automated tests with protractor.
- Failed: ECONNREFUSED connect ECONNREFUSED 127.0.0.1:54657
Protractor is running with shardedtestfiles turned on, and running with 12 browsers in parallel, in order to speed up testing.
I can't pinpoint an exact pattern to the errors that we get, so I am a bit lost here.. Below is a copy of the protractor config file, that we are using.
// Protractor configuration file, see link for more information
// https://github.com/angular/protractor/blob/master/lib/config.ts
//*global jasmine */
"use strict";
var SpecReporter = require("jasmine-spec-reporter").SpecReporter;
var timeoutSettings = require('./dist/out-tsc/e2e/protractor.config').timeoutSettings
exports.config = {
allScriptsTimeout: 99999,
suites: {
spec: [
"./dist/out-tsc/e2e/spec/**/*spec.js"
]
},
capabilities: {
browserName: "chrome",
maxInstances: 12,
chromeOptions: {
args: ["--no-sandbox", "--disable-infobars", "--start-maximized", "--lang=DA-dk"],
prefs: {
download: {
promt_for_download: false,
default_directory: "spec/downloads" // To Do: Make sure this dir is correct!
},
"profile.password_manager_enabled": false,
credentials_enable_service: false,
password_manager_enabled: false
}
}
},
directConnect: true,
framework: "jasmine",
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 120000,
print: function () {}
},
SELENIUM_PROMISE_MANAGER: false,
useAllAngular2AppRoots: true,
beforeLaunch: function () {
require("ts-node").register({
project: "./e2e/tsconfig.json"
});
},
onPrepare: function () {
browser.manage().timeouts().implicitlyWait(timeoutSettings.implicitWaitNormal);
jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
var trx = require("jasmine-trx-reporter");
return browser.getCapabilities().then(function (caps) {
var browserName = caps.get("browserName").toUpperCase();
var jasmineTrxConfig = {
reportName: "Protractor Test Results",
folder: "reports",
outputFile: "",
browser: "GANDALF_" + browserName,
groupSuitesIntoSingleFile: false,
takeScreenshotsOnlyOnFailures: false
};
jasmine.getEnv().addReporter(new trx(jasmineTrxConfig));
});
}
};
It seems that this is actually a problem in the version of selenium webdriver, that is pulled in, when using protractor
There is a discussion in an issue with protractor on github
https://github.com/angular/protractor/issues/4792

How to replace Filenames inside my manifest.json File using rev-replace

i'm stuck a little - i want to replace image file names with their hashed version inside my manifest file.
Manifest looks like this:
{
"icons": [
{
"src": "android-chrome-192x192.png",
"sizes": "192x192",
"type": "image/png"
},
{
"src": "android-chrome-512x512.png",
"sizes": "512x512",
"type": "image/png"
}
]
}
I want those icon src to be replaced with the hashed filenames which looks like this: "android-chrome-192x192-b03df0131.png"
My gulp file which should do it looks like this:
const gutil = require('gulp-util');
module.exports = function (gulp, plugins) {
return function () {
const manifest = gulp.src('public/dist/rev-manifest.json');
return gulp.src(['public/dist/#(css|js)/**','public/dist/img/icon/**.json'])
.pipe(plugins.revReplace({replaceInExtentions: ['.json']}))
.pipe(plugins.revReplace({manifest: manifest}))
.pipe(gulp.dest('public/dist'));
};
};
after a lot of googling and Documentation reading i got it working :D
So if someone searches for this:
const gutil = require('gulp-util');
module.exports = function (gulp, plugins) {
return function () {
const manifest = gulp.src('public/dist/rev-manifest.json');
function replaceIconPath(filename) {
if(filename.includes('android-chrome-')) {
return filename.replace('img/icon/', '');
}
return filename;
}
return gulp.src('public/dist/#(css|js|img)/**')
.pipe(plugins.revReplace({
replaceInExtensions: ['.json', '.css', '.js', '.html', '.hbs'],
manifest: manifest,
modifyUnreved: replaceIconPath,
modifyReved: replaceIconPath
}))
.pipe(gulp.dest('public/dist'));
};
};
So let me explain this shortly - the important part is in plugins.revReplace.
You need the option replaceInExtension and add '.json' but you also need to specify the default options or else they will be lost.
The 'modifiyUnreved' and 'modifyReved' options are just needed if you have to modify the filenames further. In my case it couldn't find the file because my rev-manifest was on another level compared to my manifest file. So i needed to cut the path for it to find the src and replace it.

JWplayer. Change destination source with http request

I'v got jwplayer source code from github. I want to change some scripts and built the player. So, i need to change file source from javascript in flash. In javascript i'm setting some params "host" and "flv_id":
jwplayer("mediaplayer").setup({
autostart: false,
controlbar: "none",
displayclick: "none",
smoothing: true,
stretching: "exactfit",
icons: false,
flashplayer: "/jwplayer.swf",
file: "/videos/3aae1ef41d.flv",
flv_id: "115554",
host: "<?php echo $host; ?>",
provider: "http",
startparam: "start",
height: 400,
width: 650,
events: {
onComplete: function() {
},
onPause: function(event) {
},
onError: function() {
}
}
});
In flash i have some class, which can make post-request:
var post:Post = new Post("http://"+someparameters["host"]+"/video/flv");
post.variables.id = someparameters["flv_id"];
post.Send(Go);
Go - is success callback function that returns some flvlink.
Go(link:String):void {
//link - is source, that i need to play
}
The player is playing the "/videos/3aae1ef41d.flv". But i want to play the source from Go(); I have class "Post", but i don't know the place to paste my code. Now, i haven't any changes in default source code. I don't know which file of player source code to edit. So, i need to know, how i can use my "Post" class to play video from Go function.

Sencha touch selectfield works fine in chrome, but it fails in android 2.1 emulator and Android 2.2 phone

I am learning Sencha Touch. I am having a strange issue. A view using select field is not showing it on Android emulator, but it does in Google Chrome. It worked fine before, I cannot guess what changed to "break" it.
In the emulator logcat I can see these three messages:
E/ActivityThread(243): Failed to find provider info for android.server.checkin
W/Checkin(243): Can't update stat BROWSER_SNAP_CENTER: java.lang.IllegalArgumentException: Unknown URL content://android.server.checkin/stats
D/CordovaLog(243): undefined: Line 1 : TypeError: Result of expression 'c' [null] is not a constructor.
Sometimes only the third is shown.
Hereafter the view code:
(function() {
var setSettingValue = function(component, query, value) {
var c = component.query(query);
if (c && value && (c.length > 0)) {
c[0].setValue(value);
}
};
var createToolbar = function () {
return Ext.create('Ext.Toolbar', {
xtype: 'toolbar',
docked: 'bottom',
layout: { pack: 'center' },
items: [
{
iconMask: true, ui: 'normal', iconCls: 'info',
itemId: 'infoButton'
},
{ xtype: 'spacer' },
{
iconMask: true, ui: 'normal', iconCls: 'reply',
itemId: 'backButton'
}
]
})};
Ext.define('MyWF.view.Settings', {
extend: 'Ext.Container',
initialize: function ()
{
this.setItems([createToolbar()]);
this.callParent();
},
config : {
layout : 'vbox',
padding : '0 10',
scrollable: {
direction: 'vertical'
},
onBackAction: function () { console.log('back'); },
onInfoAction: function () { console.log('info'); },
listeners: [{
delegate: "#backButton",
event: 'tap',
fn: 'onBackAction'
},
{
delegate: "#infoButton",
event: 'tap',
fn: 'onInfoAction'
},
{
event: 'show',
fn: function(component, eOpts) {
setSettingValue(component, 'selectfield[name=windMU]','kmh');
setSettingValue(component,'selectfield[name=temperatureMU]','C');
}
}],
items : [{
xtype : 'fieldset',
title : 'Measure units',
items : [{
xtype : 'selectfield',
name : 'temperatureMU',
label : 'Temperature',
labelAlign: 'top',
listeners : {
change : function(selectField, newData, oldData, eOpts) {
alert('Your choice is: ' + newData);
}
},
options : [{
text : 'Celsius',
value : 'C'
}, {
text : 'Farenheit',
value : 'F'
},]
}, {
xtype : 'selectfield',
name : 'windMU',
label : 'Wind speed',
labelAlign : 'top',
listeners : {
change : function(selectField, newData, oldData, eOpts) {
alert('Your choice is: ' + newData);
}
},
options : [{
text : 'Kilometers per hour',
value : 'km/h'
}, {
text : 'Meters per second',
value : 'm/s'
}, {
text : 'Miles per hour',
value : 'MPH'
}, {
text : 'Knots',
value : 'kn'
}]
}]
},]
}
});
})();
Thanks for any suggestion
Well I got some time to fix the issue.
First of all I add a lacking information to the question: I was running the app with a custom build of the Sencha Touch library, the library version is 2.0.1.1.
On Google Chrome the select field (Ext.field.Select) creates by default an Ext.dataview.List instance for the list of choiches, while on a phone an Ext.picker.Picker is created.
But Ext.picker.Picker also creates an Ext.TitleBar, that was lacking in my custom build of sencha library, while the Ext.dataview.List class is in.
So the application can show the select field in Chrome, but it cannot in the emulator, and it gives the unclear message, because the libary build is compressed and obfuscated.
There are two solutions:
you can force the use of a list also in the emulator or phone. The class Ext.picker.Picker has a creation option for this: "usePicker: false", by default set to "auto".
or, better, add an explicit reference to the title bar component in the app file: "Ext.require('Ext.TitleBar');" to include it in the library build.
I saw the problem forcing the use of the picker in Chrome, by setting the picker configuration "usePicker: true", and running the app with the debug library build "sencha-touch-debug.js", see http://docs.sencha.com/touch/2-0/#!/api/Ext.Loader, and http://docs.sencha.com/touch/2-0/#!/guide/building .
Then in the Chrome console, as well in the Android emulator logcat, I saw the clear message:
[WARN][Anonymous] [Ext.Loader] Synchronously loading 'Ext.TitleBar';
consider adding 'Ext.TitleBar' explicitly as a require of the corresponding class
A suggestion: in the logcat is better to filter the many messages, for example writing "Ext.Loader" in the filter mask.