everything-dev 0.2.0 → 0.2.1

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/config.ts +14 -15
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "everything-dev",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "type": "module",
5
5
  "main": "src/index.ts",
6
6
  "exports": {
package/src/config.ts CHANGED
@@ -1,4 +1,6 @@
1
- import { dirname, join } from "path";
1
+ import { existsSync, readFileSync, statSync } from "node:fs";
2
+ import { access, readFile } from "node:fs/promises";
3
+ import { dirname, join } from "node:path";
2
4
  import type {
3
5
  AppConfig,
4
6
  BosConfig,
@@ -26,13 +28,8 @@ export function findConfigPath(startDir: string): string | null {
26
28
  let dir = startDir;
27
29
  while (dir !== "/") {
28
30
  const configPath = join(dir, "bos.config.json");
29
- if (Bun.file(configPath).size > 0) {
30
- try {
31
- Bun.file(configPath).text();
32
- return configPath;
33
- } catch {
34
- // File doesn't exist or can't be read
35
- }
31
+ if (existsSync(configPath) && statSync(configPath).size > 0) {
32
+ return configPath;
36
33
  }
37
34
  dir = dirname(dir);
38
35
  }
@@ -43,8 +40,7 @@ function findConfigPathSync(startDir: string): string | null {
43
40
  let dir = startDir;
44
41
  while (dir !== "/") {
45
42
  const configPath = join(dir, "bos.config.json");
46
- const file = Bun.file(configPath);
47
- if (file.size > 0) {
43
+ if (existsSync(configPath) && statSync(configPath).size > 0) {
48
44
  return configPath;
49
45
  }
50
46
  dir = dirname(dir);
@@ -196,9 +192,13 @@ export function getGatewayUrl(env: "development" | "production" = "development")
196
192
  return config.gateway[env];
197
193
  }
198
194
 
195
+ async function fileExists(path: string): Promise<boolean> {
196
+ return access(path).then(() => true).catch(() => false);
197
+ }
198
+
199
199
  export async function packageExists(pkg: string): Promise<boolean> {
200
200
  const dir = getConfigDir();
201
- return Bun.file(`${dir}/${pkg}/package.json`).exists();
201
+ return fileExists(`${dir}/${pkg}/package.json`);
202
202
  }
203
203
 
204
204
  export async function resolvePackageModes(
@@ -210,7 +210,7 @@ export async function resolvePackageModes(
210
210
  const autoRemote: string[] = [];
211
211
 
212
212
  for (const pkg of packages) {
213
- const exists = await Bun.file(`${dir}/${pkg}/package.json`).exists();
213
+ const exists = await fileExists(`${dir}/${pkg}/package.json`);
214
214
  const requestedMode = input[pkg] ?? "local";
215
215
 
216
216
  if (!exists && requestedMode === "local") {
@@ -230,7 +230,7 @@ export async function getExistingPackages(packages: string[]): Promise<{ existin
230
230
  const missing: string[] = [];
231
231
 
232
232
  for (const pkg of packages) {
233
- const exists = await Bun.file(`${dir}/${pkg}/package.json`).exists();
233
+ const exists = await fileExists(`${dir}/${pkg}/package.json`);
234
234
  if (exists) {
235
235
  existing.push(pkg);
236
236
  } else {
@@ -248,8 +248,7 @@ export async function loadBosConfig(
248
248
 
249
249
  let bosConfig: BosConfig;
250
250
  if (configPath) {
251
- const file = Bun.file(configPath);
252
- const text = await file.text();
251
+ const text = await readFile(configPath, "utf-8");
253
252
  bosConfig = JSON.parse(text) as BosConfig;
254
253
  } else {
255
254
  const config = loadConfig();