diff --git a/bin/shopq.ts b/bin/shopq.ts index 0fb3220..ec04157 100755 --- a/bin/shopq.ts +++ b/bin/shopq.ts @@ -1,4 +1,4 @@ -#!/usr/bin/env node +#!/usr/bin/env bun import "../src/commands/config"; import "../src/commands/gql"; diff --git a/package.json b/package.json index 8970893..92fe59c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "shopq", - "version": "0.3.8", + "version": "0.3.9", "description": "A zero-dependency Shopify Admin CLI built on Bun", "type": "module", "license": "MIT", @@ -12,7 +12,7 @@ "skills" ], "scripts": { - "build": "bun build bin/shopq.ts --target=node --outfile dist/shopq.js && chmod +x dist/shopq.js", + "build": "bun build bin/shopq.ts --target=bun --outfile dist/shopq.js && chmod +x dist/shopq.js", "prepublishOnly": "bun run build", "test": "bun test", "check": "bunx --bun biome check --write .", diff --git a/src/graphql.ts b/src/graphql.ts index 6a56c37..a05beb7 100644 --- a/src/graphql.ts +++ b/src/graphql.ts @@ -47,48 +47,12 @@ export class ConfigError extends Error { constructor(public missing: string[]) { super( `Missing required environment variables: ${missing.join(", ")}\n` + - `Set them in ~/.config/shopq/.env, a local .env file, or as environment variables.`, + `Set them in a .env file or as environment variables.`, ); this.name = "ConfigError"; } } -/** - * Load env vars from ~/.config/shopq/.env (XDG base dir convention), - * then let CWD .env and actual env vars override. - * This follows the pattern used by gh, vercel, railway, etc. - */ -function loadConfigEnv(): void { - const xdgConfig = - process.env.XDG_CONFIG_HOME || - `${process.env.HOME || require("os").homedir()}/.config`; - const configPath = `${xdgConfig}/shopq/.env`; - - try { - const content = require("fs").readFileSync(configPath, "utf-8") as string; - for (const line of content.split("\n")) { - const trimmed = line.trim(); - if (!trimmed || trimmed.startsWith("#")) continue; - const eqIdx = trimmed.indexOf("="); - if (eqIdx === -1) continue; - const key = trimmed.slice(0, eqIdx).trim(); - const value = trimmed - .slice(eqIdx + 1) - .trim() - .replace(/^["']|["']$/g, ""); - // Don't override existing env vars (CWD .env or real env take precedence) - if (!process.env[key]) { - process.env[key] = value; - } - } - } catch { - // Config file doesn't exist — that's fine - } -} - -// Load on module init -loadConfigEnv(); - export function resolveConfig(storeFlag?: string): { store: string; clientId: string;