@postxl/cli 1.10.2 → 1.10.3

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.
@@ -98,6 +98,7 @@ const generators = [
98
98
  'frontendFormsGenerator',
99
99
  'mockDataGenerator',
100
100
  'seedDataGenerator',
101
+ { imports: 'configureSkailifyGenerator', code: 'configureSkailifyGenerator()' },
101
102
  'typesGenerator',
102
103
  ];
103
104
  /**
@@ -176,7 +176,7 @@ This reads the schema from ${(0, utils_1.yellow)('schema.json')} and runs the ge
176
176
  if (!options.dryRun && result.success) {
177
177
  await (0, base_snapshot_1.writeBaseSnapshot)(targetPath, {
178
178
  schemaSnapshot: rawSchema,
179
- generatorVersion: (0, base_snapshot_1.resolveGeneratorVersion)(),
179
+ generatorVersion: (0, base_snapshot_1.resolveGeneratorVersion)(targetPath),
180
180
  });
181
181
  }
182
182
  return g;
@@ -240,6 +240,18 @@ async function maybeReconstructBaseVfs(params) {
240
240
  if (!snapshot) {
241
241
  return undefined;
242
242
  }
243
+ // Reported before every check below, all of which decide whether reconstructing a base is worth
244
+ // 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 ejected, a
246
+ // generator change rewrote every tracked file and said nothing, which is the one run where this
247
+ // note is the only warning there is.
248
+ const driftNote = (0, base_snapshot_1.generatorDriftNote)({
249
+ snapshotVersion: snapshot.generatorVersion,
250
+ currentVersion: (0, base_snapshot_1.resolveGeneratorVersion)(targetPath),
251
+ });
252
+ if (driftNote) {
253
+ console.log((0, utils_1.yellow)(driftNote));
254
+ }
243
255
  // The base is only ever consulted to merge files that were edited on disk.
244
256
  // When nothing is ejected, reconstructing it (a second full generation +
245
257
  // lint + format) would be wasted work, so skip it — the common, clean-project
@@ -251,13 +263,6 @@ async function maybeReconstructBaseVfs(params) {
251
263
  if (!parsed.success) {
252
264
  return undefined;
253
265
  }
254
- const currentGeneratorVersion = (0, base_snapshot_1.resolveGeneratorVersion)();
255
- if (snapshot.generatorVersion !== 'unknown' &&
256
- currentGeneratorVersion !== 'unknown' &&
257
- 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.`));
260
- }
261
266
  try {
262
267
  const baseContext = (0, generator_1.prepareBaseContext)(parsed.data, {
263
268
  ...options,
@@ -19,8 +19,32 @@ export declare function writeBaseSnapshot(targetPath: string, snapshot: BaseSnap
19
19
  */
20
20
  export declare function hasLocallyEditedFiles(targetPath: string): Promise<boolean>;
21
21
  /**
22
- * Best-effort read of the installed `@postxl/generators` version, used to detect
23
- * generator drift between the snapshot and the current run. Falls back to
24
- * `'unknown'` if it cannot be resolved (drift detection is advisory only).
22
+ * The warning to print when the generator itself changed since the last generation, or
23
+ * `undefined` when it did not (or when either side is unrecorded — drift detection is advisory,
24
+ * so an unknown version is never reported as a change).
25
+ *
26
+ * Takes only the two versions, deliberately. This says something about the *generator*, not about
27
+ * the merge, so it must not be reachable only on runs that reconstruct a base: a clean project
28
+ * skips reconstruction as wasted work, and that is precisely the run where a generator change
29
+ * rewrites every tracked file with nothing else to signal it. Callers print it before any of the
30
+ * checks that decide whether a base is worth rebuilding.
31
+ */
32
+ export declare function generatorDriftNote(params: {
33
+ snapshotVersion: string;
34
+ currentVersion: string;
35
+ }): string | undefined;
36
+ /**
37
+ * Best-effort read of the `@postxl/generators` version that will actually generate, used to
38
+ * detect generator drift between the snapshot and the current run. Falls back to `'unknown'`
39
+ * if it cannot be resolved (drift detection is advisory only).
40
+ *
41
+ * Resolved from `targetPath`, not from this file. The CLI never imports `@postxl/generators`
42
+ * itself — the project's `generate.ts` does, and that is compiled to `<project>/dist/generate.js`
43
+ * and imported from there, so the copy under the *project* is the one whose output lands on disk.
44
+ * A consumer's lockfile may also nest an older copy under `@postxl/cli`; resolving from here would
45
+ * report that one, which generates nothing. Worse, it would be reported on both sides of the drift
46
+ * comparison, so a genuine generator change between two runs would compare equal and the warning
47
+ * would never fire. Falls back to this file's resolution when the project has no copy of its own,
48
+ * which keeps the monorepo and any workspace-linked setup working as before.
25
49
  */
26
- export declare function resolveGeneratorVersion(): string;
50
+ export declare function resolveGeneratorVersion(targetPath?: string): string;
@@ -37,6 +37,7 @@ exports.baseSnapshotPath = baseSnapshotPath;
37
37
  exports.readBaseSnapshot = readBaseSnapshot;
