@webship.co/workspace-craft-cms 0.0.0-stage → 1.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +161 -2
- package/agents/craft-cms-site-builder.md +112 -0
- package/agents/craft-cms-tester.md +129 -0
- package/commands/cmd-craft-cms-project.sh +35 -0
- package/commands/cmd-tools-craft-cms-cli.sh +26 -0
- package/dist/src/index.d.ts +24 -0
- package/dist/src/index.js +44 -0
- package/dist/src/index.js.map +1 -0
- package/features/craft-cms.feature +17 -0
- package/package.json +73 -4
- package/scripts/args/arg-craft-cms-cli.sh +25 -0
- package/scripts/args/arg-craft-cms.sh +25 -0
- package/scripts/functions/fun-craft-cms.sh +333 -0
- package/testing/site.feature +39 -0
package/README.md
CHANGED
|
@@ -1,3 +1,162 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @webship.co/workspace-craft-cms
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Craft CMS for the [Webship Workspace](https://github.com/webship/workspace) dashboard: a builder
|
|
4
|
+
that makes a real Craft CMS site in a container, a craft console tool for the sites it built, the
|
|
5
|
+
default account, the [Craft CMS step pack](https://github.com/webship/craft-cms-steps) wired into
|
|
6
|
+
the workspace's testing setup, and two AI agents that know all of it.
|
|
7
|
+
|
|
8
|
+
The workspace is container-based (DDEV by default): a Craft CMS project is a row like any other, so
|
|
9
|
+
the row menus the core draws (start, stop, launch, backup, clone, remove, tests) work on it unchanged.
|
|
10
|
+
|
|
11
|
+
## The free Solo edition, and one account
|
|
12
|
+
|
|
13
|
+
A site built by this plugin is on the **free Solo edition** of Craft CMS and stays on it. No licence
|
|
14
|
+
is entered, no paid edition is switched on (not even as a trial), and nothing signs in to any
|
|
15
|
+
account or to the plugin store.
|
|
16
|
+
|
|
17
|
+
The Solo edition has **one account, an admin, and no user groups**. So, unlike the plugins of the
|
|
18
|
+
other platforms, this one has a single default account, and its first test feature covers the admin
|
|
19
|
+
only: there is no second account to log in as, and no role to be refused a page.
|
|
20
|
+
|
|
21
|
+
It is made from the reference platform plugin,
|
|
22
|
+
[`@webship.co/workspace-wordpress`](https://github.com/webship/workspace-wordpress).
|
|
23
|
+
|
|
24
|
+
## Use it
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
cd ~/workspace
|
|
28
|
+
bash core/scripts/plugins.sh --require github:webship/workspace-craft-cms # npm install into the dashboard
|
|
29
|
+
bash core/scripts/plugins.sh --activate craft-cms # plugins.craft-cms in settings.yml
|
|
30
|
+
bash core/scripts/plugins.sh --install craft-cms # commands, functions, args, agents
|
|
31
|
+
bash core/scripts/plugins.sh --configure craft-cms # nothing to configure: it has no settings file
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
The same four steps are buttons on the dashboard's **Settings → Plugins** page. `--install` is
|
|
35
|
+
idempotent. `--uninstall` removes what it placed; an agent you edited stays.
|
|
36
|
+
|
|
37
|
+
The commands land in the sites folders that are in the workspace (`dev`, `test`, `sandboxes`,
|
|
38
|
+
`demos`); the agents land in the AI Agents folder (`ai-agents/`) when the workspace has one, and are
|
|
39
|
+
installed into `~/.claude/agents` from there like any other agent.
|
|
40
|
+
|
|
41
|
+
It needs a Webship Workspace 1.0.7 or later.
|
|
42
|
+
|
|
43
|
+
## What the package holds
|
|
44
|
+
|
|
45
|
+
| Path | What it is |
|
|
46
|
+
| --- | --- |
|
|
47
|
+
| `commands/cmd-craft-cms-project.sh` | The builder, in the Build list as **Craft CMS (5, Solo)**, installed into every sites folder |
|
|
48
|
+
| `commands/cmd-tools-craft-cms-cli.sh` | The craft console for one project: what the site is, a command, updates, caches, the default account |
|
|
49
|
+
| `scripts/functions/fun-craft-cms.sh` | The bash functions behind both, sourced by bootstrap once installed; the names the core's tools look for (`set_craftcms_users`, `add_craftcms_users`, `cancel_craftcms_users`, `testing_configure_craftcms`, named after the DDEV project type `craftcms`) |
|
|
50
|
+
| `scripts/args/arg-craft-cms.sh`, `arg-craft-cms-cli.sh` | Their argparse; the Build form draws the builder's flags from the first |
|
|
51
|
+
| `testing/site.feature` | The first feature a Craft CMS project gets when testing is set up: the front page, the login form, the admin |
|
|
52
|
+
| `agents/craft-cms-site-builder.md` | The agent that builds and maintains Craft CMS sites with these commands |
|
|
53
|
+
| `agents/craft-cms-tester.md` | The agent that writes and runs scenarios with the Craft CMS step pack |
|
|
54
|
+
| `src/index.ts` | `register(api)`: what the assistant is told about Craft CMS here |
|
|
55
|
+
| `features/craft-cms.feature` | Scenarios for the dashboard's own browser suite |
|
|
56
|
+
|
|
57
|
+
The `workspacePlugin` block in `package.json` is the manifest the installer reads.
|
|
58
|
+
|
|
59
|
+
## The commands
|
|
60
|
+
|
|
61
|
+
Run them from a sites folder. `--help` is safe on both.
|
|
62
|
+
|
|
63
|
+
### Build a site
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
cd ~/workspace/dev
|
|
67
|
+
bash cmd-craft-cms-project.sh mysite --install # the one account is the workspace account
|
|
68
|
+
bash cmd-craft-cms-project.sh mysite --install --add-users # the one account is the default account, for a site to test
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
| Flag | What it does |
|
|
72
|
+
| --- | --- |
|
|
73
|
+
| `--version <x>` | The release, as a Composer constraint of `craftcms/cms`: `^5` (the default, the current release of Craft CMS 5), or a number such as `5.8.0` |
|
|
74
|
+
| `--install` | Install the site on the Solo edition, with the workspace account as its one account |
|
|
75
|
+
| `--add-users` | With `--install`: the one account is the default account `administrator` instead, the one the test scenarios log in as |
|
|
76
|
+
| `--php-version <x>` | The PHP of the project container (`8.3`) |
|
|
77
|
+
| `--launch` | Open the site when it is ready |
|
|
78
|
+
|
|
79
|
+
The site answers at `https://mysite.ddev.site`, the control panel at `/admin`. The build runs
|
|
80
|
+
`ddev config --project-type=craftcms` with the docroot `web` and the Node.js of the workspace (24),
|
|
81
|
+
creates the project with Composer in the container from the starter `craftcms/craft`, and installs
|
|
82
|
+
it with Craft's own `install/craft` command, which asks no question. The container tool gives the
|
|
83
|
+
project its database settings: the plugin writes none. A project of the same name is deleted first.
|
|
84
|
+
|
|
85
|
+
### Work on a site
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
bash cmd-tools-craft-cms-cli.sh mysite # version, address, edition, the account, plugins
|
|
89
|
+
bash cmd-tools-craft-cms-cli.sh mysite --run "project-config/apply"
|
|
90
|
+
bash cmd-tools-craft-cms-cli.sh mysite --run "help" # every command of the console
|
|
91
|
+
bash cmd-tools-craft-cms-cli.sh mysite --flush # clear every cache
|
|
92
|
+
bash cmd-tools-craft-cms-cli.sh mysite --update # Craft CMS and its plugins; the edition stays
|
|
93
|
+
bash cmd-tools-craft-cms-cli.sh mysite --add-users # is the site's account the default account?
|
|
94
|
+
bash cmd-tools-craft-cms-cli.sh mysite --cancel-users # says why it stays
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
A plugin is a Composer package (`ddev composer require <vendor>/<package>`, then
|
|
98
|
+
`--run "plugin/install <handle>"`): free, open-source plugins only, and never through a sign-in to
|
|
99
|
+
the plugin store.
|
|
100
|
+
|
|
101
|
+
### The default account
|
|
102
|
+
|
|
103
|
+
| Account | Role | Handle in the tests |
|
|
104
|
+
| --- | --- | --- |
|
|
105
|
+
| `administrator` | admin: the one account of the site | `admin` |
|
|
106
|
+
|
|
107
|
+
It has the address `administrator@example.com` and the password of the workspace's other default
|
|
108
|
+
lists. It is for local sites and for tests.
|
|
109
|
+
|
|
110
|
+
Because the edition has one account, it cannot be added to a site afterwards, and it cannot be taken
|
|
111
|
+
away:
|
|
112
|
+
|
|
113
|
+
- `--install` alone gives the one account to the workspace account. That site has no default
|
|
114
|
+
account; `--add-users` on the CLI tool, `bash cmd-tools-add-users.sh mysite craftcms` and the row's
|
|
115
|
+
Users menu say so, and create nothing.
|
|
116
|
+
- `--install --add-users` gives the one account to `administrator`. A scenario then logs in with an
|
|
117
|
+
account made for tests, and the workspace account is in no test.
|
|
118
|
+
- `bash cmd-tools-cancel-users.sh mysite craftcms` deletes nothing: a site cannot be without its
|
|
119
|
+
account. Build the site again to change whose it is.
|
|
120
|
+
|
|
121
|
+
### Test a site
|
|
122
|
+
|
|
123
|
+
```bash
|
|
124
|
+
bash cmd-tools-testing.sh mysite # webship-js, the step pack, the users registry, a first feature
|
|
125
|
+
bash cmd-tools-testing.sh mysite --run # run the suite in the container
|
|
126
|
+
bash cmd-tools-testing.sh mysite --run --path tests/features/site.feature
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
`cmd-tools-testing.sh` is the workspace's own. For a Craft CMS project it also adds
|
|
130
|
+
`@webship-js/craft-cms-steps` to `package.json`, lists its step definitions in `cucumber.js` after
|
|
131
|
+
webship-js's own, writes the users registry (the handle `admin`, overridable with `ADMIN_USER` and
|
|
132
|
+
`ADMIN_PASSWORD`), places `tests/features/site.feature` when the project has none, and says whether
|
|
133
|
+
the site's account is the default account. Run it again and it adds what is missing and keeps what
|
|
134
|
+
you changed.
|
|
135
|
+
|
|
136
|
+
The first feature covers the front page, the login form and the admin: logging in, the pages an
|
|
137
|
+
admin may open, logging out. On a site whose one account is the workspace account, give a run that
|
|
138
|
+
account in its environment (`ADMIN_USER`, `ADMIN_PASSWORD`) or build the site again with
|
|
139
|
+
`--add-users`.
|
|
140
|
+
|
|
141
|
+
## The agents
|
|
142
|
+
|
|
143
|
+
| Agent | Use it to |
|
|
144
|
+
| --- | --- |
|
|
145
|
+
| `craft-cms-site-builder` | Build, update, maintain or remove a Craft CMS site with the commands above, in containers only and on the Solo edition only |
|
|
146
|
+
| `craft-cms-tester` | Set the testing stack up, look at the site in the Playwright MCP browser first, write scenarios from the pack's steps and run them; it never creates an account in a suite and never writes a platform name into a step phrase |
|
|
147
|
+
|
|
148
|
+
After `--install` they are in the AI Agents folder of the dashboard; **Install** there puts one into
|
|
149
|
+
`~/.claude/agents`, or from the command line:
|
|
150
|
+
|
|
151
|
+
```bash
|
|
152
|
+
cd ~/workspace/ai-agents
|
|
153
|
+
bash cmd-tools-ai-items.sh craft-cms-tester --install
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
## Develop it
|
|
157
|
+
|
|
158
|
+
```bash
|
|
159
|
+
npm install # builds dist/ (TypeScript)
|
|
160
|
+
npm run lint
|
|
161
|
+
npm test # the manifest, the commands, the agents, the functions against a scaffolded project
|
|
162
|
+
```
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: craft-cms-site-builder
|
|
3
|
+
description: Use this agent to build, maintain, update or remove a Craft CMS site in the Webship Workspace — a new site from `cmd-craft-cms-project.sh`, craft console work through `cmd-tools-craft-cms-cli.sh` (project config, plugins, caches, updates), start, stop, backup and remove through the workspace's own tools. The site is the free Solo edition and stays on it. It works in containers only and never on the host. Invoke for "build a Craft CMS site", "add this plugin to <site>", "update Craft CMS on <site>", "clear the caches", or "remove the Craft sandbox". For writing and running test scenarios, hand over to `craft-cms-tester`.
|
|
4
|
+
model: fable
|
|
5
|
+
tools:
|
|
6
|
+
- Bash
|
|
7
|
+
- Read
|
|
8
|
+
- Write
|
|
9
|
+
- Edit
|
|
10
|
+
- Glob
|
|
11
|
+
- Grep
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
# craft-cms-site-builder
|
|
15
|
+
|
|
16
|
+
You build and look after Craft CMS sites in a Webship Workspace (`~/workspace`), a container-based
|
|
17
|
+
workspace (DDEV by default). Everything goes through the `cmd-*.sh` commands of a sites folder
|
|
18
|
+
(`dev/`, `test/`, `sandboxes/`, `demos/`) and through the project's container. The commands come from
|
|
19
|
+
the Craft CMS plugin (`@webship.co/workspace-craft-cms`); if a folder has no
|
|
20
|
+
`cmd-craft-cms-project.sh`, the plugin is not installed there: say so, and name the steps
|
|
21
|
+
(`bash core/scripts/plugins.sh --require @webship.co/workspace-craft-cms`, `--activate craft-cms`,
|
|
22
|
+
`--install craft-cms`) instead of working around it.
|
|
23
|
+
|
|
24
|
+
Read the command before quoting a flag: `bash <command> --help` is always safe.
|
|
25
|
+
|
|
26
|
+
## The edition: Solo, and only Solo
|
|
27
|
+
|
|
28
|
+
A site built here is on the **free Solo edition** and stays on it. That decides what it has:
|
|
29
|
+
|
|
30
|
+
- **One account**, an admin. There is no second account, no user group and no permission to set.
|
|
31
|
+
- No licence is entered. No paid edition is switched on, not for a test and not as a trial.
|
|
32
|
+
- Nothing signs in anywhere: not to a vendor account, not to the plugin store.
|
|
33
|
+
|
|
34
|
+
If a task needs a second account, user groups or anything else of a paid edition, say that the
|
|
35
|
+
edition does not have it and stop. Do not change the edition to get there.
|
|
36
|
+
|
|
37
|
+
## Build a site
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
cd ~/workspace/sandboxes # or dev, test, demos
|
|
41
|
+
bash cmd-craft-cms-project.sh mysite --install
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
| Flag | What it does |
|
|
45
|
+
| --- | --- |
|
|
46
|
+
| `--version <x>` | The release, as a Composer constraint of `craftcms/cms`: `^5` (the default, the current release of Craft CMS 5), or a number such as `5.8.0`. |
|
|
47
|
+
| `--install` | Installs the site, with the workspace account (`account:` in `core/config/settings.yml`) as its one account. Without it the code is there and the installer waits at `/admin/install`. |
|
|
48
|
+
| `--add-users` | With `--install`: the one account of the site is the default account `administrator` instead of the workspace account. Use it for a site that will be tested: a scenario then logs in with an account made for tests. |
|
|
49
|
+
| `--php-version <x>` | The PHP of the project container (`8.3` by default). |
|
|
50
|
+
| `--launch` | Opens the site when it is ready. |
|
|
51
|
+
|
|
52
|
+
The site answers at `https://<name>.ddev.site`, the control panel at `/admin`. It is a Composer
|
|
53
|
+
project from the starter `craftcms/craft`: the docroot is `web/`, the templates are in `templates/`,
|
|
54
|
+
the project config in `config/project/`. The builder **deletes a project of the same name first**: a
|
|
55
|
+
build is a clean slate, so never point it at a site somebody still needs. The name is a folder, a
|
|
56
|
+
container project and a host name: short, lowercase, letters and digits.
|
|
57
|
+
|
|
58
|
+
## Work on a site
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
bash cmd-tools-craft-cms-cli.sh mysite # what it is: version, address, edition, the account, plugins
|
|
62
|
+
bash cmd-tools-craft-cms-cli.sh mysite --run "project-config/apply"
|
|
63
|
+
bash cmd-tools-craft-cms-cli.sh mysite --run "migrate/all"
|
|
64
|
+
bash cmd-tools-craft-cms-cli.sh mysite --flush # every cache
|
|
65
|
+
bash cmd-tools-craft-cms-cli.sh mysite --update # Craft CMS and its plugins; the edition stays
|
|
66
|
+
bash cmd-tools-craft-cms-cli.sh mysite --add-users # says whether the site's account is the default account
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
`--run "help"` prints every command of the site's console. Inside the project folder,
|
|
70
|
+
`ddev exec php craft <command>` is the same console, `ddev composer` is Composer, and
|
|
71
|
+
`ddev export-db --file=…`, `ddev import-db --file=…` are the tools for the database.
|
|
72
|
+
|
|
73
|
+
A plugin is a Composer package: `ddev composer require <vendor>/<package>`, then
|
|
74
|
+
`--run "plugin/install <handle>"`. Only free, open-source plugins, installed this way; the plugin
|
|
75
|
+
store in the control panel is not used.
|
|
76
|
+
|
|
77
|
+
The rest is the workspace's, the same for every project: `ddev start -y` and `ddev stop` in the
|
|
78
|
+
project (`stop` takes no `-y`), `bash cmd-tools-backup-<folder>.sh <name>`,
|
|
79
|
+
`bash cmd-tools-clone.sh <name> --to <new>`, `bash cmd-tools-remove.sh <name>`,
|
|
80
|
+
`bash cmd-tools-testing.sh <name>` (the testing stack, with the Craft CMS step pack).
|
|
81
|
+
|
|
82
|
+
## Rules
|
|
83
|
+
|
|
84
|
+
- **Containers only.** Never `php`, `composer`, `npm` or `mysql` on the host for a project.
|
|
85
|
+
- **Never write database settings.** The container tool gives the project its database settings.
|
|
86
|
+
Do not add a host, an account or a password to `.env` or to `config/db.php` by hand.
|
|
87
|
+
- **Solo only.** No licence, no paid edition, no trial, no sign-in to any account or store, and no
|
|
88
|
+
second account. `--run` is not a way around it: do not run a command that changes the edition or
|
|
89
|
+
adds a user.
|
|
90
|
+
- **The account is the workspace account**, or the default account when the site was built with
|
|
91
|
+
`--add-users`; never a made-up one. Do not print the workspace account's password, do not write
|
|
92
|
+
it into a file of the project, and do not put it in a test.
|
|
93
|
+
- **Remove through the tool.** `bash cmd-tools-remove.sh <name>` takes the containers, the volumes
|
|
94
|
+
and the folder down together; `rm -rf` leaves the containers behind.
|
|
95
|
+
- **One build at a time**, and look at `free -g` before a build on a busy machine. A site you built
|
|
96
|
+
to try something is yours to clear: when the work is done, say what you made and offer to remove
|
|
97
|
+
it. Never delete unasked, and never leave it unmentioned.
|
|
98
|
+
- **Never restart the dashboard** or anything shared (the router, another project) to make your own
|
|
99
|
+
work go through.
|
|
100
|
+
- Say what you ran and what it printed. If a build fails, show the line that failed; do not retry
|
|
101
|
+
with different flags until something passes.
|
|
102
|
+
|
|
103
|
+
## When something is off
|
|
104
|
+
|
|
105
|
+
| What you see | What it is |
|
|
106
|
+
| --- | --- |
|
|
107
|
+
| `composer create-project craftcms/craft failed` | No network in the container: the line above it says what Composer could not reach. |
|
|
108
|
+
| `craft install/craft failed` | Most often the account's password is shorter than the 6 characters Craft CMS asks for: it is changed in `core/config/settings.yml`, by its owner. |
|
|
109
|
+
| The installer instead of the site | The build ran without `--install`: finish it at `/admin/install`, or build again with `--install`. |
|
|
110
|
+
| `this site's is not administrator` from `--add-users` | The site's one account is the workspace account, and the edition has no second: build it again with `--install --add-users` if it is to be tested with the default account. |
|
|
111
|
+
| A template change does not show | The caches: `bash cmd-tools-craft-cms-cli.sh <name> --flush`. |
|
|
112
|
+
| `is not a Craft CMS project` from the CLI tool | The project's `.ddev/config.yaml` does not say `type: craftcms`: it was not built by this builder. |
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: craft-cms-tester
|
|
3
|
+
description: Use this agent to test a Craft CMS site of the Webship Workspace with webship-js and the Craft CMS step pack (`@webship-js/craft-cms-steps`) — set the testing stack up with `cmd-tools-testing.sh`, explore the site in the Playwright MCP browser first, write Gherkin scenarios from the pack's own steps, run them in the project's container and read the report. The site is the free Solo edition with one account, the admin: it logs in by the handle `admin` of the users registry, never creates an account in a suite, and never writes a platform name into a step phrase. Invoke for "test this Craft CMS site", "write scenarios for the entries", "why does this scenario fail", or "run the suite on <site>". For building or changing the site itself, hand over to `craft-cms-site-builder`.
|
|
4
|
+
model: fable
|
|
5
|
+
tools:
|
|
6
|
+
- Bash
|
|
7
|
+
- Read
|
|
8
|
+
- Write
|
|
9
|
+
- Edit
|
|
10
|
+
- Glob
|
|
11
|
+
- Grep
|
|
12
|
+
- mcp__playwright__browser_navigate
|
|
13
|
+
- mcp__playwright__browser_snapshot
|
|
14
|
+
- mcp__playwright__browser_click
|
|
15
|
+
- mcp__playwright__browser_type
|
|
16
|
+
- mcp__playwright__browser_evaluate
|
|
17
|
+
- mcp__playwright__browser_tabs
|
|
18
|
+
- mcp__playwright__browser_take_screenshot
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
# craft-cms-tester
|
|
22
|
+
|
|
23
|
+
You test Craft CMS sites in a Webship Workspace (`~/workspace`) with
|
|
24
|
+
[webship-js](https://github.com/webship/webship-js) (Playwright and Cucumber) and its Craft CMS step
|
|
25
|
+
pack, [`@webship-js/craft-cms-steps`](https://github.com/webship/craft-cms-steps). The suite lives in
|
|
26
|
+
the project (`cucumber.js`, `tests/features/`, `tests/step-definitions/`) and runs in the project's
|
|
27
|
+
container.
|
|
28
|
+
|
|
29
|
+
## Set the stack up
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
cd ~/workspace/test # the sites folder the project is in
|
|
33
|
+
bash cmd-tools-testing.sh mysite # webship-js, the step pack, the users registry, a first feature
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
For a Craft CMS project the setup adds the pack to `package.json`, lists its step definitions in
|
|
37
|
+
`cucumber.js` after webship-js's own, writes the users registry and `tests/features/site.feature`,
|
|
38
|
+
and says whether the site's account is the default account. It is idempotent: run it again and it
|
|
39
|
+
adds what is missing, and keeps what you changed.
|
|
40
|
+
|
|
41
|
+
## The order of work
|
|
42
|
+
|
|
43
|
+
1. **Read the installed steps.** They are the source of truth, not memory:
|
|
44
|
+
```bash
|
|
45
|
+
ls node_modules/@webship-js/craft-cms-steps/tests/step-definitions/
|
|
46
|
+
grep -n "^\(Given\|When\|Then\)" node_modules/@webship-js/craft-cms-steps/tests/step-definitions/craft-session.steps.js
|
|
47
|
+
```
|
|
48
|
+
Each step carries a JSDoc block with examples. webship-js's own steps (status codes, classes,
|
|
49
|
+
landmarks, accessibility) are in `node_modules/webship-js/tests/step-definitions/`.
|
|
50
|
+
2. **Look at the site in the Playwright MCP browser first**, in a tab of your own: open the page,
|
|
51
|
+
take a snapshot, do the thing by hand once. A scenario written without having seen the page
|
|
52
|
+
asserts what you imagine. Close your tab when you are done; leave other tabs alone.
|
|
53
|
+
3. **Write the scenario** from steps that exist. Run a dry run before a real one:
|
|
54
|
+
```bash
|
|
55
|
+
bash cmd-tools-testing.sh mysite --dry-run # every step matches one definition, no browser
|
|
56
|
+
```
|
|
57
|
+
4. **Run it**, narrow first, then the whole suite:
|
|
58
|
+
```bash
|
|
59
|
+
bash cmd-tools-testing.sh mysite --run --path tests/features/site.feature
|
|
60
|
+
bash cmd-tools-testing.sh mysite --run --tags "@critical"
|
|
61
|
+
bash cmd-tools-testing.sh mysite --run
|
|
62
|
+
```
|
|
63
|
+
5. **Read the result**: `tests/reports/cucumber_report.html`, the screenshot and the page dump of a
|
|
64
|
+
failed step in `tests/screenshots/`. Report what failed and why, not only that it failed.
|
|
65
|
+
|
|
66
|
+
## The account
|
|
67
|
+
|
|
68
|
+
The site is on the free Solo edition: it has **one account, an admin**, and no user groups. So the
|
|
69
|
+
users registry (`worldParameters.users` in `cucumber.js`) has one handle, and every scenario that
|
|
70
|
+
logs in logs in with it:
|
|
71
|
+
|
|
72
|
+
```gherkin
|
|
73
|
+
Given I am logged in to the control panel as "admin"
|
|
74
|
+
Then I should be logged in to the control panel as "admin"
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
| Handle | Account | Role |
|
|
78
|
+
| --- | --- | --- |
|
|
79
|
+
| `admin` | `administrator` | admin, the one account of the site |
|
|
80
|
+
|
|
81
|
+
That is the default account, on a site built with `--install --add-users`. On a site built without
|
|
82
|
+
`--add-users` the one account is the workspace account, and the edition has no room for a second:
|
|
83
|
+
the setup says so. Then either the site is built again with `--add-users`, or a run is given the
|
|
84
|
+
site's account in its environment (`ADMIN_USER`, `ADMIN_PASSWORD`), never in a file.
|
|
85
|
+
|
|
86
|
+
What a second account would prove (a role that may not open a page, an author who sees only their
|
|
87
|
+
own entries) cannot be tested on this edition. Say so; do not ask for the edition to be changed.
|
|
88
|
+
|
|
89
|
+
## Rules
|
|
90
|
+
|
|
91
|
+
- **Never create an account in a suite.** No `users/create` in a hook, no step that adds one: the
|
|
92
|
+
edition has one account, and it is on the site before the suite runs.
|
|
93
|
+
- **Never the workspace account in a file.** Its password goes in no feature and no `cucumber.js`.
|
|
94
|
+
- **No password in a feature file**, except where a wrong password is the subject of the scenario.
|
|
95
|
+
- **No platform name in a step phrase.** A step says what a person does or sees: `I am logged in to
|
|
96
|
+
the control panel as "admin"`, `I go to the control panel page "entries"`, `the control panel
|
|
97
|
+
heading should be "Dashboard"`. Never a phrase with the platform's name in it. The same holds for
|
|
98
|
+
a custom step you write.
|
|
99
|
+
- **No CSS selector and no address in a scenario when a step of the pack says it.** `the control
|
|
100
|
+
panel page "settings"`, not `/admin/settings`.
|
|
101
|
+
- **Solo only.** No scenario enters a licence, switches an edition or a trial on, or opens the
|
|
102
|
+
plugin store to sign in.
|
|
103
|
+
- **A custom step is the last resort.** Look in the pack and in webship-js first. If one is really
|
|
104
|
+
missing, write it in `tests/step-definitions/`, with a JSDoc block and examples like the pack's,
|
|
105
|
+
and say that it may belong upstream.
|
|
106
|
+
- **Content a scenario creates, it removes**, or it names it so a later run finds and clears it. A
|
|
107
|
+
suite leaves the site as it found it.
|
|
108
|
+
- **Everything runs in the container.** Never `npx cucumber-js` or `npx playwright` on the host for
|
|
109
|
+
a project.
|
|
110
|
+
- **A failing suite is a result.** Do not tag a scenario `@wip`, raise a timeout or loosen an
|
|
111
|
+
assertion to make a run green. Say what the site did.
|
|
112
|
+
|
|
113
|
+
The pack's own features are written for the sections, fields and templates its test site is seeded
|
|
114
|
+
with. A site built here is the starter project with no content model yet: write the scenarios for
|
|
115
|
+
what the site has.
|
|
116
|
+
|
|
117
|
+
## A scenario, the way the pack reads
|
|
118
|
+
|
|
119
|
+
```gherkin
|
|
120
|
+
Feature: The admin reaches the settings
|
|
121
|
+
|
|
122
|
+
Scenario: The admin opens the settings from the dashboard
|
|
123
|
+
Given I am logged in to the control panel as "admin"
|
|
124
|
+
When I go to the control panel page "settings"
|
|
125
|
+
Then the control panel heading should be "Settings"
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
Check every phrase against the installed definitions before you run it: the pack moves, and a phrase
|
|
129
|
+
from memory is a guess.
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
|
|
3
|
+
# workspace-name: Craft CMS (5, Solo)
|
|
4
|
+
|
|
5
|
+
# Installed by the Craft CMS plugin (plugins.sh --install craft-cms); __WORKSPACE__ is the workspace it was installed into.
|
|
6
|
+
#
|
|
7
|
+
# Build a Craft CMS site in a container: the current release of Craft CMS 5, or the one --version
|
|
8
|
+
# names, at https://<name>.ddev.site, on the free Solo edition. With --install the site is
|
|
9
|
+
# installed with the workspace account as its one account, an admin; with --add-users that one
|
|
10
|
+
# account is the default account instead, the one the test scenarios log in as.
|
|
11
|
+
|
|
12
|
+
# Bootstrap.
|
|
13
|
+
# Find the workspace tooling from this script, so a fresh clone needs no setup.
|
|
14
|
+
WORKSPACE_SCRIPTS="${WORKSPACE_SCRIPTS:-$(cd "$(dirname "${BASH_SOURCE[0]}")/../core/scripts" && pwd)}";
|
|
15
|
+
source ${WORKSPACE_SCRIPTS}/bootstrap.sh || exit 1 ;
|
|
16
|
+
|
|
17
|
+
# Load workspace settings.
|
|
18
|
+
eval $(parse_yaml ${WORKSPACE_CONFIG}/workspace.__WORKSPACE__.settings.yml);
|
|
19
|
+
|
|
20
|
+
# Set site version.
|
|
21
|
+
site_version="^5";
|
|
22
|
+
|
|
23
|
+
# Distribution: the name is the DDEV project type, which the user list is named after.
|
|
24
|
+
distribution_name="craftcms";
|
|
25
|
+
distribution_title="Craft CMS";
|
|
26
|
+
distribution_webroot="web";
|
|
27
|
+
project_template="craftcms/craft";
|
|
28
|
+
|
|
29
|
+
ARGPARSE_DESCRIPTION="Build a ${distribution_title} project in __WORKSPACE__"
|
|
30
|
+
# The args file comes with the plugin: core/scripts/plugins/craft-cms/ is where plugins.sh --install puts it.
|
|
31
|
+
source ${WORKSPACE_SCRIPTS}/plugins/craft-cms/args/arg-craft-cms.sh || exit 1 ;
|
|
32
|
+
|
|
33
|
+
shift $#;
|
|
34
|
+
|
|
35
|
+
craftcms_build ;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
|
|
3
|
+
# Installed by the Craft CMS plugin (plugins.sh --install craft-cms); __WORKSPACE__ is the workspace it was installed into.
|
|
4
|
+
#
|
|
5
|
+
# The craft console (php craft) for one Craft CMS project of this workspace, in its container: say
|
|
6
|
+
# what the site is, run a console command, update Craft CMS and its plugins, clear the caches, say
|
|
7
|
+
# whether the default account is the site's. Nothing here runs on the host.
|
|
8
|
+
|
|
9
|
+
# Bootstrap.
|
|
10
|
+
# Find the workspace tooling from this script, so a fresh clone needs no setup.
|
|
11
|
+
WORKSPACE_SCRIPTS="${WORKSPACE_SCRIPTS:-$(cd "$(dirname "${BASH_SOURCE[0]}")/../core/scripts" && pwd)}";
|
|
12
|
+
source ${WORKSPACE_SCRIPTS}/bootstrap.sh || exit 1 ;
|
|
13
|
+
|
|
14
|
+
# Load workspace settings.
|
|
15
|
+
eval $(parse_yaml ${WORKSPACE_CONFIG}/workspace.__WORKSPACE__.settings.yml);
|
|
16
|
+
|
|
17
|
+
# Distribution: the name is the DDEV project type, which the user list is named after.
|
|
18
|
+
distribution_name="craftcms";
|
|
19
|
+
|
|
20
|
+
ARGPARSE_DESCRIPTION="Run the craft console on a Craft CMS project of __WORKSPACE__: status, a command, updates, caches, the default account"
|
|
21
|
+
# The args file comes with the plugin: core/scripts/plugins/craft-cms/ is where plugins.sh --install puts it.
|
|
22
|
+
source ${WORKSPACE_SCRIPTS}/plugins/craft-cms/args/arg-craft-cms-cli.sh || exit 1 ;
|
|
23
|
+
|
|
24
|
+
shift $#;
|
|
25
|
+
|
|
26
|
+
craftcms_cli_tool ;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Craft CMS for Webship Workspace: a platform plugin.
|
|
3
|
+
*
|
|
4
|
+
* What the package carries is placed by the installer from the manifest: the builder and the
|
|
5
|
+
* craft console tool in the sites folders, their functions and argparse under core/scripts/plugins/craft-cms/,
|
|
6
|
+
* the agents in the AI Agents folder. The dashboard needs nothing drawn for it: the builder is in the
|
|
7
|
+
* Build list because it is a cmd-*-project.sh, the row menus are the core's, the agents are listed
|
|
8
|
+
* like any other. What register() adds is what the assistant is told.
|
|
9
|
+
*
|
|
10
|
+
* Everything the dashboard is asked for goes through `api`; this package requires nothing from the
|
|
11
|
+
* dashboard's own files, so it can be installed from npm and removed without a trace.
|
|
12
|
+
*/
|
|
13
|
+
import type { PluginApi } from '@webship.co/workspace-plugin-api';
|
|
14
|
+
/** The plugin's name: what --activate and --install take, and the folder under core/scripts/plugins/. */
|
|
15
|
+
export declare const PLATFORM = "craft-cms";
|
|
16
|
+
/** The DDEV project type of a Craft CMS project, which the functions and the user list are named after. */
|
|
17
|
+
export declare const PROJECT_TYPE = "craftcms";
|
|
18
|
+
/** The commands the installer places in every sites folder. */
|
|
19
|
+
export declare const COMMANDS: string[];
|
|
20
|
+
/** The agents the installer places in the AI Agents folder. */
|
|
21
|
+
export declare const AGENTS: string[];
|
|
22
|
+
/** What the assistant is told about Craft CMS in this workspace. */
|
|
23
|
+
export declare function assistantContext(): string;
|
|
24
|
+
export declare function register(api: PluginApi): void;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Craft CMS for Webship Workspace: a platform plugin.
|
|
4
|
+
*
|
|
5
|
+
* What the package carries is placed by the installer from the manifest: the builder and the
|
|
6
|
+
* craft console tool in the sites folders, their functions and argparse under core/scripts/plugins/craft-cms/,
|
|
7
|
+
* the agents in the AI Agents folder. The dashboard needs nothing drawn for it: the builder is in the
|
|
8
|
+
* Build list because it is a cmd-*-project.sh, the row menus are the core's, the agents are listed
|
|
9
|
+
* like any other. What register() adds is what the assistant is told.
|
|
10
|
+
*
|
|
11
|
+
* Everything the dashboard is asked for goes through `api`; this package requires nothing from the
|
|
12
|
+
* dashboard's own files, so it can be installed from npm and removed without a trace.
|
|
13
|
+
*/
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.AGENTS = exports.COMMANDS = exports.PROJECT_TYPE = exports.PLATFORM = void 0;
|
|
16
|
+
exports.assistantContext = assistantContext;
|
|
17
|
+
exports.register = register;
|
|
18
|
+
/** The plugin's name: what --activate and --install take, and the folder under core/scripts/plugins/. */
|
|
19
|
+
exports.PLATFORM = 'craft-cms';
|
|
20
|
+
/** The DDEV project type of a Craft CMS project, which the functions and the user list are named after. */
|
|
21
|
+
exports.PROJECT_TYPE = 'craftcms';
|
|
22
|
+
/** The commands the installer places in every sites folder. */
|
|
23
|
+
exports.COMMANDS = ['cmd-craft-cms-project.sh', 'cmd-tools-craft-cms-cli.sh'];
|
|
24
|
+
/** The agents the installer places in the AI Agents folder. */
|
|
25
|
+
exports.AGENTS = ['craft-cms-site-builder', 'craft-cms-tester'];
|
|
26
|
+
/** What the assistant is told about Craft CMS in this workspace. */
|
|
27
|
+
function assistantContext() {
|
|
28
|
+
return [
|
|
29
|
+
'Craft CMS (a plugin, @webship.co/workspace-craft-cms): a Craft CMS 5 site is built with',
|
|
30
|
+
'`bash cmd-craft-cms-project.sh <name> --install` from a sites folder (dev, test, sandboxes, demos),',
|
|
31
|
+
'in a container like every other project, at https://<name>.ddev.site (the control panel at /admin).',
|
|
32
|
+
'It is the free Solo edition and stays on it: one account, an admin, and no user groups; never a licence, a paid edition, a trial, or a sign-in to any account or store.',
|
|
33
|
+
'That one account is the workspace account; with --add-users it is the default account instead, the one the test scenarios log in as.',
|
|
34
|
+
'`bash cmd-tools-craft-cms-cli.sh <name>` says what the site is; `--run "<command>"` runs the craft console (php craft) in it,',
|
|
35
|
+
'`--update` updates Craft CMS and its plugins, `--flush` clears the caches.',
|
|
36
|
+
'`bash cmd-tools-testing.sh <name>` sets up webship-js with the Craft CMS step pack; `--run` runs the suite.',
|
|
37
|
+
`For Craft CMS work, hand over to the agents ${exports.AGENTS.map((a) => `\`${a}\``).join(' and ')}.`,
|
|
38
|
+
'Never run php, composer, npm or mysql on the host for a project.',
|
|
39
|
+
].join(' ');
|
|
40
|
+
}
|
|
41
|
+
function register(api) {
|
|
42
|
+
api.addAssistantContext(assistantContext);
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;GAWG;;;AAiBH,4CAaC;AAED,4BAEC;AA9BD,yGAAyG;AAC5F,QAAA,QAAQ,GAAG,WAAW,CAAC;AAEpC,2GAA2G;AAC9F,QAAA,YAAY,GAAG,UAAU,CAAC;AAEvC,+DAA+D;AAClD,QAAA,QAAQ,GAAG,CAAC,0BAA0B,EAAE,4BAA4B,CAAC,CAAC;AAEnF,+DAA+D;AAClD,QAAA,MAAM,GAAG,CAAC,wBAAwB,EAAE,kBAAkB,CAAC,CAAC;AAErE,oEAAoE;AACpE,SAAgB,gBAAgB;IAC9B,OAAO;QACL,yFAAyF;QACzF,qGAAqG;QACrG,qGAAqG;QACrG,yKAAyK;QACzK,sIAAsI;QACtI,+HAA+H;QAC/H,4EAA4E;QAC5E,6GAA6G;QAC7G,+CAA+C,cAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG;QAC7F,kEAAkE;KACnE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACd,CAAC;AAED,SAAgB,QAAQ,CAAC,GAAc;IACrC,GAAG,CAAC,mBAAmB,CAAC,gBAAgB,CAAC,CAAC;AAC5C,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
Feature: The Craft CMS plugin on the dashboard
|
|
2
|
+
Once the plugin is activated and installed, the sites folders offer the Craft CMS builder, the
|
|
3
|
+
AI Agents folder lists the Craft CMS agents, and the Plugins page lists the plugin with its steps.
|
|
4
|
+
|
|
5
|
+
Scenario: The plugin is listed on the Plugins page
|
|
6
|
+
Given I am on "/settings/plugins"
|
|
7
|
+
Then I should see "Craft CMS"
|
|
8
|
+
And I should see "@webship.co/workspace-craft-cms"
|
|
9
|
+
|
|
10
|
+
Scenario: A sites folder offers the Craft CMS builder
|
|
11
|
+
Given I am on "/dev"
|
|
12
|
+
Then "option[value='cmd-craft-cms-project.sh']" should be attached
|
|
13
|
+
|
|
14
|
+
Scenario: The AI Agents folder lists the agents the plugin ships
|
|
15
|
+
Given I am on "/ai-agents"
|
|
16
|
+
Then I should see "craft-cms-site-builder"
|
|
17
|
+
And I should see "craft-cms-tester"
|
package/package.json
CHANGED
|
@@ -1,6 +1,75 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webship.co/workspace-craft-cms",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "1.0.7",
|
|
4
|
+
"description": "Craft CMS for Webship Workspace: the builder (`cmd-craft-cms-project.sh`) and the craft console tool in every sites folder, the default account of the free Solo edition, the Craft CMS step pack wired into the testing setup, and two AI agents in the AI Agents folder.",
|
|
5
|
+
"main": "dist/src/index.js",
|
|
6
|
+
"types": "dist/src/index.d.ts",
|
|
7
|
+
"license": "ISC",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "https://github.com/webship/workspace-craft-cms.git"
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"dist/src",
|
|
14
|
+
"agents",
|
|
15
|
+
"commands",
|
|
16
|
+
"features",
|
|
17
|
+
"scripts",
|
|
18
|
+
"testing",
|
|
19
|
+
"README.md"
|
|
20
|
+
],
|
|
21
|
+
"scripts": {
|
|
22
|
+
"build": "tsc -p tsconfig.json",
|
|
23
|
+
"prepare": "npm run build",
|
|
24
|
+
"test": "npm run build && node --test dist/tests/*.test.js",
|
|
25
|
+
"lint": "tsc -p tsconfig.json --noEmit"
|
|
26
|
+
},
|
|
27
|
+
"workspacePlugin": {
|
|
28
|
+
"name": "craft-cms",
|
|
29
|
+
"label": "Craft CMS",
|
|
30
|
+
"commands": {
|
|
31
|
+
"types": [
|
|
32
|
+
"sites"
|
|
33
|
+
],
|
|
34
|
+
"workspaces": [
|
|
35
|
+
"dev",
|
|
36
|
+
"test",
|
|
37
|
+
"sandboxes",
|
|
38
|
+
"demos"
|
|
39
|
+
],
|
|
40
|
+
"files": [
|
|
41
|
+
"commands/cmd-craft-cms-project.sh",
|
|
42
|
+
"commands/cmd-tools-craft-cms-cli.sh"
|
|
43
|
+
]
|
|
44
|
+
},
|
|
45
|
+
"scripts": {
|
|
46
|
+
"functions": [
|
|
47
|
+
"scripts/functions/fun-craft-cms.sh"
|
|
48
|
+
],
|
|
49
|
+
"args": [
|
|
50
|
+
"scripts/args/arg-craft-cms.sh",
|
|
51
|
+
"scripts/args/arg-craft-cms-cli.sh"
|
|
52
|
+
],
|
|
53
|
+
"machine": [
|
|
54
|
+
"testing/site.feature"
|
|
55
|
+
]
|
|
56
|
+
},
|
|
57
|
+
"ai": {
|
|
58
|
+
"agents": [
|
|
59
|
+
"agents/craft-cms-site-builder.md",
|
|
60
|
+
"agents/craft-cms-tester.md"
|
|
61
|
+
]
|
|
62
|
+
},
|
|
63
|
+
"features": [
|
|
64
|
+
"features/craft-cms.feature"
|
|
65
|
+
]
|
|
66
|
+
},
|
|
67
|
+
"devDependencies": {
|
|
68
|
+
"@types/node": "^24.0.0",
|
|
69
|
+
"@webship.co/workspace-plugin-api": "^1.0.7",
|
|
70
|
+
"typescript": "^5.9.0"
|
|
71
|
+
},
|
|
72
|
+
"publishConfig": {
|
|
73
|
+
"access": "public"
|
|
74
|
+
}
|
|
75
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
|
|
3
|
+
argparse "$@" <<ARGEOF || exit 1
|
|
4
|
+
parser.add_argument('PROJECT_NAME',
|
|
5
|
+
help='The Craft CMS project in this workspace.')
|
|
6
|
+
parser.add_argument('-r', '--run',
|
|
7
|
+
default="_none_",
|
|
8
|
+
help='A craft console command to run in the project, without the leading php craft. Example: --run "project-config/apply"')
|
|
9
|
+
parser.add_argument('-u', '--update',
|
|
10
|
+
action='store_true',
|
|
11
|
+
default=False,
|
|
12
|
+
help='Update Craft CMS and the plugins of the project to their latest releases, and clear the caches. The edition stays what it is.')
|
|
13
|
+
parser.add_argument('-f', '--flush',
|
|
14
|
+
action='store_true',
|
|
15
|
+
default=False,
|
|
16
|
+
help='Clear every cache, and nothing else.')
|
|
17
|
+
parser.add_argument('-a', '--add-users',
|
|
18
|
+
action='store_true',
|
|
19
|
+
default=False,
|
|
20
|
+
help='Say whether the one account of the site is the default account. The Solo edition has one account, so none is created.')
|
|
21
|
+
parser.add_argument('-c', '--cancel-users',
|
|
22
|
+
action='store_true',
|
|
23
|
+
default=False,
|
|
24
|
+
help='Say why the default account stays: it is the only account of the site.')
|
|
25
|
+
ARGEOF
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
|
|
3
|
+
argparse "$@" <<ARGEOF || exit 1
|
|
4
|
+
parser.add_argument('PROJECT_NAME',
|
|
5
|
+
help='The name of the project: its folder, its DDEV project and its host name.')
|
|
6
|
+
parser.add_argument('-v', '--version',
|
|
7
|
+
default="${site_version}",
|
|
8
|
+
help='The Craft CMS release, as a Composer constraint of craftcms/cms. Example: --version 5.8.0 [default %(default)s]')
|
|
9
|
+
parser.add_argument('-i', '--install',
|
|
10
|
+
action='store_true',
|
|
11
|
+
default=False,
|
|
12
|
+
help='Install Craft CMS on the free Solo edition, with the workspace account as its one account, an admin.')
|
|
13
|
+
parser.add_argument('-a', '--add-users',
|
|
14
|
+
action='store_true',
|
|
15
|
+
default=False,
|
|
16
|
+
help='With --install, make the one account of the site the default account instead: the one the test scenarios log in as. The Solo edition has no second account.')
|
|
17
|
+
parser.add_argument('-l', '--launch',
|
|
18
|
+
action='store_true',
|
|
19
|
+
default=False,
|
|
20
|
+
help='Open the site in a browser when it is ready.')
|
|
21
|
+
parser.add_argument('--php-version',
|
|
22
|
+
default="8.3",
|
|
23
|
+
choices=['8.4', '8.3', '8.2'],
|
|
24
|
+
help='PHP version for the project container. Example: --php-version 8.4 [default %(default)s]')
|
|
25
|
+
ARGEOF
|
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
|
|
3
|
+
# Craft CMS for the Webship Workspace: build a site, run the craft console on it, name its one
|
|
4
|
+
# account, and wire its step pack into the testing setup.
|
|
5
|
+
#
|
|
6
|
+
# Placed by `plugins.sh --install craft-cms` in core/scripts/plugins/craft-cms/functions/, where
|
|
7
|
+
# bootstrap sources it after the core's own functions. Everything runs in the project's container
|
|
8
|
+
# (DDEV by default: `ddev composer …`, `ddev exec php craft …`), never on the host. The container
|
|
9
|
+
# tool gives the project its database settings; nothing here writes any.
|
|
10
|
+
#
|
|
11
|
+
# The site is the free Solo edition and stays on it: it has ONE account, an admin, and no user
|
|
12
|
+
# groups. Nothing here enters a licence, switches a paid edition on (not even as a trial), or signs
|
|
13
|
+
# in to any account or store. So the list of default accounts has one entry, and it cannot be
|
|
14
|
+
# added to a site whose one account is somebody else's.
|
|
15
|
+
#
|
|
16
|
+
# Four names are the ones the core's tools look for, under the DDEV project type `craftcms`:
|
|
17
|
+
# set_craftcms_users the default account (cmd-tools-add-users.sh <project> craftcms)
|
|
18
|
+
# add_craftcms_users say whether it is on the site (the same tool, and --add-users of the builder)
|
|
19
|
+
# cancel_craftcms_users say why it stays (cmd-tools-cancel-users.sh <project> craftcms)
|
|
20
|
+
# testing_configure_craftcms the step pack in the testing stack (cmd-tools-testing.sh <project>)
|
|
21
|
+
|
|
22
|
+
# The step pack a Craft CMS project is tested with, and the release line it is required at.
|
|
23
|
+
readonly CRAFT_STEPS_PACKAGE='@webship-js/craft-cms-steps';
|
|
24
|
+
readonly CRAFT_STEPS_VERSION='^2.0.0';
|
|
25
|
+
|
|
26
|
+
# The default account: the one a scenario logs in as. The Solo edition has one account, so the
|
|
27
|
+
# list has one entry. Accounts are configuration; a test suite never creates or deletes one.
|
|
28
|
+
function set_craftcms_users() {
|
|
29
|
+
users=(administrator);
|
|
30
|
+
printf -v "user_administrator_name" '%s' 'administrator' ;
|
|
31
|
+
printf -v "user_administrator_mail" '%s' 'administrator@example.com' ;
|
|
32
|
+
printf -v "user_administrator_password" '%s' 'dD.123123ddd' ;
|
|
33
|
+
printf -v "user_administrator_role" '%s' 'admin' ;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
# Is this folder a Craft CMS project? Its DDEV project type says so.
|
|
37
|
+
function craftcms_is_project() {
|
|
38
|
+
local project_path="$1";
|
|
39
|
+
grep -qE '^type:[[:space:]]*"?craftcms"?[[:space:]]*$' "${project_path}/.ddev/config.yaml" 2>/dev/null ;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
# Is the site installed? The installer writes the project config, and nothing else does.
|
|
43
|
+
function craftcms_is_installed() {
|
|
44
|
+
[ -f "$1/config/project/project.yaml" ] ;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
# Go to the project a tool was asked about, or say why not.
|
|
48
|
+
function craftcms_enter_project() {
|
|
49
|
+
local project_path="${WORKSPACE_ROOT}/${doc_name}/${PROJECT_NAME}";
|
|
50
|
+
if [ ! -d "${project_path}" ] ; then
|
|
51
|
+
echo "No project ${PROJECT_NAME} in ${WORKSPACE_ROOT}/${doc_name}." ;
|
|
52
|
+
return 1 ;
|
|
53
|
+
fi
|
|
54
|
+
if ! craftcms_is_project "${project_path}" ; then
|
|
55
|
+
echo "${doc_name}/${PROJECT_NAME} is not a Craft CMS project (its .ddev/config.yaml does not say type: craftcms)." ;
|
|
56
|
+
return 1 ;
|
|
57
|
+
fi
|
|
58
|
+
cd "${project_path}" || return 1 ;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
# Run the craft console in the container of the project the shell is in. Every argument is
|
|
62
|
+
# quoted for the container's shell, so a site name of two words arrives as one argument.
|
|
63
|
+
function craftcms_cli() {
|
|
64
|
+
local line="php craft" arg ;
|
|
65
|
+
for arg in "$@" ; do
|
|
66
|
+
line="${line} $(printf '%q' "${arg}")" ;
|
|
67
|
+
done
|
|
68
|
+
ddev exec "${line}" ;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
# Is the admin of this username the site's account?
|
|
72
|
+
function craftcms_user_exists() {
|
|
73
|
+
craftcms_cli users/list-admins 2>/dev/null | sed 's/\x1b\[[0-9;]*m//g' | grep -qE "(^|[^A-Za-z0-9._-])$1([^A-Za-z0-9._@-]|$)" ;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
# The release of Craft CMS in the project the shell is in.
|
|
77
|
+
function craftcms_version() {
|
|
78
|
+
ddev composer show craftcms/cms 2>/dev/null | awk '/^versions/ {print $NF}' | tr -d '\r' ;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
# The edition the site is on, from its project config.
|
|
82
|
+
function craftcms_edition() {
|
|
83
|
+
sed -nE 's/^[[:space:]]+edition:[[:space:]]*([a-z]+).*$/\1/p' "$1/config/project/project.yaml" 2>/dev/null | head -1 ;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
# Build a Craft CMS site from nothing: the container, the code, and with --install the site itself.
|
|
87
|
+
function craftcms_build() {
|
|
88
|
+
trim_project_name ;
|
|
89
|
+
local base_url="https://${PROJECT_NAME}.ddev.site" ;
|
|
90
|
+
local version="${VERSION:-${site_version:-^5}}" ;
|
|
91
|
+
local php_version="${PHP_VERSION:-${site_php_version:-8.3}}" ;
|
|
92
|
+
local admin_name="${account_name}" admin_pass="${account_pass}" admin_mail="${account_mail}" ;
|
|
93
|
+
|
|
94
|
+
cd ${WORKSPACE_ROOT}/${doc_name} || exit 1 ;
|
|
95
|
+
|
|
96
|
+
drop_database ;
|
|
97
|
+
rm -rf "${PROJECT_NAME}" ;
|
|
98
|
+
mkdir -p "${PROJECT_NAME}" ;
|
|
99
|
+
cd ${WORKSPACE_ROOT}/${doc_name}/${PROJECT_NAME} || exit 1 ;
|
|
100
|
+
|
|
101
|
+
ddev config --project-type=craftcms --docroot="${distribution_webroot}" --project-name=${PROJECT_NAME} \
|
|
102
|
+
--php-version=${php_version} --nodejs-version=$(ddev_nodejs_version) || exit 1 ;
|
|
103
|
+
ddev_up start -y || exit 1 ;
|
|
104
|
+
|
|
105
|
+
# The starter project. Its post-create script opens an installer that asks questions, so the
|
|
106
|
+
# scripts are skipped and their steps are done here: the environment file and the project's own
|
|
107
|
+
# composer.json.
|
|
108
|
+
ddev composer create-project "${project_template}" --no-scripts --no-interaction \
|
|
109
|
+
|| { echo "composer create-project ${project_template} failed." ; exit 1 ; } ;
|
|
110
|
+
cp .env.example.dev .env || exit 1 ;
|
|
111
|
+
rm -f composer.json && mv composer.json.default composer.json || exit 1 ;
|
|
112
|
+
if [ ! "${version}" == '^5' ] ; then
|
|
113
|
+
ddev composer require "craftcms/cms:${version}" --no-interaction --with-all-dependencies \
|
|
114
|
+
|| { echo "composer require craftcms/cms:${version} failed." ; exit 1 ; } ;
|
|
115
|
+
fi
|
|
116
|
+
|
|
117
|
+
craftcms_cli setup/keys || exit 1 ;
|
|
118
|
+
|
|
119
|
+
if [ "${INSTALL}" == 'yes' ] ; then
|
|
120
|
+
if [ "${ADD_USERS}" == 'yes' ] ; then
|
|
121
|
+
# The Solo edition has one account. With --add-users it is the default account, so that a
|
|
122
|
+
# scenario logs in with an account made for tests and never with the workspace account.
|
|
123
|
+
set_craftcms_users ;
|
|
124
|
+
admin_name="${user_administrator_name}" ; admin_pass="${user_administrator_password}" ; admin_mail="${user_administrator_mail}" ;
|
|
125
|
+
echo "The free Solo edition has one account: it is the default account, ${admin_name}." ;
|
|
126
|
+
fi
|
|
127
|
+
|
|
128
|
+
craftcms_cli install/craft --interactive=0 \
|
|
129
|
+
--username="${admin_name}" --password="${admin_pass}" --email="${admin_mail}" \
|
|
130
|
+
--site-name="${doc_name} ${PROJECT_NAME}" --site-url="${base_url}" --language=en-US \
|
|
131
|
+
|| { echo "craft install/craft failed. Craft CMS asks for a password of 6 characters or more: see account: pass in core/config/settings.yml." ; exit 1 ; } ;
|
|
132
|
+
|
|
133
|
+
echo "${doc_name} ${PROJECT_NAME} has been installed: Craft CMS $(craftcms_version), the $(craftcms_edition "$(pwd)") edition.";
|
|
134
|
+
echo "Go to ${base_url}/admin and log in as ${admin_name}";
|
|
135
|
+
else
|
|
136
|
+
[ "${ADD_USERS}" == 'yes' ] && echo "--add-users needs --install: there is no site to give an account to yet." ;
|
|
137
|
+
echo "${doc_name} ${PROJECT_NAME} is ready to install.";
|
|
138
|
+
echo "Go to ${base_url}/admin/install";
|
|
139
|
+
fi
|
|
140
|
+
|
|
141
|
+
if [ "${LAUNCH}" == 'yes' ] ; then
|
|
142
|
+
ddev launch ;
|
|
143
|
+
fi
|
|
144
|
+
|
|
145
|
+
cd ${WORKSPACE_ROOT}/${doc_name};
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
# The default account on a site that is already there. The Solo edition has one account and the
|
|
149
|
+
# installer made it, so there is nothing to create: this says whether that account is the
|
|
150
|
+
# default one, and what to do when it is not.
|
|
151
|
+
# The list is loaded by the caller (set_craftcms_users): the core's add_users, the builder, the CLI tool.
|
|
152
|
+
function add_craftcms_users() {
|
|
153
|
+
craftcms_enter_project || return 1 ;
|
|
154
|
+
local user user_name user_mail user_role status=0 ;
|
|
155
|
+
for user in "${users[@]}" ; do
|
|
156
|
+
user_name="user_${user}_name"; user_mail="user_${user}_mail"; user_role="user_${user}_role";
|
|
157
|
+
|
|
158
|
+
echo " ---------------------------------------------------------------- ";
|
|
159
|
+
echo " User name: ${!user_name}";
|
|
160
|
+
echo " User mail: ${!user_mail}";
|
|
161
|
+
echo " User role: ${!user_role}";
|
|
162
|
+
echo " ================================================================= ";
|
|
163
|
+
|
|
164
|
+
if craftcms_user_exists "${!user_name}" ; then
|
|
165
|
+
echo " ${!user_name} is already there: it is the site's account." ;
|
|
166
|
+
else
|
|
167
|
+
echo " The free Solo edition has one account, and this site's is not ${!user_name}." ;
|
|
168
|
+
echo " A second account needs a paid edition, which this workspace does not switch on." ;
|
|
169
|
+
echo " Build the site again with --install --add-users to make its one account the default account." ;
|
|
170
|
+
status=1 ;
|
|
171
|
+
fi
|
|
172
|
+
done
|
|
173
|
+
cd ${WORKSPACE_ROOT}/${doc_name};
|
|
174
|
+
return ${status} ;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
# The default account cannot be taken away: it is the site's only account.
|
|
178
|
+
function cancel_craftcms_users() {
|
|
179
|
+
craftcms_enter_project || return 1 ;
|
|
180
|
+
local user user_name ;
|
|
181
|
+
for user in "${users[@]}" ; do
|
|
182
|
+
user_name="user_${user}_name";
|
|
183
|
+
echo " ---------------------------------------------------------------- ";
|
|
184
|
+
echo " User name: ${!user_name}";
|
|
185
|
+
echo " ================================================================= ";
|
|
186
|
+
if craftcms_user_exists "${!user_name}" ; then
|
|
187
|
+
echo " ${!user_name} stays: the free Solo edition has one account, and a site cannot be without it." ;
|
|
188
|
+
echo " Build the site again with --install, and without --add-users, to give that account to the workspace account." ;
|
|
189
|
+
else
|
|
190
|
+
echo " ${!user_name} is not there." ;
|
|
191
|
+
fi
|
|
192
|
+
done
|
|
193
|
+
cd ${WORKSPACE_ROOT}/${doc_name};
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
# What cmd-tools-craft-cms-cli.sh does: the first of --run, --update, --flush, --add-users,
|
|
197
|
+
# --cancel-users that was asked for; with none of them, what the site is.
|
|
198
|
+
function craftcms_cli_tool() {
|
|
199
|
+
trim_project_name ;
|
|
200
|
+
craftcms_enter_project || exit 1 ;
|
|
201
|
+
|
|
202
|
+
if ! ddev describe -j 2>/dev/null | grep -q '"status":"running"' ; then
|
|
203
|
+
ddev start -y || exit 1 ;
|
|
204
|
+
fi
|
|
205
|
+
|
|
206
|
+
if [ ! "${RUN}" == '_none_' ] ; then
|
|
207
|
+
# One string on purpose: --run "project-config/apply --force" is a command and its arguments.
|
|
208
|
+
ddev exec "php craft ${RUN}" ;
|
|
209
|
+
exit $? ;
|
|
210
|
+
fi
|
|
211
|
+
|
|
212
|
+
if [ "${UPDATE}" == 'yes' ] ; then
|
|
213
|
+
craftcms_cli update all --interactive=0 && craftcms_cli clear-caches/all ;
|
|
214
|
+
elif [ "${FLUSH}" == 'yes' ] ; then
|
|
215
|
+
craftcms_cli clear-caches/all ;
|
|
216
|
+
elif [ "${ADD_USERS}" == 'yes' ] ; then
|
|
217
|
+
set_craftcms_users ;
|
|
218
|
+
add_craftcms_users ;
|
|
219
|
+
elif [ "${CANCEL_USERS}" == 'yes' ] ; then
|
|
220
|
+
set_craftcms_users ;
|
|
221
|
+
cancel_craftcms_users ;
|
|
222
|
+
else
|
|
223
|
+
echo "${doc_name}/${PROJECT_NAME}: Craft CMS $(craftcms_version) at https://${PROJECT_NAME}.ddev.site" ;
|
|
224
|
+
if craftcms_is_installed "$(pwd)" ; then
|
|
225
|
+
echo "Edition: $(craftcms_edition "$(pwd)")" ;
|
|
226
|
+
echo "" ; echo "The account:" ; craftcms_cli users/list-admins ;
|
|
227
|
+
echo "" ; echo "Plugins:" ; craftcms_cli plugin/list ;
|
|
228
|
+
else
|
|
229
|
+
echo "The site is not installed yet: open its address at /admin/install, or build it again with --install." ;
|
|
230
|
+
fi
|
|
231
|
+
fi
|
|
232
|
+
cd ${WORKSPACE_ROOT}/${doc_name};
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
# The step pack in the testing stack of a Craft CMS project. The core's testing_configure calls
|
|
236
|
+
# this in the project folder once webship-js is scaffolded and before the dependencies are
|
|
237
|
+
# installed; for a project that is not Craft CMS it changes nothing.
|
|
238
|
+
#
|
|
239
|
+
# It adds the pack to package.json, lists its step definitions in cucumber.js after webship-js's
|
|
240
|
+
# own, gives cucumber.js the users registry of the default account (a handle a scenario reads,
|
|
241
|
+
# mapped to an account; never the workspace account), and writes a first feature when the project
|
|
242
|
+
# has none of its own. Every part is skipped when it is already there, so a second run adds what
|
|
243
|
+
# the first missed and never resets a suite.
|
|
244
|
+
function testing_configure_craftcms() {
|
|
245
|
+
local project_path="$1";
|
|
246
|
+
craftcms_is_project "${project_path}" || return 0 ;
|
|
247
|
+
if [ ! -f "${project_path}/cucumber.js" ] || [ ! -f "${project_path}/package.json" ] ; then
|
|
248
|
+
echo " Craft CMS: cucumber.js is not here yet — run the testing setup again once webship-js is scaffolded." ;
|
|
249
|
+
return 1 ;
|
|
250
|
+
fi
|
|
251
|
+
|
|
252
|
+
echo "Adding the Craft CMS step pack (${CRAFT_STEPS_PACKAGE} ${CRAFT_STEPS_VERSION}).";
|
|
253
|
+
set_craftcms_users ;
|
|
254
|
+
local registry="" user user_name user_password handle ;
|
|
255
|
+
for user in "${users[@]}" ; do
|
|
256
|
+
user_name="user_${user}_name"; user_password="user_${user}_password";
|
|
257
|
+
# The pack's features call the admin "admin".
|
|
258
|
+
handle="${user}" ; [ "${user}" == 'administrator' ] && handle="admin" ;
|
|
259
|
+
registry="${registry}${handle}|${!user_name}|${!user_password}"$'\n' ;
|
|
260
|
+
done
|
|
261
|
+
|
|
262
|
+
# The pack reads ADMIN_USER and ADMIN_PASSWORD, with nothing in front: the registry keeps its names.
|
|
263
|
+
python3 - "${project_path}" "${CRAFT_STEPS_PACKAGE}" "${CRAFT_STEPS_VERSION}" '' 'PASSWORD' "${registry}" <<'PYEOF' || return 1
|
|
264
|
+
import json, re, sys
|
|
265
|
+
|
|
266
|
+
project, pack, version, prefix, secret, registry = sys.argv[1:7]
|
|
267
|
+
|
|
268
|
+
# package.json: the pack as a dev dependency, at the release line this plugin was proven on.
|
|
269
|
+
pkg_file = project + '/package.json'
|
|
270
|
+
pkg = json.load(open(pkg_file))
|
|
271
|
+
if pack not in pkg.get('dependencies', {}) and pack not in pkg.get('devDependencies', {}):
|
|
272
|
+
pkg.setdefault('devDependencies', {})[pack] = version
|
|
273
|
+
open(pkg_file, 'w').write(json.dumps(pkg, indent=2) + '\n')
|
|
274
|
+
print(' package.json: %s %s' % (pack, version))
|
|
275
|
+
|
|
276
|
+
# cucumber.js: the pack's step definitions after webship-js's own, and the users registry.
|
|
277
|
+
cucumber_file = project + '/cucumber.js'
|
|
278
|
+
src = open(cucumber_file).read()
|
|
279
|
+
before = src
|
|
280
|
+
|
|
281
|
+
if ('node_modules/%s/' % pack) not in src:
|
|
282
|
+
line = "'node_modules/%s/tests/step-definitions/**/*.js'," % pack
|
|
283
|
+
core = re.search(r"^([ \t]*)'node_modules/webship-js/tests/step-definitions/[^']*',.*$", src, re.M)
|
|
284
|
+
opening = re.search(r"^([ \t]*)require:[ \t]*\[[ \t]*$", src, re.M)
|
|
285
|
+
if core:
|
|
286
|
+
src = src[:core.end()] + '\n' + core.group(1) + line + src[core.end():]
|
|
287
|
+
elif opening:
|
|
288
|
+
src = src[:opening.end()] + '\n' + opening.group(1) + ' ' + line + src[opening.end():]
|
|
289
|
+
else:
|
|
290
|
+
sys.exit(" cucumber.js has no require list this can add to. Add this line to it:\n " + line)
|
|
291
|
+
print(' cucumber.js: the step definitions of %s' % pack)
|
|
292
|
+
|
|
293
|
+
if not re.search(r"^[ \t]*users:[ \t]*\{", src, re.M):
|
|
294
|
+
world = re.search(r"^([ \t]*)worldParameters:[ \t]*\{[ \t]*$", src, re.M)
|
|
295
|
+
if not world:
|
|
296
|
+
sys.exit(" cucumber.js has no worldParameters block to add the users registry to.")
|
|
297
|
+
pad = world.group(1) + ' '
|
|
298
|
+
lead = '%s_' % prefix if prefix else ''
|
|
299
|
+
rows = [r.split('|') for r in registry.splitlines() if r.strip()]
|
|
300
|
+
block = [
|
|
301
|
+
pad + "// The users registry: a handle a scenario reads, mapped to an account of this site (the default",
|
|
302
|
+
pad + "// accounts: cmd-tools-add-users.sh). Override one with %s<HANDLE>_USER and %s<HANDLE>_%s." % (lead, lead, secret),
|
|
303
|
+
pad + "users: {",
|
|
304
|
+
]
|
|
305
|
+
for handle, name, password in rows:
|
|
306
|
+
env = ('%s_' % prefix if prefix else '') + handle.upper()
|
|
307
|
+
block.append(pad + " %s: { username: process.env.%s_USER || '%s', password: process.env.%s_%s || '%s' }," % (handle, env, name, env, secret, password))
|
|
308
|
+
block.append(pad + "},")
|
|
309
|
+
src = src[:world.end()] + '\n' + '\n'.join(block) + src[world.end():]
|
|
310
|
+
print(' cucumber.js: the users registry (%s)' % ', '.join(r[0] for r in rows))
|
|
311
|
+
|
|
312
|
+
if src != before:
|
|
313
|
+
open(cucumber_file, 'w').write(src)
|
|
314
|
+
PYEOF
|
|
315
|
+
|
|
316
|
+
# A first feature, when the project has none for the site yet: the front page, the login form,
|
|
317
|
+
# the admin account.
|
|
318
|
+
local feature="${WORKSPACE_SCRIPTS}/plugins/craft-cms/site.feature" ;
|
|
319
|
+
if [ -f "${feature}" ] && [ ! -f "${project_path}/tests/features/site.feature" ] ; then
|
|
320
|
+
mkdir -p "${project_path}/tests/features" && cp "${feature}" "${project_path}/tests/features/site.feature" \
|
|
321
|
+
&& echo " tests/features/site.feature: a first feature for the site" ;
|
|
322
|
+
fi
|
|
323
|
+
|
|
324
|
+
# The scenarios log in as the default account. A site has one account: say when it is another.
|
|
325
|
+
if craftcms_is_installed "${project_path}" ; then
|
|
326
|
+
if craftcms_user_exists "${user_administrator_name}" ; then
|
|
327
|
+
echo " the default account is the site's account (${user_administrator_name})" ;
|
|
328
|
+
else
|
|
329
|
+
echo " The site's one account is not the default account (${user_administrator_name}): the free Solo edition has no room for a second." ;
|
|
330
|
+
echo " Give a run the site's own account with ADMIN_USER and ADMIN_PASSWORD in its environment, or build the site again with --install --add-users." ;
|
|
331
|
+
fi
|
|
332
|
+
fi
|
|
333
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
Feature: The site answers and its account works
|
|
2
|
+
As the owner of the site
|
|
3
|
+
I want the front page, the login form and the admin account to work
|
|
4
|
+
So that a build that came out broken is caught before anything else is tested
|
|
5
|
+
|
|
6
|
+
# Placed by the workspace's testing setup as a starting point: it is yours to change.
|
|
7
|
+
# The site is on the free edition, which has one account, an admin: the scenarios log in with
|
|
8
|
+
# it by the handle "admin" of the users registry in cucumber.js, so no password is written here.
|
|
9
|
+
|
|
10
|
+
@critical
|
|
11
|
+
Scenario: The front page is served
|
|
12
|
+
Given I am an anonymous user
|
|
13
|
+
And I am on the homepage
|
|
14
|
+
Then the response status code should be 200
|
|
15
|
+
And the page should have a title
|
|
16
|
+
|
|
17
|
+
@critical
|
|
18
|
+
Scenario: A visitor is sent to the login form
|
|
19
|
+
Given I am an anonymous user
|
|
20
|
+
When I go to "/admin/content/entries"
|
|
21
|
+
Then I should see the control panel login form
|
|
22
|
+
And I should not be logged in to the control panel
|
|
23
|
+
|
|
24
|
+
Scenario: The admin logs in
|
|
25
|
+
Given I am logged in to the control panel as "admin"
|
|
26
|
+
Then I should be logged in to the control panel as "admin"
|
|
27
|
+
And the control panel heading should be "Dashboard"
|
|
28
|
+
|
|
29
|
+
Scenario: The admin may open the pages of an admin
|
|
30
|
+
Given I am logged in to the control panel as "admin"
|
|
31
|
+
Then I should be allowed to open the control panel page "entries"
|
|
32
|
+
And I should be allowed to open the control panel page "settings"
|
|
33
|
+
And I should be allowed to open the control panel page "utilities"
|
|
34
|
+
|
|
35
|
+
Scenario: Logging out ends the session
|
|
36
|
+
Given I am logged in to the control panel as "admin"
|
|
37
|
+
When I log out of the control panel
|
|
38
|
+
Then I should not be logged in to the control panel
|
|
39
|
+
And I should see the control panel login form
|