@zukhruf/nx 0.8.35 → 0.8.37

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,297 @@
1
+ import { execFileSync } from 'node:child_process';
2
+ import { randomBytes } from 'node:crypto';
3
+ import { posix } from 'node:path';
4
+ import { formatFiles, installPackagesTask, readJson, runTasksInSerial, updateJson, } from '@nx/devkit';
5
+ import { appDirectory, projectNameOf } from "../app-directory.js";
6
+ import { envMarker, infraRoot } from "../dokploy/files.js";
7
+ import initGenerator from "../init/generator.js";
8
+ import { portOf } from "../pair/generator.js";
9
+ import { rootDependencyNames, settleRootDependencies, } from "../root-dependencies.js";
10
+ import { appPackageVersions as versions, zukhrufVersion } from "../versions.js";
11
+ import { allowedOriginsComment, authCliTs, authClientTs, authEnvTs, authMount, authPrisma, authRouteTs, authStackEnv, authTf, authTs, backendSessionTs, startupAuthTs, webSessionTs, } from "./files.js";
12
+ /** The origin of the Vite dev server of a react-app (its vite.config.ts). */
13
+ const viteOrigin = 'http://localhost:5173';
14
+ /** The module that the better-auth CLI loads, relative to the backend root. */
15
+ const cliConfig = 'src/auth.cli.ts';
16
+ /**
17
+ * better-auth on a node-app and the db package that it is wired to: the auth
18
+ * factory, the CLI config, the routes under /api/auth, the environment, the
19
+ * models of better-auth in the db package, and the auth:generate and
20
+ * auth:check targets. It runs `init` first. After the install, a task runs
21
+ * auth:generate, which writes the models. A second run keeps the files it
22
+ * wrote and adds nothing twice. It writes no migration (ADR 0012).
23
+ */
24
+ export default async function authGenerator(tree, options) {
25
+ const initTask = await initGenerator(tree);
26
+ const backendRoot = appDirectory(options.backend).projectRoot;
27
+ const dbRoot = appDirectory(options.db).projectRoot;
28
+ if (!tree.exists(`${backendRoot}/sdk-it.config.ts`)) {
29
+ throw new Error(`${backendRoot} has no sdk-it.config.ts, so it is not a node-app. Run @zukhruf/nx:node-app ${backendRoot} first.`);
30
+ }
31
+ if (!tree.exists(`${dbRoot}/prisma.config.ts`) ||
32
+ !tree
33
+ .read(`${dbRoot}/src/index.ts`, 'utf-8')
34
+ ?.includes('export function createPrisma(')) {
35
+ throw new Error(`${dbRoot} has no prisma.config.ts and createPrisma, so it is not a db package. Run @zukhruf/nx:prisma ${dbRoot} first.`);
36
+ }
37
+ const dbPackageName = readJson(tree, `${dbRoot}/package.json`).name;
38
+ if (dbPackageName === undefined) {
39
+ throw new Error(`${dbRoot}/package.json has no name.`);
40
+ }
41
+ const startupPath = `${backendRoot}/src/startup.ts`;
42
+ const startup = tree.read(startupPath, 'utf-8') ?? '';
43
+ if (!startup.includes(`from '${dbPackageName}';\n`)) {
44
+ throw new Error(`${startupPath} does not create the client of ${dbPackageName}. Run @zukhruf/nx:prisma ${dbRoot} --backend ${backendRoot} first.`);
45
+ }
46
+ const webRoot = options.web === undefined
47
+ ? undefined
48
+ : appDirectory(options.web).projectRoot;
49
+ if (webRoot !== undefined && !tree.exists(`${webRoot}/vite.config.ts`)) {
50
+ throw new Error(`${webRoot} has no vite.config.ts, so it is not a react-app. Run @zukhruf/nx:react-app ${webRoot} first.`);
51
+ }
52
+ const backendName = projectNameOf(tree, backendRoot);
53
+ const dbName = projectNameOf(tree, dbRoot);
54
+ const before = rootDependencyNames(tree);
55
+ writeIfMissing(tree, `${backendRoot}/src/auth.ts`, authTs(dbPackageName));
56
+ writeIfMissing(tree, `${backendRoot}/${cliConfig}`, authCliTs(dbPackageName));
57
+ writeIfMissing(tree, `${backendRoot}/src/routes/auth.route.ts`, authRouteTs);
58
+ writeIfMissing(tree, `${backendRoot}/src/session.ts`, backendSessionTs);
59
+ writeIfMissing(tree, `${dbRoot}/models/auth.prisma`, authPrisma);
60
+ wireStartup(tree, startupPath, dbPackageName);
61
+ mountRoutes(tree, `${backendRoot}/src/app.ts`);
62
+ wireEnvironment(tree, backendRoot);
63
+ wireInfra(tree);
64
+ if (webRoot !== undefined)
65
+ wireWeb(tree, backendRoot, webRoot);
66
+ updateJson(tree, `${backendRoot}/package.json`, (packageJson) => {
67
+ packageJson.dependencies = {
68
+ ...packageJson.dependencies,
69
+ 'better-auth': versions['better-auth'],
70
+ '@zukhruf/authentication': zukhrufVersion,
71
+ };
72
+ packageJson.nx = {
73
+ ...packageJson.nx,
74
+ targets: {
75
+ ...packageJson.nx?.targets,
76
+ ...authTargets({ backendRoot, dbRoot, dbName }),
77
+ },
78
+ };
79
+ return packageJson;
80
+ });
81
+ // The CLI of better-auth is a tool of the workspace, as the sdk-it CLI is.
82
+ settleRootDependencies(tree, before, {
83
+ devDependencies: { auth: versions.auth },
84
+ });
85
+ await formatFiles(tree);
86
+ return runTasksInSerial(initTask, () => installPackagesTask(tree), () => generateModels(tree.root, backendName));
87
+ }
88
+ function writeIfMissing(tree, path, content) {
89
+ if (!tree.exists(path))
90
+ tree.write(path, content);
91
+ }
92
+ /** Replaces `marker` in a file of the backend, or stops when the file has no marker. */
93
+ function insert(tree, path, marker, replacement) {
94
+ const content = tree.read(path, 'utf-8');
95
+ if (content === null || !content.includes(marker)) {
96
+ throw new Error(`${path} has no ${JSON.stringify(marker)}, so the generator cannot wire auth into it.`);
97
+ }
98
+ tree.write(path, content.replace(marker, replacement));
99
+ }
100
+ /** Adds `KEY=value` to an env file that has no line for the key. */
101
+ function addEnvEntry(tree, path, key, value) {
102
+ const content = tree.read(path, 'utf-8') ?? '';
103
+ if (new RegExp(`^${key}=`, 'm').test(content))
104
+ return;
105
+ const separator = content === '' || content.endsWith('\n') ? '' : '\n';
106
+ tree.write(path, `${content}${separator}${key}=${value}\n`);
107
+ }
108
+ /** startup.ts creates the auth from the client that the prisma generator wired. */
109
+ function wireStartup(tree, path, dbPackageName) {
110
+ if (tree.read(path, 'utf-8')?.includes('export const auth ='))
111
+ return;
112
+ const dbImport = `from '${dbPackageName}';\n`;
113
+ insert(tree, path, dbImport, `${dbImport}\nimport { createAuth } from './auth.ts';\n`);
114
+ tree.write(path, `${tree.read(path, 'utf-8')}${startupAuthTs}`);
115
+ }
116
+ /**
117
+ * The auth routes go before the UI mount of pair and before notFound, so the
118
+ * catch-all of the web build never answers them.
119
+ */
120
+ function mountRoutes(tree, path) {
121
+ const app = tree.read(path, 'utf-8') ?? '';
122
+ if (app.includes(authMount))
123
+ return;
124
+ const uiMount = `(await import('./routes/ui.route.ts')).default(app);`;
125
+ const marker = app.includes(uiMount)
126
+ ? `\n// pair fixed the path of the web build`
127
+ : '\napp.notFound((c) =>';
128
+ insert(tree, path, marker, `\n// better-auth answers under /api/auth.\n${authMount}\n${marker}`);
129
+ }
130
+ function wireEnvironment(tree, backendRoot) {
131
+ const envPath = `${backendRoot}/src/env.ts`;
132
+ if (!tree.read(envPath, 'utf-8')?.includes('BETTER_AUTH_SECRET:')) {
133
+ insert(tree, envPath, 'const env = z.object({\n', `const env = z.object({\n${authEnvTs}`);
134
+ }
135
+ const url = `http://localhost:${portOf(tree, backendRoot)}`;
136
+ const examplePath = `${backendRoot}/.env.example`;
137
+ addEnvEntry(tree, examplePath, 'BETTER_AUTH_SECRET', '');
138
+ addEnvEntry(tree, examplePath, 'BETTER_AUTH_URL', url);
139
+ // .env is the developer's copy and is not committed, so it gets a secret of
140
+ // its own.
141
+ const envFilePath = `${backendRoot}/.env`;
142
+ if (tree.exists(envFilePath)) {
143
+ addEnvEntry(tree, envFilePath, 'BETTER_AUTH_SECRET', randomBytes(32).toString('base64url'));
144
+ addEnvEntry(tree, envFilePath, 'BETTER_AUTH_URL', url);
145
+ }
146
+ }
147
+ /**
148
+ * When the dokploy generator wrote the infra, the module call in its main.tf
149
+ * gets the secret and the URL above the marker of its env map, and auth.tf the
150
+ * secret (ADR 0015 decision 6). A repo without the module call gets nothing.
151
+ */
152
+ function wireInfra(tree) {
153
+ const production = `${infraRoot}/src/environments/production`;
154
+ const mainPath = `${production}/main.tf`;
155
+ const main = tree.read(mainPath, 'utf-8');
156
+ if (main === null || !/^module "stack" \{$/m.test(main))
157
+ return;
158
+ if (!/^\s*BETTER_AUTH_SECRET\s*=/m.test(main)) {
159
+ if (!main.includes(envMarker)) {
160
+ throw new Error(`${mainPath} calls module "stack" but its env has no ${JSON.stringify(envMarker)}, so the generator cannot add BETTER_AUTH_SECRET = random_password.better_auth.result and BETTER_AUTH_URL = "https://\${local.host}". Add the two lines to env, or put the marker back as the last line of env.`);
161
+ }
162
+ tree.write(mainPath, main.replace(envMarker, `${authStackEnv}${envMarker}`));
163
+ }
164
+ writeIfMissing(tree, `${production}/auth.tf`, authTf);
165
+ }
166
+ /**
167
+ * The web app gets the client, and the backend trusts the origins that the
168
+ * browser sends in development. The Vite proxy keeps the Origin of the page
169
+ * (changeOrigin: false), so better-auth sees the origin of the web app, not
170
+ * BETTER_AUTH_URL.
171
+ */
172
+ function wireWeb(tree, backendRoot, webRoot) {
173
+ writeIfMissing(tree, `${webRoot}/src/auth-client.ts`, authClientTs);
174
+ writeIfMissing(tree, `${webRoot}/src/session.ts`, webSessionTs);
175
+ updateJson(tree, `${webRoot}/package.json`, (packageJson) => {
176
+ const reactRouter = packageJson.dependencies?.['react-router'];
177
+ packageJson.dependencies = {
178
+ ...packageJson.dependencies,
179
+ 'better-auth': versions['better-auth'],
180
+ '@zukhruf/authentication': zukhrufVersion,
181
+ // npm refuses a react-router below the peer range of
182
+ // @zukhruf/authentication (ERESOLVE). A newer one stays.
183
+ 'react-router': reactRouter !== undefined &&
184
+ !isBelow(reactRouter, versions['react-router'])
185
+ ? reactRouter
186
+ : versions['react-router'],
187
+ };
188
+ return packageJson;
189
+ });
190
+ const origins = [viteOrigin];
191
+ const portless = portlessOrigin(tree, webRoot);
192
+ if (portless !== undefined)
193
+ origins.push(portless);
194
+ for (const file of ['.env.example', '.env']) {
195
+ const path = `${backendRoot}/${file}`;
196
+ if (tree.exists(path))
197
+ addAllowedOrigins(tree, path, origins);
198
+ }
199
+ }
200
+ /**
201
+ * Whether the version that a range like `8.5.1` or `^8.5.1` starts at is below
202
+ * `version`. A range that names no version is below.
203
+ */
204
+ function isBelow(range, version) {
205
+ const parts = (text) => /(\d+)\.(\d+)\.(\d+)/.exec(text)?.slice(1).map(Number);
206
+ const [from, to] = [parts(range), parts(version)];
207
+ if (from === undefined || to === undefined)
208
+ return true;
209
+ const index = from.findIndex((part, i) => part !== to[i]);
210
+ return index !== -1 && (from[index] ?? 0) < (to[index] ?? 0);
211
+ }
212
+ /**
213
+ * The origin of the portless target of the web app: portless serves
214
+ * `--name <name>` at https://<name>.localhost by default.
215
+ */
216
+ function portlessOrigin(tree, webRoot) {
217
+ const { nx } = readJson(tree, `${webRoot}/package.json`);
218
+ const command = nx?.targets?.portless?.command ?? '';
219
+ const name = /--name (\S+)/.exec(command)?.[1];
220
+ return name === undefined ? undefined : `https://${name}.localhost`;
221
+ }
222
+ /** Adds each missing origin to the ALLOWED_ORIGINS list of an env file. */
223
+ function addAllowedOrigins(tree, path, origins) {
224
+ const content = tree.read(path, 'utf-8') ?? '';
225
+ const line = /^ALLOWED_ORIGINS=(.*)$/m.exec(content);
226
+ if (line === null) {
227
+ const separator = content === '' || content.endsWith('\n') ? '' : '\n';
228
+ tree.write(path, `${content}${separator}${allowedOriginsComment}ALLOWED_ORIGINS=${origins.join(',')}\n`);
229
+ return;
230
+ }
231
+ const [whole, list = ''] = line;
232
+ const listed = list
233
+ .split(',')
234
+ .map((origin) => origin.trim())
235
+ .filter((origin) => origin !== '');
236
+ const missing = origins.filter((origin) => !listed.includes(origin));
237
+ if (missing.length === 0)
238
+ return;
239
+ const comment = content.includes(allowedOriginsComment)
240
+ ? ''
241
+ : allowedOriginsComment;
242
+ tree.write(path, content.replace(whole, `${comment}ALLOWED_ORIGINS=${[...listed, ...missing].join(',')}`));
243
+ }
244
+ /**
245
+ * The CLI imports the db package through its development export, which
246
+ * imports the generated client, so the client is generated first. NODE_OPTIONS
247
+ * gives jiti the development condition. NODE_ENV is development also where the
248
+ * shell sets production, because the CLI refuses the placeholder secret in
249
+ * production. auth:check only reads: it compares the
250
+ * generated client with the plugins of the config, and exits 1 on a mismatch.
251
+ */
252
+ function authTargets(options) {
253
+ const { backendRoot, dbRoot, dbName } = options;
254
+ const output = posix.relative(backendRoot, `${dbRoot}/models/auth.prisma`);
255
+ // The backend imports the db package, so `^generate` generates its client.
256
+ const generateClient = ['^generate'];
257
+ const shared = {
258
+ cwd: '{projectRoot}',
259
+ env: {
260
+ NODE_OPTIONS: '--conditions=development',
261
+ NODE_ENV: 'development',
262
+ },
263
+ };
264
+ return {
265
+ 'auth:generate': {
266
+ executor: 'nx:run-commands',
267
+ dependsOn: generateClient,
268
+ options: {
269
+ ...shared,
270
+ commands: [
271
+ `npx auth generate --adapter prisma --config ${cliConfig} --output ${output} --yes`,
272
+ `npx nx run ${dbName}:generate`,
273
+ ],
274
+ parallel: false,
275
+ },
276
+ },
277
+ 'auth:check': {
278
+ executor: 'nx:run-commands',
279
+ dependsOn: generateClient,
280
+ options: {
281
+ ...shared,
282
+ command: `npx auth check schema --config ${cliConfig}`,
283
+ },
284
+ },
285
+ };
286
+ }
287
+ /**
288
+ * Runs auth:generate after the install, so the CLI writes the models of the
289
+ * plugins into the placeholder.
290
+ */
291
+ function generateModels(workspaceRoot, backendName) {
292
+ execFileSync('npx', ['nx', 'run', `${backendName}:auth:generate`], {
293
+ cwd: workspaceRoot,
294
+ stdio: 'inherit',
295
+ });
296
+ }
297
+ //# sourceMappingURL=generator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../src/generators/auth/generator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAElC,OAAO,EAGL,WAAW,EACX,mBAAmB,EACnB,QAAQ,EACR,gBAAgB,EAChB,UAAU,GACX,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAClE,OAAO,EAAE,S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BACP,GAAG,MAAM;gBACT,OAAO,EAAE,kCAAkC,SAAS,EAAE;aACvD;SACF;KACF,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,SAAS,cAAc,CAAC,aAAqB,EAAE,WAAmB;IAChE,YAAY,CAAC,KAAK,EAAE,CAAC,IAAI,EAAE,KAAK,EAAE,GAAG,WAAW,gBAAgB,CAAC,EAAE;QACjE,GAAG,EAAE,aAAa;QAClB,KAAK,EAAE,SAAS;KACjB,CAAC,CAAC;AACL,CAAC"}
@@ -1,20 +1,23 @@
1
- import type { Registry, Stack } from './generator.ts';
1
+ import type { Stack } from './generator.ts';
2
2
  /** The root of the OpenTofu project. */
3
3
  export declare const infraRoot = "infra";
4
+ /** The module that holds the Dokploy delivery, at the ref of zukhruf's actions (ADR 0015). */
5
+ export declare const stackModuleSource = "git::https://github.com/JanuaryLabs/zukhruf.git//packages/nx/opentofu/dokploy-stack?ref=main";
6
+ /** The last line of the env map of the module call: the auth generator adds its keys above it. */
7
+ export declare const envMarker = "# Generators add env keys above this line.";
4
8
  export declare const gitignore = "# State is committed ENCRYPTED (git is the state store) at\n# src/terraform.tfstate. Only unencrypted backups and lock files are ignored.\n#\n# CRITICAL: *.backup files are PLAINTEXT and must NEVER be committed.\n*.backup\n.terraform.tfstate.lock.info\n\n# Provider plugins / module cache\n.terraform/\n\n# Saved plans are regenerated by preview and freshness-guarded.\ntfplan\n\n# tfvars can carry secrets\n*.tfvars\n*.tfvars.json\n\n# Crash logs\ncrash.log\ncrash.*.log\n\n# Local overrides\noverride.tf\noverride.tf.json\n*_override.tf\n*_override.tf.json\n";
5
9
  export declare const prettierignore = ".terraform\ntfplan\ninfra/src/terraform.tfstate\n";
6
10
  export declare const nxignore = "infra/src/terraform.tfstate\n";
7
11
  export declare function envExample(stack: Stack): string;
8
12
  export declare function composeYml(stack: Stack): string;
9
- export declare function versionsTf(stack: Stack): string;
13
+ export declare const versionsTf: string;
10
14
  /** The lock blocks, in the order of their source addresses, as \`tofu init\` writes them. */
11
- export declare function lockHcl(stack: Stack): string;
15
+ export declare const lockHcl: string;
12
16
  export declare const backendTf = "terraform {\n # Git is the state store: the encrypted state is committed at\n # infra/src/terraform.tfstate, and the apply workflow commits it back.\n backend \"local\" {\n path = \"../../terraform.tfstate\"\n }\n}\n";
13
17
  export declare function encryptionTf(stack: Stack): string;
14
18
  export declare function providersTf(stack: Stack): string;
15
19
  export declare function dnsTf(stack: Stack): string;
16
20
  export declare function mainTf(stack: Stack): string;
17
- export declare function registryTf(stack: Stack, registry: Registry): string;
18
21
  export declare function outputsTf(stack: Stack): string;
19
22
  export declare function variablesTf(stack: Stack): string;
20
23
  export declare const zizmorYml = "# zizmor (https://docs.zizmor.sh) audits the workflows in CI. Each entry\n# here is a choice, with its reason.\nrules:\n unpinned-uses:\n config:\n policies:\n # Tags and @main, as zukhruf's actions are called, not commit hashes.\n '*': ref-pin\n dangerous-triggers:\n ignore:\n # Runs only after a successful push run of CI on main, and checks out\n # main, never the code of the run that triggered it.\n - deploy.yml\n";
@@ -1 +1 @@
1
- {"version":3,"file":"files.d.ts","sourceRoot":"","sources":["../../../src/generators/dokploy/files.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAQtD,wCAAwC;AACxC,eAAO,MAAM,SAAS,UAAU,CAAC;AAkBjC,eAAO,MAAM,SAAS,qjBA0BrB,CAAC;AAIF,eAAO,MAAM,cAAc,sDAG1B,CAAC;AAMF,eAAO,MAAM,QAAQ,kCACpB,CAAC;AAEF,wBAAgB,UAAU,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,CAmC/C;AASD,wBAAgB,UAAU,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,CAgG/C;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,CAiB/C;AAED,6FAA6F;AAC7F,wBAAgB,OAAO,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,CAS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AAO,MAAM,UAAU,QActB,CAAC;AAEF,6FAA6F;AAC7F,eAAO,MAAM,OAAO,QAOnB,CAAC;AAEF,eAAO,MAAM,SAAS,oOAOrB,CAAC;AAEF,wBAAgB,YAAY,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,CAiCjD;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,CAyBhD;AAED,wBAAgB,KAAK,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,CA0B1C;AAED,wBAAgB,MAAM,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,CAsC3C;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,CAgB9C;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,CA2BhD;AAED,eAAO,MAAM,SAAS,mdAarB,CAAC;AAEF,wBAAgB,KAAK,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,CAuE1C;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,CAwN9C"}
@@ -1,13 +1,12 @@
1
1
  import { dokployProvider, hcloudProvider, randomProvider, } from "./providers.js";
2
2
  /** The root of the OpenTofu project. */
3
3
  export const infraRoot = 'infra';
4
- function providersOf(stack) {
5
- return [
6
- dokployProvider,
7
- hcloudProvider,
8
- ...(stack.database ? [randomProvider] : []),
9
- ];
10
- }
4
+ /** The module that holds the Dokploy delivery, at the ref of zukhruf's actions (ADR 0015). */
5
+ export const stackModuleSource = 'git::https://github.com/JanuaryLabs/zukhruf.git//packages/nx/opentofu/dokploy-stack?ref=main';
6
+ /** The last line of the env map of the module call: the auth generator adds its keys above it. */
7
+ export const envMarker = '# Generators add env keys above this line.';
8
+ // The module requires random even without a database, so the lock always has it.
9
+ const providers = [dokployProvider, hcloudProvider, randomProvider];
11
10
  const image = (stack, name) => `ghcr.io/${stack.owner}/${stack.name}-${name}:latest`;
12
11
  const hostDescription = (stack) => stack.host.kind === 'dns'
13
12
  ? stack.host.host
@@ -133,9 +132,7 @@ ${logging} environment:
133
132
  `
134
133
  : '';
135
134
  const backendDatabase = database
136
- ? ` environment:
137
- CONNECTION_STRING: \${CONNECTION_STRING}
138
- depends_on:
135
+ ? ` depends_on:
139
136
  postgres:
140
137
  condition: service_healthy
141
138
  migrate:
@@ -159,9 +156,12 @@ volumes:
159
156
  return `# ${name} Dokploy compose template (raw), production only: the ${app.name}
160
157
  # image${database ? ', Postgres and the one-shot migrate service' : ''}.
161
158
  #
162
- # OpenTofu owns this compose and its environment (infra/src/environments/
163
- # production). Do not edit them in the Dokploy panel. Its placeholders resolve
164
- # from that environment; write a literal dollar sign as $$.
159
+ # The repo owns this compose. OpenTofu stores it in Dokploy with its env, the
160
+ # env map of module "stack" in infra/src/environments/production/main.tf. Do
161
+ # not edit them in the Dokploy panel. Dokploy writes the env to .env next to
162
+ # the compose: the ${app.name} reads every key of it through env_file, and each
163
+ # placeholder must be a key of it (the module refuses a plan otherwise). Write
164
+ # a literal dollar sign as $$.
165
165
  #
166
166
  ${pull}
167
167
 
@@ -171,7 +171,8 @@ ${postgres} ${app.name}:
171
171
  # A compose deploy reuses the cached image unless told to pull.
172
172
  pull_policy: always
173
173
  restart: unless-stopped
174
- ${logging}${backendDatabase}${networks} labels:
174
+ ${logging} env_file: .env
175
+ ${backendDatabase}${networks} labels:
175
176
  - 'traefik.enable=true'
176
177
  - 'traefik.docker.network=dokploy-network'
177
178
  - 'traefik.http.routers.${name}-web.rule=Host(\`\${PUBLIC_HOST}\`)'
@@ -189,33 +190,28 @@ networks:
189
190
  external: true
190
191
  ${volumes}`;
191
192
  }
192
- export function versionsTf(stack) {
193
- const providers = providersOf(stack)
194
- .map((provider) => ` ${provider.name} = {
195
- source = "${provider.source}"
196
- version = "${provider.version}"
197
- }`)
198
- .join('\n');
199
- return `terraform {
193
+ export const versionsTf = `terraform {
200
194
  required_version = ">= 1.12.3"
201
195
 
202
196
  required_providers {
203
- ${providers}
197
+ ${providers
198
+ .map((provider) => ` ${provider.name} = {
199
+ source = "${provider.source}"
200
+ version = "${provider.version}"
201
+ }`)
202
+ .join('\n')}
204
203
  }
205
204
  }
206
205
  `;
207
- }
208
206
  /** The lock blocks, in the order of their source addresses, as \`tofu init\` writes them. */
209
- export function lockHcl(stack) {
210
- const blocks = providersOf(stack)
211
- .map((provider) => provider.lock)
212
- .toSorted((a, b) => a.localeCompare(b));
213
- return `# This file is maintained automatically by "tofu init".
207
+ export const lockHcl = `# This file is maintained automatically by "tofu init".
214
208
  # Manual edits may be lost in future updates.
215
209
 
216
- ${blocks.join('\n\n')}
210
+ ${providers
211
+ .map((provider) => provider.lock)
212
+ .toSorted((a, b) => a.localeCompare(b))
213
+ .join('\n\n')}
217
214
  `;
218
- }
219
215
  export const backendTf = `terraform {
220
216
  # Git is the state store: the encrypted state is committed at
221
217
  # infra/src/terraform.tfstate, and the apply workflow commits it back.
@@ -311,92 +307,44 @@ resource "hcloud_zone_rrset" "${stack.name}" {
311
307
  `;
312
308
  }
313
309
  export function mainTf(stack) {
314
- const { name, app, database } = stack;
315
- const password = database
316
- ? `
317
- resource "random_password" "postgres" {
318
- length = 32
319
- special = false
320
- }
321
- `
310
+ const { name, app, database, registry } = stack;
311
+ const databaseInput = database
312
+ ? ` database = { role = "${database.role}" }\n`
322
313
  : '';
323
- const databaseEnv = database
324
- ? `
325
- POSTGRES_PASSWORD=\${random_password.postgres.result}
326
- CONNECTION_STRING=postgresql://${database.role}:\${random_password.postgres.result}@postgres:5432/${database.role}`
314
+ const registryInput = registry
315
+ ? ` registry = { username = "${registry.username}", password = var.ghcr_pull_token }\n`
327
316
  : '';
328
- return `resource "dokploy_project" "${name}" {
329
- name = "${name}"
330
- # Required in practice: the provider writes the API's description into state
331
- # even when it is unset, and the attribute is not computed. Keep it stable:
332
- # the environment's project_id requires replacement.
333
- description = "${name} at ${hostDescription(stack)} - managed by OpenTofu"
334
-
335
- lifecycle {
336
- prevent_destroy = true
337
- }
338
- }
339
-
340
- # Dokploy creates this protected default environment with every project and
341
- # refuses to create another named "production"; provider 0.8 adopts it on
342
- # create, so a single apply provisions the stack.
343
- resource "dokploy_environment" "production" {
344
- name = "production"
345
- description = "Production environment"
346
- project_id = dokploy_project.${name}.id
347
-
348
- lifecycle {
349
- prevent_destroy = true
350
- ignore_changes = [name, description]
351
- }
352
- }
353
- ${password}
354
- resource "dokploy_compose" "${app.name}" {
355
- environment_id = dokploy_environment.production.id
356
- name = "${app.name}"
357
-
358
- source_type = "raw"
359
- compose_file_content = file("\${path.module}/../../../compose.dokploy.yml")
360
-
361
- env = <<-EOT
362
- PUBLIC_HOST=\${local.host}${databaseEnv}
363
- EOT
364
-
365
- # Deploys go through the API (compose.deploy), never the refresh-token
366
- # webhook, so auto_deploy stays off. deploy_on_create stays off so creating
367
- # the compose never launches a deployment that no job observes.
368
- auto_deploy = false
369
- deploy_on_create = false
370
-
371
- lifecycle {
372
- prevent_destroy = true
317
+ return `# zukhruf's dokploy-stack module stores the stack in Dokploy: the project, its
318
+ # adopted production environment and the raw compose with its env, and, when
319
+ # given, the Postgres password and the GHCR registry. It follows zukhruf's
320
+ # main, as the actions of the workflows do.
321
+ #
322
+ # The description is required in practice: the provider writes the API's
323
+ # description into state even when it is unset. Keep it stable: a change
324
+ # replaces the environment.
325
+ #
326
+ # Each key of env reaches the ${app.name} through env_file: .env of the compose.
327
+ module "stack" {
328
+ source = "${stackModuleSource}"
329
+
330
+ name = "${name}"
331
+ description = "${name} at ${hostDescription(stack)} - managed by OpenTofu"
332
+ app = "${app.name}"
333
+ compose_file = file("\${path.module}/../../../compose.dokploy.yml")
334
+ ${databaseInput}${registryInput}
335
+ env = {
336
+ PUBLIC_HOST = local.host
337
+ ${envMarker}
373
338
  }
374
339
  }
375
340
 
376
- # Updating dokploy_compose only stores the compose. The stack does not deploy:
377
- # the release job of the deploy workflow runs zukhruf's dokploy-deploy and
378
- # wait-for-health actions after a new image, after an apply that changed the
379
- # stack (tofu-apply's \`changed\`), and after any infra change since the last
341
+ # Updating the compose only stores it. The stack does not deploy: the release
342
+ # job of the deploy workflow runs zukhruf's dokploy-deploy and wait-for-health
343
+ # actions after a new image, after an apply that changed the stack
344
+ # (tofu-apply's \`changed\`), and after any infra change since the last
380
345
  # successful deploy, so a failed rollout is retried by the next run.
381
346
  `;
382
347
  }
383
- export function registryTf(stack, registry) {
384
- return `# Dokploy runs \`docker login\` on the server when it stores a registry, and a
385
- # compose deploy pulls with that login, so the server pulls the private images.
386
- # The login is the server's docker login for ghcr.io: each stack on the server
387
- # that stores a GHCR registry replaces it. The URL is a bare host: Dokploy
388
- # refuses one with a scheme ("Registry URL must be a valid hostname or
389
- # hostname:port").
390
- resource "dokploy_registry" "ghcr" {
391
- registry_name = "${stack.name}-ghcr"
392
- registry_type = "cloud"
393
- registry_url = "ghcr.io"
394
- image_prefix = "ghcr.io"
395
- username = "${registry.username}"
396
- password = var.ghcr_pull_token
397
- }
398
- `;
399
- }
400
348
  export function outputsTf(stack) {
401
349
  return `output "dokploy_api" {
402
350
  description = "Dokploy API base URL; the release job of the deploy workflow calls compose.deploy there."
@@ -405,7 +353,7 @@ export function outputsTf(stack) {
405
353
 
406
354
  output "compose_id" {
407
355
  description = "Dokploy compose ID of the stack, for API calls such as compose.one and compose.deploy."
408
- value = dokploy_compose.${stack.app.name}.id
356
+ value = module.stack.compose_id
409
357
  }
410
358
 
411
359
  output "host" {
@@ -1 +1 @@
1
- {"version":3,"file":"files.js","sourceRoot":"","sources":["../../../src/generators/dokploy/files.ts"],"names":[],"mappings":"AAIA,OAAO,EAEL,eAAe,EACf,cAAc,EACd,cAAc,GACf,MAAM,gBAAgB,CAAC;AAExB,wCAAwC;AACxC,MAAM,CAAC,MAAM,SAAS,GAAG,OAAO,CAAC;AAEjC,SAAS,WAAW,CAAC,KAAY;IAC/B,OAAO;QACL,eAAe;QACf,cAAc;QACd,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,CAA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I,CAAC,IAAI,CAAC,CAAC;IACd,MAAM,KAAK,GAAG,QAAQ;QACpB,CAAC,CAAC;;;4EAGsE;QACxE,CAAC,CAAC,EAAE,CAAC;IACP,MAAM,aAAa,GAAG,QAAQ;QAC5B,CAAC,CAAC;;;uCAGiC;QACnC,CAAC,CAAC,EAAE,CAAC;IACP,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uBA+Ec,GAAG,CAAC,aAAa,CAAC,IAAI,CAAC,GAAG,CAAC;;;;;;;uBAO3B,KAAK,CAAC,WAAW;;;;;;;4BAOZ,aAAa;;;;;;;;EAQvC,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;EA0BX,aAAa;;;;;;;;;;;;;;;;;;;;eAoBA,SAAS;;oBAEJ,SAAS;;;;kDAIqB,KAAK;;;;;;;;;;;;;;;;;;;;;;;+BAuBxB,GAAG,CAAC,IAAI;;;;;CAKtC,CAAC;AACF,CAAC"}
@@ -65,11 +65,11 @@ export interface Stack {
65
65
  }
66
66
  /**
67
67
  * The GitOps delivery of a node-app on Dokploy: an OpenTofu project in
68
- * `infra/` that stores the compose in Dokploy, and the CI and deploy
69
- * workflows that build the images, apply the stack through zukhruf's
70
- * tofu-apply workflow and roll it out with its dokploy-deploy and
71
- * wait-for-health actions. A second run with the same options changes
72
- * nothing.
68
+ * `infra/` whose main.tf calls zukhruf's dokploy-stack module to store the
69
+ * compose in Dokploy, and the CI and deploy workflows that build the images,
70
+ * apply the stack through zukhruf's tofu-apply workflow and roll it out with
71
+ * its dokploy-deploy and wait-for-health actions. Each file is written once:
72
+ * a second run changes nothing and keeps the repo's edits.
73
73
  */
74
74
  export default function dokployGenerator(tree: Tree, options: DokployOptions): Promise<void>;
75
75
  //# sourceMappingURL=generator.d.ts.map