@postxl/cli 1.10.3 → 1.11.0
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
CHANGED
|
@@ -57,14 +57,19 @@ function register(program) {
|
|
|
57
57
|
.description(`Generates the project.
|
|
58
58
|
|
|
59
59
|
This reads the schema from ${(0, utils_1.yellow)('schema.json')} and runs the generators specified in ${(0, utils_1.yellow)('generate.ts')}.`)
|
|
60
|
-
.option('-d, --diff', 'shows diff between
|
|
61
|
-
.option('
|
|
62
|
-
|
|
60
|
+
.option('-d, --diff', 'shows diff between each modified file and its generated content')
|
|
61
|
+
.option('--modified', 'lists files edited on disk (what `pxl status` calls modified) and any ejected ones')
|
|
62
|
+
// `-e, --ejected` listed files the developer had edited, which `pxl status`
|
|
63
|
+
// calls `modified` -- while `pxl status -e` filters the actual `"ejected"`
|
|
64
|
+
// sentinel. Same flag, two commands, opposite meanings. Kept as a working
|
|
65
|
+
// alias so existing scripts do not break.
|
|
66
|
+
.option('-e, --ejected', 'deprecated alias for --modified')
|
|
67
|
+
.option('-f, --force', 'overwrites modified files (ejected files are still skipped -- force respects the sentinel)')
|
|
63
68
|
.option('-i, --ignore-errors', 'ignores errors during generation')
|
|
64
69
|
.option('--dry-run', 'compute the changes that would be made without writing or updating the lockfile')
|
|
65
70
|
.option('-m, --model <names...>', 'regenerate only for the given models (accepts multiple, e.g. -m Country City)')
|
|
66
71
|
.option('-n, --no-fix', 'does not attempt to fix linting errors')
|
|
67
|
-
.option('--no-three-way', 'skips reconstructing the previous generation for three-way merges (faster;
|
|
72
|
+
.option('--no-three-way', 'skips reconstructing the previous generation for three-way merges (faster; modified files fall back to the 2-way merge)')
|
|
68
73
|
.option('-p, --pattern <glob>', 'filters files by glob pattern (e.g., "**/*.ts" or "backend/libs/**")')
|
|
69
74
|
.option('-q, --quiet', 'does not print errors')
|
|
70
75
|
.option('-s, --skip-lint', 'skips linting')
|
|
@@ -94,7 +99,7 @@ This reads the schema from ${(0, utils_1.yellow)('schema.json')} and runs the ge
|
|
|
94
99
|
const verb = options.dryRun ? 'Would generate' : 'Generating';
|
|
95
100
|
console.log(`${verb} project from ${projectPath} to ${targetPath}`);
|
|
96
101
|
if (options.force) {
|
|
97
|
-
console.log((0, utils_1.yellow)('Warning: Forcing generation of
|
|
102
|
+
console.log((0, utils_1.yellow)('Warning: Forcing generation of modified files!'));
|
|
98
103
|
}
|
|
99
104
|
if (options.dryRun) {
|
|
100
105
|
console.log((0, utils_1.yellow)('Dry run: no files will be written and the lockfile will not be updated.'));
|
|
@@ -153,8 +158,8 @@ This reads the schema from ${(0, utils_1.yellow)('schema.json')} and runs the ge
|
|
|
153
158
|
...(baseVfs ? { baseVfs } : {}),
|
|
154
159
|
});
|
|
155
160
|
(0, generator_1.logSyncResult)(result, {
|
|
156
|
-
|
|
157
|
-
|
|
161
|
+
showModifiedStats: options.modified ?? options.ejected ?? false,
|
|
162
|
+
showModifiedDiff: options.diff ?? false,
|
|
158
163
|
});
|
|
159
164
|
// A 2-way merge conflicts far more eagerly than diff3 does. Without
|
|
160
165
|
// this note a conflict list produced without a base reads as "these
|
|
@@ -232,7 +237,7 @@ function hasMergeConflicts(result) {
|
|
|
232
237
|
async function maybeReconstructBaseVfs(params) {
|
|
233
238
|
const { manager, targetPath, options, targetModelNames } = params;
|
|
234
239
|
// `--no-three-way` opts out of base reconstruction entirely (fast iteration);
|
|
235
|
-
//
|
|
240
|
+
// modified files then fall back to the 2-way merge.
|
|
236
241
|
if (options.threeWay === false) {
|
|
237
242
|
return undefined;
|
|
238
243
|
}
|
|
@@ -242,7 +247,7 @@ async function maybeReconstructBaseVfs(params) {
|
|
|
242
247
|
}
|
|
243
248
|
// Reported before every check below, all of which decide whether reconstructing a base is worth
|
|
244
249
|
// the second generation - a question independent of whether the generator changed. It used to sit
|
|
245
|
-
// after them, so the clean-project skip below swallowed it: on a tree with nothing
|
|
250
|
+
// after them, so the clean-project skip below swallowed it: on a tree with nothing modified, a
|
|
246
251
|
// generator change rewrote every tracked file and said nothing, which is the one run where this
|
|
247
252
|
// note is the only warning there is.
|
|
248
253
|
const driftNote = (0, base_snapshot_1.generatorDriftNote)({
|
|
@@ -253,7 +258,7 @@ async function maybeReconstructBaseVfs(params) {
|
|
|
253
258
|
console.log((0, utils_1.yellow)(driftNote));
|
|
254
259
|
}
|
|
255
260
|
// The base is only ever consulted to merge files that were edited on disk.
|
|
256
|
-
// When nothing is
|
|
261
|
+
// When nothing is modified, reconstructing it (a second full generation +
|
|
257
262
|
// lint + format) would be wasted work, so skip it — the common, clean-project
|
|
258
263
|
// case pays nothing.
|
|
259
264
|
if (!(await (0, base_snapshot_1.hasLocallyEditedFiles)(targetPath))) {
|
|
@@ -8,13 +8,13 @@ export declare function writeBaseSnapshot(targetPath: string, snapshot: BaseSnap
|
|
|
8
8
|
/**
|
|
9
9
|
* Returns true if any tracked generated file has been edited on disk (its content
|
|
10
10
|
* no longer matches its lock-file checksum) — i.e. the project has at least one
|
|
11
|
-
* "
|
|
11
|
+
* "modified" file that a regeneration could need to merge.
|
|
12
12
|
*
|
|
13
13
|
* The three-way merge base is only ever consulted for such files (the
|
|
14
14
|
* `MergeConflict` sync state requires a disk file that diverges from both the
|
|
15
15
|
* lock and the fresh output). When nothing is edited on disk, reconstructing the
|
|
16
16
|
* base would be pure wasted work, so the caller can skip the second generation
|
|
17
|
-
* pass entirely.
|
|
17
|
+
* pass entirely. Ejected entries (the `"ejected"` sentinel) are
|
|
18
18
|
* skipped because sync never merges them.
|
|
19
19
|
*/
|
|
20
20
|
export declare function hasLocallyEditedFiles(targetPath: string): Promise<boolean>;
|
|
@@ -92,13 +92,13 @@ async function writeBaseSnapshot(targetPath, snapshot) {
|
|
|
92
92
|
/**
|
|
93
93
|
* Returns true if any tracked generated file has been edited on disk (its content
|
|
94
94
|
* no longer matches its lock-file checksum) — i.e. the project has at least one
|
|
95
|
-
* "
|
|
95
|
+
* "modified" file that a regeneration could need to merge.
|
|
96
96
|
*
|
|
97
97
|
* The three-way merge base is only ever consulted for such files (the
|
|
98
98
|
* `MergeConflict` sync state requires a disk file that diverges from both the
|
|
99
99
|
* lock and the fresh output). When nothing is edited on disk, reconstructing the
|
|
100
100
|
* base would be pure wasted work, so the caller can skip the second generation
|
|
101
|
-
* pass entirely.
|
|
101
|
+
* pass entirely. Ejected entries (the `"ejected"` sentinel) are
|
|
102
102
|
* skipped because sync never merges them.
|
|
103
103
|
*/
|
|
104
104
|
async function hasLocallyEditedFiles(targetPath) {
|
|
@@ -148,7 +148,7 @@ function generatorDriftNote(params) {
|
|
|
148
148
|
return undefined;
|
|
149
149
|
}
|
|
150
150
|
return (`Note: @postxl/generators changed since the last generation (${snapshotVersion} → ${currentVersion}). ` +
|
|
151
|
-
`Files it generates differently will be rewritten; any
|
|
151
|
+
`Files it generates differently will be rewritten; any modified file whose output changed with it ` +
|
|
152
152
|
`has no reproducible ancestor and falls back to a 2-way merge.`);
|
|
153
153
|
}
|
|
154
154
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@postxl/cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.11.0",
|
|
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.
|
|
49
|
-
"@postxl/generators": "^3.2.
|
|
48
|
+
"@postxl/generator": "^1.8.0",
|
|
49
|
+
"@postxl/generators": "^3.2.1",
|
|
50
50
|
"@postxl/schema": "^2.3.0",
|
|
51
51
|
"@postxl/utils": "^1.4.2"
|
|
52
52
|
},
|