FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Fix publishing by maxkorp · Pull Request #310 · nodegit/nodegit · GitHub

Repository navigation

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .js  (5) .json  (1) .yml  (2) dotfile  (1) All 4 file types selected
Only manifest files
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
22 changes: 20 additions & 2 deletions .npmignore
This file contains hidden or 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,4 +1,22 @@
/doc/
/build/
/example/
/node_modules/
/generate/
/test/
/vendor/libgit2/
/vendor/libssh2/
/vendor/http_parser/
/vendor/Release/

.astylerc
.editorconfig
.gitignore
.gitmodules
.jshintrc
.travis.yml
.appveyor.yml

*.vcxproj
*.filters
*.sln
*.log
*.md
8 changes: 8 additions & 0 deletions .travis.yml
This file contains hidden or 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
Expand Up @@ -23,6 +23,8 @@ before_script:
- chmod 600 ~/.ssh/id_rsa*
- eval `ssh-agent -s`
- ssh-add ~/.ssh/id_rsa
- git config --global user.name "John Doe"
- git config --global user.email johndoe@example.com
git:
depth: 1
branches:
Expand All @@ -35,3 +37,9 @@ script: npm test
notifications:
slack:
secure: KglNSqZiid9YudCwkPFDh+sZfW5BwFlM70y67E4peHwwlbbV1sSBPHcs74ZHP/lqgEZ4hMv4N2NI58oYFD5/1a+tKIQP1TkdIMuq4j2LXheuirA2HDcydOVrsC8kRx5XFGKdVRg/uyX2dlRHcOWFhxrS6yc6IxtxYWlRTD2SmEc=
webhooks:
urls:
- https://webhooks.gitter.im/e/cbafdb27ad32ba746a73
on_success: always # options: [always|never|change] default: always
on_failure: always # options: [always|never|change] default: always
on_start: false # default: false
12 changes: 12 additions & 0 deletions appveyor.yml
This file contains hidden or 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
Expand Up @@ -14,6 +14,8 @@ clone_folder: c:\projects\nodegit
# fix lineendings in Windows
init:
- git config --global core.autocrlf input
- git config --global user.name "John Doe"
- git config --global user.email johndoe@example.com

# what combinations to test
environment:
Expand All @@ -39,3 +41,13 @@ test_script:
- cmd: npm test

build: off

notifications:
- provider: Slack
auth_token:
secure: ZsaMCvRMfDZhNsiUvZtvszXXF3z4pLIGJmAj5MuDaa40JvmMC6wnBWIR+LHJuJPM
channel: nodegit

branches:
only:
- master
136 changes: 82 additions & 54 deletions install.js
This file contains hidden or 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
Expand Up @@ -48,7 +48,7 @@ function systemPath(parts) {
}

// Will be used near the end to configure `node-gyp`.
var pythonPath = '/usr/bin/python';
var pythonPath = "";

var local = path.join.bind(path, __dirname);

Expand All @@ -58,12 +58,7 @@ var paths = envOverride({
libgit2: local("vendor/libgit2/"),
libssh2: local("vendor/libssh2/"),
http_parser: local("vendor/http_parser/"),
sys: {
include: local("include/sys/"),
src: local("src/sys/"),
build: local("build/Release/obj.target/src/sys/")
},
release: local("build/Release/")
release: local("build/Release/"),
});

