@unsetsoft/ryunix-presets 1.0.17 → 1.0.19

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.17",
4
+ "version": "1.0.19",
5
5
  "author": "Neyunse",
6
6
  "type": "module",
7
7
  "repository": "https://github.com/UnSetSoft/Ryunixjs",
@@ -48,6 +48,8 @@
48
48
  "copy-webpack-plugin": "13.0.1",
49
49
  "css-loader": "7.1.2",
50
50
  "css-minimizer-webpack-plugin": "7.0.2",
51
+ "sass": "1.93.2",
52
+ "sass-loader": "16.0.6",
51
53
  "dotenv-webpack": "8.1.1",
52
54
  "eslint": "9.38.0",
53
55
  "eslint-plugin-react": "^7.37.5",
@@ -61,8 +63,6 @@
61
63
  "lodash": "4.17.21",
62
64
  "mini-css-extract-plugin": "2.9.4",
63
65
  "rollup": "4.52.5",
64
- "sass": "1.93.2",
65
- "sass-loader": "16.0.6",
66
66
  "style-loader": "4.0.0",
67
67
  "terminal-log": "1.0.1",
68
68
  "terser-webpack-plugin": "5.3.14",
@@ -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,115 +1,115 @@
1
1
  #! /usr/bin/env node
2
- import yargs from 'yargs'
3
- import { hideBin } from 'yargs/helpers'
4
- import { StartServer } from './serve.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
- const lint = {
18
- command: 'lint',
19
- describe: 'Lint code',
20
- builder: {
21
- fix: {
22
- alias: 'f',
23
- type: 'boolean',
24
- default: false,
25
- describe: 'Automatically fix problems',
26
- },
27
- },
28
- handler: async (arg) => {
29
- const classicConfig = eslintConfig[0]
30
-
31
- const fix = arg.fix
32
- const eslint = new ESLint({
33
- cwd: process.cwd(),
34
- overrideConfigFile: true,
35
- overrideConfig: classicConfig,
36
- fix,
37
- })
38
-
39
- const results = await eslint.lintFiles(defaultSettings.eslint.files)
40
-
41
- await ESLint.outputFixes(results)
42
-
43
- const formatter = await eslint.loadFormatter('stylish')
44
- const report = formatter.format(results)
45
- console.log(report)
46
- },
47
- }
48
-
49
- const serv = {
50
- command: 'server',
51
- describe: 'Run server',
52
- handler: async (arg) => {
53
- const open = Boolean(arg.browser) || false
54
- const settings = {
55
- open,
56
- }
57
-
58
- StartServer(settings)
59
- },
60
- }
61
-
62
- const build = {
63
- command: 'build',
64
- describe: 'Run builder',
65
- handler: async (arg) => {
66
- if (!defaultSettings.webpack.production) {
67
- logger.error(
68
- chalk.red(
69
- 'The compilation cannot complete because you are trying to compile in developer mode. remember update ryunix.config.js.',
70
- ),
71
- )
72
- return
73
- }
74
-
75
- if (defaultSettings.experimental.ssg.prerender.length > 0) {
76
- await cleanBuildDirectory(
77
- resolveApp(
78
- process.cwd(),
79
- `${defaultSettings.webpack.output.buildDirectory}/static`,
80
- ),
81
- )
82
- }
83
-
84
- compiler.run(async (err, stats) => {
85
- if (err || stats.hasErrors()) {
86
- logger.error(chalk.red('Error during compilation:'))
87
- logger.error(err || stats.toString('errors-only'))
88
- return
89
- }
90
-
91
- const buildTimeMs = stats.endTime - stats.startTime
92
-
93
- const minutes = Math.floor(buildTimeMs / 60000)
94
- const seconds = ((buildTimeMs % 60000) / 1000).toFixed(1)
95
-
96
- const formattedTime =
97
- minutes > 0 ? `${minutes}m ${seconds}s` : `${seconds}s`
98
-
99
- if (defaultSettings.experimental.ssg.prerender.length > 0) {
100
- await Prerender()
101
- }
102
-
103
- logger.info(chalk.green('Compilation successful! 🎉'))
104
- logger.info(`Done in ${formattedTime}`)
105
-
106
- compiler.close((closeErr) => {
107
- if (closeErr) {
108
- logger.error(chalk.red('Error closing the compiler:'), closeErr)
109
- }
110
- })
111
- })
112
- },
113
- }
114
-
115
- yargs(hideBin(process.argv)).command(serv).command(build).command(lint).parse()
2
+ import yargs from 'yargs'
3
+ import { hideBin } from 'yargs/helpers'
4
+ import { StartServer } from './serve.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
+ const lint = {
18
+ command: 'lint',
19
+ describe: 'Lint code',
20
+ builder: {
21
+ fix: {
22
+ alias: 'f',
23
+ type: 'boolean',
24
+ default: false,
25
+ describe: 'Automatically fix problems',
26
+ },
27
+ },
28
+ handler: async (arg) => {
29
+ const classicConfig = eslintConfig[0]
30
+
31
+ const fix = arg.fix
32
+ const eslint = new ESLint({
33
+ cwd: process.cwd(),
34
+ overrideConfigFile: true,
35
+ overrideConfig: classicConfig,
36
+ fix,
37
+ })
38
+
39
+ const results = await eslint.lintFiles(defaultSettings.eslint.files)
40
+
41
+ await ESLint.outputFixes(results)
42
+
43
+ const formatter = await eslint.loadFormatter('stylish')
44
+ const report = formatter.format(results)
45
+ console.log(report)
46
+ },
47
+ }
48
+
49
+ const serv = {
50
+ command: 'server',
51
+ describe: 'Run server',
52
+ handler: async (arg) => {
53
+ const open = Boolean(arg.browser) || false
54
+ const settings = {
55
+ open,
56
+ }
57
+
58
+ StartServer(settings)
59
+ },
60
+ }
61
+
62
+ const build = {
63
+ command: 'build',
64
+ describe: 'Run builder',
65
+ handler: async (arg) => {
66
+ if (!defaultSettings.webpack.production) {
67
+ logger.error(
68
+ chalk.red(
69
+ 'The compilation cannot complete because you are trying to compile in developer mode. remember update ryunix.config.js.',
70
+ ),
71
+ )
72
+ return
73
+ }
74
+
75
+ if (defaultSettings.experimental.ssg.prerender.length > 0) {
76
+ await cleanBuildDirectory(
77
+ resolveApp(
78
+ process.cwd(),
79
+ `${defaultSettings.webpack.output.buildDirectory}/static`,
80
+ ),
81
+ )
82
+ }
83
+
84
+ compiler.run(async (err, stats) => {
85
+ if (err || stats.hasErrors()) {
86
+ logger.error(chalk.red('Error during compilation:'))
87
+ logger.error(err || stats.toString('errors-only'))
88
+ return
89
+ }
90
+
91
+ const buildTimeMs = stats.endTime - stats.startTime
92
+
93
+ const minutes = Math.floor(buildTimeMs / 60000)
94
+ const seconds = ((buildTimeMs % 60000) / 1000).toFixed(1)
95
+
96
+ const formattedTime =
97
+ minutes > 0 ? `${minutes}m ${seconds}s` : `${seconds}s`
98
+
99
+ if (defaultSettings.experimental.ssg.prerender.length > 0) {
100
+ await Prerender()
101
+ }
102
+
103
+ logger.info(chalk.green('Compilation successful! 🎉'))
104
+ logger.info(`Done in ${formattedTime}`)
105
+
106
+ compiler.close((closeErr) => {
107
+ if (closeErr) {
108
+ logger.error(chalk.red('Error closing the compiler:'), closeErr)
109
+ }
110
+ })
111
+ })
112
+ },
113
+ }
114
+
115
+ yargs(hideBin(process.argv)).command(serv).command(build).command(lint).parse()
@@ -1,138 +1,138 @@
1
- /**
2
- * prerender metadata
3
- *
4
- */
5
- import { configFileExist } from '../utils/settingfile.cjs'
6
- import defaultSettings from '../utils/config.cjs'
7
- import { resolveApp } from '../utils/index.mjs'
8
- import fs from 'fs'
9
- import path from 'path'
10
-
11
- // proyect/.ryunix/static
12
- const buildDirectory = resolveApp(process.cwd(), '.ryunix/static')
13
- const indexFile = path.join(buildDirectory, 'index.html')
14
-
15
- const siteMap = async (routes) => {
16
- if (!defaultSettings.experimental.ssg.sitemap.baseURL) {
17
- console.error(
18
- '❌ Base URL is not defined in the configuration file. Please set `experimental.ssg.sitemap.baseURL`.',
19
- )
20
- process.exit(1)
21
- }
22
-
23
- const sitemap = `<?xml version="1.0" encoding="UTF-8"?>
24
- <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
25
- ${routes
26
- .map((route) => {
27
- const url = `${defaultSettings.experimental.ssg.sitemap.baseURL}${route.path === '/' ? '' : route.path}`
28
- const meta = route.meta || {}
29
- const sitemap_settings = route.sitemap || {}
30
- const lastmod = meta.lastmod || new Date().toISOString().split('T')[0]
31
-
32
- // sitemap settings
33
- const changefreq =
34
- sitemap_settings.changefreq ||
35
- meta.changefreq || // TODO: Remove meta.changefreq
36
- defaultSettings.experimental.ssg.sitemap.settings.changefreq
37
- const priority =
38
- sitemap_settings.priority ||
39
- meta.priority || // TODO: Remove meta.priority
40
- defaultSettings.experimental.ssg.sitemap.settings.priority
41
-
42
- return `<url>
43
- <loc>${url}</loc>
44
- <lastmod>${lastmod}</lastmod>
45
- <changefreq>${changefreq}</changefreq>
46
- <priority>${priority}</priority>
47
- </url>`
48
- })
49
- .join('\n')}
50
- </urlset>`
51
-
52
- await fs.writeFileSync(
53
- path.resolve(buildDirectory, 'sitemap.xml'),
54
- sitemap,
55
- 'utf-8',
56
- )
57
-
58
- console.log('✅ Sitemap created')
59
- }
60
-
61
- const Prerender = async () => {
62
- if (!configFileExist()) {
63
- console.error('❌ No configuration file found.')
64
- process.exit(1)
65
- }
66
-
67
- const template = fs.readFileSync(indexFile, 'utf-8')
68
-
69
- for (const route of defaultSettings.experimental.ssg.prerender) {
70
- if (route.path === '/') continue // Exclude root path, handled by defaultSettings.static.seo.meta
71
- let html = template
72
- const meta = route?.meta || defaultSettings.static.seo.meta
73
-
74
- // title
75
- if (meta.title) {
76
- html = html.replace(/<title>.*<\/title>/, `<title>${meta.title}<\/title>`)
77
- }
78
-
79
- // Helper to add or replace metatag
80
- function upsertMetaTag(html, name, value) {
81
- if (value === undefined || value === null) return html
82
-
83
- const isProperty = name.startsWith('og:') || name.startsWith('twitter:')
84
- const attr = isProperty ? 'property' : 'name'
85
- const regex = new RegExp(`<meta ${attr}=["']${name}["'][^>]*>`, 'i')
86
- const tag = `<meta ${attr}="${name}" content="${value}">`
87
-
88
- if (regex.test(html)) {
89
- return html.replace(regex, tag)
90
- } else {
91
- return html.replace(/<\/head>/i, `${tag}\n<\/head>`)
92
- }
93
- }
94
-
95
- // Description
96
- html = upsertMetaTag(html, 'description', meta.description)
97
- // Keywords
98
- html = upsertMetaTag(html, 'keywords', meta.keywords)
99
-
100
- // dynamic metatags (excluding title, description, keywords, framework, mode)
101
- for (const [key, value] of Object.entries(meta)) {
102
- if (
103
- [
104
- 'title',
105
- 'description',
106
- 'keywords',
107
- 'framework',
108
- 'mode',
109
- 'viewport',
110
- ].includes(key)
111
- )
112
- continue
113
- html = upsertMetaTag(html, key, value)
114
- }
115
-
116
- const outputDir =
117
- route.path === '/'
118
- ? buildDirectory
119
- : path.join(buildDirectory, route.path)
120
-
121
- if (!fs.existsSync(outputDir)) {
122
- await fs.mkdirSync(outputDir, { recursive: true, force: true })
123
- }
124
-
125
- await fs.writeFileSync(path.join(outputDir, 'index.html'), html)
126
- console.log(`✅ Prerendered ${route.path}`)
127
- }
128
-
129
- // need base url and enable
130
- if (
131
- defaultSettings.experimental.ssg.sitemap.enable &&
132
- defaultSettings.experimental.ssg.sitemap.baseURL
133
- ) {
134
- await siteMap(defaultSettings.experimental.ssg.prerender)
135
- }
136
- }
137
-
138
- export default Prerender
1
+ /**
2
+ * prerender metadata
3
+ *
4
+ */
5
+ import { configFileExist } from '../utils/settingfile.cjs'
6
+ import defaultSettings from '../utils/config.cjs'
7
+ import { resolveApp } from '../utils/index.mjs'
8
+ import fs from 'fs'
9
+ import path from 'path'
10
+
11
+ // proyect/.ryunix/static
12
+ const buildDirectory = resolveApp(process.cwd(), '.ryunix/static')
13
+ const indexFile = path.join(buildDirectory, 'index.html')
14
+
15
+ const siteMap = async (routes) => {
16
+ if (!defaultSettings.experimental.ssg.sitemap.baseURL) {
17
+ console.error(
18
+ '❌ Base URL is not defined in the configuration file. Please set `experimental.ssg.sitemap.baseURL`.',
19
+ )
20
+ process.exit(1)
21
+ }
22
+
23
+ const sitemap = `<?xml version="1.0" encoding="UTF-8"?>
24
+ <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
25
+ ${routes
26
+ .map((route) => {
27
+ const url = `${defaultSettings.experimental.ssg.sitemap.baseURL}${route.path === '/' ? '' : route.path}`
28
+ const meta = route.meta || {}
29
+ const sitemap_settings = route.sitemap || {}
30
+ const lastmod = meta.lastmod || new Date().toISOString().split('T')[0]
31
+
32
+ // sitemap settings
33
+ const changefreq =
34
+ sitemap_settings.changefreq ||
35
+ meta.changefreq || // TODO: Remove meta.changefreq
36
+ defaultSettings.experimental.ssg.sitemap.settings.changefreq
37
+ const priority =
38
+ sitemap_settings.priority ||
39
+ meta.priority || // TODO: Remove meta.priority
40
+ defaultSettings.experimental.ssg.sitemap.settings.priority
41
+
42
+ return `<url>
43
+ <loc>${url}</loc>
44
+ <lastmod>${lastmod}</lastmod>
45
+ <changefreq>${changefreq}</changefreq>
46
+ <priority>${priority}</priority>
47
+ </url>`
48
+ })
49
+ .join('\n')}
50
+ </urlset>`
51
+
52
+ await fs.writeFileSync(
53
+ path.resolve(buildDirectory, 'sitemap.xml'),
54
+ sitemap,
55
+ 'utf-8',
56
+ )
57
+
58
+ console.log('✅ Sitemap created')
59
+ }
60
+
61
+ const Prerender = async () => {
62
+ if (!configFileExist()) {
63
+ console.error('❌ No configuration file found.')
64
+ process.exit(1)
65
+ }
66
+
67
+ const template = fs.readFileSync(indexFile, 'utf-8')
68
+
69
+ for (const route of defaultSettings.experimental.ssg.prerender) {
70
+ if (route.path === '/') continue // Exclude root path, handled by defaultSettings.static.seo.meta
71
+ let html = template
72
+ const meta = route?.meta || defaultSettings.static.seo.meta
73
+
74
+ // title
75
+ if (meta.title) {
76
+ html = html.replace(/<title>.*<\/title>/, `<title>${meta.title}<\/title>`)
77
+ }
78
+
79
+ // Helper to add or replace metatag
80
+ function upsertMetaTag(html, name, value) {
81
+ if (value === undefined || value === null) return html
82
+
83
+ const isProperty = name.startsWith('og:') || name.startsWith('twitter:')
84
+ const attr = isProperty ? 'property' : 'name'
85
+ const regex = new RegExp(`<meta ${attr}=["']${name}["'][^>]*>`, 'i')
86
+ const tag = `<meta ${attr}="${name}" content="${value}">`
87
+
88
+ if (regex.test(html)) {
89
+ return html.replace(regex, tag)
90
+ } else {
91
+ return html.replace(/<\/head>/i, `${tag}\n<\/head>`)
92
+ }
93
+ }
94
+
95
+ // Description
96
+ html = upsertMetaTag(html, 'description', meta.description)
97
+ // Keywords
98
+ html = upsertMetaTag(html, 'keywords', meta.keywords)
99
+
100
+ // dynamic metatags (excluding title, description, keywords, framework, mode)
101
+ for (const [key, value] of Object.entries(meta)) {
102
+ if (
103
+ [
104
+ 'title',
105
+ 'description',
106
+ 'keywords',
107
+ 'framework',
108
+ 'mode',
109
+ 'viewport',
110
+ ].includes(key)
111
+ )
112
+ continue
113
+ html = upsertMetaTag(html, key, value)
114
+ }
115
+
116
+ const outputDir =
117
+ route.path === '/'
118
+ ? buildDirectory
119
+ : path.join(buildDirectory, route.path)
120
+
121
+ if (!fs.existsSync(outputDir)) {
122
+ await fs.mkdirSync(outputDir, { recursive: true, force: true })
123
+ }
124
+
125
+ await fs.writeFileSync(path.join(outputDir, 'index.html'), html)
126
+ console.log(`✅ Prerendered ${route.path}`)
127
+ }
128
+
129
+ // need base url and enable
130
+ if (
131
+ defaultSettings.experimental.ssg.sitemap.enable &&
132
+ defaultSettings.experimental.ssg.sitemap.baseURL
133
+ ) {
134
+ await siteMap(defaultSettings.experimental.ssg.prerender)
135
+ }
136
+ }
137
+
138
+ export default Prerender