mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
Fix, simplify gulp package glob handling
This commit is contained in:
+64
-71
@@ -104,82 +104,75 @@ function buildPlugins(callback, forceRebuild) {
|
||||
/*
|
||||
* Walk pluginBuildModules glob and attempt to build modules.
|
||||
* */
|
||||
PATHS.pluginBuildModules.map((buildModule) => {
|
||||
globSync(buildModule, {}, (er, files) => {
|
||||
files.map((file) => {
|
||||
let skipBuild = false;
|
||||
const pluginDir = path.dirname(file);
|
||||
const pluginName = pluginDir.split(path.sep).pop();
|
||||
const packageJsons = globSync(PATHS.pluginBuildModules, {});
|
||||
packageJsons.forEach((file) => {
|
||||
let skipBuild = false;
|
||||
const pluginDir = path.dirname(file);
|
||||
const pluginName = pluginDir.split(path.sep).pop();
|
||||
|
||||
const hashFilePath = path.join(
|
||||
pluginDir,
|
||||
DIST_PLUGIN_BUILD_IDS.indexOf(pluginName) > -1 ? "dist" : "static",
|
||||
"plugin_build_hash.txt"
|
||||
);
|
||||
const hashFilePath = path.join(
|
||||
pluginDir,
|
||||
DIST_PLUGIN_BUILD_IDS.indexOf(pluginName) > -1 ? "dist" : "static",
|
||||
"plugin_build_hash.txt"
|
||||
);
|
||||
|
||||
if (forceRebuild) {
|
||||
skipBuild = false;
|
||||
} else {
|
||||
if (fs.existsSync(hashFilePath)) {
|
||||
skipBuild =
|
||||
child_process.spawnSync(
|
||||
"git",
|
||||
["diff", "--quiet", `$(cat ${hashFilePath})`, "--", pluginDir],
|
||||
{
|
||||
stdio: "inherit",
|
||||
shell: true,
|
||||
}
|
||||
).status === 0;
|
||||
if (!skipBuild) {
|
||||
// Hash exists and is outdated, triggering a rebuild.
|
||||
// Stage current hash to .orig for debugging and to
|
||||
// force a plugin rebuild in the event of a failure
|
||||
// (i.e. -- we're committed to a new build of this plugin).
|
||||
fs.renameSync(hashFilePath, `${hashFilePath}.orig`);
|
||||
}
|
||||
} else {
|
||||
console.log(`No build hashfile detected for ${pluginName}, generating now.`);
|
||||
}
|
||||
}
|
||||
|
||||
if (skipBuild) {
|
||||
console.log(`No changes detected for ${pluginName}`);
|
||||
} else {
|
||||
console.log(`Installing Dependencies for ${pluginName}`);
|
||||
child_process.spawnSync(
|
||||
"yarn",
|
||||
["install", "--production=false", "--network-timeout=300000", "--check-files"],
|
||||
{
|
||||
cwd: pluginDir,
|
||||
stdio: "inherit",
|
||||
shell: true,
|
||||
}
|
||||
);
|
||||
console.log(`Building ${pluginName}`);
|
||||
const opts = {
|
||||
cwd: pluginDir,
|
||||
if (forceRebuild) {
|
||||
skipBuild = false;
|
||||
} else {
|
||||
if (fs.existsSync(hashFilePath)) {
|
||||
skipBuild =
|
||||
child_process.spawnSync("git", ["diff", "--quiet", `$(cat ${hashFilePath})`, "--", pluginDir], {
|
||||
stdio: "inherit",
|
||||
shell: true,
|
||||
};
|
||||
// if node version is >16, set NODE_OPTIONS to use legacy openssl provider
|
||||
if (process.versions.node.split(".")[0] > "16") {
|
||||
opts.env = {
|
||||
...process.env,
|
||||
PARCEL_WORKER_BACKEND: "process",
|
||||
NODE_OPTIONS: "--openssl-legacy-provider",
|
||||
};
|
||||
}
|
||||
if (child_process.spawnSync("yarn", ["build"], opts).status === 0) {
|
||||
console.log(`Successfully built, saving build state to ${hashFilePath}`);
|
||||
child_process.exec(`(git rev-parse HEAD 2>/dev/null || echo \`\`) > ${hashFilePath}`);
|
||||
} else {
|
||||
console.error(
|
||||
`Error building ${pluginName}, not saving build state. Please report this issue to the Galaxy Team.`
|
||||
);
|
||||
}
|
||||
}).status === 0;
|
||||
if (!skipBuild) {
|
||||
// Hash exists and is outdated, triggering a rebuild.
|
||||
// Stage current hash to .orig for debugging and to
|
||||
// force a plugin rebuild in the event of a failure
|
||||
// (i.e. -- we're committed to a new build of this plugin).
|
||||
fs.renameSync(hashFilePath, `${hashFilePath}.orig`);
|
||||
}
|
||||
});
|
||||
});
|
||||
} else {
|
||||
console.log(`No build hashfile detected for ${pluginName}, generating now.`);
|
||||
}
|
||||
}
|
||||
|
||||
if (skipBuild) {
|
||||
console.log(`No changes detected for ${pluginName}`);
|
||||
} else {
|
||||
console.log(`Installing Dependencies for ${pluginName}`);
|
||||
child_process.spawnSync(
|
||||
"yarn",
|
||||
["install", "--production=false", "--network-timeout=300000", "--check-files"],
|
||||
{
|
||||
cwd: pluginDir,
|
||||
stdio: "inherit",
|
||||
shell: true,
|
||||
}
|
||||
);
|
||||
console.log(`Building ${pluginName}`);
|
||||
const opts = {
|
||||
cwd: pluginDir,
|
||||
stdio: "inherit",
|
||||
shell: true,
|
||||
};
|
||||
// if node version is >16, set NODE_OPTIONS to use legacy openssl provider
|
||||
if (process.versions.node.split(".")[0] > "16") {
|
||||
opts.env = {
|
||||
...process.env,
|
||||
PARCEL_WORKER_BACKEND: "process",
|
||||
NODE_OPTIONS: "--openssl-legacy-provider",
|
||||
};
|
||||
}
|
||||
if (child_process.spawnSync("yarn", ["build"], opts).status === 0) {
|
||||
console.log(`Successfully built, saving build state to ${hashFilePath}`);
|
||||
child_process.exec(`(git rev-parse HEAD 2>/dev/null || echo \`\`) > ${hashFilePath}`);
|
||||
} else {
|
||||
console.error(
|
||||
`Error building ${pluginName}, not saving build state. Please report this issue to the Galaxy Team.`
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
return callback();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user