Skip to content
Browse files

[fixed] bower building and publishing

  • Loading branch information...
1 parent c182385 commit f80082bb42df2af3005754b8b92e102f7cb0e74c @AlexKVal AlexKVal committed
Showing with 76 additions and 1 deletion.
  1. +6 −1 package.json
  2. +70 −0 scripts/bower-prepare.js
View
7 package.json
@@ -5,11 +5,12 @@
"main": "./lib/index.js",
"scripts": {
"prepublish": "npm run build",
- "build": "babel src --out-dir=lib && webpack && webpack -p",
+ "build": "babel src --out-dir=lib && webpack && webpack -p && npm run bower-prepare",
"test": "npm run lint && karma start --single-run",
"tdd": "karma start",
"visual-test": "open http://localhost:8080/ && webpack-dev-server --config webpack.visual.config.babel.js",
"lint": "eslint *.babel.js src tests",
+ "bower-prepare": "babel-node scripts/bower-prepare.js",
"release": "release"
},
"repository": {
@@ -40,6 +41,7 @@
"babel-eslint": "^4.1.3",
"babel-loader": "^5.3.2",
"bootstrap": "^3.3.5",
+ "colors": "^1.1.2",
"css-loader": "^0.19.0",
"es5-shim": "^4.1.14",
"eslint": "1.6.x",
@@ -60,6 +62,7 @@
"karma-webpack": "^1.7.0",
"less": "^2.5.3",
"less-loader": "^2.2.1",
+ "lodash": "^3.10.1",
"mocha": "^2.3.3",
"mt-changelog": "^0.6.2",
"node-libs-browser": "^0.5.3",
@@ -69,6 +72,8 @@
"react-dom": "^0.14.0",
"react-router": "^1.0.0-rc3",
"release-script": "^0.5.3",
+ "rimraf": "^2.4.3",
+ "shelljs": "^0.5.3",
"style-loader": "^0.12.4",
"url-loader": "^0.5.6",
"webpack": "^1.12.2",
View
70 scripts/bower-prepare.js
@@ -0,0 +1,70 @@
+/* globals cat, config, cp, mkdir, rm, test */
+/* eslint curly: 0 */
+import 'colors';
+import 'shelljs/global';
+import path from 'path';
+import _ from 'lodash';
+import yargs from 'yargs';
+
+// do not die on errors
+config.fatal = false;
+
+//------------------------------------------------------------------------------
+// constants
+const repoRoot = path.resolve(__dirname, '../');
+const libFolder = path.join(repoRoot, 'lib');
+const bowerRoot = path.join(repoRoot, 'amd');
+const bowerTemplate = path.join(repoRoot, 'bower.template.json');
+const license = path.join(repoRoot, 'LICENSE');
+
+
+//------------------------------------------------------------------------------
+// command line options
+const argv = yargs
+ .usage('Usage: $0 [--verbose]')
+ .example('$0', 'Prepare bower package for releasing')
+ .option('verbose', {
+ demand: false,
+ default: false,
+ describe: 'Increased debug output'
+ })
+ .argv;
+
+if (argv.dryRun) console.log('DRY RUN'.magenta);
+
+config.silent = !argv.verbose;
+
+
+//------------------------------------------------------------------------------
+// functions
+function bower() {
+ console.log('Creating: '.cyan + 'bower package'.green);
+
+ rm('-rf', bowerRoot);
+ mkdir('-p', bowerRoot);
+
+ // generate bower.json from template
+ const pkg = JSON.parse(cat(path.join(repoRoot, 'package.json')));
+ const template = _.template(cat(bowerTemplate));
+ const bowerConfigObject = template({ pkg });
+ const json = JSON.stringify(JSON.parse(bowerConfigObject), null, 2); // proper formatting hack
+ json.to(path.join(bowerRoot, 'bower.json'));
+
+ // copy readme and license
+ const readmeBower = path.join(repoRoot, 'README.bower.md');
+ const readme = path.join(repoRoot, 'README.md');
+ if (test('-e', readmeBower)) {
+ cp(readmeBower, path.join(bowerRoot, 'README.md'));
+ } else {
+ cp(readme, bowerRoot);
+ }
+ if (test('-e', license)) cp(license, bowerRoot);
+
+ // copy distr files
+ cp('-r', libFolder, bowerRoot);
+
+ console.log('Created: '.cyan + 'bower package'.green);
+}
+
+//------------------------------------------------------------------------------
+bower();

0 comments on commit f80082b

Please sign in to comment.
Something went wrong with that request. Please try again.