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

asar target and prepackaged option support for it #1102

Closed
pauliusuza opened this Issue Jan 11, 2017 · 26 comments

Comments

Projects
None yet
3 participants
@pauliusuza
Contributor

pauliusuza commented Jan 11, 2017

  • 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.

develar added a commit to develar/electron-builder that referenced this issue Jan 11, 2017

@develar

This comment has been minimized.

Show comment
Hide comment
@develar

develar Jan 11, 2017

Member

@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?

Member

develar commented Jan 11, 2017

@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?

@pauliusuza

This comment has been minimized.

Show comment
Hide comment
@pauliusuza

pauliusuza Jan 11, 2017

Contributor

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?

Contributor

pauliusuza commented Jan 11, 2017

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?

@develar

This comment has been minimized.

Show comment
Hide comment
@develar

develar Jan 11, 2017

Member

@pauliusuza It is already supported (#759)

without running additional checks

What error do you get?

Member

develar commented Jan 11, 2017

@pauliusuza It is already supported (#759)

without running additional checks

What error do you get?

@wojtkowiak

This comment has been minimized.

Show comment
Hide comment
@wojtkowiak

wojtkowiak Jan 11, 2017

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?

Contributor

wojtkowiak commented Jan 11, 2017

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?

@pauliusuza

This comment has been minimized.

Show comment
Hide comment
@pauliusuza

pauliusuza Jan 11, 2017

Contributor

@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.

Contributor

pauliusuza commented Jan 11, 2017

@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.

@develar

This comment has been minimized.

Show comment
Hide comment
@develar

develar Jan 11, 2017

Member

@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?

Member

develar commented Jan 11, 2017

@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?

@pauliusuza

This comment has been minimized.

Show comment
Hide comment
@pauliusuza

pauliusuza Jan 11, 2017

Contributor

@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.

Contributor

pauliusuza commented Jan 11, 2017

@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.

@develar

This comment has been minimized.

Show comment
Hide comment
@develar

develar Jan 11, 2017

Member

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).

Member

develar commented Jan 11, 2017

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).

@pauliusuza

This comment has been minimized.

Show comment
Hide comment
@pauliusuza

pauliusuza Jan 11, 2017

Contributor

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.

Contributor

pauliusuza commented Jan 11, 2017

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.

@develar

This comment has been minimized.

Show comment
Hide comment
@develar

develar Jan 11, 2017

Member

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.
Member

develar commented Jan 11, 2017

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.

@develar develar changed the title from Crash: app-update.yml not found when using --prepackaged to asar target and prepackaged option support for it Jan 11, 2017

@develar develar added the feature label Jan 11, 2017

@pauliusuza

This comment has been minimized.

Show comment
Hide comment
@pauliusuza

pauliusuza Jan 11, 2017

Contributor

@develar thanks, that sounds good

Contributor

pauliusuza commented Jan 11, 2017

@develar thanks, that sounds good

@pauliusuza

This comment has been minimized.

Show comment
Hide comment
@pauliusuza

pauliusuza Jan 11, 2017

Contributor

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.

Contributor

pauliusuza commented Jan 11, 2017

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.

@pauliusuza

This comment has been minimized.

Show comment
Hide comment
@pauliusuza

pauliusuza Jan 17, 2017

Contributor

@develar I posted a 50$ bounty for this.

Contributor

pauliusuza commented Jan 17, 2017

@develar I posted a 50$ bounty for this.

@develar

This comment has been minimized.

Show comment
Hide comment
@develar

develar Feb 2, 2017

Member

Solution: just use electron-builder in a standard way. But your project directory must contain:

  • app.asar and other files.

If electron-builder cannot find package.json in the project directory, app.asar will be used a source of project metadata.

