Skip to content

asar target and prepackaged option support for it #1102

Closed
qcif/data-curator
#563

Description

@pauliusuza
  • electron-builder 11.2.3:
  • OSX:

Builder crashes when trying to package app with --prepackaged command with the following error:

Error: ENOENT: no such file or directory, 
open '/Users/pro/repository/desktop_app/dist/mac/Desktop.app/Contents/Resources/app-update.yml'
at /Users/pro/repository/desktop_app/node_modules/electron-builder/src/macPackager.ts:101:13

In my package.json:
{"dist": "npm run compile && build --prepackaged ./asar"}
where ./asar is the folder containing app.asar, core.asar and node_modules.asar files

What I want is to be able to point electron-builder into a folder containing app.asar and it would package the apps for distribution.

Activity

  1. added a commit that references this issue on Jan 11, 2017
    ba474be
  2. develar commented on Jan 11, 2017

    @develar
    Contributor

    @pauliusuza Crash fixed. But prepackaged is not for your use case. @wojtkowiak Could you please share your experience — how do you use already packed asar files?

  3. pauliusuza commented on Jan 11, 2017

    @pauliusuza
    ContributorAuthor

    So I found a temporary workaround by packing app.asar through the electron-builder, and including the remaining .asar files through extraResources key:

    "build": {
        "asar": true,
        "files": [
          "!**",
          "index.js",
          "package.json"
        ],
        "extraResources": [
          {
            "from": "asar",
            "to": ""
          }
        ]
    }
    

    However, it would be really great if electron builder would have a feature which would simply pack the whole folder and it's contents if it has app.asar file without running additional checks.

    build --fromAsar ./path/to/folder/containing/app.asar_file/

    Would you consider adding this feature?

  4. develar commented on Jan 11, 2017

    @develar
    Contributor

    @pauliusuza It is already supported (#759)

    without running additional checks

    What error do you get?

  5. wojtkowiak commented on Jan 11, 2017

    @wojtkowiak
    Contributor

    I am not sure what this problem is actually about.
    @pauliusuza if you are packing your app to asars yourself you just need to turn off asar packing in electron-builder, the rest should work. I am using electron-builder programmatically so I am just setting asar to false in build options. @develar is there a cli switch for that?

  6. pauliusuza commented on Jan 11, 2017

    @pauliusuza
    ContributorAuthor

    @develar it's checking for package.json and index.js files, so if I simply point it to a folder with asar files the build step fails.

  7. develar commented on Jan 11, 2017

    @develar
    Contributor

    @pauliusuza So — you have some folder where asar files are located (app.asar is required, no other electron files) and just want to pack it into .app or .dmg or any other electron-buidler target?

    Just curious — why electron-builder is not suitable to produce required asar files?

  8. pauliusuza commented on Jan 11, 2017

    @pauliusuza
    ContributorAuthor

    @develar yes. Mostly for flexibility - we want to separate the build process and packaging process. Asar files would be built in one CI process (which is complex and takes more time) and stored on a cdn, and packaging would run in another process on demand.

    We have a use case where we need to be able to build 20-30 different apps on demand on CI re-using same .asar files, but only changing app name and branding.

  9. develar commented on Jan 11, 2017

    @develar
    Contributor

    Asar files would be built in one CI process

    Using electron-builder? Or using asar tool programmatically? I just want to understand to be sure that implemented solution will be the best solution (not workaround).

  10. pauliusuza commented on Jan 11, 2017

    @pauliusuza
    ContributorAuthor

    Sure, thanks.

    1. The first step of the process would be running asar tool programmatically (through gulp or npm script) and pack the required files into .asar archives, it would then store those .asar files into a CDN. This would run on CI on each commit.

    2. Second step would be executed on demand. It would fetch the latest .asar files from CDN, store them into a folder, apply required customization / branding, and run electron builder to pack all of this into a distributable format.

  11. develar commented on Jan 11, 2017

    @develar
    Contributor

    Got it. So:

    1. New target asar will be added. electron-builder will just pack your app into app.asar.
    2. --prepackaged will detect — is it fully prepackaged directory (has electron files) or not.
  12. changed the title [-]Crash: app-update.yml not found when using --prepackaged[/-] [+]asar target and prepackaged option support for it[/+] on Jan 11, 2017
  13. pauliusuza commented on Jan 11, 2017

    @pauliusuza
    ContributorAuthor

    @develar thanks, that sounds good

  14. pauliusuza commented on Jan 11, 2017

    @pauliusuza
    ContributorAuthor

    So just a note for --prepackaged /dir
    If app.asar already exists in the /dir, then it should check for existence of the package.json and index.js files inside the app.asar file, and not in the /dir folder itself.

  15. 5 remaining items

  16. develar commented on Feb 2, 2017

    @develar
    Contributor

    Asar target — if need, please open separate issue.

  17. pauliusuza commented on Feb 2, 2017

    @pauliusuza
    ContributorAuthor

    Sorry, this does not work.

    How can i specify project directory through options and point it to a subfolder containing asar files?
    Project folder contains files which should not be packaged, and there is no way to exclude them.

  18. develar commented on Feb 2, 2017

    @develar
    Contributor

    How can i specify project directory through options

    current working directory or set explicitly using --project CLI.

  19. pauliusuza commented on Feb 2, 2017

    @pauliusuza
    ContributorAuthor

    We are using electron-builder programmatically, not through CLI - is it possible to add a config parameter for the project directory?

  20. develar commented on Feb 2, 2017

    @develar
    Contributor

    Set projectDir

    to custom.

  21. pauliusuza commented on Feb 2, 2017

    @pauliusuza
    ContributorAuthor

    Can't get this to work.

    builder.build({
        appId: 'com.test.asar',
        projectDir: '/Users/pro/repository/test-project/temp/asar'
    })
    

    Error: Application entry file "index.js" in the "/Users/pro/repository/test-project/dist/mac/Test Project.app/Contents/Resources/app.asar" does not exist. Seems like a wrong configuration.

    // index.js file exists:
    $> asar list /Users/pro/repository/test-project/temp/asar/app.asar
    
    /index.js
    /package.json
    

    Additional files in the asar folder were not copied to the Resources

  22. pauliusuza commented on Feb 2, 2017

    @pauliusuza
    ContributorAuthor

    Running this in cli

    build --project temp/asar
    

    TypeError: Cannot read property 'directories' of undefined
    at /Users/pro/repository/test-project/node_modules/electron-builder/src/packager.ts:122:68

  23. pauliusuza commented on Feb 2, 2017

    @pauliusuza
    ContributorAuthor

    Would it not be simpler just to ignore the app folder packaging step if a specific flag is set, so we can include the .asar files via extraFiles / extraResources?

  24. develar commented on Feb 2, 2017

    @develar
    Contributor

    @pauliusuza Is it possible to send me your directory with asar files to test?

  25. pauliusuza commented on Feb 2, 2017

    @pauliusuza
    ContributorAuthor

    @develar I will send you an email shortly

  26. pauliusuza commented on Feb 3, 2017

    @pauliusuza
    ContributorAuthor

    Thanks @develar for checking out the code. Leaving a comment here if someone has the same issue (this should be documented somewhere eventually)

    Important bit is to specify the electronVersion and projectDir parameters.
    Working example:

    import * as builder from 'electron-builder';
    let config = {
        appId: 'com.asar.test',
        directories: {
            buildResources: './build_resources'
        },
        electronVersion : '1.5.0'
    }
    builder.build({
        projectDir: './path/to/folder/with/asar/files',
        config: config
    }).then(() => {
        console.log('done');
    }).catch((error) => {
        console.log(error);
    })
    
  27. yansenlei commented on Nov 14, 2018

    @yansenlei

    @pauliusuza Have you successfully build a separate app.asar?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions