Skip to content

Instantly share code, notes, and snippets.

@dotansimha
Last active August 29, 2015 14:24
Show Gist options
  • Save dotansimha/217c24ec1e5c10fbec29 to your computer and use it in GitHub Desktop.
Save dotansimha/217c24ec1e5c10fbec29 to your computer and use it in GitHub Desktop.
meteor-package-publisher for all AngularJS packages for specific version
var MeteorPublisher = require('./lib/publisher');
var _ = require('lodash');
var version = '1.4.2'; // bower version
var depVersion = "1.4.2"; // atmosphere version
var packages = ['angular-animate', 'angular-sanitize', 'angular-touch', 'angular-scenario', 'angular-route', 'angular-resource', 'angular-mocks', 'angular-loader', 'angular-cookies', 'angular-messages','angular-aria']; // sub-packages, will depend on the original angular:angular package
var runNextPackage;
var basePackage = {
"source": {
"type": "bower",
"name": "",
"version": version.toString()
},
"destination": {
"atmospherePackageName": "",
"atmosphereOrganizationName": "angular",
"summary": "AngularJS (official) release. For full solution: http://angular-meteor.com/",
"git": "",
"documentation": "README.md",
"versionsFrom": "[email protected]",
"filesToAdd": [
],
"use": [
]
}
};
var publishBaseAngular = function() {
var data = {
"source": {
"type": "bower",
"name": "angular",
"version": version.toString()
},
"destination": {
"atmospherePackageName": "angular",
"atmosphereOrganizationName": "angular",
"summary": "AngularJS (official) release. For full solution: http://angular-meteor.com/",
"git": "https://github.com/angular/bower-angular",
"documentation": "README.md",
"versionsFrom": "[email protected]",
"filesToAdd": [
{"name": "angular.js", "platforms": ["client"]}
],
"use": [
{"name": "[email protected]_2", "platforms": ["client"], "weak": true}
]
}
};
var publisher = new MeteorPublisher();
publisher.setDestination(data.destination);
var sourceParser = publisher.analyse(data);
sourceParser.clean();
sourceParser.load(data.source.name, data.source.version).then(function (sourceData) {
publisher.setSource(sourceData);
try {
publisher.test();
publisher.createPackageFile().then(function () {
publisher.publish().then(function () {
runNextPackage(packages, 0);
}, function() {
console.log('rejected');
})
});
}
catch (error) {
console.error(error);
}
});
};
runNextPackage = function (packagesArray, key) {
if (!packagesArray[key]) {
console.info('done!');
return;
}
var packageName = packagesArray[key];
var data = _.clone(basePackage);
data.source.name = packageName;
data.destination.atmospherePackageName = packageName;
data.destination.git = "https://github.com/angular/bower-" + packageName;
data.destination.use[0] = {name: "angular:angular@=" + depVersion, "platforms": ["client"]};
data.destination.filesToAdd[0] = {"name": packageName + ".js", "platforms": ["client"]};
var publisher = new MeteorPublisher();
publisher.setDestination(data.destination);
var sourceParser = publisher.analyse(data);
if (key === 0) {
sourceParser.clean();
}
sourceParser.load(data.source.name, data.source.version).then(function (sourceData) {
publisher.setSource(sourceData);
try {
publisher.test();
publisher.createPackageFile().then(function () {
publisher.publish().then(function () {
runNextPackage(packagesArray, key + 1);
}, function() {
console.log('rejected');
})
});
}
catch (error) {
console.error(error);
}
});
};
publishBaseAngular();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment