-
Notifications
You must be signed in to change notification settings - Fork 158
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[fixed] bower building and publishing
- Loading branch information
Showing
2 changed files
with
76 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); |