Skip to content

Commit cdcf350

Browse files
committed
fix(cli): add missing separateFiles option
1 parent c5d5fd9 commit cdcf350

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

packages/cli/src/commands/types/generate/actions.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,10 @@ const getDatasourceTypeTitle = (slug: string) =>
3434

3535
const getPropertyTypeAnnotation = (property: ComponentPropertySchema, prefix?: string, suffix?: string) => {
3636
// If a property type is one of the ones provided by Storyblok, return that type
37-
// Casting as string[] to avoid TS error on using Array.includes on different narrowed types
3837
if (Array.from(storyblokSchemas.keys()).includes(property.type as StoryblokPropertyType)) {
3938
return { type: property.type };
4039
}
41-
// Initialize property type as any (fallback type)
40+
4241
let type: string | string[] = 'unknown';
4342

4443
const options = property.options && property.options.length > 0 ? property.options.map((item: { value: string }) => item.value) : [];

packages/cli/src/commands/types/generate/index.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { Command } from 'commander';
22
import { colorPalette, commands } from '../../../constants';
3-
import { FileSystemError, handleError, isVitest, konsola } from '../../../utils';
3+
import { FileSystemError, handleError, konsola } from '../../../utils';
44
import { Spinner } from '@topcli/spinner';
55
import { type ComponentsData, readComponentsFiles } from '../../components/push/actions';
66
import type { GenerateTypesOptions } from './constants';
@@ -30,18 +30,19 @@ generateCmd
3030
.action(async (options: GenerateTypesOptions, command: Command) => {
3131
konsola.title(`${commands.TYPES}`, colorPalette.TYPES, 'Generating types...');
3232

33-
const { space, path, verbose } = command.optsWithGlobals();
33+
const { space, path, verbose, suffix, filename, separateFiles } = command.optsWithGlobals();
3434

3535
const spinner = new Spinner({
36-
verbose: !isVitest,
36+
verbose,
3737
});
3838

3939
try {
4040
spinner.start(`Generating types...`);
4141
const componentsData = await readComponentsFiles({
4242
from: space,
4343
path,
44-
suffix: options.suffix,
44+
separateFiles,
45+
suffix,
4546
verbose,
4647
});
4748
// Try to read datasources, but make it optional
@@ -50,7 +51,8 @@ generateCmd
5051
dataSourceData = await readDatasourcesFiles({
5152
from: space,
5253
path,
53-
suffix: options.suffix,
54+
separateFiles,
55+
suffix,
5456
verbose,
5557
});
5658
}
@@ -75,19 +77,18 @@ generateCmd
7577

7678
const typedefData = await generateTypes(spaceDataWithComponentsAndDatasources, {
7779
...options,
78-
path,
7980
});
8081

8182
if (typedefData) {
8283
await saveTypesToComponentsFile(space, typedefData, {
83-
filename: options.filename,
84+
filename,
8485
path,
85-
separateFiles: options.separateFiles,
86+
separateFiles,
8687
});
8788
}
8889

8990
spinner.succeed();
90-
if (options.separateFiles && options.filename) {
91+
if (separateFiles && filename) {
9192
konsola.warn(`The --filename option is ignored when using --separate-files`);
9293
}
9394

0 commit comments

Comments
 (0)