Initial commit - full huishou project

This commit is contained in:
jiapengyu
2026-07-27 14:07:26 +08:00
commit 60790ad1b3
39127 changed files with 5989265 additions and 0 deletions
+5
View File
@@ -0,0 +1,5 @@
## /lifecycleScripts
These scripts are responsible for downloading the right dependencies, configuring vendors, and all other dependencies that are required to build, generate, and clean the module.
+5
View File
@@ -0,0 +1,5 @@
var cleanForPublish = require("clean-for-publish");
var path = require("path");
var location = path.join(__dirname, "..");
cleanForPublish(location);
+62
View File
@@ -0,0 +1,62 @@
var buildFlags = require("../utils/buildFlags");
var spawn = require("child_process").spawn;
module.exports = function install() {
console.log("[nodegit] Running install script");
var nodePreGyp = "node-pre-gyp";
if (process.platform === "win32") {
nodePreGyp += ".cmd";
}
var args = ["install"];
if (buildFlags.mustBuild) {
console.info(
"[nodegit] Pre-built download disabled, building from source."
);
args.push("--build-from-source");
if (buildFlags.debugBuild) {
console.info("[nodegit] Building debug version.");
args.push("--debug");
}
}
else {
args.push("--fallback-to-build");
}
return new Promise(function(resolve, reject) {
var spawnedNodePreGyp = spawn(nodePreGyp, args);
spawnedNodePreGyp.stdout.on("data", function(data) {
console.info(data.toString().trim());
});
spawnedNodePreGyp.stderr.on("data", function(data) {
console.error(data.toString().trim());
});
spawnedNodePreGyp.on("close", function(code) {
if (!code) {
resolve();
} else {
reject(code);
}
});
})
.then(function() {
console.info("[nodegit] Completed installation successfully.");
});
};
// Called on the command line
if (require.main === module) {
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);
});
}
+83
View File
@@ -0,0 +1,83 @@
var fse = require("fs-extra");
var path = require("path");
var exec = require("../utils/execPromise");
var buildFlags = require("../utils/buildFlags");
var rootPath = path.join(__dirname, "..");
function printStandardLibError() {
console.log(
"[nodegit] ERROR - the latest libstdc++ is missing on your system!"
);
console.log("");
console.log("On Ubuntu you can install it using:");
console.log("");
console.log("$ sudo add-apt-repository ppa:ubuntu-toolchain-r/test");
console.log("$ sudo apt-get update");
console.log("$ sudo apt-get install libstdc++-4.9-dev");
}
module.exports = function install() {
if (buildFlags.isGitRepo) {
// If we're building NodeGit from a git repo we aren't going to do any
// cleaning up
return Promise.resolve();
}
if (buildFlags.isElectron || buildFlags.isNWjs) {
// If we're building for electron or NWjs, we're unable to require the
// built library so we have to just assume success, unfortunately.
return Promise.resolve();
}
return exec("node \"" + path.join(rootPath, "dist/nodegit.js\""))
.catch(function(e) {
if (~e.toString().indexOf("Module version mismatch")) {
console.warn(
"[nodegit] WARN - NodeGit was built for a different version of node."
);
console.warn(
"If you are building NodeGit for electron/nwjs you can " +
"ignore this warning."
);
}
else {
throw e;
}
})
.then(function() {
// Is we're using NodeGit from a package manager then let's clean up after
// ourselves when we install successfully.
if (!buildFlags.mustBuild) {
// We can't remove the source files yet because apparently the
// "standard workflow" for native node moduels in Electron/nwjs is to
// build them for node and then nah eff that noise let's rebuild them
// again for the actual platform! Hurray!!! When that madness is dead
// we can clean up the source which is a serious amount of data.
// fse.removeSync(path.join(rootPath, "vendor"));
// fse.removeSync(path.join(rootPath, "src"));
// fse.removeSync(path.join(rootPath, "include"));
fse.removeSync(path.join(rootPath, "build/Release/*.a"));
fse.removeSync(path.join(rootPath, "build/Release/obj.target"));
}
});
};
// Called on the command line
if (require.main === module) {
module.exports()
.catch(function(e) {
console.warn("[nodegit] WARN - Could not finish postinstall");
if (
process.platform === "linux" &&
~e.toString().indexOf("libstdc++")
) {
printStandardLibError();
}
else {
console.log(e);
}
});
}
+47
View File
@@ -0,0 +1,47 @@
var path = require("path");
var local = path.join.bind(path, __dirname);
var exec = require(local("../utils/execPromise"));
var buildFlags = require(local("../utils/buildFlags"));
module.exports = function prepareForBuild() {
console.log("[nodegit] Running pre-install script");
return exec("npm -v")
.then(
function(npmVersion) {
if (npmVersion.split(".")[0] < 3) {
console.log(
"[nodegit] npm@2 installed, pre-loading required packages"
);
return exec("npm install --ignore-scripts");
}
return Promise.resolve();
},
function() {
// We're installing via yarn, so don't
// care about compability with npm@2
}
)
.then(function() {
if (buildFlags.isGitRepo) {
var submodules = require(local("submodules"));
var generate = require(local("../generate"));
return submodules()
.then(function() {
return generate();
});
}
});
};
// Called on the command line
if (require.main === module) {
module.exports()
.catch(function(e) {
console.error("[nodegit] ERROR - Could not finish preinstall");
console.error(e);
process.exit(1);
});
}
+50
View File
@@ -0,0 +1,50 @@
var path = require("path");
var rootDir = path.join(__dirname, "../..");
var exec = require(path.join(rootDir, "./utils/execPromise"));
module.exports = function getStatus() {
return exec("git submodule status", { cwd: rootDir})
.then(function(stdout) {
if (!stdout) {
// In the case where we pull from npm they pre-init the submodules for
// us and `git submodule status` returns empty-string. In that case
// we'll just assume that we're good.
return Promise.resolve([]);
}
function getStatusPromiseFromLine(line) {
var lineSections = line.trim().split(" ");
var onNewCommit = !!~lineSections[0].indexOf("+");
var needsInitialization = !!~lineSections[0].indexOf("-");
var commitOid = lineSections[0].replace("+", "").replace("-", "");
var name = lineSections[1];
return exec("git status", { cwd: path.join(rootDir, name)})
.then(function(workDirStatus) {
return {
commitOid: commitOid,
onNewCommit: onNewCommit,
name: name,
needsInitialization: needsInitialization,
workDirDirty: !~workDirStatus
.trim()
.split("\n")
.pop()
.indexOf("nothing to commit")
};
});
}
return Promise.all(stdout
.trim()
.split("\n")
.map(getStatusPromiseFromLine)
);
})
.catch(function() {
// In the case that NodeGit is required from another project via npm we
// won't be able to run submodule commands but that's ok since the
// correct version of libgit2 is published with nodegit.
return Promise.resolve([]);
});
};
+82
View File
@@ -0,0 +1,82 @@
var path = require("path");
var rootDir = path.join(__dirname, "../..");
var gitExecutableLocation = require(
path.join(rootDir, "./utils/gitExecutableLocation")
);
var submoduleStatus = require("./getStatus");
var exec = require(path.join(rootDir, "./utils/execPromise"));
module.exports = function submodules() {
return gitExecutableLocation()
.catch(function() {
console.error("[nodegit] ERROR - Compilation of NodeGit requires git " +
"CLI to be installed and on the path");
throw new Error("git CLI is not installed or not on the path");
})
.then(function() {
console.log("[nodegit] Checking submodule status");
return submoduleStatus();
})
.then(function(statuses) {
function printSubmodule(submoduleName) {
console.log("\t" + submoduleName);
}
var dirtySubmodules = statuses
.filter(function(status) {
return status.workDirDirty && !status.needsInitialization;
})
.map(function(dirtySubmodule) {
return dirtySubmodule.name;
});
if (dirtySubmodules.length) {
console.error(
"[nodegit] ERROR - Some submodules have uncommited changes:"
);
dirtySubmodules.forEach(printSubmodule);
console.error(
"\nThey must either be committed or discarded before we build"
);
throw new Error("Dirty Submodules: " + dirtySubmodules.join(" "));
}
var outOfSyncSubmodules = statuses
.filter(function(status) {
return status.onNewCommit && !status.needsInitialization;
})
.map(function(outOfSyncSubmodule) {
return outOfSyncSubmodule.name;
});
if (outOfSyncSubmodules.length) {
console.warn(
"[nodegit] WARNING - Some submodules are pointing to an new commit:"
);
outOfSyncSubmodules.forEach(printSubmodule);
console.warn("\nThey will not be updated.");
}
return statuses
.filter(function(status) {
return !status.onNewCommit;
})
.reduce(function(chainPromise, submoduleToUpdate) {
return chainPromise
.then(function() {
console.log(
"[nodegit] Initializing submodule",
submoduleToUpdate.name
);
return exec(
"git submodule update --init --recursive " +
submoduleToUpdate.name
);
});
}, Promise.resolve());
});
};