Stop bundling NodeJS in the package

This commit is contained in:
Juan Cruz Viotti 2015-03-04 12:16:35 -04:00
parent dac2e0a302
commit a1e6c6cda5
7 changed files with 2 additions and 345 deletions

View File

@ -1,48 +0,0 @@
distribute-win32: release/build/distrib/resin-cli-win32.zip
distribute-darwin: release/build/distrib/resin-cli-darwin.tar.gz
distribute-linux: release/build/distrib/resin-cli-linux.tar.gz
installer-win32: release/build/distrib/resin-cli-setup.exe
installer-osx: release/build/distrib/resin-cli-setup.pkg
VERSION=0.0.1
release/build/resin-cli-%:
mkdir -p $@
cp -rf bin build package.json $@ && rm -rf $@/bin/node
cd $@ && RESIN_BUNDLE=$(subst resin-cli-,,`basename $@`) npm install --production --force
flatten-packages $@
release/build/distrib/resin-cli-win32.zip: release/build/resin-cli-win32
mkdir -p `dirname $@`
cd $< && zip -r ../../../$@ .
release/build/distrib/resin-cli-darwin.tar.gz: release/build/resin-cli-darwin
mkdir -p `dirname $@`
tar fcz $@ -C `dirname $<` `basename $<`
release/build/distrib/resin-cli-linux.tar.gz: release/build/resin-cli-linux
mkdir -p `dirname $@`
tar fcz $@ -C `dirname $<` `basename $<`
release/build/distrib/resin-cli-setup.exe: release/installers/win32/resin-cli.nsi release/build/distrib/resin-cli-win32.zip
makensis $<
release/build/cli.pkg: release/build/resin-cli-darwin
pkgbuild --root $< \
--identifier io.resin.cli \
--scripts release/installers/osx/scripts \
--version $(VERSION) \
--ownership recommended \
$@
release/build/distrib/resin-cli-setup.pkg: release/build/cli.pkg release/installers/osx/distribution.xml
mkdir -p `dirname $@`
productbuild --distribution $(word 2, $^) \
--resources release/installers/osx/resources \
--package-path `dirname $<` \
--version $(VERSION) \
$@
clean:
rm -rf release/build

View File

@ -40,16 +40,6 @@ If you set `DEBUG` environment variable, errors will print with a stack trace:
$ DEBUG=true resin ... $ DEBUG=true resin ...
``` ```
## Release
The following command will compile the application into a single executable for the current platform (supports Mac OS X, GNU/Linux and Windows > XP):
```sh
$ gulp release
```
The binary will be located at `build/Release`.
## Documentation ## Documentation
You can renegerate the documentation with: You can renegerate the documentation with:

View File

