fix(admin): monitoring review fixesc53ad032 months ago38 lines · 1.5 KB | 1 | import { readFileSync, readdirSync } from "node:fs"; |
| 2 | import { fileURLToPath } |
| 3 | import { join, dirname |
| 4 | |
| 5 | const web = join |
| 6 | const apiSrc = join |
| 7 | |
| 8 | const events = new |
| 9 | for (const f |
| 10 | if (!/\.ts |
| 11 | for (const m |
| 12 | events.add(m |
| 13 | } |
| 14 | } |
| 15 | |
| 16 | const gaps = [] |
| 17 | for (const file |
| 18 | const msgs = |
| 19 | const e = |
| 20 | if (!e) |
| 21 | if (typeof e. |
| 22 | for (const ev |
| 23 | const path = |
| 24 | const dot = |
| 25 | if (dot < |
| 26 | const resource = |
| 27 | const action = |
| 28 | if (!e.resource |
| 29 | if (!e.action |
| 30 | } |
| 31 | } |
| 32 | |
| 33 | if (gaps.length) |
| 34 | console.error(gaps |
| 35 | console.error(`\n |
| 36 | process.exit(1) |
| 37 | } |
| 38 | console.log(`activity i18n ok — ${ |
from
"
node:url
"
;
}
from
"
node:path
"
;
(
dirname
(
fileURLToPath
(
import
.
meta
.
url
))
,
"
..
"
)
;
(
web
,
"
..
"
,
"
..
"
,
"
packages
"
,
"
api
"
,
"
src
"
)
;
Set
()
;
of
readdirSync
(
apiSrc
,
{
recursive
:
true
}
))
{
$
/
.
test
(
f
))
continue
;
of
readFileSync
(
join
(
apiSrc
,
f
)
,
"
utf8
"
)
.
matchAll
(
/
"
(
admin:
[
a-z0-9
.
-
]
+
)
"
/
g
))
{
[
1
])
;
;
of
readdirSync
(
join
(
web
,
"
messages
"
)))
{
JSON
.
parse
(
readFileSync
(
join
(
web
,
"
messages
"
,
file
)
,
"
utf8
"
))
;
msgs
.
admin
?.
activity
?.
events
;
{
gaps
.
push
(
`
${
file
}
: missing admin.activity.events
`
)
;
continue
;
}
unknown
!==
"
string
"
)
gaps
.
push
(
`
${
file
}
: missing events.unknown
`
)
;
of
events
)
{
ev
.
replace
(
/
^
admin:
/
,
""
)
;
path
.
lastIndexOf
(
"
.
"
)
;
0
)
continue
;
path
.
slice
(
0
,
dot
)
.
replace
(
/
\.
/
g
,
"
_
"
)
;
path
.
slice
(
dot
+
1
)
;
?.
[
resource
])
gaps
.
push
(
`
${
file
}
: missing events.resource.
${
resource
}
(
${
ev
}
)
`
)
;
?.
[
action
])
gaps
.
push
(
`
${
file
}
: missing events.action.
${
action
}
(
${
ev
}
)
`
)
;
{
.
join
(
"
\n
"
))
;
${
gaps
.
length
}
untranslated activity event part(s).
`
)
;
;
events
.
size
}
admin event types resolve in all locales
`
)
;