@rws-framework/db 2.4.2 → 2.4.4

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.
@@ -49,24 +49,7 @@ class DbHelper {
49
49
  }
50
50
  fs_1.default.writeFileSync(schemaPath, template);
51
51
  process.env = { ...process.env, [this.dbUrlVarName]: dbUrl };
52
- // Use npx directly with the full path to prisma
53
- const npxPath = path_1.default.join(workspaceRoot, 'node_modules', '.bin', 'npx');
54
- const prismaPath = path_1.default.join(workspaceRoot, 'node_modules', '.bin', 'prisma');
55
- try {
56
- // Try using npx with the full path
57
- await console_1.rwsShell.runCommand(`"${npxPath}" prisma generate --schema="${schemaPath}"`, process.cwd());
58
- }
59
- catch (error) {
60
- // If that fails, try using the prisma binary directly
61
- try {
62
- await console_1.rwsShell.runCommand(`"${prismaPath}" generate --schema="${schemaPath}"`, process.cwd());
63
- }
64
- catch (innerError) {
65
- // If both fail, try using node to run prisma
66
- const nodePrismaPath = path_1.default.join(workspaceRoot, 'node_modules', 'prisma', 'build', 'index.js');
67
- await console_1.rwsShell.runCommand(`node "${nodePrismaPath}" generate --schema="${schemaPath}"`, process.cwd());
68
- }
69
- }
52
+ await console_1.rwsShell.runCommand(`${this.detectInstaller()} prisma generate --schema="${schemaPath}"`, process.cwd());
70
53
  leaveFile = false;
71
54
  log(chalk_1.default.green('[RWS Init]') + ' prisma schema generated from ', schemaPath);
72
55
  if (!leaveFile) {
@@ -100,11 +83,7 @@ class DbHelper {
100
83
  }
101
84
  static async pushDBModels(configService, dbService, leaveFile = false) {
102
85
  process.env = { ...process.env, [this.dbUrlVarName]: configService.get('db_url') };
103
- const schemaDir = path_1.default.join(moduleDir, 'prisma');
104
- const schemaPath = path_1.default.join(schemaDir, 'schema.prisma');
105
- // Use npx directly with the full path to prisma
106
- const execCmdPath = path_1.default.join(workspaceRoot, 'node_modules', '.bin', 'yarn.cmd');
107
- const execPrismaPath = path_1.default.join(workspaceRoot, 'node_modules', '.bin', 'yarn.cmd');
86
+ const schemaPath = path_1.default.join(workspaceRoot, 'node_modules', '.prisma', 'schema.prisma');
108
87
  await console_1.rwsShell.runCommand(`${this.detectInstaller()} prisma db push --schema="${schemaPath}"`, process.cwd());
109
88
  }
110
89
  static async generateModelSections(model, configService) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@rws-framework/db",
3
3
  "private": false,
4
- "version": "2.4.2",
4
+ "version": "2.4.4",
5
5
  "description": "",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -67,25 +67,9 @@ export class DbHelper {
67
67
  }
68
68
 
69
69
  fs.writeFileSync(schemaPath, template);
70
- process.env = { ...process.env, [this.dbUrlVarName]: dbUrl }
70
+ process.env = { ...process.env, [this.dbUrlVarName]: dbUrl }
71
71
 
72
- // Use npx directly with the full path to prisma
73
- const npxPath = path.join(workspaceRoot, 'node_modules', '.bin', 'npx');
74
- const prismaPath = path.join(workspaceRoot, 'node_modules', '.bin', 'prisma');
75
-
76
- try {
77
- // Try using npx with the full path
78
- await rwsShell.runCommand(`"${npxPath}" prisma generate --schema="${schemaPath}"`, process.cwd());
79
- } catch (error) {
80
- // If that fails, try using the prisma binary directly
81
- try {
82
- await rwsShell.runCommand(`"${prismaPath}" generate --schema="${schemaPath}"`, process.cwd());
83
- } catch (innerError) {
84
- // If both fail, try using node to run prisma
85
- const nodePrismaPath = path.join(workspaceRoot, 'node_modules', 'prisma', 'build', 'index.js');
86
- await rwsShell.runCommand(`node "${nodePrismaPath}" generate --schema="${schemaPath}"`, process.cwd());
87
- }
88
- }
72
+ await rwsShell.runCommand(`${this.detectInstaller()} prisma generate --schema="${schemaPath}"`, process.cwd());
89
73
 
90
74
  leaveFile = false;
91
75
  log(chalk.green('[RWS Init]') + ' prisma schema generated from ', schemaPath);
@@ -135,13 +119,9 @@ export class DbHelper {
135
119
 
136
120
  static async pushDBModels(configService: IDbConfigHandler, dbService: DBService, leaveFile = false){
137
121
  process.env = { ...process.env, [this.dbUrlVarName]: configService.get('db_url') }
138
- const schemaDir = path.join(moduleDir, 'prisma');
139
- const schemaPath = path.join(schemaDir, 'schema.prisma');
140
-
141
- // Use npx directly with the full path to prisma
142
- const execCmdPath = path.join(workspaceRoot, 'node_modules', '.bin', 'yarn.cmd');
143
- const execPrismaPath = path.join(workspaceRoot, 'node_modules', '.bin', 'yarn.cmd');
144
122
 
123
+ const schemaPath = path.join(workspaceRoot, 'node_modules', '.prisma', 'schema.prisma');
124
+
145
125
  await rwsShell.runCommand(`${this.detectInstaller()} prisma db push --schema="${schemaPath}"`, process.cwd());
146
126
 
147
127
  }