Skip to content

Commit

Permalink
feat: add create react app project
Browse files Browse the repository at this point in the history
adds create react app project

close #1
  • Loading branch information
hassan committed Nov 22, 2018
1 parent a56d2d9 commit 4ab0059
Show file tree
Hide file tree
Showing 23 changed files with 11,874 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
build
public
coverage
src/registerServiceWorker.js
cypress/integration/examples
44 changes: 44 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"extends": "airbnb",
"env": {
"browser": true,
"node": true,
"mocha": true,
"jest": true
},
"globals": {
"localStorage": true,
"document": true,
"window": true,
"cy": true,
"Cypress": true
},
"parser": "babel-eslint",
"rules": {
"no-underscore-dangle": [
"error",
{
"allow": [
"_id",
"__REDUX_DEVTOOLS_EXTENSION__",
"__coverage__"
]
}
],
"jsx-a11y/anchor-is-valid": [
"error",
{
"components": ["Link"],
"specialLink": ["to", "hrefLeft", "hrefRight"],
"aspects": ["noHref", "invalidHref", "preferButton"]
}
],
"react/jsx-filename-extension": [
1,
{
"extensions": [".js", ".jsx"]
}
],
"import/no-named-as-default": 0
}
}
54 changes: 54 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# package directories
jspm_packages
/node_modules

# serverless directories
.serverless

# testing
/coverage

# misc
.DS_Store
.env.*
env*

# include encrypted environment variables
!.env*.encrypted
!env*.encrypted

npm-debug.log*
yarn-debug.log*
yarn-error.log*
/dist/

# build
.webpack

# vim settings
.rootdir

# exclude logs
*.log

# exclude webstorm and idea files
.idea
*.iml

# exclude sublime project files
*.sublime-*

# exclude unused coverage information
.nyc_output
coverage.lcov

# cypress generated files
/cypress/screenshots
/cypress/videos

