Skip to content
This repository has been archived by the owner on Sep 29, 2023. It is now read-only.

Commit

Permalink
Revamp and move to TypeScript
Browse files Browse the repository at this point in the history
  • Loading branch information
ronjouch committed Feb 1, 2020
1 parent b927b40 commit cba9ab2
Show file tree
Hide file tree
Showing 111 changed files with 1,820 additions and 2,239 deletions.
18 changes: 0 additions & 18 deletions .codeclimate.yml

This file was deleted.

18 changes: 10 additions & 8 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
# https://github.com/typescript-eslint/typescript-eslint/blob/master/docs/getting-started/linting/README.md
root: true
parser: '@typescript-eslint/parser'
plugins:
- '@typescript-eslint'
- prettier
extends:
- airbnb-base
- eslint:recommended
- prettier
- 'plugin:@typescript-eslint/eslint-recommended'
- 'plugin:@typescript-eslint/recommended'
env:
# TODO: find out how to turn this on only for src/**/*.test.js files
jest: true
plugins:
- import
- prettier
rules:
# TODO: Remove this when we have shifted away from the async package
no-shadow: 'warn'
# Gulpfiles and tests use dev dependencies
import/no-extraneous-dependencies: ['error', { devDependencies: ['gulpfile.babel.js', 'gulp/**/**.js', 'test/**/**.js']}]
prettier/prettier: "error"
'@typescript-eslint/no-explicit-any': 'off'
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
package-lock.json

# ignore compiled lib files
lib/*
lib*
app/lib/*
built-tests

Expand Down
7 changes: 0 additions & 7 deletions .hound.yml

This file was deleted.

10 changes: 5 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ addons:
code_climate:
repo_token: CODE_CLIMATE_TOKEN
node_js:
- '11'
- '13'
- '12'
- '10'
- '8'
- '7'
- '6'
before_install:
- npm install -g npm@5.8.x
- npm install -g npm@latest
install:
- npm run dev-up
- npm install
- npm run build
script:
- npm run ci
after_script:
Expand Down
45 changes: 43 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
[![npm version](https://badge.fury.io/js/nativefier.svg)](https://www.npmjs.com/package/nativefier)
[![Dependency Status](https://david-dm.org/jiahaog/nativefier.svg)](https://david-dm.org/jiahaog/nativefier)

![Dock](screenshots/dock.png)
![Dock](dock.png)

You want to make a native wrapper for WhatsApp Web (or any web page).

```bash
nativefier web.whatsapp.com
```

![Walkthrough](screenshots/walkthrough.gif)
![Walkthrough](walkthrough.gif)

You're done.

Expand Down Expand Up @@ -121,3 +121,44 @@ You can also pass nativefier flags, and mount additional volumes to provide loca
## License

[MIT](LICENSE.md)

## TS: Minimum to release beta

- [x] Move cli to TS
- [x] Move app to TS
- [x] Package.json nits: move away from "^A.B.C" to more understandable "A.x
- [x] Upgrade electron-packager and other deps
- [x] Fix node_modules badly pruned when copied to app
- [x] Get rid of Babel / webpack
- [x] Move from Gulp to simple npm scripts
- [x] Replace quirky & broken `progress` with basic logging and restore electron-packager logging
- [x] Replace `async` module + callbacks with real native async/await
- [x] Cleanup/port old npm tasks/scripts
- [x] Make exports more idiomatic without default & index.ts crap
- [x] Get rid of micro-packages easily inlined
- [x] Cleanup pass on cli/app code to make more modern async TS idiomatic
- [x] More verbose & normal logging everywhere
- [x] Disable logging by default in tests & add tasks to enable at any level.
- [x] Fix icon not showing up on Linux
- [ ] Add tests & typing
- [ ] Add coverage report and improve coverage
- [ ] Windows & macOS smoke test
- [ ] More typing and testing of what's passed to electron-packager
- [ ] Review .npmignore and published zip. Test installing it.
- [ ] Address TODOs in code
- [ ] Warn on using electron < 7

## TS: Post-beta/launch improvements

- [ ] Check perms to write dest dir, and error nicely if not writable
- [ ] ncp async wrapper
- [ ] `test` task: unit & integration tests in parallel, for speed
- [ ] Maybe replace loglevel.
- [ ] GitHub: Create PR template, review Issue template
- [ ] Improve typing and remove remaining `@ts-ignore`s
- [ ] ESLint cleanup: upgrade, review rules, move away from yml
- [ ] Tweak tsconfigs: make tsc strict(er)
- [ ] Use new TS project build system
- [ ] Move all src to src (/{cli, app})
- [ ] Produce cleaner output dir structure (output to /lib, not /lib/src)
- [ ] Measure build time improvement
33 changes: 17 additions & 16 deletions app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,24 @@
"version": "1.0.0",
"description": "Placeholder for the nativefier cli to override with a target url",
"main": "lib/main.js",
"dependencies": {
"electron-context-menu": "^0.10.0",
"electron-dl": "^1.10.0",
"electron-squirrel-startup": "^1.0.0",
"electron-window-state": "^4.1.1",
"loglevel": "^1.5.1",
"source-map-support": "^0.5.0",
"wurl": "^2.5.2"
},
"devDependencies": {},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Jia Hao",
"license": "MIT",
"keywords": [
"desktop",
"electron"
"electron",
"placeholder"
],
"author": "Jia Hao",
"license": "MIT"
"scripts": {},
"dependencies": {
"electron-context-menu": "0.x",
"electron-dl": "3.x",
"electron-squirrel-startup": "1.x",
"electron-window-state": "5.x",
"loglevel": "1.x",
"source-map-support": "0.x",
"wurl": "2.x"
},
"devDependencies": {
"electron": "7.x"
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { shell } from 'electron';
import contextMenu from 'electron-context-menu';

function initContextMenu(createNewWindow, createNewTab) {
export function initContextMenu(createNewWindow, createNewTab): void {
contextMenu({
prepend: (params) => {
prepend: (actions, params) => {
const items = [];
if (params.linkURL) {
items.push({
Expand Down Expand Up @@ -31,5 +31,3 @@ function initContextMenu(createNewWindow, createNewTab) {
},
});
}

export default initContextMenu;
Original file line number Diff line number Diff line change
@@ -1,25 +1,22 @@
import * as path from 'path';

import { BrowserWindow, ipcMain } from 'electron';
import path from 'path';

function createLoginWindow(loginCallback) {
export function createLoginWindow(loginCallback): BrowserWindow {
const loginWindow = new BrowserWindow({
width: 300,
height: 400,
frame: false,
resizable: false,
webPreferences: {
nodeIntegration: true,
nodeIntegration: true, // TODO work around this; insecure
},
});
loginWindow.loadURL(
`file://${path.join(__dirname, '/static/login/login.html')}`,
);
loginWindow.loadURL(`file://${path.join(__dirname, '/static/login.html')}`);

ipcMain.once('login-message', (event, usernameAndPassword) => {
loginCallback(usernameAndPassword[0], usernameAndPassword[1]);
loginWindow.close();
});
return loginWindow;
}

export default createLoginWindow;

0 comments on commit cba9ab2

Please sign in to comment.