@opensaas/stack-cli 0.43.0 → 0.44.0-alpha.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/README.md +116 -135
- package/dist/.build-hash +1 -0
- package/dist/commands/db.d.ts +23 -0
- package/dist/commands/db.d.ts.map +1 -0
- package/dist/commands/db.js +43 -0
- package/dist/commands/db.js.map +1 -0
- package/dist/commands/dev.d.ts +12 -1
- package/dist/commands/dev.d.ts.map +1 -1
- package/dist/commands/dev.js +519 -22
- package/dist/commands/dev.js.map +1 -1
- package/dist/commands/fk-renames.d.ts +14 -0
- package/dist/commands/fk-renames.d.ts.map +1 -0
- package/dist/commands/fk-renames.js +90 -0
- package/dist/commands/fk-renames.js.map +1 -0
- package/dist/commands/generate.d.ts +61 -4
- package/dist/commands/generate.d.ts.map +1 -1
- package/dist/commands/generate.js +225 -138
- package/dist/commands/generate.js.map +1 -1
- package/dist/commands/init.d.ts +6 -0
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +13 -2
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/junction-ids.d.ts +11 -0
- package/dist/commands/junction-ids.d.ts.map +1 -0
- package/dist/commands/junction-ids.js +81 -0
- package/dist/commands/junction-ids.js.map +1 -0
- package/dist/commands/migrate.d.ts +2 -0
- package/dist/commands/migrate.d.ts.map +1 -1
- package/dist/commands/migrate.js +47 -25
- package/dist/commands/migrate.js.map +1 -1
- package/dist/dev/app-runner.d.ts +70 -0
- package/dist/dev/app-runner.d.ts.map +1 -0
- package/dist/dev/app-runner.js +116 -0
- package/dist/dev/app-runner.js.map +1 -0
- package/dist/dev/control.d.ts +73 -0
- package/dist/dev/control.d.ts.map +1 -0
- package/dist/dev/control.js +251 -0
- package/dist/dev/control.js.map +1 -0
- package/dist/dev/staged-reconcile.d.ts +126 -0
- package/dist/dev/staged-reconcile.d.ts.map +1 -0
- package/dist/dev/staged-reconcile.js +289 -0
- package/dist/dev/staged-reconcile.js.map +1 -0
- package/dist/generator/config-load.d.ts +34 -0
- package/dist/generator/config-load.d.ts.map +1 -0
- package/dist/generator/config-load.js +64 -0
- package/dist/generator/config-load.js.map +1 -0
- package/dist/generator/context.d.ts +39 -3
- package/dist/generator/context.d.ts.map +1 -1
- package/dist/generator/context.js +245 -107
- package/dist/generator/context.js.map +1 -1
- package/dist/generator/contract-emit.d.ts +24 -0
- package/dist/generator/contract-emit.d.ts.map +1 -0
- package/dist/generator/contract-emit.js +34 -0
- package/dist/generator/contract-emit.js.map +1 -0
- package/dist/generator/contract-module.d.ts +39 -0
- package/dist/generator/contract-module.d.ts.map +1 -0
- package/dist/generator/contract-module.js +440 -0
- package/dist/generator/contract-module.js.map +1 -0
- package/dist/generator/extension-spaces.d.ts +142 -0
- package/dist/generator/extension-spaces.d.ts.map +1 -0
- package/dist/generator/extension-spaces.js +358 -0
- package/dist/generator/extension-spaces.js.map +1 -0
- package/dist/generator/index.d.ts +12 -4
- package/dist/generator/index.d.ts.map +1 -1
- package/dist/generator/index.js +7 -3
- package/dist/generator/index.js.map +1 -1
- package/dist/generator/lists.d.ts +6 -7
- package/dist/generator/lists.d.ts.map +1 -1
- package/dist/generator/lists.js +33 -13
- package/dist/generator/lists.js.map +1 -1
- package/dist/generator/output-paths.d.ts +62 -19
- package/dist/generator/output-paths.d.ts.map +1 -1
- package/dist/generator/output-paths.js +68 -30
- package/dist/generator/output-paths.js.map +1 -1
- package/dist/generator/prisma-cli.d.ts +61 -0
- package/dist/generator/prisma-cli.d.ts.map +1 -0
- package/dist/generator/prisma-cli.js +92 -0
- package/dist/generator/prisma-cli.js.map +1 -0
- package/dist/generator/prisma-config.d.ts +50 -31
- package/dist/generator/prisma-config.d.ts.map +1 -1
- package/dist/generator/prisma-config.js +72 -65
- package/dist/generator/prisma-config.js.map +1 -1
- package/dist/generator/source-text.d.ts +16 -0
- package/dist/generator/source-text.d.ts.map +1 -0
- package/dist/generator/source-text.js +35 -0
- package/dist/generator/source-text.js.map +1 -0
- package/dist/generator/tables.d.ts +5 -0
- package/dist/generator/tables.d.ts.map +1 -0
- package/dist/generator/tables.js +84 -0
- package/dist/generator/tables.js.map +1 -0
- package/dist/generator/types.d.ts +23 -3
- package/dist/generator/types.d.ts.map +1 -1
- package/dist/generator/types.js +291 -1171
- package/dist/generator/types.js.map +1 -1
- package/dist/index.js +20 -7
- package/dist/index.js.map +1 -1
- package/dist/mcp/lib/documentation-provider.d.ts.map +1 -1
- package/dist/mcp/lib/documentation-provider.js +44 -42
- package/dist/mcp/lib/documentation-provider.js.map +1 -1
- package/dist/mcp/lib/generators/feature-generator.d.ts.map +1 -1
- package/dist/mcp/lib/generators/feature-generator.js +124 -73
- package/dist/mcp/lib/generators/feature-generator.js.map +1 -1
- package/dist/mcp/lib/wizards/migration-wizard.js +6 -6
- package/dist/mcp/lib/wizards/migration-wizard.js.map +1 -1
- package/dist/mcp/lib/wizards/wizard-engine.d.ts.map +1 -1
- package/dist/mcp/lib/wizards/wizard-engine.js +3 -2
- package/dist/mcp/lib/wizards/wizard-engine.js.map +1 -1
- package/dist/mcp/server/stack-mcp-server.js +1 -1
- package/dist/migration/fk-renames.d.ts +39 -0
- package/dist/migration/fk-renames.d.ts.map +1 -0
- package/dist/migration/fk-renames.js +79 -0
- package/dist/migration/fk-renames.js.map +1 -0
- package/dist/migration/generators/migration-generator.d.ts +11 -0
- package/dist/migration/generators/migration-generator.d.ts.map +1 -1
- package/dist/migration/generators/migration-generator.js +83 -150
- package/dist/migration/generators/migration-generator.js.map +1 -1
- package/dist/migration/introspectors/prisma-introspector.d.ts.map +1 -1
- package/dist/migration/introspectors/prisma-introspector.js +1 -0
- package/dist/migration/introspectors/prisma-introspector.js.map +1 -1
- package/dist/migration/junction-ids.d.ts +15 -0
- package/dist/migration/junction-ids.d.ts.map +1 -0
- package/dist/migration/junction-ids.js +58 -0
- package/dist/migration/junction-ids.js.map +1 -0
- package/dist/migration/types.d.ts +2 -0
- package/dist/migration/types.d.ts.map +1 -1
- package/package.json +27 -15
- package/dist/generator/node-build.d.ts +0 -53
- package/dist/generator/node-build.d.ts.map +0 -1
- package/dist/generator/node-build.js +0 -280
- package/dist/generator/node-build.js.map +0 -1
- package/dist/generator/prisma.d.ts +0 -30
- package/dist/generator/prisma.d.ts.map +0 -1
- package/dist/generator/prisma.js +0 -422
- package/dist/generator/prisma.js.map +0 -1
package/dist/commands/dev.js
CHANGED
|
@@ -1,9 +1,97 @@
|
|
|
1
|
-
import * as path from 'path';
|
|
2
1
|
import * as fs from 'fs';
|
|
2
|
+
import * as path from 'path';
|
|
3
3
|
import chalk from 'chalk';
|
|
4
4
|
import chokidar from 'chokidar';
|
|
5
|
-
import {
|
|
6
|
-
|
|
5
|
+
import { connectionStringFault, findDatabaseConnection } from '@opensaas/stack-core/internal';
|
|
6
|
+
import { DevDatabaseInUseError, startDevDatabase, } from '@opensaas/stack-core/dev-database';
|
|
7
|
+
import { generateCommand, GenerationFailedError } from './generate.js';
|
|
8
|
+
import { loadOpenSaasConfig, loadProjectEnvFile, runPrismaCli } from '../generator/index.js';
|
|
9
|
+
import { createAppRunner } from '../dev/app-runner.js';
|
|
10
|
+
import { startControlChannel } from '../dev/control.js';
|
|
11
|
+
import { describePlan, planId, planDatabaseUpdate, promoteStagedGeneration, restoreMigrationRefs, restoreRefsAfterReconcile, snapshotMigrationRefs, STAGING_DIR, } from '../dev/staged-reconcile.js';
|
|
12
|
+
/**
|
|
13
|
+
* How long the config file must sit unwritten before a save counts as one
|
|
14
|
+
* save. `fs.writeFileSync` truncates then writes, which Linux inotify can
|
|
15
|
+
* deliver as two change events; macOS FSEvents coalesces them. The loop pays
|
|
16
|
+
* this much latency on every save before it reacts.
|
|
17
|
+
*/
|
|
18
|
+
const CONFIG_WRITE_SETTLE_MS = 200;
|
|
19
|
+
const DEFAULT_APP_COMMAND = ['next', 'dev'];
|
|
20
|
+
/**
|
|
21
|
+
* What to do with a save the loop skipped. The guard compares bytes — the
|
|
22
|
+
* config's own, and every module it resolved as of the last generation
|
|
23
|
+
* (#1414) — so the only save this route is for is a deliberate retry of the
|
|
24
|
+
* exact bytes the loop already has: after a reconcile that failed.
|
|
25
|
+
*/
|
|
26
|
+
const NOTHING_TO_RECONCILE_ROUTE = 'To regenerate and reconcile anyway — after a failed reconcile — run `pnpm db:update` ' +
|
|
27
|
+
'(`opensaas db update`) in another terminal.\n';
|
|
28
|
+
/** How a parked destructive change is applied, named wherever one is waiting. */
|
|
29
|
+
const parkedRoute = (id) => `To apply it, run \`pnpm db:update --plan ${id}\` in another terminal.\n`;
|
|
30
|
+
/** The Dev database's data directory, inside the Generated bundle (ADR-0063). */
|
|
31
|
+
const DEV_DATABASE_DIR = path.join('.opensaas', 'dev-db');
|
|
32
|
+
/**
|
|
33
|
+
* What a declared extension pack needs loaded into the Dev database's PGlite,
|
|
34
|
+
* keyed by both the binding name a config gives it and the package it comes
|
|
35
|
+
* from. A pack with nothing to load has no entry.
|
|
36
|
+
*/
|
|
37
|
+
const DEV_DATABASE_EXTENSIONS = {
|
|
38
|
+
pgvector: 'vector',
|
|
39
|
+
vector: 'vector',
|
|
40
|
+
'@prisma/orm-extension-pgvector': 'vector',
|
|
41
|
+
};
|
|
42
|
+
function declaredDevDatabaseExtensions(config) {
|
|
43
|
+
const loadable = new Set();
|
|
44
|
+
for (const extension of config.db.extensions ?? []) {
|
|
45
|
+
const name = DEV_DATABASE_EXTENSIONS[extension.name] ?? DEV_DATABASE_EXTENSIONS[extension.from];
|
|
46
|
+
if (name !== undefined)
|
|
47
|
+
loadable.add(name);
|
|
48
|
+
}
|
|
49
|
+
return [...loadable];
|
|
50
|
+
}
|
|
51
|
+
function assertExtensionsLoaded(config, loaded) {
|
|
52
|
+
const missing = declaredDevDatabaseExtensions(config).filter((name) => !loaded.includes(name));
|
|
53
|
+
if (missing.length === 0)
|
|
54
|
+
return;
|
|
55
|
+
throw new Error(`The config now declares the ${missing.join(', ')} extension pack, which the running Dev database ` +
|
|
56
|
+
'did not load: PGlite loads extensions only when it starts. Restart `opensaas dev` to pick it up.');
|
|
57
|
+
}
|
|
58
|
+
async function reconcile(cwd) {
|
|
59
|
+
console.log(chalk.gray('\nReconciling the database with the emitted contract...\n'));
|
|
60
|
+
// Interactive, so a destructive plan reaches the user as Prisma's own
|
|
61
|
+
// consent prompt rather than failing or applying unasked — the loop goes no
|
|
62
|
+
// further until that is answered (ADR-0063).
|
|
63
|
+
const refs = snapshotMigrationRefs(cwd);
|
|
64
|
+
const run = await runPrismaCli(cwd, ['db', 'update'], 'interactive');
|
|
65
|
+
restoreRefsAfterReconcile(cwd, refs);
|
|
66
|
+
if (run.exitCode === 0)
|
|
67
|
+
return true;
|
|
68
|
+
console.error(chalk.red(`\nprisma db update did not apply (exit ${run.exitCode ?? run.signal ?? 'unknown'}).`));
|
|
69
|
+
console.error(chalk.gray('The app was not started; the database is unchanged.\n'));
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
async function consentToStartupPlan(cwd, generation) {
|
|
73
|
+
const refs = snapshotMigrationRefs(cwd);
|
|
74
|
+
const planned = await planDatabaseUpdate(cwd, generation.prismaConfig, { dryRun: true });
|
|
75
|
+
restoreMigrationRefs(cwd, refs);
|
|
76
|
+
if (!planned.ok) {
|
|
77
|
+
console.error(chalk.red('\nprisma db update could not plan against the database:'));
|
|
78
|
+
const output = planned.failure.output.trim();
|
|
79
|
+
if (output.length > 0)
|
|
80
|
+
console.error(chalk.red(output));
|
|
81
|
+
console.error(chalk.gray('The app was not started; the database is unchanged.\n'));
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
84
|
+
if (planned.plan.operations.length === 0)
|
|
85
|
+
return true;
|
|
86
|
+
console.log(chalk.yellow('\nThe database came from the environment and would change, so nothing was applied:\n'));
|
|
87
|
+
for (const line of describePlan(planned.plan))
|
|
88
|
+
console.log(chalk.yellow(line));
|
|
89
|
+
console.log(chalk.yellow(`\nPlan id: ${planId(planned.plan)}`));
|
|
90
|
+
console.log(chalk.yellow('\nThe app was not started. Re-run `opensaas dev --yes` (or set OPENSAAS_DEV_YES=1) to apply this plan.\n'));
|
|
91
|
+
return false;
|
|
92
|
+
}
|
|
93
|
+
/** The dev loop: Dev database, generate, reconcile, app child, config watch (ADR-0063). */
|
|
94
|
+
export async function devCommand(options = {}) {
|
|
7
95
|
const cwd = process.cwd();
|
|
8
96
|
const configPath = path.join(cwd, 'opensaas.config.ts');
|
|
9
97
|
if (!fs.existsSync(configPath)) {
|
|
@@ -12,24 +100,433 @@ export async function devCommand() {
|
|
|
12
100
|
process.exit(1);
|
|
13
101
|
}
|
|
14
102
|
console.log(chalk.bold.cyan('\nOpenSaas Dev Mode\n'));
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
103
|
+
const envSources = loadProjectEnvFile(cwd);
|
|
104
|
+
const connectionVariable = ['DIRECT_DATABASE_URL', 'DATABASE_URL'].find((name) => (process.env[name] ?? '').length > 0);
|
|
105
|
+
const connectionFault = connectionVariable === undefined
|
|
106
|
+
? undefined
|
|
107
|
+
: connectionStringFault(process.env[connectionVariable] ?? '');
|
|
108
|
+
if (connectionVariable !== undefined && connectionFault !== undefined) {
|
|
109
|
+
console.error(chalk.red(`Error: ${connectionVariable} ${connectionFault}. Point it at a Postgres server (postgres://…), or unset it so \`opensaas dev\` starts the dev database.`));
|
|
110
|
+
process.exit(1);
|
|
111
|
+
}
|
|
112
|
+
const connectionFile = connectionVariable === undefined ? undefined : envSources.get(connectionVariable);
|
|
113
|
+
const appCommand = options.appCommand !== undefined && options.appCommand.length > 0
|
|
114
|
+
? options.appCommand
|
|
115
|
+
: DEFAULT_APP_COMMAND;
|
|
116
|
+
const stagingDir = path.join(cwd, STAGING_DIR);
|
|
117
|
+
const previousStateFile = process.env.OPENSAAS_DEV_DATABASE_STATE_FILE;
|
|
118
|
+
let database;
|
|
119
|
+
let watcher;
|
|
120
|
+
let control;
|
|
121
|
+
let app;
|
|
122
|
+
let interrupted = false;
|
|
123
|
+
let loadedExtensions = [];
|
|
124
|
+
/** A staged generation the database does not carry yet. */
|
|
125
|
+
let staged;
|
|
126
|
+
/** The id of the destructive plan printed when `staged` was parked. */
|
|
127
|
+
let parkedPlanId;
|
|
128
|
+
/** One reconcile at a time: a burst of writes must not race itself. */
|
|
129
|
+
let queue = Promise.resolve();
|
|
130
|
+
/**
|
|
131
|
+
* The config source the loop has already generated from, held only while a
|
|
132
|
+
* reconcile that ran to a promote or a deliberate park stands behind it.
|
|
133
|
+
* Everything the loop emits is derived from these bytes, so a save that
|
|
134
|
+
* reproduces them has nothing to reconcile — and promoting a fresh
|
|
135
|
+
* generation over the live bundle on the strength of one would rewrite files
|
|
136
|
+
* the user did not change.
|
|
137
|
+
*
|
|
138
|
+
* Compared as bytes, not as meaning: a reformat or a comment tweak reconciles
|
|
139
|
+
* and promotes in full. That is the safe direction — this must never skip a
|
|
140
|
+
* save that changed something — and comparing generated output instead would
|
|
141
|
+
* make the guard depend on every generator and plugin `afterGenerate` being
|
|
142
|
+
* byte-deterministic, which nothing enforces.
|
|
143
|
+
*
|
|
144
|
+
* A module the config imports is covered the same way, through
|
|
145
|
+
* {@link reconciledModules} below (#1414).
|
|
146
|
+
*/
|
|
147
|
+
let reconciledSource;
|
|
148
|
+
/**
|
|
149
|
+
* The project-local modules the config imported as of the last generation
|
|
150
|
+
* the loop ran from — the paths the watcher adds beside `opensaas.config.ts`
|
|
151
|
+
* itself, so an edit inside a split config lands the same way an edit to
|
|
152
|
+
* the config file does.
|
|
153
|
+
*/
|
|
154
|
+
let watchedModules = [];
|
|
155
|
+
/**
|
|
156
|
+
* The bytes of every module in {@link watchedModules}, as of the same
|
|
157
|
+
* generation {@link reconciledSource} was read for — `null` for one that
|
|
158
|
+
* could not be read (deleted mid-session). Paired with `reconciledSource`
|
|
159
|
+
* to decide whether a watcher event has anything new to reconcile: a save
|
|
160
|
+
* that reproduces both is the race #1260 closed, still closed here because
|
|
161
|
+
* the two are compared as bytes, never as generated output.
|
|
162
|
+
*/
|
|
163
|
+
let reconciledModules = new Map();
|
|
164
|
+
/** Reads each path's current bytes, `null` for one that cannot be read. */
|
|
165
|
+
const snapshotModules = (paths) => {
|
|
166
|
+
const snapshot = new Map();
|
|
167
|
+
for (const modulePath of paths) {
|
|
168
|
+
try {
|
|
169
|
+
snapshot.set(modulePath, fs.readFileSync(modulePath, 'utf-8'));
|
|
170
|
+
}
|
|
171
|
+
catch {
|
|
172
|
+
snapshot.set(modulePath, null);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
return snapshot;
|
|
176
|
+
};
|
|
177
|
+
const moduleSnapshotsEqual = (a, b) => {
|
|
178
|
+
if (a.size !== b.size)
|
|
179
|
+
return false;
|
|
180
|
+
for (const [modulePath, content] of a) {
|
|
181
|
+
if (b.get(modulePath) !== content)
|
|
182
|
+
return false;
|
|
183
|
+
}
|
|
184
|
+
return true;
|
|
185
|
+
};
|
|
186
|
+
/** Reconciles the watcher's set with a fresh `resolvedModules` list. */
|
|
187
|
+
const syncWatchedModules = (nextModules) => {
|
|
188
|
+
const next = new Set(nextModules);
|
|
189
|
+
const stale = watchedModules.filter((modulePath) => !next.has(modulePath));
|
|
190
|
+
const added = nextModules.filter((modulePath) => !watchedModules.includes(modulePath));
|
|
191
|
+
if (stale.length > 0)
|
|
192
|
+
watcher?.unwatch(stale);
|
|
193
|
+
if (added.length > 0)
|
|
194
|
+
watcher?.add(added);
|
|
195
|
+
watchedModules = [...nextModules];
|
|
196
|
+
};
|
|
197
|
+
const stop = async () => {
|
|
198
|
+
await watcher?.close();
|
|
199
|
+
await control?.close();
|
|
200
|
+
await database?.stop();
|
|
201
|
+
};
|
|
202
|
+
const onSignal = (signal) => {
|
|
203
|
+
interrupted = true;
|
|
204
|
+
app?.kill(signal);
|
|
205
|
+
};
|
|
206
|
+
const onSigint = () => onSignal('SIGINT');
|
|
207
|
+
const onSigterm = () => onSignal('SIGTERM');
|
|
208
|
+
// `process.exit` skips `finally`, so this listener is the only shutdown left
|
|
209
|
+
// on that path, and it is confined to what can be done synchronously:
|
|
210
|
+
// orphan neither the app child nor the files pointing other processes at a
|
|
211
|
+
// loop and a database that are about to disappear.
|
|
212
|
+
const onExit = () => {
|
|
213
|
+
app?.kill('SIGTERM');
|
|
214
|
+
control?.clearFile();
|
|
215
|
+
if (database !== undefined)
|
|
216
|
+
fs.rmSync(database.stateFile, { force: true });
|
|
217
|
+
};
|
|
218
|
+
// Registered before the database starts: Ctrl-C at Prisma's consent prompt
|
|
219
|
+
// is the natural way to decline a destructive plan, and default SIGINT
|
|
220
|
+
// handling would kill this process with PGlite still open.
|
|
221
|
+
process.once('SIGINT', onSigint);
|
|
222
|
+
process.once('SIGTERM', onSigterm);
|
|
223
|
+
process.once('exit', onExit);
|
|
224
|
+
/** How the loop reports that it could not get as far as a staged generation. */
|
|
225
|
+
const sayNothingStaged = (say, error) => {
|
|
226
|
+
say(`Generation failed, so nothing was staged: ${error instanceof Error ? error.message : String(error)}`);
|
|
227
|
+
say('The app keeps serving the contract the database already carries.');
|
|
228
|
+
return undefined;
|
|
229
|
+
};
|
|
230
|
+
/**
|
|
231
|
+
* Generates into staging. The app keeps running on the contract it has if
|
|
232
|
+
* this refuses — a half-saved config must not take the loop down with it.
|
|
233
|
+
*/
|
|
234
|
+
const stage = async (say) => {
|
|
235
|
+
// `staged` only ever names files inside `stagingDir`, so it has to be
|
|
236
|
+
// dropped with them — a pointer left behind names the bytes of whatever
|
|
237
|
+
// generation runs next, including one this loop refused.
|
|
238
|
+
staged = undefined;
|
|
239
|
+
parkedPlanId = undefined;
|
|
240
|
+
fs.rmSync(stagingDir, { recursive: true, force: true });
|
|
241
|
+
try {
|
|
242
|
+
return await generateCommand({
|
|
243
|
+
stagingDir,
|
|
244
|
+
checkConfig: (config) => database === undefined ? undefined : assertExtensionsLoaded(config, loadedExtensions),
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
catch (error) {
|
|
248
|
+
return sayNothingStaged(say, error);
|
|
249
|
+
}
|
|
250
|
+
};
|
|
251
|
+
const promote = (generation) => {
|
|
252
|
+
promoteStagedGeneration(generation.paths, generation.livePaths, stagingDir);
|
|
253
|
+
staged = undefined;
|
|
254
|
+
parkedPlanId = undefined;
|
|
255
|
+
};
|
|
256
|
+
const reportFailure = (say, output) => {
|
|
257
|
+
say('prisma db update did not apply. Nothing was promoted.');
|
|
258
|
+
const trimmed = output.trim();
|
|
259
|
+
if (trimmed.length > 0)
|
|
260
|
+
say(trimmed);
|
|
261
|
+
};
|
|
262
|
+
const sessionConsent = options.yes === true || process.env.OPENSAAS_DEV_YES === '1';
|
|
263
|
+
const onConfigChange = async () => {
|
|
264
|
+
const say = (message) => console.log(chalk.gray(message));
|
|
265
|
+
// Inside the refusal this file already has: a config removed or renamed
|
|
266
|
+
// between the watcher event and this read is a config the loop cannot
|
|
267
|
+
// stage from, which is what that refusal says.
|
|
268
|
+
let source;
|
|
269
|
+
try {
|
|
270
|
+
source = fs.readFileSync(configPath, 'utf-8');
|
|
271
|
+
}
|
|
272
|
+
catch (error) {
|
|
273
|
+
sayNothingStaged(say, error);
|
|
274
|
+
return;
|
|
275
|
+
}
|
|
276
|
+
const currentModules = snapshotModules(watchedModules);
|
|
277
|
+
if (source === reconciledSource && moduleSnapshotsEqual(currentModules, reconciledModules)) {
|
|
278
|
+
console.log(chalk.gray('\nConfig saved with no change: nothing to reconcile.'));
|
|
279
|
+
console.log(chalk.gray(staged === undefined || parkedPlanId === undefined
|
|
280
|
+
? NOTHING_TO_RECONCILE_ROUTE
|
|
281
|
+
: `The change staged earlier is still parked. ${parkedRoute(parkedPlanId)}`));
|
|
282
|
+
return;
|
|
283
|
+
}
|
|
284
|
+
console.log(chalk.yellow('\nConfig changed: staging the new contract...\n'));
|
|
285
|
+
// Before staging, not after: generation seeds each declared pack's
|
|
286
|
+
// extension contract space into the project's own `migrations/`, so a
|
|
287
|
+
// snapshot taken afterwards restores the post-seed refs rather than the
|
|
288
|
+
// ones the loop found.
|
|
289
|
+
const refs = snapshotMigrationRefs(cwd);
|
|
290
|
+
const generation = await stage(say);
|
|
291
|
+
if (generation === undefined) {
|
|
292
|
+
restoreMigrationRefs(cwd, refs);
|
|
293
|
+
return;
|
|
294
|
+
}
|
|
295
|
+
reconciledSource = source;
|
|
296
|
+
const planned = await planDatabaseUpdate(cwd, generation.prismaConfig, { dryRun: true });
|
|
297
|
+
if (!planned.ok) {
|
|
298
|
+
reconciledSource = undefined;
|
|
299
|
+
restoreMigrationRefs(cwd, refs);
|
|
300
|
+
reportFailure((message) => console.error(chalk.red(message)), planned.failure.output);
|
|
301
|
+
return;
|
|
302
|
+
}
|
|
303
|
+
const unconsentedEnvChange = database === undefined && !sessionConsent && planned.plan.operations.length > 0;
|
|
304
|
+
if (planned.plan.destructive || unconsentedEnvChange) {
|
|
305
|
+
restoreMigrationRefs(cwd, refs);
|
|
306
|
+
staged = generation;
|
|
307
|
+
const id = planId(planned.plan);
|
|
308
|
+
parkedPlanId = id;
|
|
309
|
+
// Only now, not right after staging: a rejected generation must never
|
|
310
|
+
// have already moved the live watch onto its module graph — the bundle
|
|
311
|
+
// and the database are still the previous generation's until this one
|
|
312
|
+
// is at least parked.
|
|
313
|
+
syncWatchedModules(generation.resolvedModules);
|
|
314
|
+
reconciledModules = snapshotModules(watchedModules);
|
|
315
|
+
console.log(chalk.yellow(planned.plan.destructive
|
|
316
|
+
? '\nThis change would destroy data, so it was not applied:\n'
|
|
317
|
+
: '\nThe database came from the environment and would change, so nothing was applied:\n'));
|
|
318
|
+
for (const line of describePlan(planned.plan))
|
|
319
|
+
console.log(chalk.yellow(line));
|
|
320
|
+
console.log(chalk.yellow(`\nPlan id: ${id}`));
|
|
321
|
+
console.log(chalk.yellow(`\nThe app keeps serving the previous schema. ${parkedRoute(id)}`));
|
|
322
|
+
return;
|
|
323
|
+
}
|
|
324
|
+
const applied = await planDatabaseUpdate(cwd, generation.prismaConfig);
|
|
325
|
+
if (!applied.ok) {
|
|
326
|
+
reconciledSource = undefined;
|
|
327
|
+
restoreMigrationRefs(cwd, refs);
|
|
328
|
+
reportFailure((message) => console.error(chalk.red(message)), applied.failure.output);
|
|
329
|
+
return;
|
|
330
|
+
}
|
|
331
|
+
restoreRefsAfterReconcile(cwd, refs);
|
|
332
|
+
promote(generation);
|
|
333
|
+
syncWatchedModules(generation.resolvedModules);
|
|
334
|
+
reconciledModules = snapshotModules(watchedModules);
|
|
335
|
+
console.log(chalk.green('\nDatabase updated and the new contract promoted.\n'));
|
|
336
|
+
};
|
|
337
|
+
const onDatabaseUpdateRequest = async (requestedPlanId, reply) => {
|
|
338
|
+
const say = (message) => {
|
|
339
|
+
console.log(chalk.gray(message));
|
|
340
|
+
reply.log(message);
|
|
341
|
+
};
|
|
342
|
+
const refs = snapshotMigrationRefs(cwd);
|
|
343
|
+
const generation = staged ?? (await stage(say));
|
|
344
|
+
if (generation === undefined) {
|
|
345
|
+
restoreMigrationRefs(cwd, refs);
|
|
346
|
+
reply.finish(false, 'Nothing was staged: generation refused the current config.');
|
|
347
|
+
return;
|
|
348
|
+
}
|
|
349
|
+
const planned = await planDatabaseUpdate(cwd, generation.prismaConfig, { dryRun: true });
|
|
350
|
+
if (!planned.ok) {
|
|
351
|
+
restoreMigrationRefs(cwd, refs);
|
|
352
|
+
reportFailure(say, planned.failure.output);
|
|
353
|
+
reply.finish(false, 'The database is unchanged and nothing was promoted.');
|
|
354
|
+
return;
|
|
355
|
+
}
|
|
356
|
+
if (planned.plan.destructive) {
|
|
357
|
+
const id = planId(planned.plan);
|
|
358
|
+
if (requestedPlanId !== id) {
|
|
359
|
+
restoreMigrationRefs(cwd, refs);
|
|
360
|
+
staged = generation;
|
|
361
|
+
parkedPlanId = id;
|
|
362
|
+
say('This change would destroy data, so it was not applied:');
|
|
363
|
+
for (const line of describePlan(planned.plan))
|
|
364
|
+
say(line);
|
|
365
|
+
say(`Plan id: ${id}`);
|
|
366
|
+
reply.finish(false, requestedPlanId === undefined
|
|
367
|
+
? `Destructive changes need the plan's id. ${parkedRoute(id).trim()}`
|
|
368
|
+
: `Plan ${requestedPlanId} is not the current plan. ${parkedRoute(id).trim()}`);
|
|
369
|
+
return;
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
const applied = await planDatabaseUpdate(cwd, generation.prismaConfig, {
|
|
373
|
+
consent: planned.plan,
|
|
374
|
+
});
|
|
375
|
+
if (!applied.ok) {
|
|
376
|
+
restoreMigrationRefs(cwd, refs);
|
|
377
|
+
reportFailure(say, applied.failure.output);
|
|
378
|
+
reply.finish(false, 'The database is unchanged and nothing was promoted.');
|
|
379
|
+
return;
|
|
380
|
+
}
|
|
381
|
+
restoreRefsAfterReconcile(cwd, refs);
|
|
382
|
+
promote(generation);
|
|
383
|
+
syncWatchedModules(generation.resolvedModules);
|
|
384
|
+
reconciledModules = snapshotModules(watchedModules);
|
|
385
|
+
// Best-effort: this request did not read the config itself, so this is
|
|
386
|
+
// the freshest bytes available for what the loop just generated from. A
|
|
387
|
+
// config deleted out from under a running loop is caught the same way
|
|
388
|
+
// the watcher's own read of it already is — by leaving nothing reconciled.
|
|
389
|
+
try {
|
|
390
|
+
reconciledSource = fs.readFileSync(configPath, 'utf-8');
|
|
391
|
+
}
|
|
392
|
+
catch {
|
|
393
|
+
reconciledSource = undefined;
|
|
394
|
+
}
|
|
395
|
+
for (const line of describePlan(applied.plan))
|
|
396
|
+
say(line);
|
|
397
|
+
if (applied.plan.destructive) {
|
|
398
|
+
say('Restarting the app: a client cached across a reload would query the dropped column.');
|
|
399
|
+
app?.restart();
|
|
400
|
+
}
|
|
401
|
+
reply.finish(true, 'Applied, promoted.');
|
|
402
|
+
};
|
|
403
|
+
try {
|
|
404
|
+
if (findDatabaseConnection({ cwd })?.provenance === 'env') {
|
|
405
|
+
if (connectionVariable !== undefined &&
|
|
406
|
+
connectionFile !== undefined &&
|
|
407
|
+
connectionFile !== '.env') {
|
|
408
|
+
console.log(chalk.yellow(`⚠️ ${connectionVariable} from ${connectionFile}: using it — no dev database. Schema changes reach that database only with --yes; otherwise they are parked.\n`));
|
|
409
|
+
}
|
|
410
|
+
else {
|
|
411
|
+
console.log(chalk.gray('DATABASE_URL is set: using it, and starting no dev database. Schema changes reach it only with --yes; otherwise they are parked.\n'));
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
else {
|
|
415
|
+
const { config, aliasWarnings } = await loadOpenSaasConfig(cwd, configPath);
|
|
416
|
+
for (const warning of aliasWarnings)
|
|
417
|
+
console.log(chalk.yellow(`⚠️ ${warning}`));
|
|
418
|
+
// PGlite's own `mkdir` of the data directory is not recursive, so the
|
|
419
|
+
// Generated bundle directory has to exist before it runs.
|
|
420
|
+
const dataDir = path.join(cwd, DEV_DATABASE_DIR);
|
|
421
|
+
fs.mkdirSync(path.dirname(dataDir), { recursive: true });
|
|
422
|
+
loadedExtensions = declaredDevDatabaseExtensions(config);
|
|
423
|
+
try {
|
|
424
|
+
database = await startDevDatabase({
|
|
425
|
+
cwd,
|
|
426
|
+
dataDir,
|
|
427
|
+
extensions: loadedExtensions,
|
|
428
|
+
});
|
|
429
|
+
}
|
|
430
|
+
catch (error) {
|
|
431
|
+
if (!(error instanceof DevDatabaseInUseError))
|
|
432
|
+
throw error;
|
|
433
|
+
console.error(chalk.red(`Another \`opensaas dev\` already holds the dev database (${DEV_DATABASE_DIR}). ` +
|
|
434
|
+
'Stop that process before starting a new one.'));
|
|
435
|
+
process.exitCode = 1;
|
|
436
|
+
return;
|
|
437
|
+
}
|
|
438
|
+
process.env.OPENSAAS_DEV_DATABASE_STATE_FILE = database.stateFile;
|
|
439
|
+
console.log(chalk.green(`Dev database listening on ${database.url}\n`));
|
|
440
|
+
}
|
|
441
|
+
fs.rmSync(stagingDir, { recursive: true, force: true });
|
|
442
|
+
// Read before generating, so an edit landing during startup leaves bytes
|
|
443
|
+
// the watcher will not recognise as already reconciled.
|
|
444
|
+
reconciledSource = fs.readFileSync(configPath, 'utf-8');
|
|
445
|
+
let bootGeneration;
|
|
446
|
+
try {
|
|
447
|
+
bootGeneration = await generateCommand({ showNextSteps: false });
|
|
448
|
+
}
|
|
449
|
+
catch (error) {
|
|
450
|
+
if (!(error instanceof GenerationFailedError))
|
|
451
|
+
throw error;
|
|
452
|
+
process.exitCode = 1;
|
|
453
|
+
return;
|
|
454
|
+
}
|
|
455
|
+
// Read as soon as generation names them, same reasoning as reconciledSource
|
|
456
|
+
// above: `reconcile()` below is interactive and can sit at a destructive
|
|
457
|
+
// plan's consent prompt indefinitely, and an edit to a watched module made
|
|
458
|
+
// while it waits must not be mistaken for one already reconciled.
|
|
459
|
+
watchedModules = bootGeneration.resolvedModules;
|
|
460
|
+
reconciledModules = snapshotModules(watchedModules);
|
|
461
|
+
if (database === undefined &&
|
|
462
|
+
!sessionConsent &&
|
|
463
|
+
!(await consentToStartupPlan(cwd, bootGeneration))) {
|
|
464
|
+
process.exitCode = 1;
|
|
465
|
+
return;
|
|
466
|
+
}
|
|
467
|
+
if (interrupted) {
|
|
468
|
+
process.exitCode = 1;
|
|
469
|
+
return;
|
|
470
|
+
}
|
|
471
|
+
if (!(await reconcile(cwd)) || interrupted) {
|
|
472
|
+
process.exitCode = 1;
|
|
473
|
+
return;
|
|
474
|
+
}
|
|
475
|
+
// Armed only now: `queue` serialises reconciles against each other, not
|
|
476
|
+
// against this startup generate and reconcile, so a save landing earlier
|
|
477
|
+
// would run a second `db update` against the same database concurrently.
|
|
478
|
+
watcher = chokidar.watch([configPath, ...watchedModules], {
|
|
479
|
+
persistent: true,
|
|
480
|
+
ignoreInitial: true,
|
|
481
|
+
awaitWriteFinish: { stabilityThreshold: CONFIG_WRITE_SETTLE_MS, pollInterval: 50 },
|
|
482
|
+
});
|
|
483
|
+
watcher.on('change', () => {
|
|
484
|
+
queue = queue.then(onConfigChange).catch((error) => {
|
|
485
|
+
// Whatever threw, it was not a promote and not a park, so the bytes it
|
|
486
|
+
// was working from have not reached the database or the live bundle.
|
|
487
|
+
reconciledSource = undefined;
|
|
488
|
+
reconciledModules = new Map();
|
|
489
|
+
console.error(chalk.red('\nStaged reconcile failed:'), error);
|
|
490
|
+
});
|
|
491
|
+
});
|
|
492
|
+
watcher.on('error', (error) => {
|
|
493
|
+
console.error(chalk.red('\nWatcher error:'), error);
|
|
494
|
+
});
|
|
495
|
+
control = await startControlChannel(cwd, async (request, reply) => {
|
|
496
|
+
await new Promise((resolve) => {
|
|
497
|
+
queue = queue
|
|
498
|
+
.then(() => onDatabaseUpdateRequest(request.plan, reply))
|
|
499
|
+
.catch((error) => {
|
|
500
|
+
reply.finish(false, error instanceof Error ? error.message : String(error));
|
|
501
|
+
})
|
|
502
|
+
.finally(resolve);
|
|
503
|
+
});
|
|
504
|
+
});
|
|
505
|
+
console.log(chalk.gray(`Starting the app: ${appCommand.join(' ')}\n`));
|
|
506
|
+
console.log(chalk.gray(watchedModules.length === 0
|
|
507
|
+
? 'Watching opensaas.config.ts. Press Ctrl+C to stop.\n'
|
|
508
|
+
: `Watching opensaas.config.ts and ${watchedModules.length} imported module(s). ` +
|
|
509
|
+
'Press Ctrl+C to stop.\n'));
|
|
510
|
+
app = createAppRunner({ cwd, command: appCommand, devDatabase: database !== undefined });
|
|
511
|
+
process.exitCode = await app.run();
|
|
512
|
+
}
|
|
513
|
+
finally {
|
|
514
|
+
process.off('SIGINT', onSigint);
|
|
515
|
+
process.off('SIGTERM', onSigterm);
|
|
516
|
+
process.off('exit', onExit);
|
|
517
|
+
if (app !== undefined)
|
|
518
|
+
console.log(chalk.yellow('\nStopping dev mode...'));
|
|
519
|
+
try {
|
|
520
|
+
await stop();
|
|
521
|
+
}
|
|
522
|
+
finally {
|
|
523
|
+
if (database !== undefined) {
|
|
524
|
+
if (previousStateFile === undefined)
|
|
525
|
+
delete process.env.OPENSAAS_DEV_DATABASE_STATE_FILE;
|
|
526
|
+
else
|
|
527
|
+
process.env.OPENSAAS_DEV_DATABASE_STATE_FILE = previousStateFile;
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
}
|
|
34
531
|
}
|
|
35
532
|
//# sourceMappingURL=dev.js.map
|
package/dist/commands/dev.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dev.js","sourceRoot":"","sources":["../../src/commands/dev.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,MAAM,CAAA;AAC5B,OAAO,KAAK,EAAE,MAAM,IAAI,CAAA;AACxB,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,QAAQ,MAAM,UAAU,CAAA;AAC/B,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAE/C,MAAM,CAAC,KAAK,UAAU,UAAU;IAC9B,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,EAAE,CAAA;IACzB,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,oBAAoB,CAAC,CAAA;IAEvD,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;QAC/B,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,0DAA0D,CAAC,CAAC,CAAA;QACpF,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,mDAAmD,CAAC,CAAC,CAAA;QAC9E,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACjB,CAAC;IAED,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAC,CAAA;IACrD,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,iDAAiD,CAAC,CAAC,CAAA;IAE1E,MAAM,eAAe,EAAE,CAAA;IAEvB,MAAM,OAAO,GAAG,QAAQ,CAAC,KAAK,CAAC,UAA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AAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;QAC3B,IAAI,GAAG,KAAK,SAAS;YAAE,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,wBAAwB,CAAC,CAAC,CAAA;QAC1E,IAAI,CAAC;YACH,MAAM,IAAI,EAAE,CAAA;QACd,CAAC;gBAAS,CAAC;YACT,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;gBAC3B,IAAI,iBAAiB,KAAK,SAAS;oBAAE,OAAO,OAAO,CAAC,GAAG,CAAC,gCAAgC,CAAA;;oBACnF,OAAO,CAAC,GAAG,CAAC,gCAAgC,GAAG,iBAAiB,CAAA;YACvE,CAAC;QACH,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import pg from 'pg';
|
|
2
|
+
import type { LiveSchema } from '../migration/fk-renames.js';
|
|
3
|
+
export interface FkRenamesOptions {
|
|
4
|
+
apply?: boolean;
|
|
5
|
+
out?: string;
|
|
6
|
+
}
|
|
7
|
+
export declare function introspect(client: pg.Client): Promise<LiveSchema>;
|
|
8
|
+
/**
|
|
9
|
+
* `opensaas migrate fk-renames` — emits the ADR-0069 `<field>` → `<field>Id`
|
|
10
|
+
* column renames against the live database. Without `--apply` it prints the
|
|
11
|
+
* SQL (or writes it to `--out`); with `--apply` it runs it in one transaction.
|
|
12
|
+
*/
|
|
13
|
+
export declare function fkRenamesCommand(options?: FkRenamesOptions): Promise<void>;
|
|
14
|
+
//# sourceMappingURL=fk-renames.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fk-renames.d.ts","sourceRoot":"","sources":["../../src/commands/fk-renames.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,IAAI,CAAA;AAInB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAA;AAE5D,MAAM,WAAW,gBAAgB;IAC/B,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,GAAG,CAAC,EAAE,MAAM,CAAA;CACb;AAQD,wBAAsB,UAAU,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAsBvE;AAED;;;;GAIG;AACH,wBAAsB,gBAAgB,CAAC,OAAO,GAAE,gBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC,CA2DpF"}
|