Skip to content

Commit

Permalink
shift builds
Browse files Browse the repository at this point in the history
  • Loading branch information
yeojz committed Sep 2, 2017
1 parent 04c8551 commit e11887c
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 14 deletions.
6 changes: 2 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,13 @@
"description": "HMAC-based (HOTP) and Time-based (TOTP) One-Time Password library",
"main": "otplib.js",
"scripts": {
"build": "yarn run build:module && yarn run build:browser && yarn run build:copy",
"build": "./scripts/build.sh",
"build:browser": "webpack --config ./scripts/builds/webpack.config.js",
"build:docs": "jsdoc --configure jsdoc.json --verbose",
"build:module": "./scripts/build-module.sh",
"build:copy": "cp ./{README.md,LICENSE,package.json,yarn.lock,.npmignore} ./dist",
"build:transpile": "babel dist --out-dir dist",
"clean": "npm run clean:folders && npm run clean:builds",
"clean:builds": "rimraf otplib.js otplib-browser.js browser.js core.js totp.js hotp.js utils.js authenticator.js",
"clean:folders": "rimraf coverage .nyc_output docs",
"clean": "rimraf dist coverage docs",
"coveralls": "cat ./coverage/lcov.info | coveralls",
"deploy-gh-pages": "./scripts/builds/page.sh",
"lint": "eslint --ext js src",
Expand Down
4 changes: 4 additions & 0 deletions scripts/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
yarn run build:module
yarn run build:transpile
yarn run build:browser
yarn run build:copy
4 changes: 2 additions & 2 deletions scripts/helpers/createBanner.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ function createBanner(name) {
return `/**
* ${name}
*
* @author Gerald Yeo
* @author ${pkg.author}
* @version: ${pkg.version}
* @license: MIT
* @license: ${pkg.license}
**/`
}

Expand Down
2 changes: 1 addition & 1 deletion scripts/helpers/renameImports.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ function renameImports() {
}, {});
}

module.exports = renameImports;
module.exports = renameImports();
14 changes: 7 additions & 7 deletions scripts/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,31 @@ const renameImports = require('./helpers/renameImports');

const PACKAGE_LIST = Object.keys(packageConfig);
const PACKAGE_NAME = process.env.OTPLIB_NAME;
const FILENAME = PACKAGE_NAME.replace('otplib-', '') + '.js';
const FILENAME = PACKAGE_NAME.replace('otplib-', '');

if (!PACKAGE_NAME) {
throw new Error('process.env.OTPLIB_NAME is not defined.')
}

if (PACKAGE_LIST.indexOf(PACKAGE_NAME) < 0) {
throw new Error('process.env.OTPLIB_NAME has an invalid value');
const config = packageConfig[PACKAGE_NAME];

if (!config) {
throw new Error('Unable to find configuration for ', PACKAGE_NAME);
}

console.log('build - ', PACKAGE_NAME);
console.log('ouput - ', FILENAME);

const config = packageConfig[PACKAGE_NAME];

module.exports = {
banner: createBanner(PACKAGE_NAME),
input: path.join(directory.SOURCE, PACKAGE_NAME, 'index.js'),
output: [{
file: path.join(directory.BUILD, FILENAME),
file: path.join(directory.BUILD, FILENAME + '.js'),
format: 'cjs',
}],
globals: config.globals,
external: Object.keys(config.globals || {}).concat(PACKAGE_LIST),
paths: renameImports(),
paths: renameImports,
plugins: [
nodeResolve(),
cleanup({
Expand Down

0 comments on commit e11887c

Please sign in to comment.