@webship.co/workspace-filament 1.0.0 → 1.0.1

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
@@ -77,6 +77,7 @@ Everything the builder runs for an app runs in the app's own container, through
77
77
  | `ai/prompts/filament-build-and-test.md`, `filament-scenarios-for-a-resource.md` | Two prompts: whole launch commands for a new session |
78
78
  | `src/index.ts` | `register(api)`: what the assistant is told about Filament here |
79
79
  | `features/filament.feature` | Scenarios for the dashboard's own browser suite |
80
+ | `features/filament-runtimes.feature` | The row, the test users and the login page of an app built on Docker Compose and on Kubernetes |
80
81
 
81
82
  The `workspacePlugin` block in `package.json` is the manifest the installer reads.
82
83
 
@@ -98,6 +99,7 @@ bash cmd-filament-project.sh mydemo --install --add-users --demo # the panel'
98
99
  | `--starter-kit <kit>` | Without `--demo`: the starter kit of the new app, `livewire` (the default), `react` or `vue` |
99
100
  | `--production` | Run the app as a live app runs (`APP_ENV=production`, `APP_DEBUG=false`): the error pages instead of the debug page |
100
101
  | `--php-version <x>` | The PHP of the project container (8.4 by default: the demo app's packages need it) |
102
+ | `--runtime <name>` | The container runtime to build on: `ddev` (the default), `docker`, `kubernetes`, `podman`, `lando` or `docksal`. See [Runtimes](#runtimes) |
101
103
  | `--launch` | Open the panel when it is ready |
102
104
 
103
105
  What the builder changes, each change marked "Webship Workspace" where it is made: the User model says
@@ -105,9 +107,12 @@ which accounts the panel lets in, as the panel's documentation shows it for an a
105
107
  address verified); the demo app's admin panel checks it with the panel's own middleware on every page;
106
108
  a new panel offers the password reset; the app's mail gets a sender address (the password reset mail
107
109
  needs one); a new app runs its queue in the request (`QUEUE_CONNECTION=sync`: the panel's password
108
- reset mail is a queued notification, and a local app runs no queue worker).
110
+ reset mail is a queued notification, and a local app runs no queue worker). The demo app's `.npmrc`
111
+ holds back every npm package younger than seven days (`min-release-age=7`): the builder takes that
112
+ line out, and only that line, and says so, because the testing setup installs step packs younger than
113
+ that, which npm would not find.
109
114
 
110
- The app answers at `https://myapp.ddev.site` (the panel at `/admin`, or at the root of the demo app),
115
+ On DDEV the app answers at `https://myapp.ddev.site` (the panel at `/admin`, or at the root of the demo app),
111
116
  its mail catcher at `https://myapp.ddev.site:8026`. The builder runs `ddev config
112
117
  --project-type=laravel` with the Node.js of the workspace (24); the container tool writes the database
113
118
  settings, the builder writes none. A project of the same name is deleted first.
@@ -115,6 +120,59 @@ settings, the builder writes none. A project of the same name is deleted first.
115
120
  Nothing paid and no account anywhere: the open-source panel from Packagist and its open-source demo
116
121
  app.
117
122
 
