Skip to content

Commit

Permalink
Merge pull request #362 from ryohey/fix-signin-with-apple
Browse files Browse the repository at this point in the history
Fix signin with apple
  • Loading branch information
ryohey authored Jun 1, 2024
2 parents a368de9 + 32b54cc commit 974c856
Show file tree
Hide file tree
Showing 20 changed files with 253 additions and 177 deletions.
2 changes: 2 additions & 0 deletions app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
"scripts": {
"dev": "webpack serve --config webpack.dev.js",
"build": "webpack --config webpack.prod.js",
"dev:electron": "webpack serve --config webpack.electron.dev.js",
"build:electron": "webpack --config webpack.electron.prod.js",
"serve": "npx http-server dist",
"test": "jest",
"format": "prettier --write src",
Expand Down
2 changes: 1 addition & 1 deletion app/src/components/App/ElectronCallbackHandler.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ export const ElectronCallbackHandler: FC = observer(() => {
try {
await signInWithCredential(auth, credential)
} catch (e) {
toast.error("Failed to sign in with Google")
toast.error("Failed to sign in")
}
},
),
Expand Down
4 changes: 2 additions & 2 deletions app/webpack.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const HtmlWebpackPlugin = require("html-webpack-plugin")
const webpack = require("webpack")
const Dotenv = require("dotenv-webpack")

module.exports = (env) => ({
module.exports = {
context: __dirname,
entry: {
browserMain: "./src/index.tsx",
Expand Down Expand Up @@ -49,4 +49,4 @@ module.exports = (env) => ({
template: path.join(__dirname, "public", "community.html"),
}),
],
})
}
6 changes: 2 additions & 4 deletions app/webpack.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const path = require("path")
const ForkTsCheckerWebpackPlugin = require("fork-ts-checker-webpack-plugin")
const ReactRefreshWebpackPlugin = require("@pmmmwh/react-refresh-webpack-plugin")

const config = {
module.exports = merge(common, {
mode: "development",
devtool: "inline-source-map",
devServer: {
Expand Down Expand Up @@ -64,6 +64,4 @@ const config = {
react: path.resolve("../node_modules/react"),
},
},
}

module.exports = (env) => merge(common(env), config)
})
38 changes: 38 additions & 0 deletions app/webpack.electron.common.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
const path = require("path")
const HtmlWebpackPlugin = require("html-webpack-plugin")
const webpack = require("webpack")
const Dotenv = require("dotenv-webpack")

module.exports = {
context: __dirname,
entry: {
browserMain: "./src/index.tsx",
},
output: {
filename: "[name]-[chunkhash].js",
clean: true,
},
module: {
rules: [
{
test: /\.(png|jpg|jpeg|gif|woff|woff2|eot|ttf)$/,
loader: "url-loader",
},
],
},
resolve: {
extensions: [".js", ".jsx", ".ts", ".tsx"],
},
plugins: [
new Dotenv({
path: path.join(__dirname, "../.env"),
systemvars: true,
}),
new HtmlWebpackPlugin({
inject: true,
filename: "edit.html",
chunks: ["browserMain"],
template: path.join(__dirname, "public", "edit.html"),
}),
],
}
58 changes: 58 additions & 0 deletions app/webpack.electron.dev.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
const { merge } = require("webpack-merge")
const common = require("./webpack.common.js")
const path = require("path")
const ForkTsCheckerWebpackPlugin = require("fork-ts-checker-webpack-plugin")
const ReactRefreshWebpackPlugin = require("@pmmmwh/react-refresh-webpack-plugin")

module.exports = merge(common, {
mode: "development",
devtool: "inline-source-map",
devServer: {
port: 3000,
hot: "only",
static: {
directory: path.resolve(__dirname, "public"),
watch: true,
},
client: {
overlay: {
warnings: false,
errors: true,
},
},
historyApiFallback: {
rewrites: [{ from: /^\/edit$/, to: "/edit.html" }],
},
},
module: {
rules: [
{
test: /\.(j|t)sx?$/,
exclude: /node_modules/,
use: {
loader: "babel-loader",
options: {
plugins: [require.resolve("react-refresh/babel")],
},
},
},
{
test: /\.js$/,
enforce: "pre",
use: ["source-map-loader"],
},
],
},
plugins: [
new ForkTsCheckerWebpackPlugin(),
new ReactRefreshWebpackPlugin({
exclude: [/node_modules/],
}),
],
resolve: {
alias: {
// Prevent to load local package's react https://github.com/facebook/react/issues/13991#issuecomment-435587809
react: path.resolve("../node_modules/react"),
},
},
})
35 changes: 35 additions & 0 deletions app/webpack.electron.prod.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
const { merge } = require("webpack-merge")
const common = require("./webpack.common.js")
const CopyPlugin = require("copy-webpack-plugin")
const { sentryWebpackPlugin } = require("@sentry/webpack-plugin")
const WorkboxPlugin = require("workbox-webpack-plugin")

module.exports = merge(common, {
mode: "production",
optimization: {
concatenateModules: false,
splitChunks: {
chunks: "all",
},
},
module: {
rules: [
{
test: /\.(j|t)sx?$/,
exclude: /node_modules/,
use: {
loader: "babel-loader",
},
},
],
},
plugins: [
new CopyPlugin({
patterns: [
{ from: "public/*.svg", to: "[name][ext]" },
{ from: "public/*.png", to: "[name][ext]" },
{ from: "public/*.webmanifest", to: "[name][ext]" },
],
}),
],
})
54 changes: 24 additions & 30 deletions app/webpack.prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const CopyPlugin = require("copy-webpack-plugin")
const { sentryWebpackPlugin } = require("@sentry/webpack-plugin")
const WorkboxPlugin = require("workbox-webpack-plugin")

const config = (env) => ({
module.exports = merge(common, {
mode: "production",
optimization: {
concatenateModules: false,
Expand All @@ -24,33 +24,29 @@ const config = (env) => ({
],
},
plugins: [
...(env.electron
? []
: [
new WorkboxPlugin.GenerateSW({
maximumFileSizeToCacheInBytes: 50000000,
clientsClaim: true,
skipWaiting: true,
runtimeCaching: [
{
urlPattern: /^\/.*$/,
handler: "StaleWhileRevalidate",
},
{
urlPattern: /^.+\.sf2$/,
handler: "StaleWhileRevalidate",
},
{
urlPattern: /^https:\/\/fonts\.googleapis\.com/,
handler: "StaleWhileRevalidate",
},
{
urlPattern: /^https:\/\/fonts\.gstatic\.com/,
handler: "StaleWhileRevalidate",
},
],
}),
]),
new WorkboxPlugin.GenerateSW({
maximumFileSizeToCacheInBytes: 50000000,
clientsClaim: true,
skipWaiting: true,
runtimeCaching: [
{
urlPattern: /^\/.*$/,
handler: "StaleWhileRevalidate",
},
{
urlPattern: /^.+\.sf2$/,
handler: "StaleWhileRevalidate",
},
{
urlPattern: /^https:\/\/fonts\.googleapis\.com/,
handler: "StaleWhileRevalidate",
},
{
urlPattern: /^https:\/\/fonts\.gstatic\.com/,
handler: "StaleWhileRevalidate",
},
],
}),
new CopyPlugin({
patterns: [
{ from: "public/*.svg", to: "[name][ext]" },
Expand Down Expand Up @@ -78,5 +74,3 @@ const config = (env) => ({
}),
],
})

module.exports = (env) => merge(common(env), config(env))
37 changes: 36 additions & 1 deletion electron/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions electron/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
"dev": "concurrently \"npm run build -- --watch\" \"nodemon\"",
"start": "npm run build && electron .",
"build": "rollup -c --bundleConfigAsCjs",
"build:swift": "./scripts/build_swift.sh",
"package:darwin": "npm run build && electron-forge package --platform=darwin",
"make": "npm run build && electron-forge make",
"make:mas": "npm run make -- --arch=universal --platform=mas",
Expand All @@ -33,6 +32,7 @@
"dependencies": {
"dotenv": "^16.4.5",
"electron-log": "^5.1.2",
"electron-window-state": "^5.0.3"
"electron-window-state": "^5.0.3",
"node-mac-sign-in-with-apple": "github:thomasdao/node-mac-sign-in-with-apple"
}
}
Binary file removed electron/resources/AuthSession_mac
Binary file not shown.
8 changes: 1 addition & 7 deletions electron/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,7 @@ export default [
format: "cjs",
},
external: ["electron"],
plugins: [
nodeResolve({ preferBuiltins: true }),
commonjs(),
typescript({
tsconfig: "tsconfig.preload.json",
}),
],
plugins: [nodeResolve({ preferBuiltins: true }), commonjs(), typescript()],
},
{
input: "src/index.ts",
Expand Down
13 changes: 0 additions & 13 deletions electron/scripts/build_swift.sh

This file was deleted.

Loading

0 comments on commit 974c856

Please sign in to comment.