Skip to content
This repository was archived by the owner on Jan 19, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 86 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -308,10 +308,96 @@
}
},
{
"type": "node",
"request": "launch",
"name": "Debug Migrations generate non-existing component",
"program": "${workspaceFolder}/dist/index.mjs",
"args": ["migrations", "generate", "non-existing", "--space", "295017"],

"cwd": "${workspaceFolder}",
"console": "integratedTerminal",
"sourceMaps": true,
"outFiles": ["${workspaceFolder}/dist/**/*.js"],
"env": {
"STUB": "true"
}
},
{
"type": "node",
"request": "launch",
"name": "Debug Generate types",
"program": "${workspaceFolder}/dist/index.mjs",
"args": ["types", "generate", "--space", "295017", "--filter", "component-inside-*"],
"cwd": "${workspaceFolder}",
"console": "integratedTerminal",
"sourceMaps": true,
"outFiles": ["${workspaceFolder}/dist/**/*.js"],
"env": {
"STUB": "true"
}
},
{
"type": "node",
"request": "launch",
"name": "Debug Generate types strict",
"program": "${workspaceFolder}/dist/index.mjs",
"args": ["types", "generate", "--space", "295017", "--strict"],
"cwd": "${workspaceFolder}",
"console": "integratedTerminal",
"sourceMaps": true,
"outFiles": ["${workspaceFolder}/dist/**/*.js"],
"env": {
"STUB": "true"
}
},
{
"type": "node",
"request": "launch",
"name": "Debug Generate types from separate files",
"program": "${workspaceFolder}/dist/index.mjs",
"args": ["types", "generate", "--space", "295017", "--separate-files"],
"cwd": "${workspaceFolder}",
"console": "integratedTerminal",
"sourceMaps": true,
"outFiles": ["${workspaceFolder}/dist/**/*.js"],
"env": {
"STUB": "true"
}
},
{
"type": "node",
"request": "launch",
"name": "Debug Generate types with suffix",
"program": "${workspaceFolder}/dist/index.mjs",
"args": ["types", "generate", "--space", "295017", "--suffix", "prod"],
"cwd": "${workspaceFolder}",
"console": "integratedTerminal",
"sourceMaps": true,
"outFiles": ["${workspaceFolder}/dist/**/*.js"],
"env": {
"STUB": "true"
}
},
{
"type": "node",
"request": "launch",
"name": "Debug Generate types with custom fields parser",
"program": "${workspaceFolder}/dist/index.mjs",
"args": ["types", "generate", "--space", "295017", "--custom-fields-parser", "./custom-fields-parser.ts"],
"cwd": "${workspaceFolder}",
"console": "integratedTerminal",
"sourceMaps": true,
"outFiles": ["${workspaceFolder}/dist/**/*.js"],
"env": {
"STUB": "true"
}
},
{
"type": "node",
"request": "launch",
"name": "Debug Generate types with compiler options",
"program": "${workspaceFolder}/dist/index.mjs",
"args": ["types", "generate", "--space", "295017", "--compiler-options", "./compiler-options.ts"],
"cwd": "${workspaceFolder}",
"console": "integratedTerminal",
"sourceMaps": true,
Expand Down
5 changes: 5 additions & 0 deletions compiler-options.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export default {
unknownAny: false,
additionalProperties: false,
bannerComment: 'Awiwi',
};
16 changes: 16 additions & 0 deletions custom-fields-parser.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
export default (key: string, field: any) => {
switch (field.field_type) {
case 'native-color-picker':
return {
[key]: {
properties: {
color: { type: 'string' },
},
required: ['color'],
type: 'object',
},
};
default:
return {};
}
};
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"chalk": "^5.4.1",
"commander": "^13.1.0",
"dotenv": "^16.4.7",
"json-schema-to-typescript": "^15.0.4",
"ohash": "^2.0.5",
"storyblok-js-client": "^6.10.7"
},
Expand Down
61 changes: 53 additions & 8 deletions pnpm-lock.yaml

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

2 changes: 1 addition & 1 deletion src/commands/components/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export interface SpaceComponent {
created_at: string;
updated_at: string;
id: number;
schema: Record<string, unknown>;
schema: Record<string, any>;
image?: string;
preview_field?: string;
is_root?: boolean;
Expand Down
2 changes: 1 addition & 1 deletion src/commands/components/pull/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ componentsCommand
.command('pull [componentName]')
.option('-f, --filename <filename>', 'custom name to be used in file(s) name instead of space id')
.option('--sf, --separate-files [value]', 'Argument to create a single file for each component')
.option('--su, --suffix <suffix>', 'suffix to add to the file name (e.g. components.<suffix>.json). By default, the space ID is used.')
.option('--su, --suffix <suffix>', 'suffix to add to the file name (e.g. components.<suffix>.json)')
.description(`Download your space's components schema as json. Optionally specify a component name to pull a single component.`)
.action(async (componentName: string | undefined, options: PullComponentsOptions) => {
konsola.title(` ${commands.COMPONENTS} `, colorPalette.COMPONENTS, componentName ? `Pulling component ${componentName}...` : 'Pulling components...');
Expand Down
11 changes: 11 additions & 0 deletions src/commands/types/command.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { getProgram } from '../../program';

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

// Components root command
export const typesCommand = program
.command('types')
.alias('ts')
.description(`Generate types d.ts for your component schemas`)
.option('-s, --space <space>', 'space ID')
.option('-p, --path <path>', 'path to save the file. Default is .storyblok/types');
Loading