node package manager
Stop writing boring code. Discover, share, and reuse within your team. Create a free org »

bblp-build

bblp-build:

Bundle a Backbase Launchpad static item.

INSTALL

  • Install library
npm install --save-dev bblp-build
yarn add --dev bblp-build

USAGE

  • Display help
bblp-build --help
  • Display version
bblp-build --version
 
## build current item
bblp-build ./
bblp-build ./collection/src/path/to/my/widget

Arguments:

  • [path] [./] Item to build.

Options:

  • - a --all [false] Build all external dependencies.
  • - t --templates [false] Bundle HTML templates into build file.
  • - m --moduleId [false] Build with AMD module ID in definition.
  • - o --output [./dist] Output directory path.
  • - e --expand [false] Do not minify javascript & css files.

Build theme

USAGE

  • Display help
bblp-build theme --help
 
bblp-build theme ./ universal

Arguments:

  • [path] [./] Theme path.
  • [edition] [retail] Theme retail edition

Options:

  • - A --no-assets [false] Do include assets files e.g. fonts/images.
  • - o --output [./dist] Output directory path.
  • - e --expand [false] Do not minify javascript & css files.
  • -b, --base-path [./] Theme base path e.g. bower_components

Examples

Single item build

bblp-build

Single theme build

bblp-build theme

Collection build

Collection pom.xml

 
....
<plugin>
    <groupId>com.github.eirslett</groupId>
    <artifactId>frontend-maven-plugin</artifactId>
    <version>1.0</version>
    <executions>
        <execution>
            <id>install node and npm</id>
            <goals>
                <goal>install-node-and-npm</goal>
            </goals>
            <phase>install</phase>
            <configuration>
                <nodeVersion>v4.6.0</nodeVersion>
                <npmVersion>3.3.6</npmVersion>
            </configuration>
        </execution>
        <execution>
            <id>npm-install</id>
            <phase>install</phase>
            <goals>
                <goal>npm</goal>
            </goals>
            <configuration>
                <arguments>install --loglevel error</arguments>
            </configuration>
        </execution>
        <execution>
            <id>build</id>
            <phase>install</phase>
            <goals>
                <goal>npm</goal>
            </goals>
            <configuration>
                <arguments>run build --loglevel error</arguments>
            </configuration>
        </execution>
    </executions>
</plugin>
...
 

Collection package.json:

{
  "name": "collection-retail",
  "version": "1.0.2",
  "scripts": {
    "build": "node ./scripts/build.js ./src"
  },
  "devDependencies": {    
    ....
    "bblp-build": "^1.0.4",
    "shelljs": "^0.7.4"
  }
}

Collection scripts/build.js: This is just and example you can customize it based on the project structure.

'use strict';
/**
* ------------------------------------------------------------------------
* Building statics using bblp-build command
* requires node v4.2.x LTS argon
* ------------------------------------------------------------------------
*/
const path = require('path');
const sh = require('shelljs');
 
const basePath = process.argv[2] || '../src';
const src = [
  path.resolve(basePath , 'widget-*'),
  path.resolve(basePath , 'theme-*'),
];
 
const skip = [
  path.resolve(basePath , 'widget-demo'),
];
 
const BBLP =  path.resolve(__dirname, '../node_modules/bblp-build/bin/bblp-build');
 
let cmd = '';
 
let buildExitCode = 0; //optimistic 
sh.ls('-d', src )
  .filter( file => skip.indexOf(file) < 0)
  .forEach( file => {
      const item = path.basename(file);
 
      // build theme 
      if(item.indexOf('theme') >= 0 ) {
        cmd = `node ${BBLP} theme ${file}`;
      } else {
        cmd = `node ${BBLP} ${file} --templates`;
      }
 
      console.log(`Building ${item}... `);
      console.log(`[EXEC]: ${cmd}`);
      let res = sh.exec(cmd);
      if(res.code > 0 ) {
        buildExitCode = res.code;
      }
});
if(buildExitCode > 0 ) {
  console.log(`[BUILD FAILED]`);
} else {
  console.log(`[BUILD SUCCESS]`);
}
process.exit(buildExitCode);