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 Jun 16, 2024
2 parents 651967d + ad48002 commit ca08ec9
Show file tree
Hide file tree
Showing 18 changed files with 3,693 additions and 2,888 deletions.
2 changes: 1 addition & 1 deletion .node-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20.11.0
20.14.0
2 changes: 1 addition & 1 deletion examples/basic-lang-javascript-python/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"electron": "^29.3.0",
"electron-builder": "^24.13.3",
"next": "^13.5.6",
"nextron": "^8.15.0",
"nextron": "^8.16.0",
"react": "^18.2.0",
"react-dom": "^18.2.0"
}
Expand Down
2 changes: 1 addition & 1 deletion examples/basic-lang-javascript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"electron": "^29.3.0",
"electron-builder": "^24.13.3",
"next": "^13.5.6",
"nextron": "^8.15.0",
"nextron": "^8.16.0",
"react": "^18.2.0",
"react-dom": "^18.2.0"
}
Expand Down
2 changes: 1 addition & 1 deletion examples/basic-lang-typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"electron": "^29.3.0",
"electron-builder": "^24.13.3",
"next": "^13.5.6",
"nextron": "^8.15.0",
"nextron": "^8.16.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"typescript": "^5.4.5"
Expand Down
2 changes: 1 addition & 1 deletion examples/basic-launch-app-from-url/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"electron": "^29.3.0",
"electron-builder": "^24.13.3",
"next": "^13.5.6",
"nextron": "^8.15.0",
"nextron": "^8.16.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"typescript": "^5.4.5"
Expand Down
2 changes: 1 addition & 1 deletion examples/basic-store-data/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"electron": "^29.3.0",
"electron-builder": "^24.13.3",
"next": "^13.5.6",
"nextron": "^8.15.0",
"nextron": "^8.16.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"typescript": "^5.4.5"
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 @@ -25,7 +25,7 @@
"electron": "^29.3.0",
"electron-builder": "^24.13.3",
"next": "^13.5.6",
"nextron": "^8.15.0",
"nextron": "^8.16.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"typescript": "^5.4.5"
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 @@ -20,7 +20,7 @@
"electron": "^29.3.0",
"electron-builder": "^24.13.3",
"next": "^13.5.6",
"nextron": "^8.15.0",
"nextron": "^8.16.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"typescript": "^5.4.5"
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": "^29.3.0",
"electron-builder": "^24.13.3",
"next": "^13.5.6",
"nextron": "^8.15.0",
"nextron": "^8.16.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"typescript": "^5.4.5"
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 @@ -26,7 +26,7 @@
"electron-builder": "^24.13.3",
"framer-motion": "^11.0.28",
"next": "^13.5.6",
"nextron": "^8.15.0",
"nextron": "^8.16.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"typescript": "^5.4.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": "^29.3.0",
"electron-builder": "^24.13.3",
"next": "^13.5.6",
"nextron": "^8.15.0",
"nextron": "^8.16.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"typescript": "^5.4.5"
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 @@ -27,7 +27,7 @@
"electron": "^29.3.0",
"electron-builder": "^24.13.3",
"next": "^13.5.6",
"nextron": "^8.15.0",
"nextron": "^8.16.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"typescript": "^5.4.5"
Expand Down
2 changes: 1 addition & 1 deletion examples/with-next-i18next/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"i18next": "^23.11.1",
"next": "^13.5.6",
"next-i18next": "^15.2.0",
"nextron": "^8.15.0",
"nextron": "^8.16.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-i18next": "^14.1.0"
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": "^29.3.0",
"electron-builder": "^24.13.3",
"next": "^13.5.6",
"nextron": "^8.15.0",
"nextron": "^8.16.0",
"postcss": "^8.4.38",
"react": "^18.2.0",
"react-dom": "^18.2.0",
Expand Down
56 changes: 56 additions & 0 deletions lib/configs/useExportCommand.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import fs from 'fs-extra'
import path from 'path'
import { getNextronConfig } from './getNextronConfig'
import * as logger from '../logger'

const cwd = process.cwd()
const pkgPath = path.join(cwd, 'package.json')
const nextConfigPath = path.join(
getNextronConfig().rendererSrcDir || 'renderer',
'next.config.js'
)

export const useExportCommand = async (): Promise<boolean> => {
const { dependencies, devDependencies } = await fs.readJSON(pkgPath)

let nextronVersion: string
nextronVersion = dependencies.nextron
if (nextronVersion) {
logger.info(
'To reduce the bundle size of the electron app, we recommend placing nextron in devDependencies instead of dependencies.'
)
}
if (!nextronVersion) {
nextronVersion = devDependencies.nextron
if (!nextronVersion) {
logger.error(
'Nextron not found in both dependencies and devDependencies.'
)
process.exit(1)
}
}

const majorVersion = ~~nextronVersion
.split('.')
.filter((v) => v.trim() !== '')[0]
if (majorVersion < 13) {
return true
}
if (majorVersion === 13) {
const { output } = await fs.readJSON(nextConfigPath)
return output !== 'export'
}
if (majorVersion > 13) {
const { output } = await fs.readJSON(nextConfigPath)
if (output !== 'export') {
logger.error(
'We must export static files so as Electron can handle them. Please set next.config.js#output to "export".'
)
process.exit(1)
}
return false
}

logger.error('Unexpected error occerred')
process.exit(1)
}
13 changes: 8 additions & 5 deletions lib/nextron-build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import chalk from 'chalk'
import execa from 'execa'
import * as logger from './logger'
import { getNextronConfig } from './configs/getNextronConfig'
import { useExportCommand } from './configs/useExportCommand'

const args = arg({
'--mac': Boolean,
Expand Down Expand Up @@ -39,11 +40,13 @@ const execaOptions: execa.Options = {

logger.info('Building renderer process')
await execa('next', ['build', path.join(cwd, rendererSrcDir)], execaOptions)
await execa(
'next',
['export', '-o', appDir, path.join(cwd, rendererSrcDir)],
execaOptions
)
if (await useExportCommand()) {
await execa(
'next',
['export', '-o', appDir, path.join(cwd, rendererSrcDir)],
execaOptions
)
}

logger.info('Building main process')
await execa(
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nextron",
"version": "8.15.0",
"version": "8.16.0",
"description": "⚡ NEXT.js + Electron ⚡",
"repository": "[email protected]:saltyshiomix/nextron.git",
"author": {
Expand Down
Loading

0 comments on commit ca08ec9

Please sign in to comment.