Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version detection on macOS 13.4.1 #5

Open
Bartel-C8 opened this issue Aug 30, 2023 · 1 comment
Open

Version detection on macOS 13.4.1 #5

Bartel-C8 opened this issue Aug 30, 2023 · 1 comment

Comments

@Bartel-C8
Copy link

Bartel-C8 commented Aug 30, 2023

Hi,

Did the sw_vers command change over time in macOS? While running this on my macOS 13.4.1, I get an error running start :

./node_modules/electron-to-nwjs/node_modules/semver/classes/semver.js:38
      throw new TypeError(`Invalid Version: ${version}`)
      ^

TypeError: Invalid Version: 13.4.1.0
    at new SemVer (./node_modules/electron-to-nwjs/node_modules/semver/classes/semver.js:38:13)
    at compare (./node_modules/electron-to-nwjs/node_modules/semver/functions/compare.js:3:3)
    at Object.gte (./node_modules/electron-to-nwjs/node_modules/semver/functions/gte.js:2:30)
    at Versions.isVersionEqualOrSuperiorThanVersion (./node_modules/electron-to-nwjs/scripts/utils/versions.js:5:23)
    at currentSystemRecommendedNwjsVersion (./node_modules/electron-to-nwjs/index.js:36:23)
    at Object.<anonymous> (./node_modules/electron-to-nwjs/index.js:276:62)
    at Module._compile (node:internal/modules/cjs/loader:1254:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1308:10)
    at Module.load (node:internal/modules/cjs/loader:1117:32)
    at Module._load (node:internal/modules/cjs/loader:958:12)

Node.js v18.16.0

Output of sw_vers -productVersion on my machine:

% sw_vers -productVersion
13.4.1

Possible fix (where I count the number of dots):

const currentSystemRecommendedNwjsVersion = function () {
    // Reference:
    // https://dev.to/thejaredwilcurt/guide-to-nw-js-versions-5d38#osx-support
    let platform = getCurrentOs();
    if (platform === "mac") {
        let osVersion = child_process_1.default.execSync("sw_vers -productVersion", { encoding: 'utf-8' }).toString().trim();
        const dotCount = osVersion.match(/\./g).length;
        const osVersionSem = osVersion + (dotCount == 1 ? ".0" : "")
        if (!Versions.isVersionEqualOrSuperiorThanVersion(osVersionSem, "10.9.0")) {
            // NW.js v0.14.7 and below works with 10.6+
            // NW.js v0.15.0 works with 10.9+
            return "0.14.7";
        }
        if (!Versions.isVersionEqualOrSuperiorThanVersion(osVersionSem, "10.10.0")) {
            // NW.js v0.29.0 works with 10.10+
            return "0.28.3";
        }
        if (!Versions.isVersionEqualOrSuperiorThanVersion(osVersionSem, "10.11.0")) {
            // NW.js v0.51.0 works with 10.11+
            return "0.50.3";
        }
        if (!Versions.isVersionEqualOrSuperiorThanVersion(osVersionSem, "10.15.0")) {
            // NW.js v0.64.1 works with 10.15 and no longer accurately updates the plist file
            return "0.64.0";
        }
    }
    return "0.69.1";
};

In the meanwhile, the latest NW.js version is also 0.79.1

@TheJaredWilcurt
Copy link
Member

TheJaredWilcurt commented Aug 30, 2023

Two things:

  1. Detecting OSX versions is not obvious, easy, or straight forward, you should use:
  2. That part of the blog post I wrote is the least trustworthy. I can't say with certainty the accuracy of those version numbers equating to support precisely. So it feels weird to have it codified like this. For example, I've got 10.11 running in a VM right now and it runs NW.js 0.12.3 just fine. I'd need to download later versions and see when it stops working. It's also not always obvious when something stops working, sometimes it still loads but wouldn't have full support for all features.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants