Comparing version 1.5.0 to 1.5.1
71
index.js
@@ -6,2 +6,3 @@ var path = require('path'); | ||
var _ = require('underscore'); | ||
var semver = require('semver'); | ||
@@ -100,23 +101,59 @@ module.exports = function (opts, callback) { | ||
// remove old installer and zips from whitelist | ||
if (pkg.files) { | ||
pkg.files = _.filter(pkg.files, function (file) { | ||
if (newPkg.files) { | ||
// remove old installer and zips from whitelist | ||
pkg.files = (_.isArray(pkg.files) ? _.filter(pkg.files, function (file) { | ||
return (file !== 'appc-npm' && !/\.zip$/.test(file)); | ||
}).concat(newPkg.files); | ||
}) : []).concat(newPkg.files); | ||
// sort for testing | ||
pkg.files.sort(); | ||
} | ||
// don't overwrite | ||
_.defaults(pkg, newPkg); | ||
// update version if it is greater | ||
if (newPkg.version && (!pkg.version || semver.lt(pkg.version, newPkg.version))) { | ||
pkg.version = newPkg.version; | ||
} else if (!pkg.version) { | ||
pkg.version = '1.0.0'; | ||
} | ||
// do overwrite version, falling back to 1.0.0 | ||
pkg.version = newPkg.version || pkg.version || '1.0.0'; | ||
if (!_.isObject(pkg['appc-npm'])) { | ||
pkg['appc-npm'] = {}; | ||
} | ||
// do overwrite unzip | ||
if (pkg['appc-npm'].unzip) { | ||
// overwrite unzip | ||
if (newPkg['appc-npm'].unzip) { | ||
pkg['appc-npm'].unzip = newPkg['appc-npm'].unzip; | ||
// sort for testing | ||
pkg['appc-npm'].unzip.sort(); | ||
} | ||
// overwrite target | ||
if (newPkg['appc-npm'].target) { | ||
pkg['appc-npm'].target = newPkg['appc-npm'].target; | ||
} | ||
// do not overwrite ignore | ||
if (newPkg['appc-npm'].ignore && !pkg['appc-npm'].ignore) { | ||
pkg['appc-npm'].ignore = newPkg['appc-npm'].ignore; | ||
} | ||
// sort for testing | ||
if (pkg['appc-npm'].ignore) { | ||
pkg['appc-npm'].ignore.sort(); | ||
} | ||
// don't overwrite other keys | ||
_.defaults(pkg, newPkg); | ||
// fallback name | ||
pkg.name = pkg.name || type.prefix + '-' + path.basename(src); | ||
if (!pkg.name) { | ||
pkg.name = type.prefix + '-' + path.basename(src); | ||
} | ||
// name must be in lower case | ||
pkg.name = pkg.name.toLowerCase(); | ||
// do not overwrite scripts | ||
if (typeof pkg.scripts !== 'object') { | ||
@@ -126,3 +163,3 @@ pkg.scripts = {}; | ||
// don't overwrite postinstall | ||
// do not overwrite postinstall | ||
if (!pkg.scripts.postinstall) { | ||
@@ -133,9 +170,8 @@ pkg.scripts.postinstall = 'node ./appc-npm'; | ||
// ensure keywords | ||
var keywords = ['appcelerator', 'appc-npm', type.prefix]; | ||
if (typeof pkg['appc-npm'].target === 'string') { | ||
if (_.isObject(pkg['appc-npm'])) { | ||
keywords = keywords.concat(_.keys(pkg['appc-npm'].target)); | ||
} else { | ||
keywords.push('arrow', 'alloy', 'titanium'); | ||
} else { | ||
keywords = keywords.concat(_.keys(pkg['appc-npm'].target)); | ||
} | ||
@@ -157,2 +193,5 @@ | ||
// sort for better testing | ||
pkg.keywords.sort(); | ||
return next(); | ||
@@ -159,0 +198,0 @@ }, |
@@ -32,3 +32,5 @@ var path = require('path'); | ||
}, | ||
ignore: ignore | ||
// sort for testing | ||
ignore: ignore.sort() | ||
} | ||
@@ -35,0 +37,0 @@ }; |
@@ -34,3 +34,5 @@ var path = require('path'); | ||
}, | ||
ignore: ignore | ||
// sort for testing | ||
ignore: ignore.sort() | ||
} | ||
@@ -37,0 +39,0 @@ }; |
@@ -47,4 +47,12 @@ var path = require('path'); | ||
var version = [0, 0, 0]; | ||
_.each(pkgs, function (platformPkg, platform) { | ||
var platformVersion = platformPkg.version.split('.'); | ||
// sum version | ||
version[0] += parseInt(platformVersion[0] || 0, 10); | ||
version[1] += parseInt(platformVersion[1] || 0, 10); | ||
version[2] += parseInt(platformVersion[2] || 0, 10); | ||
if (!pkg) { | ||
@@ -55,7 +63,2 @@ pkg = platformPkg; | ||
// uses highest | ||
if (semver.gt(platformPkg.version, pkg.version)) { | ||
pkg.version = platformPkg.version; | ||
} | ||
// append files | ||
@@ -68,2 +71,8 @@ pkg['appc-npm'].unzip.push(platformPkg['appc-npm'].unzip[0]); | ||
pkg.version = version.join('.'); | ||
// sort for testing | ||
pkg['appc-npm'].unzip.sort(); | ||
pkg.files.sort(); | ||
return callback(null, pkg); | ||
@@ -74,2 +83,5 @@ }); | ||
// sort for testing | ||
pkg.files.sort(); | ||
return callback(null, pkg); | ||
@@ -76,0 +88,0 @@ }); |
@@ -32,3 +32,5 @@ var path = require('path'); | ||
}, | ||
ignore: ignore | ||
// sort for testing | ||
ignore: ignore.sort() | ||
} | ||
@@ -35,0 +37,0 @@ }; |
{ | ||
"name": "appc-npm", | ||
"version": "1.5.0", | ||
"version": "1.5.1", | ||
"description": "Package components for Appcelerator Titanium, Alloy and Arrow projects for distribution via NPM.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -27,2 +27,4 @@ # Appcelerator NPM Distribution ![EXPERIMENTAL](https://img.shields.io/badge/status-experimental-green.svg?style=flat-square) | ||
> **NOTE:** You probably want to check `package.json` before you publish and set or update [fields](https://docs.npmjs.com/files/package.json) like `description`, `homepage`, `bugs`, `license`, `repository`. | ||
## Use | ||
@@ -82,3 +84,3 @@ | ||
Reads the `manifest` to populate the `package.json`, using `ti-module-<moduleid>` as name and the greatest version found for all platforms as the package version. | ||
Reads the `manifest` to populate the `package.json`, using `ti-module-<moduleid>` as name. It wil sum the versions of all platforms to be the package version. | ||
@@ -85,0 +87,0 @@ > **NOTE:** Only the most recent ZIP file of each platform and the `appc-npm` installer are added to the `package.json`'s `files` property so that only these will be packaged and published to NPM and not the full module source. |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
28547
480
148