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 b5646bb + ce416d2 commit ebb89d4
Show file tree
Hide file tree
Showing 29 changed files with 81 additions and 39 deletions.
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@

### Next.js vs Nextron

| next | nextron |
| ----------------- | ----------------- |
| `v14.x` | `v9.x` (upcoming) |
| `v12.x` / `v13.x` | `v8.x` |
| `v11.x` | `v7.x` |
| `v10.x` | `v6.x` |
| `v9.x` | `v5.x` |
| `v8.x` | `v4.x` |
| `v7.x` | `v2.x` / `v3.x` |
| `v6.x` | `v1.x` |
| next | nextron |
| ----------------- | --------------- |
| `v14.x` | `v8.x` |
| `v12.x` / `v13.x` | `v8.x` |
| `v11.x` | `v7.x` |
| `v10.x` | `v6.x` |
| `v9.x` | `v5.x` |
| `v8.x` | `v4.x` |
| `v7.x` | `v2.x` / `v3.x` |
| `v6.x` | `v1.x` |

### Package Manager

Expand Down
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.17.0",
"nextron": "^8.23.0",
"react": "^18.2.0",
"react-dom": "^18.2.0"
}
Expand Down
2 changes: 2 additions & 0 deletions examples/basic-lang-javascript-python/renderer/next.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
/** @type {import('next').NextConfig} */
module.exports = {
output: 'export',
distDir: '../app',
trailingSlash: true,
images: {
unoptimized: true,
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.17.0",
"nextron": "^8.23.0",
"react": "^18.2.0",
"react-dom": "^18.2.0"
}
Expand Down
2 changes: 2 additions & 0 deletions examples/basic-lang-javascript/renderer/next.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
/** @type {import('next').NextConfig} */
module.exports = {
output: 'export',
distDir: '../app',
trailingSlash: true,
images: {
unoptimized: true,
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.17.0",
"nextron": "^8.23.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"typescript": "^5.4.5"
Expand Down
2 changes: 2 additions & 0 deletions examples/basic-lang-typescript/renderer/next.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
/** @type {import('next').NextConfig} */
module.exports = {
output: 'export',
distDir: '../app',
trailingSlash: true,
images: {
unoptimized: true,
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.17.0",
"nextron": "^8.23.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"typescript": "^5.4.5"
Expand Down
2 changes: 2 additions & 0 deletions examples/basic-launch-app-from-url/renderer/next.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
/** @type {import('next').NextConfig} */
module.exports = {
output: 'export',
distDir: '../app',
trailingSlash: true,
images: {
unoptimized: true,
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.17.0",
"nextron": "^8.23.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"typescript": "^5.4.5"
Expand Down
2 changes: 2 additions & 0 deletions examples/basic-store-data/renderer/next.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
/** @type {import('next').NextConfig} */
module.exports = {
output: 'export',
distDir: '../app',
trailingSlash: true,
images: {
unoptimized: true,
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.17.0",
"nextron": "^8.23.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"typescript": "^5.4.5"
Expand Down
2 changes: 2 additions & 0 deletions examples/custom-build-options/renderer/next.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
/** @type {import('next').NextConfig} */
module.exports = {
output: 'export',
distDir: '../app',
trailingSlash: true,
images: {
unoptimized: true,
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.17.0",
"nextron": "^8.23.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"typescript": "^5.4.5"
Expand Down
2 changes: 2 additions & 0 deletions examples/custom-renderer-port/renderer/next.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
/** @type {import('next').NextConfig} */
module.exports = {
output: 'export',
distDir: '../app',
trailingSlash: true,
images: {
unoptimized: true,
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.17.0",
"nextron": "^8.23.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"typescript": "^5.4.5"
Expand Down
2 changes: 2 additions & 0 deletions examples/with-ant-design/renderer/next.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
/** @type {import('next').NextConfig} */
module.exports = {
output: 'export',
distDir: '../app',
trailingSlash: true,
images: {
unoptimized: true,
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.17.0",
"nextron": "^8.23.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"typescript": "^5.4.5"
Expand Down
2 changes: 2 additions & 0 deletions examples/with-chakra-ui/renderer/next.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
/** @type {import('next').NextConfig} */
module.exports = {
output: 'export',
distDir: '../app',
trailingSlash: true,
images: {
unoptimized: true,
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.17.0",
"nextron": "^8.23.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"typescript": "^5.4.5"
Expand Down
2 changes: 2 additions & 0 deletions examples/with-emotion/renderer/next.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
/** @type {import('next').NextConfig} */
module.exports = {
output: 'export',
distDir: '../app',
trailingSlash: true,
images: {
unoptimized: true,
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.17.0",
"nextron": "^8.23.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"typescript": "^5.4.5"
Expand Down
2 changes: 2 additions & 0 deletions examples/with-material-ui/renderer/next.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
/** @type {import('next').NextConfig} */
module.exports = {
output: 'export',
distDir: '../app',
trailingSlash: true,
images: {
unoptimized: true,
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.17.0",
"nextron": "^8.23.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-i18next": "^14.1.0"
Expand Down
2 changes: 2 additions & 0 deletions examples/with-next-i18next/renderer/next.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
/** @type {import('next').NextConfig} */
module.exports = {
output: 'export',
distDir: '../app',
trailingSlash: true,
images: {
unoptimized: true,
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.17.0",
"nextron": "^8.23.0",
"postcss": "^8.4.38",
"react": "^18.2.0",
"react-dom": "^18.2.0",
Expand Down
2 changes: 2 additions & 0 deletions examples/with-tailwindcss/renderer/next.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
/** @type {import('next').NextConfig} */
module.exports = {
output: 'export',
distDir: '../app',
trailingSlash: true,
images: {
unoptimized: true,
Expand Down
46 changes: 31 additions & 15 deletions lib/configs/useExportCommand.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint-disable @typescript-eslint/no-var-requires */

import fs from 'fs-extra'
import path from 'path'
import { getNextronConfig } from './getNextronConfig'
Expand All @@ -6,31 +8,30 @@ import * as logger from '../logger'
const cwd = process.cwd()
const pkgPath = path.join(cwd, 'package.json')
const nextConfigPath = path.join(
cwd,
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) {
let nextVersion: string
nextVersion = dependencies.next
if (nextVersion) {
logger.info(
'To reduce the bundle size of the electron app, we recommend placing nextron in devDependencies instead of dependencies.'
'To reduce the bundle size of the electron app, we recommend placing next and nextron in devDependencies instead of dependencies.'
)
}
if (!nextronVersion) {
nextronVersion = devDependencies.nextron
if (!nextronVersion) {
logger.error(
'Nextron not found in both dependencies and devDependencies.'
)
if (!nextVersion) {
nextVersion = devDependencies.next
if (!nextVersion) {
logger.error('Next not found in both dependencies and devDependencies.')
process.exit(1)
}
}

const majorVersion = ~~nextronVersion
const majorVersion = ~~nextVersion
.split('.')
.filter((v) => v.trim() !== '')[0]
.replace('^', '')
Expand All @@ -39,17 +40,32 @@ export const useExportCommand = async (): Promise<boolean> => {
return true
}
if (majorVersion === 13) {
const { output } = await fs.readJSON(nextConfigPath)
return output !== 'export'
const { output, distDir } = require(nextConfigPath)
if (output === 'export') {
if (distDir !== '../app') {
logger.error(
'Nextron export the build results to "app" directory, so please set "distDir" to "../app" in next.config.js.'
)
process.exit(1)
}
return false
}
return true
}
if (majorVersion > 13 || majorVersion === 0) {
const { output } = await fs.readJSON(nextConfigPath)
if (majorVersion > 13) {
const { output, distDir } = require(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)
}
if (distDir !== '../app') {
logger.error(
'Nextron exports the build results to "app" directory, so please set "distDir" to "../app" in next.config.js.'
)
process.exit(1)
}
return false
}

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.17.0",
"version": "8.23.0",
"description": "⚡ NEXT.js + Electron ⚡",
"repository": "[email protected]:saltyshiomix/nextron.git",
"author": {
Expand Down

0 comments on commit ebb89d4

Please sign in to comment.