# Technical Documentation: Automattic/simplenote-electron

> ℹ️ **Provenance:** Multi-Tier Ingestion · [CodeWiki Reference](https://codewiki.google/github.com/Automattic/simplenote-electron)

### Overview (`README.md`)

# Simplenote for Electron



A Simplenote [React](https://reactjs.org/) client packaged in [Electron](https://electronjs.org/). Learn more about Simplenote at [Simplenote.com](https://simplenote.com).

## Running

**Read this first!!** Local development is currently not supported if you don't have an existing account on the test server or access to the production credentials. This is because the move to an email-first signup flow has made it impossible to create accounts in the test database. We hope to be able to support an open-source development workflow again in the future.

1. Clone the repo: `git clone https://github.com/Automattic/simplenote-electron.git`
2. `cd simplenote-electron`
3. `npm install --legacy-peer-deps` (This flag is necessary because `react-monaco-editor` is pinned to a specific `monaco-editor` dependency, but `npm` [considers minor versions to be breaking changes for sub-1.0.0 apps](https://stackoverflow.com/questions/62629878/why-doesnt-npm-upgrade-install-my-0-0-1-dep-with-a-dependency-on-0-0-0))
4. Decrypt the config file using `make decrypt_conf`.
5. `npm run dev`
6. The dev server will start on [http://localhost:4000](http://localhost:4000), and the Electron app will launch automatically.
7. For all logging from Electron to be printed to the terminal (e.g. `console.log` statements within `app.js`), you might need to set `env ELECTRON_ENABLE_LOGGING=1`.

_Note: Simplenote API features such as sharing and publishing will not work with development builds. Due to a limitation of `make`, installation paths used for build cannot have spaces._

## Building

- **`make package-osx`**
- **`make package-win32`**
- **`make package-linux`**

## Testing

Unit tests are run with `npm test`.

## Coding Guidelines

Please adhere to the same guidelines as found in [wp-calypso](https://github.com/Automattic/wp-calypso/blob/master/docs/coding-guidelines.md).

See <a href="./CONTRIBUTING.md">CONTRIBUTING.md</a> for more guidelines.

## Dependencies

- [node-simperium](https://github.com/Simperium/node-simperium) for Simperium syncing.
- [ReactJS](https://reactjs.org/) for UI.
- [Electron](https://electronjs.org/) for wrapping the JavaScript application.
- `rpm` must be installed in order to build Linux packages (`brew install rpm` on OSX).

## Simplenote for Other Platforms

[simplenote-electron](https://github.com/Automattic/simplenote-electron) is the official Simplenote desktop app for Windows and Linux.

For other platforms, see:

- [simplenote-macos](https://github.com/Automattic/simplenote-macos)
- [simplenote-ios](https://github.com/Automattic/simplenote-ios)
- [simplenote-android](https://github.com/Automattic/simplenote-android)

---

### Overview (`desktop/app-quit/README.md`)

App Quit
=========

Determines whether the app should quit and exit, or quit to background.

Note that the implementation of quit-to-background is left up to `platform`.

---

### Overview (`desktop/updater/README.md`)

Updater
=========

Uses either the manual or auto updater to check for updates.

The config `updater.url` is used as the base URL and has the platform, version, and beta setting appended.

The updater uses:

- [Auto Updater](auto-updater/README.md)
- [Manual Updater](manual-updater/README.md)

---

### Overview (`lib/analytics/README.md`)

Analytics
=========

This module is a simplified version of the analytics module found in WP-Calypso.

Original: https://github.com/Automattic/wp-calypso/tree/master/client/analytics

## Tracks API

### analytics#tracks#recordEvent( eventName, eventProperties )

Record an event with optional properties:

```js
analytics.tracks.recordEvent( 'calypso_checkout_coupon_apply', {
	'coupon_code': 'abc123'
} );
```

---

### Overview (`desktop/updater/auto-updater/README.md`)

Auto Updater
=========

Handles Squirrel auto-update events. Note that the app must be signed for this to work.

## Functions

`ping()` - checks for an update

---

### Overview (`desktop/updater/manual-updater/README.md`)

Manual Updater
=========

Provides a manual updater on platforms where the auto updater does not work.

If an update is detected then a dialog is shown with a link to the update for download.

The update is shown once until the app is restarted.

## Functions

`ping()` - checks for an update

---

### Overview (`lib/utils/export/README.md`)

# Simplenote Export

This module provides a couple of functions for exporting all of the notes in the active account.

The output of `exportNote()` is an object containing a map of two arrays: the active notes in an account; the trashed notes in an account.

The notes will be sorted by last modification time with the most recently-modified notes appearing first in the list.

The output from `exportNotes()` can be fed into `noteExportToZip()` to generate a [JSZip](https://github.com/Stuk/jszip) object containing the information for creating a zip archive of the notes.
This archive contains each note as its own file with a generated filename and the list of associated tags at the end of the content.

## Example export

```json
{
  "activeNotes": [ {
    "id": "some-auto-generated-id",
    "content": "Simplenote is so simple! I love it.",
    "creationDate": "2016-11-18T23:28:42.957Z",
    "lastModified": "2016-12-22T21:59:36.623Z"
  }, {
    "id": "some-auto-generated-id-that-is-unique",
    "content": "This note can be accessed from a secret URL",
    "creationDate": "2016-07-02T07:24:22.699Z",
    "lastModified": "2016-11-29T16:55:49.890Z",
    "publicURL": "http://simp.ly/p/short-url-string"
  }, {
    "id": "some-auto-generated-id-again",
    "content": "Sharing is caring",
    "creationDate": "2016-10-01T08:40:33.968Z",
    "lastModified": "2016-10-30T01:57:56.050Z",
    "tags": [
      "reminders",
      "people"
    ],
    "collaboratorEmails": [
      "prince@example.com",
      "pauper@example.com"
    ]
  } ],
  "trashedNotes": [ {
    "id": "some-different-auto-generated-id",
    "content": "This note is no longer relevant",
    "creationDate": "2015-11-18T10:13:42.138Z",
    "lastModified": "2016-01-13T14:03:33.583Z",
    "tags": [
      "the departed"
    ]
  } ]
}
```

---

### Overview (`lib/utils/import/README.MD`)

# Simplenote Import

This is the core importer for Simplenote. It expects an object of notes in the same format as the `import` module. It is aggressive about only allowing certain properties, and converts dates into timestamps where appropriate. Importing specific export files (Such as Evernote .enex) should use a separate conversion script and then pass the resulting object to `importNotes()`.

Example object with allowed properties:

```
{
  "activeNotes": [
    {
      "content": "Random thought: How much wood could a woodchuck chuck if a woodchuck could chuck wood?",
      "creationDate": "2013-10-16T20:17:41.760Z",
      "lastModified": "2018-10-10T22:07:54.128Z",
      "pinned": true,
      "tags": [
        "Reminders"
      ]
    },
  ],
  "trashedNotes": [
    {
      "content": "Hello, world!",
      "creationDate": "2016-02-29T23:01:03.115Z",
      "lastModified": "2016-02-29T23:01:08.000Z"
    }
  ]
}
```

---

### Packaging (`docs/packaging.md`)

# Building a Release

* `make osx`
* `make linux`
* `make win32`

# Packaging

Some builds require further packaging before they can be released:

* `make package-win32` - Produces a signed `Setup.exe` install wizard
* `make package-osx` - Produces a `DMG` file
* `make package-linux` - Produces a `.deb`, `.rpm` and `.AppImage` file for `x86` and `x64` processors


# Requirements

## Mac Package

A Mac build requires the app to be signed. This prevents a security warning being issued when you run the app.

You can obtain all the appropriate signing certificates from an Apple Developer account.

Note that you need the certificates installed prior to building.

## Windows Package

The Windows package requires installing a valid certificate, installing the `makensis`, `wine` and `mono` packages, installable from `brew`.

`brew install mono wine makensis`

The Windows build doesn't get signed until the packaging stage.

## Linux Package

The Linux package is built using [electron-builder][1] which is a tool that makes it easy to build different package systems. electron-builder should be installed by `npm install`.

### Note for creating Linux package on Linux

1. Creating all Linux packages requires tool for converting `.icns` file to `.png`. May be installed via `apt` by typing:

   `sudo apt install --no-install-recommends -y icnsutils `

2. Creating `.rpm` package requires `rpm` package, installable from 'apt'.

   `sudo apt install --no-install-recommends -y rpm`

### Note for creating Linux package on MacOS:

1. Creating Linux package on MacOS requires `rpm` package, installable from `brew`.

   `brew install rpm`

[1]: https://www.electron.build/

---

--- METRICS ---
- Files Extracted: 9
- Estimated Token Budget: ~2224 tokens
- Canonical Reference: https://codewiki.google/github.com/Automattic/simplenote-electron
