Skip to content

Commit

Permalink
Fix, simplify gulp package glob handling
Browse files Browse the repository at this point in the history
  • Loading branch information
dannon committed Oct 18, 2023
1 parent 1f67df5 commit 3d0fc27
Showing 1 changed file with 66 additions and 73 deletions.
139 changes: 66 additions & 73 deletions client/gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 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,
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"
);

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

0 comments on commit 3d0fc27

Please sign in to comment.