Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 5 additions & 0 deletions .changeset/pretty-crews-warn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"webtools-cli": patch
---

fix: gracefully skip the setup step if the Strapi project does not have any content types yet
48 changes: 26 additions & 22 deletions packages/cli/src/commands/install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,32 +16,36 @@ export async function install() {
// Get available content types
const contentTypes = getContentTypes();

// Let user select content types
const selectedContentTypes = await checkbox({
message: 'Select content types to enable Webtools for:',
choices: contentTypes.map((type) => ({
name: type,
value: type,
})),
});
if (contentTypes.length === 0) {
console.log(chalk.yellow('No content types found in your Strapi project, skipping Webtools setup step. You can enable Webtools later using the "enable" command.'));
} else {
// Let user select content types
const selectedContentTypes = await checkbox({
message: 'Select content types to enable Webtools for:',
choices: contentTypes.map((type) => ({
name: type,
value: type,
})),
});

// Enable Webtools for selected content types
if (selectedContentTypes.length > 0) {
console.log(chalk.blue('\nEnabling Webtools for selected content types...'));
// Enable Webtools for selected content types
if (selectedContentTypes.length > 0) {
console.log(chalk.blue('\nEnabling Webtools for selected content types...'));

const results = selectedContentTypes.map((contentType) => {
const success = enableWebtoolsForContentType(contentType);
if (success) {
console.log(chalk.green(`✓ Enabled Webtools for ${contentType}`));
return true;
}
const results = selectedContentTypes.map((contentType) => {
const success = enableWebtoolsForContentType(contentType);
if (success) {
console.log(chalk.green(`✓ Enabled Webtools for ${contentType}`));
return true;
}

console.log(chalk.red(`✗ Failed to enable Webtools for ${contentType}`));
return false;
});
console.log(chalk.red(`✗ Failed to enable Webtools for ${contentType}`));
return false;
});

const successCount = results.filter(Boolean).length;
console.log(chalk.blue(`\nEnabled Webtools for ${successCount} of ${selectedContentTypes.length} content types.`));
const successCount = results.filter(Boolean).length;
console.log(chalk.blue(`\nEnabled Webtools for ${successCount} of ${selectedContentTypes.length} content types.`));
}
}

// Get available addons
Expand Down