mozu-theme-helpers
Helpers for compiling the JavaScript of Mozu themes and keeping Mozu themes up to date.
Last updated 5 years ago by jzetlen .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install mozu-theme-helpers 
SYNC missed versions from official npm registry.

mozu-theme-helpers

Library for common theme tasks: checking and maintaining repository relationship, and compiling JavaScript.

Requires

  • nodejs 0.12 or above

Install

npm install --save-dev mozu-theme-helpers

API

const mozuThemeHelpers = require('mozu-theme-helpers');
const pathToTheme = "/Users/you/mozuThemes/someTheme";
let task = mozuThemeHelpers('check', { dir: pathToTheme });
// tasks are EventEmitters, emitting "info", "warn", "error", and "done" events
task.on('info', console.log);
task.on('warn', console.log);
task.on('error' e => {
  console.error(e);
  process.exit(1);
});
task.on('done', summary => {
  console.log(summary);
  process.exit(0);
});

Task Types

check

Maintains base theme relationship in your theme.json and in Git, and informs you of available updates. This task is meant to be run on every incremental build of your theme.

  • Detects the base theme of the current theme, by looking in Git and in theme.json
  • Reattaches a basetheme remote if necessary.
  • Checks the base theme for updates.
  • Displays new available versions, or all new available commits, based on the baseThemeChannel setting in theme.json. If it's set to stable, displays only available stable versions. If it's set to prerelease, will also display prerelease versions. If it's set to edge, will display all commits that are available to merge.
  • Updates the baseThemeVersion in theme.json if it detects that you have merged in later versions.

Options:

  • dir - The directory of the theme to check. Defaults to process.cwd().

compile

Compiles your theme JavaScript using the customized Mozu RequireJS Compiler.

  • Puts built JS in the compiled directory.
  • Minifies JS using Uglify2 by default.
  • Detects extends in theme.json and uses a temp directory to simulate runtime resolution. This feature is deprecated; you should have "extends": null in your theme.json.

Options:

  • skipminification - Skip the minification step. Use this during development for faster builds. Default false.
  • verbose - Say a lot more stuff.

Grunt Task

This library is mostly designed for use in Grunt, and so it has a grunt task. Grunt will recognize the /tasks/ folder of any node module, so you can say:

grunt.loadNpmTasks('mozu-theme-helpers');

This will give Grunt a mozutheme task, that can run check and compile with options.

Example task configuration:

mozutheme: {
  check: {
    command: 'check'
  },
  fullcompile: {
    command: 'compile'
  },
  quickcompile: {
    command: 'compile',
    opts: {
      skipminification: true
    }
  }
}

Task configuration must include a command property that can be either 'check' or 'compile'. It can optionally include an opts object that will be sent to the task as options.

opts can also be a function, that can asynchronously create options. It will receive the grunt process object and a callback as arguments, and should call callback with an error as the first argument if an error occurred, or null as the first argument and an options object to be sent to the task as the second argument.

License

MIT. Copyright 2016 Volusion, LLC.

Current Tags

  • 1.3.2                                ...           latest (5 years ago)

10 Versions

  • 1.3.2                                ...           5 years ago
  • 1.3.0                                ...           5 years ago
  • 1.2.2                                ...           5 years ago
  • 1.2.1                                ...           5 years ago
  • 1.1.2                                ...           5 years ago
  • 1.1.1                                ...           5 years ago
  • 1.1.0                                ...           5 years ago
  • 1.0.2                                ...           5 years ago
  • 1.0.1                                ...           5 years ago
  • 1.0.0                                ...           5 years ago
Downloads
Today 0
This Week 0
This Month 1
Last Day 0
Last Week 0
Last Month 1
Dependencies (6)
Dev Dependencies (3)

Copyright 2014 - 2016 © taobao.org |