Skip to content

Commit ec5b775

Browse files
authored
Merge branch 'main' into new-oauthish-login
2 parents dcbf037 + 340b21f commit ec5b775

17 files changed

Lines changed: 83 additions & 77 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ lerna-debug.log*
99
coverage
1010

1111
node_modules
12+
gen
1213
dist
1314
dist-ssr
1415
*.local

packages/browser-sdk/README.md

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,42 @@ If you are not using the Bucket Browser SDK, you can still submit feedback using
270270

271271
See details in [Feedback HTTP API](https://docs.bucket.co/reference/http-tracking-api#feedback)
272272

273+
## Toolbar
274+
275+
The Bucket Toolbar is great for toggling features on/off for yourself to ensure that everything works both when a feature is on and when it's off.
276+
277+
<img width="352" alt="Toolbar screenshot" src="https://github.com/user-attachments/assets/c223df5a-4bd8-49a1-8b4a-ad7001357693" />
278+
279+
The toolbar will automatically appear on `localhost`. However, it can also be incredibly useful in production.
280+
You have full control over when it appears through the `toolbar` configuration option passed to the `BucketClient`.
281+
282+
You can pass a simple boolean to force the toolbar to appear/disappear:
283+
284+
```typescript
285+
const client = new BucketClient({
286+
// show the toolbar even in production if the user is an internal/admin user
287+
toolbar: user?.isInternal,
288+
...
289+
});
290+
```
291+
292+
You can also configure the position of the toolbar on the screen:
293+
294+
```typescript
295+
const client = new BucketClient({
296+
toolbar: {
297+
show: true;
298+
position: {
299+
placement: "bottom-left",
300+
offset: {x: "1rem", y: "1rem"}
301+
}
302+
}
303+
...
304+
})
305+
```
306+
307+
See [the reference](https://docs.bucket.co/supported-languages/browser-sdk/globals#toolbaroptions) for details.
308+
273309
## Event listeners
274310

275311
Event listeners allow for capturing various events occurring in the `BucketClient`. This is useful to build integrations with other system or for various debugging purposes. There are 5 kinds of events:
@@ -290,7 +326,7 @@ const client = new BucketClient({
290326
});
291327

292328
// or add the hooks after construction:
293-
const unsub = client.on("enabledCheck", (check: CheckEvent) =>
329+
const unsub = client.on("check", (check: CheckEvent) =>
294330
console.log(`Check event ${check}`),
295331
);
296332
// use the returned function to unsubscribe, or call `off()` with the same arguments again

packages/browser-sdk/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@bucketco/browser-sdk",
3-
"version": "3.1.1",
3+
"version": "3.1.2",
44
"packageManager": "yarn@4.1.1",
55
"license": "MIT",
66
"repository": {

packages/browser-sdk/src/toolbar/Toolbar.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@
106106
calc(100vh - 36px - 35px),
107107
calc(45px + (var(--visible-features) * 27px))
108108
);
109+
height: auto;
109110

110111
&[open] {
111112
display: flex;

packages/cli/README.md

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
# Bucket CLI
22

3-
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.
3+
Command-line interface for interacting with Bucket services. The CLI allows you to manage apps,
4+
features, authentication, and generate TypeScript types for your Bucket features. With this tool,
5+
you can streamline your feature flagging workflow directly from your terminal.
46

57
## Quick Start
68

7-
Get started quickly by running the CLI directly: initializing the CLI, creating a feature, and generate the types all at once.
9+
Get started quickly by running the CLI directly from your project's root directory:
10+
initializing the CLI (if not already setup), creating a feature, and generate the types all at once.
811

912
```bash
10-
# Initialize CLI (if not setup), create a feature, and generate types all at once
13+
# Initialize CLI (if not already setup), create a feature, and generate types all at once
1114
npx @bucketco/cli new
1215
```
1316

@@ -33,7 +36,8 @@ yarn bucket new
3336

3437
### Global installation
3538

36-
You can also install the CLI globally adding the it to your PATH allowing you to use the shorthand `bucket`
39+
You can also install the CLI globally adding the it to your PATH allowing you to use the shorthand `bucket`,
40+
but we recommend installing it locally instead to better maintain the version.
3741

3842
```bash
3943
npm install -g @bucketco/cli
@@ -58,7 +62,8 @@ bucket features types
5862

5963
## Configuration
6064

61-
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.
65+
The CLI creates a `bucket.config.json` file in your project directory when you run `bucket init`.
66+
This file contains all the necessary settings for your Bucket integration.
6267

6368
### Configuration File Structure
6469

@@ -95,7 +100,8 @@ You can override these settings using command-line options for individual comman
95100

96101
### `bucket init`
97102

98-
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.
103+
Initialize a new Bucket configuration in your project.
104+
This creates a `bucket.config.json` file with your settings and prompts for any required information not provided via options.
99105

100106
```bash
101107
bucket init [--overwrite]
@@ -109,7 +115,8 @@ Options:
109115

110116
### `bucket new [featureName]`
111117

112-
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.
118+
All-in-one command to get started quickly. This command combines `init`, feature creation,
119+
and type generation in a single step. Use this for the fastest way to get up and running with Bucket.
113120

114121
```bash
115122
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.
147154

148155
#### `bucket features create [featureName]`
149156

150-
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.
157+
Create a new feature in your Bucket app.
158+
The command guides you through the feature creation process with interactive prompts if options are not provided.
151159

152160
```bash
153161
bucket features create "My Feature" [--key my-feature] [--app-id ap123456789] [--key-format custom]
@@ -161,7 +169,8 @@ Options:
161169

162170
#### `bucket features list`
163171

164-
List all features for the current app. This helps you visualize what features are available and their current configurations.
172+
List all features for the current app.
173+
This helps you visualize what features are available and their current configurations.
165174

166175
```bash
167176
bucket features list [--app-id ap123456789]
@@ -173,7 +182,8 @@ Options:
173182

174183
#### `bucket features types`
175184

176-
Generate TypeScript types for your features. This ensures type safety when using Bucket features in your TypeScript/JavaScript applications.
185+
Generate TypeScript types for your features.
186+
This ensures type safety when using Bucket features in your TypeScript/JavaScript applications.
177187

178188
```bash
179189
bucket features types [--app-id ap123456789] [--out gen/features.ts] [--format react]

packages/cli/commands/auth.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export const loginAction = async () => {
1212

1313
try {
1414
await waitForAccessToken(baseUrl, apiUrl);
15-
console.log(`Logged in to ${chalk.cyan(baseUrl)} successfully! 🎉`);
15+
console.log(`Logged in to ${chalk.cyan(baseUrl)} successfully!`);
1616
} catch (error) {
1717
console.error("Login failed.");
1818
void handleError(error, "Login");
@@ -24,7 +24,7 @@ export const logoutAction = async () => {
2424
const spinner = ora("Logging out...").start();
2525
try {
2626
await authStore.setToken(baseUrl, undefined);
27-
spinner.succeed("Logged out successfully! 👋");
27+
spinner.succeed("Logged out successfully!");
2828
} catch (error) {
2929
spinner.fail("Logout failed.");
3030
void handleError(error, "Logout");

packages/cli/commands/features.ts

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import { dirname, isAbsolute, join, relative } from "node:path";
66
import ora, { Ora } from "ora";
77

88
import { createFeature, Feature, listFeatures } from "../services/features.js";
9-
import { listStages, Stage } from "../services/stages.js";
109
import { configStore } from "../stores/config.js";
1110
import { handleError, MissingAppIdError } from "../utils/errors.js";
1211
import { genFeatureKey, genTypes, KeyFormatPatterns } from "../utils/gen.js";
@@ -53,7 +52,7 @@ export const createFeatureAction = async (
5352
const feature = await createFeature(appId, name, key);
5453
// todo: would like to link to feature here but we don't have the env id, only app id
5554
spinner.succeed(
56-
`Created feature ${chalk.cyan(feature.name)} with key ${chalk.cyan(feature.key)} at ${chalk.cyan(baseUrl)}. 🎉`,
55+
`Created feature ${chalk.cyan(feature.name)} with key ${chalk.cyan(feature.key)} at ${chalk.cyan(baseUrl)}.`,
5756
);
5857
} catch (error) {
5958
spinner?.fail("Feature creation failed.");
@@ -76,8 +75,8 @@ export const listFeaturesAction = async () => {
7675
);
7776
console.table(
7877
features.map(({ key, name, stage }) => ({
79-
key,
8078
name,
79+
key,
8180
stage: stage?.name,
8281
})),
8382
);
@@ -93,7 +92,6 @@ export const generateTypesAction = async () => {
9392

9493
let spinner: Ora | undefined;
9594
let features: Feature[] = [];
96-
let stages: Stage[] = [];
9795
try {
9896
if (!appId) throw new MissingAppIdError();
9997
spinner = ora(
@@ -111,23 +109,13 @@ export const generateTypesAction = async () => {
111109
return;
112110
}
113111

114-
try {
115-
spinner = ora(`Loading stages...`).start();
116-
stages = await listStages(appId);
117-
spinner.succeed(`Loaded stages.`);
118-
} catch (error) {
119-
spinner?.fail("Loading stages failed.");
120-
void handleError(error, "Features Types");
121-
return;
122-
}
123-
124112
try {
125113
spinner = ora("Generating feature types...").start();
126114
const projectPath = configStore.getProjectPath();
127115

128116
// Generate types for each output configuration
129117
for (const output of typesOutput) {
130-
const types = await genTypes(features, stages, output.format);
118+
const types = await genTypes(features, output.format);
131119
const outPath = isAbsolute(output.path)
132120
? output.path
133121
: join(projectPath, output.path);

packages/cli/commands/init.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import ora, { Ora } from "ora";
66

77
import { App, listApps } from "../services/bootstrap.js";
88
import { configStore, typeFormats } from "../stores/config.js";
9-
import { chalkBrand, DEFAULT_TYPES_OUTPUT } from "../utils/constants.js";
9+
import { DEFAULT_TYPES_OUTPUT } from "../utils/constants.js";
1010
import { handleError } from "../utils/errors.js";
1111
import { overwriteOption } from "../utils/options.js";
1212

@@ -27,7 +27,7 @@ export const initAction = async (args: InitArgs = {}) => {
2727
);
2828
}
2929

30-
console.log(chalkBrand("\nWelcome to Bucket! 🪣\n"));
30+
console.log("\nWelcome to Bucket!\n");
3131
const baseUrl = configStore.getConfig("baseUrl");
3232

3333
// Load apps

packages/cli/index.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#!/usr/bin/env node
22
import chalk from "chalk";
33
import { program } from "commander";
4-
import { join } from "node:path";
54

65
import { registerAppCommands } from "./commands/apps.js";
76
import { registerAuthCommands } from "./commands/auth.js";
@@ -54,10 +53,4 @@ async function main() {
5453
program.parse(process.argv);
5554
}
5655

57-
// Run the main function if this file is run directly and not imported
58-
if (
59-
process.argv[1].endsWith(join("cli", "dist", "index.js")) ||
60-
process.argv[1].endsWith(join(".bin", "bucket"))
61-
) {
62-
void main();
63-
}
56+
void main();

packages/cli/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@bucketco/cli",
3-
"version": "0.2.0",
3+
"version": "0.2.2",
44
"packageManager": "yarn@4.1.1",
55
"description": "CLI for Bucket service",
66
"main": "./dist/index.js",

0 commit comments

Comments
 (0)