create-paratix 0.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/LICENSE +21 -0
- package/README.md +193 -0
- package/package.json +27 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Sebastian Software GmbH
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
# create-paratix
|
|
2
|
+
|
|
3
|
+
Scaffolds a new [Paratix](https://github.com/sebastian-software/paratix) server project. Run it once to get a working directory structure with a TypeScript playbook, then edit and apply.
|
|
4
|
+
|
|
5
|
+
## Quick Start
|
|
6
|
+
|
|
7
|
+
**Step 1 -- Create the project**
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
# npm
|
|
11
|
+
npm create paratix my-server
|
|
12
|
+
|
|
13
|
+
# pnpm
|
|
14
|
+
pnpm create paratix my-server
|
|
15
|
+
|
|
16
|
+
# yarn
|
|
17
|
+
yarn create paratix my-server
|
|
18
|
+
|
|
19
|
+
# bun
|
|
20
|
+
bunx create-paratix my-server
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
**Step 2 -- Enter the directory**
|
|
24
|
+
|
|
25
|
+
Dependencies are installed automatically. If installation fails, run your package manager's install command manually.
|
|
26
|
+
|
|
27
|
+
```sh
|
|
28
|
+
cd my-server
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
**Step 3 -- Edit `server.ts`** with your actual server address, SSH user, and the modules you want to apply.
|
|
32
|
+
|
|
33
|
+
**Step 4 -- Apply**
|
|
34
|
+
|
|
35
|
+
```sh
|
|
36
|
+
# pnpm / yarn / bun
|
|
37
|
+
pnpm apply:dry # dry run first -- see what would change
|
|
38
|
+
pnpm apply # apply to the server
|
|
39
|
+
|
|
40
|
+
# npm
|
|
41
|
+
npm run apply:dry
|
|
42
|
+
npm run apply
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Project Structure
|
|
46
|
+
|
|
47
|
+
| File / Directory | Purpose |
|
|
48
|
+
| ---------------- | ------------------------------------------------------------------------- |
|
|
49
|
+
| `server.ts` | Your playbook. Edit this file. |
|
|
50
|
+
| `package.json` | Includes `apply` and `apply:dry` scripts. |
|
|
51
|
+
| `tsconfig.json` | TypeScript config (ES2024, NodeNext, strict). |
|
|
52
|
+
| `.gitignore` | Excludes `node_modules/`, `dist/`, `.env`, and log files. |
|
|
53
|
+
| `.env.example` | Template for secrets. Copy to `.env` and fill in values. |
|
|
54
|
+
| `files/` | Place template files here. They get uploaded to the server at apply time. |
|
|
55
|
+
|
|
56
|
+
## Writing Your Playbook
|
|
57
|
+
|
|
58
|
+
`server.ts` exports a server definition. The scaffolded file looks like this:
|
|
59
|
+
|
|
60
|
+
```typescript
|
|
61
|
+
import { server, recipe } from "paratix"
|
|
62
|
+
import { package as pkg, hostname, sshd, ufw, file, service, user } from "paratix/modules"
|
|
63
|
+
|
|
64
|
+
export default server({
|
|
65
|
+
name: "my-server",
|
|
66
|
+
host: "1.2.3.4",
|
|
67
|
+
ssh: {
|
|
68
|
+
user: "root",
|
|
69
|
+
ports: [22],
|
|
70
|
+
privateKey: "~/.ssh/id_ed25519",
|
|
71
|
+
},
|
|
72
|
+
env: {
|
|
73
|
+
SERVER_NAME: "my-server",
|
|
74
|
+
SSH_PORT: 2222,
|
|
75
|
+
},
|
|
76
|
+
run: [
|
|
77
|
+
hostname.set("my-server"),
|
|
78
|
+
pkg.upgrade("2026-03-01"),
|
|
79
|
+
pkg.installed("nginx", "curl", "htop"),
|
|
80
|
+
|
|
81
|
+
recipe(
|
|
82
|
+
"ssh-hardening",
|
|
83
|
+
[
|
|
84
|
+
sshd.port(2222),
|
|
85
|
+
sshd.config({
|
|
86
|
+
PermitRootLogin: "no",
|
|
87
|
+
PasswordAuthentication: "no",
|
|
88
|
+
}),
|
|
89
|
+
],
|
|
90
|
+
{
|
|
91
|
+
signals: [service.restart("sshd")],
|
|
92
|
+
}
|
|
93
|
+
),
|
|
94
|
+
|
|
95
|
+
recipe("firewall", [ufw.rule("allow", [22, 2222, 80, 443]), ufw.enabled()]),
|
|
96
|
+
],
|
|
97
|
+
})
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
Key concepts:
|
|
101
|
+
|
|
102
|
+
- **Modules** -- each item in `run` is a module. A module checks the current server state and applies changes only when needed (idempotent).
|
|
103
|
+
- **Recipes** -- `recipe()` groups related modules under a name. If any module in the group changes something, signals fire after the group completes (e.g. `service.restart("sshd")`).
|
|
104
|
+
- **Signals** -- actions that run after a recipe when at least one module in it made a change. Useful for reloading services.
|
|
105
|
+
- **Env** -- values in the `env` field are available in template files as `{{KEY}}`. See [Environment Variables](#environment-variables) below.
|
|
106
|
+
|
|
107
|
+
For the full list of built-in modules and their options, see the [Paratix module reference](https://github.com/sebastian-software/paratix).
|
|
108
|
+
|
|
109
|
+
## Applying to a Server
|
|
110
|
+
|
|
111
|
+
Always do a dry run first to see what Paratix would change without touching the server:
|
|
112
|
+
|
|
113
|
+
```sh
|
|
114
|
+
pnpm apply:dry
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
Then apply for real:
|
|
118
|
+
|
|
119
|
+
```sh
|
|
120
|
+
pnpm apply
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
These scripts map to:
|
|
124
|
+
|
|
125
|
+
```sh
|
|
126
|
+
paratix apply server.ts --dry-run
|
|
127
|
+
paratix apply server.ts
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
### CLI flags
|
|
131
|
+
|
|
132
|
+
| Flag | Default | Description |
|
|
133
|
+
| ------------------------------- | -------- | -------------------------------------------------------------------- |
|
|
134
|
+
| `<file>` | required | Path to the playbook file (`.ts` or `.js`). |
|
|
135
|
+
| `--dry-run` | `false` | Check state only. Shows what would change without applying anything. |
|
|
136
|
+
| `--env <key=value>` | `{}` | Set or override an env value. Repeatable: `--env A=1 --env B=2`. |
|
|
137
|
+
| `--env-file <path>` | -- | Load a `.env` file. |
|
|
138
|
+
| `--reconnect-timeout <seconds>` | `300` | Seconds to wait for SSH reconnect after a port or reboot change. |
|
|
139
|
+
| `--verbose` | `false` | Show full stack traces on errors. |
|
|
140
|
+
|
|
141
|
+
After all modules run, Paratix prints a summary:
|
|
142
|
+
|
|
143
|
+
```
|
|
144
|
+
3 changed · 5 ok · 0 skipped · 0 failed
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
## Environment Variables
|
|
148
|
+
|
|
149
|
+
Copy `.env.example` to `.env` and fill in your values:
|
|
150
|
+
|
|
151
|
+
```sh
|
|
152
|
+
cp .env.example .env
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
The example contains:
|
|
156
|
+
|
|
157
|
+
```sh
|
|
158
|
+
# Server configuration
|
|
159
|
+
# SUDO_PASSWORD=your-sudo-password
|
|
160
|
+
# SSH_KEY_PATH=~/.ssh/id_ed25519
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
Env values come from three sources, merged in this order (last wins):
|
|
164
|
+
|
|
165
|
+
1. `--env-file <path>`
|
|
166
|
+
2. `--env <key=value>` flags
|
|
167
|
+
3. The `env` field in `server()` -- this has the highest priority
|
|
168
|
+
|
|
169
|
+
> **Note:** Because `server({ env })` has the highest priority, values defined there cannot be overridden from the CLI. Do not put secrets (passwords, tokens) or values you need to change per run in `server({ env })` -- use `.env` files or `--env` flags for those. Reserve the `env` field in `server()` for static defaults that are the same across every run.
|
|
170
|
+
|
|
171
|
+
### Template files
|
|
172
|
+
|
|
173
|
+
Files in `files/` with a `.tmpl` extension support `{{KEY}}` placeholders. Paratix replaces them with env values at apply time.
|
|
174
|
+
|
|
175
|
+
```
|
|
176
|
+
files/nginx.conf.tmpl
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
```nginx
|
|
180
|
+
server {
|
|
181
|
+
server_name {{SERVER_NAME}};
|
|
182
|
+
}
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
To write a literal `{{`, use `\{{`.
|
|
186
|
+
|
|
187
|
+
## Requirements
|
|
188
|
+
|
|
189
|
+
- Node.js >= 24.0.0
|
|
190
|
+
|
|
191
|
+
## License
|
|
192
|
+
|
|
193
|
+
MIT
|
package/package.json
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "create-paratix",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Scaffold a new Paratix server project",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"scaffold",
|
|
8
|
+
"cli",
|
|
9
|
+
"create",
|
|
10
|
+
"paratix",
|
|
11
|
+
"project-generator",
|
|
12
|
+
"template",
|
|
13
|
+
"vps",
|
|
14
|
+
"server"
|
|
15
|
+
],
|
|
16
|
+
"homepage": "https://paratix.oss.sebastian-software.com",
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "git+https://github.com/sebastian-software/paratix.git",
|
|
20
|
+
"directory": "packages/create-paratix"
|
|
21
|
+
},
|
|
22
|
+
"bugs": {
|
|
23
|
+
"url": "https://github.com/sebastian-software/paratix/issues"
|
|
24
|
+
},
|
|
25
|
+
"author": "Sebastian Fastner <s.fastner@sebastian-software.de>",
|
|
26
|
+
"license": "MIT"
|
|
27
|
+
}
|