@unsetsoft/ryunix-presets 1.0.24 → 1.0.26-canary.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/webpack/bin/compiler.mjs +6 -6
- package/webpack/bin/dev.server.mjs +115 -114
- package/webpack/bin/index.mjs +184 -167
- package/webpack/bin/prerender.mjs +54 -54
- package/webpack/bin/prod.server.mjs +25 -11
- package/webpack/config.d.ts +85 -85
- package/webpack/eslint.config.mjs +43 -43
- package/webpack/index.js +6 -6
- package/webpack/template/index.html +19 -19
- package/webpack/utils/ApiRouterPlugin.mjs +140 -0
- package/webpack/utils/apiHandler.mjs +150 -0
- package/webpack/utils/appRouterPlugin.mjs +486 -0
- package/webpack/utils/config.cjs +173 -175
- package/webpack/utils/envExist.cjs +14 -14
- package/webpack/utils/index.mjs +205 -205
- package/webpack/utils/settingfile.cjs +33 -33
- package/webpack/utils/ssg.mjs +371 -381
- package/webpack/utils/ssgPlugin.mjs +602 -631
- package/webpack/webpack.config.mjs +376 -335
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unsetsoft/ryunix-presets",
|
|
3
3
|
"description": "Package with presets for different development environments.",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.26-canary.1",
|
|
5
5
|
"author": "Neyunse",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"repository": "https://github.com/UnSetSoft/Ryunixjs",
|
|
@@ -80,4 +80,4 @@
|
|
|
80
80
|
"@remark-embedder/core": "3.0.3",
|
|
81
81
|
"@remark-embedder/transformer-oembed": "5.0.1"
|
|
82
82
|
}
|
|
83
|
-
}
|
|
83
|
+
}
|
package/webpack/bin/compiler.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import webpack from 'webpack'
|
|
2
|
-
import webpackConfig from '../webpack.config.mjs'
|
|
3
|
-
webpackConfig.mode = 'production'
|
|
4
|
-
const compiler = webpack(webpackConfig)
|
|
5
|
-
|
|
6
|
-
export { compiler }
|
|
1
|
+
import webpack from 'webpack'
|
|
2
|
+
import webpackConfig from '../webpack.config.mjs'
|
|
3
|
+
webpackConfig.mode = 'production'
|
|
4
|
+
const compiler = webpack(webpackConfig)
|
|
5
|
+
|
|
6
|
+
export { compiler }
|
|
@@ -1,114 +1,115 @@
|
|
|
1
|
-
import Webpack from 'webpack'
|
|
2
|
-
import WebpackDevServer from 'webpack-dev-server'
|
|
3
|
-
import webpackConfig from '../webpack.config.mjs'
|
|
4
|
-
import { configFileExist } from '../utils/settingfile.cjs'
|
|
5
|
-
import envPath from '../utils/envExist.cjs'
|
|
6
|
-
import {
|
|
7
|
-
getPackageVersion,
|
|
8
|
-
resolveApp,
|
|
9
|
-
cleanCacheDir,
|
|
10
|
-
} from '../utils/index.mjs'
|
|
11
|
-
import logger from 'terminal-log'
|
|
12
|
-
import chalk from 'chalk'
|
|
13
|
-
import net from 'net' // Para verificar si el puerto está disponible
|
|
14
|
-
import defaultSettings from '../utils/config.cjs'
|
|
15
|
-
|
|
16
|
-
const checkPortInUse = (port) => {
|
|
17
|
-
return new Promise((resolve, reject) => {
|
|
18
|
-
const server = net.createServer()
|
|
19
|
-
server.once('error', (err) => {
|
|
20
|
-
if (err.code === 'EADDRINUSE') {
|
|
21
|
-
resolve(true) // Puerto en uso
|
|
22
|
-
} else {
|
|
23
|
-
reject(err)
|
|
24
|
-
}
|
|
25
|
-
})
|
|
26
|
-
server.once('listening', () => {
|
|
27
|
-
server.close()
|
|
28
|
-
resolve(false) // Puerto libre
|
|
29
|
-
})
|
|
30
|
-
server.listen(port)
|
|
31
|
-
})
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const findAvailablePort = async (port) => {
|
|
35
|
-
let isPortInUse = await checkPortInUse(port)
|
|
36
|
-
while (isPortInUse) {
|
|
37
|
-
logger.warn(
|
|
38
|
-
chalk.yellow(`Port ${port} is in use, trying port ${port + 1}...`),
|
|
39
|
-
)
|
|
40
|
-
port += 1
|
|
41
|
-
isPortInUse = await checkPortInUse(port)
|
|
42
|
-
}
|
|
43
|
-
return port
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
const StartServer = async (cliSettings) => {
|
|
47
|
-
const cacheDir = resolveApp(
|
|
48
|
-
process.cwd(),
|
|
49
|
-
`${defaultSettings.webpack.output.buildDirectory}/cache`,
|
|
50
|
-
)
|
|
51
|
-
|
|
52
|
-
const mode =
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
const
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
lines
|
|
92
|
-
lines.push(
|
|
93
|
-
lines.push(
|
|
94
|
-
lines.push(`${chalk.gray('-')}
|
|
95
|
-
lines.push(`${chalk.gray('-')}
|
|
96
|
-
lines.push(`${chalk.gray('-')}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
1
|
+
import Webpack from 'webpack'
|
|
2
|
+
import WebpackDevServer from 'webpack-dev-server'
|
|
3
|
+
import webpackConfig from '../webpack.config.mjs'
|
|
4
|
+
import { configFileExist } from '../utils/settingfile.cjs'
|
|
5
|
+
import envPath from '../utils/envExist.cjs'
|
|
6
|
+
import {
|
|
7
|
+
getPackageVersion,
|
|
8
|
+
resolveApp,
|
|
9
|
+
cleanCacheDir,
|
|
10
|
+
} from '../utils/index.mjs'
|
|
11
|
+
import logger from 'terminal-log'
|
|
12
|
+
import chalk from 'chalk'
|
|
13
|
+
import net from 'net' // Para verificar si el puerto está disponible
|
|
14
|
+
import defaultSettings from '../utils/config.cjs'
|
|
15
|
+
|
|
16
|
+
const checkPortInUse = (port) => {
|
|
17
|
+
return new Promise((resolve, reject) => {
|
|
18
|
+
const server = net.createServer()
|
|
19
|
+
server.once('error', (err) => {
|
|
20
|
+
if (err.code === 'EADDRINUSE') {
|
|
21
|
+
resolve(true) // Puerto en uso
|
|
22
|
+
} else {
|
|
23
|
+
reject(err)
|
|
24
|
+
}
|
|
25
|
+
})
|
|
26
|
+
server.once('listening', () => {
|
|
27
|
+
server.close()
|
|
28
|
+
resolve(false) // Puerto libre
|
|
29
|
+
})
|
|
30
|
+
server.listen(port)
|
|
31
|
+
})
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const findAvailablePort = async (port) => {
|
|
35
|
+
let isPortInUse = await checkPortInUse(port)
|
|
36
|
+
while (isPortInUse) {
|
|
37
|
+
logger.warn(
|
|
38
|
+
chalk.yellow(`Port ${port} is in use, trying port ${port + 1}...`),
|
|
39
|
+
)
|
|
40
|
+
port += 1
|
|
41
|
+
isPortInUse = await checkPortInUse(port)
|
|
42
|
+
}
|
|
43
|
+
return port
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const StartServer = async (cliSettings) => {
|
|
47
|
+
const cacheDir = resolveApp(
|
|
48
|
+
process.cwd(),
|
|
49
|
+
`${defaultSettings.webpack.output.buildDirectory}/cache`,
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
const mode =
|
|
53
|
+
cliSettings.production || defaultSettings.webpack.production ? true : false
|
|
54
|
+
|
|
55
|
+
if (!mode) {
|
|
56
|
+
cleanCacheDir(cacheDir)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
webpackConfig.mode = mode ? 'production' : 'development'
|
|
60
|
+
const compiler = Webpack(webpackConfig)
|
|
61
|
+
let port = webpackConfig.devServer.port || 3000
|
|
62
|
+
|
|
63
|
+
// Encontrar un puerto disponible
|
|
64
|
+
port = await findAvailablePort(port)
|
|
65
|
+
|
|
66
|
+
// Modificamos el puerto en la configuración
|
|
67
|
+
webpackConfig.devServer.port = port
|
|
68
|
+
const devServerOptions = { ...webpackConfig.devServer, ...cliSettings }
|
|
69
|
+
const server = new WebpackDevServer(devServerOptions, compiler)
|
|
70
|
+
|
|
71
|
+
const devMode = Boolean(!mode)
|
|
72
|
+
|
|
73
|
+
const { version } = await getPackageVersion()
|
|
74
|
+
|
|
75
|
+
const startServer = async () => {
|
|
76
|
+
try {
|
|
77
|
+
await server.start() // Iniciar el servidor con el nuevo puerto
|
|
78
|
+
|
|
79
|
+
// Mejor formato de información para el servidor
|
|
80
|
+
const url = `http://localhost:${port}`
|
|
81
|
+
const cfgStatus = configFileExist()
|
|
82
|
+
? chalk.green('loaded')
|
|
83
|
+
: chalk.red('not found')
|
|
84
|
+
const envStatus = envPath()
|
|
85
|
+
? chalk.green('loaded')
|
|
86
|
+
: chalk.yellow('not found')
|
|
87
|
+
const modeLabel = mode
|
|
88
|
+
? chalk.green('production')
|
|
89
|
+
: chalk.yellow('development')
|
|
90
|
+
|
|
91
|
+
const lines = []
|
|
92
|
+
lines.push(chalk.bold(chalk.cyanBright(`<Ryunix/> ${version}`)))
|
|
93
|
+
lines.push('')
|
|
94
|
+
lines.push(`${chalk.gray('-')} Running at: ${chalk.underline(url)}`)
|
|
95
|
+
lines.push(`${chalk.gray('-')} Config file: ${cfgStatus}`)
|
|
96
|
+
lines.push(`${chalk.gray('-')} Environment file: ${envStatus}`)
|
|
97
|
+
lines.push(`${chalk.gray('-')} Mode: ${modeLabel}`)
|
|
98
|
+
if (devMode)
|
|
99
|
+
lines.push(
|
|
100
|
+
chalk.yellow(
|
|
101
|
+
'⚠️ You are in development mode — update ryunix.config.js for production',
|
|
102
|
+
),
|
|
103
|
+
)
|
|
104
|
+
|
|
105
|
+
lines.push('---------------------------')
|
|
106
|
+
logger.info(lines.join('\n'))
|
|
107
|
+
} catch (err) {
|
|
108
|
+
logger.error(`[error] ${err.message}`)
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
await startServer()
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export { StartServer as StartDevServer }
|
package/webpack/bin/index.mjs
CHANGED
|
@@ -1,167 +1,184 @@
|
|
|
1
|
-
#! /usr/bin/env node
|
|
2
|
-
import yargs from 'yargs'
|
|
3
|
-
import { hideBin } from 'yargs/helpers'
|
|
4
|
-
import { StartDevServer } from './dev.server.mjs'
|
|
5
|
-
import { compiler } from './compiler.mjs'
|
|
6
|
-
import logger from 'terminal-log'
|
|
7
|
-
import chalk from 'chalk'
|
|
8
|
-
import defaultSettings from '../utils/config.cjs'
|
|
9
|
-
import Prerender from './prerender.mjs'
|
|
10
|
-
import {
|
|
11
|
-
cleanBuildDirectory,
|
|
12
|
-
convertFlatToClassic,
|
|
13
|
-
resolveApp,
|
|
14
|
-
} from '../utils/index.mjs'
|
|
15
|
-
import { ESLint } from 'eslint'
|
|
16
|
-
import eslintConfig from '../eslint.config.mjs'
|
|
17
|
-
import fs from 'fs'
|
|
18
|
-
import { fileURLToPath } from 'url'
|
|
19
|
-
import { dirname, join } from 'path'
|
|
20
|
-
import server from './prod.server.mjs'
|
|
21
|
-
import config from '../utils/config.cjs'
|
|
22
|
-
const __filename = fileURLToPath(import.meta.url)
|
|
23
|
-
|
|
24
|
-
const __dirname = dirname(__filename)
|
|
25
|
-
|
|
26
|
-
const lint = {
|
|
27
|
-
command: 'lint',
|
|
28
|
-
describe: 'Lint code',
|
|
29
|
-
builder: {
|
|
30
|
-
fix: {
|
|
31
|
-
alias: 'f',
|
|
32
|
-
type: 'boolean',
|
|
33
|
-
default: false,
|
|
34
|
-
describe: 'Automatically fix problems',
|
|
35
|
-
},
|
|
36
|
-
},
|
|
37
|
-
handler: async (arg) => {
|
|
38
|
-
const classicConfig = eslintConfig[0]
|
|
39
|
-
|
|
40
|
-
const fix = arg.fix
|
|
41
|
-
const eslint = new ESLint({
|
|
42
|
-
cwd: process.cwd(),
|
|
43
|
-
overrideConfigFile: true,
|
|
44
|
-
overrideConfig: classicConfig,
|
|
45
|
-
fix,
|
|
46
|
-
})
|
|
47
|
-
|
|
48
|
-
const results = await eslint.lintFiles(defaultSettings.eslint.files)
|
|
49
|
-
|
|
50
|
-
await ESLint.outputFixes(results)
|
|
51
|
-
|
|
52
|
-
const formatter = await eslint.loadFormatter('stylish')
|
|
53
|
-
const report = formatter.format(results)
|
|
54
|
-
console.log(report)
|
|
55
|
-
},
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
const dev = {
|
|
59
|
-
command: 'dev',
|
|
60
|
-
describe: 'Run server for developer mode.',
|
|
61
|
-
handler: async (arg) => {
|
|
62
|
-
if (defaultSettings.webpack.production) {
|
|
63
|
-
logger.error(
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
})
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
1
|
+
#! /usr/bin/env node
|
|
2
|
+
import yargs from 'yargs'
|
|
3
|
+
import { hideBin } from 'yargs/helpers'
|
|
4
|
+
import { StartDevServer } from './dev.server.mjs'
|
|
5
|
+
import { compiler } from './compiler.mjs'
|
|
6
|
+
import logger from 'terminal-log'
|
|
7
|
+
import chalk from 'chalk'
|
|
8
|
+
import defaultSettings from '../utils/config.cjs'
|
|
9
|
+
import Prerender from './prerender.mjs'
|
|
10
|
+
import {
|
|
11
|
+
cleanBuildDirectory,
|
|
12
|
+
convertFlatToClassic,
|
|
13
|
+
resolveApp,
|
|
14
|
+
} from '../utils/index.mjs'
|
|
15
|
+
import { ESLint } from 'eslint'
|
|
16
|
+
import eslintConfig from '../eslint.config.mjs'
|
|
17
|
+
import fs from 'fs'
|
|
18
|
+
import { fileURLToPath } from 'url'
|
|
19
|
+
import { dirname, join } from 'path'
|
|
20
|
+
import server from './prod.server.mjs'
|
|
21
|
+
import config from '../utils/config.cjs'
|
|
22
|
+
const __filename = fileURLToPath(import.meta.url)
|
|
23
|
+
|
|
24
|
+
const __dirname = dirname(__filename)
|
|
25
|
+
|
|
26
|
+
const lint = {
|
|
27
|
+
command: 'lint',
|
|
28
|
+
describe: 'Lint code',
|
|
29
|
+
builder: {
|
|
30
|
+
fix: {
|
|
31
|
+
alias: 'f',
|
|
32
|
+
type: 'boolean',
|
|
33
|
+
default: false,
|
|
34
|
+
describe: 'Automatically fix problems',
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
handler: async (arg) => {
|
|
38
|
+
const classicConfig = eslintConfig[0]
|
|
39
|
+
|
|
40
|
+
const fix = arg.fix
|
|
41
|
+
const eslint = new ESLint({
|
|
42
|
+
cwd: process.cwd(),
|
|
43
|
+
overrideConfigFile: true,
|
|
44
|
+
overrideConfig: classicConfig,
|
|
45
|
+
fix,
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
const results = await eslint.lintFiles(defaultSettings.eslint.files)
|
|
49
|
+
|
|
50
|
+
await ESLint.outputFixes(results)
|
|
51
|
+
|
|
52
|
+
const formatter = await eslint.loadFormatter('stylish')
|
|
53
|
+
const report = formatter.format(results)
|
|
54
|
+
console.log(report)
|
|
55
|
+
},
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const dev = {
|
|
59
|
+
command: 'dev',
|
|
60
|
+
describe: 'Run server for developer mode.',
|
|
61
|
+
handler: async (arg) => {
|
|
62
|
+
if (defaultSettings.webpack.production) {
|
|
63
|
+
logger.error(
|
|
64
|
+
'You need use development mode! change webpack.production to false in ryunix.config.js.',
|
|
65
|
+
)
|
|
66
|
+
return
|
|
67
|
+
}
|
|
68
|
+
const open = Boolean(arg.browser) || false
|
|
69
|
+
const settings = {
|
|
70
|
+
open,
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
StartDevServer(settings)
|
|
74
|
+
},
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const prod = {
|
|
78
|
+
command: 'start',
|
|
79
|
+
describe: 'Run server for production mode. Requiere .ryunix/static',
|
|
80
|
+
handler: async (arg) => {
|
|
81
|
+
if (!defaultSettings.webpack.production) {
|
|
82
|
+
logger.error('You need use production mode!')
|
|
83
|
+
return
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if (
|
|
87
|
+
!fs.existsSync(
|
|
88
|
+
join(process.cwd(), config.webpack.output.buildDirectory, 'static'),
|
|
89
|
+
)
|
|
90
|
+
) {
|
|
91
|
+
logger.error('You need build first!')
|
|
92
|
+
return
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
server.listen(config.webpack.devServer.port, () => {
|
|
96
|
+
console.log(
|
|
97
|
+
`Server running at http://localhost:${config.webpack.devServer.port}/`,
|
|
98
|
+
)
|
|
99
|
+
})
|
|
100
|
+
},
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const build = {
|
|
104
|
+
command: 'build',
|
|
105
|
+
describe: 'Run builder',
|
|
106
|
+
handler: async (arg) => {
|
|
107
|
+
if (!defaultSettings.webpack.production) {
|
|
108
|
+
logger.error(
|
|
109
|
+
chalk.red(
|
|
110
|
+
'The compilation cannot complete because you are trying to compile in developer mode. remember update ryunix.config.js.',
|
|
111
|
+
),
|
|
112
|
+
)
|
|
113
|
+
return
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
if (fs.existsSync(resolveApp(process.cwd(), 'src/pages/routes.ryx'))) {
|
|
117
|
+
await cleanBuildDirectory(
|
|
118
|
+
resolveApp(
|
|
119
|
+
process.cwd(),
|
|
120
|
+
`${defaultSettings.webpack.output.buildDirectory}/static`,
|
|
121
|
+
),
|
|
122
|
+
)
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
compiler.run(async (err, stats) => {
|
|
126
|
+
if (err || stats.hasErrors()) {
|
|
127
|
+
logger.error(chalk.red('Error during compilation:'))
|
|
128
|
+
logger.error(err || stats.toString('errors-only'))
|
|
129
|
+
return
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
const buildTimeMs = stats.endTime - stats.startTime
|
|
133
|
+
|
|
134
|
+
const minutes = Math.floor(buildTimeMs / 60000)
|
|
135
|
+
const seconds = ((buildTimeMs % 60000) / 1000).toFixed(1)
|
|
136
|
+
|
|
137
|
+
const formattedTime =
|
|
138
|
+
minutes > 0 ? `${minutes}m ${seconds}s` : `${seconds}s`
|
|
139
|
+
|
|
140
|
+
if (defaultSettings.webpack.production) {
|
|
141
|
+
await Prerender(defaultSettings.webpack.output.buildDirectory)
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
logger.info(chalk.green('Compilation successful! 🎉'))
|
|
145
|
+
logger.info(`Done in ${formattedTime}`)
|
|
146
|
+
|
|
147
|
+
compiler.close((closeErr) => {
|
|
148
|
+
if (closeErr) {
|
|
149
|
+
logger.error(chalk.red('Error closing the compiler:'), closeErr)
|
|
150
|
+
}
|
|
151
|
+
})
|
|
152
|
+
})
|
|
153
|
+
},
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
const extractHTML = {
|
|
157
|
+
command: 'customHtml',
|
|
158
|
+
describe: 'Extract HTML for customization',
|
|
159
|
+
handler: async (arg) => {
|
|
160
|
+
const runPath = process.cwd()
|
|
161
|
+
|
|
162
|
+
fs.copyFile(
|
|
163
|
+
join(__dirname, '..', 'template/index.html'),
|
|
164
|
+
join(runPath, 'public/index.html'),
|
|
165
|
+
(err) => {
|
|
166
|
+
if (err) {
|
|
167
|
+
console.error('Error extracting HTML: ', err.message)
|
|
168
|
+
return
|
|
169
|
+
}
|
|
170
|
+
console.log(
|
|
171
|
+
'File extracted successfully. Now you can enable the template with static.customTemplate inside ryunix.config.js',
|
|
172
|
+
)
|
|
173
|
+
},
|
|
174
|
+
)
|
|
175
|
+
},
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
yargs(hideBin(process.argv))
|
|
179
|
+
.command(dev)
|
|
180
|
+
.command(build)
|
|
181
|
+
.command(prod)
|
|
182
|
+
.command(lint)
|
|
183
|
+
.command(extractHTML)
|
|
184
|
+
.parse()
|