Caveats:

  • files, extraResources and extraFiles are not taken in account. All content in the project directory copied as is. Default exclusion rules are still applied (so, you don't need to worry.
  • two-package.json structure is not supported. Because no dev package.json in the asar.app.
  • if you build deb, you must specify homepage in the package.json Default discovery doesn't work because no git repository
  • repository also cannot be detected automatically — required for publishing (if publish config doesn't contain all required information).
  • electron-builder.yml is taken in account and can define some extra config here. If you use electron-builder.yml to package your app.asar — you must copy it to the project directory (alongside side your packaged app.asar).

Easy possible solution to provide additional data: using --em (to set standard package.json fields) or --em.build (to set config) e.g.

--em.repository="develar/repo

This comment in progress — I will update as soon functionality is pushed/updated.

Member

develar commented Feb 2, 2017

Solution: just use electron-builder in a standard way. But your project directory must contain:

  • app.asar and other files.

If electron-builder cannot find package.json in the project directory, app.asar will be used a source of project metadata.

Caveats:

  • files, extraResources and extraFiles are not taken in account. All content in the project directory copied as is. Default exclusion rules are still applied (so, you don't need to worry.
  • two-package.json structure is not supported. Because no dev package.json in the asar.app.
  • if you build deb, you must specify homepage in the package.json Default discovery doesn't work because no git repository
  • repository also cannot be detected automatically — required for publishing (if publish config doesn't contain all required information).
  • electron-builder.yml is taken in account and can define some extra config here. If you use electron-builder.yml to package your app.asar — you must copy it to the project directory (alongside side your packaged app.asar).

Easy possible solution to provide additional data: using --em (to set standard package.json fields) or --em.build (to set config) e.g.

--em.repository="develar/repo

This comment in progress — I will update as soon functionality is pushed/updated.

@develar develar closed this in 60e1406 Feb 2, 2017

@develar

This comment has been minimized.

Show comment
Hide comment
@develar

develar Feb 2, 2017

Member

Issue closed — please try 12.3.0.

I posted a 50$ bounty for this.

If you want, you can donate. https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=W6V79R2RGCCHL

Member

develar commented Feb 2, 2017

Issue closed — please try 12.3.0.

I posted a 50$ bounty for this.

If you want, you can donate. https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=W6V79R2RGCCHL

@develar

This comment has been minimized.

Show comment
Hide comment
@develar

develar Feb 2, 2017

Member

Asar target — if need, please open separate issue.

Member

develar commented Feb 2, 2017

Asar target — if need, please open separate issue.

@pauliusuza

This comment has been minimized.

Show comment
Hide comment
@pauliusuza

pauliusuza Feb 2, 2017

Contributor

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.

Contributor

pauliusuza commented Feb 2, 2017

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.

@develar

This comment has been minimized.

Show comment
Hide comment
@develar

develar Feb 2, 2017

Member

How can i specify project directory through options

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

Member

develar commented Feb 2, 2017

How can i specify project directory through options

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

@pauliusuza

This comment has been minimized.

Show comment
Hide comment
@pauliusuza

pauliusuza Feb 2, 2017

Contributor

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

Contributor

pauliusuza commented Feb 2, 2017

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

@develar

This comment has been minimized.

Show comment
Hide comment
@develar

develar Feb 2, 2017

Member

Set projectDir

to custom.

Member

develar commented Feb 2, 2017

Set projectDir

to custom.

@pauliusuza

This comment has been minimized.

Show comment
Hide comment
@pauliusuza

pauliusuza Feb 2, 2017

Contributor

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

Contributor

pauliusuza commented Feb 2, 2017

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

@pauliusuza

This comment has been minimized.

Show comment
Hide comment
@pauliusuza

pauliusuza Feb 2, 2017

Contributor

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

Contributor

pauliusuza commented Feb 2, 2017

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

@pauliusuza

This comment has been minimized.

Show comment
Hide comment
@pauliusuza

pauliusuza Feb 2, 2017

Contributor

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?

Contributor

pauliusuza commented Feb 2, 2017

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?

@develar

This comment has been minimized.

Show comment
Hide comment
@develar

develar Feb 2, 2017

Member

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

Member

develar commented Feb 2, 2017

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

@pauliusuza

This comment has been minimized.

Show comment
Hide comment
@pauliusuza

pauliusuza Feb 2, 2017

Contributor

@develar I will send you an email shortly

Contributor

pauliusuza commented Feb 2, 2017

@develar I will send you an email shortly

develar added a commit to develar/electron-builder that referenced this issue Feb 3, 2017

develar added a commit to develar/electron-builder that referenced this issue Feb 3, 2017

develar added a commit that referenced this issue Feb 3, 2017

@pauliusuza

This comment has been minimized.

Show comment
Hide comment
@pauliusuza

pauliusuza Feb 3, 2017

Contributor

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);
})
Contributor

pauliusuza commented Feb 3, 2017

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);
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment