capacitor-community / electron

Deploy your Capacitor apps to Linux, Mac, and Windows desktops, with the Electron platform! 🖥️
https://capacitor-community.github.io/electron/
MIT License
335 stars 59 forks source link

Add command expects www directory #161

Closed ari62 closed 2 years ago

ari62 commented 2 years ago

Describe the bug Running: npx cap add @capacitor-community/electron Gives the following error:

npx cap add @capacitor-community/electron
ℹ Adding Electron platform: start 🚀
ℹ Adding Electron platform: extracting template
ℹ Adding Electron platform: copying capacitor config file
ℹ Adding Electron platform: setting up electron project
ℹ Adding Electron platform: installing npm modules
✔ Adding Electron platform: completed in 53.13s
ℹ Copying Web App to Electron platform: start 🚀
⠋ Copying Web App to Electron platform: Copying /Users/aaa/dev/projects/test/adsg/www into /Users/aaa/dev/projects/test/adsg/electron/appError: ENOENT: no such file or directory, stat '/Users/aaa/dev/projects/test/adsg/www'
✖ Copying Web App to Electron platform: ENOENT: no such file or directory, stat '/Users/aa/dev/projects/test/adsg/www'
node:fs:1536
  handleErrorFromBinding(ctx);
  ^

Error: ENOENT: no such file or directory, stat '/Users/aaa/dev/projects/test/adsg/www'
    at Object.statSync (node:fs:1536:3)
    at Object.statSync (/Users/aaa/dev/projects/test/adsg/node_modules/graceful-fs/polyfills.js:311:34)
    at statSync (/Users/aaa/dev/projects/test/adsg/node_modules/fs-extra/lib/util/stat.js:10:52)
    at getStatsSync (/Users/aaa/dev/projects/test/adsg/node_modules/fs-extra/lib/util/stat.js:24:19)
    at Object.checkPathsSync (/Users/aaa/dev/projects/test/adsg/node_modules/fs-extra/lib/util/stat.js:49:33)
    at copySync (/Users/aaa/dev/projects/test/adsg/node_modules/fs-extra/lib/copy-sync/copy-sync.js:24:38)
    at ih (/Users/aaa/dev/projects/test/adsg/node_modules/@capacitor-community/electron/dist/cli-scripts/cap-scripts.js:6:1959)
    at /Users/aaa/dev/projects/test/adsg/node_modules/@capacitor-community/electron/dist/cli-scripts/cap-scripts.js:15:316
    at Et (/Users/aaa/dev/projects/test/adsg/node_modules/@capacitor-community/electron/dist/cli-scripts/cap-scripts.js:6:333)
    at qi (/Users/aaa/dev/projects/test/adsg/node_modules/@capacitor-community/electron/dist/cli-scripts/cap-scripts.js:15:259) {
  errno: -2,
  syscall: 'stat',
  code: 'ENOENT',
  path: '/Users/aaa/dev/projects/test/adsg/www'
}

My project is an ionic angular app. It doesn't have a www folder (no www folder is the default when using ionic start), but it has a src folder.

To Reproduce Run npx cap add @capacitor-community/electron In an app without a www folder

Expected behavior Not sure, maybe give a warning if it isn't required. I don't think it should be expected that the electron app would be the same as the web app. I am left unsure if the "add" process completed or errored halfway through, so clarification would be good.

Desktop (please complete the following information): macOS 12.1

IT-MikeS commented 2 years ago

Please build your project first using, npm run build

rodydavis commented 2 years ago

I added the following script to my root:

"scripts" {
   "postbuild": "cap sync && npm run copy",
   "copy": "rm -rf electron/app && mkdir electron/app && cp -r dist/* electron/app/",
}