@ -1,64 +1,2 @@
#!/bin/bash #!/usr/bin/env node
require('../build/app');
function unsupported_platform() {
echo "Your platform (`uname -a`) is not supported." && exit 1
}
# Detect CPU arch.
ARCHITECTURE=`uname -m`
case "$ARCHITECTURE" in
i?86) ARCHITECTURE="x86" ;;
x86_64) ARCHITECTURE="x64" ;;
esac
# Detect current OS, see http://stackoverflow.com/q/3466166/682252.
# Darwin
if [ "`uname`" == "Darwin" ]; then
NODE_BIN="node-darwin-$ARCHITECTURE"
# Linux
elif [ "`expr substr $(uname -s) 1 5`" == "Linux" ]; then
NODE_BIN="node-linux-$ARCHITECTURE"
# Win32
elif [ "`expr substr $(uname -s) 1 10`" == "MINGW32_NT" ]; then
NODE_BIN="node-win32-$ARCHITECTURE.exe"
# SunOS
elif [ "`uname`" == "SunOS" ]; then
NODE_BIN="node-sunos-$ARCHITECTURE"
else
unsupported_platform
fi
BIN_RESIN=$0
while [ -L "$BIN_RESIN" ]; do
BIN_RESIN=`readlink "$BIN_RESIN"`
done
# If a link was resolved (ie BIN_RESIN != $0) and the resolved link is relative,
# we assume the link is relative to the dirname of the link location
if [[ "$BIN_RESIN" != "$0" ]] && [[ "$BIN_RESIN" != /* ]]; then
BIN_RESIN=`dirname $0`/$BIN_RESIN
fi
BIN_DIRECTORY=`dirname $BIN_RESIN`
NODE_PATH=$BIN_DIRECTORY/node/$NODE_BIN
if [ ! -x $NODE_PATH ]; then
echo "Warning: $NODE_PATH does not exist"
# As a last resource, try to use an already available node
if command -v node >/dev/null 2>&1; then
NODE_PATH="node"
else
unsupported_platform
fi
fi
$NODE_PATH "$BIN_DIRECTORY/../build/app.js" "$@"

View File

@ -1,12 +0,0 @@
@echo off
:: http://stackoverflow.com/questions/12322308/batch-file-to-check-64bit-or-32bit-os
reg Query "HKLM\Hardware\Description\System\CentralProcessor\0" | find /i "x86" > NUL && set ARCH=x86 || set ARCH=x64
set NODE_PATH="%~dp0\node\node-win32-%ARCH%.exe"
@IF NOT EXIST %NODE_PATH% (
set NODE_PATH="node.exe"
)
%NODE_PATH% "%~dp0\..\build\app.js" %*

View File

@ -1,128 +0,0 @@
(function() {
var DESTINATION, NODE_VERSION, RESIN_BUNDLE, async, binary, bundle, bundles, fs, getNodeName, i, len, nodeDownload, path;
async = require('async');
binary = require('node-binary');
fs = require('fs');
path = require('path');
DESTINATION = process.argv[2];
if (DESTINATION == null) {
console.error('Missing destination argument');
process.exit(1);
}
NODE_VERSION = require('../package.json').bundled_engine;
RESIN_BUNDLE = process.env.RESIN_BUNDLE;
if ((RESIN_BUNDLE == null) || RESIN_BUNDLE === 'current') {
bundles = [
{
os: process.platform,
arch: process.arch,
version: NODE_VERSION
}
];
} else if (RESIN_BUNDLE === 'darwin') {
bundles = [
{
os: 'darwin',
arch: 'x86',
version: NODE_VERSION
}, {
os: 'darwin',
arch: 'x64',
version: NODE_VERSION
}
];
} else if (RESIN_BUNDLE === 'linux') {
bundles = [
{
os: 'linux',
arch: 'x86',
version: NODE_VERSION
}, {
os: 'linux',
arch: 'x64',
version: NODE_VERSION
}
];
} else if (RESIN_BUNDLE === 'win32') {
bundles = [
{
os: 'win32',
arch: 'x86',
version: NODE_VERSION
}, {
os: 'win32',
arch: 'x64',
version: NODE_VERSION
}
];
} else {
console.error("Unknown RESIN_BUNDLE value: " + RESIN_BUNDLE);
process.exit(1);
}
getNodeName = function(options) {
var result;
result = "node-" + options.os + "-" + options.arch;
if (options.os === 'win32') {
result += '.exe';
}
return result;
};
console.info('Installing the following NodeJS bundles:');
for (i = 0, len = bundles.length; i < len; i++) {
bundle = bundles[i];
console.info("- " + (getNodeName(bundle)));
}
nodeDownload = function(destination, options, callback) {
var error;
try {
return binary.download(options, destination, function(error, binaryPath) {
var output;
if (error != null) {
return callback(error);
}
output = path.join(destination, getNodeName(options));
return fs.rename(binaryPath, output, function(error) {
if (error != null) {
return callback(error);
}
return callback(null, output);
});
});
} catch (_error) {
error = _error;
return callback(error);
}
};
async.eachLimit(bundles, 2, function(bundle, callback) {
console.info("Downloading: " + (getNodeName(bundle)) + " to " + DESTINATION);
return nodeDownload(DESTINATION, bundle, function(error, output) {
if (error != null) {
return callback(error);
}
console.info("Downloaded: " + (getNodeName(bundle)) + " to " + output);
return callback();
});
}, function(error) {
if (error != null) {
console.error(error.message);
return console.error('Error: Couldn\'t get the required node bundle. Omitting.');
} else {
return console.info('All NodeJS bundles downloaded');
}
});
}).call(this);

View File

@ -1,80 +0,0 @@
async = require('async')
binary = require('node-binary')
fs = require('fs')
path = require('path')
DESTINATION = process.argv[2]
if not DESTINATION?
console.error('Missing destination argument')
process.exit(1)
NODE_VERSION = require('../package.json').bundled_engine
RESIN_BUNDLE = process.env.RESIN_BUNDLE
# This will install only the correct node version for the current system,
if not RESIN_BUNDLE? or RESIN_BUNDLE is 'current'
bundles = [
os: process.platform
arch: process.arch
version: NODE_VERSION
]
else if RESIN_BUNDLE is 'darwin'
bundles = [
{ os: 'darwin', arch: 'x86', version: NODE_VERSION }
{ os: 'darwin', arch: 'x64', version: NODE_VERSION }
]
else if RESIN_BUNDLE is 'linux'
bundles = [
{ os: 'linux', arch: 'x86', version: NODE_VERSION }
{ os: 'linux', arch: 'x64', version: NODE_VERSION }
]
else if RESIN_BUNDLE is 'win32'
bundles = [
{ os: 'win32', arch: 'x86', version: NODE_VERSION }
{ os: 'win32', arch: 'x64', version: NODE_VERSION }
]
else
console.error("Unknown RESIN_BUNDLE value: #{RESIN_BUNDLE}")
process.exit(1)
getNodeName = (options) ->
result = "node-#{options.os}-#{options.arch}"
result += '.exe' if options.os is 'win32'
return result
console.info 'Installing the following NodeJS bundles:'
for bundle in bundles
console.info "- #{getNodeName(bundle)}"
nodeDownload = (destination, options, callback) ->
try
binary.download options, destination, (error, binaryPath) ->
return callback(error) if error?
output = path.join(destination, getNodeName(options))
fs.rename binaryPath, output, (error) ->
return callback(error) if error?
return callback(null, output)
catch error
return callback(error)
async.eachLimit bundles, 2, (bundle, callback) ->
console.info("Downloading: #{getNodeName(bundle)} to #{DESTINATION}")
return nodeDownload DESTINATION, bundle, (error, output) ->
return callback(error) if error?
console.info("Downloaded: #{getNodeName(bundle)} to #{output}")
return callback()
, (error) ->
if error?
console.error(error.message)
console.error('Error: Couldn\'t get the required node bundle. Omitting.')
else
console.info('All NodeJS bundles downloaded')

View File

@ -9,7 +9,6 @@
"url": "git@github.com:resin-io/resin-cli.git" "url": "git@github.com:resin-io/resin-cli.git"
}, },
"preferGlobal": true, "preferGlobal": true,
"bundled_engine": "v0.12.0",
"man": [ "man": [
"./man/resin.1", "./man/resin.1",
"./man/resin-completion.1", "./man/resin-completion.1",
@ -21,7 +20,6 @@
"scripts": { "scripts": {
"prepublish": "gulp build", "prepublish": "gulp build",
"test": "gulp test", "test": "gulp test",
"install": "node build/install-node.js bin/node",
"doc": "./scripts/extract-documentation.sh doc lib/actions" "doc": "./scripts/extract-documentation.sh doc lib/actions"
}, },
"keywords": [ "keywords": [
@ -59,7 +57,6 @@
"lodash": "~2.4.1", "lodash": "~2.4.1",
"lodash-contrib": "~241.4.14", "lodash-contrib": "~241.4.14",
"mkdirp": "~0.5.0", "mkdirp": "~0.5.0",
"node-binary": "^1.1.0",
"nplugm": "^2.1.0", "nplugm": "^2.1.0",
"open": "0.0.5", "open": "0.0.5",
"progress-stream": "^0.5.0", "progress-stream": "^0.5.0",