Skip to content

Commit a230b55

Browse files
committed
refactor: separate line for feature link
1 parent 54c686a commit a230b55

2 files changed

Lines changed: 14 additions & 8 deletions

File tree

packages/cli/commands/features.ts

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,12 @@ import { App, getApp, getOrg } from "../services/bootstrap.js";
99
import { createFeature, Feature, listFeatures } from "../services/features.js";
1010
import { configStore } from "../stores/config.js";
1111
import { handleError, MissingAppIdError } from "../utils/errors.js";
12-
import { genFeatureKey, genTypes, KeyFormatPatterns } from "../utils/gen.js";
12+
import {
13+
genFeatureKey,
14+
genTypes,
15+
indentLines,
16+
KeyFormatPatterns,
17+
} from "../utils/gen.js";
1318
import {
1419
appIdOption,
1520
featureKeyOption,
@@ -54,14 +59,15 @@ export const createFeatureAction = async (
5459

5560
spinner = ora(`Creating feature...`).start();
5661
const feature = await createFeature(appId, name, key);
57-
const production = app.environments.find((e) => e.isProduction);
5862
spinner.succeed(
59-
`Created feature ${chalk.cyan(feature.name)} with key ${chalk.cyan(feature.key)}${
60-
production
61-
? ` at ${chalk.cyan(featureUrl(baseUrl, production, feature))}`
62-
: ""
63-
}.`,
63+
`Created feature ${chalk.cyan(feature.name)} with key ${chalk.cyan(feature.key)}:`,
6464
);
65+
const production = app.environments.find((e) => e.isProduction);
66+
if (production) {
67+
console.log(
68+
indentLines(chalk.magenta(featureUrl(baseUrl, production, feature))),
69+
);
70+
}
6571
} catch (error) {
6672
spinner?.fail("Feature creation failed.");
6773
void handleError(error, "Features Create");

packages/cli/utils/gen.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ export const KeyFormatPatterns: Record<KeyFormat, KeyFormatPattern> = {
6969
},
7070
};
7171

72-
function indentLines(str: string, indent = 2, lineBreak = "\n"): string {
72+
export function indentLines(str: string, indent = 2, lineBreak = "\n"): string {
7373
const indentStr = " ".repeat(indent);
7474
return str
7575
.split(lineBreak)

0 commit comments

Comments
 (0)