Skip to content

Commit 63de585

Browse files
authored
Merge pull request #253 from pluginpal/feature/installer-wizard
Feature/installer wizard
2 parents 7800cc9 + 6a2568e commit 63de585

File tree

22 files changed

+846
-40
lines changed

22 files changed

+846
-40
lines changed

.changeset/brown-papayas-look.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"strapi-plugin-webtools": patch
3+
---
4+
5+
docs: update the install command in the readme

.changeset/forty-masks-post.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"webtools-cli": major
3+
---
4+
5+
feat: strapi-webtools installer wizard

.changeset/vast-news-return.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"docs": patch
3+
---
4+
5+
docs: add the webtools-cli commands to the docs

README.md

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,20 @@
3434

3535
[Read the Getting Started tutorial](https://docs.pluginpal.io/webtools) or follow the steps below:
3636

37-
```bash
38-
# using yarn
39-
yarn add strapi-plugin-webtools
37+
### Installer wizard
4038

41-
# using npm
42-
npm install strapi-plugin-webtools --save
39+
To provide easy installation, this plugin comes with it's own installer wizard. It let's you interactively select which content types you want to enable and which addons you want to install. Making it easy to get started with Webtools!
40+
41+
```bash
42+
npx webtools-cli install
4343
```
4444

45+
### Enabling
46+
47+
Using the installer wizard you can easily enable Webtools for your content types. If there are still more content-types you want to enable, you can do that manually through the admin panel. Read more about how to do that in the [usage documentation](https://docs.pluginpal.io/webtools/usage).
48+
49+
### Building
50+
4551
After successful installation you have to rebuild the admin UI so it'll include this plugin. To rebuild and restart Strapi run:
4652

4753
```bash
@@ -56,10 +62,6 @@ npm run develop
5662

5763
Enjoy 🎉
5864

59-
## Enabling
60-
61-
After successful installation you now need to enable Webtools for the content-types of your choice. Read more about how to do that in the [usage documentation](https://docs.pluginpal.io/webtools/usage).
62-
6365
## 📓 Documentation
6466

6567
The full documentation of this plugin can be found on it's dedicated documentation website.

packages/cli/.eslintignore

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
**/node_modules
2+
**/playground
3+
**/public
4+
**/build
5+
**/dist
6+
**/bundle
7+
**/config
8+
**/scripts
9+
**/docs
10+
**/types/generated
11+
**/__tests__
12+
strapi-admin.js
13+
strapi-server.js

packages/cli/.gitignore

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Don't check auto-generated stuff into git
2+
coverage
3+
node_modules
4+
stats.json
5+
package-lock.json
6+
7+
# Cruft
8+
.DS_Store
9+
npm-debug.log
10+
.idea
11+
12+
# Strapi
13+
.strapi-updater.json
14+
15+
# Production build
16+
build
17+
dist
18+
bundle

packages/cli/LICENSE.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Copyright (c) 2025 PluginPal.
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4+
5+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6+
7+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

packages/cli/README.md

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
<div align="center">
2+
<h1>Strapi Webtools CLI</h1>
3+
4+
<p style="margin-top: 0;">A CLI tool for installing and managing Strapi Webtools in your Strapi project.</p>
5+
6+
<a href="https://docs.pluginpal.io/webtools">Read the documentation</a>
7+
8+
<p>
9+
<a href="https://www.npmjs.org/package/strapi-plugin-webtools">
10+
<img src="https://img.shields.io/npm/v/strapi-plugin-webtools/latest.svg" alt="NPM Version" />
11+
</a>
12+
<a href="https://www.npmjs.org/package/strapi-plugin-webtools">
13+
<img src="https://img.shields.io/npm/dm/strapi-plugin-webtools" alt="Monthly download on NPM" />
14+
</a>
15+
<a href="https://codecov.io/gh/pluginpal/strapi-webtools">
16+
<img src="https://img.shields.io/github/actions/workflow/status/pluginpal/strapi-webtools/tests.yml?branch=master" alt="CI build status" />
17+
</a>
18+
<a href="https://codecov.io/gh/pluginpal/strapi-webtools">
19+
<img src="https://codecov.io/gh/pluginpal/strapi-webtools/coverage.svg?branch=master" alt="codecov.io" />
20+
</a>
21+
</p>
22+
23+
</div>
24+
25+
## ✨ Features
26+
27+
- **Easy install** Install add-ons with ease
28+
- **Simultaneous enabling** Select the content types you want to enable
29+
30+
## ⏳ Usage
31+
32+
You can use the CLI directly with npx.
33+
34+
```bash
35+
npx webtools-cli
36+
```
37+
38+
## Commands
39+
40+
The CLI offers multiple commands to make it easy to work with Webtools.
41+
42+
### Install
43+
44+
The most important command is the `install` command. It let's you install the core plugins and selected addons, and directly let's you enable Webtools for content-types of your choice.
45+
46+
```bash
47+
npx webtools-cli install
48+
```
49+
50+
### Enable
51+
52+
If you've already installed Webtools but you want to use the CLI to enable it for your content-types you can use the `enable` command.
53+
54+
```bash
55+
npx webtools-cli enable
56+
```
57+
58+
## 🔗 Links
59+
60+
- [PluginPal marketplace](https://www.pluginpal.io/plugin/webtools)
61+
- [NPM package](https://www.npmjs.com/package/strapi-plugin-webtools)
62+
- [GitHub repository](https://github.com/pluginpal/strapi-webtools)
63+
- [Strapi marketplace](https://market.strapi.io/plugins/@pluginpal-webtools-core)
64+
65+
## 🌎 Community support
66+
67+
- For general help using Strapi, please refer to [the official Strapi documentation](https://strapi.io/documentation/).
68+
- You can contact me on the Strapi Discord [channel](https://discord.strapi.io/).
69+
70+
## 📝 Resources
71+
72+
- [MIT License](https://github.com/pluginpal/strapi-webtools/blob/master/LICENSE.md)
73+

packages/cli/package.json

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
{
2+
"name": "webtools-cli",
3+
"version": "0.0.1",
4+
"description": "CLI installer for Strapi Webtools",
5+
"exports": {
6+
".": {
7+
"types": "./dist/index.d.ts",
8+
"require": "./dist/index.js",
9+
"import": "./dist/index.mjs",
10+
"source": "./src/index.ts",
11+
"default": "./dist/index.js"
12+
},
13+
"./package.json": "./package.json"
14+
},
15+
"main": "./dist/index.js",
16+
"module": "./dist/index.mjs",
17+
"files": [
18+
"dist"
19+
],
20+
"scripts": {
21+
"check": "pack-up check",
22+
"build": "pack-up build && ../../node_modules/.bin/yalc push --publish",
23+
"watch": "pack-up watch",
24+
"eslint": "../../node_modules/.bin/eslint --max-warnings=0 './**/*.{js,jsx,ts,tsx}'",
25+
"eslint:fix": "../../node_modules/.bin/eslint --fix './**/*.{js,jsx,ts,tsx}'"
26+
},
27+
"bin": {
28+
"strapi-webtools": "./dist/index.js"
29+
},
30+
"dependencies": {
31+
"@inquirer/prompts": "^3.3.0",
32+
"chalk": "^4.1.2",
33+
"commander": "^11.1.0",
34+
"fs-extra": "^11.2.0",
35+
"glob": "^10.3.10"
36+
},
37+
"devDependencies": {
38+
"@strapi/pack-up": "^5.0.0",
39+
"@types/fs-extra": "^11.0.4",
40+
"@types/glob": "^8.1.0",
41+
"@types/node": "^20.11.19",
42+
"typescript": "^5.3.3"
43+
},
44+
"author": {
45+
"name": "Boaz Poolman",
46+
"email": "[email protected]",
47+
"url": "https://github.com/boazpoolman"
48+
},
49+
"maintainers": [
50+
{
51+
"name": "Boaz Poolman",
52+
"email": "[email protected]",
53+
"url": "https://github.com/boazpoolman"
54+
}
55+
],
56+
"bugs": {
57+
"url": "https://github.com/pluginpal/strapi-webtools/issues"
58+
},
59+
"homepage": "https://www.pluginpal.io/plugin/webtools",
60+
"repository": {
61+
"type": "git",
62+
"url": "git://github.com/pluginpal/strapi-webtools.git"
63+
},
64+
"engines": {
65+
"node": ">=18.x.x <=22.x.x",
66+
"npm": ">=6.0.0"
67+
},
68+
"license": "MIT"
69+
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import chalk from 'chalk';
2+
import { checkbox } from '@inquirer/prompts';
3+
import { checkStrapiProject } from '../utils/strapi';
4+
import { getContentTypes, enableWebtoolsForContentType } from '../utils/content-types';
5+
6+
export async function enable() {
7+
// Check if we're in a Strapi project
8+
const isStrapiProject = await checkStrapiProject();
9+
if (!isStrapiProject) {
10+
console.log(chalk.red('Error: This command must be run in a Strapi project directory.'));
11+
return;
12+
}
13+
14+
// Get available content types
15+
const contentTypes = getContentTypes();
16+
17+
if (contentTypes.length === 0) {
18+
console.log(chalk.yellow('No content types found in your Strapi project.'));
19+
return;
20+
}
21+
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+
});
30+
31+
// Enable Webtools for selected content types
32+
if (selectedContentTypes.length > 0) {
33+
console.log(chalk.blue('\nEnabling Webtools for selected content types...'));
34+
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+
}
41+
42+
console.log(chalk.red(`✗ Failed to enable Webtools for ${contentType}`));
43+
return false;
44+
});
45+
46+
const successCount = results.filter(Boolean).length;
47+
console.log(chalk.blue(`\nEnabled Webtools for ${successCount} of ${selectedContentTypes.length} content types.`));
48+
} else {
49+
console.log(chalk.yellow('No content types selected. Nothing to do.'));
50+
}
51+
52+
console.log(chalk.yellow('\nYou may need to restart your Strapi server for changes to take effect.'));
53+
}

0 commit comments

Comments
 (0)