Assemble command assembling zero pages - node.js

So I've been trying to use Assemble to build e-mails, and up until now it works; the problem is that now, when I try to run the Assemble command, it fails. Or, more accurately, it succeeds, with a message reading "0 pages assembled" despite no actual compiled files appearing. I'm honestly at a loss as to what the issue is here, as all of the options seem configured to point to the right folders (relative to the root directory where the gruntfile is located) and up until recently it was working.
I'm not really sure what's broken here; the relevant section of the grunt config object is excerpted below; the full config object is a little long to include in full here.
assemble: {
'default': {
options: {
layoutdir: 'src/layouts'
},
pages: {
src: ['src/emails/*.hbs'],
dest: 'dist/'
}
}
}
Any thoughts on where I've gone wrong?

oh... you have too many layers in your assemble configuration. Remove the 'default' object wrapping:
assemble: {
options: {
layoutdir: 'src/layouts'
},
pages: {
src: ['src/emails/*.hbs'],
dest: 'dist/'
}
}
In this case, options is for all assemble targets, and pages is one of the targets.

Related

Error running grunt-responsive-images task

I'm trying to set up grunt with grunt-responsive-images, and getting the following error:
Warning: Could not execute GraphicsMagick/ImageMagick: gm "identify" "-ping" "-format" "%m:%T:%s" "assets/_img/bgAbout.jpg" this most likely means the gm/convert binaries can't be found
The npm and ImageMagick are both installed, have also tried GraphicsMagick (with default engine) to no avail.
I've verified all my versions of node/grunt/packages and I'm on Windows 10 if that's helpful info.
relevant bits from gruntfile.js:
responsive_images: {
dev: {
options: {
engine: 'im'
},
files: [{
expand: true,
src: ['**/*.{gif,jpg,png}'],
cwd: 'assets/_img/',
dest: 'assets/test/'
}]
}
},
grunt.loadNpmTasks('grunt-responsive-images');
grunt.registerTask('default', ['responsive_images']);
All relevant help I've found points to ImageMagick/GraphicsMagick not being installed, but it is. What could be hindering the communication between the task and IM?
Ugh. foiled by Windows UAC! Ran cmd as administrator, and it worked like a charm. Why did it take so long for my basic customer support troubleshooting reflexes of yore to kick in?

karma config moving a file to base directory

Is there a way to move a file loaded in the Karma config to new directory, such as /base/? I have an external project which contains the source files. I am able to load the file via ../../directory. However, it inserts the file into the /absolute/ folder. If I load the test(s) on another computer, the directory of /absolute/ is different. Is there a preprocessor or some configuration I am missing? I searched through the karma documentation, but couldn't find what I am looking for.
// list of files / patterns to load in the browser
files: [
{ pattern: 'node_modules/jquery/dist/jquery.min.js', included: false },
{ pattern: 'node_modules/knockout/build/output/knockout-latest.js', included: false },
{ pattern: 'node_modules/knockout-mapping/dist/knockout.mapping.min.js', included: false },
{ pattern: 'node_modules/knockout-postbox/build/knockout-postbox.min.js', included: false },
{ pattern: '../FantasyFootball/wwwroot/js/site.js', included: false, served: true, watched: true },
{ pattern: 'tests/*.js', included: false },
{ pattern: 'test-main.js', included: true }
],
Karma generates paths that start with /absolute/... for files you ask it to
load files that are outside Karma's basePath. Karma does this because there's no
simple way to provide a path to these files through the usual /base/ path that
is both unique and inferable. If you are to provide a relative path to a
file above basePath, Karma cannot just combine it with /base/. For instance,
if you had ../my/file.js and ../../my/file.js in your files array, then
combined with /base/, they would both turn into the path /my/file.js. For
cases like this, Karma generates a unique and inferable path by using
/absolute/ and appending the absolute path of the file on disk.
Ok, so where does that leave you? You want Karma to load files outside
basePath and you want to be able to use their paths in your loader's setup.
The problem can be overcome. You can modify karma.conf.js to provide
information useful to compute the paths you need:
client: {
absoluteTopDir: path.join("/absolute/", __dirname),
},
Then in test-main.js, you need to use the absoluteTopDir parameter:
var absoluteTopDir = window.__karma__.config.absoluteTopDir;
require.config({
baseUrl: "...",
paths: {
foo: absoluteTopDir + "../../my/file",
},
});
I've run Karma for years without any trouble but I recently ran into the problem
you ran into and used the method I described above in one of my test suites with
great success.
I've used this solution both with RequireJS and SystemJS.

grunt-contrib-copy dies with EPERM operation not permitted "C:\Documents and Settings"

