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

Use camelCase identifiers in the JS API #580

Merged
merged 3 commits into from
Feb 27, 2017
Merged

Conversation

j-f1
Copy link
Contributor

@j-f1 j-f1 commented Feb 7, 2017

This fixes #325.

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.

Thank you for the PR, I had no idea when I was going to get to this.

Some general comments:

  • I'm not really a fan of having a separate list of parameters that need to be maintained. I think what I want to do here is in the next major version, get rid of that and use the camelize module.
  • In the meantime, can we have a few tests for camelCase?

common.js Outdated
Object.keys(module.exports.kebabProperties).forEach(function (key) {
var value = module.exports.kebabProperties[key]
if (properties.hasOwnProperty(key)) {
warn && warning(`The ${key} parameter is deprecated when used from JS, use ${value} instead`)
Copy link
Member

Choose a reason for hiding this comment

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

I would prefer it if this was a full-fledged if statement.

Copy link
Member

Choose a reason for hiding this comment

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

Also, it should be mentioned that the old property is going to be removed in the next major version.

@malept
Copy link
Member

malept commented Feb 7, 2017

@j-f1 It looks like there's a problem in win32.js, take a look at the test output.

Also, what part of the testsuite is not running locally?

@malept malept added docs-needed 📝 Pull request needs documentation enhancement Feature request needs work 🚧 Feature request needs to be fleshed out before maintainers can take action on it tests-needed Pull request needs tests labels Feb 7, 2017
@malept
Copy link
Member

malept commented Feb 7, 2017

Could you also add a NEWS entry? (An entry under both "Changed" and "Deprecated".)

@j-f1
Copy link
Contributor Author

j-f1 commented Feb 9, 2017

@malept Sorry for the delay. I’ve added the changes requested.

The problem doesn’t make sense. Presumably, the files are minified somehow (see this line).

When I try to run the test locally, it downloads Electron, then nothing happens.

I’m also not exactly sure what to test for camelCase.

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.

  • The tests are still broken: https://travis-ci.org/electron-userland/electron-packager/jobs/199956707#L4331
  • For new tests, I would take one of the attributes that you know will be converted and directly test the camelCase function. (I guess in test/basic.js?)
  • Regarding your local tests problem: Try running the tests with the environment variable DEBUG="*" set, and paste the output somewhere accessible.

NEWS.md Outdated
@@ -2,6 +2,12 @@

## Unreleased

### Changed
* The JS API now uses camelCase identifiers.
Copy link
Member

Choose a reason for hiding this comment

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

Options previously formatted in kebab-case (i.e., with hyphens) are now available in camelCase, per JavaScript naming standards (#580)

NEWS.md Outdated
* The JS API now uses camelCase identifiers.

### Deprecated
* Using kebab-case keys for the JS API is deprecated. Please use camelCase.
Copy link
Member

Choose a reason for hiding this comment

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

Options currently formatted in kebab-case (i.e., with hyphens) are deprecated in favor of their camelCase variants, per JavaScript naming standards (#580)

docs/api.md Outdated
@@ -51,13 +51,13 @@ An array of functions to be called after Electron has been extracted to a tempor

When `true`, sets both [`arch`](#arch) and [`platform`](#platform) to `all`.

##### `app-copyright`
##### `appCopyright`
Copy link
Member

Choose a reason for hiding this comment

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

For the docs, what I typically do when I'm renaming an option is add an entry for the old name with the type and a deprecated message (for example: version-string)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@malept Should I place the deprecated names right underneath the new one, or should I group them at the bottom?

Copy link
Member

Choose a reason for hiding this comment

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

Please keep the options alphabetized, so probably place the deprecated options somewhere above their respective new names.

common.js Outdated
'helper-bundle-id': 'helperBundleId',
'osx-sign': 'osxSign',
'protocol-name': 'protocolName',
'version-string': 'versionString'
Copy link
Member

Choose a reason for hiding this comment

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

There's no point in camel-casing version-string, it's deprecated.

@malept
Copy link
Member

malept commented Feb 9, 2017

The problem doesn’t make sense. Presumably, the files are minified somehow

I think this is an artifact of the code coverage module.

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.

I figured out what caused the test failure.

win32.js Outdated
if (opts['app-copyright']) {
rcOpts['version-string'].LegalCopyright = opts['app-copyright']
if (opts.appCopyright) {
rcOpts.versionString.LegalCopyright = opts.appCopyright
Copy link
Member

Choose a reason for hiding this comment

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

This is incorrect, rcOpts is for the rcedit module. I take it you did a global search/replace?

win32.js Outdated
}

if (opts.icon || opts.win32metadata || opts['version-string'] || opts['app-copyright'] || opts['app-version'] || opts['build-version']) {
if (opts.icon || opts.win32metadata || opts.versionString || opts.appCopyright || opts.appVersion || opts.buildVersion) {
Copy link
Member

@malept malept Feb 9, 2017

Choose a reason for hiding this comment

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

Revert the opts.versionString change, please.

@j-f1 j-f1 changed the title Use camelCase identifiers in the JS API. Use camelCase identifiers in the JS API Feb 9, 2017
docs/api.md Outdated
*Object* or *`true`*

If present, signs OS X target apps when the host platform is OS X and XCode is installed. When the value is `true`, pass default configuration to the signing module. The configuration values listed below can be customized when the value is an `Object`. See [electron-osx-sign](https://www.npmjs.com/package/electron-osx-sign#opts) for more detailed option descriptions and the defaults.
- `identity` (*String*): The identity used when signing the package via `codesign`.
- `entitlements` (*String*): The path to the 'parent' entitlements.
- `entitlements-inherit` (*String*): The path to the 'child' entitlements.



Copy link
Member

Choose a reason for hiding this comment

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

Unnecessary whitespace

docs/api.md Outdated

*String* (**deprecated** and will be removed in a future major version, please use the
[`electronVersion`](#electronVersion) parameter instead)

Copy link
Member

Choose a reason for hiding this comment

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

This never existed as a JavaScript API option.

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.

I've squashed your commits, fixed up the NEWS entries, and added a separate test for camelCase. I'll merge once the tests run satisfactorily.

Thanks for your work on this!

@malept malept merged commit ae6f036 into electron:master Feb 27, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs-needed 📝 Pull request needs documentation enhancement Feature request needs work 🚧 Feature request needs to be fleshed out before maintainers can take action on it tests-needed Pull request needs tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Programmatic API options should follow Javascript naming conventions
2 participants