diff --git a/packages/cli/README.md b/packages/cli/README.md index 59e2f085..776722bb 100644 --- a/packages/cli/README.md +++ b/packages/cli/README.md @@ -1,13 +1,16 @@ # Bucket CLI -Command-line interface for interacting with Bucket services. The CLI allows you to manage apps, features, authentication, and generate TypeScript types for your Bucket features. With this tool, you can streamline your feature flagging workflow directly from your terminal. +Command-line interface for interacting with Bucket services. The CLI allows you to manage apps, +features, authentication, and generate TypeScript types for your Bucket features. With this tool, +you can streamline your feature flagging workflow directly from your terminal. ## Quick Start -Get started quickly by running the CLI directly: initializing the CLI, creating a feature, and generate the types all at once. +Get started quickly by running the CLI directly from your project's root directory: +initializing the CLI (if not already setup), creating a feature, and generate the types all at once. ```bash -# Initialize CLI (if not setup), create a feature, and generate types all at once +# Initialize CLI (if not already setup), create a feature, and generate types all at once npx @bucketco/cli new ``` @@ -33,7 +36,8 @@ yarn bucket new ### Global installation -You can also install the CLI globally adding the it to your PATH allowing you to use the shorthand `bucket` +You can also install the CLI globally adding the it to your PATH allowing you to use the shorthand `bucket`, +but we recommend installing it locally instead to better maintain the version. ```bash npm install -g @bucketco/cli @@ -58,7 +62,8 @@ bucket features types ## Configuration -The CLI creates a `bucket.config.json` file in your project directory when you run `bucket init`. This file contains all the necessary settings for your Bucket integration. +The CLI creates a `bucket.config.json` file in your project directory when you run `bucket init`. +This file contains all the necessary settings for your Bucket integration. ### Configuration File Structure @@ -95,7 +100,8 @@ You can override these settings using command-line options for individual comman ### `bucket init` -Initialize a new Bucket configuration in your project. This creates a `bucket.config.json` file with your settings and prompts for any required information not provided via options. +Initialize a new Bucket configuration in your project. +This creates a `bucket.config.json` file with your settings and prompts for any required information not provided via options. ```bash bucket init [--overwrite] @@ -109,7 +115,8 @@ Options: ### `bucket new [featureName]` -All-in-one command to get started quickly. This command combines `init`, feature creation, and type generation in a single step. Use this for the fastest way to get up and running with Bucket. +All-in-one command to get started quickly. This command combines `init`, feature creation, +and type generation in a single step. Use this for the fastest way to get up and running with Bucket. ```bash bucket new "My Feature" [--key my-feature] [--app-id ap123456789] [--key-format custom] [--out gen/features.ts] [--format react] @@ -147,7 +154,8 @@ Manage your Bucket features with the following subcommands. #### `bucket features create [featureName]` -Create a new feature in your Bucket app. The command guides you through the feature creation process with interactive prompts if options are not provided. +Create a new feature in your Bucket app. +The command guides you through the feature creation process with interactive prompts if options are not provided. ```bash bucket features create "My Feature" [--key my-feature] [--app-id ap123456789] [--key-format custom] @@ -161,7 +169,8 @@ Options: #### `bucket features list` -List all features for the current app. This helps you visualize what features are available and their current configurations. +List all features for the current app. +This helps you visualize what features are available and their current configurations. ```bash bucket features list [--app-id ap123456789] @@ -173,7 +182,8 @@ Options: #### `bucket features types` -Generate TypeScript types for your features. This ensures type safety when using Bucket features in your TypeScript/JavaScript applications. +Generate TypeScript types for your features. +This ensures type safety when using Bucket features in your TypeScript/JavaScript applications. ```bash bucket features types [--app-id ap123456789] [--out gen/features.ts] [--format react] diff --git a/packages/cli/commands/auth.ts b/packages/cli/commands/auth.ts index 55882a04..47a4b823 100644 --- a/packages/cli/commands/auth.ts +++ b/packages/cli/commands/auth.ts @@ -12,7 +12,7 @@ export const loginAction = async () => { const spinner = ora(`Logging in to ${chalk.cyan(baseUrl)}...`).start(); try { await authenticateUser(baseUrl); - spinner.succeed(`Logged in to ${chalk.cyan(baseUrl)} successfully! 🎉`); + spinner.succeed(`Logged in to ${chalk.cyan(baseUrl)} successfully!`); } catch (error) { spinner.fail("Login failed."); void handleError(error, "Login"); @@ -24,7 +24,7 @@ export const logoutAction = async () => { const spinner = ora("Logging out...").start(); try { await authStore.setToken(baseUrl, undefined); - spinner.succeed("Logged out successfully! 👋"); + spinner.succeed("Logged out successfully!"); } catch (error) { spinner.fail("Logout failed."); void handleError(error, "Logout"); diff --git a/packages/cli/commands/features.ts b/packages/cli/commands/features.ts index 739a3057..a6f4fed7 100644 --- a/packages/cli/commands/features.ts +++ b/packages/cli/commands/features.ts @@ -53,7 +53,7 @@ export const createFeatureAction = async ( const feature = await createFeature(appId, name, key); // todo: would like to link to feature here but we don't have the env id, only app id spinner.succeed( - `Created feature ${chalk.cyan(feature.name)} with key ${chalk.cyan(feature.key)} at ${chalk.cyan(baseUrl)}. 🎉`, + `Created feature ${chalk.cyan(feature.name)} with key ${chalk.cyan(feature.key)} at ${chalk.cyan(baseUrl)}.`, ); } catch (error) { spinner?.fail("Feature creation failed."); diff --git a/packages/cli/commands/init.ts b/packages/cli/commands/init.ts index 6b2688dc..80160230 100644 --- a/packages/cli/commands/init.ts +++ b/packages/cli/commands/init.ts @@ -6,7 +6,7 @@ import ora, { Ora } from "ora"; import { App, listApps } from "../services/bootstrap.js"; import { configStore, typeFormats } from "../stores/config.js"; -import { chalkBrand, DEFAULT_TYPES_OUTPUT } from "../utils/constants.js"; +import { DEFAULT_TYPES_OUTPUT } from "../utils/constants.js"; import { handleError } from "../utils/errors.js"; import { overwriteOption } from "../utils/options.js"; @@ -27,7 +27,7 @@ export const initAction = async (args: InitArgs = {}) => { ); } - console.log(chalkBrand("\nWelcome to Bucket! 🪣\n")); + console.log("\nWelcome to Bucket!\n"); const baseUrl = configStore.getConfig("baseUrl"); // Load apps diff --git a/packages/cli/index.ts b/packages/cli/index.ts index e95f568e..cc39c135 100755 --- a/packages/cli/index.ts +++ b/packages/cli/index.ts @@ -1,7 +1,6 @@ #!/usr/bin/env node 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"; @@ -54,10 +53,4 @@ async function main() { program.parse(process.argv); } -// Run the main function if this file is run directly and not imported -if ( - process.argv[1].endsWith(join("cli", "dist", "index.js")) || - process.argv[1].endsWith(join(".bin", "bucket")) -) { - void main(); -} +void main(); diff --git a/packages/cli/package.json b/packages/cli/package.json index e8639666..80999282 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "@bucketco/cli", - "version": "0.2.0", + "version": "0.2.1", "packageManager": "yarn@4.1.1", "description": "CLI for Bucket service", "main": "./dist/index.js", diff --git a/packages/cli/utils/constants.ts b/packages/cli/utils/constants.ts index 8d00b7bb..062bc0de 100644 --- a/packages/cli/utils/constants.ts +++ b/packages/cli/utils/constants.ts @@ -1,5 +1,4 @@ import { join } from "path"; -import chalk from "chalk"; export const CONFIG_FILE_NAME = "bucket.config.json"; export const AUTH_FILE = join( @@ -12,8 +11,6 @@ export const DEFAULT_BASE_URL = "https://app.bucket.co"; export const DEFAULT_API_URL = `${DEFAULT_BASE_URL}/api`; export const DEFAULT_TYPES_OUTPUT = join("gen", "features.ts"); -export const chalkBrand = chalk.hex("#847CFB"); - export const loginUrl = (baseUrl: string, localPort: number) => `${baseUrl}/login?redirect_url=` + encodeURIComponent("/cli-login?port=" + localPort);