Skip to content

Commit

Permalink
Building as npm package
Browse files Browse the repository at this point in the history
  • Loading branch information
pramodsum committed Oct 18, 2017
1 parent 6780f4e commit 3fdeabb
Show file tree
Hide file tree
Showing 13 changed files with 1,165 additions and 511 deletions.
13 changes: 10 additions & 3 deletions .babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,25 @@
"transform-decorators-legacy"
],
"env": {
"npm": {
"plugins": [
[
"babel-plugin-transform-require-ignore", {
"extensions": [".scss", ".css"]
}
]
]
},
"test": {
"plugins": [
["istanbul", {
"exclude": [
"**/*-test.js",
"build/**",
"src/polyfill.js",
"src/browser.js",
]
}],
["babel-plugin-transform-require-ignore", { "extensions": [".scss"] }]
]
}
},
}
}
6 changes: 1 addition & 5 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,7 @@
"sinon": false,
"assert": false,
"fixture": false,
"__": false,
"PDFJS": false,
"Box": false,
"DocumentTouch": false,
"ActiveXObject": false
"__": false
},
"rules": {
"quotes": [
Expand Down
36 changes: 36 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
*~
.vimrc
.sublime-project
.swp
coverage
reports
desktop.ini
npm-debug.log
yarn-debug.log
.npmrc
Thumbs.db
.idea
src
.babelrc
.DS_Store
.editorconfig
.eslintrc.json
.eslintrc
.git
.gitignore
.npmignore
.stylelintignore
.stylelintrc
.vscode
.yarnrc
build
postcss.config.js
reports
test
yarn.lock
.travis.yml
flow
.flowconfig
browserslist
.conventional-changelog-lintrc
*~~bak
7 changes: 7 additions & 0 deletions src/lib/README.md → README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
[![Project Status](https://img.shields.io/badge/status-active-brightgreen.svg?style=flat-square)](http://opensource.box.com/badges/)
[![Styled With Prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)
[![build status](https://img.shields.io/travis/box/box-content-preview/master.svg?style=flat-square)](https://travis-ci.org/box/box-annotations)
[![version](https://img.shields.io/badge/version-v0.0.0-blue.svg?style=flat-square)](https://github.com/box/box-annotations)
[![npm version](https://img.shields.io/npm/v/box-ui-elements.svg?style=flat-square)](https://www.npmjs.com/package/box-ui-elements)


[Box Annotations](https://developer.box.com/docs/getting-started-with-new-box-view#section-annotations)
====================================================================
Box Annotations allow developers to provide collaboration capabilities right from within the embedded Box preview in their application. Box Annotations fit a wide range of use cases and can be used to draw the previewer's attention and/or provide feedback on specific parts of a document or images. To learn more about Box Content Preview and for further documentation on how to use it, please go to our page on [Box Content Preview](https://developer.box.com/docs/box-content-preview).
Expand Down
17 changes: 0 additions & 17 deletions build/RsyncPlugin.js

This file was deleted.

Binary file removed build/closure-compiler-v20161201.jar
Binary file not shown.
9 changes: 9 additions & 0 deletions build/license.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module.exports = `Box UI Element
Copyright 2016-present, Box, Inc.
All rights reserved.
This source code is licensed under the Box Software License Agreement found
in the LICENSE file in the root directory of this source tree. Additional
third party license disclosures can be found in the THIRD_PARTY_LICENSES
file in the same directory.`;
220 changes: 220 additions & 0 deletions build/publish.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,220 @@
#!/bin/bash

# Temp version
VERSION="XXX"

install_dependencies() {
echo "--------------------------------------------------------"
echo "Installing all package dependencies"
echo "--------------------------------------------------------"
if yarn install; then
echo "----------------------------------------------------"
echo "Installed dependencies successfully."
echo "----------------------------------------------------"
else
echo "----------------------------------------------------"
echo "Error: Failed to run 'yarn install'!"
echo "----------------------------------------------------"
exit 1;
fi
}

lint_and_test() {
echo "----------------------------------------------------"
echo "Running linter for version" $VERSION
echo "----------------------------------------------------"
if yarn run lint; then
echo "----------------------------------------------------"
echo "Done linting for version" $VERSION
echo "----------------------------------------------------"
else
echo "----------------------------------------------------"
echo "Failed linting!"
echo "----------------------------------------------------"
exit 1;
fi


echo "----------------------------------------------------"
echo "Running flow for version" $VERSION
echo "----------------------------------------------------"
if yarn run flow; then
echo "----------------------------------------------------"
echo "Done flowing for version" $VERSION
echo "----------------------------------------------------"
else
echo "----------------------------------------------------"
echo "Failed flowing!"
echo "----------------------------------------------------"
exit 1;
fi


echo "----------------------------------------------------"
echo "Running tests for version" $VERSION
echo "----------------------------------------------------"
if yarn run test; then
echo "----------------------------------------------------"
echo "Done testing for version" $VERSION
echo "----------------------------------------------------"
else
echo "----------------------------------------------------"
echo "Failed testing!"
echo "----------------------------------------------------"
exit 1;
fi
}

clean_assets() {
echo "----------------------------------------------------"
echo "Running clean for version" $VERSION
echo "----------------------------------------------------"
if yarn run clean; then
echo "----------------------------------------------------"
echo "Done cleaning for version" $VERSION
echo "----------------------------------------------------"
else
echo "----------------------------------------------------"
echo "Failed cleaning!"
echo "----------------------------------------------------"
exit 1;
fi
}

build_assets() {
echo "----------------------------------------------------"
echo "Starting babel build for version" $VERSION
echo "----------------------------------------------------"
if yarn run build-lib; then
echo "----------------------------------------------------"
echo "Built babel assets for version" $VERSION
echo "----------------------------------------------------"
else
echo "----------------------------------------------------"
echo "Failed to build production assets!"
echo "----------------------------------------------------"
exit 1;
fi
}

push_to_npm() {
echo "---------------------------------------------------------"
echo "Running npm publish for version" $VERSION
echo "---------------------------------------------------------"
if npm publish; then
echo "--------------------------------------------------------"
echo "Published version" $VERSION
echo "--------------------------------------------------------"
else
echo "----------------------------------------------------"
echo "Error publishing to npm registry!"
echo "----------------------------------------------------"
exit 1;
fi
}

add_remote() {
# Add the release remote if it is not present
if git remote get-url release; then
git remote remove release || return 1
fi
git remote add release [email protected]:box/box-annotations.git || return 1
}

publish_to_npm() {
if [[ $(git diff --shortstat 2> /dev/null | tail -n1) != "" ]] ; then
echo "----------------------------------------------------"
echo "Your branch is dirty!"
echo "----------------------------------------------------"
exit 1
fi

if ! add_remote; then
echo "----------------------------------------------------"
echo "Error in add_remote!"
echo "----------------------------------------------------"
exit 1
fi

git checkout master || exit 1
git fetch release || exit 1
git reset --hard release/master || exit 1
# Remove old local tags in case a build failed
git fetch --prune release '+refs/tags/*:refs/tags/*' || exit 1
git clean -fdX || exit 1

VERSION=$(./build/current_version.sh)

if [[ $(git status --porcelain 2>/dev/null| grep "^??") != "" ]] ; then
echo "----------------------------------------------------"
echo "Your branch has untracked files!"
echo "----------------------------------------------------"
exit 1
fi

if [[ $(git status --porcelain 2>/dev/null| egrep "^(M| M)") != "" ]] ; then
echo "----------------------------------------------------"
echo "Your branch has uncommited files!"
echo "----------------------------------------------------"
exit 1
fi

echo "----------------------------------------------------"
echo "Checking out version" $VERSION
echo "----------------------------------------------------"
# Check out the version we want to build (version tags are prefixed with a v)
git checkout v$VERSION || exit 1

# Install node modules
if ! install_dependencies; then
echo "----------------------------------------------------"
echo "Error in install_dependencies!"
echo "----------------------------------------------------"
exit 1
fi

# Do testing and linting
if ! clean_assets; then
echo "----------------------------------------------------"
echo "Error in clean_assets!"
echo "----------------------------------------------------"
exit 1
fi

# Do testing and linting
if ! lint_and_test; then
echo "----------------------------------------------------"
echo "Error in lint_and_test!"
echo "----------------------------------------------------"
exit 1
fi

# Babel build
if ! build_assets; then
echo "----------------------------------------------------"
echo "Error in build_assets!"
echo "----------------------------------------------------"
exit 1
fi

# Publish
if ! push_to_npm; then
echo "----------------------------------------------------"
echo "Error in push_to_npm!"
echo "----------------------------------------------------"
exit 1
fi
}

# Execute this entire script
if ! publish_to_npm; then
echo "----------------------------------------------------"
echo "Error: failure in publish_to_npm!"
echo "----------------------------------------------------"
exit 1
fi

echo "----------------------------------------------------"
echo "Checking out back to master"
echo "----------------------------------------------------"
git checkout master || exit 1
4 changes: 2 additions & 2 deletions build/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ update_readme() {
# Replace 'v{VERSION}' string
sed -i -e "s@v$OLD_VERSION@v$VERSION@g" README.md

# Replace 'preview/{VERSION}' string
sed -i -e "s@preview/$OLD_VERSION@preview/$VERSION@g" README.md
# Replace 'annotations/{VERSION}' string
sed -i -e "s@annotations/$OLD_VERSION@annotations/$VERSION@g" README.md

rm README.md-e
}
Expand Down
Loading

0 comments on commit 3fdeabb

Please sign in to comment.