Skip to content

Commit

Permalink
Merge branch 'next' into feature/pull-components-cmd
Browse files Browse the repository at this point in the history
  • Loading branch information
alvarosabu committed Jan 22, 2025
2 parents 8de5ee0 + 5ddd298 commit 5ac8c15
Show file tree
Hide file tree
Showing 6 changed files with 138 additions and 13 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"chalk": "^5.3.0",
"commander": "^12.1.0",
"dotenv": "^16.4.5",
"ora": "^8.1.1",
"storyblok-js-client": "^6.9.2"
},
"devDependencies": {
Expand Down
126 changes: 118 additions & 8 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 7 additions & 2 deletions src/commands/languages/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ import { session } from '../../session'
import { fetchLanguages, saveLanguagesToFile } from './actions'
import chalk from 'chalk'
import type { PullLanguagesOptions } from './constants'
import ora from 'ora'

const program = getProgram() // Get the shared singleton instance

export const languagesCommand = program
.command('languages')
.alias('lang')
.description(`Manage your space's languages`)
.option('-s, --space <space>', 'space ID')
.option('-p, --path <path>', 'path to save the file. Default is .storyblok/languages')
Expand All @@ -20,7 +22,8 @@ languagesCommand
.option('-f, --filename <filename>', 'filename to save the file as <filename>.<suffix>.json')
.option('--su, --suffix <suffix>', 'suffix to add to the file name (e.g. languages.<suffix>.json). By default, the space ID is used.')
.action(async (options: PullLanguagesOptions) => {
konsola.title(` ${commands.LANGUAGES} `, colorPalette.LANGUAGES, 'Pulling languages...')
konsola.title(` ${commands.LANGUAGES} `, colorPalette.LANGUAGES)

// Global options
const verbose = program.opts().verbose
// Command options
Expand All @@ -40,8 +43,10 @@ languagesCommand
}

try {
const internationalization = await fetchLanguages(space, state.password, state.region)
const spinner = ora(`Fetching ${chalk.hex(colorPalette.LANGUAGES)('languages')}`).start()

const internationalization = await fetchLanguages(space, state.password, state.region)
spinner.succeed()
if (!internationalization || internationalization.languages?.length === 0) {
konsola.warn(`No languages found in the space ${space}`)
return
Expand Down
Loading

0 comments on commit 5ac8c15

Please sign in to comment.