@postxl/generator 0.53.1 → 0.54.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/generator.js CHANGED
@@ -80,6 +80,8 @@ const types_1 = require("./lib/schema/types");
80
80
  const vfs_1 = require("./lib/vfs");
81
81
  const client_path_1 = require("./prisma/client-path");
82
82
  const parse_1 = require("./prisma/parse");
83
+ // NOTE: This needs to match the constant used in the manager package.
84
+ const GENERATOR_NAMESPACE = 'dynamic';
83
85
  const CONFIG_SCHEMA = zod_1.z
84
86
  .object({
85
87
  pathToDataLib: zod_1.z.string().optional(),
@@ -155,11 +157,17 @@ const CONFIG_SCHEMA = zod_1.z
155
157
  */
156
158
  function generate({ models, enums, config, prismaClientPath, logger, }) {
157
159
  return __awaiter(this, void 0, void 0, function* () {
158
- const root = yield lock_1.LockUtils.findProjectRoot();
160
+ const root = yield lock_1.LockFile.findProjectRoot();
159
161
  if (root == undefined) {
160
162
  throw new Error(`Could not find lock file. Make sure you are running the generator in a project folder.`);
161
163
  }
162
- const vfs = yield vfs_1.ExtendedVirtualFS.fromLockFile(root);
164
+ const vfs = yield vfs_1.ExtendedVirtualFS.fromLockFile({
165
+ root,
166
+ namespace: GENERATOR_NAMESPACE,
167
+ // NOTE: We start with a clean slate every time we generate so we can detect
168
+ // which files were not generated in the last run.
169
+ opts: { clean: true },
170
+ });
163
171
  const generated = new vfs_1.ExtendedVirtualFS();
164
172
  // Generate Models
165
173
  for (const model of models) {
@@ -313,12 +321,12 @@ function generate({ models, enums, config, prismaClientPath, logger, }) {
313
321
  // Flush to disk.
314
322
  // NOTE: We use a special "internal" variable to force regeneration of all files so that
315
323
  // the template files are always up to date.
316
- const FORCE = process.env.POSTXL_FORCE_REWRITE === 'true';
317
- if (FORCE) {
324
+ const FORCE_ENV = process.env.POSTXL_FORCE_REWRITE === 'true';
325
+ if (FORCE_ENV) {
318
326
  console.debug('Forcing regeneration of all files due to POSTXL_FORCE_REWRITE=true!');
319
327
  }
320
- const changes = yield vfs.flush(process.cwd(), { force: config.force || FORCE });
321
- const log = lock_1.ConsoleUtils.getFilesChangelog(changes.filter((c) => !c.static && c.status !== 'skipped'));
328
+ const changes = yield vfs.flush(process.cwd(), GENERATOR_NAMESPACE, { force: config.force || FORCE_ENV });
329
+ const log = lock_1.ConsoleUtils.getFilesChangelog(changes.filter((c) => c.status !== 'skipped'));
322
330
  console.info(log);
323
331
  });
324
332
  }
@@ -27,7 +27,7 @@ import { DbService } from '@backend/db'
27
27
 
28
28
  ${imports.generate()}
29
29
 
30
- import { ActionExecutionFactory, IActionExecution } from './actionExecution'
30
+ import { ActionExecutionFactory, IActionExecution } from './execution'
31
31
  import { Action, ResultOfAction } from './actions.types'
32
32
 
33
33
 
@@ -51,6 +51,7 @@ export class TestDataService {
51
51
  await this.db.WIPE_ENTIRE_DATABASE()
52
52
 
53
53
  // We need to init the user repository first so the root user is created
54
+ this.logger.log('✍ Setting test data')
54
55
  await this.dataService.users.init()
55
56
 
56
57
  this.logger.log('✍ Setting test data')
@@ -11,7 +11,7 @@ const modals_generator_1 = require("./modals.generator");
11
11
  * Generates generic React components for a given model.
12
12
  */
13
13
  function generateReactComponentsForModel({ model, meta }) {
14
- const vfs = new lock_1.VirtualFS({});
14
+ const vfs = new lock_1.VirtualFS();
15
15
  const exports = exports_1.ExportsGenerator.fromRoot()
16
16
  .exportEverythingFromFile('./CreateModal')
17
17
  .exportEverythingFromFile('./EditModal')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@postxl/generator",
3
- "version": "0.53.1",
3
+ "version": "0.54.0",
4
4
  "main": "./dist/generator.js",
5
5
  "typings": "./dist/generator.d.ts",
6
6
  "bin": {
@@ -26,7 +26,7 @@
26
26
  "fast-glob": "3.2.12",
27
27
  "remeda": "1.9.4",
28
28
  "zod": "3.21.4",
29
- "@postxl/lock": "1.1.0"
29
+ "@postxl/lock": "1.2.0"
30
30
  },
31
31
  "devDependencies": {
32
32
  "@prisma/client": "5.8.1",