@catapultjs/deploy 0.11.0 → 0.13.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.
Files changed (41) hide show
  1. package/README.md +34 -13
  2. package/build/bin/run.js +31 -55
  3. package/build/bin/run.js.map +1 -1
  4. package/build/commands/config_validate.d.ts +7 -0
  5. package/build/commands/config_validate.js +45 -0
  6. package/build/commands/config_validate.js.map +1 -0
  7. package/build/commands/init.js +20 -4
  8. package/build/commands/init.js.map +1 -1
  9. package/build/index.d.ts +1 -0
  10. package/build/index.js +1 -0
  11. package/build/index.js.map +1 -1
  12. package/build/recipes/caddy.d.ts +10 -0
  13. package/build/recipes/caddy.js +64 -0
  14. package/build/recipes/caddy.js.map +1 -0
  15. package/build/recipes/systemd.d.ts +9 -0
  16. package/build/recipes/systemd.js +37 -0
  17. package/build/recipes/systemd.js.map +1 -0
  18. package/build/src/config/json/loader.d.ts +4 -0
  19. package/build/src/config/json/loader.js +206 -0
  20. package/build/src/config/json/loader.js.map +1 -0
  21. package/build/src/config/json/recipe_registry.d.ts +3 -0
  22. package/build/src/config/json/recipe_registry.js +44 -0
  23. package/build/src/config/json/recipe_registry.js.map +1 -0
  24. package/build/src/config/json/schema.d.ts +45 -0
  25. package/build/src/config/json/schema.js +198 -0
  26. package/build/src/config/json/schema.js.map +1 -0
  27. package/build/src/config/loader.d.ts +2 -0
  28. package/build/src/config/loader.js +21 -0
  29. package/build/src/config/loader.js.map +1 -0
  30. package/build/src/config/resolve.d.ts +2 -0
  31. package/build/src/config/resolve.js +30 -0
  32. package/build/src/config/resolve.js.map +1 -0
  33. package/build/src/utils.js +8 -1
  34. package/build/src/utils.js.map +1 -1
  35. package/package.json +11 -6
  36. package/schema/deploy.schema.json +287 -0
  37. package/skills/catapultjs/SKILL.md +14 -11
  38. package/skills/catapultjs/references/cli.md +11 -2
  39. package/skills/catapultjs/references/config.md +133 -34
  40. package/skills/catapultjs/references/recipe.md +1 -1
  41. package/skills/catapultjs/references/recipes.md +68 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@catapultjs/deploy",
3
- "version": "0.11.0",
3
+ "version": "0.13.0",
4
4
  "type": "module",
5
5
  "main": "build/index.js",
6
6
  "bin": {
@@ -14,10 +14,12 @@
14
14
  },
