Running Dalekjs Tests on Saucelabs with Grunt - gruntjs

what i want:
run dalekjs-tests on saucelabs with grunt
what i did:
installed grunt-dalek, dalek-driver-sauce
created grunt config:
dalek: {
options: {
driver: ['sauce'],
browser: ['chrome'],
advanced: {
"driver.sauce": {
user: "xxx",
key: "xxx"
}
}
}
}
what my problem is
Warning: Cannot read property '0' of null Use --force to continue.

finally i had some time to dig deeper into this. the error came from dalek-driver-sauce.
Function _verfiyBrowserConfig inside browser.js caused the problem.
var browser = browsers[0][browserName] || null;
in my config i was missing the browsers property.
the dalek-driver-sauce docs are kind of misleading there:
if you would like to have a more control over the browser/OS combinations that are available, you are able to configure you custom combinations
the browsers config inside advanced-config is mandatory!
a final working grunt-config looked like this:
dalek: {
options: {
driver: ['sauce'],
advanced: {
"driver.sauce": {
user: "xxx",
key: "xxx"
},
browsers: [{
chrome: {
"platform": "OS X 10.6",
"actAs": "chrome",
"version": 27
}
}]
}
},
mytest: ['test.js']
}

Related

Gatsby/Wordpress - .env credentials not working

I am working with the gatsby-source-wordpress plugin
If I hard code my API keys/secret into my Gatsby.config, everything works fine, but I want to add these as .env variables so that I can .gitignore for deployment, and this is where things are breaking.
At the root of my directory, I have a .env file which looks like this
CLIENT_SECRET=10987654321
CLIENT_ID=123456
USER=secret#secret.com
PASS=mypassword1
I'm then try to access these in gatsby.config, like this
require('dotenv').config({
path: `.env.${process.env.NODE_ENV}`
});
module.exports = {
siteMetadata: {
title: 'Gatsby Default Starter',
},
plugins: [
{
resolve: 'gatsby-source-wordpress',
options: {
baseUrl: 'myurl.com',
protocol: 'http',
hostingWPCOM: true,
useACF: false,
auth: {
wpcom_app_clientSecret: `${process.env.CLIENT_SECRET}`,
wpcom_app_clientId: `${process.env.CLIENT_ID}`,
wpcom_user: `${process.env.USER}`,
wpcom_pass: `${process.env.PASS}`,
},
},
},
{
resolve: `gatsby-plugin-emotion`,
},
'gatsby-plugin-react-helmet',
{
resolve: `gatsby-plugin-manifest`,
options: {
name: 'gatsby-starter-default',
short_name: 'starter',
start_url: '/',
background_color: '#663399',
theme_color: '#663399',
display: 'minimal-ui',
icon: 'src/images/gatsby-icon.png', // This path is
relative to the root of the site.
},
},
'gatsby-plugin-offline',
],
}
which is returning the following errors when I run either gatsby develop or gatsby build
source and transform nodesThe server response was "400 Bad Request"
source and transform nodesThe server response was "403 Forbidden"
Inner exception message : "User cannot access this private blog."
No routes to fetch. Ending.
So, the issue is the .env variables don't seem to be pulling through properly, but I can't see a reason why they wouldn't be? Is there anything I've missed in setting this up?
Gatsby doesn't know which plugin you mean (see How to use) and your overall syntax is wrong. The plugins is an array for example.
module.exports = {
plugins: [
{
resolve: "gatsby-source-wordpress",
options: {
auth: {
wpcom_app_clientSecret: process.env.CLIENT_SECRET,
wpcom_app_clientId: process.env.CLIENT_ID,
wpcom_user: process.env.USER,
wpcom_pass: process.env.PASS,
}
}
}
]
}
This should work assuming that you also define the other necessary fields mentioned in the README.

Is this the right way to get lite-server to recognize the "server.index" override in bs-config.js?

