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

Bring life cycle in line with npm standards by johnhaley81 · Pull Request #1055 · 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  (14) .json  (1) .yml  (2) dotfile  (1) All 4 file types selected
Only manifest files
Deleted 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
15 changes: 10 additions & 5 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,11 +1,14 @@
/.travis/
/build/
/examples/
/generate/
/guides/
/lib/

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Why ignore lib? all of our js is in there?

johnhaley81 Jun 23, 2016 •
edited
Loading

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

lib should already be 100% built and in dist.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

That makes complete and total sense and I should have realized that, but sometimes I am do the forget.

/test/
/vendor/Release/

/generate/output
/generate/**/*.json
!/generate/input/*.json
!/include
!/src

.astylerc
.editorconfig
Expand All @@ -15,8 +18,10 @@
.travis.yml
appveyor.yml

*.vcxproj
!binding.gyp

*.filters
*.sln
*.log
*.md
*.sln
*.vcxproj
2 changes: 1 addition & 1 deletion .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 @@ -78,7 +78,7 @@ before_install:
fi

install:
- BUILD_ONLY=true npm install
- npm install

# This is a random private key used purely for testing.
before_script:
Expand Down
1 change: 0 additions & 1 deletion 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 @@ -23,7 +23,6 @@ init:
# what combinations to test
environment:
JOBS: 4
BUILD_ONLY: true
GIT_SSH: c:\projects\nodegit\vendor\plink.exe
GYP_MSVS_VERSION: 2013
matrix:
Expand Down
10 changes: 6 additions & 4 deletions generate/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 @@ -4,6 +4,8 @@ var generateMissingTests = require("./scripts/generateMissingTests");
var submoduleStatus = require("../lifecycleScripts/submodules/getStatus");

module.exports = function generate() {
console.log("[nodegit] Generating native code");

return submoduleStatus()
.then(function(statuses) {
var dirtySubmodules = statuses
Expand All @@ -14,9 +16,9 @@ module.exports = function generate() {
});

if (dirtySubmodules.length) {
console.log("WARNING - Some submodules are out-of-sync");
console.warn("[nodegit] WARNING - Some submodules are out-of-sync");
dirtySubmodules.forEach(function(submodule) {
console.log("\t" + submodule.name);
console.warn("[nodegit]\t" + submodule.name);
});
}
})
Expand All @@ -26,8 +28,8 @@ module.exports = function generate() {
generateMissingTests();
})
.catch(function(e) {
console.log("ERROR - Could not generate native code");
console.log(e);
console.error("[nodegit] ERROR - Could not generate native code");
console.error(e);
});
}

Expand Down
2 changes: 1 addition & 1 deletion generate/scripts/generateJson.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 @@ -222,7 +222,7 @@ module.exports = function generateJson() {
_.merge(enumerable, _.omit(override, ["values"]));

output.push(enumerable);
}).value();
});

maxkorp Jun 23, 2016 •
edited
Loading

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

don't we need the .value to make lodash actually do the operation? I thought they were lazy about that as of v4?

Edit: Maybe that was a change going in to v3, and now thats not there in v4?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Correct. We needed it in v3 but in v4 a forEach just executes.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

PRAISE BE TO LODASH, FOR THEY ARE IMPROVE


output = _.sortBy(output, "typeName");

Expand Down
2 changes: 0 additions & 2 deletions generate/scripts/generateMissingTests.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
@@ -1,6 +1,4 @@
const path = require("path");
const promisify = require("promisify-node");
const fse = promisify(require("fs-extra"));
const utils = require("./utils");

const testFilesPath = "../test/tests";
Expand Down
2 changes: 1 addition & 1 deletion generate/scripts/helpers.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 @@ -345,7 +345,7 @@ var Helpers = {
if (fnDef.jsFunctionName == utils.camelCase(collidingName)) {
fnDef.jsFunctionName = utils.camelCase(newName);
}
}).value();
});

if ("git_" + typeDef.typeName == fnDef.cFunctionName) {
fnDef.useAsOnRootProto = true;
Expand Down
1 change: 0 additions & 1 deletion generate/scripts/utils.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
@@ -1,4 +1,3 @@
const promisify = require("promisify-node");
const fse = require("fs-extra");

const fs = require("fs");
Expand Down
2 changes: 1 addition & 1 deletion lifecycleScripts/configureLibssh2.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 @@ -42,6 +42,6 @@ if (require.main === module) {
console.log("nothing to do");
}
else {
module.exports();
module.exports().done();
}
}
201 changes: 38 additions & 163 deletions lifecycleScripts/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
@@ -1,187 +1,62 @@
var path = require("path");
var fs = require("fs");
var cp = require("child_process");
var prepareForBuild = require("./prepareForBuild");
var exec = require("../utils/execPromise");
var buildFlags = require("../utils/buildFlags");
var spawn = require("child_process").spawn;

module.exports = function install() {
var fromRegistry;
console.log("[nodegit] Running install script");

try {
fs.statSync(path.join(__dirname, "..", "include"));
fs.statSync(path.join(__dirname, "..", "src"));
fs.statSync(path.join(__dirname, "..", "dist"));
fromRegistry = true;
}
catch(e) {
fromRegistry = false;
}
var nodePreGyp = "node-pre-gyp";

if (!fromRegistry) {
console.info("[nodegit] Local install, no fetching allowed.");
return prepareAndBuild();
}
if (process.env.BUILD_DEBUG) {
console.info("[nodegit] Doing a debug build, no fetching allowed.");
return prepareAndBuild();
}
if (process.env.BUILD_ONLY) {
console.info("[nodegit] BUILD_ONLY is set to true, no fetching allowed.");
return prepareAndBuild();
if (process.platform === "win32") {
nodePreGyp += ".cmd";
}

return installPrebuilt();
var args = ["install"];

function installPrebuilt() {
console.info("[nodegit] Fetching binary from S3.");
var npg = pathForTool("node-pre-gyp");
return exec("\""+ npg + "\" install --fallback-to-build=false")
.then(
function() {
console.info("[nodegit] Completed installation successfully.");
},
function(err) {
console.info("[nodegit] Failed to install prebuilt binary:");
console.error(err);
console.info("[nodegit] Building manually. (You'll be here a while.)");
return prepareAndBuild();
}
if (buildFlags.mustBuild) {
console.info(
"[nodegit] Pre-built download disabled, building from source."
);
}
args.push("--build-from-source");

function pathForTool(name) {
var toolPath = path.resolve(".", "node_modules", ".bin", name);
if (process.platform == "win32") {
toolPath += ".cmd";
if (buildFlags.debugBuild) {
console.info("[nodegit] Building debug version.");
args.push("--debug");
}
return toolPath;
}

function prepareAndBuild() {
console.info("[nodegit] Regenerating and configuring code");
return prepareForBuild()
.then(function() {
return build();
})
.then(function() {
return transpileJavascript();
});
else {
args.push("--fallback-to-build");
}

function transpileJavascript() {
var cmd = pathForTool("babel");
var args = [
"--presets",
"es2015",
"-d",
"./dist",
"./lib"
];
var opts = {
cwd: ".",
maxBuffer: Number.MAX_VALUE,
env: process.env,
stdio: "inherit"
};
var home = process.platform == "win32" ?
process.env.USERPROFILE : process.env.HOME;
return new Promise(function(resolve, reject) {
var spawnedNodePreGyp = spawn(nodePreGyp, args);

opts.env.HOME = path.join(home, ".nodegit-gyp");

return new Promise(function(resolve, reject) {
var child = cp.spawn(cmd, args, opts);
child.on("close", function(code) {
if (code) {
reject(code);
process.exitCode = 13;
}
else {
resolve();
}
});
spawnedNodePreGyp.stdout.on("data", function(data) {
console.info(data.toString().trim());
});
}

function build() {
console.info("[nodegit] Everything is ready to go, attempting compilation");

var electronVersion = process.env.ELECTRON_VERSION;
var nwjsVersion = process.env.NWJS_VERSION;
var opts = {
cwd: ".",
maxBuffer: Number.MAX_VALUE,
env: process.env,
stdio: "inherit"
};

var builder = "node-gyp";
var debug = (process.env.BUILD_DEBUG ? "--debug" : "");
var target = "";
var arch = (process.env.TARGET_ARCH ?
"--arch=" + process.env.TARGET_ARCH : "");
var distUrl = "";
var runtime = "";

process.argv.forEach(function(arg) {
if (~arg.indexOf("electronVersion")) {
electronVersion = arg.split("=")[1].trim();
}
else if (~arg.indexOf("nsjwVersion")) {
nwjsVersion = arg.split("=")[1].trim();
}
});
spawnedNodePreGyp.stderr.on("data", function(data) {
console.error(data.toString().trim());
});

if (electronVersion) {
target = "--target=" + electronVersion;
distUrl = "--dist-url=https://atom.io/download/atom-shell";
runtime = "--runtime=electron";
spawnedNodePreGyp.on("close", function(code) {
if (!code) {
resolve();
} else {
reject(code);
}
else if (nwjsVersion) {
builder = "nw-gyp";
target = "--target=" + nwjsVersion;
runtime = "--runtime=node-webkit";
}

var home = process.platform == "win32" ?
process.env.USERPROFILE : process.env.HOME;

opts.env.HOME = path.join(home, ".nodegit-gyp");

var cmd = pathForTool(builder);
var args = [
"rebuild",
debug,
target,
arch,
distUrl,
runtime
]
.filter(function(arg) {
return arg;
});

return new Promise(function(resolve, reject) {
var child = cp.spawn(cmd, args, opts);
child.on("close", function(code) {
console.log(code);
if (code) {
reject(code);
process.exitCode = 13;
}
else {
resolve();
}
});
});
}
});
})
.then(function() {
console.info("[nodegit] Completed installation successfully.");
});
};

// Called on the command line
if (require.main === module) {
module
.exports()
.catch(function(err) {
console.error(err);
return -1;
module.exports()
.catch(function(e) {
console.error("[nodegit] ERROR - Could not finish install");
console.error("[nodegit] ERROR - finished with error code: " + e);
process.exit(e);
});
}
Loading

Back | FazBrowse Home | New Git URL