-
Notifications
You must be signed in to change notification settings - Fork 17
feat(cli): allow storyblok create to use an existing space #385
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@storyblok/astro
storyblok
@storyblok/eslint-config
@storyblok/js
storyblok-js-client
@storyblok/management-api-client
@storyblok/nuxt
@storyblok/react
@storyblok/region-helper
@storyblok/richtext
@storyblok/svelte
@storyblok/vue
commit: |
| template?: string; | ||
| blueprint?: string; // Deprecated, use template instead | ||
| skipSpace?: boolean; | ||
| key?: string; // Access token for Storyblok |
There was a problem hiding this comment.
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 ;)
There was a problem hiding this comment.
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 () => { |
There was a problem hiding this comment.
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)') |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
Add
--tokenOption, Refactor Success Messaging, and Fix--skip-spaceincreateCommandFeatures
--tokenoption:Users can now pass an access token directly via
--token. If provided, space creation is skipped and the.envfile is updated with this token.When using
--token, the CLI writes the token to the.envfile for the generated project.Bug Fixes
--skip-spaceoption:The
--skip-spaceflag now reliably skips space creation and related steps, as verified by new and updated tests.Refactoring
Refactored repeated success and "next steps" messages into a helper function to avoid duplication and ensure consistent output.
Centralized
.envfile creation error handling for both space and key flows.Tests
--tokenoption:Ensures that when
--tokenis provided:.envis updated with the provided key.--skip-space:Verified that space creation and related prompts are skipped, and messaging is correct.