lite-server seems to be ignoring my attempt to override the default index.
I have bs-config.json:
{
"server": {
"baseDir": "src",
"index": "/index.3.html",
"routes": {
"/node_modules": "node_modules"
}
}
}
I am using lite-server version 2.3.0, like this:
> lite-server -c=bs-config.json
browser-sync config **
{ injectChanges: false,
files: [ './**/*.{html,htm,css,js}' ],
watchOptions: { ignored: 'node_modules' },
server:
{ baseDir: 'src',
middleware: [ [Function], [Function] ],
directory: true,
index: '/index.3.html',
routes: { '/node_modules': 'node_modules'
}
}
}
In the console log output above, it recognizes the bs-config.json index default of "index.3.html", however, when the browser requests "GET http://localhost", the console shows it is trying to serve index.html instead of index.3.html.
[Browsersync] Serving files from: src
[Browsersync] Watching files...
17.09.04 22:35:51 404 GET /index.html
I have also tried supplying bs-config.js:
"use strict";
module.exports = {
"server": {
"baseDir": "src",
index: "i/index.3.html",
"directory":true,
"routes": {
"/node_modules": "node_modules"
}
// middleware,: {
// // overrides the second middleware default with new settings
// 1: require('connect-history-api-fallback')({index: '/index.3.html', verbose: true})
// }
}
}
and running lite-server with:
> lite-server -c=bs-config.js
but the behavior is the same.
Question: how do I override bs-config's server.index for lite-server?
lite-server's config-default.js sets index in it's 2nd middleware "fallback" function. This seems to be overring bs-config setting.
So the solution seems to be, override the middleware to set index as desired.
bs-config.js:
module.exports = {
"server": {
"baseDir": "src",
"routes": {
"/node_modules": "node_modules"
},
middleware: {
// overrides the second middleware default with new settings
1: require('connect-history-api-fallback')({
index: '/index.3.html',
htmlAcceptHeaders: ['text/html', 'application/xhtml+xml'] // systemjs workaround})
}
}
}
Notes:
1. If a future version of lite-server changes it's default-config's middleware to put the index fallback in a different index position of the middleware function array, or to set different response headers, then this bs-config solution will need to be changed accordingly.
references:
Browserync Docs: https://browsersync.io/docs/options
lite-server: https://github.com/johnpapa/lite-server

Yeoman Angular, grunt server always launches IE

Just started using Yeoman Angular generator, but when I run grunt server command, it always opens IE. Tried changes in GruntFile.js
autoprefixer: {
options: {
browsers: ['last 1 version', 'Chrome']
}
But it gives error
Any clues how to get it working?
Simply in your Gruntfile.js you can add an app parameter:
open: {
server: {
url: 'http://localhost:XXXXXXXX',
app: 'Google Chrome'
}
},
This will work.
For reference check this link https://github.com/GabLeRoux/grunt-open/commit/6f2c7069767e58160ec96aaaa8fa20ed210ba183
If you are still having problems, the following should work:
livereload: {
options: {
open: {
appName: "google-chrome"
},

Gruntjs not correctly inheriting options in task

Below is a part of my Gruntfile. Running '$grunt msbuild:migrate:local' works fine, but '$grunt msbuild:migrate:dev' doesnt seem to be pulling in my ConnectionString property. Am I organizing things correctly for the options in inherit correctly?
msbuild: {
src: ['Web Platform\Web Platform.csproj'],
options: {
projectConfiguration: 'Dev',
targets: ['Clean', 'Rebuild'],
maxCpuCount: 4,
verbosity: 'minimal',
stdout: true,
buildParameters: {
WarningLevel: 2,
DeployOnBuild: false,
Configuration: 'Dev',
},
},
migrate: {
// Defaults -----------------------------------------
src: ['Migrate.msbuild'],
options: {
targets: ['Migrate'],
buildParameters: {
DryRun: 'False',
Verbose: 'False',
RollbackSteps: '1',
},
verbosity: 'minimal',
},
// Tasks -----------------------------------------
local: {
// Uses defaults from above (I hope)
},
dev: {
options: {
buildParameters: {
ConnectionString: 'Data Source=<%= credentials.aws_rds_hostname %>,1433;Initial Catalog=DevDatabase;User ID=<%= credentials.aws_rds_admin_username %>;Password=<%= credentials.aws_rds_admin_password %>'
}
}
}
}
}
Grunt doesn't support deeply nested tasks. The only thing that can run here is "grunt msbuild:migrate" (inheriting the global configuration, overridden by its own config)
See this ticket for example.

Is it possible to config an array in a nested object in grunt options?

I'm trying to write a small plugin and I want the user to be able to input an array into a nested object in grunt config, something like:
myTask: {
default: {
options: {
name: "someName"
deploy: {
envs: ["dev", "staging", "prod"]
}
}
}
}
In my task I'm trying to grab this.options.deploy.envs but it's undefined.
Not seen this style of plugin configuration before. Might be wiser to follow existing conventions for multi tasks:
myTask: {
deploy: {
options: {
name: "someName",
envs: ["dev", "staging", "prod"]
}
},
development: {
options: {
name: "othertarget",
envs: ["dev"]
}
}
}
In any case, you are missing a comma after "someName".

Resources