123
+
124
+ ### Runtimes
125
+
126
+ ```bash
127
+ bash cmd-filament-project.sh mydemo --demo --install --add-users # DDEV, the default
128
+ bash cmd-filament-project.sh mydemo --demo --install --add-users --runtime docker # Docker Compose
129
+ bash cmd-filament-project.sh mydemo --demo --install --add-users --runtime kubernetes # a Kubernetes cluster
130
+ bash cmd-filament-project.sh mydemo --demo --install --add-users --runtime lando # Lando
131
+ bash cmd-filament-project.sh mydemo --demo --install --add-users --runtime docksal # Docksal
132
+ ```
133
+
134
+ Without `--runtime` a build takes `container.runtime` of the workspace's `settings.yml`, then DDEV.
135
+ It needs a Webship Workspace with the container runtimes
136
+ ([webship/workspace#694](https://github.com/webship/workspace/issues/694)); on an older one the
137
+ builder refuses `--runtime` and builds on DDEV only. Lando and Docksal need a Workspace whose runtime
138
+ layer has them ([webship/workspace#729](https://github.com/webship/workspace/issues/729),
139
+ [#730](https://github.com/webship/workspace/issues/730)).
140
+
141
+ | | DDEV | Docker Compose | Kubernetes | Podman | Lando | Docksal |
142
+ | --- | --- | --- | --- | --- | --- | --- |
143
+ | The demo app, built with `--demo --install --add-users` | Yes | Yes | Yes | Not yet run | Yes | Yes |
144
+ | The panel's pages | Yes | Yes | Yes | Not yet run | Yes | Yes |
145
+ | `cmd-tools-laravel-artisan.sh`: status, `--run`, the accounts | Yes | Yes | Yes | Not yet run | Yes | Yes |
146
+ | Test users, added and cancelled | Yes | Yes | Yes | Not yet run | Yes | Yes |
147
+ | Mail caught by Mailpit | Yes | Yes | Yes | Not yet run | Yes | Yes |
148
+ | The testing setup and the first feature | Yes | Yes | Yes | Not yet run | Yes | Yes |
149
+ | The step pack's examples (49 scenarios) | 48 of 49 (*) | 48 of 49 (*) | 48 of 49 (*) | Not yet run | 48 of 49 (*) | 48 of 49 (*) |
150
+ | Export and import the database | Yes | Yes | Yes | Not yet run | Yes | Yes |
151
+ | The row in the dashboard, and remove | Yes | Yes | Yes | Not yet run | Yes | Yes |
152
+
153
+ "Yes" means it was run on a real app of that runtime. Podman runs the same code as Docker Compose
154
+ and was not run yet. (*) The one scenario is the step pack's own, on every runtime, DDEV included: it
155
+ expects the subject "Reset Password Notification", and the demo of today sends "Reset your password".
156
+
157
+ | Runtime | The app's address | What the project carries |
158
+ | --- | --- | --- |
159
+ | DDEV | `https://myapp.ddev.site` | `.ddev/config.yaml` |
160
+ | Docker Compose | `http://127.0.0.1:<port>`, printed by the build | `compose.yaml`, `.webship/runtime/Dockerfile` |
161
+ | Kubernetes | `http://<node address>:<port>`, printed by the build | The same, and `k8s/` (the namespace `ws-myapp`) |
162
+ | Lando | `http://127.0.0.1:<port>`, printed by the build | `.lando.yml` (Lando's proxy stays off) |
163
+ | Docksal | `http://myapp.docksal.site`, on Docksal's own proxy | `.docksal/docksal.env`, `.docksal/docksal.yml` |
164
+
165
+ What differs on Docker Compose, Kubernetes, Lando and Docksal:
166
+
167
+ - **It needs the Laravel plugin 1.0.2 or later**, which builds on the runtimes: the demo's `.env` gets what DDEV's start writes (the address, `db`/`db`/`db` on the host `db`, the mail catcher), and Artisan and `.env` keys go through that plugin. With an older one a `--runtime` build is refused; on DDEV it builds as before.
168
+ - **The claim:** the project type is `laravel` there too, and the builder also writes `platform: filament` in the `x-webship:` block (the core's `rt_claim`), so the dashboard knows an app with a panel from a plain Laravel app and the row hands the panel's test users.
169
+ - **npm** (the demo's `npm ci` and `npm run build`) runs in the Workspace's tests container: the web container there has no Node.js.
170
+ - **HTTPS and a host name** are DDEV's: a runtime's address is plain HTTP.
171
+
172
+ The same commands work on every runtime: `cmd-tools-laravel-artisan.sh` (the Laravel plugin's), `cmd-tools-add-users.sh`,
173
+ `cmd-tools-testing.sh`. The pattern is the Workspace's
174
+ [`core/docs/plugins-on-runtimes.md`](https://github.com/webship/workspace/blob/1.0.x/core/docs/plugins-on-runtimes.md).
175
+
118
176
  ### The panel's command line
119
177
 
120
178
  The panel's CLI is Artisan, through the Laravel plugin's tool:
@@ -42,11 +42,13 @@ bash cmd-filament-project.sh mydemo --install --add-users --demo # the panel'
42
42
  | `--php-version <x>` | The PHP of the project container (8.4 by default; the demo app needs 8.4 or later). |
43
43
  | `--launch` | Opens the panel when it is ready. |
44
44
 
45
- The app answers at `https://<name>.ddev.site` (the panel at `/admin`, or at the root for the demo
45
+ On DDEV the app answers at `https://<name>.ddev.site` (the panel at `/admin`, or at the root for the demo
46
46
  app), its mail catcher at `https://<name>.ddev.site:8026`. The builder **deletes a project of the
47
47
  same name first**: a build is a clean slate, so never point it at an app somebody still needs. The
48
48
  name is a folder, a container project and a host name: short, lowercase, letters and digits.
49
49
 
50
+ With `--runtime docker`, `podman`, `kubernetes`, `lando` or `docksal` the app 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 an app. Its mailbox is at the address `rt_mail_url` gives, and the same commands work on it.
51
+
50
52
  What the builder changes in the app, each change marked "Webship Workspace" where it is made: the User
51
53
  model says which accounts the panel lets in (an address verified, as the panel's documentation shows
52
54
  it for an app in production); the demo app's admin panel checks it on every page with the panel's own
@@ -4,7 +4,9 @@
4
4
 
5
5
  # Installed by the Filament plugin (plugins.sh --install filament); __WORKSPACE__ is the workspace it was installed into.
6
6
  #
7
- # Build a Laravel app with an admin panel in a container, at https://<name>.ddev.site: a new app made by
7
+ # Build a Laravel app with an admin panel in a container, on DDEV (the default) at
8
+ # https://<name>.ddev.site, or with --runtime docker, podman, kubernetes, lando or docksal on that
9
+ # runtime, at the address the build prints: a new app made by
8
10
  # the Laravel plugin's builder (the official installer and a starter kit) with the panel installed the
9
11
  # documented way (its admin panel at /admin), or with --demo the panel's official demo app (its admin
10
12
  # panel at the root of the app). With --install its database is migrated and the workspace account is
package/dist/src/index.js CHANGED
@@ -40,7 +40,8 @@ function assistantContext() {
40
40
  '`bash cmd-filament-project.sh <name> --install --add-users` from a sites folder (dev, test, sandboxes, demos):',
41
41
  'a new Laravel app made by the Laravel plugin\'s builder (`--starter-kit livewire|react|vue`) with the panel installed the documented way, its admin panel at /admin;',
42
42
  'or with `--demo` the panel\'s official demo app (a shop, a blog, an HR suite, its own seed), its admin panel at the root of the app and a second panel with teams at /app.',
43
- 'It runs in a container like every other project, at https://<name>.ddev.site; `--production` runs it as a live app runs.',
43
+ 'It runs in a container like every other project: on DDEV by default, at https://<name>.ddev.site, or with `--runtime docker|podman|kubernetes|lando|docksal`',
44
+ 'on that runtime, at the address the build prints; `--production` runs it as a live app runs.',
44
45
  'The panel\'s CLI is Artisan through the Laravel plugin\'s tool: `bash cmd-tools-laravel-artisan.sh <name> --run "<artisan command>"` (make:filament-resource, filament:upgrade, about).',
45
46
  '`bash cmd-tools-add-users.sh <name> filament` adds the default accounts (administrator, its address verified: the panel lets it in; unverified: the panel refuses it).',
46
47
  '`bash cmd-tools-testing.sh <name>` sets up webship-js with the Filament step pack (it brings the Laravel step pack along); `--run` runs the suite.',
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;;AA0BH,4CAeC;AAED,4BAEC;AAzCD,mIAAmI;AACtH,QAAA,QAAQ,GAAG,UAAU,CAAC;AAEnC,2FAA2F;AAC9E,QAAA,IAAI,GAAG,SAAS,CAAC;AAE9B,qHAAqH;AACxG,QAAA,QAAQ,GAAG,CAAC,yBAAyB,CAAC,CAAC;AAEpD,+DAA+D;AAClD,Q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AAED,SAAgB,QAAQ,CAAC,GAAc;IACrC,GAAG,CAAC,mBAAmB,CAAC,gBAAgB,CAAC,CAAC;AAC5C,CAAC"}
@@ -0,0 +1,53 @@
1
+ Feature: An app with a panel 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. An app built on Docker Compose or Kubernetes has the row a DDEV site has: its state, its own address,
4
+ the runtime's menu, and the test users of the plugin in its Tests menu.
5
+
6
+ # Each scenario drives a real app of that runtime, built with cmd-filament-project.sh --runtime: the first running
7
+ # one the workspace holds that the plugin claims. Without one it is skipped, with the reason. In the plugin's CI
8
+ # the Docker Compose app is the one the manifest's featuresSite builds (the panel's demo app). The login page
9
+ # is read by what a login form of either kind of app shows: the demo's panel is at the root, a new app's at /admin.
10
+
11
+ @needs-runtime-docker @needs-platform-filament
12
+ Scenario: An app built on Docker Compose runs at its own address, with the DOCKER menu
13
+ Given I am on the folder of the "docker" site
14
+ Then the row of the "docker" site should show "Running"
15
+ And the row of the "docker" site should link to the address of its runtime
16
+ And the address of the "docker" site should answer
17
+ And the row of the "docker" site should carry the "DOCKER" menu and no DDEV menu
18
+
19
+ @needs-runtime-docker @needs-platform-filament
20
+ Scenario: The Tests menu of an app on Docker Compose offers the test users
21
+ Given I am on the folder of the "docker" site
22
+ When I open the "tests" menu of the "docker" site
23
+ Then the open menu should offer "Add the test users"
24
+ And the open menu should offer "Cancel the test users"
25
+
26
+ @needs-runtime-docker @needs-platform-filament
27
+ Scenario: The app on Docker Compose is installed: its login page
28
+ Given I am on the folder of the "docker" site
29
+ When I open "/login" on the "docker" site
30
+ Then I should see "Email address"
31
+ And I should see "Password"
32
+
33
+ @needs-runtime-kubernetes @needs-platform-filament
34
+ Scenario: An app 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-filament
42
+ Scenario: The Tests menu of an app 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-filament
49
+ Scenario: The app on Kubernetes is installed: its login page
50
+ Given I am on the folder of the "kubernetes" site
51
+ When I open "/login" on the "kubernetes" site
52
+ Then I should see "Email address"
53
+ And I should see "Password"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webship.co/workspace-filament",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Filament for Webship Workspace: the builder (`cmd-filament-project.sh`, a new Laravel app with the admin panel installed, or the panel's official demo app) in every sites folder, built on the Laravel plugin, the default accounts, the Filament step pack wired into the testing setup next to the Laravel one, and its AI items in their folders: two agents, a skill, a command and two prompts.",
5
5
  "main": "dist/src/index.js",
6
6
  "types": "dist/src/index.d.ts",
@@ -82,8 +82,10 @@
82
82
  ]
83
83
  },
84
84
  "features": [
85
- "features/filament.feature"
86
- ]
85
+ "features/filament.feature",
86
+ "features/filament-runtimes.feature"
87
+ ],
88
+ "featuresSite": "cmd-filament-project.sh ci-filament --demo --install --add-users --runtime docker"
87
89
  },
88
90
  "devDependencies": {
89
91
  "@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('-d', '--demo',
7
12
  action='store_true',
8
13
  default=False,
@@ -9,7 +9,15 @@
9
9
  # @webship.co/workspace-laravel. A new app starts from that plugin's laravel_build (the official
10
10
  # installer and a starter kit), and the accounts are written with its laravel_write_accounts.
11
11
  # Everything runs in the project's container (DDEV by default: `ddev artisan …`, `ddev composer …`),
12
- # never on the host. The container tool writes the database settings of the app into its .env.
12
+ # never on the host. On DDEV the container tool writes the database settings of the app into its .env.
13
+ #
14
+ # The runtimes: an app is built on DDEV, or with --runtime on Docker Compose, Podman, Kubernetes, Lando
15
+ # or Docksal. The commands are the same on each: `ddev <verb>` is DDEV itself on a DDEV project, and on
16
+ # another runtime the core's layer (fun-runtime.sh) gives the verb its meaning there. What differs comes
17
+ # from the Laravel plugin: Artisan and `.env` (laravel_artisan and laravel_dotenv_set: DDEV has verbs of
18
+ # its own for them, the layer has none), the .env DDEV writes on start (laravel_runtime_config: the
19
+ # address, the database of the project's own stack and its mail catcher), and a new app's build. The
20
+ # address is the runtime's (filament_url), and npm runs in the tests container there.
13
21
  #
14
22
  # The panel's CLI is Artisan, through the Laravel plugin's tool:
15
23
  # bash cmd-tools-laravel-artisan.sh <app> --run "make:filament-resource Post --generate"
@@ -21,7 +29,9 @@
21
29
  # testing_configure_filament the step pack in the testing stack (cmd-tools-testing.sh <project>)
22
30
  # An app with a panel is a project of the DDEV type `laravel`: the row's Users menu hands the tools the
23
31
  # Laravel plugin's list. The panel's own accounts come with the builder's --add-users, with the testing
24
- # setup, and with `cmd-tools-add-users.sh <project> filament`.
32
+ # setup, and with `cmd-tools-add-users.sh <project> filament`. On another runtime the builder claims the
33
+ # project (the core's rt_claim: `platform: filament` in the x-webship block, beside the type laravel),
34
+ # so the dashboard knows an app with a panel from a plain Laravel app, and its row hands the panel's list.
25
35
 
26
36
  # The step pack a panel is tested with, and the release line it is required at. It brings the Laravel
27
37
  # step pack along; the Laravel plugin's hook adds that one too.
@@ -48,11 +58,41 @@ function set_filament_users() {
48
58
  user_unverified_role='unverified' ;
49
59
  }
50
60
 
51
- # Is this folder an app with a panel? A Laravel project (its DDEV project type) with the panel in its
52
- # Composer packages.
61
+ # The runtime of the project in this folder, or of a new build (--runtime, else the workspace's
62
+ # setting, else DDEV). A core without the runtime layer has DDEV only.
63
+ function filament_runtime() {
64
+ if declare -f runtime_of > /dev/null ; then runtime_of ; else echo 'ddev' ; fi
65
+ }
66
+
67
+ # The address of the app in this folder: https://<name>.ddev.site on DDEV, http://127.0.0.1:<port> on
68
+ # Docker Compose, Podman and Lando, the node's address and a port on Kubernetes, http://<name>.docksal.site
69
+ # on Docksal. Asked after `ddev config`.
70
+ function filament_url() {
71
+ if declare -f rt_url > /dev/null ; then rt_url ; else echo "https://${PROJECT_NAME}.ddev.site" ; fi
72
+ }
73
+
74
+ # Artisan in the app of this folder, through the Laravel plugin on every runtime; DDEV's own
75
+ # `ddev artisan` with a Laravel plugin from before the runtimes.
76
+ function filament_artisan() {
77
+ if declare -f laravel_artisan > /dev/null ; then laravel_artisan "$@" ; else ddev artisan "$@" ; fi
78
+ }
79
+
80
+ # Set keys of a .env file, through the Laravel plugin on every runtime; DDEV's own `ddev dotenv set`
81
+ # with a Laravel plugin from before the runtimes.
82
+ function filament_dotenv_set() {
83
+ if declare -f laravel_dotenv_set > /dev/null ; then laravel_dotenv_set "$@" ; else ddev dotenv set "$@" ; fi
84
+ }
85
+
86
+ # Is this folder an app with a panel? A Laravel project (its project type: on DDEV in .ddev/config.yaml,
87
+ # on another runtime in the x-webship block, both read by the core's rt_is_platform) with the panel in
88
+ # its Composer packages.
53
89
  function filament_is_project() {
54
90
  local project_path="$1";
55
- grep -qE '^type:[[:space:]]*"?laravel"?[[:space:]]*$' "${project_path}/.ddev/config.yaml" 2>/dev/null || return 1 ;
91
+ if declare -f rt_is_platform > /dev/null ; then
92
+ rt_is_platform "${project_path}" laravel || return 1 ;
93
+ else
94
+ grep -qE '^type:[[:space:]]*"?laravel"?[[:space:]]*$' "${project_path}/.ddev/config.yaml" 2>/dev/null || return 1 ;
95
+ fi
56
96
  grep -q '"filament/filament"' "${project_path}/composer.json" 2>/dev/null ;
57
97
  }
58
98
 
@@ -64,7 +104,7 @@ function filament_enter_project() {
64
104
  return 1 ;
65
105
  fi
66
106
  if ! filament_is_project "${project_path}" ; then
67
- echo "${doc_name}/${PROJECT_NAME} is not an app with a panel: a Laravel project (type: laravel) with filament/filament in its composer.json." ;
107
+ echo "${doc_name}/${PROJECT_NAME} is not an app with a panel: a Laravel project (project type laravel) with filament/filament in its composer.json." ;
68
108
  return 1 ;
69
109
  fi
70
110
  cd "${project_path}" || return 1 ;
@@ -140,13 +180,25 @@ function filament_get_demo() {
140
180
  [ -f .env ] || cp .env.example .env ;
141
181
  }
142
182
 
183
+ # The demo app ships an .npmrc that holds back every npm package younger than seven days (`min-release-age=…`).
184
+ # The testing setup installs step packs younger than that, which npm then cannot find ("ENOVERSIONS"), on every
185
+ # runtime. Only that line is taken out of the app's .npmrc, and the builder says so; the rest of the file stays as
186
+ # it is, and an app with no .npmrc gets none.
187
+ function filament_npmrc_release_age() {
188
+ local file="${1:-.npmrc}" ;
189
+ [ -f "${file}" ] || return 0 ;
190
+ grep -qE '^[[:space:]]*min-release-age[[:space:]]*=' "${file}" || return 0 ;
191
+ sed -i -E '/^[[:space:]]*min-release-age[[:space:]]*=/d' "${file}" || return 1 ;
192
+ echo " .npmrc: the min-release-age line taken out of the app's .npmrc: the testing setup installs step packs younger than seven days." ;
193
+ }
194
+
143
195
  # Build an app with a panel from nothing. With --demo, the panel's official demo app; without it, a new
144
196
  # app made by the Laravel plugin's builder (the official installer and a starter kit) with the panel
145
197
  # installed the documented way. With --install the database is migrated and the workspace account is
146
198
  # the panel's first account; with --add-users the default accounts.
147
199
  function filament_build() {
148
200
  trim_project_name ;
149
- local base_url="https://${PROJECT_NAME}.ddev.site" ;
201
+ local base_url runtime ;
150
202
  local php_version="${PHP_VERSION:-${site_php_version:-8.4}}" ;
151
203
  local add_users="${ADD_USERS}" launch="${LAUNCH}" production="${PRODUCTION}" ;
152
204
 
@@ -155,6 +207,17 @@ function filament_build() {
155
207
  echo " bash core/scripts/plugins.sh --install laravel" ;
156
208
  exit 1 ;
157
209
  fi
210
+ runtime="$(filament_runtime)" ;
211
+ if [ "${RUNTIME:-_none_}" != '_none_' ] && [ "${RUNTIME}" != "${runtime}" ] ; then
212
+ echo "--runtime ${RUNTIME} needs a Webship Workspace with the container runtimes (webship/workspace#694): update the workspace, or build on DDEV." ;
213
+ exit 1 ;
214
+ fi
215
+ # On another runtime the app's .env is written by the Laravel plugin, as DDEV writes it on DDEV: one
216
+ # from before the runtimes would leave the app with no database.
217
+ if [ "${runtime}" != 'ddev' ] && ! declare -f laravel_runtime_config > /dev/null ; then
218
+ echo "--runtime ${runtime} needs the Laravel plugin 1.0.2 or later, which builds on the container runtimes: update it, or build on DDEV." ;
219
+ exit 1 ;
220
+ fi
158
221
 
159
222
  if [ "${DEMO}" == 'yes' ] ; then
160
223
  cd ${WORKSPACE_ROOT}/${doc_name} || exit 1 ;
@@ -165,16 +228,27 @@ function filament_build() {
165
228
  # PHP 8.4: the demo's lock file holds packages that need it.
166
229
  ddev config --project-type=laravel --docroot=public --project-name=${PROJECT_NAME} \
167
230
  --nodejs-version=$(ddev_nodejs_version) --php-version=${php_version} --auto || exit 1 ;
231
+ # On another runtime than DDEV the plugin claims the project: its type is the Laravel plugin's.
232
+ if [ "${runtime}" != 'ddev' ] ; then
233
+ rt_claim filament || exit 1 ;
234
+ fi
235
+ # The address is the runtime's to say, once the project is configured: never a written ddev.site.
236
+ base_url="$(filament_url)" ;
168
237
  filament_get_demo || exit 1 ;
238
+ filament_npmrc_release_age .npmrc || exit 1 ;
169
239
  # The restart writes the database and the mail settings of the container into .env.
170
240
  ddev_up start -y || exit 1 ;
241
+ if [ "${runtime}" != 'ddev' ] ; then
242
+ # What DDEV's start writes into .env: the address, the database and the mail of the container.
243
+ laravel_runtime_config "${base_url}" || { echo "The .env of the app could not be written." ; exit 1 ; } ;
244
+ fi
171
245
  ddev composer install --no-interaction --no-progress || { echo "composer install failed." ; exit 1 ; } ;
172
246
  ddev composer update 'filament/*' --with-dependencies --no-interaction --no-progress || exit 1 ;
173
- ddev artisan key:generate --ansi > /dev/null || exit 1 ;
174
- ddev dotenv set .env --mail-from-address=webship@example.com > /dev/null ;
247
+ filament_artisan key:generate --ansi > /dev/null || exit 1 ;
248
+ filament_dotenv_set .env --mail-from-address=webship@example.com > /dev/null ;
175
249
  if [ "${INSTALL}" == 'yes' ] ; then
176
- ddev artisan migrate --force --seed --no-interaction || { echo "The migrations and the demo's seed failed." ; exit 1 ; } ;
177
- ddev artisan storage:link > /dev/null ;
250
+ filament_artisan migrate --force --seed --no-interaction || { echo "The migrations and the demo's seed failed." ; exit 1 ; } ;
251
+ filament_artisan storage:link > /dev/null ;
178
252
  fi
179
253
  ddev npm ci --no-audit --no-fund || exit 1 ;
180
254
  ddev npm run build || exit 1 ;
@@ -185,17 +259,22 @@ function filament_build() {
185
259
  ( laravel_build ) || exit 1 ;
186
260
  ADD_USERS="${add_users}" ; LAUNCH="${launch}" ; PRODUCTION="${production}" ;
187
261
  cd ${WORKSPACE_ROOT}/${doc_name}/${PROJECT_NAME} || exit 1 ;
262
+ # On another runtime than DDEV the plugin claims the project the Laravel plugin's builder made.
263
+ if [ "${runtime}" != 'ddev' ] ; then
264
+ rt_claim filament || exit 1 ;
265
+ fi
266
+ base_url="$(filament_url)" ;
188
267
  ddev composer require "filament/filament:^${FILAMENT_LINE}.0" --with-all-dependencies --no-interaction --no-progress \
189
268
  || { echo "The panel could not be required." ; exit 1 ; } ;
190
- ddev artisan filament:install --panels --no-interaction || { echo "The panel could not be installed." ; exit 1 ; } ;
191
- ddev dotenv set .env --mail-from-address=webship@example.com > /dev/null ;
269
+ filament_artisan filament:install --panels --no-interaction || { echo "The panel could not be installed." ; exit 1 ; } ;
270
+ filament_dotenv_set .env --mail-from-address=webship@example.com > /dev/null ;
192
271
  # The panel's mail (the password reset) is a queued notification, and a new app queues in its
193
272
  # database: a local app runs no queue worker, so its queue runs in the request, as the demo's does.
194
- ddev dotenv set .env --queue-connection=sync > /dev/null ;
273
+ filament_dotenv_set .env --queue-connection=sync > /dev/null ;
195
274
  fi
196
275
 
197
276
  filament_set_up_panel || exit 1 ;
198
- ddev artisan optimize:clear > /dev/null 2>&1 ;
277
+ filament_artisan optimize:clear > /dev/null 2>&1 ;
199
278
 
200
279
  if [ "${INSTALL}" == 'yes' ] ; then
201
280
  # The workspace account is the panel's first account, its address verified.
@@ -207,11 +286,11 @@ function filament_build() {
207
286
  cd ${WORKSPACE_ROOT}/${doc_name}/${PROJECT_NAME} || exit 1 ;
208
287
  fi
209
288
  if [ "${PRODUCTION}" == 'yes' ] ; then
210
- ddev dotenv set .env --app-env=production --app-debug=false > /dev/null ;
289
+ filament_dotenv_set .env --app-env=production --app-debug=false > /dev/null ;
211
290
  fi
212
291
  local panel_path ;
213
292
  panel_path="$(filament_panel_path "$(pwd)")" ;
214
- echo "${doc_name} ${PROJECT_NAME} has been installed: $(ddev artisan --version 2>/dev/null), panel $(ddev composer show filament/filament 2>/dev/null | awk '$1 == "versions" {print $NF}')$( [ "${DEMO}" == 'yes' ] && echo ', the demo app').";
293
+ echo "${doc_name} ${PROJECT_NAME} has been installed: $(filament_artisan --version 2>/dev/null), panel $(ddev composer show filament/filament 2>/dev/null | awk '$1 == "versions" {print $NF}')$( [ "${DEMO}" == 'yes' ] && echo ', the demo app').";
215
294
  echo "Go to ${base_url}${panel_path%/}/login and log in as ${account_mail}";
216
295
  else
217
296
  [ "${ADD_USERS}" == 'yes' ] && echo "--add-users needs --install: there is no database to add accounts to yet." ;
@@ -393,7 +472,7 @@ PYEOF
393
472
  fi
394
473
 
395
474
  # The scenarios log in as the default accounts: make sure a migrated app has them.
396
- if ddev artisan migrate:status > /dev/null 2>&1 ; then
475
+ if filament_artisan migrate:status > /dev/null 2>&1 ; then
397
476
  ( add_filament_users > /dev/null ) && echo " the panel's default accounts are on the app (${users[*]})" ;
398
477
  fi
399
478
  }