diff --git a/packages/cli/index.ts b/packages/cli/index.ts index e4ad154a..d631643d 100755 --- a/packages/cli/index.ts +++ b/packages/cli/index.ts @@ -1,8 +1,7 @@ #!/usr/bin/env node -import { resolve } from "path"; -import { fileURLToPath } from "url"; import chalk from "chalk"; import { program } from "commander"; +import { join } from "node:path"; import { registerAppCommands } from "./commands/apps.js"; import { registerAuthCommands } from "./commands/auth.js"; @@ -52,6 +51,9 @@ async function main() { } // Run the main function if this file is run directly and not imported -if (resolve(fileURLToPath(import.meta.url)) === resolve(process.argv[1])) { +if ( + process.argv[1].endsWith(join("@bucketco", "cli", "dist", "index.js")) || + process.argv[1].endsWith(join(".bin", "bucket")) +) { void main(); } diff --git a/packages/cli/package.json b/packages/cli/package.json index 7e2c989e..e6190031 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "@bucketco/cli", - "version": "0.1.0", + "version": "0.1.1", "packageManager": "yarn@4.1.1", "description": "CLI for Bucket service", "main": "./dist/index.js", diff --git a/packages/cli/stores/config.ts b/packages/cli/stores/config.ts index cd4a978b..79ed927c 100644 --- a/packages/cli/stores/config.ts +++ b/packages/cli/stores/config.ts @@ -56,7 +56,10 @@ class ConfigStore { protected async createValidator() { try { - const schemaPath = await findUp("schema.json"); + const schemaPath = await findUp("schema.json", { + cwd: import.meta.url, + stopAt: "cli", + }); if (!schemaPath) return; const content = await readFile(schemaPath, "utf-8"); const parsed = JSON5.parse(content);