Skip to content

Commit 40e03b4

Browse files
committed
fix: remove stages gen (not ready yet) and update some defaults
1 parent 273bd39 commit 40e03b4

6 files changed

Lines changed: 8 additions & 29 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/cli/commands/features.ts

Lines changed: 2 additions & 14 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";
@@ -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/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.1",
3+
"version": "0.2.2",
44
"packageManager": "yarn@4.1.1",
55
"description": "CLI for Bucket service",
66
"main": "./dist/index.js",

packages/cli/services/bootstrap.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ export async function listApps(): Promise<App[]> {
2929
throw new Error("No apps found");
3030
}
3131
return response.org.apps.map(({ id, name, demo }) => ({
32-
id,
3332
name,
34-
demo,
33+
id,
3534
featureKeyFormat: org.featureKeyFormat ?? "custom",
35+
demo,
3636
}));
3737
}

packages/cli/utils/constants.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export const SCHEMA_URL = `https://unpkg.com/@bucketco/cli@latest/schema.json`;
99

1010
export const DEFAULT_BASE_URL = "https://app.bucket.co";
1111
export const DEFAULT_API_URL = `${DEFAULT_BASE_URL}/api`;
12-
export const DEFAULT_TYPES_OUTPUT = join("gen", "features.ts");
12+
export const DEFAULT_TYPES_OUTPUT = join("gen", "features.d.ts");
1313

1414
export const loginUrl = (baseUrl: string, localPort: number) =>
1515
`${baseUrl}/login?redirect_url=` +

packages/cli/utils/gen.ts

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { camelCase, kebabCase, pascalCase, snakeCase } from "change-case";
22

33
import { Feature, RemoteConfig } from "../services/features.js";
4-
import { Stage } from "../services/stages.js";
54

65
import { JSONToType } from "./json.js";
76

@@ -90,11 +89,7 @@ export function genRemoteConfig(remoteConfigs?: RemoteConfig[]) {
9089
);
9190
}
9291

93-
export function genTypes(
94-
features: Feature[],
95-
stages: Stage[],
96-
format: GenFormat = "react",
97-
) {
92+
export function genTypes(features: Feature[], format: GenFormat = "react") {
9893
const configDefs = new Map<string, { name: string; definition: string }>();
9994
features.forEach(({ key, name, remoteConfigs }) => {
10095
const definition = genRemoteConfig(remoteConfigs);
@@ -110,11 +105,6 @@ export function genTypes(
110105
import "@bucketco/${format}-sdk";
111106
112107
declare module "@bucketco/${format}-sdk" {
113-
${
114-
stages.length
115-
? /* ts */ `export type Stage = ${stages.map(({ name }) => `"${name}"`).join(" | ")};\n`
116-
: ""
117-
}
118108
export interface Features {
119109
${features
120110
.map(({ key }) => {

0 commit comments

Comments
 (0)