Skip to content

Commit

Permalink
fix(faucet,store-indexer): add bin wrappers (#3296)
Browse files Browse the repository at this point in the history
  • Loading branch information
holic authored Oct 16, 2024
1 parent 41a6e2f commit 20f44fb
Show file tree
Hide file tree
Showing 18 changed files with 56 additions and 33 deletions.
6 changes: 6 additions & 0 deletions .changeset/five-tomatoes-guess.md
Original file line number Diff line number Diff line change
@@ -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.
3 changes: 3 additions & 0 deletions packages/faucet/bin/faucet-server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env node
// workaround for https://github.com/pnpm/pnpm/issues/1801
import "../dist/bin/faucet-server.js";
7 changes: 4 additions & 3 deletions packages/faucet/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion packages/faucet/tsup.config.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
3 changes: 3 additions & 0 deletions packages/store-indexer/bin/postgres-decoded-indexer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env node
// workaround for https://github.com/pnpm/pnpm/issues/1801
import "../dist/bin/postgres-decoded-indexer.js";
3 changes: 3 additions & 0 deletions packages/store-indexer/bin/postgres-frontend.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env node
// workaround for https://github.com/pnpm/pnpm/issues/1801
import "../dist/bin/postgres-frontend.js";
3 changes: 3 additions & 0 deletions packages/store-indexer/bin/postgres-indexer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env node
// workaround for https://github.com/pnpm/pnpm/issues/1801
import "../dist/bin/postgres-indexer.js";
3 changes: 3 additions & 0 deletions packages/store-indexer/bin/sqlite-indexer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env node
// workaround for https://github.com/pnpm/pnpm/issues/1801
import "../dist/bin/sqlite-indexer.js";
11 changes: 6 additions & 5 deletions packages/store-indexer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion packages/store-indexer/src/koa-middleware/sentry.ts
Original file line number Diff line number Diff line change
@@ -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";

Expand Down
8 changes: 4 additions & 4 deletions packages/store-indexer/tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
Expand Down

0 comments on commit 20f44fb

Please sign in to comment.