// Load the package.json.
Expand All @@ -76,8 +71,7 @@ if (NODE_VERSION === 0.1) {
fse.ensureDir(path.resolve(__dirname, paths.release))
.then(detectNodeWebkit.call(null, __dirname))
.then(fetch)
.then(finish, compile)
.done()
.then(finish, compile);

function fetch() {
console.info("[nodegit] Fetching binary from S3.");
Expand All @@ -104,83 +98,103 @@ function compile(err) {

console.info("[nodegit] Determining dependencies.");

return python()
.then(getVendorLib("libgit2", "https://github.com/libgit2/libgit2/tarball/" + pkg.libgit2.sha))
.then(getVendorLib("libssh2", pkg.libssh2.url))
.then(getVendorLib("http_parser", pkg.http_parser.url))
.then(buildNative)
.then(finish, fail);

return Promise.all([
python(),
getVendorLib("libgit2", "https://github.com/libgit2/libgit2/tarball/" + pkg.libgit2.sha),
getVendorLib("libssh2", pkg.libssh2.url),
getVendorLib("http_parser", pkg.http_parser.url),
guardGenerated()
])
.then(buildNative)
.then(finish, fail);
}

function python() {
return exec("which python2")
var pathFinderCommand = process.platform === "win32" ? "where" : "which";

return exec(pathFinderCommand + " python2")
.then(function(which){
return which;
}, function(err) {
return null;
})
.then(function(path) {
return path || exec("which python");
return path || exec(pathFinderCommand + " python");
})
.then(function(which) {
return which;
.then(function(path) {
return path;
}, function(err) {
return null;
})
.then(function(path) {
pythonPath = path.trim();
if (!pythonPath) {
if (!path) {
throw new Error("Python is required to build libgit2.");
}
return path.trim();
}, function(err) {
throw new Error("Error finding python.");
})
.then(function() {
return exec(pythonPath + " -V 2>&1");
.then(function(path) {
pythonPath = path;
return exec(path + " -V 2>&1");
})
.then(function(version) {
if (version[1].indexOf("Python 3") === 0) {
if (version.trim().indexOf("Python 3") === 0) {
throw new Error("Incorrect version of Python, gyp requires < 3.");
}
});
}

function getVendorLib(name, url) {
return function() {
var version = pkg[name].sha || pkg[name].version;
console.info("[nodegit] Detecting vendor/" + name + ".");
if (fse.existsSync(paths[name] + version)) {
console.info("[nodegit] vendor/" + name + " already exists.");
return new Promise(function(resolve, reject) {resolve() });
}
else {
console.info("[nodegit] Removing outdated vendor/" + name + ".");
return fse.remove(paths[name])
.then(function() {
return new Promise(function (resolve, reject) {

console.info("[nodegit] Fetching vendor/" + name + ".");
var version = pkg[name].sha || pkg[name].version;
console.info("[nodegit] Detecting vendor/" + name + ".");
if (fse.existsSync(paths[name] + version)) {
console.info("[nodegit] vendor/" + name + " already exists.");
return Promise.resolve();
}
else {
console.info("[nodegit] Removing outdated vendor/" + name + ".");
return fse.remove(paths[name])
.then(function() {
return new Promise(function (resolve, reject) {

var extract = tar.Extract({
path: paths[name],
strip: true
});
console.info("[nodegit] Fetching vendor/" + name + ".");

request.get(url).pipe(zlib.createUnzip()).pipe(extract)
.on("error", reject)
.on("end", resolve);
var extract = tar.Extract({
path: paths[name],
strip: true
});
}).then(function() {
return fse.writeFile(paths[name] + version, "");
}).then(function() {
if ((name == "libssh2") && (process.platform !== "win32")) {

return exec(paths[name] + "configure", {cwd: paths[name]});
}
request.get(url).pipe(zlib.createUnzip()).pipe(extract)
.on("error", reject)
.on("end", resolve);
});
}
}).then(function() {
return fse.writeFile(paths[name] + version, "");
}).then(function() {
if ((name == "libssh2") && (process.platform !== "win32")) {
return exec(paths[name] + "configure", {cwd: paths[name]});
}
});
}
}

function guardGenerated() {
return Promise.all([
fse.stat(path.resolve(__dirname, "src/")),
fse.stat(path.resolve(__dirname, "include/"))
]).then(function() {
return Promise.resolve();
}, function() {
console.info("[nodegit] C++ files not found, generating now.");
console.info("[nodegit] Installing all devDependencies");
return exec("npm install --ignore-scripts --dont-prepublish")
.then(function() {
return exec("node generate");
});
});
}

function buildNative() {
return exec("cd " + __dirname).then(function() {
if (nodeWebkit) {
Expand Down Expand Up @@ -221,7 +235,21 @@ function detectNodeWebkit(directory) {

function finish() {
console.info("[nodegit] Completed installation successfully.");
return Promise.resolve().done();
if (!buildOnly) {
console.info("[nodegit] Cleaning up");
return Promise.all([
fse.remove(path.resolve(__dirname, "src")),
fse.remove(path.resolve(__dirname, "include")),
fse.remove(path.resolve(__dirname, "generate/output")),
fse.remove(path.resolve(__dirname, paths.libgit2)),
fse.remove(path.resolve(__dirname, paths.libssh2)),
fse.remove(path.resolve(__dirname, paths.http_parser))
// exec("npm prune --production")
]).done();
}
else {
return Promise.resolve().done();
}
}

function fail(message) {
Expand Down
17 changes: 10 additions & 7 deletions package.json
This file contains hidden or 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
Expand Up @@ -60,14 +60,8 @@
"node-pre-gyp"
],
"dependencies": {
"combyne": "~0.6.2",
"find-parent-dir": "^0.3.0",
"fs-extra": "^0.12.0",
"istanbul": "~0.3.2",
"js-beautify": "^1.5.4",
"jshint": "~2.5.6",
"lodash": "^2.4.1",
"mocha": "~1.21.4",
"nan": "~1.3.0",
"node-gyp": "~1.0.2",
"node-pre-gyp": "~0.5.27",
Expand All @@ -77,6 +71,14 @@
"request": "~2.45.0",
"tar": "~1.0.1"
},
"devDependencies": {
"mocha": "~1.21.4",
"combyne": "~0.6.2",
"istanbul": "~0.3.2",
"js-beautify": "^1.5.4",
"jshint": "~2.5.6",
"lodash": "^2.4.1"
},
"binary": {
"module_name": "nodegit",
"module_path": "./build/Release/",
Expand All @@ -91,8 +93,9 @@
"generateJson": "node generate/scripts/generateJson",
"generateNativeCode": "node generate/scripts/generateNativeCode",
"generateMissingTests": "node generate/scripts/generateMissingTests",
"prepublish": "node prepublish",
"publish": "node-pre-gyp package && node-pre-gyp publish",
"install": "node generate && node install",
"install": "node install",
"recompile": "BUILD_ONLY=true npm install",
"rebuild": "BUILD_ONLY=true node generate && node-gyp configure build"
}
Expand Down
8 changes: 8 additions & 0 deletions prepublish.js
This file contains hidden or 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 @@
var exec = require('child_process').exec;
try {
require("./build/Release/nodegit");
console.info("[nodegit] Nothing to do.")
}
catch (e) {
exec("node generate");
}
2 changes: 2 additions & 0 deletions test/index.js
This file contains hidden or 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
Expand Up @@ -10,4 +10,6 @@ var args = [

require("child_process").fork("../node_modules/istanbul/lib/cli.js", args, {
cwd: __dirname
}).on("close", function(code) {
process.exit(code);
});
5 changes: 4 additions & 1 deletion test/tests/merge.js
This file contains hidden or 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
Expand Up @@ -213,7 +213,10 @@ describe("Merge", function() {
});
})
.then(function() {
return repository.mergeBranches(ourBranchName, theirBranchName);
return repository.mergeBranches(
ourBranchName,
theirBranchName,
ourSignature);
})
.then(function(oid) {
assert.equal(oid.toString(),
Expand Down
7 changes: 7 additions & 0 deletions test/tests/repository.js
This file contains hidden or 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
Expand Up @@ -7,6 +7,7 @@ describe("Repository", function() {

var Repository = require("../../lib/repository");
var Index = require("../../lib/index");
var Signature = require("../../lib/signature");

before(function() {
var test = this;
Expand Down Expand Up @@ -58,4 +59,10 @@ describe("Repository", function() {
assert.equal(branch.shorthand(), "master");
});
});

it("can get the default signature", function() {
var sig = this.repository.defaultSignature();

assert(sig instanceof Signature);
});
});

Back | FazBrowse Home | New Git URL