diff --git a/commandLine/src/defines.h b/commandLine/src/defines.h index f919214d..58f1b251 100644 --- a/commandLine/src/defines.h +++ b/commandLine/src/defines.h @@ -1,5 +1,5 @@ #define OFPROJECTGENERATOR_MAJOR_VERSION "0" -#define OFPROJECTGENERATOR_MINOR_VERSION "105" +#define OFPROJECTGENERATOR_MINOR_VERSION "106" #define OFPROJECTGENERATOR_PATCH_VERSION "0" #define PG_VERSION (OFPROJECTGENERATOR_MAJOR_VERSION "." OFPROJECTGENERATOR_MINOR_VERSION "." OFPROJECTGENERATOR_PATCH_VERSION) diff --git a/frontend/app.js b/frontend/app.js index f825f0c8..21340748 100644 --- a/frontend/app.js +++ b/frontend/app.js @@ -534,7 +534,8 @@ function setup() { if(isSierra) { try { - const runningOnVar = (ofpath.length >= 8 && ofpath.substring(0,8) === '/private'); + // matches Gatekeeper's real AppTranslocation path, not just any /private path + const runningOnVar = /^\/private\/var\/folders\/.*\/AppTranslocation\//.test(ofpath); isFirstTimeSierra = runningOnVar; } catch(e) { isFirstTimeSierra = false; diff --git a/frontend/index.html b/frontend/index.html index dd8e9f5a..654ea123 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -389,12 +389,14 @@ -
diff --git a/frontend/index.js b/frontend/index.js index 96053a17..27aa331e 100644 --- a/frontend/index.js +++ b/frontend/index.js @@ -63,6 +63,30 @@ const templateSettings = { +// mirrors isGoodOFPath() in commandLine/src/main.cpp +function isGoodOFPath(p) { + try { + return ['addons', 'libs', 'scripts'].every((folder) => { + const full = path.join(p, folder); + return fs.existsSync(full) && fs.statSync(full).isDirectory(); + }); + } catch (e) { + return false; + } +} + +// mirrors findOFPathUpwards() in commandLine/src/main.cpp +function findOFPathUpwards(startPath) { + let current = path.resolve(startPath); + let previous = null; + while (current !== previous) { + if (isGoodOFPath(current)) return current; + previous = current; + current = path.dirname(current); + } + return null; +} + /** * Determines the current platform based on process information. * @returns {string} The platform identifier. @@ -256,10 +280,18 @@ if (!path.isAbsolute(defaultOfPath)) { // arturo, this may differ on linux, if putting ../ in settings doesn't work for the default path // take a look at this... + let fixedDepthGuess; if (hostplatform == "windows" || hostplatform == "linux" || hostplatform == "linux64" ){ - defaultOfPath = path.resolve(path.join(path.join(__dirname, "../../../"), defaultOfPath)); + fixedDepthGuess = path.resolve(path.join(path.join(__dirname, "../../../"), defaultOfPath)); } else if(hostplatform == "osx"){ - defaultOfPath = path.resolve(path.join(path.join(__dirname, "../../../"), defaultOfPath)); + fixedDepthGuess = path.resolve(path.join(path.join(__dirname, "../../../"), defaultOfPath)); + } + + // validate the fixed-depth guess, else search upward from this app's own location + if (isGoodOFPath(fixedDepthGuess)) { + defaultOfPath = fixedDepthGuess; + } else { + defaultOfPath = findOFPathUpwards(__dirname) || fixedDepthGuess; } settings["defaultOfPath"] = defaultOfPath || ""; @@ -977,11 +1009,35 @@ function getPgPath() { return pgApp; } +// clear error when the cmdLine binary hasn't been built/copied into frontend/app/ yet +function pgMissingError(pgApp) { + return new Error( + `commandLine binary not found at "${pgApp}". Build it first (commandLine/, via make/xcodebuild/MSBuild) ` + + `then copy it into frontend/app/ - see scripts/