Skip to content

Commit

Permalink
Add standalone Meteor package and Travis
Browse files Browse the repository at this point in the history
  • Loading branch information
dandv committed Dec 16, 2014
1 parent 79b50f5 commit 9bdd205
Show file tree
Hide file tree
Showing 8 changed files with 111 additions and 54 deletions.
11 changes: 9 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
language: node_js
node_js:
- 0.10

node_js: 0.10

before_script:
- node --version
- npm --version
- npm install -g grunt-cli

# Install meteor
- curl https://install.meteor.com | /bin/sh
# Install spacejam, Meteor's CI helper
- npm install -g spacejam

script: grunt test --verbose
20 changes: 6 additions & 14 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,9 @@ module.exports = function (grunt) {
},

// Meteor commands to test and publish package
shell: {
exec: {
'meteor-test': {
command: 'meteor/runtests.sh',
options: {
execOptions: {
killSignal: 'SIGKILL'
}
}
command: 'meteor/runtests.sh'
},
'meteor-publish': {
command: 'meteor/publish.sh'
Expand All @@ -132,7 +127,7 @@ module.exports = function (grunt) {
grunt.loadTasks('build');

// test: unit test on test folder
grunt.registerTask('test', ['jshint', 'qunit']);
grunt.registerTask('test', ['jshint', 'qunit', 'meteor-test']);

// dist
grunt.registerTask('dist', ['build', 'test', 'uglify', 'recess']);
Expand All @@ -141,11 +136,8 @@ module.exports = function (grunt) {
grunt.registerTask('default', ['dist']);

// Meteor tasks
grunt.registerTask('meteor-test', 'shell:meteor-test');
grunt.registerTask('meteor-publish', 'shell:meteor-publish');
// Ideally we'd run tests before publishing, but the chances of tests breaking (given that
// Meteor is orthogonal to the library) are so small that it's not worth the maintainer's time
// grunt.regsterTask('meteor', ['shell:meteor-test', 'shell:meteor-publish']);
grunt.registerTask('meteor', 'shell:meteor-publish');
grunt.registerTask('meteor-test', 'exec:meteor-test');
grunt.registerTask('meteor-publish', 'exec:meteor-publish');
grunt.registerTask('meteor', ['meteor-test', 'meteor-publish']);

};
15 changes: 10 additions & 5 deletions meteor/README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
Packaging [http://hackerwins.github.io/summernote/](http://hammerjs.github.io/) for [Meteor.js](http://meteor.com).
Build + Meteor status: [![Build Status](https://travis-ci.org/MeteorPackaging/summernote.svg?branch=meteor-integration)](https://github.com/MeteorPackaging/summernote/tree/meteor-integration/meteor)

Packaging [summernote](http://hackerwins.github.io/summernote/) for [Meteor.js](http://meteor.com).

# Versions

* [summernote:summernote](https://atmospherejs.com/summernote/summernote) - includes jQuery and Bootstrap as dependencies
* [summernote:standalone](https://atmospherejs.com/summernote/standalone) - doesn't include any dependencies


# Meteor

If you're new to Meteor, here's what the excitement is all about -
[watch the first two minutes](https://www.youtube.com/watch?v=fsi0aJ9yr2o); you'll be hooked by 1:28.

That screencast is from 2012. In the meantime, Meteor has become a mature JavaScript-everywhere web
development framework. Read more at [Why Meteor](http://www.meteorpedia.com/read/Why_Meteor).

Expand All @@ -22,7 +28,6 @@ If you encounter an issue while using this package, please CC @dandv when you fi

# TODO

* Make sure library works with Meteor's reactivity - for example to auto-save to a collection
transparently after the text changes.

* Make sure the library works with Meteor's reactivity - for example to auto-save to a collection
transparently after the text changes.
* Tests ensuring correct event handling on template re-rendering
36 changes: 36 additions & 0 deletions meteor/package-standalone.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// package metadata file for Meteor.js
'use strict';

var packageName = 'summernote:standalone'; // http://atmospherejs.com/summernote:standalone
var where = 'client'; // where to install: 'client' or 'server'. For both, pass nothing.

var packageJson = JSON.parse(Npm.require("fs").readFileSync('package.json'));

Package.describe({
name: packageName,
summary: 'summernote standalone (official): WYSIWYG editor with embedded images support, packaged without deps',
version: packageJson.version,
git: 'https://github.com/HackerWins/summernote.git'
});

Package.onUse(function (api) {
api.versionsFrom(['[email protected]', '[email protected]']);
// no exports - summernote adds itself to jQuery
api.addFiles([
'dist/summernote.js',
'dist/summernote.css'
], where);
});

Package.onTest(function (api) {
// load dependencies for test only, before loading the package
api.use(['twbs:[email protected]', 'fortawesome:[email protected]'], where);

// load our package
api.use(packageName, where);

// load the test runner
api.use('tinytest', where);

api.addFiles('meteor/test.js', where);
});
44 changes: 26 additions & 18 deletions meteor/publish.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
# Publish package on Meteor's Atmospherejs.com
# Publish package to Meteor's repository, Atmospherejs.com

# Make sure Meteor is installed, per https://www.meteor.com/install.
# The curl'ed script is totally safe; takes 2 minutes to read its source and check.
Expand All @@ -8,25 +8,33 @@ type meteor >/dev/null 2>&1 || { curl https://install.meteor.com/ | sh; }
# sanity check: make sure we're in the root directory of the checkout
cd "$( dirname "$0" )/.."

# Meteor expects package.js in the root directory of the checkout, so copy it there temporarily
cp meteor/package.js .
ALL_EXIT_CODE=0

# publish package
PACKAGE_NAME=$(grep -i name package.js | head -1 | cut -d "'" -f 2)
# test any package*.js packages we may have, e.g. package.js, package-compat.js
for PACKAGE_FILE in meteor/package*.js; do

echo "Publishing $PACKAGE_NAME..."
# Meteor expects package.js to be in the root directory of the checkout, so copy there our package file under that name, temporarily
cp $PACKAGE_FILE ./package.js

# Attempt to re-publish the package - the most common operation once the initial release has
# been made. If the package name was changed (rare), you'll have to pass the --create flag.
meteor publish "$@"; EXIT_CODE=$?
if (( $EXIT_CODE == 0 )); then
echo "Thanks for releasing a new version. You can see it at"
echo "https://atmospherejs.com/${PACKAGE_NAME/://}"
else
echo "We got an error. Please post it at https://github.com/raix/Meteor-community-discussions/issues/14"
fi
# publish package, creating it if it's the first time we're publishing
PACKAGE_NAME=$(grep -i name package.js | head -1 | cut -d "'" -f 2)

# rm the temporary build files and package.js
rm -rf ".build.$PACKAGE_NAME" versions.json package.js
echo "Publishing $PACKAGE_NAME..."

exit $EXIT_CODE
# Attempt to re-publish the package - the most common operation once the initial release has
# been made. If the package name was changed (rare), you'll have to pass the --create flag.
meteor publish "$@"; EXIT_CODE=$?
ALL_EXIT_CODE=$(( $ALL_EXIT_CODE + $EXIT_CODE ))
if (( $EXIT_CODE == 0 )); then
echo "Thanks for releasing a new version. You can see it at"
echo "https://atmospherejs.com/${PACKAGE_NAME/://}"
else
echo "We got an error. Please post it at https://github.com/raix/Meteor-community-discussions/issues/14"
fi

# rm the temporary build files and package.js
rm -rf ".build.$PACKAGE_NAME" versions.json package.js

done

exit $ALL_EXIT_CODE
35 changes: 22 additions & 13 deletions meteor/runtests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,31 @@ type meteor >/dev/null 2>&1 || { curl https://install.meteor.com/ | sh; }
# sanity check: make sure we're in the root directory of the checkout
cd "$( dirname "$0" )/.."

# run tests and delete the temporary package.js even if Ctrl+C is pressed
int_trap() {
printf "\nTests interrupted. Hopefully you verified in the browser that tests pass?\n\n"
}
ALL_EXIT_CODE=0

trap int_trap INT
# test any package*.js packages we may have, e.g. package.js, package-standalone.js
for PACKAGE_FILE in meteor/package*.js; do

# Meteor expects package.js in the root directory of the checkout, so copy it there temporarily
cp meteor/package.js .
# Meteor expects package.js in the root dir of the checkout, so copy there our package file under that name, temporarily
cp $PACKAGE_FILE ./package.js

PACKAGE_NAME=$(grep -i name package.js | head -1 | cut -d "'" -f 2)
PACKAGE_NAME=$(grep -i name package.js | head -1 | cut -d "'" -f 2)

echo "Testing $PACKAGE_NAME..."
echo "### Testing $PACKAGE_NAME..."

# provide an invalid MONGO_URL so Meteor doesn't bog us down with an empty Mongo database
MONGO_URL=mongodb:// meteor test-packages ./
# provide an invalid MONGO_URL so Meteor doesn't bog us down with an empty Mongo database
if [ $# -gt 0 ]; then
# interpret any parameter to mean we want an interactive test
MONGO_URL=mongodb:// meteor test-packages ./
else
# automated/CI test with phantomjs
spacejam --mongo-url mongodb:// test-packages ./
ALL_EXIT_CODES=$(( $ALL_EXIT_CODES + $? ))
fi

# delete temporary build files and package.js
rm -rf ".build.*$PACKAGE_NAME" versions.json package.js
# delete temporary build files and package.js
rm -rf .build.* versions.json package.js

done

exit $ALL_EXIT_CODES
2 changes: 1 addition & 1 deletion meteor/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ Tinytest.add('Instantiation', function (test) {
document.body.appendChild(editor);
$(editor).summernote();

test.isTrue($(editor).code().length >= 3, 'Instantiation');
test.equal(typeof $(editor).code(), 'string', 'Instantiation');
});
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"grunt-recess": "*",
"grunt-contrib-watch": "*",
"grunt-contrib-connect": "*",
"grunt-shell": "^1.1.1",
"grunt-exec": "^0.4.6",
"connect-livereload": "*"
},
"dependencies": {
Expand Down

0 comments on commit 9bdd205

Please sign in to comment.