From 3d0fc2740f4a815403694e2f91ecd8083d80667f Mon Sep 17 00:00:00 2001 From: Dannon Baker Date: Tue, 17 Oct 2023 21:38:20 -0400 Subject: [PATCH] Fix, simplify gulp package glob handling --- client/gulpfile.js | 139 +++++++++++++++++++++------------------------ 1 file changed, 66 insertions(+), 73 deletions(-) diff --git a/client/gulpfile.js b/client/gulpfile.js index a5b49c133846..ca806b726c76 100644 --- a/client/gulpfile.js +++ b/client/gulpfile.js @@ -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(); }