@typed-assistant/builder 0.0.39 → 0.0.40
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 +1 -1
- package/src/appProcess.tsx +3 -3
- package/src/setupWebhook.tsx +19 -0
- package/src/setupWebserver.tsx +12 -2
package/package.json
CHANGED
package/src/appProcess.tsx
CHANGED
|
@@ -32,9 +32,6 @@ export async function setup({
|
|
|
32
32
|
const directoryToWatch = join(process.cwd(), "./src")
|
|
33
33
|
const addonUrl = `${slug}/ingress`
|
|
34
34
|
|
|
35
|
-
checkProcesses(entryFile, { addonUrl, onProcessError })
|
|
36
|
-
await setupGitSync()
|
|
37
|
-
|
|
38
35
|
let subprocesses = await buildAndStartAppProcess(entryFile, {
|
|
39
36
|
mdiPaths: mdiPaths,
|
|
40
37
|
})
|
|
@@ -53,6 +50,9 @@ export async function setup({
|
|
|
53
50
|
getSubprocesses: () => subprocesses,
|
|
54
51
|
})
|
|
55
52
|
|
|
53
|
+
checkProcesses(entryFile, { addonUrl, onProcessError })
|
|
54
|
+
await setupGitSync()
|
|
55
|
+
|
|
56
56
|
return subprocesses
|
|
57
57
|
}
|
|
58
58
|
|
package/src/setupWebhook.tsx
CHANGED
|
@@ -13,6 +13,23 @@ const commonOptions = {
|
|
|
13
13
|
},
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
+
const webhookIsSetup = async () => {
|
|
17
|
+
const { error } = await fetch(webhookUrl, {
|
|
18
|
+
...commonOptions,
|
|
19
|
+
body: JSON.stringify({ check: "true" }),
|
|
20
|
+
})
|
|
21
|
+
.then(handleFetchError)
|
|
22
|
+
.then((d) => d.json())
|
|
23
|
+
|
|
24
|
+
if (error) {
|
|
25
|
+
logger.error("🚨 Failed to reach webhook", error.message)
|
|
26
|
+
return false
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
logger.info("🪝 Webhook reached successfully: ")
|
|
30
|
+
return true
|
|
31
|
+
}
|
|
32
|
+
|
|
16
33
|
const listRepoWebhooks = async () =>
|
|
17
34
|
withErrorHandling(() =>
|
|
18
35
|
fetch(
|
|
@@ -125,6 +142,8 @@ export const setupWebhook = async (): Promise<void> => {
|
|
|
125
142
|
return
|
|
126
143
|
}
|
|
127
144
|
|
|
145
|
+
await webhookIsSetup()
|
|
146
|
+
|
|
128
147
|
const { data: webhook, error: createError } = await createRepoWebhook()
|
|
129
148
|
|
|
130
149
|
if (createError) {
|
package/src/setupWebserver.tsx
CHANGED
|
@@ -110,6 +110,18 @@ export const startWebappServer = async ({
|
|
|
110
110
|
restartAddon()
|
|
111
111
|
return { message: "Restarting addon..." }
|
|
112
112
|
})
|
|
113
|
+
.get(
|
|
114
|
+
"/webhook",
|
|
115
|
+
async ({ query }) => {
|
|
116
|
+
if (query.check === "true") return { message: "Set up successfully" }
|
|
117
|
+
return { message: "Restarting addon..." }
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
query: t.Object({
|
|
121
|
+
check: t.Optional(t.Literal("true")),
|
|
122
|
+
}),
|
|
123
|
+
},
|
|
124
|
+
)
|
|
113
125
|
.get("/addon-info", async () => {
|
|
114
126
|
const { data, error } = await getAddonInfo()
|
|
115
127
|
|
|
@@ -138,7 +150,6 @@ export const startWebappServer = async ({
|
|
|
138
150
|
}),
|
|
139
151
|
response: t.Object({ logs: t.Array(t.String()) }),
|
|
140
152
|
async open(ws) {
|
|
141
|
-
console.log("😅😅😅 ~ ws.data.query.limit:", ws.data.query.limit)
|
|
142
153
|
ws.send(await getLogsFromFile(ws.data.query.limit))
|
|
143
154
|
logSubscribers.set(ws.id, async () => {
|
|
144
155
|
ws.send(await getLogsFromFile(ws.data.query.limit))
|
|
@@ -226,7 +237,6 @@ export const startWebappServer = async ({
|
|
|
226
237
|
export type WebServer = Awaited<ReturnType<typeof startWebappServer>>
|
|
227
238
|
|
|
228
239
|
const getLogsFromFile = async (limit?: string) => {
|
|
229
|
-
console.log("😅😅😅 ~ limit:", limit)
|
|
230
240
|
try {
|
|
231
241
|
const lines = (await Bun.file("./log.txt").text()).split("\n")
|
|
232
242
|
const logFile = limit
|