@catapultjs/deploy 0.9.0 → 0.10.0

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.
@@ -0,0 +1,316 @@
1
+ # Official Catapult recipes
2
+
3
+ Recipes are imported as side effects and register tasks into the pipeline automatically. Import order matters: `set()` calls that configure a recipe must appear **before** the recipe import.
4
+
5
+ Full docs: https://catapultjs.com/guide/recipes
6
+
7
+ ## Choosing a recipe
8
+
9
+ | Recipe | Delivers `deploy:update_code`? | Use when |
10
+ | --- | --- | --- |
11
+ | `recipes/git` | Yes | Server can reach the repo; build runs on the server |
12
+ | `recipes/rsync` | Yes | Local build, push artifacts via rsync |
13
+ | `recipes/astro` | Yes | Astro site, build locally, upload dist |
14
+ | `recipes/vitepress` | Yes | VitePress site, build locally, upload dist |
15
+ | `recipes/adonisjs_local` | Yes | AdonisJS, build locally, upload artifact |
16
+ | `recipes/adonisjs` | No (pair with `git` or `rsync`) | AdonisJS, build on the server |
17
+ | `recipes/nuxt` | No (pair with `git` or `rsync`) | Nuxt, build on the server |
18
+ | `recipes/directus` | No (pair with `git` or `rsync`) | Directus, migrations and schema snapshots |
19
+ | `recipes/pm2` | No | Process management (add to any stack) |
20
+ | `recipes/redis` | No | Redis cache flush (add to any stack) |
21
+
22
+ ---
23
+
24
+ ## `recipes/git`
25
+
26
+ ```typescript
27
+ import '@catapultjs/deploy/recipes/git'
28
+ ```
29
+
30
+ Requires `branch` on each host. `repository` is auto-detected from `git remote get-url origin`.
31
+
32
+ | Task | Inserted | Description |
33
+ | --- | --- | --- |
34
+ | `git:check` | after `deploy:lock` | Verifies the branch exists on the remote |
35
+ | `git:update` | before `deploy:update_code` | Clones a bare mirror into `.catapult/repo`, or fetches it |
36
+ | `deploy:update_code` | — | Clones or resets the branch from the local mirror into the release |
37
+
38
+ No store keys.
39
+
40
+ ---
41
+
42
+ ## `recipes/rsync`
43
+
44
+ ```typescript
45
+ import '@catapultjs/deploy/recipes/rsync'
46
+ ```
47
+
48
+ Always uses `--delete`. Trailing slash on the source is added automatically.
49
+
50
+ | Task | Inserted | Description |
51
+ | --- | --- | --- |
52
+ | `deploy:update_code` | — | Syncs a local directory into `releases/<release>/` via rsync |
53
+
54
+ | Key | Type | Default | Description |
55
+ | --- | --- | --- | --- |
56
+ | `rsync_source_path` | `string` | `./` | Local source directory |
57
+ | `source_path` | `string` | — | Fallback if `rsync_source_path` is not set |
58
+ | `rsync_excludes` | `string[]` | `[]` | Patterns passed to `--exclude` |
59
+
60
+ ```typescript
61
+ set('rsync_source_path', './dist')
62
+ set('rsync_excludes', ['.env'])
63
+ import '@catapultjs/deploy/recipes/rsync'
64
+ ```
65
+
66
+ ---
67
+
68
+ ## `recipes/astro`
69
+
70
+ ```typescript
71
+ import '@catapultjs/deploy/recipes/astro'
72
+ ```
73
+
74
+ Builds locally before the lock step, then uploads the output via SCP. Does not run `astro build` on the server.
75
+
76
+ | Task | Inserted | Description |
77
+ | --- | --- | --- |
78
+ | `deploy:build` | before `deploy:lock` | Runs `astro build --mode <astro_mode>` locally |
79
+ | `deploy:update_code` | — | Uploads the generated directory to `releases/<release>` via SCP |
80
+
81
+ | Key | Type | Default | Description |
82
+ | --- | --- | --- | --- |
83
+ | `astro_mode` | `string \| Record<string, string>` | `'production'` | Build mode. String = same for all hosts; object = per host name |
84
+ | `source_path` | `string` | `'./dist/.'` | Local directory uploaded after the build |
85
+
86
+ ```typescript
87
+ // Per-host modes
88
+ set('astro_mode', { production: 'production', staging: 'staging' })
89
+ import '@catapultjs/deploy/recipes/astro'
90
+ ```
91
+
92
+ To use rsync instead of SCP for the upload, import both `astro` and `rsync` — `astro` provides `deploy:build`, `rsync` overrides `deploy:update_code`. Do not combine with `git`.
93
+
94
+ ---
95
+
96
+ ## `recipes/vitepress`
97
+
98
+ ```typescript
99
+ import '@catapultjs/deploy/recipes/vitepress'
100
+ ```
101
+
102
+ | Task | Inserted | Description |
103
+ | --- | --- | --- |
104
+ | `deploy:build` | before `deploy:lock` | Runs `vitepress build <vitepress_path>` locally |
105
+ | `deploy:update_code` | — | Uploads `<vitepress_path>.vitepress/dist` to `releases/<release>` via SCP |
106
+
107
+ | Key | Type | Default | Description |
108
+ | --- | --- | --- | --- |
109
+ | `vitepress_path` | `string` | `''` | Path passed to `vitepress build`; output read from `<path>.vitepress/dist` |
110
+ | `source_path` | `string` | `''` | Used as default for `vitepress_path` |
111
+
112
+ ```typescript
113
+ set('vitepress_path', 'docs/')
114
+ import '@catapultjs/deploy/recipes/vitepress'
115
+ ```
116
+
117
+ ---
118
+
119
+ ## `recipes/adonisjs`
120
+
121
+ ```typescript
122
+ import '@catapultjs/deploy/recipes/adonisjs'
123
+ ```
124
+
125
+ Remote build. Does not override `deploy:update_code` — pair with `git` or `rsync`.
126
+
127
+ | Task | Inserted | Description |
128
+ | --- | --- | --- |
129
+ | `deploy:install` | after `deploy:update_code` | Installs dependencies in the release |
130
+ | `deploy:build` | after `deploy:shared` | Runs `node ace build`, copies `package.json` + lockfile into `build/`, creates `build/tmp` |
131
+ | `ace:migration:run` | before `deploy:publish` | Runs `node ace migration:run --force` |
132
+ | `ace:migration:rollback` | manual | Runs `node ace migration:rollback` |
133
+ | `ace:migration:status` | manual | Runs `node ace migration:status` |
134
+ | `ace:list:routes` | manual | Runs `node ace list:routes` |
135
+
136
+ | Key | Type | Default | Description |
137
+ | --- | --- | --- | --- |
138
+ | `writable_dirs` | `string[]` | `['storage', 'logs', 'tmp']` | Created in `shared/` at setup |
139
+ | `shared_dirs` | `string[]` | `['storage', 'logs']` | Symlinked into each release |
140
+ | `shared_files` | `string[]` | `['.env']` | Symlinked into each release |
141
+ | `adonisjs_path` | `string` | `''` | Sub-path to the app within the repo (monorepo) |
142
+
143
+ ```typescript
144
+ set('adonisjs_path', 'apps/api')
145
+ set('shared_files', ['.env', '.env.production'])
146
+ import '@catapultjs/deploy/recipes/adonisjs'
147
+ ```
148
+
149
+ ---
150
+
151
+ ## `recipes/adonisjs_local`
152
+
153
+ ```typescript
154
+ import '@catapultjs/deploy/recipes/adonisjs_local'
155
+ ```
156
+
157
+ Local build + artifact upload. Same `ace:*` tasks as `adonisjs`. Copies `package.json`, lockfile, and optionally `pnpm-workspace.yaml`, `.npmrc`, `ecosystem.config.cjs` into the local `build/` before uploading.
158
+
159
+ | Task | Inserted | Description |
160
+ | --- | --- | --- |
161
+ | `deploy:build` | before `deploy:lock` | Runs `node ace build` locally |
162
+ | `deploy:update_code` | — | Uploads local build output to `releases/<release>` via SCP |
163
+ | `deploy:install` | after `deploy:shared` | Installs prod dependencies in the release |
164
+ | `ace:migration:run` | before `deploy:publish` | Runs `node ace migration:run --force` |
165
+ | `ace:migration:rollback` | manual | Runs `node ace migration:rollback` |
166
+ | `ace:migration:status` | manual | Runs `node ace migration:status` |
167
+ | `ace:list:routes` | manual | Runs `node ace list:routes` |
168
+
169
+ | Key | Type | Default | Description |
170
+ | --- | --- | --- | --- |
171
+ | `writable_dirs` | `string[]` | `['storage', 'logs', 'tmp']` | Created in `shared/` at setup |
172
+ | `shared_dirs` | `string[]` | `['storage', 'logs']` | Symlinked into each release |
173
+ | `shared_files` | `string[]` | `['.env']` | Symlinked into each release |
174
+ | `adonisjs_path` | `string` | `''` | Sub-path to the app (monorepo) |
175
+ | `source_path` | `string` | `<adonisjs_path>/build/.` | Local build directory to upload |
176
+
177
+ ---
178
+
179
+ ## `recipes/nuxt`
180
+
181
+ ```typescript
182
+ import '@catapultjs/deploy/recipes/nuxt'
183
+ ```
184
+
185
+ Remote build. Does not override `deploy:update_code` — pair with `git` or `rsync`.
186
+
187
+ | Task | Inserted | Description |
188
+ | --- | --- | --- |
189
+ | `deploy:build` | — | Overrides the built-in build task, runs `nuxt build` |
190
+ | `nuxt:generate` | — | Runs `nuxt generate` (manual) |
191
+
192
+ | Key | Type | Default | Description |
193
+ | --- | --- | --- | --- |
194
+ | `shared_files` | `string[]` | `['.env']` | Symlinked into each release |
195
+ | `nuxt_path` | `string` | `''` | Sub-path to the Nuxt app (monorepo) |
196
+ | `source_path` | `string` | `''` | Used as default for `nuxt_path` |
197
+
198
+ ```typescript
199
+ set('nuxt_path', 'apps/web')
200
+ import '@catapultjs/deploy/recipes/nuxt'
201
+ ```
202
+
203
+ ---
204
+
205
+ ## `recipes/directus`
206
+
207
+ ```typescript
208
+ import '@catapultjs/deploy/recipes/directus'
209
+ ```
210
+
211
+ DB migrations and schema snapshots. Does not override `deploy:update_code` — pair with `git` or `rsync`. All tasks are manual (not inserted automatically).
212
+
213
+ | Task | Inserted | Description |
214
+ | --- | --- | --- |
215
+ | `directus:database:migrate` | manual | Runs `directus database migrate:latest` |
216
+ | `directus:snapshot:create` | manual | Runs `directus schema snapshot <directus_snapshot_path>` |
217
+ | `directus:snapshot:apply` | manual | Runs `directus schema apply -y <directus_snapshot_path>` |
218
+
219
+ | Key | Type | Default | Description |
220
+ | --- | --- | --- | --- |
221
+ | `writable_dirs` | `string[]` | `['uploads']` | Created in `shared/` at setup |
222
+ | `shared_dirs` | `string[]` | `['uploads']` | Symlinked into each release |
223
+ | `shared_files` | `string[]` | `['.env']` | Symlinked into each release |
224
+ | `directus_path` | `string` | `''` | Sub-path to the Directus app (monorepo) |
225
+ | `directus_snapshot_path` | `string` | `'./snapshot.yaml'` | Snapshot file path used by schema tasks |
226
+
227
+ ```typescript
228
+ set('directus_path', 'apps/cms')
229
+ set('directus_snapshot_path', './database/snapshot.yaml')
230
+ import '@catapultjs/deploy/recipes/directus'
231
+ ```
232
+
233
+ ---
234
+
235
+ ## `recipes/pm2`
236
+
237
+ ```typescript
238
+ import '@catapultjs/deploy/recipes/pm2'
239
+ ```
240
+
241
+ Requires an `ecosystem.config.cjs` at the release root. Use absolute paths inside that file resolving through `current/` to avoid stale release references after a new deploy.
242
+
243
+ | Task | Inserted | Description |
244
+ | --- | --- | --- |
245
+ | `pm2:startOrReload` | after `deploy:publish` | Starts or reloads via `startOrReload --update-env` |
246
+ | `pm2:save` | after `pm2:startOrReload` | Persists the PM2 process list |
247
+ | `pm2:start` | manual | Starts PM2 processes |
248
+ | `pm2:reload` | manual | Zero-downtime reload |
249
+ | `pm2:restart` | manual | Hard restart |
250
+ | `pm2:stop` | manual | Stops all processes |
251
+ | `pm2:delete` | manual | Deletes all processes from PM2 |
252
+ | `pm2:logs` | manual | Displays the last 50 lines of logs |
253
+ | `pm2:list` | manual | Lists PM2 processes |
254
+ | `pm2:show` | manual | Shows detailed info for each app in `ecosystem.config.cjs` |
255
+
256
+ No store keys. `onStatus` displays the PM2 version in `cata status`.
257
+
258
+ ```bash
259
+ npx cata task pm2:reload
260
+ npx cata task pm2:logs --host staging
261
+ ```
262
+
263
+ ---
264
+
265
+ ## `recipes/redis`
266
+
267
+ ```typescript
268
+ import '@catapultjs/deploy/recipes/redis'
269
+ ```
270
+
271
+ All tasks are manual (not inserted automatically).
272
+
273
+ | Task | Inserted | Description |
274
+ | --- | --- | --- |
275
+ | `redis:db:flush` | manual | Flushes the configured Redis DB(s) |
276
+ | `redis:db:flush_all` | manual | Runs `redis-cli FLUSHALL` |
277
+
278
+ | Key | Type | Default | Description |
279
+ | --- | --- | --- | --- |
280
+ | `redis_db` | `number \| number[]` | `1` | DB index(es) flushed by `redis:db:flush` |
281
+
282
+ ```typescript
283
+ set('redis_db', [0, 1, 2])
284
+ import '@catapultjs/deploy/recipes/redis'
285
+
286
+ // Insert before publish:
287
+ before('deploy:publish', 'redis:db:flush')
288
+ ```
289
+
290
+ ---
291
+
292
+ ## Monorepo pattern
293
+
294
+ Keep the transfer recipe (`git` or `rsync`) and override `deploy:install`/`deploy:build` paths via `set()`:
295
+
296
+ ```typescript
297
+ import { defineConfig, set, before } from '@catapultjs/deploy'
298
+ import '@catapultjs/deploy/recipes/git'
299
+ import '@catapultjs/deploy/recipes/nuxt'
300
+ import '@catapultjs/deploy/recipes/directus'
301
+ import '@catapultjs/deploy/recipes/pm2'
302
+ import '@catapultjs/deploy/recipes/redis'
303
+
304
+ set('nuxt_path', 'apps/web')
305
+ set('directus_path', 'apps/cms')
306
+ set('directus_snapshot_path', './database/snapshot.yaml')
307
+ set('redis_db', 2)
308
+
309
+ before('deploy:publish', 'redis:db:flush')
310
+
311
+ export default defineConfig({
312
+ hosts: [{ name: 'production', ssh: 'deploy@example.com', deployPath: '/home/deploy/acme', branch: 'main' }],
313
+ })
314
+ ```
315
+
316
+ `deploy:install` (inserted by `nuxt`/`directus`) runs at the workspace root `{{release_path}}` by default — no override needed for standard monorepos.