I am trying to run a simple grunt task using grunt-contrib-copy, but it dies immediately on reaching the copy task, with this message:
Running "copy:main" (copy) task
Warning: EPERM, operation not permitted 'C:\Documents and Settings' Use --force to continue
Aborted due to warnings
I am running:
Windows 7 64-bit (so C:\Documents and Settings doesn't exist)
node 0.10.28 (installed at C:\nodejs)
npm 1.4.9
grunt-cli 0.1.13
grunt 0.4.5
grunt-contrib-copy 0.5.0
I have done a full-text search for "Documents and Settings" on both C:\nodejs and my project folder (C:\Users\myusername\Documents\Programming\myprojectname, with no spaces or parentheses in there), but nothing matches.
My copy task definition is:
copy: {
main: {
files: [
{expand: true, cwd: 'src/core', src: '/**', dest: 'src/chrome/'},
{expand: true, cwd: 'src/core', src: '/**', dest: 'src/firefox/'}
]
}
},
What could be causing this error?
I fixed it. The problem was the src: '/**' properties in the original code.
I changed it to this, and now it works perfectly:
copy: {
main: {
files: [
{expand: true, cwd: 'src/core', src: '**/*', dest: 'src/chrome/'},
{expand: true, cwd: 'src/core', src: '**/*', dest: 'src/firefox/'}
]
}
},
The /** src property was breaking it, and **/* works correctly. I'm pretty new to Grunt, so I didn't realize the former syntax was a problem; I somehow got the impression it would be treated as a relative path.
I searched high and low for an answer to this before posting my question. The Grunt docs have a good explanation of Grunt's globbing patterns (*, **, etc.), but it doesn't mention leading slashes being a problem. So, I figured I would leave this up for anyone else who runs into this kind of problem. I hope it helps someone else.

Building Durandal with Grunt (R.js + Text)

I would like to use Grunt to build a Durandal project, because Weyland remains completely undocumented and isn't as standard as Grunt.
To do this, the grunt task needs to pull in all the js and html files during optimization, but I am unable to get RequireJS to inline the html files via the text module.
It looks like weyland copies the text files manually, but I can't figure out what it's doing to get requirejs (or almond, in this case), to actually use them. I have seeen this question, but it requires the text modules to be referenced in the define call, which isn't done in Durandal.
My gruntfile for require uses this config
requirejs: {
build: {
options: {
name: '../lib/require/almond-custom', //to deploy with require.js, use the build's name here instead
insertRequire: ['main'], //needed for almond, not require
baseUrl: 'src/client/app',
out: 'build/main-built.js',
mainConfigFile: 'src/client/app/main.js', //needed for almond, not require
wrap: true, //needed for almond, not require
paths: {
'text': '../lib/require/text',
'durandal':'../lib/durandal/js',
'plugins' : '../lib/durandal/js/plugins',
'transitions' : '../lib/durandal/js/transitions',
'knockout': '../lib/knockout-2.3.0',
'bootstrap': '../lib/bootstrap.min',
'jquery': '../lib/jquery-1.9.1',
'Q' : '../lib/q.min'
},
inlineText: true,
optimize: 'none',
stubModules: ['text']
}
}
}
You might want to give https://npmjs.org/package/grunt-durandal a try. I'm using this as part of a grunt based build process. See https://github.com/RainerAtSpirit/HTMLStarterKitPro for an example.
durandal: {
main: {
src: ['app/**/*.*', 'lib/durandal/**/*.js'],
options: {
name: '../lib/require/almond-custom',
baseUrl: requireConfig.baseUrl,
mainPath: 'app/main',
paths: mixIn({}, requireConfig.paths, { 'almond': '../lib/require/almond-custom.js' }),
exclude: [],
optimize: 'none',
out: 'build/app/main.js'
}
}
},
As a possible alternative to Grunt I would suggest looking at Mimosa. It's not as widely used as Grunt but is well documented and requires a good deal less configuration and if you start with the durandal skeleton everything is configured for you including inlining html.
Durandal also recommends it and tells you how to get started with it: http://durandaljs.com/pages/get-started/
You can run make start to start developing and make dist to have it package everything up for release.

Understanding the mean stack and integrating uglify.js and stylus

I'm just getting started with the MEAN stack (https://github.com/linnovate/mean), so I'm pretty sure my question is going to look very basic to an expert, so my apologies in advance!
While I think it would be a gread addition to what this stack already has to offer, I cannot manage to integrate Uglify.js and stylus
Also someone already asked this, but it would make sense to me to use Jade template for both server and public views, at least for a matter of standardization.
I have tried playing with the grunt file and server.js, renaming some files, but all I managed to achieve so far, is break the original project...
Thanks in advance!
EDIT: Just found a fork of this project which has just added support for jade templates for public views: https://github.com/tutley/mean
This post explains how to integrate Stylus pre-processing to the MEAN stack: http://to-s.tk/integrate-stylus-to-the-mean-stack/
Short version:
Move public/css to a new assets/stylesheets and rename all the .css files to .styl
Install grunt-contrib-stylus through npm's package.json, as both a dev and runtime dependency.
-Configure stylus compilation in your Gruntfile
// ...
grunt.initConfig({
// ...
watch: {
// ...
stylus: {
files: ['assets/stylesheets/**/*.styl'],
tasks: ['stylus']
},
// ...
},
// ...
stylus: {
compile: {
options: {
paths: ['assets/stylesheets/**']
},
files: [{
dest: 'public/css/',
cwd: 'assets/stylesheets/',
src: '*.styl',
ext: '.css',
expand: true
}]
}
},
// ...
});
//...
//Load NPM tasks
// ...
grunt.loadNpmTasks('grunt-contrib-stylus');
// ...
Import views stylus files (or any substylus) in common.styl using #require statements
Remove references to views or other substylesheets in head.jade.
Then all assets/stylesheets/*.styl files should be automatically compiled into public/css/*.css, as long as grunt is running. To trigger a compile without relying on watch, you can run grunt stylus.

Resources