-
-
Notifications
You must be signed in to change notification settings - Fork 530
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
electron-forge import #20
Conversation
const pruneSpinner = ora.ora('Pruning deleted modules').start(); | ||
await new Promise((resolve) => { | ||
d('attempting to prune node_modules in:', dir); | ||
const child = yarnOrNPMSpawn(hasYarn() ? [] : ['prune'], { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ugh. I was hoping to avoid command specific behavior when implementing electron/packager#518 but I guess I'll have to do it.
|
||
await pify(rimraf)(path.resolve(dir, 'node_modules/.bin/electron')); | ||
await pify(rimraf)(path.resolve(dir, 'node_modules/.bin/electron.cmd')); | ||
await pify(rimraf)(path.resolve(dir, 'node_modules', electronName)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It occurs to me that we can replace rimraf
calls with fs.remove
since fs-promise
uses fs-extra
. But that can be for another PR.
const { shouldChangeMain } = await inquirer.createPromptModule()({ | ||
type: 'confirm', | ||
name: 'shouldChangeMain', | ||
message: 'Do you want us to change the "main" attribute of your package.json? If you are currently using babel and pointint to a "build" directory say yes.', // eslint-disable-line |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pointing
' "electron-prebuilt-compile" '.cyan + | ||
'dependency. This is the dependency you must version bump to get newer versions of Electron.\n\n' + | ||
'We also tried to import any build tooling you already had but we can\'t get everything. You might need to convert any CLI/gulp/grunt tasks yourself.\n\n' + | ||
'Thanks for using ' + 'electron-forge'.green + '!!!'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like this should be a multi-line templated string (if that works). Not a big fan of the +
s and backslashes.
@@ -24,7 +24,7 @@ const main = async () => { | |||
dir = path.resolve(dir, cwd); | |||
} | |||
}) | |||
.parse(process.argv); | |||
.parse(process.argv.slice(0, 2)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only parse the first two args (electron-forge
and start
, all the rest should be ignored or the CLI fails 😢
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah. I completely missed the part below this where you take the rest of the arguments and pass them directly to electron
.
packageJSON.scripts.lint = 'eslint src'; | ||
break; | ||
default: | ||
packageJSON.scripts.lint = 'echo "No linting yet..."'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"No linting configured"?
891c404
to
7b77621
Compare
Is the last thing that's missing "remove Electron Packager and other existing build tools from (dev)Dependencies"? |
@malept Pretty much yes. Currently blocked though by |
@MarshallOfSound I fixed this in the latest version |
7b77621
to
7fbf837
Compare
/cc @malept There are a few bonus features in this PR now that seemed to be required for some projects to move over to |
const bins = await pify(glob)(path.join(buildPath, '**/.bin/**/*')); | ||
for (const bin of bins) { | ||
await fs.remove(bin); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm probably missing something, but can we use --no-bin-links
when yarn install
is run?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about during development or if users run yarn
manually?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm. Good point. For some reason I thought that Electron Packager ran npm install
but it was just for its tests.
I added automatic removal of all known Electron build tools from |
@malept Probably should prompt for each removal to be sure 👍, maybe with an brief explanation as to how |
Use lodash templating to allow the config object to reuse values from the existing package.json file
This adds a command that (at least in my testing) semi-automates the transition from other build tooling (gulp, babel, -builder, Etc.) to
electron-forge
. Currently it:main
pointer of the package.json file.compilerc
preload
propertyelectron-forge
output directory to the gitignoreelectron
andelectron-prebuilt
and replaces them withelectron-prebuilt-compile
electron-compile
It does all this while warning the user that we will be writing to their files and in certain steps asking if we are doing the right thing.
This command isn't complete yet (I probably want import other configs like LESS and such if they exist) and I need to do some testing. But as an example when I ran this against my rather complex GPMDP and then ran
electron-forge start
it launched correctly 👍Just looking for initial feedback and maybe some enhancements to the import process.
/cc @paulcbetts because you seemed quite keen for this 😆
TODO
Should prompt (and automate) the installation of linting tools if none are present(no longer doing this because of Support for custom template directories #35)