Skip to content

Commit

Permalink
update build docs, set npm prefix on install
Browse files Browse the repository at this point in the history
fix issue regarding response on fetching available
fix issue with build script causing a crash when github doesnt respond to downloads
  • Loading branch information
nullivex committed Oct 21, 2015
1 parent dafde2b commit 2da9f3b
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/.node-version
node_modules
/.idea
NodistSetup.exe
/build/NodistSetup**
/build/staging
/build/tmp
/build/Nodist.nsi
43 changes: 41 additions & 2 deletions BUILD.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,45 @@ Moving forward as of 0.7.0 Nodist no longer installs like it had previously.
Now an installer is generated from the build process. This document is going
to overview the build process in the hope that it can then be scripted.

## Dirty Overview of Steps
## Preparation

*
Before a build can be made the following software is needed.

* Working Node at least 0.10.40
* Working NPM at least 2.x
* Install the NSIS Package
* Download here: http://nsis.sourceforge.net/Download
* I am using 3.0b2
* Install with the wizard
* Install the NSIS Plugin AccessControl
* Download here: http://nsis.sourceforge.net/AccessControl_plug-in
* Extract ZIP File
* Copy `Plugin\AccessControl.dll` to `C:\Program Files x86\NSIS\Plugins\x86-ansi`
* Copy `Unicode\Plugin\AccessControl.dll` to `C:\Program Files x86\NSIS\Plugins\x86-unicode`

## Build Process


First run the build script to prepare the installer for compilation.

```
$ cd <NODIST_DEV_FOLDER>
$ node build\build.js
``
Next compile the installer by opening NSIS and selecting the "Compile Scripts"
option. Point the compiler to `<NODIST_DEV_FOLDER>\build\Nodist.nsi` this will
start the compile process.
Provided the process is successful the installer will be at
`<NODIST_DEV_FOLDER>\build\NodistSetup.exe`
Next, move the `NodistSetup.exe` to the final production name of
`NodistSetup-v<VERSION>.exe` for example `NodistSetup-v0.7.0.exe`
## Publishing
Now to publish the new builds simply cut a release tag based on the code
just used for the build here: https://github.com/marcelklehr/nodist/releases
Attach the binary to the release.
2 changes: 2 additions & 0 deletions build/Nodist.template.nsi
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ WriteRegExpandStr ${ENV_HKLM} NODE_PATH "$INSTDIR\bin\node_modules;%NODE_PATH%"
SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000
; change the permssions on the install dir, since everyone needs ot write to it
AccessControl::GrantOnFile "$INSTDIR" "(BU)" "FullAccess"
; set the NPM prefix
Exec '"$INSTDIR\node.exe" "$INSTDIR\bin\node_modules\npm\bin\npm-cli.js" config set prefix "$INSTDIR\bin"'
SectionEnd

######################################################################
Expand Down
26 changes: 15 additions & 11 deletions build/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,21 @@ exports.downloadFile = function downloadFile(url, dest, cb){
var fileSize = 1;
var req = request.get(url);
req.on('response',function(res){
fileSize = Math.round(res.headers['content-length'] / 1024);
progress = new ProgressBar(
path.basename(dest) +
' [:bar] :current/:total KiB :rate/Kbps :percent :etas',
{
complete: '=',
incomplete: ' ',
width: 15,
total: fileSize
}
);
if(res.statusCode !== 200){
cb(new Error('Failed to read response from ' + url));
} else {
fileSize = Math.round(res.headers['content-length'] / 1024);
progress = new ProgressBar(
path.basename(dest) +
' [:bar] :current/:total KiB :rate/Kbps :percent :etas',
{
complete: '=',
incomplete: ' ',
width: 15,
total: fileSize
}
);
}
});
req.on('data',function(chunk){
progress.tick(Math.round(chunk.length / 1024));
Expand Down
5 changes: 4 additions & 1 deletion lib/nodist.js
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,10 @@ nodist.prototype.fetchAvailable = function fetchAvailable(sourceUrl, name, cb){
err.message = 'Could not list available ' + name + ' versions: ' +
err.message;
}
if(resp.statusCode !== 200){
if(!resp){
err = new Error('Could not read response for ' + sourceUrl);
}
if(!err && resp.statusCode !== 200){
err = new Error(
'Could not list available ' + name + ' versions: HTTP ' +
resp.statusCode
Expand Down

0 comments on commit 2da9f3b

Please sign in to comment.