diff --git a/.changeset/five-tomatoes-guess.md b/.changeset/five-tomatoes-guess.md new file mode 100644 index 0000000000..e1fd3244d2 --- /dev/null +++ b/.changeset/five-tomatoes-guess.md @@ -0,0 +1,6 @@ +--- +"@latticexyz/faucet": patch +"@latticexyz/store-indexer": patch +--- + +Added bin wrappers to resolve issues when installing the package locally as a dependency of another package. diff --git a/packages/faucet/bin/faucet-server.js b/packages/faucet/bin/faucet-server.js new file mode 100755 index 0000000000..7fd125216a --- /dev/null +++ b/packages/faucet/bin/faucet-server.js @@ -0,0 +1,3 @@ +#!/usr/bin/env node +// workaround for https://github.com/pnpm/pnpm/issues/1801 +import "../dist/bin/faucet-server.js"; diff --git a/packages/faucet/package.json b/packages/faucet/package.json index b52e35acc6..4221250252 100644 --- a/packages/faucet/package.json +++ b/packages/faucet/package.json @@ -10,19 +10,20 @@ "license": "MIT", "type": "module", "exports": { - ".": "./dist/src/index.js" + ".": "./dist/index.js" }, "typesVersions": { "*": { "index": [ - "./dist/src/index.d.ts" + "./dist/index.d.ts" ] } }, "bin": { - "faucet-server": "./dist/bin/faucet-server.js" + "faucet-server": "./bin/faucet-server.js" }, "files": [ + "bin", "dist" ], "scripts": { diff --git a/packages/faucet/bin/faucet-server.ts b/packages/faucet/src/bin/faucet-server.ts similarity index 94% rename from packages/faucet/bin/faucet-server.ts rename to packages/faucet/src/bin/faucet-server.ts index dbbd0ac73a..657a06c213 100644 --- a/packages/faucet/bin/faucet-server.ts +++ b/packages/faucet/src/bin/faucet-server.ts @@ -4,7 +4,7 @@ import fastify from "fastify"; import { fastifyTRPCPlugin } from "@trpc/server/adapters/fastify"; import { http, createClient } from "viem"; import { privateKeyToAccount } from "viem/accounts"; -import { AppRouter, createAppRouter } from "../src/createAppRouter"; +import { AppRouter, createAppRouter } from "../createAppRouter"; import { parseEnv } from "./parseEnv"; const env = parseEnv(); diff --git a/packages/faucet/bin/parseEnv.ts b/packages/faucet/src/bin/parseEnv.ts similarity index 100% rename from packages/faucet/bin/parseEnv.ts rename to packages/faucet/src/bin/parseEnv.ts diff --git a/packages/faucet/tsup.config.ts b/packages/faucet/tsup.config.ts index ff4fa8454b..5cd8ce1630 100644 --- a/packages/faucet/tsup.config.ts +++ b/packages/faucet/tsup.config.ts @@ -1,7 +1,7 @@ import { defineConfig } from "tsup"; export default defineConfig((opts) => ({ - entry: ["src/index.ts", "bin/faucet-server.ts"], + entry: ["src/index.ts", "src/bin/faucet-server.ts"], target: "esnext", format: ["esm"], sourcemap: true, diff --git a/packages/store-indexer/bin/postgres-decoded-indexer.js b/packages/store-indexer/bin/postgres-decoded-indexer.js new file mode 100755 index 0000000000..b74e6a37a6 --- /dev/null +++ b/packages/store-indexer/bin/postgres-decoded-indexer.js @@ -0,0 +1,3 @@ +#!/usr/bin/env node +// workaround for https://github.com/pnpm/pnpm/issues/1801 +import "../dist/bin/postgres-decoded-indexer.js"; diff --git a/packages/store-indexer/bin/postgres-frontend.js b/packages/store-indexer/bin/postgres-frontend.js new file mode 100755 index 0000000000..2411ed9286 --- /dev/null +++ b/packages/store-indexer/bin/postgres-frontend.js @@ -0,0 +1,3 @@ +#!/usr/bin/env node +// workaround for https://github.com/pnpm/pnpm/issues/1801 +import "../dist/bin/postgres-frontend.js"; diff --git a/packages/store-indexer/bin/postgres-indexer.js b/packages/store-indexer/bin/postgres-indexer.js new file mode 100755 index 0000000000..6d198d3d7f --- /dev/null +++ b/packages/store-indexer/bin/postgres-indexer.js @@ -0,0 +1,3 @@ +#!/usr/bin/env node +// workaround for https://github.com/pnpm/pnpm/issues/1801 +import "../dist/bin/postgres-indexer.js"; diff --git a/packages/store-indexer/bin/sqlite-indexer.js b/packages/store-indexer/bin/sqlite-indexer.js new file mode 100755 index 0000000000..ce4ad37075 --- /dev/null +++ b/packages/store-indexer/bin/sqlite-indexer.js @@ -0,0 +1,3 @@ +#!/usr/bin/env node +// workaround for https://github.com/pnpm/pnpm/issues/1801 +import "../dist/bin/sqlite-indexer.js"; diff --git a/packages/store-indexer/package.json b/packages/store-indexer/package.json index 41e869f3e5..26e5dc2e02 100644 --- a/packages/store-indexer/package.json +++ b/packages/store-indexer/package.json @@ -15,17 +15,18 @@ "typesVersions": { "*": { "index": [ - "./dist/src/index.d.ts" + "./dist/index.d.ts" ] } }, "bin": { - "postgres-decoded-indexer": "./dist/bin/postgres-decoded-indexer.js", - "postgres-frontend": "./dist/bin/postgres-frontend.js", - "postgres-indexer": "./dist/bin/postgres-indexer.js", - "sqlite-indexer": "./dist/bin/sqlite-indexer.js" + "postgres-decoded-indexer": "./bin/postgres-decoded-indexer.js", + "postgres-frontend": "./bin/postgres-frontend.js", + "postgres-indexer": "./bin/postgres-indexer.js", + "sqlite-indexer": "./bin/sqlite-indexer.js" }, "files": [ + "bin", "dist" ], "scripts": { diff --git a/packages/store-indexer/bin/parseEnv.ts b/packages/store-indexer/src/bin/parseEnv.ts similarity index 100% rename from packages/store-indexer/bin/parseEnv.ts rename to packages/store-indexer/src/bin/parseEnv.ts diff --git a/packages/store-indexer/bin/postgres-decoded-indexer.ts b/packages/store-indexer/src/bin/postgres-decoded-indexer.ts similarity index 94% rename from packages/store-indexer/bin/postgres-decoded-indexer.ts rename to packages/store-indexer/src/bin/postgres-decoded-indexer.ts index 70bce8a446..ed1c9a3dc9 100644 --- a/packages/store-indexer/bin/postgres-decoded-indexer.ts +++ b/packages/store-indexer/src/bin/postgres-decoded-indexer.ts @@ -10,9 +10,9 @@ import postgres from "postgres"; import { createStorageAdapter } from "@latticexyz/store-sync/postgres-decoded"; import { createStoreSync } from "@latticexyz/store-sync"; import { indexerEnvSchema, parseEnv } from "./parseEnv"; -import { sentry } from "../src/koa-middleware/sentry"; -import { healthcheck } from "../src/koa-middleware/healthcheck"; -import { helloWorld } from "../src/koa-middleware/helloWorld"; +import { sentry } from "../koa-middleware/sentry"; +import { healthcheck } from "../koa-middleware/healthcheck"; +import { helloWorld } from "../koa-middleware/helloWorld"; const env = parseEnv( z.intersection( diff --git a/packages/store-indexer/bin/postgres-frontend.ts b/packages/store-indexer/src/bin/postgres-frontend.ts similarity index 76% rename from packages/store-indexer/bin/postgres-frontend.ts rename to packages/store-indexer/src/bin/postgres-frontend.ts index f54651c6df..bd6c868864 100644 --- a/packages/store-indexer/bin/postgres-frontend.ts +++ b/packages/store-indexer/src/bin/postgres-frontend.ts @@ -8,12 +8,12 @@ import { createAppRouter } from "@latticexyz/store-sync/trpc-indexer"; import { drizzle } from "drizzle-orm/postgres-js"; import postgres from "postgres"; import { frontendEnvSchema, parseEnv } from "./parseEnv"; -import { createQueryAdapter } from "../src/postgres/deprecated/createQueryAdapter"; -import { apiRoutes } from "../src/postgres/apiRoutes"; -import { sentry } from "../src/koa-middleware/sentry"; -import { healthcheck } from "../src/koa-middleware/healthcheck"; -import { helloWorld } from "../src/koa-middleware/helloWorld"; -import { metrics } from "../src/koa-middleware/metrics"; +import { createQueryAdapter } from "../postgres/deprecated/createQueryAdapter"; +import { apiRoutes } from "../postgres/apiRoutes"; +import { sentry } from "../koa-middleware/sentry"; +import { healthcheck } from "../koa-middleware/healthcheck"; +import { helloWorld } from "../koa-middleware/helloWorld"; +import { metrics } from "../koa-middleware/metrics"; const env = parseEnv( z.intersection( diff --git a/packages/store-indexer/bin/postgres-indexer.ts b/packages/store-indexer/src/bin/postgres-indexer.ts similarity index 95% rename from packages/store-indexer/bin/postgres-indexer.ts rename to packages/store-indexer/src/bin/postgres-indexer.ts index 2e92ef3fdd..8508ee3eef 100644 --- a/packages/store-indexer/bin/postgres-indexer.ts +++ b/packages/store-indexer/src/bin/postgres-indexer.ts @@ -108,9 +108,9 @@ combineLatest([latestBlockNumber$, storedBlockLogs$]) if (env.HEALTHCHECK_HOST != null || env.HEALTHCHECK_PORT != null) { const { default: Koa } = await import("koa"); const { default: cors } = await import("@koa/cors"); - const { healthcheck } = await import("../src/koa-middleware/healthcheck"); - const { metrics } = await import("../src/koa-middleware/metrics"); - const { helloWorld } = await import("../src/koa-middleware/helloWorld"); + const { healthcheck } = await import("../koa-middleware/healthcheck"); + const { metrics } = await import("../koa-middleware/metrics"); + const { helloWorld } = await import("../koa-middleware/helloWorld"); const server = new Koa(); diff --git a/packages/store-indexer/bin/sqlite-indexer.ts b/packages/store-indexer/src/bin/sqlite-indexer.ts similarity index 93% rename from packages/store-indexer/bin/sqlite-indexer.ts rename to packages/store-indexer/src/bin/sqlite-indexer.ts index e2198cbec6..0416ffd4a0 100644 --- a/packages/store-indexer/bin/sqlite-indexer.ts +++ b/packages/store-indexer/src/bin/sqlite-indexer.ts @@ -11,15 +11,15 @@ import cors from "@koa/cors"; import { createKoaMiddleware } from "trpc-koa-adapter"; import { createAppRouter } from "@latticexyz/store-sync/trpc-indexer"; import { chainState, schemaVersion, syncToSqlite } from "@latticexyz/store-sync/sqlite"; -import { createQueryAdapter } from "../src/sqlite/createQueryAdapter"; +import { createQueryAdapter } from "../sqlite/createQueryAdapter"; import { isDefined } from "@latticexyz/common/utils"; import { combineLatest, filter, first } from "rxjs"; import { frontendEnvSchema, indexerEnvSchema, parseEnv } from "./parseEnv"; -import { healthcheck } from "../src/koa-middleware/healthcheck"; -import { helloWorld } from "../src/koa-middleware/helloWorld"; -import { apiRoutes } from "../src/sqlite/apiRoutes"; -import { sentry } from "../src/koa-middleware/sentry"; -import { metrics } from "../src/koa-middleware/metrics"; +import { healthcheck } from "../koa-middleware/healthcheck"; +import { helloWorld } from "../koa-middleware/helloWorld"; +import { apiRoutes } from "../sqlite/apiRoutes"; +import { sentry } from "../koa-middleware/sentry"; +import { metrics } from "../koa-middleware/metrics"; const env = parseEnv( z.intersection( diff --git a/packages/store-indexer/src/koa-middleware/sentry.ts b/packages/store-indexer/src/koa-middleware/sentry.ts index e8999dffcd..7d6a9c482d 100644 --- a/packages/store-indexer/src/koa-middleware/sentry.ts +++ b/packages/store-indexer/src/koa-middleware/sentry.ts @@ -1,7 +1,7 @@ import * as Sentry from "@sentry/node"; import { ProfilingIntegration } from "@sentry/profiling-node"; import { stripUrlQueryAndFragment } from "@sentry/utils"; -import debug from "debug"; +import { debug } from "../debug"; import Koa from "koa"; import compose from "koa-compose"; diff --git a/packages/store-indexer/tsup.config.ts b/packages/store-indexer/tsup.config.ts index bd0464e7fc..ab84c8d956 100644 --- a/packages/store-indexer/tsup.config.ts +++ b/packages/store-indexer/tsup.config.ts @@ -3,10 +3,10 @@ import { defineConfig } from "tsup"; export default defineConfig((opts) => ({ entry: [ "src/index.ts", - "bin/postgres-frontend.ts", - "bin/postgres-indexer.ts", - "bin/postgres-decoded-indexer.ts", - "bin/sqlite-indexer.ts", + "src/bin/postgres-frontend.ts", + "src/bin/postgres-indexer.ts", + "src/bin/postgres-decoded-indexer.ts", + "src/bin/sqlite-indexer.ts", ], target: "esnext", format: ["esm"],