@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 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.24",
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
+ }
@@ -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 = cliSettings.production || defaultSettings.webpack.production ? true : false
53
-
54
- if (!mode) {
55
- cleanCacheDir(cacheDir)
56
- }
57
-
58
- webpackConfig.mode = mode ? 'production' : 'development'
59
- const compiler = Webpack(webpackConfig)
60
- let port = webpackConfig.devServer.port || 3000
61
-
62
- // Encontrar un puerto disponible
63
- port = await findAvailablePort(port)
64
-
65
- // Modificamos el puerto en la configuración
66
- webpackConfig.devServer.port = port
67
- const devServerOptions = { ...webpackConfig.devServer, ...cliSettings }
68
- const server = new WebpackDevServer(devServerOptions, compiler)
69
-
70
- const devMode = Boolean(!mode)
71
-
72
- const { version } = await getPackageVersion()
73
-
74
- const startServer = async () => {
75
- try {
76
- await server.start() // Iniciar el servidor con el nuevo puerto
77
-
78
- // Mejor formato de información para el servidor
79
- const url = `http://localhost:${port}`
80
- const cfgStatus = configFileExist()
81
- ? chalk.green('loaded')
82
- : chalk.red('not found')
83
- const envStatus = envPath()
84
- ? chalk.green('loaded')
85
- : chalk.yellow('not found')
86
- const modeLabel = mode
87
- ? chalk.green('production')
88
- : chalk.yellow('development')
89
-
90
- const lines = []
91
- lines.push(chalk.bold(chalk.cyanBright(`<Ryunix/> ${version}`)))
92
- lines.push('')
93
- lines.push(`${chalk.gray('-')} Running at: ${chalk.underline(url)}`)
94
- lines.push(`${chalk.gray('-')} Config file: ${cfgStatus}`)
95
- lines.push(`${chalk.gray('-')} Environment file: ${envStatus}`)
96
- lines.push(`${chalk.gray('-')} Mode: ${modeLabel}`)
97
- if (devMode)
98
- lines.push(
99
- chalk.yellow(
100
- '⚠️ You are in development mode — update ryunix.config.js for production',
101
- ),
102
- )
103
-
104
- lines.push('---------------------------')
105
- logger.info(lines.join('\n'))
106
- } catch (err) {
107
- logger.error(`[error] ${err.message}`)
108
- }
109
- }
110
-
111
- await startServer()
112
- }
113
-
114
- export { StartServer as StartDevServer }
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 }
@@ -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("You need use development mode! change webpack.production to false in ryunix.config.js.")
64
- return
65
- }
66
- const open = Boolean(arg.browser) || false
67
- const settings = {
68
- open,
69
- }
70
-
71
- StartDevServer(settings)
72
- },
73
- }
74
-
75
- const prod = {
76
- command: 'start',
77
- describe: 'Run server for production mode. Requiere .ryunix/static',
78
- handler: async (arg) => {
79
- if (!defaultSettings.webpack.production) {
80
- logger.error("You need use production mode!")
81
- return
82
- }
83
-
84
- if (!fs.existsSync(join(process.cwd(), config.webpack.output.buildDirectory, 'static'))) {
85
- logger.error("You need build first!")
86
- return
87
- }
88
-
89
- server.listen(config.webpack.devServer.port, () => {
90
- console.log(`Server running at http://localhost:${config.webpack.devServer.port}/`);
91
- });
92
- }
93
- }
94
-
95
- const build = {
96
- command: 'build',
97
- describe: 'Run builder',
98
- handler: async (arg) => {
99
- if (!defaultSettings.webpack.production) {
100
- logger.error(
101
- chalk.red(
102
- 'The compilation cannot complete because you are trying to compile in developer mode. remember update ryunix.config.js.',
103
- ),
104
- )
105
- return
106
- }
107
-
108
- if (fs.existsSync(resolveApp(process.cwd(), 'src/pages/routes.ryx'))) {
109
- await cleanBuildDirectory(
110
- resolveApp(
111
- process.cwd(),
112
- `${defaultSettings.webpack.output.buildDirectory}/static`,
113
- ),
114
- )
115
- }
116
-
117
- compiler.run(async (err, stats) => {
118
- if (err || stats.hasErrors()) {
119
- logger.error(chalk.red('Error during compilation:'))
120
- logger.error(err || stats.toString('errors-only'))
121
- return
122
- }
123
-
124
- const buildTimeMs = stats.endTime - stats.startTime
125
-
126
- const minutes = Math.floor(buildTimeMs / 60000)
127
- const seconds = ((buildTimeMs % 60000) / 1000).toFixed(1)
128
-
129
- const formattedTime =
130
- minutes > 0 ? `${minutes}m ${seconds}s` : `${seconds}s`
131
-
132
- if (defaultSettings.webpack.production) {
133
-
134
-
135
- await Prerender(defaultSettings.webpack.output.buildDirectory)
136
- }
137
-
138
- logger.info(chalk.green('Compilation successful! 🎉'))
139
- logger.info(`Done in ${formattedTime}`)
140
-
141
- compiler.close((closeErr) => {
142
- if (closeErr) {
143
- logger.error(chalk.red('Error closing the compiler:'), closeErr)
144
- }
145
- })
146
- })
147
- },
148
- }
149
-
150
- const extractHTML = {
151
- command: 'customHtml',
152
- describe: 'Extract HTML for customization',
153
- handler: async (arg) => {
154
- const runPath = process.cwd()
155
-
156
- fs.copyFile(join(__dirname, "..", "template/index.html"), join(runPath, "public/index.html"), (err) => {
157
- if (err) {
158
- console.error("Error extracting HTML: ", err.message);
159
- return;
160
- }
161
- console.log("File extracted successfully. Now you can enable the template with static.customTemplate inside ryunix.config.js");
162
- });
163
- },
164
- }
165
-
166
-
167
- yargs(hideBin(process.argv)).command(dev).command(build).command(prod).command(lint).command(extractHTML).parse()
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()