@webship.co/workspace-craft-cms 1.0.11 → 1.0.12

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 CHANGED
@@ -85,6 +85,7 @@ A workspace that knows none of this (Webship Workspace 1.0.8 and older) ignores
85
85
  | `docs/plugin-items-pattern.md` | How a plugin carries its own commands and AI items, and how to prove it |
86
86
  | `src/index.ts` | `register(api)`: what the assistant is told about Craft CMS here |
87
87
  | `features/craft-cms.feature` | Scenarios for the dashboard's own browser suite |
88
+ | `features/craft-cms-runtimes.feature` | The row, the test users and two pages of a site built on Docker Compose and on Kubernetes |
88
89
 
89
90
  The `workspacePlugin` block in `package.json` is the manifest the installer reads.
90
91
 
@@ -106,14 +107,71 @@ bash cmd-craft-cms-project.sh mysite --install --add-users # the one account
106
107
  | `--install` | Install the site on the Solo edition, with the workspace account as its one account |
107
108
  | `--add-users` | With `--install`: the one account is the default account `administrator` instead, the one the test scenarios log in as |
108
109
  | `--php-version <x>` | The PHP of the project container (`8.3`) |
110
+ | `--runtime <name>` | The container runtime to build on: `ddev` (the default), `docker`, `kubernetes`, `podman`, `lando` or `docksal`. See [Runtimes](#runtimes) |
109
111
  | `--launch` | Open the site when it is ready |
110
112
 
111
- The site answers at `https://mysite.ddev.site`, the control panel at `/admin`. The build runs
113
+ On DDEV the site answers at `https://mysite.ddev.site`, the control panel at `/admin`. The build runs
112
114
  `ddev config --project-type=craftcms` with the docroot `web` and the Node.js of the workspace (24),
113
115
  creates the project with Composer in the container from the starter `craftcms/craft`, and installs
114
116
  it with Craft's own `install/craft` command, which asks no question. The container tool gives the
115
117
  project its database settings: the plugin writes none. A project of the same name is deleted first.
116
118
 
119
+
120
+ ### Runtimes
121
+
122
+ ```bash
123
+ bash cmd-craft-cms-project.sh mysite --install --add-users # DDEV, the default
124
+ bash cmd-craft-cms-project.sh mysite --install --add-users --runtime docker # Docker Compose
125
+ bash cmd-craft-cms-project.sh mysite --install --add-users --runtime kubernetes # a Kubernetes cluster
126
+ bash cmd-craft-cms-project.sh mysite --install --add-users --runtime lando # Lando
127
+ bash cmd-craft-cms-project.sh mysite --install --add-users --runtime docksal # Docksal
128
+ ```
129
+
130
+ Without `--runtime` a build takes `container.runtime` of the workspace's `settings.yml`, then DDEV.
131
+ It needs a Webship Workspace with the container runtimes
132
+ ([webship/workspace#694](https://github.com/webship/workspace/issues/694)); on an older one the
133
+ builder refuses `--runtime` and builds on DDEV only. Lando and Docksal need a Workspace whose runtime
134
+ layer has them ([webship/workspace#729](https://github.com/webship/workspace/issues/729),
135
+ [#730](https://github.com/webship/workspace/issues/730)).
136
+
137
+ | | DDEV | Docker Compose | Kubernetes | Podman | Lando | Docksal |
138
+ | --- | --- | --- | --- | --- | --- | --- |
139
+ | Build with `--install --add-users` (the Solo edition, its one account) | Yes | Yes | Yes | Not yet run | Yes | Yes |
140
+ | The front page and the control panel's login | Yes | Yes | Yes | Not yet run | Yes | Yes |
141
+ | `cmd-tools-craft-cms-cli.sh`: status, `--run`, the account | Yes | Yes | Yes | Not yet run | Yes | Yes |
142
+ | The test account, said to be there and kept | Yes | Yes | Yes | Not yet run | Yes | Yes |
143
+ | Mail caught by Mailpit (`--run "mailer/test …"`) | Yes | Yes | Yes | Not yet run | Yes | Yes |
144
+ | The testing setup and the first feature | Yes | Yes | Yes | Not yet run | Yes | Yes |
145
+ | The step pack's examples, with its content (99 scenarios) | 95 of 99 (*) | 95 of 99 (*) | 95 of 99 (*) | Not yet run | 95 of 99 (*) | 95 of 99 (*) |
146
+ | Export and import the database | Yes | Yes | Yes | Not yet run | Yes | Yes |
147
+ | The row in the dashboard, and remove | Yes | Yes | Yes | Not yet run | Yes | Yes |
148
+
149
+ "Yes" means it was run on a real site of that runtime. Podman runs the same code as Docker Compose
150
+ and was not run yet. (*) With the content of the step pack's README (its editor field, templates and
151
+ seed), on every runtime, DDEV included: the four are the ones its README names for a site of this
152
+ plugin, which read the account and the site name of the pack's own test site (`admin`,
153
+ `admin@example.com`, "Webship Test Site").
154
+
155
+ | Runtime | The site's address | What the project carries |
156
+ | --- | --- | --- |
157
+ | DDEV | `https://mysite.ddev.site` | `.ddev/config.yaml` |
158
+ | Docker Compose | `http://127.0.0.1:<port>`, printed by the build | `compose.yaml`, `.webship/runtime/Dockerfile` |
159
+ | Kubernetes | `http://<node address>:<port>`, printed by the build | The same, and `k8s/` (the namespace `ws-mysite`) |
160
+ | Lando | `http://127.0.0.1:<port>`, printed by the build | `.lando.yml` (Lando's proxy stays off) |
161
+ | Docksal | `http://mysite.docksal.site`, on Docksal's own proxy | `.docksal/docksal.env`, `.docksal/docksal.yml` |
162
+
163
+ What differs on Docker Compose, Kubernetes, Lando and Docksal:
164
+
165
+ - **`.env`** gets the database DDEV's `craftcms` type gives the container: `CRAFT_DB_DRIVER=mysql`, `CRAFT_DB_SERVER=db`, `CRAFT_DB_PORT=3306`, `CRAFT_DB_DATABASE=db`, `CRAFT_DB_USER=db`, `CRAFT_DB_PASSWORD=db`. Nothing personal; on DDEV the builder still writes none.
166
+ - **The site URL** the install records (`PRIMARY_SITE_URL`) is the runtime's address.
167
+ - **Mail:** Craft's own Sendmail transport goes through the container's `sendmail`, which each runtime hands to its mail catcher.
168
+ - **`composer create-project`** is told the project root (`.`), as DDEV takes it.
169
+ - **HTTPS and a host name** are DDEV's: a runtime's address is plain HTTP.
170
+
171
+ The same commands work on every runtime: `cmd-tools-craft-cms-cli.sh`, `cmd-tools-add-users.sh`,
172
+ `cmd-tools-testing.sh`. The pattern is the Workspace's
173
+ [`core/docs/plugins-on-runtimes.md`](https://github.com/webship/workspace/blob/1.0.x/core/docs/plugins-on-runtimes.md).
174
+
117
175
  ### Work on a site
118
176
 
119
177
  ```bash
@@ -49,12 +49,14 @@ bash cmd-craft-cms-project.sh mysite --install
49
49
  | `--php-version <x>` | The PHP of the project container (`8.3` by default). |
50
50
  | `--launch` | Opens the site when it is ready. |
51
51
 
52
- The site answers at `https://<name>.ddev.site`, the control panel at `/admin`. It is a Composer
52
+ On DDEV the site answers at `https://<name>.ddev.site`, the control panel at `/admin`. It is a Composer
53
53
  project from the starter `craftcms/craft`: the docroot is `web/`, the templates are in `templates/`,
54
54
  the project config in `config/project/`. The builder **deletes a project of the same name first**: a
55
55
  build is a clean slate, so never point it at a site somebody still needs. The name is a folder, a
56
56
  container project and a host name: short, lowercase, letters and digits.
57
57
 
58
+ With `--runtime docker`, `podman`, `kubernetes`, `lando` or `docksal` the site is built on that runtime instead, at the address the build prints (`http://127.0.0.1:<port>`, the node's address and a port, or `http://<name>.docksal.site`): never write a `ddev.site` address for such a site. Its mailbox is at the address `rt_mail_url` gives, and the same commands work on it.
59
+
58
60
  ## Work on a site
59
61
 
60
62
  ```bash
@@ -5,7 +5,8 @@
5
5
  # Installed by the Craft CMS plugin (plugins.sh --install craft-cms); __WORKSPACE__ is the workspace it was installed into.
6
6
  #
7
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
8
+ # names, on DDEV (the default) at https://<name>.ddev.site, or
9
+ # with --runtime docker, podman, kubernetes, lando or docksal at the address the build prints, on the free Solo edition. With --install the site is
9
10
  # installed with the workspace account as its one account, an admin; with --add-users that one
10
11
  # account is the default account instead, the one the test scenarios log in as.
11
12
 
package/dist/src/index.js CHANGED
@@ -36,7 +36,7 @@ function assistantContext() {
36
36
  return [
37
37
  'Craft CMS (a plugin, @webship.co/workspace-craft-cms): a Craft CMS 5 site is built with',
38
38
  '`bash cmd-craft-cms-project.sh <name> --install` from a sites folder (dev, test, sandboxes, demos),',
39
- 'in a container like every other project, at https://<name>.ddev.site (the control panel at /admin).',
39
+ 'in a container like every other project: on DDEV by default, at https://<name>.ddev.site, or with `--runtime docker|podman|kubernetes|lando|docksal` on that runtime, at the address the build prints, (the control panel at /admin).',
40
40
  '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.',
41
41
  'That one account is the workspace account; with --add-users it is the default account instead, the one the test scenarios log in as.',
42
42
  '`bash cmd-tools-craft-cms-cli.sh <name>` says what the site is; `--run "<command>"` runs the craft console (php craft) in it,',
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;GAaG;;;AA0BH,4CAeC;AAED,4BAEC;AAzCD,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,iGAAiG;AACpF,QAAA,MAAM,GAAG,CAAC,qBAAqB,CAAC,CAAC;AAE9C,wEAAwE;AAC3D,QAAA,WAAW,GAAG,CAAC,gBAAgB,CAAC,CAAC;AAE9C,+GAA+G;AAClG,QAAA,OAAO,GAAG,CAAC,0BAA0B,CAAC,CAAC;AAEpD,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,oCAAoC,cAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,oDAAoD;QAChI,eAAe,mBAAW,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,mCAAmC,eAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,kBAAkB;QACrK,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"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;GAaG;;;AA0BH,4CAeC;AAED,4BAEC;AAzCD,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,iGAAiG;AACpF,QAAA,MAAM,GAAG,CAAC,qBAAqB,CAAC,CAAC;AAE9C,wEAAwE;AAC3D,QAAA,WAAW,GAAG,CAAC,gBAAgB,CAAC,CAAC;AAE9C,+GAA+G;AAClG,QAAA,OAAO,GAAG,CAAC,0BAA0B,CAAC,CAAC;AAEpD,oEAAoE;AACpE,SAAgB,gBAAgB;IAC9B,OAAO;QACL,yFAAyF;QACzF,qGAAqG;QACrG,uOAAuO;QACvO,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,oCAAoC,cAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,oDAAoD;QAChI,eAAe,mBAAW,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,mCAAmC,eAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,kBAAkB;QACrK,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,54 @@
1
+ Feature: A site on Docker Compose and on Kubernetes
2
+ The builder builds on DDEV by default, and with --runtime on Docker Compose, Podman, Kubernetes, Lando or
3
+ Docksal. A site built on Docker Compose or Kubernetes has the row a DDEV site has: its state, its own
4
+ address, the runtime's menu, and the test users of the plugin in its Tests menu.
5
+
6
+ # Each scenario drives a real site of that runtime, built with cmd-craft-cms-project.sh --runtime: the first running
7
+ # one the workspace holds of this platform. Without one it is skipped, with the reason. In the plugin's CI the
8
+ # Docker Compose site is the one the manifest's featuresSite builds.
9
+
10
+ @needs-runtime-docker @needs-platform-craftcms
11
+ Scenario: A site built on Docker Compose runs at its own address, with the DOCKER menu
12
+ Given I am on the folder of the "docker" site
13
+ Then the row of the "docker" site should show "Running"
14
+ And the row of the "docker" site should link to the address of its runtime
15
+ And the address of the "docker" site should answer
16
+ And the row of the "docker" site should carry the "DOCKER" menu and no DDEV menu
17
+
18
+ @needs-runtime-docker @needs-platform-craftcms
19
+ Scenario: The Tests menu of a site on Docker Compose offers the test users
20
+ Given I am on the folder of the "docker" site
21
+ When I open the "tests" menu of the "docker" site
22
+ Then the open menu should offer "Add the test users"
23
+ And the open menu should offer "Cancel the test users"
24
+
25
+ @needs-runtime-docker @needs-platform-craftcms
26
+ Scenario: The site on Docker Compose is installed: its control panel asks for a login
27
+ Given I am on the folder of the "docker" site
28
+ When I open "/admin" on the "docker" site
29
+ Then I should see "Username or Email"
30
+ When I open "/admin/login" on the "docker" site
31
+ Then I should see "Forgot password?"
32
+
33
+ @needs-runtime-kubernetes @needs-platform-craftcms
34
+ Scenario: A site built on Kubernetes runs at the address of its node, with the K8S menu
35
+ Given I am on the folder of the "kubernetes" site
36
+ Then the row of the "kubernetes" site should show "Running"
37
+ And the row of the "kubernetes" site should link to the address of its runtime
38
+ And the address of the "kubernetes" site should answer
39
+ And the row of the "kubernetes" site should carry the "K8S" menu and no DDEV menu
40
+
41
+ @needs-runtime-kubernetes @needs-platform-craftcms
42
+ Scenario: The Tests menu of a site on Kubernetes offers the test users
43
+ Given I am on the folder of the "kubernetes" site
44
+ When I open the "tests" menu of the "kubernetes" site
45
+ Then the open menu should offer "Add the test users"
46
+ And the open menu should offer "Cancel the test users"
47
+
48
+ @needs-runtime-kubernetes @needs-platform-craftcms
49
+ Scenario: The site on Kubernetes is installed: its control panel asks for a login
50
+ Given I am on the folder of the "kubernetes" site
51
+ When I open "/admin" on the "kubernetes" site
52
+ Then I should see "Username or Email"
53
+ When I open "/admin/login" on the "kubernetes" site
54
+ Then I should see "Forgot password?"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webship.co/workspace-craft-cms",
3
- "version": "1.0.11",
3
+ "version": "1.0.12",
4
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 its AI items in their folders: two agents, a skill, a command and a prompt.",
5
5
  "main": "dist/src/index.js",
6
6
  "types": "dist/src/index.d.ts",
@@ -83,8 +83,10 @@
83
83
  ]
84
84
  },
85
85
  "features": [
86
- "features/craft-cms.feature"
87
- ]
86
+ "features/craft-cms.feature",
87
+ "features/craft-cms-runtimes.feature"
88
+ ],
89
+ "featuresSite": "cmd-craft-cms-project.sh ci-craft-cms --install --add-users --runtime docker"
88
90
  },
89
91
  "devDependencies": {
90
92
  "@types/node": "^24.0.0",
@@ -2,7 +2,12 @@
2
2
 
3
3
  argparse "$@" <<ARGEOF || exit 1
4
4
  parser.add_argument('PROJECT_NAME',
5
- help='The name of the project: its folder, its DDEV project and its host name.')
5
+ help='The name of the project: its folder, and its name on the container runtime (on DDEV its host name too).')
6
+ parser.add_argument('--runtime',
7
+ dest='RUNTIME',
8
+ default="_none_",
9
+ choices=['ddev', 'docker', 'podman', 'kubernetes', 'lando', 'docksal'],
10
+ help='The container runtime to build on: ddev (the default, or container.runtime of settings.yml), docker (Docker Compose), podman, kubernetes, lando or docksal.')
6
11
  parser.add_argument('-v', '--version',
7
12
  default="${site_version}",
8
13
  help='The Craft CMS release, as a Composer constraint of craftcms/cms. Example: --version 5.8.0 [default %(default)s]')
@@ -5,8 +5,16 @@
5
5
  #
6
6
  # Placed by `plugins.sh --install craft-cms` in core/scripts/plugins/craft-cms/functions/, where
7
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.
8
+ # (DDEV by default: `ddev composer …`, `ddev exec php craft …`), never on the host. On DDEV the
9
+ # container tool gives the project its database settings; nothing here writes any.
10
+ #
11
+ # The runtimes: a site is built on DDEV, or with --runtime on Docker Compose, Podman, Kubernetes, Lando
12
+ # or Docksal. The commands are the same on each: `ddev <verb>` is DDEV itself on a DDEV project, and on
13
+ # another runtime the core's layer (fun-runtime.sh) gives the verb its meaning there. What differs is
14
+ # behind craftcms_runtime: the address (craftcms_url), the folder `composer create-project` makes the
15
+ # project in (DDEV takes the project root, the layer is told "."), and what DDEV's craftcms type gives
16
+ # the site and the other runtimes do not (craftcms_runtime_config: the database of the project's own
17
+ # stack, db/db/db on the host db, in the site's .env).
10
18
  #
11
19
  # The site is the free Solo edition and stays on it: it has ONE account, an admin, and no user
12
20
  # groups. Nothing here enters a licence, switches a paid edition on (not even as a trial), or signs
@@ -33,9 +41,65 @@ function set_craftcms_users() {
33
41
  printf -v "user_administrator_role" '%s' 'admin' ;
34
42
  }
35
43
 
36
- # Is this folder a Craft CMS project? Its DDEV project type says so.
44
+ # The runtime of the project in this folder, or of a new build (--runtime, else the workspace's
45
+ # setting, else DDEV). A core without the runtime layer has DDEV only.
46
+ function craftcms_runtime() {
47
+ if declare -f runtime_of > /dev/null ; then runtime_of ; else echo 'ddev' ; fi
48
+ }
49
+
50
+ # The address of the site in this folder: https://<name>.ddev.site on DDEV, http://127.0.0.1:<port> on
51
+ # Docker Compose, Podman and Lando, the node's address and a port on Kubernetes, http://<name>.docksal.site
52
+ # on Docksal. Asked after `ddev config`.
53
+ function craftcms_url() {
54
+ if declare -f rt_url > /dev/null ; then rt_url ; else echo "https://${PROJECT_NAME}.ddev.site" ; fi
55
+ }
56
+
57
+ # Set keys of the site's .env: each where the file has it (commented out or not), else at the end.
58
+ # Only on a runtime that is not DDEV: there DDEV's craftcms type gives the container the values.
59
+ function craftcms_dotenv_set() {
60
+ python3 - "$@" <<'PYEOF'
61
+ import re, sys
62
+ path, pairs = sys.argv[1], []
63
+ for arg in sys.argv[2:]:
64
+ key, _, value = arg.partition('=')
65
+ if not re.match(r'^[A-Z][A-Z0-9_]*$', key):
66
+ sys.exit('craftcms_dotenv_set: KEY=value, not ' + arg)
67
+ if re.search(r'[\s#"\'$\\]', value):
68
+ value = '"' + value.replace('\\', '\\\\').replace('"', '\\"') + '"'
69
+ pairs.append((key, value))
70
+ try:
71
+ lines = open(path).read().split('\n')
72
+ except FileNotFoundError:
73
+ lines = []
74
+ if lines and lines[-1] == '':
75
+ lines.pop()
76
+ for key, value in pairs:
77
+ found = [i for i, l in enumerate(lines) if re.match(r'^\s*' + re.escape(key) + r'\s*=', l)] \
78
+ or [i for i, l in enumerate(lines) if re.match(r'^\s*#\s*' + re.escape(key) + r'\s*=', l)]
79
+ if found:
80
+ lines[found[0]] = key + '=' + value
81
+ else:
82
+ lines.append(key + '=' + value)
83
+ open(path, 'w').write('\n'.join(lines) + '\n')
84
+ PYEOF
85
+ }
86
+
87
+ # What DDEV's craftcms project type gives the site, and the other runtimes do not: the database of the
88
+ # project's own stack (db, db, db on the host db, as on every runtime), in the site's .env. Only on a
89
+ # runtime that is not DDEV, in the project folder.
90
+ function craftcms_runtime_config() {
91
+ craftcms_dotenv_set .env CRAFT_DB_DRIVER=mysql CRAFT_DB_SERVER=db CRAFT_DB_PORT=3306 \
92
+ CRAFT_DB_DATABASE=db CRAFT_DB_USER=db CRAFT_DB_PASSWORD=db CRAFT_DB_SCHEMA= CRAFT_DB_TABLE_PREFIX= ;
93
+ }
94
+
95
+ # Is this folder a Craft CMS project? Its project type says so: on DDEV in .ddev/config.yaml, on another
96
+ # runtime in the x-webship block, both read by the core's rt_is_platform.
37
97
  function craftcms_is_project() {
38
98
  local project_path="$1";
99
+ if declare -f rt_is_platform > /dev/null ; then
100
+ rt_is_platform "${project_path}" craftcms ;
101
+ return $? ;
102
+ fi
39
103
  grep -qE '^type:[[:space:]]*"?craftcms"?[[:space:]]*$' "${project_path}/.ddev/config.yaml" 2>/dev/null ;
40
104
  }
41
105
 
@@ -52,7 +116,7 @@ function craftcms_enter_project() {
52
116
  return 1 ;
53
117
  fi
54
118
  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)." ;
119
+ echo "${doc_name}/${PROJECT_NAME} is not a Craft CMS project (its project type is not craftcms)." ;
56
120
  return 1 ;
57
121
  fi
58
122
  cd "${project_path}" || return 1 ;
@@ -86,7 +150,12 @@ function craftcms_edition() {
86
150
  # Build a Craft CMS site from nothing: the container, the code, and with --install the site itself.
87
151
  function craftcms_build() {
88
152
  trim_project_name ;
89
- local base_url="https://${PROJECT_NAME}.ddev.site" ;
153
+ local base_url runtime ;
154
+ runtime="$(craftcms_runtime)" ;
155
+ if [ "${RUNTIME:-_none_}" != '_none_' ] && [ "${RUNTIME}" != "${runtime}" ] ; then
156
+ echo "--runtime ${RUNTIME} needs a Webship Workspace with the container runtimes (webship/workspace#694): update the workspace, or build on DDEV." ;
157
+ exit 1 ;
158
+ fi
90
159
  local version="${VERSION:-${site_version:-^5}}" ;
91
160
  local php_version="${PHP_VERSION:-${site_php_version:-8.3}}" ;
92
161
  local admin_name="${account_name}" admin_pass="${account_pass}" admin_mail="${account_mail}" ;
@@ -100,14 +169,23 @@ function craftcms_build() {
100
169
 
101
170
  ddev config --project-type=craftcms --docroot="${distribution_webroot}" --project-name=${PROJECT_NAME} \
102
171
  --php-version=${php_version} --nodejs-version=$(ddev_nodejs_version) || exit 1 ;
172
+ # The address is the runtime's to say, once the project is configured: never a written ddev.site.
173
+ base_url="$(craftcms_url)" ;
103
174
  ddev_up start -y || exit 1 ;
104
175
 
105
176
  # The starter project. Its post-create script opens an installer that asks questions, so the
106
177
  # scripts are skipped and their steps are done here: the environment file and the project's own
107
178
  # composer.json.
108
- ddev composer create-project "${project_template}" --no-scripts --no-interaction \
179
+ # DDEV makes it in the project root; the layer of another runtime is told so (".").
180
+ local into='' ;
181
+ [ "${runtime}" != 'ddev' ] && into='.' ;
182
+ ddev composer create-project "${project_template}" ${into} --no-scripts --no-interaction \
109
183
  || { echo "composer create-project ${project_template} failed." ; exit 1 ; } ;
110
184
  cp .env.example.dev .env || exit 1 ;
185
+ if [ "${runtime}" != 'ddev' ] ; then
186
+ # What DDEV's craftcms type gives the container: the database of the project's own stack.
187
+ craftcms_runtime_config || { echo "The .env of the site could not be written." ; exit 1 ; } ;
188
+ fi
111
189
  rm -f composer.json && mv composer.json.default composer.json || exit 1 ;
112
190
  if [ ! "${version}" == '^5' ] ; then
113
191
  ddev composer require "craftcms/cms:${version}" --no-interaction --with-all-dependencies \
@@ -220,7 +298,7 @@ function craftcms_cli_tool() {
220
298
  set_craftcms_users ;
221
299
  cancel_craftcms_users ;
222
300
  else
223
- echo "${doc_name}/${PROJECT_NAME}: Craft CMS $(craftcms_version) at https://${PROJECT_NAME}.ddev.site" ;
301
+ echo "${doc_name}/${PROJECT_NAME}: Craft CMS $(craftcms_version) at $(craftcms_url)" ;
224
302
  if craftcms_is_installed "$(pwd)" ; then
225
303
  echo "Edition: $(craftcms_edition "$(pwd)")" ;
226
304
  echo "" ; echo "The account:" ; craftcms_cli users/list-admins ;