@typed-assistant/builder 0.0.72 → 0.0.74

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,6 +1,6 @@
1
1
  {
2
2
  "name": "@typed-assistant/builder",
3
- "version": "0.0.72",
3
+ "version": "0.0.74",
4
4
  "exports": {
5
5
  "./appProcess": "./src/appProcess.tsx",
6
6
  "./bunInstall": "./src/bunInstall.tsx",
@@ -26,8 +26,8 @@
26
26
  "typescript": "^5.3.3",
27
27
  "@typed-assistant/eslint-config": "0.0.10",
28
28
  "@typed-assistant/logger": "0.0.21",
29
- "@typed-assistant/typescript-config": "0.0.10",
30
- "@typed-assistant/utils": "0.0.18"
29
+ "@typed-assistant/utils": "0.0.18",
30
+ "@typed-assistant/typescript-config": "0.0.10"
31
31
  },
32
32
  "peerDependencies": {},
33
33
  "publishConfig": {
@@ -74,7 +74,15 @@ export async function setup({
74
74
  )
75
75
  },
76
76
  })
77
- await setupGitSync()
77
+ await setupGitSync({
78
+ onChangesPulled: async () => {
79
+ subprocesses = await killAndRestartApp(
80
+ entryFile,
81
+ { mdiPaths },
82
+ subprocesses,
83
+ )
84
+ },
85
+ })
78
86
 
79
87
  return subprocesses
80
88
  }
@@ -92,9 +100,9 @@ async function buildAndStartAppProcess(
92
100
  async function startApp(appSourceFile: string) {
93
101
  logger.info({ emoji: "🚀" }, "Starting app...")
94
102
  const path = join(process.cwd(), appSourceFile)
95
- return Bun.spawn(["bun", path], {
103
+ return Bun.spawn(["bun", "--bun", path], {
96
104
  stderr: "pipe",
97
- env: { ...process.env, FORCE_COLOR: "1" },
105
+ env: { ...process.env, FORCE_COLOR: "1", NODE_ENV: "production" },
98
106
  })
99
107
  }
100
108
 
@@ -164,7 +172,11 @@ const getAddonInfo = async () => {
164
172
  return data
165
173
  }
166
174
 
167
- const setupGitSync = async () => {
175
+ const setupGitSync = async ({
176
+ onChangesPulled,
177
+ }: {
178
+ onChangesPulled: () => void
179
+ }) => {
168
180
  if (
169
181
  !process.env.GITHUB_TOKEN ||
170
182
  !process.env.GITHUB_USERNAME ||
@@ -178,7 +190,7 @@ const setupGitSync = async () => {
178
190
  }
179
191
 
180
192
  logger.warn({ emoji: "⬇️" }, "Setting up git poller...")
181
- await setupGitPoller()
193
+ await setupGitPoller({ onChangesPulled })
182
194
  }
183
195
 
184
196
  const ig = ignore().add(
@@ -2,7 +2,11 @@ import { logger } from "@typed-assistant/logger"
2
2
  import { $ } from "bun"
3
3
  import { bunInstall } from "./bunInstall"
4
4
 
5
- export const pullChanges = async () => {
5
+ export const pullChanges = async ({
6
+ onChangesPulled,
7
+ }: {
8
+ onChangesPulled: () => void
9
+ }) => {
6
10
  logger.debug({ emoji: "⬇️" }, "Pulling changes...")
7
11
  const { exitCode, stderr, stdout } = await $`git pull`.quiet()
8
12
  if (exitCode) {
@@ -19,11 +23,12 @@ export const pullChanges = async () => {
19
23
  logger.debug({ emoji: "⬇️👌" }, "No new changes.")
20
24
  return {}
21
25
  } else {
26
+ if (packageJSONUpdated) {
27
+ logger.info({ emoji: "⬇️📦" }, "package.json updated.")
28
+ await bunInstall()
29
+ }
22
30
  logger.info({ emoji: "⬇️🆕" }, "Changes pulled.")
23
- }
24
- if (packageJSONUpdated) {
25
- logger.info({ emoji: "⬇️📦" }, "package.json updated.")
26
- await bunInstall()
31
+ onChangesPulled()
27
32
  }
28
33
  return {}
29
34
  }
@@ -4,18 +4,20 @@ import { pullChanges } from "./pullChanges"
4
4
 
5
5
  export const setupGitPoller = async ({
6
6
  gitPullPollDuration,
7
+ onChangesPulled,
7
8
  }: {
8
9
  /** Duration in seconds */
9
10
  gitPullPollDuration?: number
10
- } = {}) => {
11
+ onChangesPulled: () => void
12
+ }) => {
11
13
  const duration = gitPullPollDuration ?? 30
12
- await pullChanges()
14
+ await pullChanges({ onChangesPulled })
13
15
  logger.debug(
14
16
  { emoji: "⬇️⏳" },
15
17
  `Pulling changes again in ${duration} seconds...`,
16
18
  )
17
19
 
18
20
  setTimeout(() => {
19
- setupGitPoller({ gitPullPollDuration })
21
+ setupGitPoller({ gitPullPollDuration, onChangesPulled })
20
22
  }, duration * ONE_SECOND)
21
23
  }