Skip to content

Commit aefb622

Browse files
authored
Merge pull request #271 from pluginpal/feature/cli-empty-state
fix: gracefully skip the setup step if the Strapi project does not ha…
2 parents 534bace + 8a11a4e commit aefb622

File tree

2 files changed

+31
-22
lines changed

2 files changed

+31
-22
lines changed

.changeset/pretty-crews-warn.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"webtools-cli": patch
3+
---
4+
5+
fix: gracefully skip the setup step if the Strapi project does not have any content types yet

packages/cli/src/commands/install.ts

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -16,32 +16,36 @@ export async function install() {
1616
// Get available content types
1717
const contentTypes = getContentTypes();
1818

19-
// Let user select content types
20-
const selectedContentTypes = await checkbox({
21-
message: 'Select content types to enable Webtools for:',
22-
choices: contentTypes.map((type) => ({
23-
name: type,
24-
value: type,
25-
})),
26-
});
19+
if (contentTypes.length === 0) {
20+
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.'));
21+
} else {
22+
// Let user select content types
23+
const selectedContentTypes = await checkbox({
24+
message: 'Select content types to enable Webtools for:',
25+
choices: contentTypes.map((type) => ({
26+
name: type,
27+
value: type,
28+
})),
29+
});
2730

28-
// Enable Webtools for selected content types
29-
if (selectedContentTypes.length > 0) {
30-
console.log(chalk.blue('\nEnabling Webtools for selected content types...'));
31+
// Enable Webtools for selected content types
32+
if (selectedContentTypes.length > 0) {
33+
console.log(chalk.blue('\nEnabling Webtools for selected content types...'));
3134

32-
const results = selectedContentTypes.map((contentType) => {
33-
const success = enableWebtoolsForContentType(contentType);
34-
if (success) {
35-
console.log(chalk.green(`✓ Enabled Webtools for ${contentType}`));
36-
return true;
37-
}
35+
const results = selectedContentTypes.map((contentType) => {
36+
const success = enableWebtoolsForContentType(contentType);
37+
if (success) {
38+
console.log(chalk.green(`✓ Enabled Webtools for ${contentType}`));
39+
return true;
40+
}
3841

39-
console.log(chalk.red(`✗ Failed to enable Webtools for ${contentType}`));
40-
return false;
41-
});
42+
console.log(chalk.red(`✗ Failed to enable Webtools for ${contentType}`));
43+
return false;
44+
});
4245

43-
const successCount = results.filter(Boolean).length;
44-
console.log(chalk.blue(`\nEnabled Webtools for ${successCount} of ${selectedContentTypes.length} content types.`));
46+
const successCount = results.filter(Boolean).length;
47+
console.log(chalk.blue(`\nEnabled Webtools for ${successCount} of ${selectedContentTypes.length} content types.`));
48+
}
4549
}
4650

4751
// Get available addons

0 commit comments

Comments
 (0)