Skip to content

Conversation

@dipankarmaikap
Copy link
Contributor

@dipankarmaikap dipankarmaikap commented Nov 25, 2025

Add --token Option, Refactor Success Messaging, and Fix --skip-space in create Command

Features

  • New --token option:
    Users can now pass an access token directly via --token. If provided, space creation is skipped and the .env file is updated with this token.
  • Environment update:
    When using --token, the CLI writes the token to the .env file for the generated project.

Bug Fixes

  • Fixed --skip-space option:
    The --skip-space flag now reliably skips space creation and related steps, as verified by new and updated tests.

Refactoring

  • Success messaging:
    Refactored repeated success and "next steps" messages into a helper function to avoid duplication and ensure consistent output.
  • Error handling:
    Centralized .env file creation error handling for both space and key flows.

Tests

  • Added test for --token option:
    Ensures that when --token is provided:
    • Space creation and browser opening are skipped.
    • .env is updated with the provided key.
    • Success and next steps messages are shown.
  • Improved tests for --skip-space:
    Verified that space creation and related prompts are skipped, and messaging is correct.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Nov 25, 2025

Open in StackBlitz

@storyblok/astro

npm i https://pkg.pr.new/@storyblok/astro@385

storyblok

npm i https://pkg.pr.new/storyblok@385

@storyblok/eslint-config

npm i https://pkg.pr.new/@storyblok/eslint-config@385

@storyblok/js

npm i https://pkg.pr.new/@storyblok/js@385

storyblok-js-client

npm i https://pkg.pr.new/storyblok-js-client@385

@storyblok/management-api-client

npm i https://pkg.pr.new/@storyblok/management-api-client@385

@storyblok/nuxt

npm i https://pkg.pr.new/@storyblok/nuxt@385

@storyblok/react

npm i https://pkg.pr.new/@storyblok/react@385

@storyblok/region-helper

npm i https://pkg.pr.new/@storyblok/region-helper@385

@storyblok/richtext

npm i https://pkg.pr.new/@storyblok/richtext@385

@storyblok/svelte

npm i https://pkg.pr.new/@storyblok/svelte@385

@storyblok/vue

npm i https://pkg.pr.new/@storyblok/vue@385

commit: 4a2bc2c

template?: string;
blueprint?: string; // Deprecated, use template instead
skipSpace?: boolean;
key?: string; // Access token for Storyblok
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question(blocking):
@dipankarmaikap what do you think about naming it token, or accessToken? I know it used to be called key, but I believe those 2 are more descriptive and here we have a chance to improve the DX ;)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Going with token

expect(openSpaceInBrowser).not.toHaveBeenCalled();
});

it('should NOT prompt for space creation when --skip-space is provided', async () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

praise: nice extra test!

.option('-t, --template <template>', 'technology starter template')
.option('-b, --blueprint <blueprint>', '[DEPRECATED] use --template instead')
.option('--skip-space', 'skip space creation')
.option('--key <key>', 'Storyblok access token (skip space creation and use this token)')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above (naming comment)

konsola.warn(`Failed to open browser: ${(error as Error).message}`);
const spaceUrl = generateSpaceUrl(createdSpace.id, region);
konsola.info(`You can manually open your space at: ${chalk.hex(colorPalette.PRIMARY)(spaceUrl)}`);
if (region !== 'eu' && userData.has_org) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion:

@dipankarmaikap shall we, instead of using the eu literal directly, reuse regions.EU constant for the constants.ts file?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: what is it about eu that makes it special? Is it the default region? Is it the only region allowed for non-enterprise customers? A combination of multiple things?

suggestion: depending on the answer, we might add a helper like isDefaultRegion or isEnterpriseRegion or whatever.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@maoberlehner In this case it’s only used three times, and I think it’s fine as is. It makes the code easier to read than creating an abstraction. But if this ends up being used in more places in the CLI, we could create a helper and reuse it. What do you think?

@dipankarmaikap dipankarmaikap merged commit 68c8a0e into main Nov 25, 2025
5 checks passed
@dipankarmaikap dipankarmaikap deleted the feat/storyblok-create branch November 25, 2025 10:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants