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
+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());
});
};