Skip to content

Commit c7dcff5

Browse files
committed
packaging refinements
1 parent 12e716c commit c7dcff5

4 files changed

Lines changed: 14 additions & 14 deletions

File tree

packaging/src/actions.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,8 @@ The recommended pattern:
132132
3. **Provide a toggle action** that reads the current registration state, flips it, and writes back.
133133

134134
```typescript
135-
// In init/initializeService.ts
136-
export const initializeService = sdk.setupOnInit(async (effects, kind) => {
135+
// In init/taskDisableRegistrations.ts
136+
export const taskDisableRegistrations = sdk.setupOnInit(async (effects, kind) => {
137137
if (kind !== "install") return;
138138
await sdk.action.createOwnTask(effects, toggleRegistrations, "important", {
139139
reason:
@@ -390,7 +390,7 @@ export const main = sdk.setupMain(async ({ effects }) => {
390390

391391
### 5. Initialize with SMTP Disabled
392392

393-
In `init/initializeService.ts`, set the default SMTP state alongside any internal-only secrets the service needs. The admin password is set by the `setAdminPassword` action when the user runs its critical task (see [Prompt User to Create Admin Credentials](./recipe-admin-credentials.md)):
393+
In `init/seedFiles.ts`, set the default SMTP state alongside any internal-only secrets the service needs. The admin password is set by the `setAdminPassword` action when the user runs its critical task (see [Prompt User to Create Admin Credentials](./recipe-admin-credentials.md)):
394394

395395
```typescript
396396
await storeJson.merge(effects, {

packaging/src/init.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
For one-time setup that generates new state. Internal-only secrets (DB password, JWT secret, etc.) **are** generated here, because no user interaction is involved:
1717

1818
```typescript
19-
export const initializeService = sdk.setupOnInit(async (effects, kind) => {
19+
export const seedFiles = sdk.setupOnInit(async (effects, kind) => {
2020
if (kind !== 'install') return
2121

2222
// Internal secret consumed by setupMain — never shown to the user
@@ -33,7 +33,7 @@ User-facing admin credentials follow a different pattern — see [Watch State an
3333
For setup that should also run when restoring from backup (but not on container rebuild):
3434

3535
```typescript
36-
export const initializeService = sdk.setupOnInit(async (effects, kind) => {
36+
export const reRegisterWebhook = sdk.setupOnInit(async (effects, kind) => {
3737
if (kind === null) return // Skip on container rebuild
3838

3939
// Runs on both install and restore — e.g. re-register a webhook with an
@@ -47,7 +47,7 @@ export const initializeService = sdk.setupOnInit(async (effects, kind) => {
4747
For registering `.const()` triggers that need to persist for the container's lifetime. These re-register on container rebuild:
4848

4949
```typescript
50-
export const initializeService = sdk.setupOnInit(async (effects, kind) => {
50+
export const registerWatchers = sdk.setupOnInit(async (effects, kind) => {
5151
// Runs on install, restore, AND container rebuild
5252

5353
// Register a watcher that lives for the container lifetime
@@ -148,7 +148,7 @@ export const setAdminPassword = sdk.Action.withoutInput(
148148

149149
If the upstream service needs the password applied via CLI or API rather than just read from the store at startup, wrap the work in `sdk.SubContainer.withTemp()` inside the action handler — see the [Reset a Password](recipe-reset-password.md) recipe.
150150

151-
## Registering initializeService
151+
## Registering a custom init function
152152

153153
Add your custom init function to `init/index.ts`:
154154

@@ -159,15 +159,15 @@ import { setInterfaces } from '../interfaces'
159159
import { versionGraph } from '../versions'
160160
import { actions } from '../actions'
161161
import { restoreInit } from '../backups'
162-
import { initializeService } from './initializeService'
162+
import { seedFiles } from './seedFiles'
163163

164164
export const init = sdk.setupInit(
165165
restoreInit,
166166
versionGraph,
167167
setInterfaces,
168168
setDependencies,
169169
actions,
170-
initializeService, // Add this
170+
seedFiles, // Add this
171171
)
172172

173173
export const uninit = sdk.setupUninit(versionGraph)
@@ -316,7 +316,7 @@ Severity levels: `'critical'`, `'important'`, `'optional'`
316316
### Checking Init Kind
317317

318318
```typescript
319-
export const initializeService = sdk.setupOnInit(async (effects, kind) => {
319+
export const seedFiles = sdk.setupOnInit(async (effects, kind) => {
320320
// kind === 'install': Fresh install
321321
// kind === 'update': After version upgrade
322322
// kind === 'restore': Restoring from backup

packaging/src/main.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ Oneshots are tasks that run on every startup before daemons. Use them for idempo
177177
```
178178

179179
> [!WARNING]
180-
> Do NOT put one-time setup tasks (like `createsuperuser`) in `main.ts` oneshots -- they run on every startup and will fail on subsequent runs. Use `init/initializeService.ts` instead. See [Initialization Patterns](./init.md) for details.
180+
> Do NOT put one-time setup tasks (like `createsuperuser`) in `main.ts` oneshots -- they run on every startup and will fail on subsequent runs. Use a custom init file (e.g. `init/seedFiles.ts`) instead. See [Initialization Patterns](./init.md) for details.
181181
182182
## Exec Command
183183

@@ -468,7 +468,7 @@ The `user` option is optional. If omitted, commands run as the default user defi
468468
**Use `execFail()` when:**
469469

470470
- The command must succeed for the service to work correctly
471-
- You are in `initializeService.ts` and want installation to fail if setup fails
471+
- You are in a custom init file (e.g. `seedFiles.ts`) and want installation to fail if setup fails
472472
- You want automatic error propagation
473473

474474
**Use `exec()` when:**

packaging/src/versions.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,8 +270,8 @@ export const seedFiles = sdk.setupOnInit(async (effects, kind) => {
270270
Tasks reference actions, so they must be created in a `setupOnInit` that runs after actions are registered in the init sequence:
271271

272272
```typescript
273-
// init/initializeService.ts
274-
export const initializeService = sdk.setupOnInit(async (effects, kind) => {
273+
// init/taskDisableRegistrations.ts
274+
export const taskDisableRegistrations = sdk.setupOnInit(async (effects, kind) => {
275275
if (kind !== 'install') return
276276
await sdk.action.createOwnTask(effects, toggleRegistrations, 'important', {
277277
reason: 'After creating your admin account, disable registrations.',

0 commit comments

Comments
 (0)