forked from SortableJS/Sortable
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Simplify Meteor packaging and add Windows support
- Loading branch information
Showing
6 changed files
with
147 additions
and
80 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
[email protected] | ||
[email protected] | ||
[email protected] | ||
[email protected] | ||
[email protected] | ||
[email protected] | ||
dburles:[email protected] | ||
[email protected] | ||
[email protected] | ||
[email protected] | ||
[email protected] | ||
[email protected] | ||
[email protected] | ||
[email protected] | ||
[email protected]_2 | ||
[email protected] | ||
lai:[email protected] | ||
local-test:rubaxa:[email protected] | ||
[email protected] | ||
[email protected] | ||
[email protected] | ||
[email protected] | ||
[email protected] | ||
[email protected] | ||
[email protected] | ||
[email protected] | ||
[email protected] | ||
[email protected] | ||
rubaxa:[email protected] | ||
[email protected] | ||
[email protected] | ||
[email protected] | ||
[email protected] | ||
[email protected] |
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 |
---|---|---|
@@ -1,35 +1,85 @@ | ||
// package metadata file for Meteor.js | ||
// Package metadata file for Meteor.js | ||
'use strict'; | ||
|
||
var packageName = 'rubaxa:sortable'; // http://atmospherejs.com/rubaxa/sortable | ||
var packageName = 'rubaxa:sortable'; // https://atmospherejs.com/rubaxa/sortable | ||
var gitHubPath = 'RubaXa/Sortable'; // https://github.com/RubaXa/Sortable | ||
var npmPackageName = 'sortablejs'; // https://www.npmjs.com/package/sortablejs - optional but recommended; used as fallback if GitHub fails | ||
|
||
var packageJson = JSON.parse(Npm.require("fs").readFileSync('package.json')); | ||
/* All of the below is just to get the version number of the 3rd party library. | ||
* First we'll try to read it from package.json. This works when publishing or testing the package | ||
* but not when running an example app that uses a local copy of the package because the current | ||
* directory will be that of the app, and it won't have package.json. Finding the path of a file is hard: | ||
* http://stackoverflow.com/questions/27435797/how-do-i-obtain-the-path-of-a-file-in-a-meteor-package | ||
* Therefore, we'll fall back to GitHub (which is more frequently updated), and then to NPMJS. | ||
* We also don't have the HTTP package at this stage, and if we use Package.* in the request() callback, | ||
* it will error that it must be run in a Fiber. So we'll use Node futures. | ||
*/ | ||
var request = Npm.require('request'); | ||
var Future = Npm.require('fibers/future'); | ||
|
||
var fut = new Future; | ||
var version; | ||
|
||
if (!version) try { | ||
var packageJson = JSON.parse(Npm.require('fs').readFileSync('../package.json')); | ||
version = packageJson.version; | ||
} catch (e) { | ||
// if the file was not found, fall back to GitHub | ||
console.warn('Could not find ../package.json to read version number from; trying GitHub...'); | ||
var url = 'https://api.github.com/repos/' + gitHubPath + '/tags'; | ||
request.get({ | ||
url: url, | ||
headers: { | ||
'User-Agent': 'request' // GitHub requires it | ||
} | ||
}, function (error, response, body) { | ||
if (!error && response.statusCode === 200) { | ||
var versions = JSON.parse(body).map(function (version) { | ||
return version['name'].replace(/^\D+/, '') // trim leading non-digits from e.g. "v4.3.0" | ||
}).sort(); | ||
fut.return(versions[versions.length -1]); | ||
} else { | ||
// GitHub API rate limit reached? Fall back to npmjs. | ||
console.warn('GitHub request to', url, 'failed:\n ', response && response.statusCode, response && response.body, error || '', '\nTrying NPMJS...'); | ||
url = 'http://registry.npmjs.org/' + npmPackageName + '/latest'; | ||
request.get(url, function (error, response, body) { | ||
if (!error && response.statusCode === 200) | ||
fut.return(JSON.parse(body).version); | ||
else | ||
fut.throw('Could not get version information from ' + url + ' either (incorrect package name?):\n' + (response && response.statusCode || '') + (response && response.body || '') + (error || '')); | ||
}); | ||
} | ||
}); | ||
|
||
version = fut.wait(); | ||
} | ||
|
||
// Now that we finally have an accurate version number... | ||
Package.describe({ | ||
name: packageName, | ||
summary: 'Sortable: reactive minimalist reorderable drag-and-drop lists on modern browsers and touch devices', | ||
version: packageJson.version, | ||
git: 'https://github.com/RubaXa/Sortable.git', | ||
documentation: 'meteor/README.md' | ||
name: packageName, | ||
summary: 'Sortable: reactive minimalist reorderable drag-and-drop lists on modern browsers and touch devices', | ||
version: version, | ||
git: 'https://github.com/RubaXa/Sortable.git', | ||
documentation: 'README.md' | ||
}); | ||
|
||
Package.onUse(function (api) { | ||
api.versionsFrom(['[email protected]', '[email protected]']); | ||
api.use('templating', 'client'); | ||
api.use('dburles:[email protected]'); // to watch collections getting created | ||
api.export('Sortable'); // exported on the server too, as a global to hold the array of sortable collections (for security) | ||
api.addFiles([ | ||
'Sortable.js', | ||
'meteor/template.html', // the HTML comes first, so reactivize.js can refer to the template in it | ||
'meteor/reactivize.js' | ||
], 'client'); | ||
api.addFiles('meteor/methods-client.js', 'client'); | ||
api.addFiles('meteor/methods-server.js', 'server'); | ||
api.versionsFrom(['[email protected]', '[email protected]']); | ||
api.use('templating', 'client'); | ||
api.use('dburles:[email protected]'); // to watch collections getting created | ||
api.export('Sortable'); // exported on the server too, as a global to hold the array of sortable collections (for security) | ||
api.addFiles([ | ||
'../Sortable.js', | ||
'template.html', // the HTML comes first, so reactivize.js can refer to the template in it | ||
'reactivize.js' | ||
], 'client'); | ||
api.addFiles('methods-client.js', 'client'); | ||
api.addFiles('methods-server.js', 'server'); | ||
}); | ||
|
||
Package.onTest(function (api) { | ||
api.use(packageName, 'client'); | ||
api.use('tinytest', 'client'); | ||
api.use(packageName, 'client'); | ||
api.use('tinytest', 'client'); | ||
|
||
api.addFiles('meteor/test.js', 'client'); | ||
api.addFiles('test.js', 'client'); | ||
}); |
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,8 @@ | ||
REM Test Meteor package before publishing to Atmospherejs.com | ||
@echo off | ||
|
||
REM Sanity check: make sure we're in the directory of the script | ||
set DIR=%~dp0 | ||
cd %DIR% | ||
|
||
meteor test-packages ./ %* |
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