15
15
  "files": [
16
16
  "build",
17
+ "schema",
17
18
  "skills",
18
19
  "!build/bin/test.js",
19
20
  "!build/bin/test.d.ts",
20
21
  "!build/bin/test.js.map",
22
+ "!build/scripts",
21
23
  "!build/docs",
22
24
  "!build/examples",
23
25
  "!build/tests"
@@ -25,9 +27,10 @@
25
27
  "scripts": {
26
28
  "lint": "eslint .",
27
29
  "format": "prettier --write .",
30
+ "schema:generate": "node scripts/generate_json_schema.ts",
28
31
  "typecheck": "tsc --noEmit",
29
32
  "build": "tsc",
30
- "prepublishOnly": "npm run build",
33
+ "prepublishOnly": "npm run schema:generate && npm run build",
31
34
  "docs:dev": "vitepress dev docs",
32
35
  "docs:build": "vitepress build docs",
33
36
  "docs:preview": "vitepress preview docs",
@@ -73,6 +76,7 @@
73
76
  "types": "./build/src/api.d.ts",
74
77
  "import": "./build/src/api.js"
75
78
  },
79
+ "./schema/deploy.schema.json": "./schema/deploy.schema.json",
76
80
  "./recipes/*": {
77
81
  "types": "./build/recipes/*.d.ts",
78
82
  "import": "./build/recipes/*.js"
@@ -84,14 +88,15 @@
84
88
  "@adonisjs/tsconfig": "^2.0.0",
85
89
  "@japa/assert": "^4.2.0",
86
90
  "@japa/runner": "^5.3.0",
87
- "@types/node": "^25.9.3",
88
- "eslint": "^10.4.1",
89
- "prettier": "^3.8.4",
91
+ "@types/node": "^25.9.5",
92
+ "eslint": "^10.7.0",
93
+ "prettier": "^3.9.5",
90
94
  "typescript": "^6.0.3",
91
- "vitepress": "^2.0.0-alpha.17"
95
+ "vitepress": "^2.0.0-alpha.18"
92
96
  },
93
97
  "dependencies": {
94
98
  "@adonisjs/ace": "^14.1.0",
99
+ "ajv": "^8.20.0",
95
100
  "execa": "^9.6.1"
96
101
  },
97
102
  "eslintConfig": {
@@ -0,0 +1,287 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "$id": "https://catapultjs.com/schema/deploy.schema.json",
4
+ "title": "Catapult deploy JSON configuration",
5
+ "description": "Declarative deployment configuration for @catapultjs/deploy.",
6
+ "type": "object",
7
+ "required": ["version", "config"],
8
+ "additionalProperties": false,
9
+ "properties": {
10
+ "$schema": { "type": "string" },
11
+ "version": { "const": 1 },
12
+ "recipes": {
13
+ "type": "array",
14
+ "items": {
15
+ "enum": [
16
+ "adonisjs",
17
+ "adonisjs_local",
18
+ "astro",
19
+ "astro_static",
20
+ "caddy",
21
+ "directus",
22
+ "git",
23
+ "nestjs",
24
+ "nextjs",
25
+ "nextjs_static",
26
+ "nuxt",
27
+ "nuxt_static",
28
+ "pm2",
29
+ "redis",
30
+ "rsync",
31
+ "systemd",
32
+ "tanstack",
33
+ "vitepress"
34
+ ]
35
+ },
36
+ "uniqueItems": true
37
+ },
38
+ "config": { "$ref": "#/definitions/config" },
39
+ "store": { "$ref": "#/definitions/store" },
40
+ "tasks": {
41
+ "type": "object",
42
+ "propertyNames": { "type": "string", "minLength": 1, "pattern": "^\\S+$" },
43
+ "additionalProperties": { "$ref": "#/definitions/taskDefinition" }
44
+ },
45
+ "pipeline": {
46
+ "type": "array",
47
+ "items": { "type": "string", "minLength": 1, "pattern": "^\\S+$" },
48
+ "minItems": 1,
49
+ "uniqueItems": true
50
+ },
51
+ "before": {
52
+ "type": "object",
53
+ "propertyNames": { "type": "string", "minLength": 1, "pattern": "^\\S+$" },
54
+ "additionalProperties": {
55
+ "oneOf": [
56
+ { "type": "string", "minLength": 1, "pattern": "^\\S+$" },
57
+ {
58
+ "type": "array",
59
+ "items": { "type": "string", "minLength": 1, "pattern": "^\\S+$" },
60
+ "minItems": 1,
61
+ "uniqueItems": true
62
+ }
63
+ ]
64
+ }
65
+ },
66
+ "after": {
67
+ "type": "object",
68
+ "propertyNames": { "type": "string", "minLength": 1, "pattern": "^\\S+$" },
69
+ "additionalProperties": {
70
+ "oneOf": [
71
+ { "type": "string", "minLength": 1, "pattern": "^\\S+$" },
72
+ {
73
+ "type": "array",
74
+ "items": { "type": "string", "minLength": 1, "pattern": "^\\S+$" },
75
+ "minItems": 1,
76
+ "uniqueItems": true
77
+ }
78
+ ]
79
+ }
80
+ },
81
+ "remove": {
82
+ "type": "array",
83
+ "items": { "type": "string", "minLength": 1, "pattern": "^\\S+$" },
84
+ "uniqueItems": true
85
+ }
86
+ },
87
+ "definitions": {
88
+ "store": {
89
+ "type": "object",
90
+ "properties": {
91
+ "shared_dirs": { "type": "array", "items": { "type": "string", "minLength": 1 } },
92
+ "shared_files": { "type": "array", "items": { "type": "string", "minLength": 1 } },
93
+ "writable_dirs": { "type": "array", "items": { "type": "string", "minLength": 1 } },
94
+ "source_path": { "type": "string" },
95
+ "adonisjs_path": { "type": "string" },
96
+ "astro_mode": {
97
+ "oneOf": [
98
+ { "type": "string", "minLength": 1 },
99
+ {
100
+ "type": "object",
101
+ "minProperties": 1,
102
+ "propertyNames": { "type": "string", "minLength": 1 },
103
+ "additionalProperties": { "type": "string", "minLength": 1 }
104
+ }
105
+ ]
106
+ },
107
+ "astro_path": { "type": "string" },
108
+ "caddy_config_path": { "type": "string", "minLength": 1 },
109
+ "caddy_local_config_path": { "type": "string", "minLength": 1 },
110
+ "caddy_use_sudo": { "type": "boolean" },
111
+ "caddy_validate_before_reload": { "type": "boolean" },
112
+ "caddy_reload_after_publish": { "type": "boolean" },
113
+ "directus_path": { "type": "string" },
114
+ "directus_snapshot_path": { "type": "string", "minLength": 1 },
115
+ "nextjs_path": { "type": "string" },
116
+ "nextjs_out_path": { "type": "string", "minLength": 1 },
117
+ "nuxt_path": { "type": "string" },
118
+ "redis_db": {
119
+ "oneOf": [
120
+ { "type": "integer", "minimum": 0 },
121
+ {
122
+ "type": "array",
123
+ "items": { "type": "integer", "minimum": 0 },
124
+ "minItems": 1,
125
+ "uniqueItems": true
126
+ }
127
+ ]
128
+ },
129
+ "rsync_source_path": { "type": "string", "minLength": 1 },
130
+ "rsync_excludes": { "type": "array", "items": { "type": "string", "minLength": 1 } },
131
+ "systemd_service": { "type": "string", "minLength": 1 },
132
+ "systemd_use_sudo": { "type": "boolean" },
133
+ "systemd_logs_lines": { "type": "number", "exclusiveMinimum": 0 },
134
+ "vitepress_path": { "type": "string" }
135
+ },
136
+ "required": [],
137
+ "additionalProperties": false
138
+ },
139
+ "config": {
140
+ "type": "object",
141
+ "properties": {
142
+ "keepReleases": { "type": "integer", "minimum": 1 },
143
+ "repository": { "type": "string", "minLength": 1 },
144
+ "packageManager": { "enum": ["npm", "pnpm", "yarn", "bun"] },
145
+ "hosts": { "type": "array", "items": { "$ref": "#/definitions/host" }, "minItems": 1 },
146
+ "verbose": { "enum": [0, 1, 2, 3] }
147
+ },
148
+ "required": ["hosts"],
149
+ "additionalProperties": false
150
+ },
151
+ "host": {
152
+ "type": "object",
153
+ "properties": {
154
+ "name": { "type": "string", "minLength": 1 },
155
+ "ssh": {
156
+ "oneOf": [
157
+ { "type": "string", "minLength": 1 },
158
+ {
159
+ "type": "object",
160
+ "properties": {
161
+ "user": { "type": "string", "minLength": 1 },
162
+ "host": { "type": "string", "minLength": 1 },
163
+ "port": { "type": "integer", "minimum": 1, "maximum": 65535 }
164
+ },
165
+ "required": ["user", "host"],
166
+ "additionalProperties": false
167
+ }
168
+ ]
169
+ },
170
+ "deployPath": { "type": "string", "minLength": 1, "pattern": "^/" },
171
+ "branch": {
172
+ "oneOf": [
173
+ { "type": "string", "minLength": 1 },
174
+ {
175
+ "type": "object",
176
+ "properties": {
177
+ "name": { "type": "string", "minLength": 1 },
178
+ "ask": { "type": "boolean" }
179
+ },
180
+ "required": ["name", "ask"],
181
+ "additionalProperties": false
182
+ }
183
+ ]
184
+ },
185
+ "healthcheck": {
186
+ "type": "object",
187
+ "properties": {
188
+ "url": { "type": "string", "minLength": 1 },
189
+ "retries": { "type": "integer", "minimum": 1 },
190
+ "delayMs": { "type": "integer", "minimum": 0 }
191
+ },
192
+ "required": [],
193
+ "additionalProperties": false
194
+ },
195
+ "bin": {
196
+ "type": "object",
197
+ "propertyNames": { "type": "string", "minLength": 1 },
198
+ "additionalProperties": { "type": "string", "minLength": 1 }
199
+ }
200
+ },
201
+ "required": ["name", "ssh", "deployPath"],
202
+ "additionalProperties": false
203
+ },
204
+ "taskStep": {
205
+ "oneOf": [
206
+ {
207
+ "type": "object",
208
+ "properties": { "cd": { "type": "string", "minLength": 1 } },
209
+ "required": ["cd"],
210
+ "additionalProperties": false
211
+ },
212
+ {
213
+ "type": "object",
214
+ "properties": { "run": { "type": "string", "minLength": 1 } },
215
+ "required": ["run"],
216
+ "additionalProperties": false
217
+ },
218
+ {
219
+ "type": "object",
220
+ "properties": {
221
+ "local": {
222
+ "type": "object",
223
+ "properties": {
224
+ "command": { "type": "string", "minLength": 1 },
225
+ "cwd": { "type": "string", "minLength": 1 }
226
+ },
227
+ "required": ["command"],
228
+ "additionalProperties": false
229
+ }
230
+ },
231
+ "required": ["local"],
232
+ "additionalProperties": false
233
+ },
234
+ {
235
+ "type": "object",
236
+ "properties": {
237
+ "upload": {
238
+ "type": "object",
239
+ "properties": {
240
+ "local": { "type": "string", "minLength": 1 },
241
+ "remote": { "type": "string", "minLength": 1 }
242
+ },
243
+ "required": ["local", "remote"],
244
+ "additionalProperties": false
245
+ }
246
+ },
247
+ "required": ["upload"],
248
+ "additionalProperties": false
249
+ },
250
+ {
251
+ "type": "object",
252
+ "properties": {
253
+ "download": {
254
+ "type": "object",
255
+ "properties": {
256
+ "remote": { "type": "string", "minLength": 1 },
257
+ "local": { "type": "string", "minLength": 1 }
258
+ },
259
+ "required": ["remote", "local"],
260
+ "additionalProperties": false
261
+ }
262
+ },
263
+ "required": ["download"],
264
+ "additionalProperties": false
265
+ }
266
+ ]
267
+ },
268
+ "taskDefinition": {
269
+ "oneOf": [
270
+ { "type": "array", "items": { "$ref": "#/definitions/taskStep" }, "minItems": 1 },
271
+ {
272
+ "type": "object",
273
+ "properties": {
274
+ "description": { "type": "string", "minLength": 1 },
275
+ "steps": {
276
+ "type": "array",
277
+ "items": { "$ref": "#/definitions/taskStep" },
278
+ "minItems": 1
279
+ }
280
+ },
281
+ "required": ["steps"],
282
+ "additionalProperties": false
283
+ }
284
+ ]
285
+ }
286
+ }
287
+ }
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: catapultjs
3
- description: Work with Catapult (@catapultjs/deploy), the SSH deployment tool for Node.js. Use when creating or updating a deploy.ts config, writing recipes or deployment tasks, customizing the deploy pipeline, or scripting deployments with the programmatic API (Catapult class).
3
+ description: Work with Catapult (@catapultjs/deploy), the SSH deployment tool for Node.js. Use when creating or updating TypeScript, JavaScript or JSON deploy configs, writing recipes or deployment tasks, customizing the deploy pipeline, or scripting deployments with the programmatic API (Catapult class).
4
4
  ---
5
5
 
6
6
  # Catapult (@catapultjs/deploy)
@@ -9,33 +9,36 @@ Capistrano-style SSH deployment for Node.js: versioned releases under `releases/
9
9
 
10
10
  ## Critical rule
11
11
 
12
- `deploy:update_code` uploads `source_path` by SCP by default. Import `recipes/git` or `recipes/rsync` only when you want to replace that delivery behavior. Do not combine delivery providers such as `git` and `rsync` unless the user explicitly defines the pipeline.
12
+ `deploy:update_code` uploads `source_path` by SCP by default. Import `recipes/git` or `recipes/rsync`, or list `git`/`rsync` under JSON `recipes`, only when you want to replace that delivery behavior. Do not combine delivery providers such as `git` and `rsync` unless the user explicitly defines the pipeline.
13
13
 
14
14
  ## References
15
15
 
16
16
  Read the file matching the task before writing code:
17
17
 
18
- | Task | Read |
19
- | --- | --- |
20
- | Create or update `deploy.ts`: hosts, recipe selection, healthchecks, lifecycle hooks, pipeline tuning, `setPipeline()` | [references/config.md](references/config.md) |
21
- | Write or modify a recipe or deployment task: task DSL, `onSetup`/`onStatus` hooks, store options, `TaskRegistry` | [references/recipe.md](references/recipe.md) |
22
- | Use an official recipe (git, rsync, nextjs, nuxt, astro, tanstack, nestjs, adonisjs, vitepress, directus, pm2, redis): tasks added, store keys, monorepo patterns | [references/recipes.md](references/recipes.md) |
23
- | Script deployments from Node.js (scripts, CI, bots, dashboards) with the `Catapult` class | [references/api.md](references/api.md) |
24
- | Set up a GitHub Actions workflow with `catapultjs/deploy-action`: inputs, SSH secrets, env vars | [references/github-actions.md](references/github-actions.md) |
25
- | Use the `cata` CLI: deploy, rollback, task, status, run, ssh, list commands and their options | [references/cli.md](references/cli.md) |
18
+ | Task | Read |
19
+ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------ |
20
+ | Create or update a deploy config: choose TS/JS or JSON, configure hosts and recipes, add tasks, store values, healthchecks or pipeline controls | [references/config.md](references/config.md) |
21
+ | Write or modify a recipe or deployment task: task DSL, `onSetup`/`onStatus` hooks, store options, `TaskRegistry` | [references/recipe.md](references/recipe.md) |
22
+ | Use an official recipe (git, rsync, nextjs, nuxt, astro, tanstack, nestjs, adonisjs, vitepress, directus, pm2, redis, caddy, systemd): tasks added, store keys, monorepo patterns | [references/recipes.md](references/recipes.md) |
23
+ | Script deployments from Node.js (scripts, CI, bots, dashboards) with the `Catapult` class | [references/api.md](references/api.md) |
24
+ | Set up a GitHub Actions workflow with `catapultjs/deploy-action`: inputs, SSH secrets, env vars | [references/github-actions.md](references/github-actions.md) |
25
+ | Use the `cata` CLI: deploy, rollback, task, status, run, ssh, list commands and their options | [references/cli.md](references/cli.md) |
26
26
 
27
27
  When a change spans several areas (e.g. a config plus a custom recipe), read every matching reference.
28
28
 
29
29
  ## Interactive config workflow
30
30
 
31
- When the user asks to create, initialize, or configure a Catapult deployment and the required facts are not already present in the repo or prompt, ask focused questions before writing `deploy.ts`.
31
+ When the user asks to create, initialize, or configure a Catapult deployment and the required facts are not already present in the repo or prompt, ask focused questions before writing the config.
32
32
 
33
33
  Do not invent production values. At minimum, determine:
34
34
 
35
35
  - app stack/recipe (`nextjs`, `nextjs_static`, `nuxt`, `astro`, `nestjs`, `tanstack`, `adonisjs`, etc.)
36
+ - config format: strict declarative JSON, or TypeScript/JavaScript when executable behavior is required
36
37
  - code delivery mode (default SCP via `source_path`, `git`, `rsync`, local-build/static recipe, or custom)
37
38
  - host name, SSH target, deploy path, and branch if using `git`
38
39
  - process manager (`pm2` or none) and whether an `ecosystem.config.cjs` should be created
39
40
  - `.env`/shared paths and optional healthcheck URL
40
41
 
41
42
  Prefer one compact question group over a long interview. If the project files already answer some items, state the inferred values and ask only for the missing or ambiguous ones. After the user answers, generate the config and include the setup/deploy commands.
43
+
44
+ Use `deploy.config.json` for data-only deployments with built-in recipes, serializable store values, declarative task steps and direct `pipeline`, `remove`, `before`, and `after` controls. Include `"$schema": "https://catapultjs.com/schema/deploy.schema.json"` and `"version": 1`. Static `hosts[].bin` overrides are supported. Use `cata config:validate` to validate a config explicitly in CI or before deployment; add `--json` for machine-readable output. Use TypeScript or JavaScript for callbacks/hooks, external recipes, dynamic `bin()` calls inside custom tasks, conditional pipeline changes or arbitrary task code.
@@ -4,7 +4,7 @@ The CLI is `cata`, invoked via `npx cata <command>`. Full docs: https://catapult
4
4
 
5
5
  ## Config loading
6
6
 
7
- `version` and `init` work without a config file. All other commands load `deploy.ts`, `deploy.config.ts`, `deploy.js`, or `deploy.config.js` from the current directory, or use `--config <path>` / `-c <path>` to specify another file.
7
+ `version` and `init` work without a config file. All other commands auto-detect `deploy.ts`, `deploy.config.ts`, `deploy.js`, `deploy.config.js`, `deploy.config.json` or `deploy.json` from the current directory, or use `--config <path>` / `-c <path>` to specify another file. JSON configs are schema-validated before command execution.
8
8
 
9
9
  ## Global options
10
10
 
@@ -145,12 +145,21 @@ npx cata pipeline --json
145
145
 
146
146
  ### `init`
147
147
 
148
- Generates a starter `deploy.ts` in the current directory. No config required.
148
+ Prompts for TypeScript, JavaScript or JSON and generates `deploy.config.ts`, `deploy.config.js` or `deploy.config.json` in the current directory. The JSON template includes `version: 1` and `"$schema": "https://catapultjs.com/schema/deploy.schema.json"`. No config required.
149
149
 
150
150
  ```bash
151
151
  npx cata init
152
152
  ```
153
153
 
154
+ ### `config:validate`
155
+
156
+ Loads the deploy config and exits without running deployment tasks or connecting to hosts. Supports `--config <path>` / `-c <path>` and `--json`. JSON output is `{ "valid": true, "file": "..." }` on success and `{ "valid": false, "file": "...", "error": "..." }` on validation failure.
157
+
158
+ ```bash
159
+ npx cata config:validate
160
+ npx cata config:validate --json
161
+ ```
162
+
154
163
  ### `version`
155
164
 
156
165
  Prints the installed `@catapultjs/deploy` version. No config required.