uninstall electron-forge, switch to manual webpack for frontend/tsc for backend, install eslint
This commit is contained in:
parent
609803ff23
commit
be39755762
|
@ -0,0 +1,2 @@
|
||||||
|
dist
|
||||||
|
frontend
|
|
@ -0,0 +1,9 @@
|
||||||
|
{
|
||||||
|
"root": true,
|
||||||
|
"extends": ["eslint:recommended", "plugin:prettier/recommended"],
|
||||||
|
"env": {
|
||||||
|
"es6": true,
|
||||||
|
"browser": true,
|
||||||
|
"node": true
|
||||||
|
}
|
||||||
|
}
|
|
@ -3,4 +3,4 @@ node_modules
|
||||||
|
|
||||||
# generated code
|
# generated code
|
||||||
dist
|
dist
|
||||||
.webpack
|
frontend
|
||||||
|
|
|
@ -1,3 +0,0 @@
|
||||||
declare module '*.svelte';
|
|
||||||
|
|
||||||
declare const MAIN_WINDOW_WEBPACK_ENTRY: string;
|
|
|
@ -5,4 +5,5 @@
|
||||||
<title>Renai</title>
|
<title>Renai</title>
|
||||||
</head>
|
</head>
|
||||||
<body id="app"></body>
|
<body id="app"></body>
|
||||||
|
<script src="./frontend/bundle.js"></script>
|
||||||
</html>
|
</html>
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
44
package.json
44
package.json
|
@ -4,20 +4,25 @@
|
||||||
"description": ".",
|
"description": ".",
|
||||||
"private": true,
|
"private": true,
|
||||||
"author": "Xymorot",
|
"author": "Xymorot",
|
||||||
"main": "./.webpack/main",
|
"main": "dist/main.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "electron-forge start",
|
"start": "electron .",
|
||||||
|
"dev": "electron . --debug",
|
||||||
|
"tsc": "tsc --watch",
|
||||||
|
"webpack": "webpack --watch",
|
||||||
|
"eslint-check": "eslint --print-config . | eslint-config-prettier-check",
|
||||||
|
"eslint": "eslint .",
|
||||||
"tslint-check": "tslint-config-prettier-check ./tslint.json",
|
"tslint-check": "tslint-config-prettier-check ./tslint.json",
|
||||||
"tslint": "tslint -t stylish -c tslint.json -p tsconfig.json",
|
"tslint": "tslint -t stylish -c tslint.json -p tsconfig.json",
|
||||||
"prettier": "prettier --ignore-path .gitignore -c **/*.{html,json,{c,sc,sa,le}ss,yml}"
|
"prettier": "prettier --ignore-path .gitignore -c **/*.{html,json,{c,sc,sa,le}ss,yml}"
|
||||||
},
|
},
|
||||||
"dependencies": {},
|
"dependencies": {},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@electron-forge/cli": "^6.0.0-beta.39",
|
|
||||||
"@electron-forge/plugin-webpack": "^6.0.0-beta.39",
|
|
||||||
"@types/webpack": "^4.4.32",
|
"@types/webpack": "^4.4.32",
|
||||||
"@zeit/webpack-asset-relocator-loader": "^0.5.0",
|
|
||||||
"electron": "^5.0.3",
|
"electron": "^5.0.3",
|
||||||
|
"eslint": "^5.16.0",
|
||||||
|
"eslint-config-prettier": "^5.0.0",
|
||||||
|
"eslint-plugin-prettier": "^3.1.0",
|
||||||
"prettier": "^1.18.2",
|
"prettier": "^1.18.2",
|
||||||
"svelte": "^3.5.1",
|
"svelte": "^3.5.1",
|
||||||
"svelte-loader": "^2.13.4",
|
"svelte-loader": "^2.13.4",
|
||||||
|
@ -25,30 +30,9 @@
|
||||||
"tslint": "^5.17.0",
|
"tslint": "^5.17.0",
|
||||||
"tslint-config-prettier": "^1.18.0",
|
"tslint-config-prettier": "^1.18.0",
|
||||||
"tslint-plugin-prettier": "^2.0.1",
|
"tslint-plugin-prettier": "^2.0.1",
|
||||||
"typescript": "^3.5.1",
|
"typescript": "^3.5.2",
|
||||||
"typescript-tslint-plugin": "^0.4.0",
|
"typescript-tslint-plugin": "^0.5.0",
|
||||||
"webpack": "^4.33.0"
|
"webpack": "^4.34.0",
|
||||||
},
|
"webpack-cli": "^3.3.4"
|
||||||
"config": {
|
|
||||||
"forge": {
|
|
||||||
"plugins": [
|
|
||||||
[
|
|
||||||
"@electron-forge/plugin-webpack",
|
|
||||||
{
|
|
||||||
"mainConfig": "./webpack.main.config.js",
|
|
||||||
"renderer": {
|
|
||||||
"config": "./webpack.renderer.config.js",
|
|
||||||
"entryPoints": [
|
|
||||||
{
|
|
||||||
"html": "./index.html",
|
|
||||||
"js": "./src/renderer.ts",
|
|
||||||
"name": "main_window"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
declare module '*.svelte';
|
|
@ -1,22 +1,24 @@
|
||||||
import { app, BrowserWindow } from 'electron';
|
import { app, BrowserWindow } from 'electron';
|
||||||
|
import api from './main/services/api';
|
||||||
import session from './main/services/session';
|
import session from './main/services/session';
|
||||||
|
|
||||||
let mainWindow: Electron.BrowserWindow;
|
let mainWindow: Electron.BrowserWindow;
|
||||||
|
|
||||||
async function createWindow() {
|
async function createWindow() {
|
||||||
session.init();
|
session.init();
|
||||||
|
api.init();
|
||||||
|
|
||||||
// Create the browser window.
|
// Create the browser window.
|
||||||
mainWindow = new BrowserWindow({
|
mainWindow = new BrowserWindow({
|
||||||
width: 1600,
|
width: 1600,
|
||||||
height: 900,
|
height: 900,
|
||||||
webPreferences: {
|
webPreferences: {
|
||||||
nodeIntegration: false,
|
nodeIntegration: true,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
// and load the index.html of the app.
|
// and load the index.html of the app.
|
||||||
await mainWindow.loadURL(MAIN_WINDOW_WEBPACK_ENTRY);
|
await mainWindow.loadFile('index.html');
|
||||||
|
|
||||||
// Open the DevTools.
|
// Open the DevTools.
|
||||||
mainWindow.webContents.openDevTools();
|
mainWindow.webContents.openDevTools();
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
import { ipcMain } from 'electron';
|
||||||
|
|
||||||
|
function init() {
|
||||||
|
ipcMain.on(
|
||||||
|
IpcRendererMessages.Credentials,
|
||||||
|
(event: any, arg: ICredentials) => {
|
||||||
|
event.reply(IpcMainMessages.Pong, arg);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default {
|
||||||
|
init,
|
||||||
|
};
|
|
@ -0,0 +1,44 @@
|
||||||
|
const url = 'https://nhentai.net/';
|
||||||
|
|
||||||
|
const paths = {
|
||||||
|
books: 'g/',
|
||||||
|
login: 'login/',
|
||||||
|
favorites: 'favorites/',
|
||||||
|
};
|
||||||
|
|
||||||
|
// @ts-ignore
|
||||||
|
let loginPassword: string;
|
||||||
|
// @ts-ignore
|
||||||
|
let loginName: string;
|
||||||
|
|
||||||
|
function fetchNHentai(path: string): Promise<Document> {
|
||||||
|
return fetch(`${url}${path}`, {
|
||||||
|
credentials: 'include',
|
||||||
|
})
|
||||||
|
.then(res => {
|
||||||
|
console.log(res);
|
||||||
|
return res.text();
|
||||||
|
})
|
||||||
|
.then(text => {
|
||||||
|
const parser = new DOMParser();
|
||||||
|
return parser.parseFromString(text, 'text/html');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function fetchLogin(): void {
|
||||||
|
fetchNHentai(paths.login)
|
||||||
|
.then(() => true)
|
||||||
|
.catch(e => {
|
||||||
|
console.error(e);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function setLoginCredentials(name: string, password: string): void {
|
||||||
|
loginName = name;
|
||||||
|
loginPassword = password;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default {
|
||||||
|
setLoginCredentials,
|
||||||
|
fetchLogin,
|
||||||
|
};
|
|
@ -1,11 +1,11 @@
|
||||||
<script>
|
<script>
|
||||||
import Button from 'atoms/Button.svelte';
|
import Button from 'atoms/Button.svelte';
|
||||||
import nhentai from 'services/nhentai-crawler';
|
import api from 'services/api';
|
||||||
|
|
||||||
let text = 'tach';
|
let text = 'tach';
|
||||||
|
|
||||||
function handleClick() {
|
function handleClick() {
|
||||||
nhentai.setLoginCredentials('1', '2');
|
api.sendCredentials({name: '1', password: '2'});
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
import { ipcRenderer } from 'electron';
|
||||||
|
|
||||||
|
function sendCredentials(credentials: ICredentials) {
|
||||||
|
ipcRenderer.send(IpcRendererMessages.Credentials, credentials);
|
||||||
|
}
|
||||||
|
|
||||||
|
ipcRenderer.on(IpcMainMessages.Pong, (...args: any) => {
|
||||||
|
console.log(args);
|
||||||
|
});
|
||||||
|
|
||||||
|
export default {
|
||||||
|
sendCredentials,
|
||||||
|
};
|
|
@ -1,19 +0,0 @@
|
||||||
const url = 'https://nhentai.net/';
|
|
||||||
|
|
||||||
const paths = {
|
|
||||||
books: 'g/',
|
|
||||||
login: 'login/',
|
|
||||||
favorites: 'favorites/',
|
|
||||||
};
|
|
||||||
|
|
||||||
let loginPassword: string;
|
|
||||||
let loginName: string;
|
|
||||||
|
|
||||||
function setLoginCredentials(name: string, password: string): void {
|
|
||||||
loginName = name;
|
|
||||||
loginPassword = password;
|
|
||||||
}
|
|
||||||
|
|
||||||
export default {
|
|
||||||
setLoginCredentials,
|
|
||||||
};
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
const enum IpcRendererMessages {
|
||||||
|
Credentials = 'CREDENTIALS',
|
||||||
|
}
|
||||||
|
|
||||||
|
const enum IpcMainMessages {
|
||||||
|
Pong = 'PONG',
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ICredentials {
|
||||||
|
name: string;
|
||||||
|
password: string;
|
||||||
|
}
|
|
@ -1,20 +1,19 @@
|
||||||
{
|
{
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"baseUrl": ".",
|
"baseUrl": "./src",
|
||||||
"module": "commonjs",
|
"module": "commonjs",
|
||||||
"noImplicitAny": true,
|
|
||||||
"noUnusedLocals": true,
|
|
||||||
"noUnusedParameters": true,
|
|
||||||
"removeComments": true,
|
"removeComments": true,
|
||||||
"sourceMap": true,
|
"sourceMap": true,
|
||||||
"allowJs": true,
|
"allowJs": true,
|
||||||
"checkJs": true,
|
"preserveConstEnums": false,
|
||||||
"lib": ["es6", "dom"],
|
"lib": ["es6", "dom"],
|
||||||
"plugins": [
|
"plugins": [
|
||||||
{
|
{
|
||||||
"name": "typescript-tslint-plugin",
|
"name": "typescript-tslint-plugin"
|
||||||
"jsEnable": true
|
|
||||||
}
|
}
|
||||||
]
|
],
|
||||||
}
|
"rootDir": "src",
|
||||||
|
"outDir": "dist"
|
||||||
|
},
|
||||||
|
"include": ["src/**/*"]
|
||||||
}
|
}
|
||||||
|
|
13
tslint.json
13
tslint.json
|
@ -1,14 +1,19 @@
|
||||||
{
|
{
|
||||||
"rulesDirectory": ["tslint-plugin-prettier"],
|
"rulesDirectory": ["tslint-plugin-prettier"],
|
||||||
"extends": ["tslint:latest", "tslint-config-prettier"],
|
"extends": ["tslint:latest", "tslint-config-prettier"],
|
||||||
|
"defaultSeverity": "warn",
|
||||||
"rules": {
|
"rules": {
|
||||||
"prettier": true,
|
"prettier": true,
|
||||||
"no-console": true,
|
"no-console": true,
|
||||||
"object-literal-sort-keys": [true, "match-declaration-order-only"],
|
"object-literal-sort-keys": [true, "match-declaration-order-only"],
|
||||||
"no-implicit-dependencies": [true, "dev"]
|
"no-implicit-dependencies": false,
|
||||||
},
|
"no-submodule-imports": false,
|
||||||
"linterOptions": {
|
"arrow-parens": [true, "ban-single-arg-parens"],
|
||||||
"exclude": ["node_modules", ".webpack"]
|
"no-floating-promises": true,
|
||||||
|
"no-unused-expression": true,
|
||||||
|
"await-promise": true,
|
||||||
|
"no-inferrable-types": true,
|
||||||
|
"prefer-for-of": true
|
||||||
},
|
},
|
||||||
"jsRules": true
|
"jsRules": true
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,38 @@
|
||||||
|
const path = require('path');
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
entry: {
|
||||||
|
bundle: path.resolve(__dirname, 'src/renderer.ts'),
|
||||||
|
},
|
||||||
|
target: 'electron-renderer',
|
||||||
|
output: {
|
||||||
|
path: path.resolve(__dirname, 'frontend'),
|
||||||
|
},
|
||||||
|
module: {
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
test: /\.svelte$/,
|
||||||
|
loaders: [
|
||||||
|
{
|
||||||
|
loader: 'svelte-loader',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
test: /\.ts$/,
|
||||||
|
loader: [
|
||||||
|
{
|
||||||
|
loader: 'ts-loader',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
resolve: {
|
||||||
|
extensions: ['.js', '.ts'],
|
||||||
|
alias: {
|
||||||
|
atoms: path.resolve(__dirname, 'src/renderer/components/1-atoms'),
|
||||||
|
services: path.resolve(__dirname, 'src/renderer/services'),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
|
@ -1,12 +0,0 @@
|
||||||
module.exports = {
|
|
||||||
/**
|
|
||||||
* This is the main entry point for your application, it's the first file
|
|
||||||
* that runs in the main process.
|
|
||||||
*/
|
|
||||||
entry: './src/main.ts',
|
|
||||||
// Put your normal webpack config below here
|
|
||||||
module: {
|
|
||||||
rules: require('./webpack.rules'),
|
|
||||||
},
|
|
||||||
resolve: require('./webpack.resolve'),
|
|
||||||
};
|
|
|
@ -1,7 +0,0 @@
|
||||||
module.exports = {
|
|
||||||
// Put your normal webpack config below here
|
|
||||||
module: {
|
|
||||||
rules: require('./webpack.rules'),
|
|
||||||
},
|
|
||||||
resolve: require('./webpack.resolve'),
|
|
||||||
};
|
|
|
@ -1,12 +0,0 @@
|
||||||
const path = require('path');
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
extensions: ['.js', '.ts'],
|
|
||||||
alias: {
|
|
||||||
atoms: path.resolve(__dirname, 'src/renderer/components/1-atoms'),
|
|
||||||
molecules: path.resolve(__dirname, 'src/renderer/components/2-molecules'),
|
|
||||||
polymers: path.resolve(__dirname, 'src/renderer/components/3-polymers'),
|
|
||||||
cells: path.resolve(__dirname, 'src/renderer/components/4-cells'),
|
|
||||||
services: path.resolve(__dirname, 'src/renderer/services'),
|
|
||||||
},
|
|
||||||
};
|
|
|
@ -1,34 +0,0 @@
|
||||||
module.exports = [
|
|
||||||
// Add support for native node modules
|
|
||||||
{
|
|
||||||
test: /\.node$/,
|
|
||||||
use: 'node-loader',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
test: /\.(m?js|node)$/,
|
|
||||||
parser: { amd: false },
|
|
||||||
use: {
|
|
||||||
loader: '@zeit/webpack-asset-relocator-loader',
|
|
||||||
options: {
|
|
||||||
outputAssetBase: 'native_modules',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
test: /\.ts$/,
|
|
||||||
exclude: /(node_modules|.webpack)/,
|
|
||||||
loaders: [
|
|
||||||
{
|
|
||||||
loader: 'ts-loader',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
test: /\.svelte$/,
|
|
||||||
loaders: [
|
|
||||||
{
|
|
||||||
loader: 'svelte-loader',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
];
|
|
Loading…
Reference in New Issue