Skip to content
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

Merged
merged 3 commits into from
Apr 10, 2018

Conversation

jacobq
Copy link
Contributor

@jacobq jacobq commented Mar 12, 2018

  • I have read the contribution documentation for this project.
  • I agree to follow the code of conduct that this project follows, as appropriate.
  • The changes are appropriately documented (if applicable).
  • The changes have sufficient test coverage (if applicable).
  • The testsuite passes successfully on my local machine (if applicable).

Summarize your changes:

  • Replace home-made RegEx for testing whether or not the version string of electron-prebuild-compile with exact-version.

    • Since this functionality is not closely related to electron / electron-forge, I think it makes sense to use and external library instead. Even though it is relatively small, there are a lot of subtleties that should have test coverage.
    • The existing implementation does not correctly identify strings like 1.x, 1.7.0 || 1.8.3, or 1.0.0 - 1.5.0 as a range.
  • Obtain electron version via new getElectronVersion util, which reads the electron-prebuilt-compile's package.json (using the existing util readPackageJSON), 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.

Sorry, something went wrong.

Copy link
Member

@malept malept left a 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
Copy link
Member

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.

Copy link
Contributor Author

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

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

import readPackageJSON from './read-package-json';

export default async (projectDir) => {
const epcPackageJSON = await readPackageJSON(path.resolve(projectDir, 'node_modules', 'electron-prebuilt-compile'));
Copy link
Member

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.

import path from 'path';
import readPackageJSON from './read-package-json';

export default async (projectDir) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);
Copy link
Member

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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

await

@jacobq
Copy link
Contributor Author

jacobq commented Mar 12, 2018

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

@jacobq
Copy link
Contributor Author

jacobq commented Mar 12, 2018

Oops, I'll add those missing awaits right now (originally I had it as a sync function).

@jacobq jacobq force-pushed the feat/allow-commitish-epc branch from 637bda6 to 1d701ad Compare March 12, 2018 22:03
@jacobq
Copy link
Contributor Author

jacobq commented Mar 12, 2018

@malept I've revised, rebased, and pushed. Please take another look when you have the chance.

@malept malept changed the title Feat/allow commitish epc feat(generic): allow specifying electron-prebuilt-compile via URL Mar 12, 2018
.gitignore Outdated
@@ -4,3 +4,6 @@ docs
.nyc_output
coverage
npm-debug.log
package-lock.json
yarn.lock
Copy link
Member

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.

export default async (projectDir) => {
let result = null;

const modulesToExamine = ['electron-prebuilt-compile', 'electron-compile', 'electron'];
Copy link
Member

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']

let result = null;

const modulesToExamine = ['electron-prebuilt-compile', 'electron-compile', 'electron'];
for (let i = 0; i < modulesToExamine.length; i += 1) {
Copy link
Member

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.

result = packageJSON.version;
break;
} catch (e) {
d(`Could not read package.json for moduleName=${moduleName}`);
Copy link
Member

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?

}

if (!result) {
d(`getElectronVersion failed to determine electron version: projectDir=${projectDir}, result=${result}`);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Electron version

@malept
Copy link
Member

malept commented Mar 12, 2018

@jacobq I talked to @MarshallOfSound briefly and we decided to hold off on merging this after we've merged the v6 branch to master, due to the significant amount of refactoring in that branch.

@jacobq
Copy link
Contributor Author

jacobq commented Mar 12, 2018

@malept OK, but I hope you'll keep this in mind / come back to it later. Thanks.

@malept
Copy link
Member

malept commented Mar 12, 2018

We're not going to close this PR 😄 we're more likely going to rebase this on the merged master after v6 is merged.

@malept
Copy link
Member

malept commented Mar 12, 2018

Also, I'm not immune to this, I have a PR that's being deferred for the same reason.

@malept
Copy link
Member

malept commented Apr 10, 2018

I'm going to merge this into the 5.x branch and then forward-port the change into the 6.x branch.

@malept malept changed the base branch from master to 5.x April 10, 2018 03:42
jacobq added 3 commits April 9, 2018 20:46

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
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.
@malept malept force-pushed the feat/allow-commitish-epc branch from 598e330 to de1634b Compare April 10, 2018 03:46
@malept malept merged commit 489a25c into electron:5.x Apr 10, 2018
dsanders11 pushed a commit that referenced this pull request Jan 14, 2023
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants