Skip to content

Commit

Permalink
Upgrade Cerebro core update packages and improve project build (#559)
Browse files Browse the repository at this point in the history
* fix: removeNoise function not working correctly

* style: fix linter errors

* chore(deps): use exact dependencies

* CI: try build gh action

* ci: fix gh token

* ci: fix repo

* chore: small refactor

* chore: rm deprecated proptypes - use prop-types

* chore: small refactor

* fix: can not read getPrimarydisplay of undefined

* chore: update electron to v19

* chore: update deps

* chore: update deps

* chore: use new electron whenReady

* chore: lint webpack configs

* CI: delete unused files

* CI: run on workflow dispatch

* chore: update dev deps

* chore: update deps

* deps: update url-loader

* chore: fix plugin installation errors
chore: move to rimraf

* chore: fix building errors

* CI: run scripts in parallel

* chore: update babel

* chore: update webpack dev middleware

* chore: update cross-env

* chore: update redux

* chore: update linter config

* fix: quit app not working

* chore: remove unused code

* fix: remote module in background window

* chore: update deps, autoinstall app deps

* docs: update readme

* chore: minor fixes

* docs: two package.json msg + delete broken links

* ci: update workflows, work when tags pushed

* ci: test CI

* chore: fix babel target

* CI: test new release

* CI: test on release

* CI: run on gh release

* Update build.yml

* Update build.yml

* docs: update release configuration

* docs: target info

* docs: how to publish a release

* CI: run on git tags

* chore: move to @cerebroapp/cerebro-ui

* chore: add @cerebroapp/cerebro-ui dependency

* feat: support @cerebroapp in plugin names

* fix: handle @cerebroapp directory

* chore: refactor promises

* chore: small refactor

* chore: fix tests script

* CI: add tests to publish workflow

* chore: adjusting json package description and version

* chore: add new rule in eslint

* doc: update readme

* feat: add template string

* refactor: fix lint problems

* chore: remove comments

Co-authored-by: oguhpereira <[email protected]>
  • Loading branch information
dubisdev and ogustavo-pereira authored Jul 21, 2022
1 parent 606a1ba commit eaa59bf
Show file tree
Hide file tree
Showing 80 changed files with 5,216 additions and 5,242 deletions.
8 changes: 0 additions & 8 deletions .babelrc

This file was deleted.

2 changes: 0 additions & 2 deletions .eslintignore

This file was deleted.

10 changes: 6 additions & 4 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"parser": "babel-eslint",
"parser": "@babel/eslint-parser",
"extends": "airbnb",
"env": {
"browser": true,
Expand All @@ -16,6 +16,7 @@
"no-useless-escape": 0,
"no-mixed-operators": "off",
"no-continue": "off",
"no-unused-expressions": ["error", { "allowShortCircuit": true, "allowTernary": true }],
"import/no-extraneous-dependencies": "off",
"import/imports-first": "off",
"import/extensions": "off",
Expand All @@ -32,7 +33,8 @@
"prefer-spread": "off",
"class-methods-use-this": "off",
"jsx-a11y/no-static-element-interactions": "off",
"jsx-a11y/label-has-for": "off"
"jsx-a11y/label-has-for": "off",
"linebreak-style": 0
},
"plugins": [
"jsx-a11y",
Expand All @@ -43,8 +45,8 @@
"settings": {
"import/core-modules": "electron",
"import/resolver": {
"webpack": {
"config": "../webpack.config.base.js"
"node": {
"paths": ["app"]
}
}
}
Expand Down
41 changes: 41 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Build/release

on:
push:
tags:
- '*'

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Use Node.js 16
uses: actions/setup-node@v3
with:
node-version: 16
- run: yarn
- run: yarn test --detectOpenHandles --forceExit

release:
needs: test
runs-on: ${{ matrix.os }}

strategy:
matrix:
os: [ubuntu-latest, windows-latest]

steps:
- name: Check out Git repository
uses: actions/checkout@v3

- name: Install Node.js, NPM and Yarn
uses: actions/setup-node@v3
with:
node-version: 16

- name: Build & Release Electron app
uses: samuelmeuli/action-electron-builder@v1
with:
github_token: ${{ secrets.github_token }}
release: true
52 changes: 0 additions & 52 deletions .travis.yml

This file was deleted.

37 changes: 26 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,26 @@ First, clone the repo via git:
```bash
$ git clone https://github.com/cerebroapp/cerebro.git cerebro
```
Open the project

```bash
$ cd cerebro
```

And then install dependencies:


```bash
$ cd cerebro && yarn && cd ./app && yarn && cd ../
yarn
```

### Run

```bash
$ yarn run dev
```

> Note: requires a node version >=6.x
> Note: requires a node version >=16.x
### Resolve common issues
1. `AssertionError: Current node version is not supported for development` on npm postinstall.
Expand Down Expand Up @@ -90,19 +97,26 @@ Use this command to build `.app` file:
$ yarn build
```

## For developers

### Publish a release

## Be in touch
Follow to be notified about new releases or learn some productivity tips with Cerebro:
CerebroApp is using GH actions to build the app and publish it to a release. To publish a new release follow the steps below:

* [Twitter](https://twitter.com/cerebro_app)
* [Facebook](https://www.facebook.com/cerebroapp)
* [Google+](https://plus.google.com/104292436165594177472)
* [VK.com](https://vk.com/cerebroapp) – channel in Russian
1. Update the version on both `package.json` and `app/package.json` files.
2. Create a release with from GH and publish it. 🚧 The release **tag** SHOULD NOT contain the `v` prefix (❌ `v0.1.2` → ✅`0.1.2`).
3. Complete the name with a name and a description of the release.
4. The GH action is triggered and the release is updated when executables are built.

Or [subscribe to newsletter](http://eepurl.com/coiKU9) to be notified only about big releases.
### Add dependencies

CerebroApp was created from an [old version of electron-react-boilerplate](https://github.com/cerebroapp/cerebro/commit/57b6e28c0f64beae8948cf17f099fa5d6236ae3c) and uses a two package.json file structure. If you are interested in developing a new feature, you should read about this structure in the [electron-react-boilerplate documentation](https://www.electron.build/tutorials/two-package-structure.html).


# Support

## Support
### Backers

Support us with a monthly donation and help us continue our activities. [[Become a backer](https://opencollective.com/cerebro#backer)]

<a href="https://opencollective.com/cerebro/backer/0/website" target="_blank"><img src="https://opencollective.com/cerebro/backer/0/avatar.svg"></a>
Expand Down Expand Up @@ -171,4 +185,5 @@ Become a sponsor and get your logo on our README on Github with a link to your s
<a href="https://opencollective.com/cerebro/sponsor/29/website" target="_blank"><img src="https://opencollective.com/cerebro/sponsor/29/avatar.svg"></a>

## License
MIT © [Alexandr Subbotin](https://github.com/KELiON)

MIT © [Cerebro App](https://github.com/cerebroapp/cerebro/blob/master/LICENSE)
5 changes: 5 additions & 0 deletions __mocks__/@electron/remote.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
app: {
getPath: jest.fn(),
}
}
8 changes: 8 additions & 0 deletions __mocks__/electron.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module.exports = {
app: {
getPath: jest.fn(),
},
ipcRenderer: {
on: jest.fn(),
}
}
1 change: 1 addition & 0 deletions __mocks__/fileMock.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = ''
3 changes: 0 additions & 3 deletions __mocks__/lib/config.js

This file was deleted.

3 changes: 0 additions & 3 deletions __mocks__/lib/plugins.js

This file was deleted.

5 changes: 0 additions & 5 deletions __mocks__/plugins.js

This file was deleted.

16 changes: 8 additions & 8 deletions app/background/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,35 @@ import ReactDOM from 'react-dom'
import plugins from 'plugins'
import { on, send } from 'lib/rpc'
import { settings as pluginSettings, modulesDirectory } from 'lib/plugins'
import fixPath from 'fix-path'

require('fix-path')()
fixPath()

global.React = React
global.ReactDOM = ReactDOM
global.isBackground = true

on('initializePluginAsync', ({ name }) => {
console.group(`Initialize async plugin ${name}`)

try {
const { initializeAsync } = plugins[name]
? plugins[name]
: window.require(`${modulesDirectory}/${name}`)

if (!initializeAsync) {
console.log('no `initializeAsync` function, skipped')
return
}

console.log('running `initializeAsync`')
initializeAsync((data) => {
console.log('Done! Sending data back to main window')
// Send message back to main window with initialization result
send('plugin.message', {
name,
data,
})
send('plugin.message', { name, data })
}, pluginSettings.getUserSettings(name))
} catch (err) {
console.log('Failed', err)
}
} catch (err) { console.log('Failed', err) }

console.groupEnd()
})

Expand Down
1 change: 1 addition & 0 deletions app/background/createWindow.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export default ({ src }) => {
contextIsolation: false
},
})

backgroundWindow.loadURL(src)
return backgroundWindow
}
4 changes: 3 additions & 1 deletion app/background/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
(function() {
const script = document.createElement('script');
script.async = true;
script.src = (process.env.HOT) ? 'http://localhost:3000/dist/background.bundle.js' : '../dist/background.bundle.js';
script.src = (process.env.HOT)
? 'http://localhost:3000/dist/background.bundle.js'
: '../dist/background.bundle.js';
document.write(script.outerHTML);
}());
</script>
Expand Down
15 changes: 8 additions & 7 deletions app/initAutoUpdater.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import * as os from "os";
import { dialog, } from 'electron'
import { autoUpdater } from "electron-updater";
import { autoUpdater } from 'electron-updater'

const event = 'update-downloaded'

const TEN_SECONDS = 10 * 1000
const ONE_HOUR = 60 * 60 * 1000

export default (w) => {
if (process.env.NODE_ENV === 'development' || os.platform() === "linux") {
if (process.env.NODE_ENV === 'development' || process.platform === 'linux') {
return
}

Expand All @@ -18,9 +19,9 @@ export default (w) => {

setTimeout(() => {
autoUpdater.checkForUpdates()
}, 10 * 1000)
}, TEN_SECONDS)

setInterval(() => {
autoUpdater.checkForUpdates()
}, 60 * 60 * 1000)
}
}, ONE_HOUR)
}
13 changes: 9 additions & 4 deletions app/lib/config.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import { app, remote, ipcRenderer } from 'electron'
import { app, ipcRenderer } from 'electron'
import fs from 'fs'
import { memoize } from 'cerebro-tools'
import { trackEvent } from './trackEvent'
import loadThemes from './loadThemes'

const remote = process.type === 'browser'
? undefined
: require('@electron/remote')

const electronApp = remote ? remote.app : app

// initiate portable mode
Expand Down Expand Up @@ -55,13 +59,13 @@ const readConfig = () => {
*/
const get = (key) => {
let config

if (!fs.existsSync(CONFIG_FILE)) {
// Save default config to local storage
config = defaultSettings()
fs.writeFileSync(CONFIG_FILE, JSON.stringify(config, null, 2))
} else {
config = readConfig()
}
} else { config = readConfig() }

return config[key]
}

Expand All @@ -87,6 +91,7 @@ const set = (key, value) => {
event: `Change ${key}`,
label: value
})

if (ipcRenderer) {
console.log('notify main process', key, value)
// Notify main process about settings changes
Expand Down
Loading

0 comments on commit eaa59bf

Please sign in to comment.