miolo 3.0.0-beta.21 → 3.0.0-beta.210
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/bin/build/build.mjs +53 -0
- package/bin/build/build_bin.mjs +17 -0
- package/bin/build/cli/client.mjs +52 -0
- package/bin/build/cli/css.mjs +22 -0
- package/bin/build/cli/index.mjs +40 -0
- package/bin/build/cli/ssr.mjs +21 -0
- package/bin/build/server/aliases.mjs +112 -0
- package/bin/build/server/babel.config.js +24 -0
- package/bin/build/server/banner.mjs +20 -0
- package/bin/build/server/bundle.mjs +111 -0
- package/bin/build/server/fix.mjs +15 -0
- package/bin/build/server/index.mjs +69 -0
- package/bin/build/server/options.mjs +83 -0
- package/bin/create/auth.mjs +23 -0
- package/bin/create/copy.mjs +175 -0
- package/bin/create/docker.mjs +25 -0
- package/bin/create/index.mjs +137 -0
- package/bin/create/pkgjson.mjs +72 -0
- package/bin/create/prepare-template.mjs +158 -0
- package/bin/create/validation.mjs +27 -0
- package/bin/dev/dev.mjs +32 -23
- package/bin/dev/dev_start.mjs +6 -5
- package/bin/index.mjs +94 -52
- package/bin/prod-bin/create-bin.mjs +42 -27
- package/bin/prod-bin/run.mjs +13 -9
- package/bin/{prod-run → run}/pid.mjs +4 -4
- package/bin/run/restart.mjs +13 -0
- package/bin/run/start.mjs +18 -0
- package/bin/run/stop.mjs +20 -0
- package/bin/util.mjs +35 -11
- package/package.json +59 -39
- package/src/config/.env +34 -12
- package/src/config/defaults.mjs +253 -185
- package/src/config/env.mjs +40 -22
- package/src/config/index.mjs +19 -24
- package/src/config/util.mjs +25 -10
- package/src/db-conn.mjs +34 -0
- package/src/engines/cron/emails.mjs +10 -5
- package/src/engines/cron/index.mjs +45 -51
- package/src/engines/cron/init.mjs +16 -17
- package/src/engines/cron/ipsum.mjs +65 -60
- package/src/engines/cron/syscheck.mjs +30 -30
- package/src/engines/emailer/index.mjs +1 -2
- package/src/engines/emailer/queue.mjs +14 -20
- package/src/engines/emailer/transporter.mjs +86 -74
- package/src/engines/geoip/index.mjs +23 -28
- package/src/engines/http/index.mjs +26 -15
- package/src/engines/logger/buildErrorEmailBody.mjs +72 -0
- package/src/engines/logger/index.mjs +114 -122
- package/src/engines/logger/injectStackTrace.mjs +59 -0
- package/src/engines/logger/logger_mail.mjs +47 -61
- package/src/engines/logger/reopenTransportOnHupSignal.mjs +12 -13
- package/src/engines/parser/Parser.mjs +77 -60
- package/src/engines/parser/index.mjs +1 -1
- package/src/engines/schema/diffObjs.mjs +41 -0
- package/src/engines/schema/index.mjs +4 -0
- package/src/engines/schema/input.mjs +54 -0
- package/src/engines/schema/output.mjs +66 -0
- package/src/engines/socket/index.mjs +44 -46
- package/src/index.mjs +15 -10
- package/src/middleware/auth/basic.mjs +41 -40
- package/src/middleware/auth/custom.mjs +10 -13
- package/src/middleware/auth/guest.mjs +27 -27
- package/src/middleware/auth/passport/index.mjs +374 -0
- package/src/middleware/auth/passport/session/index.mjs +43 -0
- package/src/middleware/auth/{credentials → passport}/session/store.mjs +35 -15
- package/src/middleware/auth/passport/session/store_koa_redis.mjs +3 -0
- package/src/middleware/context/cache/index.mjs +78 -33
- package/src/middleware/context/cache/options.mjs +19 -21
- package/src/middleware/context/db.mjs +45 -20
- package/src/middleware/context/index.mjs +12 -12
- package/src/middleware/extra.mjs +4 -5
- package/src/middleware/http/body.mjs +25 -25
- package/src/middleware/http/catcher.mjs +81 -8
- package/src/middleware/http/custom_blacklist.mjs +19 -16
- package/src/middleware/http/headers.mjs +37 -34
- package/src/middleware/http/ratelimit.mjs +16 -23
- package/src/middleware/http/request.mjs +60 -65
- package/src/middleware/routes/catch_js_error.mjs +30 -23
- package/src/middleware/routes/robots.mjs +4 -7
- package/src/middleware/routes/router/crud/attachCrudRoutes.mjs +108 -90
- package/src/middleware/routes/router/crud/getCrudConfig.mjs +31 -55
- package/src/middleware/routes/router/defaults.mjs +6 -19
- package/src/middleware/routes/router/index.mjs +17 -21
- package/src/middleware/routes/router/queries/attachQueriesRoutes.mjs +227 -50
- package/src/middleware/routes/router/queries/getQueriesConfig.mjs +45 -55
- package/src/middleware/routes/router/utils.mjs +41 -26
- package/src/middleware/ssr/context.mjs +5 -7
- package/src/middleware/ssr/html.mjs +66 -43
- package/src/middleware/ssr/loader.mjs +11 -14
- package/src/middleware/ssr/ssr_render.mjs +39 -22
- package/src/middleware/static/index.mjs +33 -14
- package/src/middleware/vite/devserver.mjs +38 -22
- package/src/middleware/vite/watcher.mjs +12 -14
- package/src/server-cron.mjs +13 -8
- package/src/server-dev.mjs +13 -16
- package/src/server.mjs +49 -51
- package/template/.agent/skills/miolo-app-arch/SKILL.md +218 -0
- package/template/.agent/skills/miolo-auth/SKILL.md +450 -0
- package/template/.agent/skills/miolo-cli-router/SKILL.md +394 -0
- package/template/.agent/skills/miolo-database/SKILL.md +358 -0
- package/template/.agent/skills/miolo-react-patterns/SKILL.md +426 -0
- package/template/.agent/skills/miolo-routing/SKILL.md +326 -0
- package/template/.agent/skills/miolo-schemas/SKILL.md +329 -0
- package/template/.agent/skills/miolo-session-context/SKILL.md +397 -0
- package/template/.agent/skills/miolo-ssr/SKILL.md +433 -0
- package/template/.editorconfig +18 -0
- package/template/.env +120 -0
- package/template/biome.json +63 -0
- package/template/components.json +21 -0
- package/template/db/init.sh +89 -0
- package/template/db/sql/00_drop.sql +2 -0
- package/template/db/sql/01_users.sql +31 -0
- package/template/db/sql/02_todos.sql +20 -0
- package/template/docker/Dockerfile +13 -0
- package/template/docker/docker-compose.yaml +79 -0
- package/template/gitignore +42 -0
- package/template/jsconfig.json +18 -0
- package/template/package.json +88 -0
- package/template/postcss.config.js +9 -0
- package/template/src/cli/App.jsx +25 -0
- package/template/src/cli/components/JsonTreeViewer.jsx +128 -0
- package/template/src/cli/components/shadcn-io/spinner/index.jsx +232 -0
- package/template/src/cli/components/stepper.jsx +408 -0
- package/template/src/cli/components/ui/avatar.jsx +36 -0
- package/template/src/cli/components/ui/badge.jsx +31 -0
- package/template/src/cli/components/ui/breadcrumb.jsx +97 -0
- package/template/src/cli/components/ui/card.jsx +73 -0
- package/template/src/cli/components/ui/collapsible.jsx +16 -0
- package/template/src/cli/components/ui/dropdown-menu.jsx +179 -0
- package/template/src/cli/components/ui/field.jsx +217 -0
- package/template/src/cli/components/ui/input.jsx +19 -0
- package/template/src/cli/components/ui/label.jsx +17 -0
- package/template/src/cli/components/ui/pagination.jsx +99 -0
- package/template/src/cli/components/ui/patched/alert.jsx +56 -0
- package/template/src/cli/components/ui/patched/button.jsx +45 -0
- package/template/src/cli/components/ui/patched/dialog.jsx +114 -0
- package/template/src/cli/components/ui/patched/sidebar.jsx +660 -0
- package/template/src/cli/components/ui/select.jsx +141 -0
- package/template/src/cli/components/ui/separator.jsx +21 -0
- package/template/src/cli/components/ui/sheet.jsx +115 -0
- package/template/src/cli/components/ui/skeleton.jsx +13 -0
- package/template/src/cli/components/ui/sonner.jsx +22 -0
- package/template/src/cli/components/ui/switch.jsx +25 -0
- package/template/src/cli/components/ui/table.jsx +88 -0
- package/template/src/cli/components/ui/textarea.jsx +16 -0
- package/template/src/cli/components/ui/tooltip.jsx +45 -0
- package/template/src/cli/config/store_keys.mjs +2 -0
- package/template/src/cli/context/data/DataContext.jsx +5 -0
- package/template/src/cli/context/data/DataProvider.jsx +44 -0
- package/template/src/cli/context/data/useBreads.mjs +15 -0
- package/template/src/cli/context/data/useDataContext.mjs +4 -0
- package/template/src/cli/context/session/SessionContext.mjs +4 -0
- package/template/src/cli/context/session/SessionProvider.jsx +31 -0
- package/template/src/cli/context/session/makePermissioner.mjs +34 -0
- package/template/src/cli/context/session/useSessionContext.mjs +6 -0
- package/template/src/cli/context/theme/ThemeContext.mjs +4 -0
- package/template/src/cli/context/theme/ThemeProvider.jsx +49 -0
- package/template/src/cli/context/theme/useThemeContext.mjs +6 -0
- package/template/src/cli/context/ui/UIContext.jsx +5 -0
- package/template/src/cli/context/ui/UIProvider.jsx +16 -0
- package/template/src/cli/context/ui/useUIContext.mjs +4 -0
- package/template/src/cli/context/util.mjs +17 -0
- package/template/src/cli/entry-cli.jsx +33 -0
- package/template/src/cli/hooks/useIsMobile.mjs +19 -0
- package/template/src/cli/hooks/useStoragedState.mjs +63 -0
- package/template/src/cli/index.html +29 -0
- package/template/src/cli/layout/app-sidebar.jsx +25 -0
- package/template/src/cli/layout/main-layout.jsx +63 -0
- package/template/src/cli/layout/nav-last-todos.jsx +72 -0
- package/template/src/cli/layout/nav-main.jsx +39 -0
- package/template/src/cli/layout/nav-user.jsx +105 -0
- package/template/src/cli/layout/prop-switcher.jsx +93 -0
- package/template/src/cli/lib/utils.mjs +10 -0
- package/template/src/cli/pages/Index.jsx +13 -0
- package/template/src/cli/pages/IndexOffline.jsx +13 -0
- package/template/src/cli/pages/IndexOnline.jsx +18 -0
- package/template/src/cli/pages/dash/Dashboard.jsx +29 -0
- package/template/src/cli/pages/offline/Login.jsx +43 -0
- package/template/src/cli/pages/offline/LoginForm.jsx +115 -0
- package/template/src/cli/pages/security/Security.jsx +39 -0
- package/template/src/cli/pages/security/SecurityForm.jsx +106 -0
- package/template/src/cli/pages/todos/TodoActions.jsx +99 -0
- package/template/src/cli/pages/todos/TodoAdd.jsx +43 -0
- package/template/src/cli/pages/todos/TodoList.jsx +60 -0
- package/template/src/cli/pages/todos/Todos.jsx +23 -0
- package/template/src/cli/pages/todos/context/TodosContext.jsx +5 -0
- package/template/src/cli/pages/todos/context/TodosProvider.jsx +191 -0
- package/template/src/cli/pages/todos/context/useTodosContext.mjs +4 -0
- package/template/src/ns/models/Todo.mjs +29 -0
- package/template/src/ns/models/TodoList.mjs +8 -0
- package/template/src/ns/models/User.mjs +40 -0
- package/template/src/server/bot/check_today.mjs +10 -0
- package/template/src/server/io/cache/base.mjs +21 -0
- package/template/src/server/io/db/filter.mjs +92 -0
- package/template/src/server/io/db/todos/delete.mjs +29 -0
- package/template/src/server/io/db/todos/find.mjs +13 -0
- package/template/src/server/io/db/todos/read.mjs +83 -0
- package/template/src/server/io/db/todos/toggle.mjs +37 -0
- package/template/src/server/io/db/todos/upsave.mjs +32 -0
- package/template/src/server/io/db/triggers/user.mjs +13 -0
- package/template/src/server/io/db/users/auth.mjs +132 -0
- package/template/src/server/io/db/users/pwd.mjs +38 -0
- package/template/src/server/io/db/users/save.mjs +17 -0
- package/template/src/server/miolo/auth/basic.mjs +15 -0
- package/template/src/server/miolo/auth/guest.mjs +3 -0
- package/template/src/server/miolo/auth/passport.mjs +73 -0
- package/template/src/server/miolo/cache.mjs +11 -0
- package/template/src/server/miolo/cron/foo.mjs +7 -0
- package/template/src/server/miolo/cron/index.mjs +28 -0
- package/template/src/server/miolo/cron/invalidate.mjs +21 -0
- package/template/src/server/miolo/db.mjs +36 -0
- package/template/src/server/miolo/http.mjs +14 -0
- package/template/src/server/miolo/index.mjs +43 -0
- package/template/src/server/miolo/routes/crud.mjs +16 -0
- package/template/src/server/miolo/routes/index.mjs +8 -0
- package/template/src/server/miolo/ssr/entry-server.jsx +13 -0
- package/template/src/server/miolo/ssr/loader.mjs +18 -0
- package/template/src/server/routes/index.mjs +66 -0
- package/template/src/server/routes/todos/mod.mjs +52 -0
- package/template/src/server/routes/todos/read.mjs +45 -0
- package/template/src/server/routes/todos/special.mjs +47 -0
- package/template/src/server/routes/users/user.mjs +54 -0
- package/template/src/server/server.mjs +10 -0
- package/template/src/server/utils/crypt.mjs +38 -0
- package/template/src/server/utils/io.mjs +15 -0
- package/template/src/server/utils/pwdfor.mjs +25 -0
- package/template/src/server/utils/schema.mjs +22 -0
- package/template/src/static/img/default/profile.png +0 -0
- package/template/src/static/img/favicon.ico +0 -0
- package/template/src/static/img/miolo_logo.png +0 -0
- package/template/src/static/img/miolo_name.png +0 -0
- package/template/src/static/public/manifest.json +21 -0
- package/template/src/static/public/sw.js +79 -0
- package/template/src/static/style/globals.css +156 -0
- package/template/src/static/style/json-tree.css +54 -0
- package/template/src/static/style/skeleton.css +49 -0
- package/bin/prod-build/build-client.mjs +0 -67
- package/bin/prod-build/build-server.mjs +0 -58
- package/bin/prod-run/restart.mjs +0 -9
- package/bin/prod-run/start.mjs +0 -15
- package/bin/prod-run/stop.mjs +0 -20
- package/src/engines/logger/verify.mjs +0 -22
- package/src/middleware/auth/credentials/index.mjs +0 -151
- package/src/middleware/auth/credentials/session/index.mjs +0 -24
- package/src/middleware/auth/credentials/session/store_koa_redis.mjs +0 -3
package/bin/dev/dev_start.mjs
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import path from
|
|
2
|
-
import {miolo_dev} from
|
|
1
|
+
import path from "node:path"
|
|
2
|
+
import { miolo_dev } from "../../src/server-dev.mjs"
|
|
3
3
|
|
|
4
4
|
async function _miolo_dev_start_server() {
|
|
5
|
-
|
|
5
|
+
process.env.NODE_ENV = "development"
|
|
6
|
+
const config = await import(path.join(process.cwd(), process.env.MIOLO_BUILD_CONFIG_ENTRY))
|
|
6
7
|
const app = await miolo_dev(config.default)
|
|
7
8
|
await app.start()
|
|
8
|
-
return app
|
|
9
|
+
return app
|
|
9
10
|
}
|
|
10
11
|
|
|
11
|
-
_miolo_dev_start_server()
|
|
12
|
+
_miolo_dev_start_server()
|
package/bin/index.mjs
CHANGED
|
@@ -1,86 +1,128 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import path from
|
|
3
|
-
import yargs from
|
|
4
|
-
import { init_env_config } from
|
|
5
|
-
|
|
2
|
+
import path from "node:path"
|
|
3
|
+
import yargs from "yargs-parser"
|
|
4
|
+
import { init_env_config } from "../src/config/env.mjs"
|
|
6
5
|
|
|
7
6
|
async function main() {
|
|
8
7
|
const args = yargs(process.argv.slice(2))
|
|
9
8
|
const command = args._[0]
|
|
10
9
|
|
|
11
|
-
// Init env
|
|
12
|
-
init_env_config()
|
|
13
|
-
|
|
14
|
-
// Init vars
|
|
15
|
-
const appName = args['app-name'] || process.env.MIOLO_NAME
|
|
16
|
-
const serverExt = 'node.bundle.mjs'
|
|
17
|
-
|
|
18
10
|
try {
|
|
11
|
+
// Special handling for 'create' command - doesn't need env config
|
|
12
|
+
if (command === "create") {
|
|
13
|
+
const createAppName = args._[1]
|
|
14
|
+
const createOptions = {
|
|
15
|
+
port: args.port,
|
|
16
|
+
auth: args.auth,
|
|
17
|
+
dest: args.d || args.dest // Support both --d and --dest
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const createAppHandler = (await import("./create/index.mjs")).default
|
|
21
|
+
await createAppHandler(createAppName, createOptions)
|
|
22
|
+
return
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// Init env for other commands
|
|
26
|
+
process.env.NODE_ENV = "production"
|
|
27
|
+
init_env_config()
|
|
28
|
+
|
|
29
|
+
// Init vars
|
|
30
|
+
const appName = args["app-name"] || process.env.MIOLO_NAME || "miolo"
|
|
31
|
+
const cliEntry =
|
|
32
|
+
args["cli-entry"] || process.env.MIOLO_BUILD_CLIENT_ENTRY || "./src/cli/entry-cli.jsx"
|
|
33
|
+
const cliDest = args["cli-dest"] || process.env.MIOLO_BUILD_CLIENT_DEST || "./build/cli"
|
|
34
|
+
const cliSuffix =
|
|
35
|
+
args["cli-suffix"] || process.env.MIOLO_BUILD_CLIENT_SUFFIX || "iife.bundle.min"
|
|
36
|
+
const htmlFile =
|
|
37
|
+
args["html-file"] || process.env.MIOLO_BUILD_HTML_FILE || "./src/cli/index.html"
|
|
38
|
+
const srvEntry =
|
|
39
|
+
args["server-entry"] || process.env.MIOLO_BUILD_SERVER_ENTRY || "./src/server/server.mjs"
|
|
40
|
+
const configEntry =
|
|
41
|
+
args["config-entry"] || process.env.MIOLO_BUILD_CONFIG_ENTRY || "./src/server/config.mjs"
|
|
42
|
+
const srvDest = args["server-dest"] || process.env.MIOLO_BUILD_SERVER_DEST || "./build/server"
|
|
43
|
+
const srvExt = args["server-ext"] || process.env.MIOLO_BUILD_SERVER_EXT || "node.bundle.mjs"
|
|
44
|
+
const ssrEntry = args["ssr-entry"] || process.env.MIOLO_BUILD_SERVER_SSR_ENTRY
|
|
45
|
+
const ssrDest = args["ssr-dest"] || process.env.MIOLO_BUILD_SERVER_DEST || "./build/server"
|
|
46
|
+
const binDest = args["bin-dest"] || "./build/bin"
|
|
47
|
+
const binEntry = args["bin-entry"]
|
|
48
|
+
const binName =
|
|
49
|
+
args["bin-name"] || (binEntry ? path.basename(binEntry, path.extname(binEntry)) : "")
|
|
50
|
+
const binExt = args["bin-ext"] || "node.bundle.mjs"
|
|
19
51
|
|
|
20
52
|
switch (command) {
|
|
21
|
-
case
|
|
22
|
-
process.env.NODE_ENV =
|
|
23
|
-
const devHandler = (await import
|
|
53
|
+
case "dev": {
|
|
54
|
+
process.env.NODE_ENV = "development"
|
|
55
|
+
const devHandler = (await import("./dev/dev.mjs")).default
|
|
24
56
|
await devHandler(appName)
|
|
25
57
|
break
|
|
58
|
+
}
|
|
26
59
|
|
|
27
|
-
case
|
|
28
|
-
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
const buildClientHandler = (await import ('./prod-build/build-client.mjs')).default
|
|
33
|
-
await buildClientHandler(appName, entry, htmlFile, cliDest)
|
|
60
|
+
case "deb": {
|
|
61
|
+
process.env.NODE_ENV = "development"
|
|
62
|
+
const debHandler = (await import("./dev/dev.mjs")).default
|
|
63
|
+
await debHandler(appName, true)
|
|
34
64
|
break
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
case "build": {
|
|
68
|
+
const buildHandler = (await import("./build/build.mjs")).default
|
|
69
|
+
await buildHandler(
|
|
70
|
+
appName,
|
|
71
|
+
cliEntry,
|
|
72
|
+
cliDest,
|
|
73
|
+
cliSuffix,
|
|
74
|
+
htmlFile,
|
|
75
|
+
srvEntry,
|
|
76
|
+
configEntry,
|
|
77
|
+
srvDest,
|
|
78
|
+
srvExt,
|
|
79
|
+
ssrEntry,
|
|
80
|
+
ssrDest
|
|
81
|
+
)
|
|
45
82
|
break
|
|
83
|
+
}
|
|
46
84
|
|
|
47
|
-
case
|
|
48
|
-
|
|
49
|
-
|
|
85
|
+
case "build-bin": {
|
|
86
|
+
const buildHandler = (await import("./build/build_bin.mjs")).default
|
|
87
|
+
await buildHandler(appName, binEntry, binDest, binName, binExt)
|
|
88
|
+
break
|
|
89
|
+
}
|
|
50
90
|
|
|
51
|
-
|
|
52
|
-
|
|
91
|
+
case "start": {
|
|
92
|
+
const startHandler = (await import("./run/start.mjs")).default
|
|
93
|
+
await startHandler(appName, srvDest, srvExt)
|
|
53
94
|
break
|
|
95
|
+
}
|
|
54
96
|
|
|
55
|
-
case
|
|
56
|
-
const stopHandler = (await import
|
|
97
|
+
case "stop": {
|
|
98
|
+
const stopHandler = (await import("./run/stop.mjs")).default
|
|
57
99
|
await stopHandler(appName)
|
|
58
100
|
break
|
|
101
|
+
}
|
|
59
102
|
|
|
60
|
-
case
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
const restartHandler = (await import ('./prod-run/restart.mjs')).default
|
|
64
|
-
await restartHandler(appName, restartDestFile)
|
|
103
|
+
case "restart": {
|
|
104
|
+
const restartHandler = (await import("./run/restart.mjs")).default
|
|
105
|
+
await restartHandler(appName, srvDest, srvExt)
|
|
65
106
|
break
|
|
107
|
+
}
|
|
66
108
|
|
|
67
|
-
case
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
const createHandler = (await import ('./prod-bin/create-bin.mjs')).default
|
|
72
|
-
await createHandler(appName, dest, cbinDestFile)
|
|
109
|
+
case "create-bin": {
|
|
110
|
+
const createHandler = (await import("./prod-bin/create-bin.mjs")).default
|
|
111
|
+
await createHandler(appName, srvDest, srvExt)
|
|
73
112
|
break
|
|
113
|
+
}
|
|
74
114
|
|
|
75
115
|
default:
|
|
76
116
|
console.error(`[miolo] Unknown command: ${command}`)
|
|
77
|
-
console.log(
|
|
117
|
+
console.log(
|
|
118
|
+
"[miolo] Available commands: create, dev, deb, build, start, stop, restart, create-bin"
|
|
119
|
+
)
|
|
78
120
|
process.exit(1)
|
|
79
121
|
}
|
|
80
122
|
} catch (error) {
|
|
81
|
-
console.error(
|
|
123
|
+
console.error("[miolo] Error during command execution:", error)
|
|
82
124
|
process.exit(1)
|
|
83
125
|
}
|
|
84
126
|
}
|
|
85
127
|
|
|
86
|
-
main()
|
|
128
|
+
main()
|
|
@@ -1,31 +1,46 @@
|
|
|
1
|
-
import {readFileSync, writeFileSync} from
|
|
2
|
-
import path from
|
|
3
|
-
import { fileURLToPath } from
|
|
4
|
-
import { copyFileSync } from
|
|
1
|
+
import { readFileSync, writeFileSync } from "node:fs"
|
|
2
|
+
import path from "node:path"
|
|
3
|
+
import { fileURLToPath } from "node:url"
|
|
4
|
+
import { copyFileSync } from "../util.mjs"
|
|
5
5
|
|
|
6
6
|
const __my_filename = fileURLToPath(import.meta.url)
|
|
7
7
|
const __my_dirname = path.dirname(__my_filename)
|
|
8
8
|
|
|
9
|
-
export default async function(appName,
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
writeDest(
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
9
|
+
export default async function (appName, srvDest, srvExt) {
|
|
10
|
+
// const cbinDestFile = `./${appName}.${srvExt}`
|
|
11
|
+
|
|
12
|
+
const pkgPath = process.cwd()
|
|
13
|
+
console.log(`[${appName}][build][create-bin] Creating bin files...`)
|
|
14
|
+
|
|
15
|
+
const readSource = (f) =>
|
|
16
|
+
readFileSync(path.resolve(__my_dirname, "../run", f), { encoding: "utf8" })
|
|
17
|
+
const writeDest = (f, content) =>
|
|
18
|
+
writeFileSync(path.join(pkgPath, srvDest, f), content, { encoding: "utf8", flag: "w" })
|
|
19
|
+
|
|
20
|
+
const pidContent = readSource("pid.mjs")
|
|
21
|
+
writeDest("pid.mjs", pidContent)
|
|
22
|
+
|
|
23
|
+
let startContent = readSource("start.mjs")
|
|
24
|
+
startContent = startContent.replace(
|
|
25
|
+
"(appName, srvDest, srvExt) {",
|
|
26
|
+
`(appName= '${appName}', srvDest= '${srvDest}', srvExt= '${srvExt}') {`
|
|
27
|
+
)
|
|
28
|
+
writeDest("start.mjs", startContent)
|
|
29
|
+
|
|
30
|
+
let stopContent = readSource("stop.mjs")
|
|
31
|
+
stopContent = stopContent.replace("(appName) {", `(appName= '${appName}') {`)
|
|
32
|
+
writeDest("stop.mjs", stopContent)
|
|
33
|
+
|
|
34
|
+
let restartContent = readSource("restart.mjs")
|
|
35
|
+
restartContent = restartContent.replace(
|
|
36
|
+
"(appName, srvDest, srvExt) {",
|
|
37
|
+
`(appName= '${appName}', srvDest= '${srvDest}', srvExt= '${srvExt}') {`
|
|
38
|
+
)
|
|
39
|
+
writeDest("restart.mjs", restartContent)
|
|
40
|
+
|
|
41
|
+
copyFileSync(path.join(__my_dirname, "run.mjs"), path.join(pkgPath, srvDest, "run.mjs"))
|
|
42
|
+
copyFileSync(
|
|
43
|
+
path.join(__my_dirname, "../../src/config/.env"),
|
|
44
|
+
path.join(pkgPath, srvDest, ".env")
|
|
45
|
+
)
|
|
46
|
+
}
|
package/bin/prod-bin/run.mjs
CHANGED
|
@@ -2,33 +2,37 @@
|
|
|
2
2
|
async function miolo_run() {
|
|
3
3
|
const args = process.argv.slice(2)
|
|
4
4
|
const command = args[0]
|
|
5
|
+
process.env.NODE_ENV = "production"
|
|
5
6
|
|
|
6
7
|
try {
|
|
7
8
|
switch (command) {
|
|
8
|
-
case
|
|
9
|
-
const startHandler = (await import
|
|
9
|
+
case "start": {
|
|
10
|
+
const startHandler = (await import("./start.mjs")).default
|
|
10
11
|
await startHandler()
|
|
11
12
|
break
|
|
13
|
+
}
|
|
12
14
|
|
|
13
|
-
case
|
|
14
|
-
const stopHandler = (await import
|
|
15
|
+
case "stop": {
|
|
16
|
+
const stopHandler = (await import("./stop.mjs")).default
|
|
15
17
|
await stopHandler()
|
|
16
18
|
break
|
|
19
|
+
}
|
|
17
20
|
|
|
18
|
-
case
|
|
19
|
-
const restartHandler = (await import
|
|
21
|
+
case "restart": {
|
|
22
|
+
const restartHandler = (await import("./restart.mjs")).default
|
|
20
23
|
await restartHandler()
|
|
21
24
|
break
|
|
25
|
+
}
|
|
22
26
|
|
|
23
27
|
default:
|
|
24
28
|
console.error(`[miolo] Unknown command: ${command}`)
|
|
25
|
-
console.log(
|
|
29
|
+
console.log("[miolo] Available commands: start, stop, restart")
|
|
26
30
|
process.exit(1)
|
|
27
31
|
}
|
|
28
32
|
} catch (error) {
|
|
29
|
-
console.error(
|
|
33
|
+
console.error("[miolo] Error during command execution:", error)
|
|
30
34
|
process.exit(1)
|
|
31
35
|
}
|
|
32
36
|
}
|
|
33
37
|
|
|
34
|
-
miolo_run()
|
|
38
|
+
miolo_run()
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { readFileSync, writeFileSync } from "node:fs"
|
|
2
2
|
|
|
3
3
|
export function pidFileCreate(appName) {
|
|
4
4
|
const pidFilePath = `/tmp/${appName}.pid`
|
|
5
|
-
writeFileSync(pidFilePath, `${process.pid}`, {encoding:
|
|
5
|
+
writeFileSync(pidFilePath, `${process.pid}`, { encoding: "utf8", flag: "w" })
|
|
6
6
|
return process.pid
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
export function pidFileRead(appName) {
|
|
10
10
|
const pidFilePath = `/tmp/${appName}.pid`
|
|
11
|
-
const pid = readFileSync(pidFilePath, {encoding:
|
|
11
|
+
const pid = readFileSync(pidFilePath, { encoding: "utf8" })
|
|
12
12
|
return pid
|
|
13
|
-
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import path from "node:path"
|
|
2
|
+
import start from "./start.mjs"
|
|
3
|
+
import stop from "./stop.mjs"
|
|
4
|
+
|
|
5
|
+
export default async function restart(appName, srvDest, srvExt) {
|
|
6
|
+
const pkgPath = process.cwd()
|
|
7
|
+
const destFile = path.join(pkgPath, `${srvDest}/${appName}.${srvExt}`)
|
|
8
|
+
|
|
9
|
+
console.log(`[${appName}][restart] Restarting server...`)
|
|
10
|
+
|
|
11
|
+
await stop(appName)
|
|
12
|
+
await start(appName, destFile)
|
|
13
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import path from "node:path"
|
|
2
|
+
import { pidFileCreate } from "./pid.mjs"
|
|
3
|
+
|
|
4
|
+
export default async function start(appName, srvDest, srvExt) {
|
|
5
|
+
// Start server
|
|
6
|
+
const pkgPath = process.cwd()
|
|
7
|
+
const destFile = path.join(pkgPath, `${srvDest}/${appName}.${srvExt}`)
|
|
8
|
+
|
|
9
|
+
console.log(`[${appName}][start] Starting server from ${destFile}...`)
|
|
10
|
+
|
|
11
|
+
const srv_module = await import(destFile)
|
|
12
|
+
const server = srv_module.default
|
|
13
|
+
|
|
14
|
+
const pid = pidFileCreate(appName)
|
|
15
|
+
console.log(`[${appName}][start] Starting server. PID is ${pid}...`)
|
|
16
|
+
|
|
17
|
+
await server()
|
|
18
|
+
}
|
package/bin/run/stop.mjs
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { pidFileRead } from "./pid.mjs"
|
|
2
|
+
|
|
3
|
+
export default async function stop(appName) {
|
|
4
|
+
// stop server by killin gprocess
|
|
5
|
+
console.log(`[${appName}][stop] Stopping server...`)
|
|
6
|
+
|
|
7
|
+
try {
|
|
8
|
+
const pid = pidFileRead(appName)
|
|
9
|
+
console.log(`[${appName}][stop] Killing current process with PID ${pid}`)
|
|
10
|
+
|
|
11
|
+
process.kill(pid, "SIGKILL")
|
|
12
|
+
|
|
13
|
+
return 1
|
|
14
|
+
} catch (_) {
|
|
15
|
+
console.log(`[${appName}][stop] No current process to kill`)
|
|
16
|
+
console.error(_)
|
|
17
|
+
|
|
18
|
+
return 0
|
|
19
|
+
}
|
|
20
|
+
}
|
package/bin/util.mjs
CHANGED
|
@@ -1,32 +1,56 @@
|
|
|
1
|
-
import {readdirSync, rmSync, writeFileSync
|
|
2
|
-
import
|
|
3
|
-
|
|
1
|
+
import { readdirSync, readFileSync, rmSync, writeFileSync } from "node:fs"
|
|
2
|
+
import { readFile } from "node:fs/promises"
|
|
3
|
+
import path from "node:path"
|
|
4
4
|
|
|
5
5
|
export function cleanFolder(folder) {
|
|
6
|
-
readdirSync(folder).forEach(file => {
|
|
7
|
-
rmSync(`${folder}/${file}`, { recursive: true, force: true })
|
|
6
|
+
readdirSync(folder).forEach((file) => {
|
|
7
|
+
rmSync(`${folder}/${file}`, { recursive: true, force: true })
|
|
8
8
|
})
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
export function copyFileSync(srcPath, destPath, modifier= undefined) {
|
|
11
|
+
export function copyFileSync(srcPath, destPath, modifier = undefined) {
|
|
12
12
|
try {
|
|
13
|
-
let content = readFileSync(srcPath,
|
|
13
|
+
let content = readFileSync(srcPath, "utf8")
|
|
14
14
|
if (modifier) {
|
|
15
15
|
content = modifier(content)
|
|
16
16
|
}
|
|
17
|
-
writeFileSync(destPath, content, {encoding:
|
|
17
|
+
writeFileSync(destPath, content, { encoding: "utf8", flag: "w" })
|
|
18
18
|
console.log(`[miolo] Copied file from ${srcPath} to ${destPath}`)
|
|
19
19
|
} catch (error) {
|
|
20
20
|
console.error(`[miolo] Error copying file from ${srcPath} to ${destPath}:`, error)
|
|
21
21
|
}
|
|
22
|
-
}
|
|
22
|
+
}
|
|
23
23
|
|
|
24
24
|
export function isFileExistingSync(filePath) {
|
|
25
25
|
try {
|
|
26
|
-
const fullPath = path.join(process.cwd(), filePath)
|
|
26
|
+
const fullPath = path.join(process.cwd(), filePath)
|
|
27
27
|
return readdirSync(path.dirname(fullPath)).includes(path.basename(fullPath))
|
|
28
28
|
} catch (error) {
|
|
29
29
|
console.error(`[miolo] Error checking if file exists: ${filePath}`, error)
|
|
30
30
|
return false
|
|
31
31
|
}
|
|
32
|
-
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export async function readJsonFile(jsonPath) {
|
|
35
|
+
try {
|
|
36
|
+
const data = await readFile(jsonPath)
|
|
37
|
+
const obj = JSON.parse(data)
|
|
38
|
+
return obj
|
|
39
|
+
} catch (err) {
|
|
40
|
+
console.error(`readJsonFile${jsonPath}`, err)
|
|
41
|
+
return {}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function readJsonFileSync(jsonPath, silent = false) {
|
|
46
|
+
try {
|
|
47
|
+
const data = readFileSync(jsonPath, { encoding: "utf8", flag: "r" })
|
|
48
|
+
const obj = JSON.parse(data)
|
|
49
|
+
return obj
|
|
50
|
+
} catch (err) {
|
|
51
|
+
if (!silent) {
|
|
52
|
+
console.error(`readJsonFileSync${jsonPath}`, err)
|
|
53
|
+
}
|
|
54
|
+
return {}
|
|
55
|
+
}
|
|
56
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "miolo",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.210",
|
|
4
4
|
"description": "all-in-one koa-based server",
|
|
5
5
|
"author": "Donato Lorenzo <donato@afialapis.com>",
|
|
6
6
|
"contributors": [
|
|
@@ -15,71 +15,91 @@
|
|
|
15
15
|
},
|
|
16
16
|
"homepage": "https://www.afialapis.com/os/miolo",
|
|
17
17
|
"license": "MIT",
|
|
18
|
+
"type": "module",
|
|
18
19
|
"bin": {
|
|
19
20
|
"miolo": "./bin/index.mjs"
|
|
20
21
|
},
|
|
21
|
-
"
|
|
22
|
+
"main": "./src/index.mjs",
|
|
22
23
|
"exports": {
|
|
23
|
-
"node": "./src/index.mjs",
|
|
24
|
+
"node": "./src/index.mjs",
|
|
24
25
|
"import": "./src/index.mjs",
|
|
25
|
-
"default": "./
|
|
26
|
+
"default": "./src/index.mjs"
|
|
26
27
|
},
|
|
27
28
|
"files": [
|
|
28
29
|
"bin",
|
|
29
|
-
"src"
|
|
30
|
+
"src",
|
|
31
|
+
"template",
|
|
32
|
+
"template/.env",
|
|
33
|
+
"template/.env.production",
|
|
34
|
+
"template/.editorconfig",
|
|
35
|
+
"template/.agent",
|
|
36
|
+
"package.json"
|
|
30
37
|
],
|
|
31
38
|
"scripts": {
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"
|
|
39
|
+
"lint": "biome check ./src ./bin --reporter=github",
|
|
40
|
+
"lint:fix": "biome check --write ./src ./bin --reporter=github",
|
|
41
|
+
"reset": "rm -fr package-lock.json npm-lock.yaml && npm i",
|
|
42
|
+
"prepare-template": "node bin/create/prepare-template.mjs",
|
|
43
|
+
"dist": "npm run prepare-template",
|
|
44
|
+
"prepublishOnly": "npm run lint && npm run dist"
|
|
37
45
|
},
|
|
38
46
|
"dependencies": {
|
|
39
|
-
"@babel/plugin-proposal-decorators": "^7.
|
|
40
|
-
"@
|
|
41
|
-
"@
|
|
47
|
+
"@babel/plugin-proposal-decorators": "^7.29.7",
|
|
48
|
+
"@babel/preset-env": "^7.29.7",
|
|
49
|
+
"@babel/preset-react": "^7.29.7",
|
|
50
|
+
"@dotenvx/dotenvx": "^1.75.0",
|
|
51
|
+
"@koa/bodyparser": "^6.1.0",
|
|
42
52
|
"@koa/cors": "^5.0.0",
|
|
43
|
-
"@koa/router": "^
|
|
44
|
-
"@maxmind/geoip2-node": "^6.
|
|
45
|
-
"@
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"
|
|
53
|
+
"@koa/router": "^15.6.0",
|
|
54
|
+
"@maxmind/geoip2-node": "^6.3.4",
|
|
55
|
+
"@rollup/plugin-alias": "^6.0.0",
|
|
56
|
+
"@rollup/plugin-babel": "^7.1.0",
|
|
57
|
+
"@rollup/plugin-commonjs": "^29.0.3",
|
|
58
|
+
"@rollup/plugin-json": "^6.1.0",
|
|
59
|
+
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
60
|
+
"@rollup/plugin-replace": "^6.0.3",
|
|
61
|
+
"@tailwindcss/postcss": "^4.3.1",
|
|
62
|
+
"@tailwindcss/vite": "^4.3.1",
|
|
63
|
+
"@vitejs/plugin-react": "^6.0.2",
|
|
64
|
+
"autoprefixer": "^10.5.0",
|
|
65
|
+
"cacheiro": "^0.5.0-beta.11",
|
|
66
|
+
"calustra": "^1.0.0-beta.14",
|
|
67
|
+
"cron": "^4.4.0",
|
|
49
68
|
"deepmerge": "^4.3.1",
|
|
50
69
|
"diskspace": "^2.0.0",
|
|
51
70
|
"http-terminator": "^3.2.0",
|
|
52
|
-
"intre": "^
|
|
71
|
+
"intre": "^3.0.0-beta.4",
|
|
72
|
+
"is-plain-object": "^5.0.0",
|
|
73
|
+
"joi": "^18.2.3",
|
|
53
74
|
"jwt-simple": "^0.5.6",
|
|
54
|
-
"koa": "^3.
|
|
55
|
-
"koa-compress": "^5.
|
|
56
|
-
"koa-connect": "^2.1.
|
|
75
|
+
"koa": "^3.2.1",
|
|
76
|
+
"koa-compress": "^5.2.2",
|
|
77
|
+
"koa-connect": "^2.1.1",
|
|
57
78
|
"koa-favicon": "^2.1.0",
|
|
58
79
|
"koa-mount": "^4.2.0",
|
|
59
80
|
"koa-passport": "^6.0.0",
|
|
60
81
|
"koa-proxies": "^0.12.4",
|
|
61
82
|
"koa-ratelimit": "^6.0.0",
|
|
62
83
|
"koa-session": "^7.0.2",
|
|
63
|
-
"koa-socket-2": "^2.0.0",
|
|
64
84
|
"koa-static": "^5.0.0",
|
|
65
|
-
"
|
|
85
|
+
"nanoid": "^5.1.15",
|
|
86
|
+
"nodemailer": "^9.0.1",
|
|
87
|
+
"passport-google-oauth20": "^2.0.0",
|
|
66
88
|
"passport-local": "^1.0.0",
|
|
67
|
-
"
|
|
68
|
-
"
|
|
89
|
+
"rollup": "^4.62.2",
|
|
90
|
+
"rollup-plugin-node-externals": "^9.0.1",
|
|
91
|
+
"rollup-plugin-postcss": "^4.0.2",
|
|
92
|
+
"socket.io": "^4.8.3",
|
|
93
|
+
"socket.io-client": "^4.8.3",
|
|
94
|
+
"statuses": "^2.0.2",
|
|
95
|
+
"tailwindcss": "^4.3.1",
|
|
69
96
|
"tinguir": "^0.0.7",
|
|
70
|
-
"vite": "^
|
|
71
|
-
"winston": "^3.
|
|
97
|
+
"vite": "^8.0.16",
|
|
98
|
+
"winston": "^3.19.0",
|
|
72
99
|
"winston-daily-rotate-file": "^5.0.0",
|
|
73
100
|
"yargs-parser": "^22.0.0"
|
|
74
101
|
},
|
|
75
|
-
"
|
|
76
|
-
"
|
|
77
|
-
"node-fetch": "^3.3.2",
|
|
78
|
-
"xeira": "^1.2.3"
|
|
79
|
-
},
|
|
80
|
-
"eslintConfig": {
|
|
81
|
-
"extends": [
|
|
82
|
-
"../../node_modules/xeira/configs/eslint.react.cjs"
|
|
83
|
-
]
|
|
102
|
+
"engines": {
|
|
103
|
+
"node": ">=24"
|
|
84
104
|
}
|
|
85
|
-
}
|
|
105
|
+
}
|