Skip to content

Commit

Permalink
Merge branch 'release/v8'
Browse files Browse the repository at this point in the history
  • Loading branch information
saltyshiomix committed Sep 26, 2023
2 parents f5fd6fa + 432d179 commit 6f63d60
Show file tree
Hide file tree
Showing 28 changed files with 457 additions and 463 deletions.
2 changes: 1 addition & 1 deletion examples/basic-javascript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"electron": "^26.2.2",
"electron-builder": "^24.6.4",
"next": "^12.3.4",
"nextron": "^8.9.0",
"nextron": "^8.10.0",
"react": "^18.2.0",
"react-dom": "^18.2.0"
}
Expand Down
2 changes: 1 addition & 1 deletion examples/basic-typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"electron": "^26.2.2",
"electron-builder": "^24.6.4",
"next": "^12.3.4",
"nextron": "^8.9.0",
"nextron": "^8.10.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"typescript": "^4.9.4"
Expand Down
2 changes: 1 addition & 1 deletion examples/custom-build-options/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"electron": "^26.2.2",
"electron-builder": "^24.6.4",
"next": "^12.3.4",
"nextron": "^8.9.0",
"nextron": "^8.10.0",
"react": "^18.2.0",
"react-dom": "^18.2.0"
}
Expand Down
2 changes: 1 addition & 1 deletion examples/custom-main-entry/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"electron": "^26.2.2",
"electron-builder": "^24.6.4",
"next": "^12.3.4",
"nextron": "^8.9.0",
"nextron": "^8.10.0",
"react": "^18.2.0",
"react-dom": "^18.2.0"
}
Expand Down
2 changes: 1 addition & 1 deletion examples/custom-renderer-port/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"electron": "^26.2.2",
"electron-builder": "^24.6.4",
"next": "^12.3.4",
"nextron": "^8.9.0",
"nextron": "^8.10.0",
"react": "^18.2.0",
"react-dom": "^18.2.0"
}
Expand Down
2 changes: 1 addition & 1 deletion examples/ipc-communication/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"electron": "^26.2.2",
"electron-builder": "^24.6.4",
"next": "^12.3.4",
"nextron": "^8.9.0",
"nextron": "^8.10.0",
"react": "^18.2.0",
"react-dom": "^18.2.0"
}
Expand Down
2 changes: 1 addition & 1 deletion examples/store-data/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"electron": "^26.2.2",
"electron-builder": "^24.6.4",
"next": "^12.3.4",
"nextron": "^8.9.0",
"nextron": "^8.10.0",
"react": "^18.2.0",
"react-dom": "^18.2.0"
}
Expand Down
2 changes: 1 addition & 1 deletion examples/with-ant-design/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"electron": "^26.2.2",
"electron-builder": "^24.6.4",
"next": "^12.3.4",
"nextron": "^8.9.0",
"nextron": "^8.10.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"typescript": "^4.9.4"
Expand Down
2 changes: 1 addition & 1 deletion examples/with-chakra-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"electron-builder": "^24.6.4",
"framer-motion": "^6.5.1",
"next": "^12.3.4",
"nextron": "^8.9.0",
"nextron": "^8.10.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"typescript": "^4.9.5"
Expand Down
2 changes: 1 addition & 1 deletion examples/with-emotion/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"electron": "^26.2.2",
"electron-builder": "^24.6.4",
"next": "^12.3.4",
"nextron": "^8.9.0",
"nextron": "^8.10.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"typescript": "^4.9.4"
Expand Down
2 changes: 1 addition & 1 deletion examples/with-emotion/renderer/pages/next.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function Next() {
<a>Go to home page</a>
</Link>
</BasicCard>
<AnimatedCard animation={bounce}>Let's bounce.</AnimatedCard>
<AnimatedCard animation={bounce}>Let&apos;s bounce.</AnimatedCard>
</div>
</React.Fragment>
)
Expand Down
2 changes: 1 addition & 1 deletion examples/with-material-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"electron": "^26.2.2",
"electron-builder": "^24.6.4",
"next": "^12.3.4",
"nextron": "^8.9.0",
"nextron": "^8.10.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"typescript": "^4.9.4"
Expand Down
2 changes: 1 addition & 1 deletion examples/with-tailwindcss/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"electron": "^26.2.2",
"electron-builder": "^24.6.4",
"next": "^12.3.4",
"nextron": "^8.9.0",
"nextron": "^8.10.0",
"postcss": "^8.4.30",
"react": "^18.2.0",
"react-dom": "^18.2.0",
Expand Down
11 changes: 11 additions & 0 deletions lib/helpers/getNextronConfig.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import fs from 'fs'
import path from 'path'

export const getNextronConfig = () => {
const nextronConfigPath = path.join(process.cwd(), 'nextron.config.js')
if (fs.existsSync(nextronConfigPath)) {
return require(nextronConfigPath)
} else {
return {}
}
}
Original file line number Diff line number Diff line change
@@ -1,22 +1,12 @@
import fs from 'fs'
import path from 'path'
import webpack from 'webpack'
import { getBabelConfig } from './getBabelConfig'

const cwd = process.cwd()
// eslint-disable-next-line @typescript-eslint/no-var-requires
const externals = require(path.join(cwd, 'package.json')).dependencies

const getBabelrc = (): string | undefined => {
if (fs.existsSync(path.join(cwd, '.babelrc')))
return path.join(cwd, '.babelrc')
if (fs.existsSync(path.join(cwd, '.babelrc.js')))
return path.join(cwd, '.babelrc.js')
if (fs.existsSync(path.join(cwd, 'babel.config.js')))
return path.join(cwd, 'babel.config.js')
return path.join(__dirname, '../babel.js')
}