# production
build/*
!build/favicon.ico

# exclude keys
*.aes
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
save-exact=true
10 changes: 10 additions & 0 deletions assets/entitlements.mas.inherit.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.inherit</key>
<true/>
</dict>
</plist>
14 changes: 14 additions & 0 deletions assets/entitlements.mas.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.application-identifier</key>
<string>XXXXXXXXXX.com.your-domain</string>
<key>com.apple.security.network.client</key>
<true/>
<key>com.apple.security.files.user-selected.read-write</key>
<true/>
</dict>
</plist>
Binary file added assets/icon.icns
Binary file not shown.
Binary file added assets/icon.ico
Binary file not shown.
Binary file added assets/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added build/favicon.ico
Binary file not shown.
96 changes: 96 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
{
"name": "graasp-desktop",
"version": "0.1.0",
"description": "Building and Publishing a React Based Electron App From Scratch",
"private": false,
"author": "Juan Carlos Farah",
"license": "MIT",
"homepage": "./",
"main": "public/electron.js",
"keywords": [
"Example",
"React",
"Electron"
],
"scripts": {
"dev": "yarn react-scripts start",
"build": "react-scripts build",
"start": "concurrently \"cross-env BROWSER=none yarn react-scripts start\" \"wait-on http://localhost:3000 && electron .\"",
"pack": "electron-builder --dir",
"dist": "npx build --x64 --macos --win --linux --c.extraMetadata.main=build/electron.js -p always"
},
"dependencies": {
"@material-ui/core": "3.5.1",
"electron-is-dev": "1.0.1",
"electron-publisher-s3": "20.17.2",
"react": "16.6.3",
"react-dev-utils": "6.1.1",
"react-dom": "16.6.3"
},
"devDependencies": {
"concurrently": "4.1.0",
"cross-env": "5.2.0",
"electron": "3.0.10",
"electron-builder": "20.36.2",
"react-scripts": "2.1.1",
"version-bump-prompt": "4.2.1"
},
"build": {
"appId": "com.your-domain",
"compression": "normal",
"productName": "Example",
"directories": {
"buildResources": "build",
"output": "dist"
},
"mac": {
"icon": "assets/icon.icns",
"type": "distribution",
"target": [
"pkg",
"dmg",
"mas"
],
"publish": {
"provider": "s3",
"bucket": "example-releases",
"path": "releases"
},
"category": "public.app-category.news"
},
"mas": {
"entitlements": "assets/entitlements.mas.plist",
"entitlementsInherit": "assets/entitlements.mas.inherit.plist",
"provisioningProfile": "assets/embedded.provisionprofile"
},
"win": {
"target": "nsis",
"icon": "assets/icon.ico",
"publish": {
"provider": "s3",
"bucket": "example-releases",
"path": "releases"
}
},
"linux": {
"icon": "assets/icon.png",
"target": [
"snap",
"AppImage"
],
"description": "Example",
"category": "Network;Feed",
"publish": {
"provider": "s3",
"bucket": "example-releases",
"path": "releases"
}
}
},
"browserslist": [
">0.2%",
"not dead",
"not ie <= 11",
"not op_mini all"
]
}
143 changes: 143 additions & 0 deletions public/electron.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
const { app, BrowserWindow, shell, ipcMain, Menu, TouchBar } = require('electron');
const { TouchBarButton, TouchBarLabel, TouchBarSpacer } = TouchBar;

const path = require('path');
const isDev = require('electron-is-dev');

let mainWindow;

createWindow = () => {
mainWindow = new BrowserWindow({
backgroundColor: '#F7F7F7',
minWidth: 880,
show: false,
titleBarStyle: 'hidden',
webPreferences: {
nodeIntegration: false,
preload: __dirname + '/preload.js',
},
height: 860,
width: 1280,
});

mainWindow.loadURL(
isDev
? 'http://localhost:3000'
: `file://${path.join(__dirname, '../build/index.html')}`,
);

if (isDev) {
const {
default: installExtension,
REACT_DEVELOPER_TOOLS,
REDUX_DEVTOOLS,
} = require('electron-devtools-installer');

installExtension(REACT_DEVELOPER_TOOLS)
.then(name => {
console.log(`Added Extension: ${name}`);
})
.catch(err => {
console.log('An error occurred: ', err);
});

installExtension(REDUX_DEVTOOLS)
.then(name => {
console.log(`Added Extension: ${name}`);
})
.catch(err => {
console.log('An error occurred: ', err);
});
}

mainWindow.once('ready-to-show', () => {
mainWindow.show();

ipcMain.on('open-external-window', (event, arg) => {
shell.openExternal(arg);
});
});
};

generateMenu = () => {
const template = [
{
label: 'File',
submenu: [{ role: 'about' }, { role: 'quit' }],
},
{
label: 'Edit',
submenu: [
{ role: 'undo' },
{ role: 'redo' },
{ type: 'separator' },
{ role: 'cut' },
{ role: 'copy' },
{ role: 'paste' },
{ role: 'pasteandmatchstyle' },
{ role: 'delete' },
{ role: 'selectall' },
],
},
{
label: 'View',
submenu: [
{ role: 'reload' },
{ role: 'forcereload' },
{ role: 'toggledevtools' },
{ type: 'separator' },
{ role: 'resetzoom' },
{ role: 'zoomin' },
{ role: 'zoomout' },
{ type: 'separator' },
{ role: 'togglefullscreen' },
],
},
{
role: 'window',
submenu: [{ role: 'minimize' }, { role: 'close' }],
},
{
role: 'help',
submenu: [
{
click() {
require('electron').shell.openExternal(
'https://getstream.io/winds',
);
},
label: 'Learn More',
},
{
click() {
require('electron').shell.openExternal(
'https://github.com/GetStream/Winds/issues',
);
},
label: 'File Issue on GitHub',
},
],
},
];

Menu.setApplicationMenu(Menu.buildFromTemplate(template));
};

app.on('ready', () => {
createWindow();
generateMenu();
});

app.on('window-all-closed', () => {
app.quit();
});

app.on('activate', () => {
if (mainWindow === null) {
createWindow();
}
});

ipcMain.on('load-page', (event, arg) => {
mainWindow.loadURL(arg);
});
Binary file added public/favicon.ico
Binary file not shown.
Loading

0 comments on commit 4ab0059

Please sign in to comment.