prisma-laravel-migrate 0.2.7 → 0.2.9

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.
@@ -7,7 +7,7 @@ import { spawn } from "child_process";
7
7
  import * as dmf from "@prisma/internals";
8
8
  import { loadConfig } from "../utils/config.js";
9
9
  // utility: load/merge ALL *.prisma files under prisma/ (schema first, then the rest)
10
- async function loadMergedDatamodel(schemaPrismaPath) {
10
+ export async function loadMergedDatamodel(schemaPrismaPath) {
11
11
  const schemaDir = path.dirname(schemaPrismaPath);
12
12
  const entries = readdirSync(schemaDir).filter(f => f.endsWith(".prisma"));
13
13
  const order = [
@@ -18,7 +18,7 @@ async function loadMergedDatamodel(schemaPrismaPath) {
18
18
  return chunks.join("\n\n");
19
19
  }
20
20
  /** extract our generator blocks' configs right from the datamodel */
21
- async function getLaravelGeneratorConfigs(datamodel) {
21
+ export async function getLaravelGeneratorConfigs(datamodel) {
22
22
  const sdk = dmf.default ?? dmf;
23
23
  const { generators } = await sdk.getConfig({ datamodel });
24
24
  const findCfg = (provider) => (generators ?? []).find((g) => (g.provider?.value ?? "") === provider)?.config ?? {};
@@ -1,6 +1,6 @@
1
1
  import { PrismaTypes } from "../migrator/column-maps.js";
2
2
  import { buildRelationsForModel } from "./relationship/index.js";
3
- import { isForModel, listFrom, parseSilentDirective } from "../../utils/utils.js";
3
+ import { getConfig, isForModel, listFrom, parseSilentDirective } from "../../utils/utils.js";
4
4
  /**
5
5
  * Build ModelDefinition[] + EnumDefinition[] from your DMMF.
6
6
  */
@@ -14,6 +14,7 @@ export class PrismaToLaravelModelGenerator {
14
14
  // 1) Extract all Prisma enums into EnumDefinition[]
15
15
  const enums = this.dmmf.datamodel.enums.map((e) => ({
16
16
  name: e.name,
17
+ namespace: getConfig('model')?.namespace ?? 'App', // filled in by printer
17
18
  values: e.values.map((v) => v.name),
18
19
  }));
19
20
  // 2) Build each ModelDefinition
@@ -157,6 +158,7 @@ export class PrismaToLaravelModelGenerator {
157
158
  tableName: model.dbName ?? model.name,
158
159
  guarded,
159
160
  properties,
161
+ namespace: getConfig('model')?.namespace ?? 'App', // filled in by printer
160
162
  relations,
161
163
  enums,
162
164
  interfaces,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prisma-laravel-migrate",
3
- "version": "0.2.7",
3
+ "version": "0.2.9",
4
4
  "description": "Generate laravel migrations and/or models using prisma files",
5
5
  "bin": {
6
6
  "prisma-laravel-migrations": "./dist/cli/migrator.index.js",
package/stubs/enum.stub CHANGED
@@ -1,6 +1,6 @@
1
1
  <?php
2
2
 
3
- namespace App\\Enums;
3
+ namespace ${enumDef.namespace}\\Enums;
4
4
 
5
5
  enum ${enumDef.name}: string
6
6
  {
package/stubs/model.stub CHANGED
@@ -1,6 +1,6 @@
1
1
  <?php
2
2
 
3
- namespace App\\Models;
3
+ namespace ${model.namespace}\\Models;
4
4
 
5
5
  ${model.imports.join('\n')}${model.extends && model.extends !== 'Illuminate\Database\Eloquent\Model'
6
6
  ? ''