-
-
Notifications
You must be signed in to change notification settings - Fork 548
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
feat(generic): allow specifying electron-prebuilt-compile via URL #450
Conversation
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.
Out of curiosity, what's the use case that necessitated this PR? Never mind, didn't finish reading the summary.
fix(generic): allow specifying electron-prebuilt-compile via URL
I think this is a feature, not a bugfix.
.gitignore
Outdated
@@ -4,3 +4,6 @@ docs | |||
.nyc_output | |||
coverage | |||
npm-debug.log | |||
|
|||
# Prevent adding test fixture package-lock files from npm@5 | |||
test/**/package-lock.json |
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'd say just ignore all package-lock.json
files.
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.
Just curious, is the reason why electron-forge
isn't using package-lock.json
or yarn.lock
to control dependency upgrades because consumer won't use them anyway (so by not having them we should detect potential breaks earlier)?
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.
We're going to require Yarn (well, technically bolt) in v6.
src/util/get-electron-version.js
Outdated
import readPackageJSON from './read-package-json'; | ||
|
||
export default async (projectDir) => { | ||
const epcPackageJSON = await readPackageJSON(path.resolve(projectDir, 'node_modules', 'electron-prebuilt-compile')); |
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.
Just call it packageJSON
, we're going to decouple electron-compile
from Forge.
src/util/get-electron-version.js
Outdated
import path from 'path'; | ||
import readPackageJSON from './read-package-json'; | ||
|
||
export default async (projectDir) => { |
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.
@MarshallOfSound we're going to need to figure out how to merge this with https://github.com/electron-userland/electron-forge/pull/432/files#diff-f5dc721cced1da6c967b89a0309237de
src/api/make.js
Outdated
@@ -129,7 +130,8 @@ export default async (providedOptions = {}) => { | |||
|
|||
await runHook(forgeConfig, 'preMake'); | |||
|
|||
for (const targetArch of parseArchs(platform, arch, packageJSON.devDependencies['electron-prebuilt-compile'])) { | |||
const electronVersion = getElectronVersion(dir); |
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.
await
src/api/start.js
Outdated
@@ -51,8 +52,9 @@ export default async (providedOptions = {}) => { | |||
} | |||
|
|||
const forgeConfig = await getForgeConfig(dir); | |||
const electronVersion = getElectronVersion(dir); |
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.
await
@malept Oops, I was pushing changes while you were reviewing, sorry. Feel free to edit/fix/squash as needed (you should be able to write to this branch) or to let me know if you want me to make any changes myself. Thanks for checking it out! |
Oops, I'll add those missing |
637bda6
to
1d701ad
Compare
@malept I've revised, rebased, and pushed. Please take another look when you have the chance. |
.gitignore
Outdated
@@ -4,3 +4,6 @@ docs | |||
.nyc_output | |||
coverage | |||
npm-debug.log | |||
package-lock.json | |||
yarn.lock |
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 don't know if we want to add yarn.lock
into .gitignore
right now given that it's going to be committed in v6.
src/util/get-electron-version.js
Outdated
export default async (projectDir) => { | ||
let result = null; | ||
|
||
const modulesToExamine = ['electron-prebuilt-compile', 'electron-compile', 'electron']; |
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.
['electron-prebuilt-compile', 'electron', 'electron-prebuilt']
src/util/get-electron-version.js
Outdated
let result = null; | ||
|
||
const modulesToExamine = ['electron-prebuilt-compile', 'electron-compile', 'electron']; | ||
for (let i = 0; i < modulesToExamine.length; i += 1) { |
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.
for...of
?
Also @MarshallOfSound this would be interesting if we gather this info when flora-colossus
walks the module tree.
src/util/get-electron-version.js
Outdated
result = packageJSON.version; | ||
break; | ||
} catch (e) { | ||
d(`Could not read package.json for moduleName=${moduleName}`); |
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.
Add e
to the debug message?
src/util/get-electron-version.js
Outdated
} | ||
|
||
if (!result) { | ||
d(`getElectronVersion failed to determine electron version: projectDir=${projectDir}, result=${result}`); |
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.
Electron version
@jacobq I talked to @MarshallOfSound briefly and we decided to hold off on merging this after we've merged the |
@malept OK, but I hope you'll keep this in mind / come back to it later. Thanks. |
We're not going to close this PR 😄 we're more likely going to rebase this on the merged master after v6 is merged. |
Also, I'm not immune to this, I have a PR that's being deferred for the same reason. |
I'm going to merge this into the 5.x branch and then forward-port the change into the 6.x branch. |
Sometimes the official `electron-prebuilt-compile` package is not up to date with the latest `electron` release. In order to allow more flexibility in development and testing, we should allow developers to [specify a git URL](https://docs.npmjs.com/files/package.json#urls-as-dependencies) instead. This commit introduces a `getElectronVersion` utility to provide the exact version number when needed. For now it still relies on reading `package.json` but unifies the accesses through a single function.
598e330
to
de1634b
Compare
Bumps [elliptic](https://github.com/indutny/elliptic) from 6.5.2 to 6.5.3. - [Release notes](https://github.com/indutny/elliptic/releases) - [Commits](indutny/elliptic@v6.5.2...v6.5.3) Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Summarize your changes:
Replace home-made RegEx for testing whether or not the version string of
electron-prebuild-compile
withexact-version
.1.x
,1.7.0 || 1.8.3
, or1.0.0 - 1.5.0
as a range.Obtain electron version via new
getElectronVersion
util, which reads theelectron-prebuilt-compile
's package.json (using the existing utilreadPackageJSON
), which is guaranteed (by package.json / npm publish semantics) to be in a predictable format.Why? One reason is that it should make it much easier to try the latest version of electron before a corresponding version of the official
electron-prebuilt-compile
module is published to NPM.