diff --git a/.erb/configs/.eslintrc b/.erb/configs/.eslintrc index 778b71dc..86328cfc 100644 --- a/.erb/configs/.eslintrc +++ b/.erb/configs/.eslintrc @@ -1,13 +1,13 @@ { - "rules": { - "no-console": "off", - "global-require": "off", - "import/no-dynamic-require": "off", - "prettier/prettier": 0, - "no-await-in-loop": "off", - "import/prefer-default-export": "off", - "no-empty-function": "off", - "@typescript-eslint/no-empty-function": "off", - "@angular-eslint/no-empty-lifecycle-method": "off" - } + "rules": { + "no-console": "off", + "global-require": "off", + "import/no-dynamic-require": "off", + "prettier/prettier": 0, + "no-await-in-loop": "off", + "import/prefer-default-export": "off", + "no-empty-function": "off", + "@typescript-eslint/no-empty-function": "off", + "@angular-eslint/no-empty-lifecycle-method": "off" + } } diff --git a/.erb/configs/postcss.config.js b/.erb/configs/postcss.config.js index 84b2f497..f66b5346 100644 --- a/.erb/configs/postcss.config.js +++ b/.erb/configs/postcss.config.js @@ -1,6 +1,6 @@ -const tailwindcss = require('tailwindcss'); -const autoprefixer = require('autoprefixer'); +const tailwindcss = require("tailwindcss"); +const autoprefixer = require("autoprefixer"); module.exports = { - plugins: [tailwindcss, autoprefixer], -}; \ No newline at end of file + plugins: [tailwindcss, autoprefixer], +}; diff --git a/.erb/configs/webpack.config.base.ts b/.erb/configs/webpack.config.base.ts index 2356a9e2..44be08a1 100644 --- a/.erb/configs/webpack.config.base.ts +++ b/.erb/configs/webpack.config.base.ts @@ -2,52 +2,52 @@ * Base webpack config used across other specific configs */ -import webpack from 'webpack'; -import webpackPaths from './webpack.paths'; -import { dependencies as externals } from '../../release/app/package.json'; +import webpack from "webpack"; +import webpackPaths from "./webpack.paths"; +import { dependencies as externals } from "../../release/app/package.json"; const configuration: webpack.Configuration = { - externals: [...Object.keys(externals || {})], + externals: [...Object.keys(externals || {})], - stats: 'errors-only', + stats: "errors-only", - module: { - rules: [ - { - test: /\.[jt]sx?$/, - exclude: /node_modules/, - use: { - loader: 'ts-loader', - options: { - // Remove this line to enable type checking in webpack builds - transpileOnly: true, - }, - }, - }, - ], - }, - - output: { - path: webpackPaths.srcPath, - // https://github.com/webpack/webpack/issues/1114 - library: { - type: 'commonjs2', + module: { + rules: [ + { + test: /\.[jt]sx?$/, + exclude: /node_modules/, + use: { + loader: "ts-loader", + options: { + // Remove this line to enable type checking in webpack builds + transpileOnly: true, + }, + }, + }, + ], }, - }, - /** - * Determine the array of extensions that should be used to resolve modules. - */ - resolve: { - extensions: ['.js', '.jsx', '.json', '.ts', '.tsx'], - modules: [webpackPaths.srcPath, 'node_modules'], - }, + output: { + path: webpackPaths.srcPath, + // https://github.com/webpack/webpack/issues/1114 + library: { + type: "commonjs2", + }, + }, - plugins: [ - new webpack.EnvironmentPlugin({ - NODE_ENV: 'production', - }), - ], + /** + * Determine the array of extensions that should be used to resolve modules. + */ + resolve: { + extensions: [".js", ".jsx", ".json", ".ts", ".tsx"], + modules: [webpackPaths.srcPath, "node_modules"], + }, + + plugins: [ + new webpack.EnvironmentPlugin({ + NODE_ENV: "production", + }), + ], }; export default configuration; diff --git a/.erb/configs/webpack.config.eslint.ts b/.erb/configs/webpack.config.eslint.ts index 35a631b7..761d146d 100644 --- a/.erb/configs/webpack.config.eslint.ts +++ b/.erb/configs/webpack.config.eslint.ts @@ -1,3 +1,3 @@ /* eslint import/no-unresolved: off, import/no-self-import: off */ -module.exports = require('./webpack.config.renderer.dev').default; +module.exports = require("./webpack.config.renderer.dev").default; diff --git a/.erb/configs/webpack.config.main.prod.ts b/.erb/configs/webpack.config.main.prod.ts index 3ed351f1..b1c7ff22 100644 --- a/.erb/configs/webpack.config.main.prod.ts +++ b/.erb/configs/webpack.config.main.prod.ts @@ -2,81 +2,81 @@ * Webpack config for production electron main process */ -import path from 'path'; -import webpack from 'webpack'; -import { merge } from 'webpack-merge'; -import TerserPlugin from 'terser-webpack-plugin'; -import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer'; -import baseConfig from './webpack.config.base'; -import webpackPaths from './webpack.paths'; -import checkNodeEnv from '../scripts/check-node-env'; -import deleteSourceMaps from '../scripts/delete-source-maps'; +import path from "path"; +import webpack from "webpack"; +import { merge } from "webpack-merge"; +import TerserPlugin from "terser-webpack-plugin"; +import { BundleAnalyzerPlugin } from "webpack-bundle-analyzer"; +import baseConfig from "./webpack.config.base"; +import webpackPaths from "./webpack.paths"; +import checkNodeEnv from "../scripts/check-node-env"; +import deleteSourceMaps from "../scripts/delete-source-maps"; -checkNodeEnv('production'); +checkNodeEnv("production"); deleteSourceMaps(); const devtoolsConfig = - process.env.DEBUG_PROD === 'true' - ? { - devtool: 'source-map', - } - : {}; + process.env.DEBUG_PROD === "true" + ? { + devtool: "source-map", + } + : {}; const configuration: webpack.Configuration = { - ...devtoolsConfig, + ...devtoolsConfig, - mode: 'production', + mode: "production", - target: 'electron-main', + target: "electron-main", - entry: { - main: path.join(webpackPaths.srcMainPath, 'main.ts'), - preload: path.join(webpackPaths.srcMainPath, 'preload.ts'), - }, + entry: { + main: path.join(webpackPaths.srcMainPath, "main.ts"), + preload: path.join(webpackPaths.srcMainPath, "preload.ts"), + }, - output: { - path: webpackPaths.distMainPath, - filename: '[name].js', - }, + output: { + path: webpackPaths.distMainPath, + filename: "[name].js", + }, - optimization: { - minimizer: [ - new TerserPlugin({ - parallel: true, - }), + optimization: { + minimizer: [ + new TerserPlugin({ + parallel: true, + }), + ], + }, + + plugins: [ + new BundleAnalyzerPlugin({ + analyzerMode: process.env.ANALYZE === "true" ? "server" : "disabled", + }), + + /** + * Create global constants which can be configured at compile time. + * + * Useful for allowing different behaviour between development builds and + * release builds + * + * NODE_ENV should be production so that modules do not perform certain + * development checks + */ + new webpack.EnvironmentPlugin({ + NODE_ENV: "production", + DEBUG_PROD: false, + START_MINIMIZED: false, + }), ], - }, - - plugins: [ - new BundleAnalyzerPlugin({ - analyzerMode: process.env.ANALYZE === 'true' ? 'server' : 'disabled', - }), /** - * Create global constants which can be configured at compile time. - * - * Useful for allowing different behaviour between development builds and - * release builds - * - * NODE_ENV should be production so that modules do not perform certain - * development checks + * Disables webpack processing of __dirname and __filename. + * If you run the bundle in node.js it falls back to these values of node.js. + * https://github.com/webpack/webpack/issues/2010 */ - new webpack.EnvironmentPlugin({ - NODE_ENV: 'production', - DEBUG_PROD: false, - START_MINIMIZED: false, - }), - ], - - /** - * Disables webpack processing of __dirname and __filename. - * If you run the bundle in node.js it falls back to these values of node.js. - * https://github.com/webpack/webpack/issues/2010 - */ - node: { - __dirname: false, - __filename: false, - }, + node: { + __dirname: false, + __filename: false, + }, }; export default merge(baseConfig, configuration); diff --git a/.erb/configs/webpack.config.preload.dev.ts b/.erb/configs/webpack.config.preload.dev.ts index 061db530..f123e8a3 100644 --- a/.erb/configs/webpack.config.preload.dev.ts +++ b/.erb/configs/webpack.config.preload.dev.ts @@ -1,68 +1,68 @@ -import path from 'path'; -import webpack from 'webpack'; -import { merge } from 'webpack-merge'; -import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer'; -import baseConfig from './webpack.config.base'; -import webpackPaths from './webpack.paths'; -import checkNodeEnv from '../scripts/check-node-env'; +import path from "path"; +import webpack from "webpack"; +import { merge } from "webpack-merge"; +import { BundleAnalyzerPlugin } from "webpack-bundle-analyzer"; +import baseConfig from "./webpack.config.base"; +import webpackPaths from "./webpack.paths"; +import checkNodeEnv from "../scripts/check-node-env"; // When an ESLint server is running, we can't set the NODE_ENV so we'll check if it's // at the dev webpack config is not accidentally run in a production environment -if (process.env.NODE_ENV === 'production') { - checkNodeEnv('development'); +if (process.env.NODE_ENV === "production") { + checkNodeEnv("development"); } const configuration: webpack.Configuration = { - devtool: 'inline-source-map', + devtool: "inline-source-map", - mode: 'development', + mode: "development", - target: 'electron-preload', + target: "electron-preload", - entry: path.join(webpackPaths.srcMainPath, 'preload.ts'), + entry: path.join(webpackPaths.srcMainPath, "preload.ts"), - output: { - path: webpackPaths.dllPath, - filename: 'preload.js', - }, + output: { + path: webpackPaths.dllPath, + filename: "preload.js", + }, - plugins: [ - new BundleAnalyzerPlugin({ - analyzerMode: process.env.ANALYZE === 'true' ? 'server' : 'disabled', - }), + plugins: [ + new BundleAnalyzerPlugin({ + analyzerMode: process.env.ANALYZE === "true" ? "server" : "disabled", + }), + + /** + * Create global constants which can be configured at compile time. + * + * Useful for allowing different behaviour between development builds and + * release builds + * + * NODE_ENV should be production so that modules do not perform certain + * development checks + * + * By default, use 'development' as NODE_ENV. This can be overriden with + * 'staging', for example, by changing the ENV variables in the npm scripts + */ + new webpack.EnvironmentPlugin({ + NODE_ENV: "development", + }), + + new webpack.LoaderOptionsPlugin({ + debug: true, + }), + ], /** - * Create global constants which can be configured at compile time. - * - * Useful for allowing different behaviour between development builds and - * release builds - * - * NODE_ENV should be production so that modules do not perform certain - * development checks - * - * By default, use 'development' as NODE_ENV. This can be overriden with - * 'staging', for example, by changing the ENV variables in the npm scripts + * Disables webpack processing of __dirname and __filename. + * If you run the bundle in node.js it falls back to these values of node.js. + * https://github.com/webpack/webpack/issues/2010 */ - new webpack.EnvironmentPlugin({ - NODE_ENV: 'development', - }), + node: { + __dirname: false, + __filename: false, + }, - new webpack.LoaderOptionsPlugin({ - debug: true, - }), - ], - - /** - * Disables webpack processing of __dirname and __filename. - * If you run the bundle in node.js it falls back to these values of node.js. - * https://github.com/webpack/webpack/issues/2010 - */ - node: { - __dirname: false, - __filename: false, - }, - - watch: true, + watch: true, }; export default merge(baseConfig, configuration); diff --git a/.erb/configs/webpack.config.renderer.dev.dll.ts b/.erb/configs/webpack.config.renderer.dev.dll.ts index 614b90f0..28b50547 100644 --- a/.erb/configs/webpack.config.renderer.dev.dll.ts +++ b/.erb/configs/webpack.config.renderer.dev.dll.ts @@ -2,76 +2,76 @@ * Builds the DLL for development electron renderer process */ -import webpack from 'webpack'; -import path from 'path'; -import { merge } from 'webpack-merge'; -import baseConfig from './webpack.config.base'; -import webpackPaths from './webpack.paths'; -import { dependencies } from '../../package.json'; -import checkNodeEnv from '../scripts/check-node-env'; +import webpack from "webpack"; +import path from "path"; +import { merge } from "webpack-merge"; +import baseConfig from "./webpack.config.base"; +import webpackPaths from "./webpack.paths"; +import { dependencies } from "../../package.json"; +import checkNodeEnv from "../scripts/check-node-env"; -checkNodeEnv('development'); +checkNodeEnv("development"); const dist = webpackPaths.dllPath; const configuration: webpack.Configuration = { - context: webpackPaths.rootPath, + context: webpackPaths.rootPath, - devtool: 'eval', + devtool: "eval", - mode: 'development', + mode: "development", - target: 'electron-renderer', + target: "electron-renderer", - externals: ['fsevents', 'crypto-browserify'], - - /** - * Use `module` from `webpack.config.renderer.dev.js` - */ - module: require('./webpack.config.renderer.dev').default.module, - - entry: { - renderer: Object.keys(dependencies || {}), - }, - - output: { - path: dist, - filename: '[name].dev.dll.js', - library: { - name: 'renderer', - type: 'var', - }, - }, - - plugins: [ - new webpack.DllPlugin({ - path: path.join(dist, '[name].json'), - name: '[name]', - }), + externals: ["fsevents", "crypto-browserify"], /** - * Create global constants which can be configured at compile time. - * - * Useful for allowing different behaviour between development builds and - * release builds - * - * NODE_ENV should be production so that modules do not perform certain - * development checks + * Use `module` from `webpack.config.renderer.dev.js` */ - new webpack.EnvironmentPlugin({ - NODE_ENV: 'development', - }), + module: require("./webpack.config.renderer.dev").default.module, - new webpack.LoaderOptionsPlugin({ - debug: true, - options: { - context: webpackPaths.srcPath, - output: { - path: webpackPaths.dllPath, + entry: { + renderer: Object.keys(dependencies || {}), + }, + + output: { + path: dist, + filename: "[name].dev.dll.js", + library: { + name: "renderer", + type: "var", }, - }, - }), - ], + }, + + plugins: [ + new webpack.DllPlugin({ + path: path.join(dist, "[name].json"), + name: "[name]", + }), + + /** + * Create global constants which can be configured at compile time. + * + * Useful for allowing different behaviour between development builds and + * release builds + * + * NODE_ENV should be production so that modules do not perform certain + * development checks + */ + new webpack.EnvironmentPlugin({ + NODE_ENV: "development", + }), + + new webpack.LoaderOptionsPlugin({ + debug: true, + options: { + context: webpackPaths.srcPath, + output: { + path: webpackPaths.dllPath, + }, + }, + }), + ], }; export default merge(baseConfig, configuration); diff --git a/.erb/configs/webpack.config.renderer.dev.ts b/.erb/configs/webpack.config.renderer.dev.ts index 8bcbcc73..1ae950d2 100644 --- a/.erb/configs/webpack.config.renderer.dev.ts +++ b/.erb/configs/webpack.config.renderer.dev.ts @@ -1,43 +1,34 @@ -import 'webpack-dev-server'; -import path from 'path'; -import fs from 'fs'; -import webpack from 'webpack'; -import HtmlWebpackPlugin from 'html-webpack-plugin'; -import chalk from 'chalk'; -import { merge } from 'webpack-merge'; -import { execSync, spawn } from 'child_process'; -import ReactRefreshWebpackPlugin from '@pmmmwh/react-refresh-webpack-plugin'; -import baseConfig from './webpack.config.base'; -import webpackPaths from './webpack.paths'; -import checkNodeEnv from '../scripts/check-node-env'; -import { AppWindow } from "../../src/shared/models/window-manager/app-window.model" +import "webpack-dev-server"; +import path from "path"; +import fs from "fs"; +import webpack from "webpack"; +import HtmlWebpackPlugin from "html-webpack-plugin"; +import chalk from "chalk"; +import { merge } from "webpack-merge"; +import { execSync, spawn } from "child_process"; +import ReactRefreshWebpackPlugin from "@pmmmwh/react-refresh-webpack-plugin"; +import baseConfig from "./webpack.config.base"; +import webpackPaths from "./webpack.paths"; +import checkNodeEnv from "../scripts/check-node-env"; +import { AppWindow } from "../../src/shared/models/window-manager/app-window.model"; // When an ESLint server is running, we can't set the NODE_ENV so we'll check if it's // at the dev webpack config is not accidentally run in a production environment -if (process.env.NODE_ENV === 'production') { - checkNodeEnv('development'); +if (process.env.NODE_ENV === "production") { + checkNodeEnv("development"); } const port = process.env.PORT || 1212; -const manifest = path.resolve(webpackPaths.dllPath, 'renderer.json'); +const manifest = path.resolve(webpackPaths.dllPath, "renderer.json"); // eslint-disable-next-line @typescript-eslint/no-non-null-assertion -const requiredByDLLConfig = module.parent!.filename.includes( - 'webpack.config.renderer.dev.dll' -); +const requiredByDLLConfig = module.parent!.filename.includes("webpack.config.renderer.dev.dll"); /** * Warn if the DLL is not built */ -if ( - !requiredByDLLConfig && - !(fs.existsSync(webpackPaths.dllPath) && fs.existsSync(manifest)) -) { - console.log( - chalk.black.bgYellow.bold( - 'The DLL files are missing. Sit back while we build them for you with "npm run build-dll"' - ) - ); - execSync('npm run postinstall'); +if (!requiredByDLLConfig && !(fs.existsSync(webpackPaths.dllPath) && fs.existsSync(manifest))) { + console.log(chalk.black.bgYellow.bold('The DLL files are missing. Sit back while we build them for you with "npm run build-dll"')); + execSync("npm run postinstall"); } const getHtmlPageOptions = (page: AppWindow): HtmlWebpackPlugin.Options => { @@ -45,169 +36,160 @@ const getHtmlPageOptions = (page: AppWindow): HtmlWebpackPlugin.Options => { filename: path.join(page), template: path.join(webpackPaths.srcRendererPath, page.replace(".html", ".ejs")), minify: { - collapseWhitespace: true, - removeAttributeQuotes: true, - removeComments: true, + collapseWhitespace: true, + removeAttributeQuotes: true, + removeComments: true, }, isBrowser: false, env: process.env.NODE_ENV, - isDevelopment: process.env.NODE_ENV !== 'production', + isDevelopment: process.env.NODE_ENV !== "production", nodeModules: webpackPaths.appNodeModulesPath, - } -} + }; +}; const configuration: webpack.Configuration = { - devtool: 'inline-source-map', + devtool: "inline-source-map", - mode: 'development', + mode: "development", - target: ['web', 'electron-renderer'], + target: ["web", "electron-renderer"], - entry: [ - `webpack-dev-server/client?http://localhost:${port}/dist`, - 'webpack/hot/only-dev-server', - path.join(webpackPaths.srcRendererPath, 'index.tsx'), - ], + entry: [`webpack-dev-server/client?http://localhost:${port}/dist`, "webpack/hot/only-dev-server", path.join(webpackPaths.srcRendererPath, "index.tsx")], - output: { - path: webpackPaths.distRendererPath, - publicPath: '/', - filename: 'renderer.dev.js', - library: { - type: 'umd', + output: { + path: webpackPaths.distRendererPath, + publicPath: "/", + filename: "renderer.dev.js", + library: { + type: "umd", + }, }, - }, - module: { - rules: [ - { - test: /\.s?css$/, - use: [ - 'style-loader', - { - loader: 'css-loader', - options: { - modules: true, - sourceMap: true, - importLoaders: 1, + module: { + rules: [ + { + test: /\.s?css$/, + use: [ + "style-loader", + { + loader: "css-loader", + options: { + modules: true, + sourceMap: true, + importLoaders: 1, + }, + }, + "sass-loader", + ], + include: /\.module\.s?(c|a)ss$/, }, - }, - 'sass-loader', - ], - include: /\.module\.s?(c|a)ss$/, - }, - { - test: /\.s?css$/, - use: [ - 'style-loader', - 'css-loader', - 'sass-loader', - { - loader: 'postcss-loader', - options: { - postcssOptions: { - plugins: - [ - require('tailwindcss'), - require('autoprefixer'), - ] - }, + { + test: /\.s?css$/, + use: [ + "style-loader", + "css-loader", + "sass-loader", + { + loader: "postcss-loader", + options: { + postcssOptions: { + plugins: [require("tailwindcss"), require("autoprefixer")], + }, + }, + }, + ], + exclude: /\.module\.s?(c|a)ss$/, + }, + // Fonts + { + test: /\.(woff|woff2|eot|ttf|otf)$/i, + type: "asset/resource", + }, + // Images + { + test: /\.(png|svg|jpg|jpeg|gif|mp4|webp)$/i, + type: "asset/resource", }, - }, ], - exclude: /\.module\.s?(c|a)ss$/, - }, - // Fonts - { - test: /\.(woff|woff2|eot|ttf|otf)$/i, - type: 'asset/resource', - }, - // Images - { - test: /\.(png|svg|jpg|jpeg|gif|mp4|webp)$/i, - type: 'asset/resource', - }, + }, + plugins: [ + ...(requiredByDLLConfig + ? [] + : [ + new webpack.DllReferencePlugin({ + context: webpackPaths.dllPath, + manifest: require(manifest), + sourceType: "var", + }), + ]), + + new webpack.NoEmitOnErrorsPlugin(), + + /** + * Create global constants which can be configured at compile time. + * + * Useful for allowing different behaviour between development builds and + * release builds + * + * NODE_ENV should be production so that modules do not perform certain + * development checks + * + * By default, use 'development' as NODE_ENV. This can be overriden with + * 'staging', for example, by changing the ENV variables in the npm scripts + */ + new webpack.EnvironmentPlugin({ + NODE_ENV: "development", + }), + + new webpack.LoaderOptionsPlugin({ + debug: true, + }), + + new ReactRefreshWebpackPlugin(), + + new HtmlWebpackPlugin(getHtmlPageOptions("index.html")), + new HtmlWebpackPlugin(getHtmlPageOptions("launcher.html")), + new HtmlWebpackPlugin(getHtmlPageOptions("oneclick-download-map.html")), + new HtmlWebpackPlugin(getHtmlPageOptions("oneclick-download-playlist.html")), + new HtmlWebpackPlugin(getHtmlPageOptions("oneclick-download-model.html")), ], - }, - plugins: [ - ...(requiredByDLLConfig - ? [] - : [ - new webpack.DllReferencePlugin({ - context: webpackPaths.dllPath, - manifest: require(manifest), - sourceType: 'var', - }), - ]), - new webpack.NoEmitOnErrorsPlugin(), - - /** - * Create global constants which can be configured at compile time. - * - * Useful for allowing different behaviour between development builds and - * release builds - * - * NODE_ENV should be production so that modules do not perform certain - * development checks - * - * By default, use 'development' as NODE_ENV. This can be overriden with - * 'staging', for example, by changing the ENV variables in the npm scripts - */ - new webpack.EnvironmentPlugin({ - NODE_ENV: 'development', - }), - - new webpack.LoaderOptionsPlugin({ - debug: true, - }), - - new ReactRefreshWebpackPlugin(), - - new HtmlWebpackPlugin(getHtmlPageOptions("index.html")), - new HtmlWebpackPlugin(getHtmlPageOptions("launcher.html")), - new HtmlWebpackPlugin(getHtmlPageOptions("oneclick-download-map.html")), - new HtmlWebpackPlugin(getHtmlPageOptions("oneclick-download-playlist.html")), - new HtmlWebpackPlugin(getHtmlPageOptions("oneclick-download-model.html")), - - ], - - node: { - __dirname: false, - __filename: false, - }, - - devServer: { - port, - compress: true, - hot: true, - headers: { 'Access-Control-Allow-Origin': '*' }, - static: { - publicPath: '/', + node: { + __dirname: false, + __filename: false, }, - historyApiFallback: true, - setupMiddlewares(middlewares) { - console.log('Starting preload.js builder...'); - const preloadProcess = spawn('npm', ['run', 'start:preload'], { - shell: true, - stdio: 'inherit', - }) - .on('close', (code: number) => process.exit(code!)) - .on('error', (spawnError) => console.error(spawnError)); - console.log('Starting Main Process...'); - spawn('npm', ['run', 'start:main'], { - shell: true, - stdio: 'inherit', - }) - .on('close', (code: number) => { - preloadProcess.kill(); - process.exit(code!); - }) - .on('error', (spawnError) => console.error(spawnError)); - return middlewares; + devServer: { + port, + compress: true, + hot: true, + headers: { "Access-Control-Allow-Origin": "*" }, + static: { + publicPath: "/", + }, + historyApiFallback: true, + setupMiddlewares(middlewares) { + console.log("Starting preload.js builder..."); + const preloadProcess = spawn("npm", ["run", "start:preload"], { + shell: true, + stdio: "inherit", + }) + .on("close", (code: number) => process.exit(code!)) + .on("error", spawnError => console.error(spawnError)); + + console.log("Starting Main Process..."); + spawn("npm", ["run", "start:main"], { + shell: true, + stdio: "inherit", + }) + .on("close", (code: number) => { + preloadProcess.kill(); + process.exit(code!); + }) + .on("error", spawnError => console.error(spawnError)); + return middlewares; + }, }, - }, }; export default merge(baseConfig, configuration); diff --git a/.erb/configs/webpack.config.renderer.prod.ts b/.erb/configs/webpack.config.renderer.prod.ts index 54b67a5e..54a8d33a 100644 --- a/.erb/configs/webpack.config.renderer.prod.ts +++ b/.erb/configs/webpack.config.renderer.prod.ts @@ -2,157 +2,151 @@ * Build config for electron renderer process */ -import path from 'path'; -import webpack from 'webpack'; -import HtmlWebpackPlugin from 'html-webpack-plugin'; -import MiniCssExtractPlugin from 'mini-css-extract-plugin'; -import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer'; -import CssMinimizerPlugin from 'css-minimizer-webpack-plugin'; -import { merge } from 'webpack-merge'; -import TerserPlugin from 'terser-webpack-plugin'; -import baseConfig from './webpack.config.base'; -import webpackPaths from './webpack.paths'; -import checkNodeEnv from '../scripts/check-node-env'; -import deleteSourceMaps from '../scripts/delete-source-maps'; -import { AppWindow } from "../../src/shared/models/window-manager/app-window.model" +import path from "path"; +import webpack from "webpack"; +import HtmlWebpackPlugin from "html-webpack-plugin"; +import MiniCssExtractPlugin from "mini-css-extract-plugin"; +import { BundleAnalyzerPlugin } from "webpack-bundle-analyzer"; +import CssMinimizerPlugin from "css-minimizer-webpack-plugin"; +import { merge } from "webpack-merge"; +import TerserPlugin from "terser-webpack-plugin"; +import baseConfig from "./webpack.config.base"; +import webpackPaths from "./webpack.paths"; +import checkNodeEnv from "../scripts/check-node-env"; +import deleteSourceMaps from "../scripts/delete-source-maps"; +import { AppWindow } from "../../src/shared/models/window-manager/app-window.model"; -checkNodeEnv('production'); +checkNodeEnv("production"); deleteSourceMaps(); const devtoolsConfig = - process.env.DEBUG_PROD === 'true' - ? { - devtool: 'source-map', - } - : {}; - + process.env.DEBUG_PROD === "true" + ? { + devtool: "source-map", + } + : {}; const getHtmlPageOptions = (page: AppWindow): HtmlWebpackPlugin.Options => { return { filename: path.join(page), template: path.join(webpackPaths.srcRendererPath, page.replace(".html", ".ejs")), minify: { - collapseWhitespace: true, - removeAttributeQuotes: true, - removeComments: true, + collapseWhitespace: true, + removeAttributeQuotes: true, + removeComments: true, }, isBrowser: false, env: process.env.NODE_ENV, - isDevelopment: process.env.NODE_ENV !== 'production', + isDevelopment: process.env.NODE_ENV !== "production", nodeModules: webpackPaths.appNodeModulesPath, - } -} + }; +}; const configuration: webpack.Configuration = { - ...devtoolsConfig, + ...devtoolsConfig, - mode: 'production', + mode: "production", - target: ['web', 'electron-renderer'], + target: ["web", "electron-renderer"], - entry: [path.join(webpackPaths.srcRendererPath, 'index.tsx')], + entry: [path.join(webpackPaths.srcRendererPath, "index.tsx")], - output: { - path: webpackPaths.distRendererPath, - publicPath: './', - filename: 'renderer.js', - library: { - type: 'umd', + output: { + path: webpackPaths.distRendererPath, + publicPath: "./", + filename: "renderer.js", + library: { + type: "umd", + }, }, - }, - module: { - rules: [ - { - test: /\.s?(a|c)ss$/, - use: [ - MiniCssExtractPlugin.loader, - { - loader: 'css-loader', - options: { - modules: true, - sourceMap: true, - importLoaders: 1, + module: { + rules: [ + { + test: /\.s?(a|c)ss$/, + use: [ + MiniCssExtractPlugin.loader, + { + loader: "css-loader", + options: { + modules: true, + sourceMap: true, + importLoaders: 1, + }, + }, + "sass-loader", + ], + include: /\.module\.s?(c|a)ss$/, }, - }, - 'sass-loader', - ], - include: /\.module\.s?(c|a)ss$/, - }, - { - test: /\.s?(a|c)ss$/, - use: [ - MiniCssExtractPlugin.loader, - 'css-loader', - 'sass-loader', - { - loader: 'postcss-loader', - options: { - postcssOptions: { - plugins: - [ - require('tailwindcss'), - require('autoprefixer'), - ] - }, + { + test: /\.s?(a|c)ss$/, + use: [ + MiniCssExtractPlugin.loader, + "css-loader", + "sass-loader", + { + loader: "postcss-loader", + options: { + postcssOptions: { + plugins: [require("tailwindcss"), require("autoprefixer")], + }, + }, + }, + ], + exclude: /\.module\.s?(c|a)ss$/, + }, + // Fonts + { + test: /\.(woff|woff2|eot|ttf|otf)$/i, + type: "asset/resource", + }, + // Images + { + test: /\.(png|svg|jpg|jpeg|gif|mp4|webp)$/i, + type: "asset/resource", }, - }, ], - exclude: /\.module\.s?(c|a)ss$/, - }, - // Fonts - { - test: /\.(woff|woff2|eot|ttf|otf)$/i, - type: 'asset/resource', - }, - // Images - { - test: /\.(png|svg|jpg|jpeg|gif|mp4|webp)$/i, - type: 'asset/resource', - }, + }, + + optimization: { + minimize: true, + minimizer: [ + new TerserPlugin({ + parallel: true, + }), + new CssMinimizerPlugin(), + ], + }, + + plugins: [ + /** + * Create global constants which can be configured at compile time. + * + * Useful for allowing different behaviour between development builds and + * release builds + * + * NODE_ENV should be production so that modules do not perform certain + * development checks + */ + new webpack.EnvironmentPlugin({ + NODE_ENV: "production", + DEBUG_PROD: false, + }), + + new MiniCssExtractPlugin({ + filename: "style.css", + }), + + new BundleAnalyzerPlugin({ + analyzerMode: process.env.ANALYZE === "true" ? "server" : "disabled", + }), + + new HtmlWebpackPlugin(getHtmlPageOptions("index.html")), + new HtmlWebpackPlugin(getHtmlPageOptions("launcher.html")), + new HtmlWebpackPlugin(getHtmlPageOptions("oneclick-download-map.html")), + new HtmlWebpackPlugin(getHtmlPageOptions("oneclick-download-playlist.html")), + new HtmlWebpackPlugin(getHtmlPageOptions("oneclick-download-model.html")), ], - }, - - optimization: { - minimize: true, - minimizer: [ - new TerserPlugin({ - parallel: true, - }), - new CssMinimizerPlugin(), - ], - }, - - plugins: [ - /** - * Create global constants which can be configured at compile time. - * - * Useful for allowing different behaviour between development builds and - * release builds - * - * NODE_ENV should be production so that modules do not perform certain - * development checks - */ - new webpack.EnvironmentPlugin({ - NODE_ENV: 'production', - DEBUG_PROD: false, - }), - - new MiniCssExtractPlugin({ - filename: 'style.css', - }), - - new BundleAnalyzerPlugin({ - analyzerMode: process.env.ANALYZE === 'true' ? 'server' : 'disabled', - }), - - new HtmlWebpackPlugin(getHtmlPageOptions("index.html")), - new HtmlWebpackPlugin(getHtmlPageOptions("launcher.html")), - new HtmlWebpackPlugin(getHtmlPageOptions("oneclick-download-map.html")), - new HtmlWebpackPlugin(getHtmlPageOptions("oneclick-download-playlist.html")), - new HtmlWebpackPlugin(getHtmlPageOptions("oneclick-download-model.html")), - - ], }; export default merge(baseConfig, configuration); diff --git a/.erb/configs/webpack.paths.ts b/.erb/configs/webpack.paths.ts index e5ba5734..96b4addb 100644 --- a/.erb/configs/webpack.paths.ts +++ b/.erb/configs/webpack.paths.ts @@ -1,38 +1,38 @@ -const path = require('path'); +const path = require("path"); -const rootPath = path.join(__dirname, '../..'); +const rootPath = path.join(__dirname, "../.."); -const dllPath = path.join(__dirname, '../dll'); +const dllPath = path.join(__dirname, "../dll"); -const srcPath = path.join(rootPath, 'src'); -const srcMainPath = path.join(srcPath, 'main'); -const srcRendererPath = path.join(srcPath, 'renderer'); +const srcPath = path.join(rootPath, "src"); +const srcMainPath = path.join(srcPath, "main"); +const srcRendererPath = path.join(srcPath, "renderer"); -const releasePath = path.join(rootPath, 'release'); -const appPath = path.join(releasePath, 'app'); -const appPackagePath = path.join(appPath, 'package.json'); -const appNodeModulesPath = path.join(appPath, 'node_modules'); -const srcNodeModulesPath = path.join(srcPath, 'node_modules'); +const releasePath = path.join(rootPath, "release"); +const appPath = path.join(releasePath, "app"); +const appPackagePath = path.join(appPath, "package.json"); +const appNodeModulesPath = path.join(appPath, "node_modules"); +const srcNodeModulesPath = path.join(srcPath, "node_modules"); -const distPath = path.join(appPath, 'dist'); -const distMainPath = path.join(distPath, 'main'); -const distRendererPath = path.join(distPath, 'renderer'); +const distPath = path.join(appPath, "dist"); +const distMainPath = path.join(distPath, "main"); +const distRendererPath = path.join(distPath, "renderer"); -const buildPath = path.join(releasePath, 'build'); +const buildPath = path.join(releasePath, "build"); export default { - rootPath, - dllPath, - srcPath, - srcMainPath, - srcRendererPath, - releasePath, - appPath, - appPackagePath, - appNodeModulesPath, - srcNodeModulesPath, - distPath, - distMainPath, - distRendererPath, - buildPath, + rootPath, + dllPath, + srcPath, + srcMainPath, + srcRendererPath, + releasePath, + appPath, + appPackagePath, + appNodeModulesPath, + srcNodeModulesPath, + distPath, + distMainPath, + distRendererPath, + buildPath, }; diff --git a/.erb/mocks/fileMock.js b/.erb/mocks/fileMock.js index 602eb23e..dbc304ad 100644 --- a/.erb/mocks/fileMock.js +++ b/.erb/mocks/fileMock.js @@ -1 +1 @@ -export default 'test-file-stub'; +export default "test-file-stub"; diff --git a/.erb/scripts/.eslintrc b/.erb/scripts/.eslintrc index 35dc618d..431d4c34 100644 --- a/.erb/scripts/.eslintrc +++ b/.erb/scripts/.eslintrc @@ -1,8 +1,8 @@ { - "rules": { - "no-console": "off", - "global-require": "off", - "import/no-dynamic-require": "off", - "import/no-extraneous-dependencies": "off" - } + "rules": { + "no-console": "off", + "global-require": "off", + "import/no-dynamic-require": "off", + "import/no-extraneous-dependencies": "off" + } } diff --git a/.erb/scripts/check-build-exists.ts b/.erb/scripts/check-build-exists.ts index ccb0ba8a..5835f5b7 100644 --- a/.erb/scripts/check-build-exists.ts +++ b/.erb/scripts/check-build-exists.ts @@ -1,24 +1,16 @@ // Check if the renderer and main bundles are built -import path from 'path'; -import chalk from 'chalk'; -import fs from 'fs'; -import webpackPaths from '../configs/webpack.paths'; +import path from "path"; +import chalk from "chalk"; +import fs from "fs"; +import webpackPaths from "../configs/webpack.paths"; -const mainPath = path.join(webpackPaths.distMainPath, 'main.js'); -const rendererPath = path.join(webpackPaths.distRendererPath, 'renderer.js'); +const mainPath = path.join(webpackPaths.distMainPath, "main.js"); +const rendererPath = path.join(webpackPaths.distRendererPath, "renderer.js"); if (!fs.existsSync(mainPath)) { - throw new Error( - chalk.whiteBright.bgRed.bold( - 'The main process is not built yet. Build it by running "npm run build:main"' - ) - ); + throw new Error(chalk.whiteBright.bgRed.bold('The main process is not built yet. Build it by running "npm run build:main"')); } if (!fs.existsSync(rendererPath)) { - throw new Error( - chalk.whiteBright.bgRed.bold( - 'The renderer process is not built yet. Build it by running "npm run build:renderer"' - ) - ); + throw new Error(chalk.whiteBright.bgRed.bold('The renderer process is not built yet. Build it by running "npm run build:renderer"')); } diff --git a/.erb/scripts/check-native-dep.js b/.erb/scripts/check-native-dep.js index f5a23268..4a93337b 100644 --- a/.erb/scripts/check-native-dep.js +++ b/.erb/scripts/check-native-dep.js @@ -1,54 +1,38 @@ -import fs from 'fs'; -import chalk from 'chalk'; -import { execSync } from 'child_process'; -import { dependencies } from '../../package.json'; +import fs from "fs"; +import chalk from "chalk"; +import { execSync } from "child_process"; +import { dependencies } from "../../package.json"; if (dependencies) { - const dependenciesKeys = Object.keys(dependencies); - const nativeDeps = fs - .readdirSync('node_modules') - .filter((folder) => fs.existsSync(`node_modules/${folder}/binding.gyp`)); - if (nativeDeps.length === 0) { - process.exit(0); - } - try { - // Find the reason for why the dependency is installed. If it is installed - // because of a devDependency then that is okay. Warn when it is installed - // because of a dependency - const { dependencies: dependenciesObject } = JSON.parse( - execSync(`npm ls ${nativeDeps.join(' ')} --json`).toString() - ); - const rootDependencies = Object.keys(dependenciesObject); - const filteredRootDependencies = rootDependencies.filter((rootDependency) => - dependenciesKeys.includes(rootDependency) - ); - if (filteredRootDependencies.length > 0) { - const plural = filteredRootDependencies.length > 1; - console.log(` - ${chalk.whiteBright.bgYellow.bold( - 'Webpack does not work with native dependencies.' - )} -${chalk.bold(filteredRootDependencies.join(', '))} ${ - plural ? 'are native dependencies' : 'is a native dependency' - } and should be installed inside of the "./release/app" folder. - First, uninstall the packages from "./package.json": -${chalk.whiteBright.bgGreen.bold('npm uninstall your-package')} - ${chalk.bold( - 'Then, instead of installing the package to the root "./package.json":' - )} -${chalk.whiteBright.bgRed.bold('npm install your-package')} - ${chalk.bold('Install the package to "./release/app/package.json"')} -${chalk.whiteBright.bgGreen.bold( - 'cd ./release/app && npm install your-package' -)} - Read more about native dependencies at: -${chalk.bold( - 'https://electron-react-boilerplate.js.org/docs/adding-dependencies/#module-structure' -)} - `); - process.exit(1); + const dependenciesKeys = Object.keys(dependencies); + const nativeDeps = fs.readdirSync("node_modules").filter(folder => fs.existsSync(`node_modules/${folder}/binding.gyp`)); + if (nativeDeps.length === 0) { + process.exit(0); + } + try { + // Find the reason for why the dependency is installed. If it is installed + // because of a devDependency then that is okay. Warn when it is installed + // because of a dependency + const { dependencies: dependenciesObject } = JSON.parse(execSync(`npm ls ${nativeDeps.join(" ")} --json`).toString()); + const rootDependencies = Object.keys(dependenciesObject); + const filteredRootDependencies = rootDependencies.filter(rootDependency => dependenciesKeys.includes(rootDependency)); + if (filteredRootDependencies.length > 0) { + const plural = filteredRootDependencies.length > 1; + console.log(` + ${chalk.whiteBright.bgYellow.bold("Webpack does not work with native dependencies.")} +${chalk.bold(filteredRootDependencies.join(", "))} ${plural ? "are native dependencies" : "is a native dependency"} and should be installed inside of the "./release/app" folder. + First, uninstall the packages from "./package.json": +${chalk.whiteBright.bgGreen.bold("npm uninstall your-package")} + ${chalk.bold('Then, instead of installing the package to the root "./package.json":')} +${chalk.whiteBright.bgRed.bold("npm install your-package")} + ${chalk.bold('Install the package to "./release/app/package.json"')} +${chalk.whiteBright.bgGreen.bold("cd ./release/app && npm install your-package")} + Read more about native dependencies at: +${chalk.bold("https://electron-react-boilerplate.js.org/docs/adding-dependencies/#module-structure")} + `); + process.exit(1); + } + } catch (e) { + console.log("Native dependencies could not be checked"); } - } catch (e) { - console.log('Native dependencies could not be checked'); - } } diff --git a/.erb/scripts/check-node-env.js b/.erb/scripts/check-node-env.js index 0e74b115..5f19ed94 100644 --- a/.erb/scripts/check-node-env.js +++ b/.erb/scripts/check-node-env.js @@ -1,16 +1,12 @@ -import chalk from 'chalk'; +import chalk from "chalk"; export default function checkNodeEnv(expectedEnv) { - if (!expectedEnv) { - throw new Error('"expectedEnv" not set'); - } + if (!expectedEnv) { + throw new Error('"expectedEnv" not set'); + } - if (process.env.NODE_ENV !== expectedEnv) { - console.log( - chalk.whiteBright.bgRed.bold( - `"process.env.NODE_ENV" must be "${expectedEnv}" to use this webpack config` - ) - ); - process.exit(2); - } + if (process.env.NODE_ENV !== expectedEnv) { + console.log(chalk.whiteBright.bgRed.bold(`"process.env.NODE_ENV" must be "${expectedEnv}" to use this webpack config`)); + process.exit(2); + } } diff --git a/.erb/scripts/check-port-in-use.js b/.erb/scripts/check-port-in-use.js index 3ade730a..65503aea 100644 --- a/.erb/scripts/check-port-in-use.js +++ b/.erb/scripts/check-port-in-use.js @@ -1,16 +1,12 @@ -import chalk from 'chalk'; -import detectPort from 'detect-port'; +import chalk from "chalk"; +import detectPort from "detect-port"; -const port = process.env.PORT || '1212'; +const port = process.env.PORT || "1212"; detectPort(port, (err, availablePort) => { - if (port !== String(availablePort)) { - throw new Error( - chalk.whiteBright.bgRed.bold( - `Port "${port}" on "localhost" is already in use. Please use another port. ex: PORT=4343 npm start` - ) - ); - } else { - process.exit(0); - } + if (port !== String(availablePort)) { + throw new Error(chalk.whiteBright.bgRed.bold(`Port "${port}" on "localhost" is already in use. Please use another port. ex: PORT=4343 npm start`)); + } else { + process.exit(0); + } }); diff --git a/.erb/scripts/clean.js b/.erb/scripts/clean.js index b03b0baf..f73271f9 100644 --- a/.erb/scripts/clean.js +++ b/.erb/scripts/clean.js @@ -1,17 +1,17 @@ -import rimraf from 'rimraf'; -import process from 'process'; -import webpackPaths from '../configs/webpack.paths'; +import rimraf from "rimraf"; +import process from "process"; +import webpackPaths from "../configs/webpack.paths"; const args = process.argv.slice(2); const commandMap = { - dist: webpackPaths.distPath, - release: webpackPaths.releasePath, - dll: webpackPaths.dllPath, + dist: webpackPaths.distPath, + release: webpackPaths.releasePath, + dll: webpackPaths.dllPath, }; -args.forEach((x) => { - const pathToRemove = commandMap[x]; - if (pathToRemove !== undefined) { - rimraf.sync(pathToRemove); - } +args.forEach(x => { + const pathToRemove = commandMap[x]; + if (pathToRemove !== undefined) { + rimraf.sync(pathToRemove); + } }); diff --git a/.erb/scripts/delete-source-maps.js b/.erb/scripts/delete-source-maps.js index 3d051eab..1ed590da 100644 --- a/.erb/scripts/delete-source-maps.js +++ b/.erb/scripts/delete-source-maps.js @@ -1,8 +1,8 @@ -import path from 'path'; -import rimraf from 'rimraf'; -import webpackPaths from '../configs/webpack.paths'; +import path from "path"; +import rimraf from "rimraf"; +import webpackPaths from "../configs/webpack.paths"; export default function deleteSourceMaps() { - rimraf.sync(path.join(webpackPaths.distMainPath, '*.js.map')); - rimraf.sync(path.join(webpackPaths.distRendererPath, '*.js.map')); + rimraf.sync(path.join(webpackPaths.distMainPath, "*.js.map")); + rimraf.sync(path.join(webpackPaths.distRendererPath, "*.js.map")); } diff --git a/.erb/scripts/electron-rebuild.js b/.erb/scripts/electron-rebuild.js index 0bea3279..fca6c630 100644 --- a/.erb/scripts/electron-rebuild.js +++ b/.erb/scripts/electron-rebuild.js @@ -1,20 +1,13 @@ -import { execSync } from 'child_process'; -import fs from 'fs'; -import { dependencies } from '../../release/app/package.json'; -import webpackPaths from '../configs/webpack.paths'; +import { execSync } from "child_process"; +import fs from "fs"; +import { dependencies } from "../../release/app/package.json"; +import webpackPaths from "../configs/webpack.paths"; -if ( - Object.keys(dependencies || {}).length > 0 && - fs.existsSync(webpackPaths.appNodeModulesPath) -) { - const electronRebuildCmd = - '../../node_modules/.bin/electron-rebuild --force --types prod,dev,optional --module-dir .'; - const cmd = - process.platform === 'win32' - ? electronRebuildCmd.replace(/\//g, '\\') - : electronRebuildCmd; - execSync(cmd, { - cwd: webpackPaths.appPath, - stdio: 'inherit', - }); +if (Object.keys(dependencies || {}).length > 0 && fs.existsSync(webpackPaths.appNodeModulesPath)) { + const electronRebuildCmd = "../../node_modules/.bin/electron-rebuild --force --types prod,dev,optional --module-dir ."; + const cmd = process.platform === "win32" ? electronRebuildCmd.replace(/\//g, "\\") : electronRebuildCmd; + execSync(cmd, { + cwd: webpackPaths.appPath, + stdio: "inherit", + }); } diff --git a/.erb/scripts/link-modules.ts b/.erb/scripts/link-modules.ts index 6cc31e66..75ef24b1 100644 --- a/.erb/scripts/link-modules.ts +++ b/.erb/scripts/link-modules.ts @@ -1,9 +1,9 @@ -import fs from 'fs'; -import webpackPaths from '../configs/webpack.paths'; +import fs from "fs"; +import webpackPaths from "../configs/webpack.paths"; const { srcNodeModulesPath } = webpackPaths; const { appNodeModulesPath } = webpackPaths; if (!fs.existsSync(srcNodeModulesPath) && fs.existsSync(appNodeModulesPath)) { - fs.symlinkSync(appNodeModulesPath, srcNodeModulesPath, 'junction'); + fs.symlinkSync(appNodeModulesPath, srcNodeModulesPath, "junction"); } diff --git a/.erb/scripts/notarize.js b/.erb/scripts/notarize.js index 4fd3bb8f..68281f6d 100644 --- a/.erb/scripts/notarize.js +++ b/.erb/scripts/notarize.js @@ -1,30 +1,28 @@ -const { notarize } = require('electron-notarize'); -const { build } = require('../../package.json'); +const { notarize } = require("electron-notarize"); +const { build } = require("../../package.json"); exports.default = async function notarizeMacos(context) { - const { electronPlatformName, appOutDir } = context; - if (electronPlatformName !== 'darwin') { - return; - } + const { electronPlatformName, appOutDir } = context; + if (electronPlatformName !== "darwin") { + return; + } - if (process.env.CI !== 'true') { - console.warn('Skipping notarizing step. Packaging is not running in CI'); - return; - } + if (process.env.CI !== "true") { + console.warn("Skipping notarizing step. Packaging is not running in CI"); + return; + } - if (!('APPLE_ID' in process.env && 'APPLE_ID_PASS' in process.env)) { - console.warn( - 'Skipping notarizing step. APPLE_ID and APPLE_ID_PASS env variables must be set' - ); - return; - } + if (!("APPLE_ID" in process.env && "APPLE_ID_PASS" in process.env)) { + console.warn("Skipping notarizing step. APPLE_ID and APPLE_ID_PASS env variables must be set"); + return; + } - const appName = context.packager.appInfo.productFilename; + const appName = context.packager.appInfo.productFilename; - await notarize({ - appBundleId: build.appId, - appPath: `${appOutDir}/${appName}.app`, - appleId: process.env.APPLE_ID, - appleIdPassword: process.env.APPLE_ID_PASS, - }); + await notarize({ + appBundleId: build.appId, + appPath: `${appOutDir}/${appName}.app`, + appleId: process.env.APPLE_ID, + appleIdPassword: process.env.APPLE_ID_PASS, + }); }; diff --git a/.eslintrc.js b/.eslintrc.js index 5513c870..a574bc5c 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,70 +1,70 @@ module.exports = { - extends: 'erb', - rules: { - // A temporary hack related to IDE not resolving correct package.json - 'import/no-extraneous-dependencies': 'off', - 'import/no-unresolved': 'error', - // Since React 17 and typescript 4.1 you can safely disable the rule - 'react/react-in-jsx-scope': 'off', - 'prettier/prettier': 0, - "global-require": 0, - "import/prefer-default-export": "off", - "no-empty-function": "off", - "no-await-in-loop": "off", - "no-continue": "off", - "@typescript-eslint/no-empty-function": "off", - '@typescript-eslint/lines-between-class-members': "off", - "class-methods-use-this": "off", - "promise/catch-or-return": "off", - "promise/always-return": "off", - "import/order": "off", - "react/destructuring-assignment": "off", - "promise/no-nesting": "off", - "react-hooks/exhaustive-deps": "off", - "@typescript-eslint/no-shadow": "off", - "@typescript-eslint/no-use-before-define": "off", - "jsx-a11y/click-events-have-key-events": "off", - "jsx-a11y/no-static-element-interactions": "off", - "react/require-default-props": "off", - "consistent-return": "off", - "no-underscore-dangle": "off", - "no-restricted-syntax": "off", - "@typescript-eslint/no-throw-literal": "off", - "@typescript-eslint/no-unused-expressions": "off", - "no-param-reassign": "off", - "no-useless-escape": "off", - "jsx-a11y/no-noninteractive-element-interactions": "off", - "no-async-promise-executor": "off", - "new-cap": "off", - "no-new": "off", - "no-plusplus": "off", - "react/jsx-props-no-spreading": "off", - "jsx-a11y/iframe-has-title": "off", - "import/no-dynamic-require": "off", - "radix": "off", - "jsx-a11y/alt-text": "off", - "react/prop-types": "off", - "import/no-cycle": "off", - "prefer-promise-reject-errors": "off" - }, - parserOptions: { - ecmaVersion: 2020, - sourceType: 'module', - project: './tsconfig.json', - tsconfigRootDir: __dirname, - createDefaultProgram: true, - }, - settings: { - 'import/resolver': { - // See https://github.com/benmosher/eslint-plugin-import/issues/1396#issuecomment-575727774 for line below - node: {}, - webpack: { - config: require.resolve('./.erb/configs/webpack.config.eslint.ts'), - }, - typescript: {}, + extends: "erb", + rules: { + // A temporary hack related to IDE not resolving correct package.json + "import/no-extraneous-dependencies": "off", + "import/no-unresolved": "error", + // Since React 17 and typescript 4.1 you can safely disable the rule + "react/react-in-jsx-scope": "off", + "prettier/prettier": 0, + "global-require": 0, + "import/prefer-default-export": "off", + "no-empty-function": "off", + "no-await-in-loop": "off", + "no-continue": "off", + "@typescript-eslint/no-empty-function": "off", + "@typescript-eslint/lines-between-class-members": "off", + "class-methods-use-this": "off", + "promise/catch-or-return": "off", + "promise/always-return": "off", + "import/order": "off", + "react/destructuring-assignment": "off", + "promise/no-nesting": "off", + "react-hooks/exhaustive-deps": "off", + "@typescript-eslint/no-shadow": "off", + "@typescript-eslint/no-use-before-define": "off", + "jsx-a11y/click-events-have-key-events": "off", + "jsx-a11y/no-static-element-interactions": "off", + "react/require-default-props": "off", + "consistent-return": "off", + "no-underscore-dangle": "off", + "no-restricted-syntax": "off", + "@typescript-eslint/no-throw-literal": "off", + "@typescript-eslint/no-unused-expressions": "off", + "no-param-reassign": "off", + "no-useless-escape": "off", + "jsx-a11y/no-noninteractive-element-interactions": "off", + "no-async-promise-executor": "off", + "new-cap": "off", + "no-new": "off", + "no-plusplus": "off", + "react/jsx-props-no-spreading": "off", + "jsx-a11y/iframe-has-title": "off", + "import/no-dynamic-require": "off", + radix: "off", + "jsx-a11y/alt-text": "off", + "react/prop-types": "off", + "import/no-cycle": "off", + "prefer-promise-reject-errors": "off", }, - 'import/parsers': { - '@typescript-eslint/parser': ['.ts', '.tsx'], + parserOptions: { + ecmaVersion: 2020, + sourceType: "module", + project: "./tsconfig.json", + tsconfigRootDir: __dirname, + createDefaultProgram: true, + }, + settings: { + "import/resolver": { + // See https://github.com/benmosher/eslint-plugin-import/issues/1396#issuecomment-575727774 for line below + node: {}, + webpack: { + config: require.resolve("./.erb/configs/webpack.config.eslint.ts"), + }, + typescript: {}, + }, + "import/parsers": { + "@typescript-eslint/parser": [".ts", ".tsx"], + }, }, - }, }; diff --git a/.github/ISSUE_TEMPLATE/-bug--bug-report.md b/.github/ISSUE_TEMPLATE/-bug--bug-report.md index e5f00799..cdb91fa0 100644 --- a/.github/ISSUE_TEMPLATE/-bug--bug-report.md +++ b/.github/ISSUE_TEMPLATE/-bug--bug-report.md @@ -4,7 +4,6 @@ about: Create a report to help us improve title: "[BUG] : " labels: bug assignees: Zagrios - --- **Describe the bug** @@ -12,6 +11,7 @@ A clear and concise description of what the bug is. **To Reproduce** Steps to reproduce the behavior: + 1. Go to '...' 2. Click on '....' 3. Scroll down to '....' @@ -24,8 +24,9 @@ A clear and concise description of what you expected to happen. If applicable, add screenshots to help explain your problem. **Desktop (please complete the following information):** - - OS: [e.g. iOS] - - Version [e.g. 22] + +- OS: [e.g. iOS] +- Version [e.g. 22] **Additional context** Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/-feat---feature-request.md b/.github/ISSUE_TEMPLATE/-feat---feature-request.md index 11b2a633..19c6b5da 100644 --- a/.github/ISSUE_TEMPLATE/-feat---feature-request.md +++ b/.github/ISSUE_TEMPLATE/-feat---feature-request.md @@ -4,7 +4,6 @@ about: Suggest an idea for this project title: "[FEAT.] : " labels: enhancement assignees: Zagrios - --- **Is your feature request related to a problem? Please describe.** diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 1f0eab3d..cec2a02a 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -4,21 +4,21 @@ name: Linting on: - push: - branches: [ "master" ] - pull_request: - branches: [ "master" ] + push: + branches: ["master"] + pull_request: + branches: ["master"] jobs: - build: - runs-on: ubuntu-latest + build: + runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: Use Node.js - uses: actions/setup-node@v3 - with: - node-version: 18.x - cache: 'npm' - - run: npm ci - - run: npm run lint + steps: + - uses: actions/checkout@v3 + - name: Use Node.js + uses: actions/setup-node@v3 + with: + node-version: 18.x + cache: "npm" + - run: npm ci + - run: npm run lint diff --git a/.github/workflows/node.js.yaml b/.github/workflows/node.js.yaml index 4f0ffcc0..b666d9bb 100644 --- a/.github/workflows/node.js.yaml +++ b/.github/workflows/node.js.yaml @@ -4,28 +4,28 @@ name: Node.js CI on: - push: - branches: [ "master" ] - pull_request: - branches: [ "master" ] + push: + branches: ["master"] + pull_request: + branches: ["master"] jobs: - build: - strategy: - matrix: - os: [ubuntu-latest, windows-latest, macos-latest] + build: + strategy: + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] - runs-on: ${{ matrix.os }} + runs-on: ${{ matrix.os }} - steps: - - uses: actions/checkout@v3 - - name: Use Node.js - uses: actions/setup-node@v3 - with: - node-version: 18.x - cache: 'npm' - - run: npm ci - - run: npm run build - - run: npm test - # Currently typescript, eslint, and prettier are unhappy - continue-on-error: true + steps: + - uses: actions/checkout@v3 + - name: Use Node.js + uses: actions/setup-node@v3 + with: + node-version: 18.x + cache: "npm" + - run: npm ci + - run: npm run build + - run: npm test + # Currently typescript, eslint, and prettier are unhappy + continue-on-error: true diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index dd88d677..e7ff0db1 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -1,20 +1,20 @@ name: Build on: - push: - branches: - - master - pull_request_target: - types: [opened, synchronize, reopened] + push: + branches: + - master + pull_request_target: + types: [opened, synchronize, reopened] jobs: - sonarcloud: - name: SonarCloud - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis - - name: SonarCloud Scan - uses: SonarSource/sonarcloud-github-action@master - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} \ No newline at end of file + sonarcloud: + name: SonarCloud + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis + - name: SonarCloud Scan + uses: SonarSource/sonarcloud-github-action@master + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} diff --git a/.vscode/extensions.json b/.vscode/extensions.json index d9165248..ae2213e4 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -1,3 +1,3 @@ { - "recommendations": ["dbaeumer.vscode-eslint", "EditorConfig.EditorConfig"] + "recommendations": ["dbaeumer.vscode-eslint", "EditorConfig.EditorConfig"] } diff --git a/.vscode/launch.json b/.vscode/launch.json index acd2b9fb..9c06cf39 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -1,30 +1,28 @@ { - "version": "0.2.0", - "configurations": [ - { - "name": "Electron: Main", - "type": "node", - "request": "launch", - "protocol": "inspector", - "runtimeExecutable": "npm", - "runtimeArgs": [ - "run start:main --inspect=5858 --remote-debugging-port=9223" - ], - "preLaunchTask": "Start Webpack Dev" - }, - { - "name": "Electron: Renderer", - "type": "chrome", - "request": "attach", - "port": 9223, - "webRoot": "${workspaceFolder}", - "timeout": 15000 - } - ], - "compounds": [ - { - "name": "Electron: All", - "configurations": ["Electron: Main", "Electron: Renderer"] - } - ] + "version": "0.2.0", + "configurations": [ + { + "name": "Electron: Main", + "type": "node", + "request": "launch", + "protocol": "inspector", + "runtimeExecutable": "npm", + "runtimeArgs": ["run start:main --inspect=5858 --remote-debugging-port=9223"], + "preLaunchTask": "Start Webpack Dev" + }, + { + "name": "Electron: Renderer", + "type": "chrome", + "request": "attach", + "port": 9223, + "webRoot": "${workspaceFolder}", + "timeout": 15000 + } + ], + "compounds": [ + { + "name": "Electron: All", + "configurations": ["Electron: Main", "Electron: Renderer"] + } + ] } diff --git a/.vscode/settings.json b/.vscode/settings.json index 2f19f17f..3aadc1f0 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,33 +1,27 @@ { - "files.associations": { - ".eslintrc": "jsonc", - ".prettierrc": "jsonc", - ".eslintignore": "ignore" - }, + "files.associations": { + ".eslintrc": "jsonc", + ".prettierrc": "jsonc", + ".eslintignore": "ignore" + }, - "eslint.validate": [ - "javascript", - "javascriptreact", - "html", - "typescriptreact" - ], + "eslint.validate": ["javascript", "javascriptreact", "html", "typescriptreact"], - "javascript.validate.enable": false, - "javascript.format.enable": false, - "typescript.format.enable": false, + "javascript.validate.enable": false, + "javascript.format.enable": false, + "typescript.format.enable": false, - "search.exclude": { - ".git": true, - ".eslintcache": true, - ".erb/dll": true, - "release/{build,app/dist}": true, - "node_modules": true, - "npm-debug.log.*": true, - "test/**/__snapshots__": true, - "package-lock.json": true, - "*.{css,sass,scss}.d.ts": true - }, - "editor.detectIndentation": false, - "editor.tabSize": 4 - + "search.exclude": { + ".git": true, + ".eslintcache": true, + ".erb/dll": true, + "release/{build,app/dist}": true, + "node_modules": true, + "npm-debug.log.*": true, + "test/**/__snapshots__": true, + "package-lock.json": true, + "*.{css,sass,scss}.d.ts": true + }, + "editor.detectIndentation": false, + "editor.tabSize": 4 } diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 42cb7401..e0c639bd 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -1,25 +1,25 @@ { - "version": "2.0.0", - "tasks": [ - { - "type": "npm", - "label": "Start Webpack Dev", - "script": "start:renderer", - "options": { - "cwd": "${workspaceFolder}" - }, - "isBackground": true, - "problemMatcher": { - "owner": "custom", - "pattern": { - "regexp": "____________" - }, - "background": { - "activeOnStart": true, - "beginsPattern": "Compiling\\.\\.\\.$", - "endsPattern": "(Compiled successfully|Failed to compile)\\.$" + "version": "2.0.0", + "tasks": [ + { + "type": "npm", + "label": "Start Webpack Dev", + "script": "start:renderer", + "options": { + "cwd": "${workspaceFolder}" + }, + "isBackground": true, + "problemMatcher": { + "owner": "custom", + "pattern": { + "regexp": "____________" + }, + "background": { + "activeOnStart": true, + "beginsPattern": "Compiling\\.\\.\\.$", + "endsPattern": "(Compiled successfully|Failed to compile)\\.$" + } + } } - } - } - ] + ] } diff --git a/CHANGELOG.md b/CHANGELOG.md index ca12ddd6..72e7f1bc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,16 +1,19 @@ ## [0.2.0](https://github.com/Zagrios/bs-manager/releases/tag/v0.2.0) (October 23, 2022) -### Features -- Mods management fully implementd [5c47897](https://github.com/Zagrios/bs-manager/commit/5c478979e96b14dd54a3889e551c163ece701b4a) -- Add close button in settings page #5 -- Add GitHub and contribution actions in settings page #3 -### Fixes -- Lunch Beat Saber multiple times #1 -- Placeholders and some texts not with light theme #6 -- Wrong background color when version is downloading #7 -- Add missing translations [5817260](https://github.com/Zagrios/bs-manager/commit/58172606f3f4731c90c9aa838fb89ac95458e032) -- Error when loading downloaded versions when Steam is not installed [6e07adb](https://github.com/Zagrios/bs-manager/commit/6e07adb990f78073dd68c2b9cf6209562bb4bf2b) +### Features + +- Mods management fully implementd [5c47897](https://github.com/Zagrios/bs-manager/commit/5c478979e96b14dd54a3889e551c163ece701b4a) +- Add close button in settings page #5 +- Add GitHub and contribution actions in settings page #3 + +### Fixes + +- Lunch Beat Saber multiple times #1 +- Placeholders and some texts not with light theme #6 +- Wrong background color when version is downloading #7 +- Add missing translations [5817260](https://github.com/Zagrios/bs-manager/commit/58172606f3f4731c90c9aa838fb89ac95458e032) +- Error when loading downloaded versions when Steam is not installed [6e07adb](https://github.com/Zagrios/bs-manager/commit/6e07adb990f78073dd68c2b9cf6209562bb4bf2b) ## [0.1.0](https://github.com/Zagrios/bs-manager/releases/tag/v0.1.0) (September 19, 2022) -- Initial public release \ No newline at end of file +- Initial public release diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index 972fb08e..1526cc01 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -1,4 +1,3 @@ - # Contributor Covenant Code of Conduct ## Our Pledge @@ -18,24 +17,24 @@ diverse, inclusive, and healthy community. Examples of behavior that contributes to a positive environment for our community include: -* Demonstrating empathy and kindness toward other people -* Being respectful of differing opinions, viewpoints, and experiences -* Giving and gracefully accepting constructive feedback -* Accepting responsibility and apologizing to those affected by our mistakes, - and learning from the experience -* Focusing on what is best not just for us as individuals, but for the overall - community +- Demonstrating empathy and kindness toward other people +- Being respectful of differing opinions, viewpoints, and experiences +- Giving and gracefully accepting constructive feedback +- Accepting responsibility and apologizing to those affected by our mistakes, + and learning from the experience +- Focusing on what is best not just for us as individuals, but for the overall + community Examples of unacceptable behavior include: -* The use of sexualized language or imagery, and sexual attention or advances of - any kind -* Trolling, insulting or derogatory comments, and personal or political attacks -* Public or private harassment -* Publishing others' private information, such as a physical or email address, - without their explicit permission -* Other conduct which could reasonably be considered inappropriate in a - professional setting +- The use of sexualized language or imagery, and sexual attention or advances of + any kind +- Trolling, insulting or derogatory comments, and personal or political attacks +- Public or private harassment +- Publishing others' private information, such as a physical or email address, + without their explicit permission +- Other conduct which could reasonably be considered inappropriate in a + professional setting ## Enforcement Responsibilities @@ -119,14 +118,14 @@ version 2.1, available at [https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1]. Community Impact Guidelines were inspired by -[Mozilla's code of conduct enforcement ladder][Mozilla CoC]. +[Mozilla's code of conduct enforcement ladder][mozilla coc]. For answers to common questions about this code of conduct, see the FAQ at -[https://www.contributor-covenant.org/faq][FAQ]. Translations are available at +[https://www.contributor-covenant.org/faq][faq]. Translations are available at [https://www.contributor-covenant.org/translations][translations]. [homepage]: https://www.contributor-covenant.org [v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html -[Mozilla CoC]: https://github.com/mozilla/diversity -[FAQ]: https://www.contributor-covenant.org/faq +[mozilla coc]: https://github.com/mozilla/diversity +[faq]: https://www.contributor-covenant.org/faq [translations]: https://www.contributor-covenant.org/translations diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 2035890b..0399414d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -26,7 +26,7 @@ We'd also love PRs. If you're thinking of a large PR, we advise opening up an is Here are a few things you can do that will increase the likelihood of your pull request being accepted: -- Follow the [style guide][style] which is using standard. -- Keep your changes as focused as possible. If there are multiple changes you would like to make that are not dependent upon each other, consider submitting them as separate pull requests. +- Follow the [style guide][style] which is using standard. +- Keep your changes as focused as possible. If there are multiple changes you would like to make that are not dependent upon each other, consider submitting them as separate pull requests. Work in Progress pull requests are also welcome to get feedback early on, or if there is something blocked you. diff --git a/README.md b/README.md index 9dba4c8a..d4340f5e 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,6 @@ *** https://www.markdownguide.org/basic-syntax/#reference-style-links --> -
@@ -32,8 +31,8 @@
- ---- +## +
Stargazers @@ -50,8 +49,11 @@
--- + + Table of Contents +