export const configure = (
export const configureWebpack = (
env: 'development' | 'production'
): webpack.Configuration => ({
mode: env,
Expand All @@ -42,7 +32,7 @@ export const configure = (
loader: require.resolve('babel-loader'),
options: {
cacheDirectory: true,
extends: getBabelrc(),
extends: getBabelConfig(),
},
},
exclude: [/node_modules/, path.join(cwd, 'renderer')],
Expand Down
14 changes: 14 additions & 0 deletions lib/helpers/getWebpackConfig/getBabelConfig.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import fs from 'fs'
import path from 'path'

const cwd = process.cwd()

export const getBabelConfig = (): string | undefined => {
if (fs.existsSync(path.join(cwd, '.babelrc')))
return path.join(cwd, '.babelrc')
if (fs.existsSync(path.join(cwd, '.babelrc.js')))
return path.join(cwd, '.babelrc.js')
if (fs.existsSync(path.join(cwd, 'babel.config.js')))
return path.join(cwd, 'babel.config.js')
return path.join(__dirname, '../babel.js')
}
Original file line number Diff line number Diff line change
@@ -1,23 +1,15 @@
import fs from 'fs'
import path from 'path'
import { merge } from 'webpack-merge'
import { configure } from './webpack.config'
import { configureWebpack } from './configureWebpack'
import { getNextronConfig } from '../getNextronConfig'

const cwd = process.cwd()
const ext = fs.existsSync(path.join(cwd, 'tsconfig.json')) ? '.ts' : '.js'

export const getNextronConfig = () => {
const nextronConfigPath = path.join(cwd, 'nextron.config.js')
if (fs.existsSync(nextronConfigPath)) {
return require(nextronConfigPath)
} else {
return {}
}
}

export const getWebpackConfig = (env: 'development' | 'production') => {
const { mainSrcDir, webpack } = getNextronConfig()
const userConfig = merge(configure(env), {
const userConfig = merge(configureWebpack(env), {
entry: {
background: path.join(cwd, mainSrcDir || 'main', `background${ext}`),
},
Expand Down
1 change: 1 addition & 0 deletions lib/helpers/getWebpackConfig/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './getWebpackConfig'
3 changes: 3 additions & 0 deletions lib/helpers/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export * from './getWebpackConfig'
export * from './getNextronConfig'
export * from './log'
2 changes: 1 addition & 1 deletion lib/logger.ts → lib/helpers/log.ts
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import chalk from 'chalk'

export default function log(text: string) {
export const log = (text: string) => {
console.log(chalk`{cyan [nextron]} ${text}`)
}
3 changes: 1 addition & 2 deletions lib/nextron-build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ import path from 'path'
import arg from 'arg'
import chalk from 'chalk'
import execa from 'execa'
import { getNextronConfig } from './webpack/helpers'
import log from './logger'
import { getNextronConfig, log } from './helpers'

const args = arg({
'--help': Boolean,
Expand Down
4 changes: 2 additions & 2 deletions lib/nextron-dev.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { ChildProcess } from 'child_process'
import arg from 'arg'
import chalk from 'chalk'
import execa from 'execa'
import webpack from 'webpack'
import { getNextronConfig, getWebpackConfig } from './webpack/helpers'
import { getNextronConfig, getWebpackConfig } from './helpers'
import type { ChildProcess } from 'child_process'

const args = arg({
'--help': Boolean,
Expand Down
47 changes: 0 additions & 47 deletions lib/nextron-init.ts

This file was deleted.

2 changes: 1 addition & 1 deletion lib/nextron.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import execa from 'execa'
import chalk from 'chalk'

const defaultCommand = 'dev'
const commands = new Set(['init', 'build', defaultCommand])
const commands = new Set(['build', defaultCommand])

let cmd = process.argv[2]
let args: string[] = []
Expand Down
8 changes: 6 additions & 2 deletions lib/webpack/build.production.ts → lib/webpack.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ compiler.run((err, stats) => {
if (err) {
console.error(err.stack || err)
}
if (stats && stats.hasErrors()) {
console.error(stats.toString())
if (stats) {
if (stats.hasErrors()) {
console.error(stats.toString())
} else {
console.log(stats.toString())
}
}
})
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nextron",
"version": "8.9.0",
"version": "8.10.0",
"description": "⚡ NEXT.js + Electron ⚡",
"repository": "[email protected]:saltyshiomix/nextron.git",
"author": "Shiono Yoshihide <[email protected]>",
Expand Down Expand Up @@ -39,20 +39,20 @@
"prepare": "husky install"
},
"dependencies": {
"@babel/core": "7.22.20",
"@babel/core": "7.23.0",
"@babel/plugin-transform-class-properties": "7.22.5",
"@babel/plugin-transform-object-rest-spread": "7.22.15",
"@babel/plugin-transform-optional-chaining": "7.22.15",
"@babel/plugin-transform-optional-chaining": "7.23.0",
"@babel/plugin-transform-runtime": "7.22.15",
"@babel/preset-env": "7.22.20",
"@babel/preset-typescript": "7.22.15",
"@babel/runtime": "7.22.15",
"@babel/runtime-corejs3": "7.22.15",
"@babel/preset-typescript": "7.23.0",
"@babel/runtime": "7.23.1",
"@babel/runtime-corejs3": "7.23.1",
"arg": "5.0.2",
"babel-loader": "9.1.3",
"chalk": "4.1.2",
"execa": "5.1.1",
"fs-extra": "11.1.0",
"fs-extra": "11.1.1",
"webpack": "5.88.2",
"webpack-merge": "5.9.0"
},
Expand Down
Loading

0 comments on commit 6f63d60

Please sign in to comment.