38
38
  exports.writeBaseSnapshot = writeBaseSnapshot;
39
39
  exports.hasLocallyEditedFiles = hasLocallyEditedFiles;
40
+ exports.generatorDriftNote = generatorDriftNote;
40
41
  exports.resolveGeneratorVersion = resolveGeneratorVersion;
41
42
  /**
42
43
  * Base-snapshot management for the generator's three-way (diff3) merge.
@@ -131,17 +132,52 @@ async function hasLocallyEditedFiles(targetPath) {
131
132
  return false;
132
133
  }
133
134
  /**
134
- * Best-effort read of the installed `@postxl/generators` version, used to detect
135
- * generator drift between the snapshot and the current run. Falls back to
136
- * `'unknown'` if it cannot be resolved (drift detection is advisory only).
135
+ * The warning to print when the generator itself changed since the last generation, or
136
+ * `undefined` when it did not (or when either side is unrecorded — drift detection is advisory,
137
+ * so an unknown version is never reported as a change).
138
+ *
139
+ * Takes only the two versions, deliberately. This says something about the *generator*, not about
140
+ * the merge, so it must not be reachable only on runs that reconstruct a base: a clean project
141
+ * skips reconstruction as wasted work, and that is precisely the run where a generator change
142
+ * rewrites every tracked file with nothing else to signal it. Callers print it before any of the
143
+ * checks that decide whether a base is worth rebuilding.
137
144
  */
138
- function resolveGeneratorVersion() {
139
- try {
140
- const require = (0, node_module_1.createRequire)(__filename);
141
- const pkg = require('@postxl/generators/package.json');
142
- return pkg.version ?? 'unknown';
145
+ function generatorDriftNote(params) {
146
+ const { snapshotVersion, currentVersion } = params;
147
+ if (snapshotVersion === 'unknown' || currentVersion === 'unknown' || snapshotVersion === currentVersion) {
148
+ return undefined;
143
149
  }
144
- catch {
145
- return 'unknown';
150
+ return (`Note: @postxl/generators changed since the last generation (${snapshotVersion} → ${currentVersion}). ` +
151
+ `Files it generates differently will be rewritten; any ejected file whose output changed with it ` +
152
+ `has no reproducible ancestor and falls back to a 2-way merge.`);
153
+ }
154
+ /**
155
+ * Best-effort read of the `@postxl/generators` version that will actually generate, used to
156
+ * detect generator drift between the snapshot and the current run. Falls back to `'unknown'`
157
+ * if it cannot be resolved (drift detection is advisory only).
158
+ *
159
+ * Resolved from `targetPath`, not from this file. The CLI never imports `@postxl/generators`
160
+ * itself — the project's `generate.ts` does, and that is compiled to `<project>/dist/generate.js`
161
+ * and imported from there, so the copy under the *project* is the one whose output lands on disk.
162
+ * A consumer's lockfile may also nest an older copy under `@postxl/cli`; resolving from here would
163
+ * report that one, which generates nothing. Worse, it would be reported on both sides of the drift
164
+ * comparison, so a genuine generator change between two runs would compare equal and the warning
165
+ * would never fire. Falls back to this file's resolution when the project has no copy of its own,
166
+ * which keeps the monorepo and any workspace-linked setup working as before.
167
+ */
168
+ function resolveGeneratorVersion(targetPath) {
169
+ const bases = targetPath ? [path.resolve(targetPath, 'noop.js'), __filename] : [__filename];
170
+ for (const base of bases) {
171
+ try {
172
+ const require = (0, node_module_1.createRequire)(base);
173
+ const pkg = require('@postxl/generators/package.json');
174
+ if (pkg.version) {
175
+ return pkg.version;
176
+ }
177
+ }
178
+ catch {
179
+ // Not resolvable from this base — try the next one.
180
+ }
146
181
  }
182
+ return 'unknown';
147
183
  }
@@ -94,6 +94,13 @@ exports.GENERATOR_REGISTRY = [
94
94
  importFrom: '@postxl/generators',
95
95
  defaultOptions: () => `{ useDatabase: true, keycloakComponents: [], useS3: false, useBitbucket: false }`,
96
96
  },
97
+ {
98
+ kind: 'configure',
99
+ name: 'skailify',
100
+ configureFn: 'configureSkailifyGenerator',
101
+ importFrom: '@postxl/generators',
102
+ defaultOptions: () => `{}`,
103
+ },
97
104
  ];
98
105
  /**
99
106
  * Reverse mapping: a top-level call expression in `generate.ts` is matched
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@postxl/cli",
3
- "version": "1.10.2",
3
+ "version": "1.10.3",
4
4
  "description": "Command-line interface for PostXL code generation framework",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -46,8 +46,8 @@
46
46
  "ts-morph": "26.0.0",
47
47
  "zod-validation-error": "5.0.0",
48
48
  "@postxl/generator": "^1.7.2",
49
- "@postxl/generators": "^3.1.1",
50
- "@postxl/schema": "^2.2.0",
49
+ "@postxl/generators": "^3.2.0",
50
+ "@postxl/schema": "^2.3.0",
51
51
  "@postxl/utils": "^1.4.2"
52
52
  },
53
53
  "devDependencies": {},