@postxl/cli 1.10.1 → 1.10.2
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/dist/generate.command.js +53 -8
- package/package.json +3 -3
package/dist/generate.command.js
CHANGED
|
@@ -156,9 +156,24 @@ This reads the schema from ${(0, utils_1.yellow)('schema.json')} and runs the ge
|
|
|
156
156
|
showEjectedStats: options.ejected ?? false,
|
|
157
157
|
showEjectedDiff: options.diff ?? false,
|
|
158
158
|
});
|
|
159
|
+
// A 2-way merge conflicts far more eagerly than diff3 does. Without
|
|
160
|
+
// this note a conflict list produced without a base reads as "these
|
|
161
|
+
// files cannot merge", when a run with a base may merge them cleanly.
|
|
162
|
+
if (!baseVfs && hasMergeConflicts(result)) {
|
|
163
|
+
console.log((0, utils_1.yellow)('Note: these conflicts were computed with a 2-way merge (no three-way base). Re-run without `--no-three-way`, after committing a generation that writes `.postxl/base-snapshot.json`, before concluding the files cannot be merged.'));
|
|
164
|
+
}
|
|
165
|
+
// The summary already says a human has to look at this run; the exit
|
|
166
|
+
// code has to say the same thing, or `pxl generate && pnpm build`
|
|
167
|
+
// carries on over output the generator itself flagged.
|
|
168
|
+
if (needsAttention(result)) {
|
|
169
|
+
process.exitCode = 1;
|
|
170
|
+
}
|
|
159
171
|
// Persist the current schema as the base for the next generation's
|
|
160
|
-
// three-way merge. Skipped on dry runs (which must not touch disk)
|
|
161
|
-
|
|
172
|
+
// three-way merge. Skipped on dry runs (which must not touch disk),
|
|
173
|
+
// and on an aborted sync - nothing was written, so advancing the
|
|
174
|
+
// snapshot would claim a generation that never happened as the next
|
|
175
|
+
// run's ancestor.
|
|
176
|
+
if (!options.dryRun && result.success) {
|
|
162
177
|
await (0, base_snapshot_1.writeBaseSnapshot)(targetPath, {
|
|
163
178
|
schemaSnapshot: rawSchema,
|
|
164
179
|
generatorVersion: (0, base_snapshot_1.resolveGeneratorVersion)(),
|
|
@@ -173,6 +188,30 @@ This reads the schema from ${(0, utils_1.yellow)('schema.json')} and runs the ge
|
|
|
173
188
|
}));
|
|
174
189
|
});
|
|
175
190
|
}
|
|
191
|
+
/**
|
|
192
|
+
* True when the run left something a human still has to act on.
|
|
193
|
+
*
|
|
194
|
+
* `success: false` means generation was aborted outright (unresolved markers
|
|
195
|
+
* were already on disk); an unverified ancestor means an incoming generator
|
|
196
|
+
* change may not have been applied; an unparseable merge means reconciliation
|
|
197
|
+
* broke a file outright. None of those may be built straight through.
|
|
198
|
+
*
|
|
199
|
+
* Conflict markers on their own keep their existing exit 0. That predates this
|
|
200
|
+
* change and flipping it would break every pipeline that tolerates conflicts, so
|
|
201
|
+
* it is a separate call to make.
|
|
202
|
+
*/
|
|
203
|
+
function needsAttention(result) {
|
|
204
|
+
if (!result.success) {
|
|
205
|
+
return true;
|
|
206
|
+
}
|
|
207
|
+
return Object.values(result.files).some((file) => file.action.type === 'MergeConflict' && (file.action.hasUnverifiedBase || file.action.mergeIsUnparseable));
|
|
208
|
+
}
|
|
209
|
+
function hasMergeConflicts(result) {
|
|
210
|
+
// The `!success` abort reports markers that were already on disk before this
|
|
211
|
+
// run, not conflicts this run computed — the note would be wrong there.
|
|
212
|
+
return (result.success &&
|
|
213
|
+
Object.values(result.files).some((file) => file.action.type === 'MergeConflict' && file.action.hasConflicts));
|
|
214
|
+
}
|
|
176
215
|
/**
|
|
177
216
|
* Reconstructs the previous generation (`B = G(schema_old)`) to serve as the
|
|
178
217
|
* common ancestor for sync's three-way merge.
|
|
@@ -183,9 +222,10 @@ This reads the schema from ${(0, utils_1.yellow)('schema.json')} and runs the ge
|
|
|
183
222
|
* lint/format transform as the fresh output, so formatting churn cannot
|
|
184
223
|
* manufacture false conflicts.
|
|
185
224
|
*
|
|
186
|
-
*
|
|
187
|
-
*
|
|
188
|
-
*
|
|
225
|
+
* The base is narrowed by the same `-m`/`-p` filters as the fresh output, so
|
|
226
|
+
* selective and pattern runs compare like with like (and pay only for what they
|
|
227
|
+
* regenerate). Dry runs reconstruct it too - a preview that reported conflicts
|
|
228
|
+
* the real run would merge away is worse than a slow preview. Returns
|
|
189
229
|
* `undefined` whenever a base cannot be reconstructed (no snapshot, unparseable
|
|
190
230
|
* snapshot, or a generation error), in which case sync uses the 2-way path.
|
|
191
231
|
*/
|
|
@@ -193,7 +233,7 @@ async function maybeReconstructBaseVfs(params) {
|
|
|
193
233
|
const { manager, targetPath, options, targetModelNames } = params;
|
|
194
234
|
// `--no-three-way` opts out of base reconstruction entirely (fast iteration);
|
|
195
235
|
// ejected files then fall back to the 2-way merge.
|
|
196
|
-
if (options.threeWay === false
|
|
236
|
+
if (options.threeWay === false) {
|
|
197
237
|
return undefined;
|
|
198
238
|
}
|
|
199
239
|
const snapshot = await (0, base_snapshot_1.readBaseSnapshot)(targetPath);
|
|
@@ -215,10 +255,15 @@ async function maybeReconstructBaseVfs(params) {
|
|
|
215
255
|
if (snapshot.generatorVersion !== 'unknown' &&
|
|
216
256
|
currentGeneratorVersion !== 'unknown' &&
|
|
217
257
|
snapshot.generatorVersion !== currentGeneratorVersion) {
|
|
218
|
-
console.log((0, utils_1.yellow)(`Note: @postxl/generators changed since the last generation (${snapshot.generatorVersion} → ${currentGeneratorVersion})
|
|
258
|
+
console.log((0, utils_1.yellow)(`Note: @postxl/generators changed since the last generation (${snapshot.generatorVersion} → ${currentGeneratorVersion}). ` +
|
|
259
|
+
`Any ejected file whose generated output changed with it has no reproducible ancestor and falls back to a 2-way merge.`));
|
|
219
260
|
}
|
|
220
261
|
try {
|
|
221
|
-
const baseContext = (0, generator_1.prepareBaseContext)(parsed.data, {
|
|
262
|
+
const baseContext = (0, generator_1.prepareBaseContext)(parsed.data, {
|
|
263
|
+
...options,
|
|
264
|
+
...(options.pattern ? { filePattern: options.pattern } : {}),
|
|
265
|
+
...(targetModelNames ? { targetModelNames } : {}),
|
|
266
|
+
});
|
|
222
267
|
const baseGenerated = await manager.generate(baseContext);
|
|
223
268
|
const baseG = await new generator_1.Generator(baseGenerated).generate((g) => g);
|
|
224
269
|
if (!options.skipTransform) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@postxl/cli",
|
|
3
|
-
"version": "1.10.
|
|
3
|
+
"version": "1.10.2",
|
|
4
4
|
"description": "Command-line interface for PostXL code generation framework",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -45,8 +45,8 @@
|
|
|
45
45
|
"dotenv": "17.4.2",
|
|
46
46
|
"ts-morph": "26.0.0",
|
|
47
47
|
"zod-validation-error": "5.0.0",
|
|
48
|
-
"@postxl/generator": "^1.7.
|
|
49
|
-
"@postxl/generators": "^3.1.
|
|
48
|
+
"@postxl/generator": "^1.7.2",
|
|
49
|
+
"@postxl/generators": "^3.1.1",
|
|
50
50
|
"@postxl/schema": "^2.2.0",
|
|
51
51
|
"@postxl/utils": "^1.4.2"
|
|
52
52
|
},
|