evshiron / nwjs-builder

https://www.npmjs.com/package/nwjs-builder
76 stars 12 forks source link

Build a former Chrome Packaged App #62

Closed bernardofd closed 7 years ago

bernardofd commented 7 years ago

Hi;

I am trying to build a package from a Chrome Package App through nwjs-builder. NW.js is able to run the app perfectly if I run the NW.js executable pointing to the ZIP file which we would upload to the Chrome Store. But when I try to build a package, I'm yet to make it work.

I've tried the scenarios listed below, building through the command:

nwb nwbuild -o <output_folder> --output-format ZIP --with-ffmpeg <input_folder> -p linux64

EDIT: I'm using the latest versions of NW.js and nwjsbuilder

  1. Unzip the ZIP file in a folder and build "as-is". Build Output: ENOENT: no such file or directory, open '/tmp/player/package.json'. Which is odd considering NW.js works fine with only the manifest.json file present.
  2. Manually copy the project package.json to the folder and try again. It builds successfully. Executable OUTPUT: Window with the following error: Failed to load extension from /tmp/.io.nwjs.xxxxxx. Localization used, but default_locale wasn't specified in the manifest. The manifest.json file contains a "default_locale": "en" line, though.
  3. Insert the "default_locale": "en", line into the package.json file, and try again. It built successfully. When I execute the binary file, nothing happens, no graphic nor text output whatsoever. Probably because of a missing main entry on the package.json. Since a Chrome Package App entrypoint is the manifest.json file, which tell Chrome to load and run all files on the app.background.scripts entry, I've tried to set the main to the manifest.json file, but it only opens a window with the JSON file listed as text.

So, I've finally come here to ask for help: is there a way to build a package using nwjs-builder from a Chrome Packaged App, preferably with minimal code change?

Thanks in advance!

evshiron commented 7 years ago

Greetings.

I'm afraid I can't help you about this because I don't even know NW.js supports Chrome Apps :( ~Although NW.js project runs as a Chrome App.~

  1. nwjs-builder will read package.json for basic information of a NW.js project, which is created and managed by npm.
  2. I'm not familiar with it but putting "default_locale": "en" into package.json should work. See also SchizoDuckie/DuckieTV#638.
  3. I guess package.json has a higher priority than manifest.json, and when both files are present, package.json is loaded, as a result NW.js treats it as a NW.js project, not a Chrome App.

If no argument is provided, NW.js will try to load app from its pwd. You can unpack your Chrome Packaged App and make sure nw(.exe) and manifest.json are in the same directory, and then run nw(.exe) directly and see if it works properly. If it works, nwjs-builder has a --side-by-side option to do the above, which will neither pack files nor append them to the executable. Delete the package.json in the output directory after building, and see if it works.

BTW See also http://docs.nwjs.io/en/latest/References/Manifest%20Format/.

Basically I don't have a Chrome App sample and I have never tried to run a Chrome App on NW.js, maybe I can't help much about it, but feedback is appreciated.

bernardofd commented 7 years ago

Hi @evshiron, thanks for the quick response.

I don't even know NW.js supports Chrome Apps :(

They do since v0.13 it seems, according to their blog post. Since Google decided to kill Chrome packaged apps for all platforms except ChromeOS, we've been looking for alternatives. :)

nwjs-builder has a --side-by-side option to do the above

I'll try that and update here if it works.

Best Regards!

bernardofd commented 7 years ago

If it works, nwjs-builder has a --side-by-side option to do the above, which will neither pack files nor append them to the executable. Delete the package.json in the output directory after building, and see if it works.

It worked, at least on my machine. I'll have to test it in other platforms, but at least I can go forward. Thanks @evshiron . Closing the issue!