2018-05-02 00:37:21 +02:00
# Contributor Guidelines
2015-01-20 06:33:06 +01:00
2016-02-26 02:01:34 +01:00
## Advice for new contributors
Start small. The PRs most likely to be merged are the ones that make small,
2018-01-11 02:47:22 +01:00
easily reviewed changes with clear and specific intentions. See below for more
2016-02-26 02:01:34 +01:00
[guidelines on pull requests ](#pull-requests ).
2017-09-20 00:31:04 +02:00
It's a good idea to gauge interest in your intended work by finding the current issue
for it or creating a new one yourself. You can use also that issue as a place to signal
your intentions and get feedback from the users most likely to appreciate your changes.
2018-01-11 02:47:22 +01:00
You're most likely to have your pull request accepted easily if it addresses bugs already
2018-01-30 23:22:51 +01:00
in the [Next Steps project ](https://github.com/signalapp/Signal-Desktop/projects/1 ),
2018-01-11 02:47:22 +01:00
especially if they are near the top of the Backlog column. Those are what we'll be looking
at next, so it would be a great help if you helped us out!
2017-09-20 00:31:04 +02:00
Once you've spent a little bit of time planning your solution, it's a good idea to go
back to the issue and talk about your approach. We'd be happy to provide feedback. [An
ounce of prevention, as they say!](https://www.goodreads.com/quotes/247269-an-ounce-of-prevention-is-worth-a-pound-of-cure)
2016-02-26 02:01:34 +01:00
2017-04-10 20:06:39 +02:00
## Developer Setup
2015-01-20 06:33:06 +01:00
2018-01-10 00:31:23 +01:00
First, you'll need [Node.js ](https://nodejs.org/ ) which matches our current version.
2018-01-30 23:22:51 +01:00
You can check [`.nvmrc` in the `development` branch ](https://github.com/signalapp/Signal-Desktop/blob/development/.nvmrc ) to see what the current version is. If you have [nvm ](https://github.com/creationix/nvm )
2018-01-10 00:31:23 +01:00
you can just run `nvm use` in the project directory and it will switch to the project's
desired Node.js version. [nvm for windows ](https://github.com/coreybutler/nvm-windows ) is
still useful, but it doesn't support `.nvmrc` files.
2017-09-20 00:31:04 +02:00
Then you need `git` , if you don't have that yet: https://git-scm.com/
2018-05-02 00:35:19 +02:00
### macOS
2015-01-20 06:33:06 +01:00
2018-05-02 00:35:19 +02:00
1. Install the [Xcode Command-Line Tools ](http://osxdaily.com/2014/02/12/install-command-line-tools-mac-os-x/ ).
### Windows
1. **Windows 7 only:** Install Microsoft .NET Framework 4.5.1:
https://www.microsoft.com/en-us/download/details.aspx?id=40773
1. Install _Windows Build Tools_ : Open the [Command Prompt (`cmd.exe`) as Administrator ](<https://technet.microsoft.com/en-us/library/cc947813(v=ws.10 ).aspx>)
and run: `npm install --global --production --add-python-to-path windows-build-tools`
### Linux
1. Pick your favorite package manager.
1. Install Python 2.x.
1. Install GCC.
2017-09-20 00:31:04 +02:00
2018-05-02 00:35:19 +02:00
### All platforms
2017-09-20 00:31:04 +02:00
Now, run these commands in your preferred terminal in a good directory for development:
2017-04-10 20:06:39 +02:00
```
2018-01-30 23:22:51 +01:00
git clone https://github.com/signalapp/Signal-Desktop.git
2017-09-20 00:31:04 +02:00
cd Signal-Desktop
2018-05-02 00:35:19 +02:00
npm install --global yarn # (only if you don’ t already have `yarn` )
2018-03-02 22:01:43 +01:00
yarn install --frozen-lockfile # Install and build dependencies (this will take a while)
yarn grunt # Generate final JS and CSS assets
yarn icon-gen # Generate full set of icons for Electron
yarn test # A good idea to make sure tests run first
yarn start # Start Signal!
2018-01-10 00:31:23 +01:00
```
2018-05-02 00:35:45 +02:00
You'll need to restart the application regularly to see your changes, as there
is no automatic restart mechanism. Alternatively, keep the developer tools open
(`View > Toggle Developer Tools`), hover over them, and press
< kbd > Cmd< / kbd > + < kbd > R< / kbd > (macOS) or < kbd > Ctrl< / kbd > + < kbd > R< / kbd >
(Windows & Linux).
2018-01-10 00:31:23 +01:00
Also, note that the assets loaded by the application are not necessarily the same files
2018-05-02 00:35:45 +02:00
you’ re touching. You may not see your changes until you run `yarn grunt` on the
2018-03-02 22:01:43 +01:00
command-line like you did during setup. You can make it easier on yourself by generating
the latest built assets when you change a file. Run this in its own terminal instance
while you make changes:
2018-01-10 00:31:23 +01:00
```
2018-03-02 22:01:43 +01:00
yarn grunt dev # runs until you stop it, re-generating built assets on file changes
2017-04-10 20:06:39 +02:00
```
2015-03-26 18:46:40 +01:00
2017-09-20 00:31:04 +02:00
## Setting up standalone
By default the application will connect to the **staging** servers, which means that you
**will not** be able to link it with your primary mobile device.
Fear not! You don't have to link the app with your phone. During setup in development
mode, you'll be presented with a 'Standalone' button which goes through the registration
process like you would on a phone. But you won't be linked to any other devices.
## The staging environment
2015-03-26 18:46:40 +01:00
2017-09-20 00:31:04 +02:00
Sadly, this default setup results in no contacts and no message history, an entirely
empty application. But you can use the information from your production install of Signal
Desktop to populate your testing application!
2015-03-26 18:46:40 +01:00
2017-09-20 00:31:04 +02:00
First, find your application data:
2018-05-02 00:37:21 +02:00
* OSX: `~/Library/Application Support/Signal`
* Linux: `~/.config/Signal`
* Windows 10: `C:\Users\<YourName>\AppData\Roaming\Signal`
2015-01-20 06:33:06 +01:00
2017-09-20 00:31:04 +02:00
Now make a copy of this production data directory in the same place, and call it
`Signal-development` . Now start up the development version of the app as normal,
and you'll see all of your contacts and messages!
2015-03-07 20:16:18 +01:00
2017-09-20 00:31:04 +02:00
You'll notice a prompt to re-link, because your production credentials won't work on
staging. Click 'Relink', then 'Standalone', then verify the phone number and click
'Send SMS.'
2015-01-20 06:33:06 +01:00
2017-09-20 00:31:04 +02:00
Once you've entered the confirmation code sent to your phone, you are registered as a
standalone staging device with your normal phone number, and a copy of your production
message history and contact list.
2015-01-20 06:33:06 +01:00
2017-09-20 00:31:04 +02:00
Here's the catch: you can't message any of these contacts, since they haven't done the
same thing. Who can you message for testing?
2015-03-03 20:15:28 +01:00
2017-09-20 00:31:04 +02:00
## Additional storage profiles
What you need for proper testing is additional phone numbers, to register additional
standalone devices. You can get them via
[Twilio ($1/mo. per number + $0.0075 per SMS) ](https://www.twilio.com/ ), or via
[Google Voice (one number per Google Account, free SMS) ](https://voice.google.com/ ).
Once you have the additional numbers, you can setup additional storage profiles and switch
between them using the `NODE_APP_INSTANCE` environment variable.
For example, to create an 'alice' profile, put a file called `local-alice.json` in the
`config` directory:
2017-04-13 05:38:49 +02:00
```
{
"storageProfile": "aliceProfile"
}
2017-09-20 00:31:04 +02:00
```
Then you can start up the application a little differently to load the profile:
2017-04-13 05:38:49 +02:00
2017-09-20 00:31:04 +02:00
```
NODE_APP_INSTANCE=alice yarn run start
2017-04-13 05:38:49 +02:00
```
This changes the [userData ](https://electron.atom.io/docs/all/#appgetpathname )
directory from `%appData%/Signal` to `%appData%/Signal-aliceProfile` .
2017-09-20 00:31:04 +02:00
# Making changes
So you're in the process of preparing that pull request. Here's how to make that go
smoothly.
## Tests
Please write tests! Our testing framework is
[mocha ](http://mochajs.org/ ) and our assertion library is
[chai ](http://chaijs.com/api/assert/ ).
2018-01-10 00:31:23 +01:00
The easiest way to run all tests at once is `yarn test` .
2018-03-23 15:21:31 +01:00
You can browse tests from the command line with `grunt unit-tests` or in an
2018-01-10 00:31:23 +01:00
interactive session with `NODE_ENV=test yarn run start` . The `libtextsecure` tests are run
similarly: `grunt lib-unit-tests` and `NODE_ENV=test-lib yarn run start` . You can tweak
the appropriate `test.html` for both of these runs to get code coverage numbers via
`blanket.js` (it's shown at the bottom of the web page when the run is complete).
To run Node.js tests, you can run `yarn test-server` from the command line. You can get
code coverage numbers for this kind of run via `yarn test-server-coverage` , then display
the report with `yarn open-coverage` .
2017-09-20 00:31:04 +02:00
2015-01-20 06:33:06 +01:00
## Pull requests
So you wanna make a pull request? Please observe the following guidelines.
2018-05-02 00:37:21 +02:00
* Please do not submit pull requests for translation fixes. Anyone can update
the translations in
[Transifex ](https://www.transifex.com/projects/p/signal-desktop ).
* Never use plain strings right in the source code - pull them from `messages.json` !
You **only** need to modify the default locale
[`_locales/en/messages.json` ](_locales/en/messages.json ). Other locales are generated
automatically based on that file and then periodically uploaded to Transifex for
translation.
* [Rebase ](https://nathanleclaire.com/blog/2014/09/14/dont-be-scared-of-git-rebase/ ) your
changes on the latest `development` branch, resolving any conflicts.
This ensures that your changes will merge cleanly when you open your PR.
* Be sure to add and run tests!
* Make sure the diff between our master and your branch contains only the
minimal set of changes needed to implement your feature or bugfix. This will
make it easier for the person reviewing your code to approve the changes.
Please do not submit a PR with commented out code or unfinished features.
* Avoid meaningless or too-granular commits. If your branch contains commits like
the lines of "Oops, reverted this change" or "Just experimenting, will
delete this later", please [squash or rebase those changes away ](https://robots.thoughtbot.com/git-interactive-rebase-squash-amend-rewriting-history ).
* Don't have too few commits. If you have a complicated or long lived feature
branch, it may make sense to break the changes up into logical atomic chunks
to aid in the review process.
* Provide a well written and nicely formatted commit message. See [this
link](http://chris.beams.io/posts/git-commit/)
for some tips on formatting. As far as content, try to include in your
summary
1. What you changed
2. Why this change was made (including git issue # if appropriate)
3. Any relevant technical details or motivations for your implementation
choices that may be helpful to someone reviewing or auditing the commit
history in the future. When in doubt, err on the side of a longer
commit message.
2015-01-20 06:33:06 +01:00
2017-09-20 00:31:04 +02:00
Above all, spend some time with the repository. Follow the pull request template added to
your pull request description automatically. Take a look at recent approved pull requests,
see how they did things.
## Linking to a staging mobile device
Multiple standalone desktop devices are great for testing of a lot of scenarios. But a lot
of the Signal experience requires a primary mobile device: contact management,
synchronizing read and verification states among all linked devices, etc.
This presents a problem - even if you had another phone, the production versions of the
iOS and Android apps are locked to the production servers. To test all secenarios in
staging, your best bet is to pull down the development version of the iOS or Android app,
and register it with one of your extra phone numbers:
First, build Signal for Android or iOS from source, and point its TextSecure service URL to `textsecure-service-staging.whispersystems.org` :
2018-01-30 23:22:51 +01:00
**on Android:** Replace the `SIGNAL_URL` value in [build.gradle ](https://github.com/signalapp/Signal-Android/blob/master/build.gradle )
2017-09-20 00:31:04 +02:00
**on iOS:** Replace the `textSecureServerURL` value in `TSConstants.h` (located in the SignalServiceKit pod)
This task is 1% search and replace, 99% setting up your build environment. Instructions are available for both
2018-01-30 23:22:51 +01:00
the [Android ](https://github.com/signalapp/Signal-Android/blob/master/BUILDING.md )
and [iOS ](https://github.com/signalapp/Signal-iOS/blob/master/BUILDING.md ) projects.
2017-09-20 00:31:04 +02:00
Then you can set up your development build of Signal Desktop as normal. If you've already
set up as a standalone install, you can switch by opening the DevTools (View -> Toggle
Developer Tools) and entering this into the Console and pressing enter: `window.owsDesktopApp.appView.openInstaller();`
## Changing to production
If you're completely sure that your changes will have no impact to the production servers,
you can connect your development build to the production server by putting a file called
`local-development.json` in the `config` directory that looks like this:
```
{
"serverUrl": "https://textsecure-service.whispersystems.org",
"cdnUrl": "https://cdn.signal.org"
}
```
**Beware:** Setting up standalone with your primary phone number when connected to the
production servers will _unregister_ your mobile device! All messages from your contacts
will go to your new development desktop app instead of your phone.
2018-01-10 00:31:23 +01:00
## Testing Production Builds
To test changes to the build system, build a release using
2018-05-02 00:37:21 +02:00
2018-01-10 00:31:23 +01:00
```
yarn generate
yarn build-release
```
2018-05-02 00:37:21 +02:00
Then, run the tests using `grunt test-release:osx --dir=release` , replacing `osx` with `linux` or `win` depending on your platform.
2018-01-10 00:31:23 +01:00
2018-05-02 18:35:23 +02:00
## Translations
2015-01-20 06:33:06 +01:00
2018-05-02 18:35:23 +02:00
To pull the latest translations, follow these steps:
2015-01-20 06:33:06 +01:00
2018-05-02 18:35:23 +02:00
1. Download Transifex client:
https://docs.transifex.com/client/installing-the-client
1. Create Transifex account: https://transifex.com
1. Generate API token: https://www.transifex.com/user/settings/api/
1. Create `~/.transifexrc` configuration:
https://docs.transifex.com/client/client-configuration#-transifexrc
1. Run `yarn grunt tx` .