pjs-project-settings is a global npm package that helps other pjs projects keep their build process up to date.
Install pjs-project-settings globally.
$ npm i pjs-project-settings -g
Then run pjs-project-settings
from the directory you want to update.
It will override your Gruntfile.js and add a directory called grunt/tasks and grunt/settings.
You'll be prompted for every override, except for settings, which should be kept up to date.
If you have an existing Gruntfile and want to preserve some of your tasks, try using grunt-generate-configs with -js option. generate_configs -js
from the directory of your project. Then copy the output to the grunt/tasks as you see fit.
Next run this command to update your devDependencies.
$ pjs-project-settings --devDeps
clean
Removes files and directories.copy
Copies files and directories.jsbeautifier
Beautifies js filesjshint
Lints js for errors.replace
Replaces template varsrig
Combines js files (like concat but better).uglify
Minifies js fileswatch
Watches for changes and runs tasks when they change, usually thedefault
task.
bump
Bump the version in the package.json and the bower.json. Example:grunt bump --level minor
.githooks
pre-commit: Make sure js files are beautified according to p-js conventions. Build a release, and add the dist folder.
This changes often per project, but the most basic default
grunt task list and release
grunt task list are included in grunt/tasks/aliases.yml
.
- default:
clean
,jshint:devel
,rig
,replace
,copy
- release:
clean
,jshint:release
,rig
,replace
,copy
,uglify
In grunt/settings you'll find jshint.json and jshint-dev.json. jshint.json is used for release builds, and jshint-dev.json is used for dev builds while you're editing your code.
In dev mode, the differences are:
- you can skip semicolons (asi = false).
- you can have unused variables (unused = false).
- you can have trailing whitespace (trailing = false).
- you can use debug statements (debug = true).
- you can use console and alert (devel = true).
- no indent enforced (indent options removed).
For a quick overview of the current settings see here.
Below are the pjs settings for beautifying. See here for more about these options.
Workflow Tip: If you're using Sublime Text, install JSFormat and use these as your settings. And add
"format_on_save": true
.
{
"indent_with_tabs": true,
"preserve_newlines": true,
"max_preserve_newlines": 10,
"jslint_happy": false,
"brace_style": "collapse",
"keep_array_indentation": false,
"keep_function_indentation": false,
"space_before_conditional": true,
"break_chained_methods": false,
"eval_code": false,
"unescape_strings": false,
"wrap_line_length": 0
}