@typed-assistant/builder 0.0.63 → 0.0.65
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 +4 -4
- package/src/appProcess.tsx +7 -15
- package/src/setupWebserver.tsx +2 -2
- package/src/webserver/Logs.tsx +3 -1
- package/src/webserver/Stats.tsx +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@typed-assistant/builder",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.65",
|
|
4
4
|
"exports": {
|
|
5
5
|
"./appProcess": "./src/appProcess.tsx",
|
|
6
6
|
"./bunInstall": "./src/bunInstall.tsx",
|
|
@@ -26,9 +26,9 @@
|
|
|
26
26
|
"ts-toolbelt": "^9.6.0",
|
|
27
27
|
"typescript": "^5.3.3",
|
|
28
28
|
"@typed-assistant/eslint-config": "0.0.9",
|
|
29
|
-
"@typed-assistant/
|
|
30
|
-
"@typed-assistant/
|
|
31
|
-
"@typed-assistant/
|
|
29
|
+
"@typed-assistant/typescript-config": "0.0.9",
|
|
30
|
+
"@typed-assistant/logger": "0.0.18",
|
|
31
|
+
"@typed-assistant/utils": "0.0.16"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|
|
34
34
|
"home-assistant-js-websocket": "^8.2.0"
|
package/src/appProcess.tsx
CHANGED
|
@@ -2,21 +2,20 @@ import { logger } from "@typed-assistant/logger"
|
|
|
2
2
|
import { generateTypes } from "@typed-assistant/types/generateTypes"
|
|
3
3
|
import type { Subprocess } from "bun"
|
|
4
4
|
import { $ } from "bun"
|
|
5
|
+
import debounce from "debounce"
|
|
5
6
|
import { readFileSync, watch } from "fs"
|
|
6
7
|
import ignore from "ignore"
|
|
7
8
|
import { join, relative } from "path"
|
|
9
|
+
import { getAddonInfo as getAddonInfoAPI } from "./getAddonInfo"
|
|
8
10
|
import {
|
|
9
11
|
addKillListener,
|
|
10
12
|
callKillListeners,
|
|
11
13
|
callSoftKillListeners,
|
|
12
14
|
killSubprocess,
|
|
13
15
|
} from "./killProcess"
|
|
16
|
+
import { restartAddon } from "./restartAddon"
|
|
14
17
|
import { setupGitPoller } from "./setupGitPoller"
|
|
15
|
-
import { setupWebhook } from "./setupWebhook"
|
|
16
18
|
import { startWebappServer } from "./setupWebserver"
|
|
17
|
-
import { restartAddon } from "./restartAddon"
|
|
18
|
-
import { getAddonInfo as getAddonInfoAPI } from "./getAddonInfo"
|
|
19
|
-
import debounce from "debounce"
|
|
20
19
|
|
|
21
20
|
export async function setup({
|
|
22
21
|
entryFile,
|
|
@@ -31,7 +30,6 @@ export async function setup({
|
|
|
31
30
|
const slug = addonInfo?.data.slug ?? ""
|
|
32
31
|
const directoryToWatch = join(process.cwd(), "./src")
|
|
33
32
|
const addonUrl = `${slug}/ingress`
|
|
34
|
-
const webhookUrl = `${process.env.HASS_EXTERNAL_URL}${basePath}/webhook`
|
|
35
33
|
|
|
36
34
|
let subprocesses = await buildAndStartAppProcess(entryFile, {
|
|
37
35
|
mdiPaths: mdiPaths,
|
|
@@ -76,7 +74,7 @@ export async function setup({
|
|
|
76
74
|
)
|
|
77
75
|
},
|
|
78
76
|
})
|
|
79
|
-
await setupGitSync(
|
|
77
|
+
await setupGitSync()
|
|
80
78
|
|
|
81
79
|
return subprocesses
|
|
82
80
|
}
|
|
@@ -166,7 +164,7 @@ const getAddonInfo = async () => {
|
|
|
166
164
|
return data
|
|
167
165
|
}
|
|
168
166
|
|
|
169
|
-
const setupGitSync = async (
|
|
167
|
+
const setupGitSync = async () => {
|
|
170
168
|
if (
|
|
171
169
|
!process.env.GITHUB_TOKEN ||
|
|
172
170
|
!process.env.GITHUB_USERNAME ||
|
|
@@ -178,14 +176,8 @@ const setupGitSync = async (webhookUrl: string) => {
|
|
|
178
176
|
)
|
|
179
177
|
return { error: {} }
|
|
180
178
|
}
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
return
|
|
184
|
-
}
|
|
185
|
-
logger.warn(
|
|
186
|
-
{ emoji: "⚠️" },
|
|
187
|
-
"No HASS_EXTERNAL_URL found. Setting up git poller...",
|
|
188
|
-
)
|
|
179
|
+
|
|
180
|
+
logger.warn({ emoji: "⬇️" }, "Setting up git poller...")
|
|
189
181
|
await setupGitPoller()
|
|
190
182
|
}
|
|
191
183
|
|
package/src/setupWebserver.tsx
CHANGED
|
@@ -92,13 +92,13 @@ const getStats = async () => {
|
|
|
92
92
|
? data.data.memory_usage
|
|
93
93
|
: stats.max_memory_usage,
|
|
94
94
|
}
|
|
95
|
-
logger.
|
|
95
|
+
logger.debug(
|
|
96
96
|
{ additionalDetails: JSON.stringify(stats, null, 2), emoji: "📊" },
|
|
97
97
|
"Stats updated",
|
|
98
98
|
)
|
|
99
99
|
}
|
|
100
100
|
|
|
101
|
-
setTimeout(getStats,
|
|
101
|
+
setTimeout(getStats, 10 * ONE_SECOND)
|
|
102
102
|
}
|
|
103
103
|
|
|
104
104
|
export const startWebappServer = async ({
|
package/src/webserver/Logs.tsx
CHANGED
|
@@ -94,7 +94,9 @@ export const Logs = ({ basePath }: { basePath: string }) => {
|
|
|
94
94
|
<ul>
|
|
95
95
|
{logs
|
|
96
96
|
.filter((log) => log.level >= (levels[level] ?? 0))
|
|
97
|
-
.sort(
|
|
97
|
+
.sort(
|
|
98
|
+
(a, b) => new Date(b.time).getTime() - new Date(a.time).getTime(),
|
|
99
|
+
)
|
|
98
100
|
.map((log) => {
|
|
99
101
|
return (
|
|
100
102
|
<li key={JSON.stringify(log)} className="flex gap-1">
|