Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
benbria-build
Advanced tools
Readme
This is a tool for building projects using Ninja. It assumes your project follows a certain layout.
npm install --save-dev benbria-build
npm install --save-dev ninja-build
npm install --save-dev coffee-script
npm install --save-dev [other optional dependencies - see below]
mkdir src
echo "console.log 'hello world'" > src/index.coffee
./node_modules/.bin/benbria-configure-ninja
./node_modules/.bin/ninja
This benbria-configure-ninja
configures the Ninja build
process, generating build.ninja
. See the
Ninja manual for more information.
This assumes you have a project with the following file structure:
/
|-- src
+-- assets
|-- js
+-- css
By convention we put browserify bundles in assets/browserify. (We don't put them in assets/js, since we don't want the files to by compiled into the build directory.)
Your project should have any the following optional dependencies specified as dependencies or devDependencies in it's project.json, and installed in the node_modules folder. All of these are optional; so long as you don't need the specified feature, you don't need them installed:
--streamline8
to build-configure-ninja
. Otherwise,
streamline 0.10.9 or newer is required. You can also use --streamline-opts '--cb _cb'
to set
whatever extra streamline options you want. Streamline is not currently supported for files in
/assets/js.--stylus-opts '--import node_modules/nib/index.styl'
to set arbitrary extra stylus options.benbria-configure-ninja
will generate a ninja file with the following edges:
lint
- Lint all source files.
lib
- Compile all source files in /src to /lib. This will automatically include:
*.js
- Copied directly over.*.coffee
, *.litcoffee
, *.coffee.md
- Compiled to .coffee file. Sourcemap will be
generated.*._js
, *._coffee
- Compiled with streamline compiler. Souremaps will be generated if your
streamline compiler is v0.10.x or better. Note you need to specify --streamline8 for
v0.8.x. Lower than v0.8.x is not supported.debug-assets
- Build files in the assets folders. Compiled files go into build/assets/debug.
Any files which start with an "_" will be excluded from the build:
assets/js/*.coffee
, assets/js/*.js
- Javascript: These will be compiled with snockets support.assets/*.styl
- CSS.release-assets
- Same as debug-assets
except compiled files go into build/assets/release.
Also this will run all files through the "fingerprint" process, producing a
build/release/fingerprints.json.
Build edges are generated by factory
objects defined in src/ninjaFactories.coffee. You can
define your own factories to customize your build process. For example, to build a browserify
bundle as part of the build, create a file called ninjaConfig.coffee
:
{defineFactory} = require 'benbria-build'
# Browserify bundle
defineFactory "foo-bundle", {
makeRules: (ninja, config) ->
['debug', 'release'].forEach (releaseType) ->
cli = "$buildCoffee ./assets/foo/doBuild.coffee -o $out"
cli += if (releaseType is 'release') then '' else ' --debug'
ninja.rule("foo-#{releaseType}")
.run(cli)
.description "(#{releaseType}) BROWSERIFY $in"
assetFiles: 'foo/src/foo.coffee'
makeAssetEdge: (ninja, source, target, releaseType) ->
ninja.edge(target)
.from(source)
.using("foo-#{releaseType}")
return [target]
}
Then when you run benbria-configure-ninja:
benbria-configure-ninja --require './ninjaConfig.coffee'
You can register a factory to create a browserify bundle:
# Browserify bundle for reporting
defineBrowserifyFactory "inbox",
"browserify/inbox/inbox.coffee",
"inbox/inbox.js", {
extensions: ['.coffee', '.jade']
transform: [
'coffeeify'
'browserify-jade'
'aliasify'
'includify'
'rfolderify'
'debowerify'
]
}
This will read assets/browserify/inbox/inbox.coffee, and compile it to build/assets/[buildtype]/js/inbox/inbox.js. i18n-extractor is automatically run on the output, and in debug mode a dependencies file is built, so ninja will know whether or not your js file needs rebuilding. For release mode, the bundle is automatically minified using uglify-js.
benbria-build
has a default set of paths it lints. Those paths being the assumed directory structure
(see above). If you have some extra paths you would like to lint, or perhaps omit, you can override the
defaults like so:
{configureCoffeelint} = require 'benbria-build'
configureCoffeelint {
extensions: [
'coffee'
'_coffee'
]
paths: [
'src/**/*.$ext'
'assets/js/**/*.$ext'
'assets/browserify/**/*.$ext'
'bin/**/*.$ext'
'Gruntfile.$ext'
]
}
Where $ext
will be replaced by each item in the extensions
array of the options hash. This example
adds the new path 'assets/browserify/**/*.$ext'
to be linted.
Run:
scripts/browserify-bundle.coffee \
--transforms 'coffeeify,browserify-jade' \
--show myFile.coffee
to see what a set of transforms is going to do to a source file.
FAQs
This is a tool for building projects using [Ninja](http://martine.github.io/ninja/). It assumes your project follows a certain layout.
The npm package benbria-build receives a total of 22 weekly downloads. As such, benbria-build popularity was classified as not popular.
We found that benbria-build demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.